I'm using private upload on several sites and can confirm that this works.  So no need to file a bug issue.

  At this stage I imagined that these settings would cause an uploaded file to go inside the ../private directory. Nope, instead they go into public directory sites/default/files. Was my assumption wrong?

No. This is indeed what should have happened.

So just to make sure, I set up a site to your exact specifications. I.e. with Drupal root in /demo/drupal and the private directory in /demo/private  (where / is the Unix file system root).

I first tested it using the absolute path (i.e. /demo/private as the private upload directory).  That worked without a glitch.

I then re-tested it using the relative path to the same directory (i.e. ../private).  That also worked without a glitch.

I also noted that Drupal threw the following error if I tried to input a non-existing directory as the private upload directory:

Warning: mkdir(): Permission denied in drupal_mkdir()
 (line 2341 of /demo/drupal/includes/file.inc).
 The directory /demo/bogus does not exist and could not be created.

In other words: If Drupal allow you to use ../private as the private upload directory without throwing this error, your setup should work for private upload.

Drupal will automatically place a .htaccess-file in the private upload directory to protect it against  prying eyes.  However, for best security, the private upload directory should be above the web-root.

PS: As for the file being "served merrily to an anonymous user", this will happen if the anonymous user is granted access to the node the privatly uploaded file it attached to.

All that the "private download method" does, is to extend Drupal's access control system so that files attached to nodes are made inaccesible to those who happen to know their URL.  It does so by pretending that the attachement is stored in the fictitious directory (system/files/).  Since this directory does not exist, bypassing Drupal by converting the path into an URL and requesting it directly from the web server will not work.

This is different from, and more secure than the "public download method". This method let those who know a file attachement URL bypass Drupal's access control.


Update a single field when saving an entity

Give a try with field_sql_storage_field_storage_write.

See this blog post with an example:

//Get the id of your field
$name = 'name_of_your_field';
$info = field_info_field($field_name);
$fields = array(info['id']);

//Execute the storage function
field_sql_storage_field_storage_write('model', $entity, 'update', $fields);


Change quantity of product kit based on attribute

It seems that - against the official docs of ubercart - the hook hook_uc_cart_alter IS available for Drupal 7.

Found the answer here on Drupal Answers in an old question: https://drupal.stackexchange.com/a/94497/53491

With the available $items-object I iterate through my cart as I need it. Works perfect.


Internationalization and pay.nl does not seem to work properly together, any idea how to fix that one?

Your problem might be because of the "Language negotiation" configuration.

So check this configuration, which in D6 you can find via /admin/settings/language/configure/language. Experiment with the 4 available options in the Language negotiation selection list, to see if any of these options solve your issue.


Its similar to any other entity on Drupal 8

$name = $terms[0]->name;

//simple text field
$color = $terms[0]->field_color->value;

//multivalue field - get array of values
$color = $terms[0]->get('field_color')->getValue();

//entity reference field
$entity = $terms[0]->field_color->entity;

//image field
$image = $terms[0]->get('field_image')->entity;
$image_uri = $image->getFileUri();

//get color entity id
$entity_id = $entity->id();

I think at least your color field is actually an entity reference


Create a views page and list all food results with a contextual filter on the unique id. Give it a path with a wildcard % . In another block or page list the man names. Include the unique id and put that field on top and exclude it from display. Rewrite the output of the name as a link to the views path but replace the wildcard with the token of the unique id.


How do I load a library using xautoload and libraries?

It was calling the wrong composer.json. Facebook api has it's own.

The fix is

$adapter->composerJson('vendor/facebook/graph-sdk/composer.json');


Cannot use drupal_set_messages in a custom controller module

You might want to try

return array(
  '#theme' => 'ctr',
  '#myvar' => 'myvalue',
);

And then define a hook_theme.

/**
 * Implements hook_theme().
 */
function ctr_theme($existing, $type, $theme, $path) {
  $variables = array(
    'ctr' => array(
      'template' => 'cntr',
      'variables' => array(
        'myvar' => 'defaultvalue',
      ),
    ),
  );
  return $variables;
}


Move only jQuery UI Tabs load in footer in Drupal 7

Try using the following code.

drupal_add_js(drupal_get_path('theme', 'youthemename').'/js/jquery.easing.1.3.js', array('type' => 'file', 'scope' => 'footer'));


I use the Commerce Sale Price module with great success on my website. It is easy to configure. Just install and enable then you can set the discounts on the product pages.

Update: I think you could use Commerce Coupon to achieve your results. The coupons can be automatically applied based on a role. Sorry I did not understand your question fully before. Also, I have not used this module but the description appears to do what you want.


Keep getting "Bad request" messages in browser after adding JS

Finally found the solution to my problem, in case anyone else makes the same mistake.

The problem with my cookie is this line from the code above:

var cookieName = 'Drupal-quicktabs-active-tab-id-' + wrapperID + 'nid='+ nid;

Cookie names cannot contain equal characters (or spaces, commas, semi-colons etc). That will create errors. So i simply changed "=" to "-" in my code line above, and the errors went away.


This is the expected behavior if page.tpl is missing:

Since your theme does not print anything in page, the Core system module (the one that defines page.tpl.php etc) takes over and drupal uses system's page.tpl.

I suppose that if page.tpl is empty the default page array is rendered with any region that exists in your theme's.info and has content.If regions exist, Drupal will try to render them even without template.


Ultimate Cron Background Process Taking a Long Time

I think we need to check from start to end point. This issue is like some processes which takes more time to execute. So we need to check what is that process and we can find that using Elysia Cron plugin.

This plugin helps you to find which cron process has taken much time and where to take possible actions.

PS: If this stuff helps you please leave me a comment and support :)

Thanks!


Drupal Views field handler: how to unserialize an additional field data?

The views data can be altered in the handler's render() method.

  function render($values) {
    $values->commerce_line_item_data = unserialize($values->commerce_line_item_data);
    return '<!--form-item-' . $this->options['id'] . '--' . $this->view->row_index . '-->';
  }


Taken from: here

You need to make sure that drupal/core is in the require part of your composer.json and not the replace part, it won't work otherwise.

Haven't tested it yet, but it explains the Package "drupal/core" listed for update is not installed. Ignoring. message.

In case someone's looking for the way to upgrade using drush:

drush up drupal


You can do this by using any of below modules :

Megamenu

  Mega menus are a type of drop-down, which seeks to overcome some of
  the usability drawbacks to traditional style drop-downs.

Bigmenu

  THIS MODULE attempts to replace the all-in-one global tree view with a
  similar interface, but sub-trees are "collapsed" below a certain
  level, and can be expanded as needed.

TB Mega Menu

  TB Mega Menu allows you to create a mega menu with an innovative
  back-end user interface and synchronized with Drupal core menu.

OM Maximenu

  That is now possible by using OM Maximenu which can create menus with
  all other module blocks you want as attachments, modules like views,
  slideshow, menu, user, nice menus, quicktabs, and custom blocks with
  tables, lists, images, videos, etc.

Superfish

  Superfish integrates jQuery Superfish plugin with your Drupal menus.

Menu Views

  Allows menu items to render views instead of links. This is useful for
  creating "mega-menus".

MuchoMenu

  This module allows users to create mega menus that have mini panels as
  their flyout content. The benefit is that ANY type of content or UI
  can be added to the menu flyouts.


Will managed files be deleted if no corresponding entry exists in file_usage?

Drupal automatically deletes temporary files in system_cron().

Permament files which have no file_usage are not deleted, however.


The content id is missing from your function call you have to add it like this

{{ drupal_view('who_s_new', 'block_1', arg_1, arg_2, arg_3) }}

or you can render your view in custom block and add it in every page via 'block layout'

https://www.webwash.net/programmatically-create-block-drupal-8/

$view = views_get_view('view_name');
$view->set_display('view_block_name');
$view->set_arguments(array($tid));
// change the amount of items to show
$view->set_items_per_page(4);
$view->pre_execute();
$view->execute();
$view->render();


How to make content translation available for front page?

The relative URL to display as the front page is specified within admin/config/system/site-information . If you want to be able to specify a value for it that is different for each of the site's languages, make sure you have made it a "multilingual" variable (it should say "This is a multilingual variable.") in the description of that variable on that page.

Refer to the community documentation about Variable translation for details about how to translate text and settings that are stored in Drupal as variables. Here is a quote from that page:

  The Variable translation module, part of the Internationalization (i18n) package, allows you to translate text and settings that are stored in Drupal as variables. These variables include text such as 'site name' and 'site slogan', as well as settings like 'Default front page' and 'Default 404 page'.

The Variable translation module has a dependency on the Variable module.

And these are the specific steps required to make a variable multilangual (mentioned on that community page):

Enable the Variable translation module included with the Internationalization package
Go to Administration > Configuration > Regional and language > Multilingual settings
Click on the Variables tab
Select the variables that will be multilingual
Click Save configuration button

Obviously, in this case in step 4 the variable to be selected is "Default front frontpage", within "Site information".

Finally, this is what remains to be done (another quote from that same page):

  Once you have the correct settings, they'll be marked with "This is a multilingual variable" when you go to the corresponding administration pages (Figure 2). You must switch the site language while in the administration pages to set the variables for each language. A language switcher link will appear at the top of each administrative page that has multilingual variables.

"That's all" what's needed to specify a language specific value for the frontpage of your site ...


Taxonomy child terms as Select options in CCK form

For this you can add a term reference field and use the full vocab. Then you will need to do a form alter hook in one of your custom module and filter out options based on logged in user.


Any solution to use two different $base_url's for drupal 7

Rather than trying to change the base_url manually you might be better using something like https://www.drupal.org/project/domain or Drupal's language translation system and having 2 domains setup and the content shared for both domains.

So they effectively will look and act the same but the base url for drupal will be whatever the user is currently on. Then you could use these modules inbuilt hooks if you wanted to force a user ontop a specific domain based on their IP or whatever


Simple debug results in internal server error

Hi!! you can use a official symfony dumper, insert this line on the file "composer.json"

"require-dev": {
    "symfony/var-dumper":"3.0.4"
  }

run the follow command:

composer install "symfony/var-dumper"

or

composer update

you can use in your code with these line:

dump($variable_name);

enjoy!!! ;)


How to find the ID of a views block that is not assigned to a region?

you can edit that view, move your mouse on the "block" that you need to analyze and see the url.Like this one:

http://mydomain.ext/admin/structure/views/view/flag_bookmarks/edit/page_4

The last url path is the page id: page_4.
In your case all start with "block_".


Limit duration (length / time) of Uploaded Video

You can't do that at the moment, but you can set up your presets to limit the length of the transcoded video. I hope that is sufficient for you.


Creating paragraph entities and adding to a node

I have a similar function and would recommend that if you already know what language your node is, you capture it from the node and use it for the language in the paragraph field. I only had 1 language to worry about but you could easily replace LANGUAGE_NONE('und') with the appropriate language code from the node.

$paragraph = new ParagraphsItemEntity([
  'field_name' => $host_field_name,
  'bundle'     => $para_bundle,
]);
$paragraph->is_new = TRUE;
$paragraph->setHostEntity('node', node_load($this->node->nid));
$paragraph->field_long_text[LANGUAGE_NONE][0]['value'] = $field_content;
$paragraph->field_long_text[LANGUAGE_NONE][0]['format'] = 'wysiwyg';
$paragraph->save();


How to create a view using the References module?

You could achieve your goal by building two views

The first is the view you have build with relationship to politicians content type, Add new field gets the politician id tagged in that video

The second is a view that gets videos for politicians ids sent as a contextual filter

  that accepts multiple values by checking that checkbox as in the picture

Install  that module views field view that enables you to embed a view inside another view as a field

Add new field in the first view that embed the second view and send the politicians ids as tokens to that view

Now you could achieve your goal


Custom home page not recognized by system

There are two separate issues at play here, which is where you are getting confused.

1) page--front.html.twig - this is a template suggestion for the page theme hook. This can be seen by the double-hyphens that follow page. The page theme hook is used to wrap the content of every page on the site, using the page.html.twig template. Drupal's theme layer allows for creating suggestions for templates that take precedence over the base template. In this case, when on the front page, the site looks for page--front.html.twig, and if it finds this file, it uses it. You have created this file. However, you'll notice I said this template wraps the current page content. That leads to:

2) Page content. 'Pages' on Drupal show content if a page has been assigned to the given path. However, if a user goes to a path that doesn't exist, they get the 'page not found' page. This page is wrapped by page.html.twig, just like any content page.

When you go to /front, you see page not found, because you have not created a page at that path yet. You've only created a template for the front page, whatever that may be (even if that ends up being page not found).

You can test this by creating a new node, and setting the path to be /front (note - you'll need appropriate permissions for this). Then set the site front page to /front, and your template will be picked up.


How do I add a block of JavaScript to the home page only?

If by home page you mean the front page, then you can implement hook_preprocess_page() in a custom module.

function mymodule_preprocess_page(&$variables) {
  if ($variables['is_front']) {
    drupal_add_js(drupal_get_path('module', 'mymodule') . '/mymodule.js');
    $variables['scripts'] = drupal_get_js();
  }
}

The same code works on Drupal 7, as $variables['is_front'] is set in _template_preprocess_default_variables() (called from template_preprocess()), using the following code.

  // drupal_is_front_page() might throw an exception.
  try {
    $variables['is_front'] = drupal_is_front_page();
  }
  catch (Exception $e) {
    // If the database is not yet available, set default values for these
    // variables.
    $variables['is_front'] = FALSE;
    $variables['db_is_active'] = FALSE;
  }

The reason of calling drupal_add_js() first, and then drupal_get_js() is that, in the case another module that is executed after would run the following code, the JavaScript file would still be added.

function quite_a_different_module_preprocess_page(&$vars) {
  drupal_add_js(drupal_get_path('module', 'quite_a_different_mymodule') . '/quite_a_different_module.js');
  $vars['scripts'] = drupal_get_js();
}

Using drupal_add_js(), the file will be added to the output returned from drupal_get_js().


Enable users to view their own profile, without enabling "View user profiles"

You could do this with a custom rule, as follows:

{ "rules_users_view_own_profile_only" : {
    "LABEL" : "Users View Own Profile Only",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "user_view" ],
    "IF" : [
        { "NOT user_has_role" : { "account" : [ "site:current-user" ], "roles" : { "value" : { "3" : "3" } } } },
        { "AND" : [] },
        { "NOT data_is" : { "data" : [ "site:current-user:uid" ], "value" : [ "account:uid" ] } }
    ],
    "DO" : [ { "redirect" : { "url" : "http:\/\/www.yourdomain.com\/denied" } } ]
    }
}

That basically checks to make sure the user isn't an admin or on his own account page before directing to yourdomain.com. If you use the CustomError module, you can redirect to an access denied page.

You might also want to check out the Edit own user account permission module - you might be able to enable that and disable "View user profiles" and get the results you want, although I haven't tried that.


Use hook_cron() to check the value of that field when cron runs and fire off an email with drupal_mail_system() if the value meets your criteria.


Drupal always creates its own URL aliases, even when I tell it not to

I've just had the same issue. I found the reason why it was behaving like that, so I thought I would post the answer here for others with the same problem.

You need to go to Path Settings --> Section "While Updating" (I don't know the exact wording in English as I have the PT version).

Here, you have to select the first option: Do nothing. Keep the old alternative path.

This should solve your question. :-)


I have a tab in mysite.com/user which I don't know where it's coming from?

Its coming from the webform module.  I believe if you turn off the ability to allow users to view previous submissions it will go away.


How to add directions with a link to a webform in Drupal 7

I'd recommend creating a custom module and using hook_form_alter() as shown in this example.

You can add a form element of type #markup to add custom html in your form. And set the #weight to a low number, -50 for instance, for your markup element to show at the top.


Placing a menu based on a page’s taxonomy

If you will put more blocks based on taxonomies or maybe for certain content type i would recommend the context module:

http://drupal.org/project/context

With context you can set conditions with a friendly UI  for display blocks in your drupal instalation.


Can I migrate content to non drupal sites

It's probably better to try to go directly from one system into another. Placing Drupal in the middle is likely to add complexity to your migration strategy. But hey, if you find that it solves some issues that your migrations face, then I see no reason why it can't be done.


Batch removal of users and comments without causing excess load on server

Try setting up a View with VBO.

Add a new users view
Add a bulk operations field to the view
Add a "Delete item" operation to the field settings
Configure the field settings to process "1" per batch
Add any other required exposed filters.

That will delete one user per batch run until finished, so should be fine on your server.


How to use user wildcard in a custom path?

You've picked user_load as your wildcard's load function - that takes an ID, and loads a user object. Your requirement is to load by username, which will work differently.

A function ending with _load doesn't exist for that, so you'll have to create your own:

$items['user/%MYMODULE_user_name/job'] = array(
...

function MYMODULE_user_name_load($name) {
  return user_load_by_name($name);
}


Different permissions after node publishing

I resolve this with small custom module. I checking user role as well because I need to apply this only on one role.

There is my code:

/**
 * Implements hook_node_access().
 */
function MODULE_node_access($node, $op, $account = NULL) {
    global $user;
  if (
    // The $node argument can be either a $node object or a machine name of
    // node's content type. It is called multiple times during a page load
    // so it is enough if you perform the check once you get the object.
      is_object($node) && array_key_exists(6, $user->roles) &&
      // Operation on which you want to act: "create", "delete", "update", "view".
      ($op == 'update' || $op == 'delete')
  ) {
    // Check if the node is published.
    if ($node->status == 1) {
      return NODE_ACCESS_DENY;
    }
  }
}

My role's ID is 6, so I used this part array_key_exists(6, $user->roles) because of that.


How can I 'trim' the users returned by a user reference fields' autocomplete widget?

You can use hook_form_alter() to provide your own autocomplete path. After that you can code it just like if you were creating brand new autocomplete field. Examples for developers module contains pretty solid autocomplete example, use it as a reference.


If you don't need to have filters or sorting or other view related things interacting with books or classes then I would set the view up to not display fields and use relationships, etc. Rather I'd configure it to display a view mode of the Student. Then do all display configuration for what should appear about the student in that view mode. I find using view modes, vs configuring fields directly in the view, to be an easier way to configure views in most scenarios. Plus if you need to display the same information somewhere else, it's much easier to re-use the view mode vs having to re-configure a view.

In your view, instead of showing fields, show Content and then choose a view mode of your Student. (You can create new view modes at /admin/structure/display-modes/view or Manage > Structure > Display Modes > View Modes in the admin menu.)

Then update your Student view mode via the manage display to show whatever student content plus the classes field. Configure your classes field to, again, show a particular view mode.

Then update your Classes view mode to show whatever content you want to display about the class plus the books field (not sure if you'd want to show just the label or again another view mode).


Can I suggest a slightly different strategy? If you have the Rules modules installed - or are willing to install it - then can use a Rules condition to apply the specific test you want. If it passes that test, you can get Rules to set a field on your node that Context can respond to.

So, for example, you could have a Term reference on your content type that has three vocabulary items 'YouTube', 'Image', 'Empty'. Rules can set this field whenever the node is saved. And Context is able to respond differently depending on the Taxonomy Term that is present.

A downside is the user gets to see the Term reference field when entering data, but since it's changed to the right value on save anyway, this may not be a big deal. You can tell the user to ignore this on the form and hide it away, e.g. in a closed fieldset. Or if you are a Display Suite user, you can easily hide using configuration.

I've tested whether Rules can pick up the media type and can confirm it does so quite cheerfully. To start the process, add a new rule and choose React on event with the type 'Before saving content'. Supposing you have a field on your content type with the machine name field_media, then you will need to use a Data comparison condition that checked [node:field-media:file:mime] to see if it is equal to video/youtube or image\png etc. You may need to do a bit of fishing to get out all the relevant mime types. You'll then need to create an appropriate action when the condition is true. You'll probably want several rules bundled together in a Rule set.

A single condition will look a bit like this:

If you've not used Rules before, it can be a bit fiddly to set up the first couple of times, but well worth it. Knowing that it can detect the condition that is of interest to you, means that this is a solution that you can make work.


The screenshot is a render element of a link which gets printed in the template completely. What you find inside is for internal usage and is most times protected anyway.
To get this request parameter in your template build your own variable in preprocess:
$variables['path_info'] = \Drupal::request()->getPathInfo();

You might also need to add a cache context if your template depends on this information:
$variables['#cache']['contexts'][] = 'url.path';

Then print it in Twig:
{{ path_info }}

This is the general approach. In this specific case if you are interested in the current path (including the base path) then you could simply use a Twig function:
{{ path('<current>') }}


how to add table tr using ajax_command in drupal 7

The HTML wrapper you will be replacing sounds like it includes the whole table, so when you return the markup for the new table row, it will replace all the content in that selector/wrapper. You need to include the markup for your whole table including the newly added row, not just the new row.


D7 Views 3: Filter by relationship based on nid and uid

I ended up achieving the result that I wanted with hook_views_query_alter:

function site_views_query_alter (& $view, & $query)
{
  if ('block_3' == $view->current_display) {
    $account        = SiteUser::loadByID(arg(1), TRUE);
    $query->where[] = array(
      'conditions' => array(
        array(
          'field'    => 'node.nid',
          // Return just the IDs
          'value'    => SiteContest::getContestsPlayedBy($account, TRUE),
          'operator' => 'in',
        ),
      ),
      'args'       => array(),
      'type'       => 'AND',
    );
  }
}


Where is the best place for cache bins (Drupal 7)?

First, cache tables is a term specific for a relational database, the generic term is cache bin or simply cache.

This is quite a big question but I can try to give you some hints...

Memcache

The memcached backend for Drupal 7 was rather buggy until very recently, but a lot of issues were fixed recently (some by me, more by catch) and it should work fine now. Memcache allows to have multiple cache servers, it is very fast.

MongoDB

I can't say much about this, haven't used it as a cache backend. Not as fast as Memcached, but might get interesting in the feature, as it will provide native support for the upcoming cache tag API (which will only be part of Drupal 8).

APC

Probably the fastest solution because the cache is read directly from memory within the same process. However, I've had stability issues in the past when using this as the cache, it doesn't allow to store that much data (as it blows up the apache processes memory-wise) and it gets problematic once you have multiple web servers (because you can't clear the cache on the other servers).

Filecache

Slower than Memcache/APC but allows to store large amounts of data. I'd look into it if your caches start to get too big for memcache.

My recommendation: Memcache

Note that some cache tables (cache_update) can't be moved out of the database, because they're not a real cache and use separate API functions and some others should be kept there too (cache_form: again not a real cache, must not be cleared as it contains information about built forms including their data)


You're mixing a couple of different things there :)

The resource returned from db_query() can be iterated over directly, there's no need for an intermediary function. The resource isn't the same as one that would be returned from mysql_query(), as the Drupal database layer wraps around PDO.

This is the standard way to iterate over db_query() results:

$result = db_query("SELECT nid FROM node WHERE type ='emp'");

$storeArray = array();
foreach ($result as $row) { // An object is returned by default
  $storeArray[] = $row->nid;
}

However, the db layer also has a handy shortcut method called fetchCol() that will fetch the results of the query's first column into an array. So you can simplify your code to a single line:

$storeArray = db_query("SELECT nid FROM node WHERE type ='emp'")->fetchCol();


It's a bit unusual request, but if you want to clear main menu from ul anl li tags and print just links, you can do that in this way:

template.php

/**
 * Main menu
 * Implements theme__menu_tree().
 */
function YOURTHEME_menu_tree__main_menu($variables) {
  return $variables['tree'];
}

/**
 * Main menu
 * Implements theme__menu_link().
 */
function YOURTHEME_menu_link__main_menu(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $element['#localized_options']['html'] = TRUE;
  $output = l('' . $element['#title'] . '', $element['#href'], $element['#localized_options']);
  return $output . $sub_menu . "\n";
}

go to admin/structure/block and place main menu in header region (or wherever you want)

Result

Link1
link2


Is there a way to set two separate views with exposed filters in a panel page?

yes . you can show exposed filters in a block. See you view, on right hand side under Exposed form Caption. here you can put yes for Exposed form in block:No.
Now your filters are available in a separate block.


Australian payment gateway adapter for Pay API

There are a few modules floating around for commerce, CiviCRM and Ubercart that use eWay, they would be good basis.


First thing you should be aware of, is that you probably don't want to expose the roles to the user during registration, at least not all of them. If you do, then any user would be able to create an admin account, and gain access to the backend.

You can't easily make different registration forms, but you can instead create a multi step form. Step one would be general user information where the user selects which role / type of user to create. The second step would have unique fields depending on the role selection.

The example module has a lot of great examples including how to create multi-step forms.


Roles are not correct while getting it in hook_user

The variable $account already has the loaded user object. Calling $account->roles will give you an array of roles.


Create a dynamic Tabbed View from Group By


Adding node edit links to a views block display?

There is a field called Node :Edit link which can be added to the fields and it will give you the edit link. This also respects the permissions that is it would only be shown to those who have permission to edit a post.


@Clive was spot on... Better Formats does exactly what I wanted.


Don't calculate shipping for specific item

From the screenprint of your calculation rule it's hard to tell what exactly the logic is that you implemented (an exported rule, created with the Rules UI, provides ALL the details).

Anyway, it seems that your Rules Loop is adding "an amount to the unit price" for EACH line item, so it doesn't check (within that Rules Loop) if it is "Physical" or "Digital", which explains why for Digital items shipping gets calculated also (which is not what you want).

The easiest way to correct this, is to use the Conditional Rules module to add an extra test (Rules Condition!) within your Rules Loop to NOT calculate shipping for Digital items (AND remove all Rules Conditions starting from the "AND" you added). As a variation (to not have to use this extra module), transform the 2 Rules Actions within your loop to an equivalent Rules Component (by passing the line-item as a parameter), and within that Rules Component add an extra Rules Condition to check ... indeed ... if it is a Physical item.

Update 1

As per the update that was applied to your question (by adding your improved rule using the Conditional Rules module I suggested before), it seems that you've for sure not correctly used that module. Because the CONDITIONAL near the end of your exported rule is NOT supposed to be empty. Therefor have a look at this variation of your exported rule (if needed, just import it in your own setup to look at it with the Rules UI):

{ "rules__1_extra_not_for_digital" : {
    "LABEL" : "+1$ extra not for digital",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [
      "rules_conditional",
      "rules",
      "commerce_line_item",
      "commerce_shipping"
    ],
    "ON" : { "commerce_shipping_calculate_rate" : [] },
    "DO" : [
      { "LOOP" : {
          "USING" : { "list" : [ "commerce-line-item:order:commerce-line-items" ] },
          "ITEM" : { "list_item" : "Current list item" },
          "DO" : [
            { "CONDITIONAL" : [
                {
                  "IF" : { "data_is" : { "data" : [ "commerce-line-item:type" ], "value" : "product" } },
                  "DO" : [
                    { "data_calc" : {
                        "USING" : { "input_1" : [ "list-item:quantity" ], "op" : "*", "input_2" : "100" },
                        "PROVIDE" : { "result" : { "result" : "Calculation result" } }
                      }
                    },
                    { "commerce_line_item_unit_price_add" : {
                        "commerce_line_item" : [ "commerce_line_item" ],
                        "amount" : [ "result" ],
                        "component_name" : "flat_rate_flat_rate",
                        "round_mode" : "0"
                      }
                    }
                  ]
                }
              ]
            }
          ]
        }
      },
      { "commerce_line_item_unit_price_subtract" : {
          "commerce_line_item" : [ "commerce_line_item" ],
          "amount" : "100",
          "component_name" : "flat_rate_flat_rate",
          "round_mode" : "0"
        }
      }
    ]
  }
}

Note these changes I applied as compared to your exported rule:

The CONDITIONAL is to be contained within your Rules Loop (not after it).
Within that CONDITIONAL, I added some other condition. And only if that condition is satisfied, the 2 Rules Actions (as in your own exported rule) are to be executed.
Attention about that "some other condition": the actual condition I added is for sure not correct yet to make it match your question, so make sure to rework that to fit your case (I just added this condition here to show how to use that CONDITION statement).

Additionally, I'm not sure (actually I doubt) if the very last Rules Action in my updated Rule is still correct. Because you'd only want to do that subtract again if the very first line item actually did pass the test about CONDITION. But after you understand how to use the Conditional Rules module, I'm sure you'll get that part fixed also.

Update 2

Yet another update, as per this additional comment you added after I added my "update 1":

  I can't find my term field in Data Comparison to select if product is Digital or Physical

That is not a surprise (at least not to me), because think about what kind of data about a product are available when processing a "line item" (inside a Rules Loop in this case here) ... No panic, because if it is not available, you can make it available, similar to what is explained in my answer to "How to access commerce_product field of line-items using Rules to flag the Commerce Product?" ...

Here is a blueprint of what you need to do (to further improve your rule):

Create a Rules Component, similar to the Rules Component of Step 1 in my related answer, just an import of that Rules Component should be enough (to get started and further improve it as detailed below).
Execute that Rules Component inside your Rules Loop of the rule you already have. But make sure to do so BEFORE the "CONDITIONAL" Rules Action.
Move the "CONDITIONAL" Rules Action (and everything inside of it) to the Rules Actions of the new Rules Component you need to create. Make sure to place them AFTER that Rules Action (in the Rules Component) that performs "Fetch entity by ID". At that point you should have access to your field to indicate "if product is Digital or Physical" (because of the "Fetch entity by ID").
Make sure that in that new Rules Component you also add a "Provided" variable (= value returned by the Rules Component to the calling Rule), which actually will, in the end, contain the "Calculation result" (BTW, result is a terrible variable name, hard to know what it is about). And it is that Calculation result that is what your main (further improved) rule should calculate, right?


How do I Pass a Nid to a webform and create a token for a different field on that node?

How many teams are there?

If not too many, you could set up categories in your site contact form in admin/structure/contact that represent each team then pass the team name to the contact form, thus not exposing the email address.


How to programmatically set a custom field?

Use the Entity module wrapper.

  The entity API provides some wrapper classes you may use to easily deal with entities and to leverage the entity property information modules provided. With the help of the wrappers you can access the property information, loop over known properties, or just get/set the described data values, etc.

Install the Entity module and do something like:

$user = user_load($GLOBALS['user']->uid);
$obj = entity_metadata_wrapper('user', $user);
$obj->field_custom = $lead_id;
$obj->save();

$GLOBALS is http://php.net/manual/en/reserved.variables.globals.php


jQuery error "C is undefined" while making ajax call for pagination

Finally I fixed it. But I think there should be better way of doing that. All I did was, I added latest jQuery file from Google CDN in the module itself as it was clashing with Drupal 6 dynamically added jQuery 1.2.x and giving me error.

 drupal_add_js(drupal_get_path('module', 'my_module') . '/my_module.js');

I used some ajax calls for pagination, due to which old jQuery was giving me an error. It is fixed with newer version of jQuery. I also tried http://drupal.org/node/1058168 but it was also not useful.

Please suggest if there is any better way of doing the same.


Menu view does not render when editing profile2 profile

The issue here ended up being that Drupal considers the page where a user edit's his profile in Profile2 an "admin" page. And, as of this writing, menu_views.module (line 159) does not process menu views on admin pages. This has been reported to the module in the form of re-opening http://drupal.org/node/1790444.

Hopefully this helps somebody else as this was a very tough one to trace down.


How to showing Created time in node teaser?

To print date add this <?php print date('d M Y', $node->created); ?>

The output of this will be something like: 12 Dec 2014.

You can change 'd M Y' part for different output, take a look at date() function.


Is it possible to have pre-load elements in webforms?

You could pre-load the elements in a hook_ENTITY_TYPE_create hook:

mymodule.module:

  /**
   * Implements hook_ENTITY_TYPE_create() for webform entities.
   */
  function mymodule_webform_create(\Drupal\webform\WebformInterface $webform) {

    $elements = [
      'name' => [
        '#type' => 'textfield',
        '#title' => 'name',
      ],
      'other' => [
        '#type' => 'textfield',
        '#title' => 'other',
      ],
    ];

    $webform->setElements($elements);
  }


A drupal.org groups comment shows examples how to allow use of multiple tpl.php file versions.

Using

<?php $vars['template_file'] ?>

it is possible to create your own template file suggestions.

Example:

function phptemplate_preprocess_page(&$vars, $hook) {

  if($vars['language']->language == 'bg') {
    $vars['template_file'] = 'page-bg';
  }
}


Moving "vendor/" in a different location and symlinking it breaks drush

I managed to solve it via specifying an absolute path in the vendor-dir configuration of composer.json: https://getcomposer.org/doc/06-config.md#vendor-dir


Wrap teasers in a div (simple taxonomy page, no views)

Using template.php and hook_preprocess_page()

function THEMENAME_preprocess_page(&$variables) {
  if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
    $variables['page']['content']['system_main']['nodes']['#prefix'] = '
';
    $variables['page']['content']['system_main']['nodes']['#suffix'] = '
';
  }
}

So what this does is checks if the URLs match the condition /taxonomy/term/%term-id then if it's satisfied then it adds a prefix and a suffix that are to be rendered by <?php print render($page['content']); ?>.


Why is the replacement not happening when using the Search and Replace Scanner module?

Your scenario sounds similar to what is described in issue # 2616640.

Have a look at Comment nr 6 in it for an explanation for what may be causing it, i.e.:

  It looks like the module assumes that the field content to replace is set to the same language as the node.

Probably your best bet is to try the patch attached to Comment nr 18.


how to add an event subscriber when the user reaches the login form

You can't, not with core alone. D8 doesn't have a form-alter event.
D8 added events as an alternative to some D7 hooks but didn't fully replace all the hooks available. Replacing all hooks was mooted for a D10 goal but didn't make the cut.
As such, the only way to do this modify core functionality like:

Patch core (see issue comment) to add form-alter events.
Do something like Hook Event Dispatcher which wraps custom form-alter events around a hook_form_alter handler.

Then add an event subscriber for it.


What is the difference betweeen hook_validate and case 'validate' in hook_nodeapi

hook_validate is used inside a module that creates a node type of its own, and is used along with the form used to create the node to validate that all the information required has been entered.

For example, let's say you created a node type with a specific field in it of "area" and you wanted to make sure it was of the format city-state.  You would do it in here.

hook_nodeapi with op=validate is used to validate any nodes that are being edited but not created by the module in question.

For example, let's say you wanted to make sure a description field in a node with that field had more than 1000 characters.  You would do it with nodeapi/validate.

Carefully read hook_validate and hook_nodeapi for more information or clarification.


How to switch to other site's database in multisite enviroment?

You can't.

Multi-site is only about sharing the code in the file system. Unless you actually add the database connections to the specific settings.php, Drupal doesn't even know that there are other sites.

Functionally, once the bootstrap and site selection happened, there is 0 difference between two different installations and a multi-site.

IMHO, there are more downsides than advantages with multi-sites these days, you can use git and e.g. different branches to share code between multiple sites at least as well, with way more flexibility and options for updating and customizing them.


Drupal 7 & OpenLayers - Can see sample map under OpenLayers Admin: Preview but NOT under Views: Preview

Openlayers is generated via JavaScript so wont display in the views admin. Save your view and check the page/block.

If it is still not working check the width of the map. Sometimes, when set to auto the map will collapse showing nothing. Set a fixed with and check again. If it works then some simple css will fix the rest.

Good luck :)


Adding functionality to a form button that would load user details / corresponding field data for "autofill"

Take a look at how Commerce Addressbook solves these same requirements: https://www.drupal.org/project/commerce_addressbook.

There is a demo video on the project page: https://commerceguys.com/blog/commerce-module-tuesday-commerce-addressbook.

I think if you dig through the module code of that module, you'll find all the logic and code examples you'll need to pull off a similar solution on your custom form.

If you want to see this in action on a local setup, I recommend installing commerce kickstart with commerce addressbook to see how the addresses are organized.

Good luck, Jason


Disable CkEditor to body field of a content type

The problem you experienced with configuring the field is that in core there is no option to select the allowed text formats. When this module is installed

https://www.drupal.org/project/allowed_formats

you can select the text format that is available for a specific field and then you can choose in the settings of the text format whether to use ckeditor or not.

There is work going on to put this in core: https://www.drupal.org/node/784672


How do I add a column to the table shown in the vocabulary listing page?

You would need to override the class generating the list builder output on this page, then fill in the methods with what you want:

  /**
   * {@inheritdoc}
   */
  public function buildHeader() {
    $header['label'] = t('Vocabulary name');
    $header['foo'] = t('Custom Header');
    return $header + parent::buildHeader();
  }

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    $row['label'] = $entity->label();
    $row['foo'] = 'custom_value';
    return $row + parent::buildRow($entity);
  }

See this related question: Can you change the list builder class used by an entity?

So, in essence:

function mymodule_entity_type_alter(array &$entity_types) {
  /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
  $entity_types['taxonomy_vocabulary']->setListBuilderClass('Drupal\mymodule\VocabularyListBuilder');
}

Then, in your mymodule/src folder, create a VocabularyListBuilder.php, and copy in from the core/modules/taxonomy/src/VocabularyListBuilder.php and modify the two methods above for your output (since they'll be basically identical).

You could also do this with a View page as well, but for archival purposes wanted to explain how this works in general for Drupal core. List builder classes are such a cool and useful new D8 thing.


Can I use custom name for theme directory?

Renaming core directories is not possible without hacking Drupal's core. Hacking core is highly discouraged. Even if it will work, one module that will try to access directory directly may mess up your installation.


I need to update a longblob value in the variable table using variable_set

With variable_set() you can set a persistent variable to any PHP value, including array. variable_set() will serialize the value passed as second argument, and variable_get() will unserialize that value. If you pass an array to variable_set() for a persistent variable, variable_get() will return an array for the same persistent variable (if another module doesn't change that persistent variable's value to an integer, for example).
Suppose that you want to change the value of node_revision_delete_minimum_age_to_delete_time, which is set from that module in its installation hook using the following code.
  $node_revision_delete_minimum_age_to_delete_time = array(
    'max_number' => 12,
    'time' => 'months',
  );
  variable_set('node_revision_delete_minimum_age_to_delete_time', $node_revision_delete_minimum_age_to_delete_time);

If you want to change max_number to 24, you would use code similar to the following one.
$node_revision_delete_minimum_age_to_delete_time = variable_get('node_revision_delete_minimum_age_to_delete_time', array());

if (is_array($node_revision_delete_minimum_age_to_delete_time)) {
  $node_revision_delete_minimum_age_to_delete_time['max_number'] = 24;
  variable_set('node_revision_delete_minimum_age_to_delete_time', $node_revision_delete_minimum_age_to_delete_time);
}


Not possible to drush sql-sync sqlite to mysql pragma

Drush sql-sync cannot convert and sync databases in one step; however, you can use drush dbtng migrator to convert the database locally into mysql format, and then use sql-sync to copy it to the final destination.


Adding a jQuery UI widget in the administrative front-end

drupal_add_library() can be called from pretty much anywhere, including your form function:

function my_form_name($form, &$form_state) {
  drupal_add_library('system','ui.slider');

  // Build and return the form.
}


Yep!
Take a look at:

yourtheme_form_user_register_form_alter

Add a new value to the form there,  and then change the form's saving function. In your new saving function you can do whatever you need to do with custom validation and re-assigning that value.

https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_form_alter/7


Spent some time looking around for an answer to this, so I thought I'd write it up even though I figured it out.

The combination of machine names involved in my nesting for the paragraph type and the paragraph reference field were overloading the ajax link length. I shortened the paragraph reference field machine name and nesting now works beautifully!


views use the same css class for both sidebar and article, blocks me from resizing main content

Surely you can either define different classes for the teaser and fullpage views of your content type using templates, edit the views template or define your css using the class .front or .node-type-article ?

For 1) create a node--content-type-name.tpl.php file and use the if (!$page) { // teaser view switch to output a different class or template.

For 2) create a views-view-unformatted--view-name.tpl.php file and wrap it in a different class

For 3) use the built in drupal classes that are outputted into your themes body tag in your themes html.tpl.php file with <?php print $classes; ?>. Edit your css to specify your style usinf .front .article {} .not-front .article {} etc ..

Or edit your block.tpl.php file and remove the class .content


For sure this is due to some problem with your sever setting, contact your web hosting company and talk with them regarding the issue.

It could be due to ModSecurity that scans incoming http requests for any malicious scripts. There may be an issue with the script causing mod_security to stop the script. ModSecurity is an is an open sourceweb application firewall Apache module, which help in providing an external security layer that increases security, and help in preventing attacks.

In the event that mod_security is causing the error, you will need to contact tech support to have them look at the logs to see what is exactly causing mod_security to flag the uploaded file. You may need to Disable mod_security via cPanel Modsec Manager on your specific domain if there is no work around. Otherwise, tech support will need do this for you.

The other reason could be the size you are allow to upload that can be change in your server setting. It is also important to check apache max_execution_time.

If you have control over your server then you can try to change your php file

post_max_size = 128M upload_max_filesize = 32M max_execution_time = 5000
max_input_time = 5000
memory_limit = 1000M

Source

If not solved then Other Reason May be :
Check the .htaccess or settings.php for conflicting Code
Edit the .htaccess file to see if there are any overrides in the code. Some server configurations allow .htaccess settings to override your file upload size. Comment any code that controls the files upload size and save the changes.

The settings.php file also can hold overrides for the file upload size. Edit the settings.php directly on the server or you can change the settings through the Drupal dashboard by going to Administer > Site configuration > File uploads and updating the settings from there.


You could write a small custom module and use hook_admin_paths():

function MYMODULE_admin_paths() {
  return array(
    'node/*/panel_layout' => TRUE
  );
}

This will instruct Drupal to treat paths that match the pattern as admin pages, including rendering them with the admin theme.


When you define the page the form is on via hook_menu(), you need to set the access rights via the "access callback" and "access arguments" settings.

The simplest way to do this is to provide an array containing a single permission value as the "access arguments" setting.


A colleague of mine created a module called path data a while back. His intentition was to solve this very problem. Unfortunately it has turned out that it conflicts with regular path aliases, so it will work on a site like drupal.org that doesn't use aliases, but will break links on a path-alias using site.

Currently, it's my belief that the only generic way to solve this issue is either manipulating the URLs at the httpd layer, or using hook_url_inbound_alter and hook_url_outbound_alter. You can read a bit more about the mentioned hooks at this question.

However, if I were to give this another shoot myself, I would attempt a Views specific solution instead, as this problem is common enough that it could be justified to have a module for this.

In hook_views_pre_build, one could take data from a url like "members/valuea/valueb", push these values into $_GET['q'], let views build it's query seeing the get arguments "in the url", then possibly remove them again in hook_views_post_build.


How to modify a view's empty text to show a different message depending the user viewing it

Do you have the php filter input format turned on for your site? You can do this by adding the following code into your empty text field with the input format 'php code' enabled:

//get the current $user object to determine the logged in user's id
global $user;

//now load the user id from the profile page into another object by pulling it from path
$usertmp = user_load(array('uid' => arg(1)));

if ($user->uid == $usertmp->uid) {
     //we're on the logged in user's page
     print "You need to write more stories..";
} else {
     print $usertmp->name." needs to write more stories.. ";
}


Is there a common method to password protect registration pages?

Well, till they register/login, you can't actually say who they are.

I will suggest a CAPTCHA in the registration form. If you want to restrict it more, then you can search for email white listing modules. https://drupal.org/sandbox/amrit_b/1768342 This is something I wrote few months back. This is still in dev. In case you don't find anything else, you can try this one.


Why won't taxonomy list sort alphabetically?

Have you already tried with "Show row weights", it looks like a javascript problem; adding the weight manually will give you some hint about that problem.


Export Drupal Commerce Checkout Settings

The checkout configuration is all managed via standard Drupal variables, so the Strongarm module with Features is all you should need. All variables in our modules will be prefixed with commerce_* and typically with the module name (e.g. commerce_checkout_*).


In form_set_error, the first parameter should be form name, if you are not sure of the name, just leave empty.

form_set_error('', t('hello test'));

This should work just fine.

UPDATED ANSWER

If you would like to have only your validation and skip the rest of Drupal core's validation for that particular form, you can unset the validator function and inject your own.

unset($form['#validate']);
$form['#validate'][] = 'zloginsecurity_validators';

Or

If you like to have both and give priority to yours first, then

$default_validators = $form['#validate'];
unset($form['#validate']);
$form['#validate'][] = 'zloginsecurity_validators';
foreach ($default_validators as $val) {
  $form['#validate'][] = $val;
}


If someone comes here, use template_preprocess_field

In template.php :

function MYTHEME_preprocess_field(&$variables) {
  $element = $variables['element'];

  if ($element['#field_name'] == 'field_myfield') {
    //Load the related node, I let you do this step ...
    //$nid = ...

    $nodeB = node_load($nid);
    $variables['items'][0]['#items'][] = $nodeB->field_another_image_field[LANGUAGE_NONE][0];
    //If you have a pager
    $variables['items'][0]['#pager']['#items'][] = $nodeB->field_another_image_field[LANGUAGE_NONE][0];
  }
}


How to add a custom read more link in views?

Probably going about it the wrong way, you could either set a custom text field on your node called 'Link text' then output that as a field and check 'Link this field to its node' in views.

Or you could use the 'Link' field type contrib module, then output that as a field, this will allow you to set custom text as the link label, but you will also need to supply the link itself. But this will allow more flexibility.


How to create a button that creates an article with a specific tag?

Sounds like the Prepopulate module does exactly what you want.

EDIT:
From the module's page:

The Prepopulate module allows fields in most forms to be pre-populated from the $_REQUEST variable.

For example, the following URL,

http://www.example.com/node/add/blog?edit[title]=this is the title

will automatically fill the Title field on a new blog post with the words "this is the title". Any field can be prepopulated this way, including taxonomy and CCK fields. You can prepopulate more than one field at a time as well. Prepopulate is excellent for creating bookmarklets. For examples on usage for all of these cases, please read the USAGE.txt file that comes with the module or you can read the online handbook page.


Remove disabled attribute/state during submission

Once you submit a form, you are not able to retrieve disabled inputs (https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#constructing-the-form-data-set). That said:

You cannot modify input's attributes from server-side since the submission data is already posted.
Developing your solution with jQuery on .submit() function is a good idea (far away from bad practices).
You can also make another work around: instead of disabling you could use readonly="readonly" attribute (https://www.w3.org/TR/REC-html40-971218/interact/forms.html#h-17.12.2)


How do I add module theme elements to drupalSettings

I created an Element within the parent module. This element includes code to add the data and options to drupalSettings. It also determines which libraries are needed and includes them.


You can get the path using drupal default function drupal_get_path();

It return path to any module or theme from root of installation.

If i want to access path of any module e.g. mymodule

Then i just need to use,

$path = drupal_get_path('module','mymodule');   //path to module directory

If i want to access path of my theme e.g. mytheme

$path =  drupal_get_path('theme','mytheme');   //path to theme directory

Now you can make the path variable global..


Figured it out - Regular Expression, case-sensitive:

Regex Code: [A-Z]

Negate Rule is checked.


Drupal 7 : Tons of HTTP requests from Media Vimeo module

Those HTTP requests look like (slightly broken) video analytics tracking requests via the service conviva.
It might be possible to opt-out of conviva with Vimeo
See also Make Vimeo Faster - Opt Out of Conviva


If my assumption is correct, then you are looking for the way to handle 404 and 403 pages.

If that is the case,

  Goto configuration->Site information, there you can specify your own page for handling 404 or
  403 pages.

For that particular page, you can write tpl file like node--type--nid.tpl.php


How to make a view specific to only 1 node, not all nodes

At Taxonomy add one vocabulary and name as "Event". At content type add fields for particular info and "Event". User will fill up the particular as well as event type. At views filter by Event category. This is an example and I not really what is your structure. Hope it help


Showing the description for the term identified by the argument in the Taxonomy Term view

I want the description for the term coming in via the contextual
  filter argument

Ok then,

1) Create a new view

Show: Taxonomy Terms.
☑ Create a Block

Display format: Unformated list of Fields

2) Save and Continue.

Add the Contextual Filter.
Add the description field.

3) Go back to your other view and attach view to header.


How to create rule to change user role based on points (using User Points module)?

Have you tried the user points contrib module. I am specifically referring to

userpoints_role

Users join/leave roles as they earn/lose certain points threshold.


This is pretty well explained on Drupal programming from an object-oriented perspective.

In short, Drupal has existed for much longer than you could properly use OOP in PHP. Which means, PHP5.

Drupal 7 already uses classes internally in a lot of places and it will probably continue so with Drupal 8.

But this is a step by step process and not everything needs to be a class. For example, it does not make any sense to make modules into a single class.


how to open drupal login and signup form on modal form.

You should include the necessary javascript in your theme .info file or template or module with drupal_add_js() , then you should use the code defined in the link you provide to target the element that you want to apply the functionality too. This elememnt may be generated by a module that specifies a theme function and uses a template (tpl.php) file in which you would put your markup.


Node/add and node/edit do not display forms

According to the person who resolved the issue memory_limit on the server was the problem.


Related products in Drupal Commerce can be accomplished in a variety of ways:

As entity references, rendered in a related products view
Using this approach, relationships are defined manually by Store/site managers (they curate/associate what specific products/skus to show as related) as they edit each product node.  Then the view is setup with a contextual filter for the current node ID and a relationship to show all values assigned to the "related products" entity reference field.
Refer to this "Related Products Guide using Views and Entity Reference" post that walks you through the approach.
As taxonomy tags, rendered in a related products views
Using this approach, relationships are defined manually by Store/site managers (they tag products with specific classifications) as they edit each product node.  Then the view is setup with a contextual filter for the taxonomy terms on the current node and a relationship for terms in the specific taxonomy on that node.  See this similar post, "Related Articles - A Block View Of Nodes With Common Taxonomy Terms"
As a view that programmatically looks for skus of a particular pattern
Using this approach, store/site managers don't have to tag products- they just need to ensure following a standard ruleset in defining skus for products.  Then the site manager would setup a view of Commerce Products with a filter on the product sku field containing "skuredring" in your example.  This approach locks the view into showing only those products with the sku.


How do I override field_multiple_value_form()?

You need to implement hook_field_widget_form_alter(), which is invoked from field_multiple_value_form() using the following code.

  $element = array(
    '#entity_type' => $instance['entity_type'],
    '#entity' => $form['#entity'],
    '#bundle' => $instance['bundle'],
    '#field_name' => $field_name,
    '#language' => $langcode,
    '#field_parents' => $parents,
    '#columns' => array_keys($field['columns']),
    // For multiple fields, title and description are handled by the wrapping table.
    '#title' => $multiple ? '' : $title,
    '#description' => $multiple ? '' : $description,
    // Only the first widget should be required.
    '#required' => $delta == 0 && $instance['required'],
    '#delta' => $delta,
    '#weight' => $delta,
  );
  if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta, $element)) {
    // Input field for the delta (drag-n-drop reordering).
    if ($multiple) {
      // We name the element '_weight' to avoid clashing with elements
      // defined by widget.
      $element['_weight'] = array(
        '#type' => 'weight',
        '#title' => t('Weight for row @number', array('@number' => $delta + 1)),
        '#title_display' => 'invisible',
        // Note: this 'delta' is the FAPI 'weight' element's property.
        '#delta' => $max,
        '#default_value' => isset($items[$delta]['_weight']) ? $items[$delta]['_weight'] : $delta,
        '#weight' => 100,
      );
    }

    // Allow modules to alter the field widget form element.
    $context = array(
      'form' => $form,
      'field' => $field,
      'instance' => $instance,
      'langcode' => $langcode,
      'items' => $items,
      'delta' => $delta,
    );
    drupal_alter(array('field_widget_form', 'field_widget_' . $instance['widget']['type'] . '_form'), $element, $form_state, $context);

    $field_elements[$delta] = $element;
  }

For example, you could implement it using the following code.

function mymodule_field_widget_form_alter(&$element, &$form_state, $context) {
  $element['#prefix'] = $element['#suffix'] = '';
}

The arguments passed to field_multiple_value_form() are also passed to hook_field_widget_form_alter(), directly, or contained in $context.


What are the differences between Drush 9 and 10

You can check the difference here https://github.com/drush-ops/drush/compare/9.7.1...10.0.0

As you can see, they are mostly fixes and improvements.

There are also some compatibility changes:

  Source: https://docs.drush.org/en/master/install/

As long as you're using PHP 7.1+ there is no risk. The benefit is that it will still work once Drupal 9 comes out later this year.


How to add a folder to my site with media or media browser?

Turns out a a list of vocabularies is being used to generate the drop down. In other words look at taxonomies and find out which one is being used and add a new term vocabulary


Is is possible to access views from a module file?

You can use drupal function views_get_view_result($name, $display_id = NULL)

$name : name of the view
$display_id : On the edit page for the view in question, you'll find a list of displays at the left side of the control area . e.g. 'MASTER', 'Page'

This function will return An array containing an object for each view item.

Reference :https://api.drupal.org/api/views/views.module/function/views_get_view_result/7


How can a text field be re-sized by touch and drag with finger in Smartphone devices

You might need to implement a custom module that just loads a library similar to this one:

http://interactjs.io/

Scroll down to the resizing section and then check out the demo. You could presumably do this for your input fields.


I think you can by adding algorythm like this:

  <a href="<? print $front_page; ?>"><img src="<? if (theme_get_setting(theme)=="dark") print $logo; else print $logo_light; ?> border="0" alt="<? print $site_name; ?>">


You can achieve this by setting a very high default TTL (expire time) and then invalidating the cache only for modified content. The Varnish module and the Cache Actions module are useful tools for that purpose.

Fabian Sörqist, maintainer of the Cache Actions module, has written a detailed article about it here: http://dev.nodeone.se/en/caching-with-varnish-drupal-7-and-cache-actions


Multiple Relations and Contextual Filters in a Translated View

Not sure if there's anything else that could be configured.

Something you could consider is using something like hook_views_pre_view(). Internally then you can check the language of the site for that request, read the values of the month, and using a table, translate internally juillet to july.

hook_views_pre_view() - https://api.drupal.org/api/drupal/core%21modules%21views%21views.api.php/function/hook_views_pre_view/8.6.x


Can we configure Devel module to pick up images for the image field of a content type only from a specific directory containing images?

Yes.

There are at least two modules providing this or similar features:

https://www.drupal.org/project/realistic_dummy_content
https://www.drupal.org/project/devel_image_provider

HTH


Deployment of full database dump still causes error

You can run Drush commands remotely from another server using methods such as site aliases.
https://docs.drush.org/en/master/usage/#site-aliases

So you might be able to run registry rebuild https://www.drupal.org/project/registry_rebuild

which sometimes helps with class errors.


How to create Embedded Media Field: Video with custom resolution per Views field

You can set it in the template_preprocess_node()

depending on your view mode you can set the first element :

if ($vars['view_mode'] == "full") {

   $node->video_field_name[0]['#settings']['width'] = '300';
   $node->video_field_name[0]['#settings']['height'] = '150';

}

dont forget to set all elements, not just the first one

other settings you can set:

#settings
  controls (Boolean) TRUE
  width (String) 300
  height (String) 150
  download_link (Boolean) FALSE
  download_text (String) Download

Edit:

template_preprocess_views_view_field is what you need for views probably. there you can access to the $vars['row'] with all data you need. maybe you will need to rerender the field.

If this does not work there is a workaround:
the embedded-media-field sets its settings in the drupal js-settings.
get the js settings with drupal_add_js(), find the element mediaelement and set the settings manually.


Solved! There is a list of all available tokens in: admin/help/token.

In my case I needed to get 3 field values from Field Collection:

[node:field-school-undergrad:0:field-school-list]
[node:field-school-undergrad:0:field-school-degree]
[node:field-school-undergrad:0:field-school-year]


Hide node created messages programmatically

drupal_set_message is not hookable. But the message you want removed comes from node_form_submit, so you can get rid of it using hook_form_FORM_ID_alter on node_form. Either replace node_form_submit as form's submit handler with it's clone, sans messages, or set second handler that will remove what you want removed from $_SESSION['messages'][$type].


Use entity reference to target revisions of an an entity

Revisions are stored in a separate db table from content. Views module makes you choose the base table for the query to the database when you're creating a new View (it's commonly called Views type: Content, User, Media, Taxonomy terms).
The easiest way to allow an Entity Reference Field to choose a particular Revision of a Content item is to build the list of Content Revisions items, and not a list of Content items.
Create a new Views entirely but this time choose Content revisions under Show, and not Content (you can't change that from within your existing Content type Views).
Your aim it to have a separate revision in each Views row, because when you're using that list within an ER Field each Views row becomes one checkbox/radio button to select when you're creating a new node.
Revisions can be grouped by their original content ID, Title or something else in common, but I'm not sure if the Entity Reference Views Display type supports that, I expect it doesn't and it won't affect it, you'll still get a plain list of all Revisions and you need to make sure yourself what to output and how to style it to make the options clear. There are probably ways on how to improve the ER Display output in Field widgets but that is out of scope of this question.

I haven't tries this, but usually when listing content referenced through ERs you need to add a Relationship to get any other info than an ID of the referenced entity. You'd need a Relationship to get that info. In your case if you start with Content Views type I expect you'd have to make sure to have each Revision is in a separate row (after you make them appear in results by adding a Relationship, and you'd probably need to list only the Revision info to make them appear in separate rows). I know it's possible to create the reverse ER Views through the forward list Views this way, but haven't tried it with Revisons, maybe the same logic applies.
Anyway, go with the Content Revisions Views type as explained above ;)


1) .htaccess (before line 100):

RewriteRule ^profiles($|/(.*)) /index.php [L]

2) VirtualHost (for de-slash setting):

<Location /profiles>
     DirectorySlash Off
</Location>

Second part is needed only if you use Global Redirect "de-slash".


How to avoid losing custom CSS/JS on a form using Ctools Modal when Validation Errors Occur

Turns out that the JS and CSS files were not being dropped, but since the modal window uses ajax, all the ID's were being incremented when the form was rebuilt after a validation error.

So JS and CSS selectors such as edit-field-act-property-ref

would become

which is a problem if you have CSS/JS targeting the original. I thought I would share in case this helps out somebody else in the future.


Is it possible to build a site without Users and Node?

With Drupal 7 and a reasonable amount of effort, I don't actually believe it's possible.

Drupal 8 however will further decouple the modules, so that you can (hopefully) truly build a site without it.

A good use case for disabling User, is as a security hardening mechanism. Have your production site completely disallow logging in by not having the module, and push content from an internal stage environment instead with the help of something like Deploy.

A good use case for disabling Node could be a file handling API. One would need the file entity, but then only communicate with the world through a REST based API. No nodes (or even theme) needed.


Create the view and render it as a block, then go to block settings, set the view to show on every page except:

  drupal/?q=searchpanel&body_value=

  drupal/?q=searchpanel

Edit: Add the created view block to the content area where you want it to display e.g footer, content etc. it will show on every page except the pages above


how to customize autocomplete TO field in privatemsg module - drupal 6

Open privatemsg.module

in hook_menu search for $items['messages/user-name-autocomplete']
this particular menu item  defines that auto complete path.

Search for privatemsg_user_name_autocomplete function where the output defines.

Edit this function. Thats all.
Also Create a patch if youre familiar with patching, so that others c


Install views rules module, make a views-rule of users, if you need UID as a contextual filer add it as always, then in middle column set your UID as an integer in parameters settings, add user pictures as a field, now in middle column settings, set user-pictures as an file entity. then in your rule, fetch entity by id with your variable UID, now you have user picture avilable and can be copied to your content type file field. Done, cheers.


Multiple Values does not work when field widget is "Autocomplete term widget (tagging)"

Change the field widget to "Check boxes/ Radio buttons"

For letting user select multiple values, go to Administration » Structure » Taxonomy » Your-Term » Manage fields, set Number of Values in Field Settings to "Unlimited"


Got it!

From these two sources:

How to embed drupal content in other sites (remove X-Frame-Options: SAMEORIGIN)?
https://wunderkraut.se/blogg/remove-xframe-options-and-set-contentsecuritypolicy

I realized that I was missing a mymodule.info.yml file.

mymodule
  ├── mymodule.info.yml
  ├── mymodule.services.yml
  └── src
    └── EventSubscriber
      └── RemoveXFrameOptionsSubscriber.php

Then, go to /admin/modules in the backend (Extend tab) and install the new module & clear all caches afterwards.

Woohoo!


How to create Drupal 7 clean pager links?

Hi please check the following link Clean Pagination, Hope this will help you.

  Clean Pagination is a very simple module that allows you to enable clean URL pagination for specified pages. The way Drupal typically works, if you had a view with the URL 'my-view', subsequent pages would normally use a query to pass the page number, as in 'my-view?page=2'. When Clean Pagination is being used for a page, it will create a url like 'my-view/2'.


Problems translating strings for my module

The string has to be displayed at least once on the site (as far as i know). If this does not work, try to rename the string you want to replace with a translation and clear the caches again.


How are node and node_revision tables related?

The node table holds the basic information about the node, the nid is the primary key on this table and contains the vid field which is a foreign key to the node_revision table. The node_revision table holds each revision of the node, the vid is the primary key on this table and contains the nid field which is a foreign key to node table.

You may think that this information is identical, but it's not. The node table only contains one record relating to a node and also stores the current vid whereas the node_revision table contains the revision data. Just because you're not using revisions it doesn't mean that this process isn't being used.

Also keep in mind that all field tables have 2 versions, field_data_[field_name] and field_revision_[field_name], the data tables contain the current revision and the revisions table contain the revision data.

To get an understanding of how practical revisioning works try looking at Revisioning, a more complex and powerful solution can be achieved using Workbench


How to create a rule which asks the user whether to proceed or not?

You might want to check, and experiment with, the Rules Link module. Here is an excerpt from its project page:

... lets you create links which trigger arbitrary functionality with the help of Rules.
There are three types of links (usages):

Javascript - Links that will trigger the rules using Ajax.
Token - This are basic links, that will reload the page after calling them.
Confirmation link - Show a confirmation form before executing the rule

The module's Readme.txt contains some more documentation about how to use it.
Example Configuration

Define a rules_link with a "Link type" of "Confirmation" and make sure to define a "Path" for it, e.g. http://example.com/confirmation-page.
Edit the rules_link you created and go to "Configure rules" then create a "Reaction" rule containing all the actions you want to take if the user clicks "Confirm" on the confirmation page.
Create a normal rule for the particular event you want to trigger the confirmation page on (in this case we're using an "After updating existing content" event).
Add whatever conditions you might require then add a single "Page redirect" action where the "URL" is defined as the path to the rules_link confirmation page plus a node ID token and a destination parameter, e.g. confirmation-page/[node:nid]?destination=node/[node:nid].

With this configuration, when the user updates a node with nid 12345 they are redirected to "http://example.com/confirmation-page/12345?destination=node/12345". If they click "Confirm" the rest of the required actions are executed before returning to the updated node. If they click "Cancel" they return directly to the updated node without any further actions executing.


Creating Feature with content types imported by Feature

If your nodetype is already in a feature, they will not show up in the feature list.
You can disable the feature containing the nodetypes, now the nodetypes should appear.


How to add text as page variable to node add form? Or in other works print explanation/guideline text

The core page.tpl.php template doesn't know anything about any current node object or help information from its node type. The snippet you're using is for printing a region named help, not a node type's help test.

That help information is retrieved by the System help block and is placed in whatever theme region you've configured in the block admin UI (/admin/structure/block). You're better off utilizing that block with your theme regions rather inserting a variable into your page template.

However, if you're really wanting to push this information into your template you can evoke node_help() to retrieve the information for your template variable and push in your template.php's template_preprocess_page() function:

/**
 * Override or insert variables into the page template.
 */
function MYTHEME_process_page(&$vars) {
  // $help_text will be available as printable markup with page.tpl.php
  $vars['help_text'] = node_help(current_path(), arg());
}


In Panels, how are the 2 given arguments in System's node_view created?

Panels has by default some operations on url arguments which can create variables used in Panels. The short explanation is that Panels for nodes does a node_load on the node id which is part of the url: node/[nid]. It does something similar for taxonomy terms, only depth isn't the term itself, but rather information about it.

You can do this yourself if you create a custom url with placeholders, like my-panels-url/%node and assign the variable to be a node or taxonomy term.


update node field without node be updated

I found this http://timonweb.com/how-insert-and-update-only-specific-fields-your-entity-drupal-7 and it is useful and final solution is :

$node->field_share_counter['und'][0]['value'] = intval($node->field_share_counter['und'][0]['value']) + 1;
        //$node->field_product_description[$node->language][0]['value'] = 'This is a very nice and useful product. Buy it now! We want your money!';

            // Get the numeric id of your field by passing field name
            $info = field_info_field('field_share_counter');
            $fields = array($info['id']);

            // Execute the storage function
            field_sql_storage_field_storage_write('node', $node, 'update', $fields);

            // Clear field cache
            cache_clear_all("field:node:$node->nid", 'cache_field');


Blocks placed in content region appear in wrong positions

I moved the blocks around to different orders and back and they suddenly appeared in the correct positions. Seems that they just needed some fiddling. Please comment if you have a similar experience, I'm interested.


Modifying the properties and output of a select list when adding content with the admin Drupal 7

You need hook_form_FORM_ID_alter() or hook_form_alter() to modify the select list. Something like this should work:

// form_alter hook for "mycontent" content type.
function mymodule_form_mycontent_node_form_alter(&$form, &$form_state, $form_id) {
  switch ($_SERVER['SERVER_NAME']) {
    case 'domain1.example.com':
      // Remove term 2 from select list.
      unset($form['field_myfield']['und']['#options'][2]);
      break;
    case 'domain2.example.com':
      // Make term reference field required.
      $form['field_myfield']['und']['#required'] = TRUE;
      break;
  }
}

Bear in mind that you can't just add new terms to the select list since they will fail validation when the form is submitted. You can only choose which existing terms to include in the list.

What you could also do is create different fields for different groups of terms and unset whole fields depending on the domain so that only the relevant field is displayed.


Send out a unique (unprotected) link per user

I don't know of a single module to do this.

I would suggest looking at the VBO module (views bulk operations).

You can create an "email" action and customize what gets sent.

From your description I think the biggest barrier you're facing is that users don't want to login,  and you'd like them to just click a link.

To do that you're going to have to roll your own module and likely make use of a menu hook with a callback to a function that processes the link.


Installing a site from existing configuration

I found out we can do this by running the following drush command

drush site:install --existing-config

However you might encounter an error related to hook_install found in standard install profile. To mitigate that you would need to install this patch.

https://www.drupal.org/files/issues/2018-11-27/2982052-22.patch


How to recover drupal password in localhost?

You can update the password via mysql. You can run the following query in mysql to update password. The given hashed value is the hashed value of password: NewPassword

UPDATE users SET pass = '$S$DRSUIz9NFfxOXKPveQ00UTGMzsJe62LjYvVHfYJ8I8wuy4zRqVBK' WHERE uid = 1;

For detailed instructions go through these article Resetting the administrator password with sql-query (Drupal 7)


Session Timeout after certain period of inactivity

You are looking for Automated Logout module.

  This module provides a site administrator the ability to log users out
  after a specified time of inactivity. It is highly customizable and
  includes "site policies" by role to enforce logout.

Features

Different timeouts based on role
Disabling of timeouts based on role
Permission for users to set their own timeout
Includes some JS mechanisms to keep uses logged in even if multiple tabs are open or if the user is working on a form for a long period of time.
Includes developer hooks to allow users to remain logged in depending on your own project specific requirements
Optional integration with Javascript Timer

(or) take a look at Session Limit

(or)

Ejector Seat

  A Drupal module to immediately log out (eject) a user whose session
  has ended


Why does Drupal run slow on localhost wamp?

Installed Acquia Dev Desktop, runs smooth ant fast. Wamp is not production system.


Programmatically specifying pathauto alias

Pathauto 8.x is already hooking into the hook_entity_$CRUD_OP() hooks of D8 to do its work. Thus, trying to do this via a hook_entity_insert() means your module hook might fire before/after pathauto has set its alias (depending on module weight).

Instead of doing this, you should use the API functions of pathauto to alter its behavior. For example, hook_pathauto_pattern_alter() or hook_pathauto_alias_alter() will let you alter the pattern/alias prior to generation/saving.

See pathauto.api.php for more info.


Creating Private file directories inside public files directory

Using just Drupal, it's not possible.

It's important to consider what setting store files as public means for Drupal. Essentially, it means Drupal relies on the web server for output of files URLs (vs. it being the gatekeeper to a directory non-accessible from the web server).

As such, to do what you want would require your zip processing code to do extra work of configuring your web server to restrict access (e.g. creating .htaccess files). You would also need some custom code to create proxy URLs paths to any file inside the unpacked zip directory. Lastly, you'd want to take a hard look at possible security vulnerabilities you're opening up by giving users unfettered access to run/view any arbitrary JS/HTML/CSS on your domain.


How to set Drush sql-sync not to clone users between @dev and @staging?

The drush sql-sync has an option --skip-tables-key that allows you drushrc.php to skip tables during the synchronization.

In your drushrc.php you add this line.

$options['skip-tables']['staging'] = array('users', 'users_roles', 'roles', 'permission');

Your drush command line should look like the following.

drush sql-sync --skip-tables-key=staging @dev @staging

You've to be careful, as you've to skip all tables that had informations related to your users, including the tables used from third modules.


Custom Field Type hook_field_widget_form() not showing #title values

According to hook_field_widget_form() the $element parameter will already have a #title set. If you take a look at the docs for PHP array operators:

  The + operator returns the right-hand array appended to the left-hand array; for keys that exist in both arrays, the elements from the left-hand array will be used, and the matching elements from the right-hand array will be ignored.

Emphasis mine.

So your new #title is currently being ignored.

Try this instead:

$labels = array(
  '#type' => 'select',
  '#title' => t('Label'),
  '#options' => $options,
  '#default_value' => isset($default_label) ? $default_label : '',
  '#suffix' => '<br \>',
) + $element;

The example in hook_field_widget_form() might be a bit confusing as it uses an approach similar to your original one, but if you look closely neither of the properties added exist in the list of defaults that $element will contain, so there's no chance of a collision.


With the relationship to the second content type properly defined (and possibly also required) you should be able to display the image requested.

One problem area I've seen is the base tables defined.  You can see the base table in the export text of a given view right on top.

If your base tables do in fact differ, then there are further nuances to the relational display in views, but it can be done.

Post back if you have more details to this view creation to guide a useful example.  I'll post more step by step instructions.


How to add local task links to referenced entities for a specific content type?

The reason these tabs show up on all of your content types is that entity.node.canonical is the base route for all nodes. Since you're setting entity.node.canonical as the parent_id, Drupal thinks you want these tabs displayed on every node page.

The easiest way to achieve your goal is probably to implement hook_menu_local_tasks_alter() with code similar to this:

  if ($route_name === 'entity.node.canonical') {
    /** @var \Drupal\node\Entity\Node $node */
    $node = \Drupal::routeMatch()->getParameter('node');
    if ($node->bundle() !== 'my_bundle') {
      $data['tabs']['my_module.my_content.my_content_type']['#access'] = FALSE;
      $data['tabs']['my_module.my_content.my_referenced_node']['#access'] = FALSE;
    }
  }

Because Drupal performs upcasting on this route, you can get a reference to the current node directly from routeMatch() as a parameter, and then compare its bundle to your custom content type. When they don't match up, we set access to FALSE for those tabs.

I think another approach that would probably work is to override the getRouteParameters() method of your LocalTaskDefault classes and use similar logic; if the current node isn't your custom content type, then return an empty array of route parameters.

A third approach might be to create a custom route for your specific content type and then assign that route as the parent_id for these tabs.


How to change filed type from integer to string

I ended up following this path. The reason I opened a new question was to see if there were any module or alternative to custom code.

My main concern was that the example was converting text to text and not number to text, but after executing some code using devel + webprofiler + kint (locally) I was able to see that even that same code was going to do the trick as the schema is affected only when needed.

For anyone looking at this same issue: take in mind that after running the custom code via the update process you will need some manual steps: recreate some views (when the field is used) and reconfigure the form display, presentation and so on of the bundles that are using the field.

As I have configuration of the site in git, my path was running the code locally, reconfigure the corresponding views, form displays, etc and then export the configuration, commit and push; then on production ran the upgrade and then import the config; it was pretty clean except that some views that have menu links assigned I had to manually edit its ordering.


Render multiple values of a field in Drupal 7

For multivalue field it makes the field value array like :

// $node->field_creation_images['und'][0]['uri'];
// $node->field_creation_images['und'][1]['uri'];

So to print all values you need to use foreach :

<?php foreach ($node->field_creation_images['und'] as $uri) { ?>
  <div class="CLASS" style="background: url('<?php print file_create_url($uri['uri']); ?>')">

<?php } ?>


You can use thw Views module, which is a Drupal 8 core module.
On admin/structure/views you can create a new view, even a block view. You can select which content type you want to display, the fields that should appear, and add all your limitations. After you save the view, on /admin/structure/block you can place the block on your preferred region.
If you have a content type for the photo albums, you can do exactly the same.


Views has a nice built-in way to help you decipher which template filename(s) to use.

Open up your view in edit mode, go to the display that you're interested in, and open up the 'Advanced' tab. Right at the bottom you'll see the "Theme: Information" link. Click that, and you'll be presented with a popup that looks something like this:

Once you've decided on the right filename, create the file and populate it, then make sure to clear Drupal's theme registry caches or the changes won't get picked up.


How to filter views output base on custom field

You can use the Views UI to accomplish this.

Add two date filters: one of them should filter date fields for "is empty" and the other should filter date fields for "is less than" and choose "Enter relative date" and type "now".

Then create an "OR" group and drag the two date filters to it. It should look like this:


The Calendar module doesn't recognize fields

I installed Calendar 7.x-2.x-dev, Date 7.x-2.x-dev, and Views 7.x-3.x-dev; then I created a "Test" content type to which I added a date field ("Start date").

When I edited the Calendar view, and added a new argument for the view (view arguments are called "contextual filters," in Views 7.x-3.x-dev), I followed the following steps:

I filtered out the list of arguments to show only the ones defined from the Date module; between the two argument types, I selected "Date: Date (node)."
On the settings page that Views shows after I selected the argument type, I selected the date field I added to my content type.

If you select "Date: Date (users)," then you will see all the date fields that are associated with users, as in the following screenshot.

Still, the field I added to my content type is visible in the list of fields shown in the settings page for the view argument.

The issue you are seeing is probably caused by compatibily problems between Date, and Views. I would try using Views 7.x-3.x-dev.


How do I set a variable in the install profile to enable users to sign up for the website

Variables in install profiles work no differently to variables in a 'normal' bootstrap.

To set a variable use variable_set():

variable_set('var_name', 'value');

To retrieve it, use variable_get():

$var = variable_get('var_name', 'default');

To find the names of variables, the easiest method is to install the Devel module and visit the variable editor at /devel/variable


No data returned when SSL enabled for REST server via services module

OK so I had some help in where to look on StackOverflow but ultimately I discovered my problem myself.

The issue was that I was using a name based Virtual Host rather than an IP one.

So to be clear, I had:

<VirtualHost MyDomain:443>

and I needed

<VirtualHost *:443>


I solved it. Turns out it was because my base theme was mentioned as 'socialblue'. I changed it to 'socialbase' and it worked out. I don't know if a parent theme can have more than one child themes in drupal 8.


No.
Not all functions invokes a hook in other modules. As we can see in http://api.drupal.org/api/drupal/includes%21common.inc/function/format_size/7 there is no module_invoke_all is called.

Here is how we define module_invoke_all

  Invokes a hook in all enabled modules that implement it.

function module_invoke_all($hook) {
  $args = func_get_args();
  // Remove $hook from the arguments.
  unset($args[0]);
  $return = array();
  foreach (module_implements($hook) as $module) {
    $function = $module . '_' . $hook;
    if (function_exists($function)) {
      $result = call_user_func_array($function, $args);
      if (isset($result) && is_array($result)) {
        $return = array_merge_recursive($return, $result);
      }
      elseif (isset($result)) {
        $return[] = $result;
      }
    }
  }

  return $return;
}


Hundred of Thousands of database records and how to safely delete them?

Forget about accessing the database manually, you will just break things.

For mass-deletion create a VBO-based view.

Same thing for export, you will want to export whole entities, not tables.


Show only comment textarea, if entered something show required fields for anonymous user

Paste in file template.php

function MYTHEME_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'comment_node_blog_form') {
    $form['author']['name']['#attributes']['class'][] = 'validate[required]';
    $form['author']['mail']['#attributes']['class'][] = 'validate[required,custom[email]]';
    $form['comment_body']['und'][0]['#attributes']['class'][] = 'validate[required,minSize[20]]';
    $form['#attached']['js'][] = drupal_get_path('theme', 'MYTHEME') . '/js/jquery.validationEngine-en.js';
    $form['#attached']['js'][] = drupal_get_path('theme', 'MYTHEME') . '/js/jquery.validationEngine.js';
    $form['#attached']['js'][] = drupal_get_path('theme', 'MYTHEME') . '/js/scripts.js';
  }
}

change form_id with your form comment

Source jQuery validate and file scripts.js

(function ($) {
    $(document).ready(function(){
        $("#comment-form").validationEngine();
        $('#comment-form').find('.form-type-textfield').hide();
        $('#edit-comment-body').keyup(function() {
            var value = $(this).find('.text-full').val(),
                lenght = value.length;
            if (lenght > 20) {
                $('#comment-form').find('.form-type-textfield').show();
            }
            else {
                $('#comment-form').find('.form-type-textfield').hide();
            }
        });
    });
})(jQuery);

Form with empty text

Form with more 20 characters