Which type of entity should I use for editable homepage content?

Sure, there are modules that let you setup "blocks" of service badge/icon widgets for like Twitter, FB, YT, etc.

Look at Widgets, Social Media and Service Links modules.

I've used Social Media (which relies on Widgets) to put a block of badges on most pages via Context. And also to create other badge collection tokens that i've used within Footer blocks and embedded into WYSIWYG entries to show a FB link on the homepage for instance, or a mini-block of service links on a newsletter.


How to render a field collection without default divs?

You need to override theme_field_collection_view theme function in your template.php .


Drupal core includes the Inline Form Errors module which will move required validation messages below each element. Issue #2889272 was specifically about where the main message container, with the "X errors have been found" text, should be placed on a page.

I also recommend checking out the Clientside Validation module. Here is a short video showing how to improve webform client-side validation.


Importing Joomla 1.5.23 to Drupal 7 by using Feeds

I've never considered how you would use Feeds to import from a database, but it works great for migrating content when that content is in a "feed".

If you have to use the DB, then there is Feeds SQL and Feeds DB, but I think both require you to write a query. That said, if you are using phpMyAdmin then when you "open" any of those tables phpMyAdmin will show the query it's running.

If you are able to expose your content as an xml/rss feed, a JSON feed, , or etc. then thing become very straight forward.

Using the Feeds Preview module may help you get your mapping correct.

You should be able to import the node alias (path) along with the content.


Why don't all pages of content show up in the pagination beneath main content?

This appears to be a bug in Drupal 7 or in some configuration. After migrating the site to Drupal 8, the full pages display correctly.


I can't set a data value using rule on a custom entity

In the provided hook, You need to add the setter callback.

So it will be like:

function project_entity_property_info() {
  // .... rest of code removed for brevity.

  $info['project']['properties']['name'] = array(
    'label' => t('Project name'),
    'description' => t('Name of the project.'),
    'type' => 'text',
    'schema field' => 'name',
    'setter callback' => 'entity_property_verbatim_set', // -> this is it!
  );

Now rules knows how to set the value on entity.

More information about the hook_entity_property_info can be found here. If name requires a complex workflow to be set, you can write your own setter similar to entity_property_verbatim_set (for validating purposes, or ...).

If you are benefiting from the power of Entity API you may declare it in your EntityMetadataController class. There is a default class called EntityDefaultMetadataController you can extend it and introduce it as your entity type's metadata controller.

Another option is to use entityspice to declare your entity type which takes care of it all.


How to show fivestar votes in views as number instead of percentage?

I found a solution for my question: Hide your vote field in views ("Exclude from display"); then, add a Global field, the "global math expression", and in this field add a replacement token of your exclude field, in my case [value]. Finally add the mathematical expression to divide by 10 the number: [value]/10.
Apply and save the view.


You can create a variation of file_entity.tpl.php from the File Entity module using the following pattern.

file__{file type}__{view mode}.tpl.php

e.g.

file__image__teaser.tpl.php


How can I use the logged in user's group ID as a contextual filter in Views?

Once you enable OG Context, that comes with Organic Groups module, you can clone the og_members view since it does almost what you want: it shows members from one group.

The OG Context module allows the "OG membership: Group gid" contextual filter to have a default value set to "Current OG Group from context". Nice, but we need members from all of the current use groups. So change the default value to "User ID from logged in user" to pass in the current user as the default argument. Then check the "Specify validation criteria" checkbox and choose PHP Code.

// let's see if there is a logged in user
if ($argument) {
  // og_get_entity_groups() returns the logged in user groups
  $groups = og_get_entity_groups();
  // setting $handler->argument changes the argument value
  $handler->argument = implode('+', $groups);
  // you have to return TRUE, else nothing works
  return TRUE;
}
// this will run if $argument is 0, for anonymous users
else return FALSE;

The "Action to take if filter value does not validate" should be "hide view": no block is shown if there is no logged in user. Expanding the "More" fieldset should be a "Allow multiple values" checkbox. Check it: that's why we imploded the groups array in the argument validation — this way we can pass several groups as arguments.


How do I use a different node template on taxonomy term node listing pages?

This answer had two parts:

As detailed in my Update #1, you have to put your suggestion last in the theme_hook_suggestions array, as last is highest priority.
Your template files must be named with two dashes, not one.

File system:

  node--taxonomy.tpl.php

As added to theme_hook_suggestions array:

  node__taxonomy


There is extension module for Devel: Search Krumo. It uses Javascript to find text in Krumo/dpm messages and open array in those places.
Looks like this:

Update

After 22 Apr 2012 you should use sdpm() function to see search box.


The absolutely easiest way to do it, is to enable any module, as that will do it for you. Of course, if you need to rebuild the registry, generally speaking the UI might be unavailable, but drush en [modulename] might be all you need.

If that's not enough, Registry rebuild makes it trivially easy to rebuild the registry. The easiest way to do it, is to install it as a drush extension.

Install the extension, and run drush rr.

The module page has detailed installation instructions and also shows how to run it without drush if necessary.


Why is langcode in configuration files ignored during installation?

It has to work like this. The alternative would be that a single-language non-English site would need to use the configuration translation to translate its configuration.

For the en langcode configuration, the installer will attempt to override it with the provided locale translations, from localize.drupal.org or local, and store the original English configurations separately, as far as I know. So, if you install in a language where you have translations, it should use them; if you don't, you have to change your configuration to the desired language.


how to create categorized webforms in drupal?

With Views, you can group the results by the value of a field, so create a field for your Forms and then group by that. You will have to get creative (custom templates) to get the numbering, if that's important to you.

As for sharing fields between Forms, I don't know of an easy way to do that.


How to display date/ time of current user base on time zone?

You can modify the user pages (view/edit/etc) with the user templates, like the user profile template In the template's top documentation there's some good info like:

 * Use render($user_profile) to print all profile items, or print a subset
 * such as render($user_profile['user_picture']). Always call
 * render($user_profile) at the end in order to print all remaining items.

So you can first dpm the $user_profile array and find out the user's timezone, then add php code after the print render($user_profile); to print the date/time according to the timezone value you retrieved from the user profile array.


How to send an email notification when a subcription renewal is due?

Part 1 - Sending eMail notifications
Use the Rules module together with Rules Scheduler (a sub-module of it), as explained in the steps below. These steps are based on a date field which is added to the user profile, so that for each user you can indicate an appropriate renewal date of a specific package. To support multiple packages, just create similar date fields (1 for each package type).
Step 1: Create a field to store the renewal date
Add a field to the "user" entity with machine name (say) field_next_renewal. Allow only 1 date (to store the "next" renewal).
Step 2: Create a Rules "Component"
Here is the Rules Component to be created (in Rules export format, just import it in your own environment via copy-paste):
{ "rules_send_email_notification" : {
    "LABEL" : "Send eMail notification",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "user_to_notify" : { "label" : "User to be notified", "type" : "user" } },
    "ACTION SET" : [
      { "mail" : {
          "to" : [ "user-to-notify:mail" ],
          "subject" : "Friendly reminder about your upcoming renewal",
          "message" : "This is a reminder about the upcoming renewal  on [user-to-notify:field_next_renewal] ...",
          "from" : "[site:mail]",
          "language" : [ "" ]
        }
      }
    ]
  }
}

Obviously, the Subject and Message of the eMail may need review / tuning, while you might also want to use some other From eMail ID. The Message-part of it is also where you can add the "link to upgrade to a different package" (as in your question).
Step 3: Create a "Rule" using the Rules Component
Here is the Rule to be created, in Rules export format (just import it in your own environment via copy-paste):
{ "rules_on_user_renewal" : {
    "LABEL" : "On user renewal",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "rules_scheduler" ],
    "ON" : { "user_update" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "account" ], "field" : "field_next_renewal" } }
    ],
    "DO" : [
      { "schedule_delete" : {
          "component" : "rules_send_email_notification",
          "task" : "[account:name]"
        }
      },
      { "schedule" : {
          "component" : "rules_send_email_notification",
          "date" : {
            "select" : "account:field-next-renewal",
            "date_offset" : { "value" : 259200 }
          },
          "identifier" : "[account:name]",
          "param_user_to_notify" : [ "account" ]
        }
      }
    ]
  }
}

Note that the above rule refers to the Rules Component from the previous step. It gets triggered any time a user profile is updated (feel free to replace that Rules Event with any other event that might fit).
The schedule_delete that is part of this rule is to ensure that previously "scheduled" reminders will get removed when updating the data field (so that it only triggers 1 reminder, and with the most recent date).
Step 4: additional refinements

The date_offset (=259200) in the above rule corresponds to "3 days in advance", which may need review / tuning.

If needed, you could also use the Field Permissions module to set field-level permissions to edit, view and create this renewal field.

Instead of just sending an eMail (as in the Rules Component), you could replace that by a more advanced option using the Message module (which has great integrations with the Rules module also). Here is an quote about that module (from its project page):

... enables logging and displaying system events in a number of different use cases. Events that are recorded over time are sometimes call activity streams. Exportable messages subtypes can be created for different use cases with custom fields and display (view) modes.

Part 2 - Tracking possible responses
If you'd also use the Flag module, you could enhance the above Rules logic to also "flag" the user (to indicate that you're waiting for some kind of response to the renewal eMail. By creating a view (using the Views module), you could then simply list the flagged users for which you do not have some desired response (those are the users who didn't perform a renewal).
Happy Rules-ing!


First, create a custom permission:

/**
 * Implements hook_permission().
 */
function MY_MODULE_permission() {
  return array(
    'access doctor content' => array(
      'title' => t('Access content for doctors'),
    )
  );
}

If the restricted content is a custom page you can do this:

/**
* Implements hook_menu().
*/
function MY_MODULE_menu() {
  $items = array();
  $items['doctor_page'] = array(
    'title' => 'Doctor page',
    'page callback' => '_doctor_page_content',
    'access arguments' => array('access doctor content'),
    'type' => MENU_NORMAL_ITEM,
  );
  return $items;
}

If the restricted content is a node make sure there is a reliable way to filter that content in your code (e.g. by adding a checkbox 'Protected' to the node). Set access restrictions on nodes like this:

/**
 * Implements hook_node_access().
 */
function MY_MODULE_node_access($node, $op, $account) {
  // Check if the content is protected.
  if (!empty($node->field_protected_content[LANGUAGE_NONE][0]['value'])) {
    // If so, check if the user has access to it.
    if (user_access('access doctor content', $account)) {
      // Allow access.
      return NODE_ACCESS_ALLOW;
    }
    // Deny access.
    return NODE_ACCESS_DENY;
  }

  // Handle the default restrictions.
  return NODE_ACCESS_IGNORE;
}

Don't forget to add your custom permission to the user role via the permissions page (admin/people/permissions).


Can I include nodes in a view's results only at URLs specified in the nodes?

Hook views_pre_render should meet your needs.

Here is a sample code of what you are describing:

$string_pos = strpos($haystack = current_path(), $needle = 'chickens'); // or you may use drupal_get_path_alias()
  if ($view->name == 'view_name' && $view->current_display == 'view_display') {
    foreach($view->result as $row_num => $row) {
      if ($string_pos && strpos($haystack = $row->node_path, $needle = 'chickens')) {
        unset($view->result[$row_num]);
      }
    }
  }

It can be optimized but I guess you got the idea.

Hope that helps!


PHPTemplate:

  A theme engine that allows you to use template files written in pure
  php. These template files do not need to be processed by the theme
  engine, and as such execute a lot faster than most other template
  engines. Another major advantage to using PHP as your template
  language, is flexibility, as the advanced user can access any
  information / functionality available in the Drupal API, and is not
  restricted to what the template engine / language allows him to do.

  This is the default theme engine starting in Drupal 4.7. If you are
  using Drupal 4.7 and above, you don't need to download PHPTemplate
  here.

A Template system does not need to use special code or markup to be called a template. PHPTemplate refers the system of implementing pure php code template files, how those files are accessed and referenced by the system and how other parts of the system (such as template.php) can modify the results of those files


entityform association with organic group

It looks like you and I have two very similar questions going. This is a link to my question, which you (@sly) have a nice answer to, and which also includes my custom module answer: Organic Groups access to Entityforms: is it possible?.


"Save draft" form button for anonymous users

The condition is on line 1977 of webform.module.

You can remove the && $user != 0 condition, but the comment above is valid. Removing the anonymous user check allows the form state to be saved in the database, with uid=0 and a valid sid.

Removing the same anonymous user check on draft form retrieval, however, does not result in the active draft being returned to the anonymous user.

This functionality would require patching the webform module to allow storage of the $form_state in $_SESSION, or in a client-side cookie, which could be read as part of the draft form retrieval process. It would not be difficult to do, but would be a significant change in the webform module.

If you wish to pursue this, open a feature request in the Webform issue queue on Drupal.org, and message me with the link.


build custom field in comments in drupal 6

In drupal 6 you should use hook_form_alter:

<?php
function mymodule_form_alter(&$form, &$form_state, $form_id) {

if ($form_id == 'comment_form') {

$cid = 1; // TODO See bottom comment in submit funtcion about this.
$answer = db_result(db_query('SELECT answer FROM {my_module_comment} WHERE cid = %d', $cid));
$answer = $answer ? $answer : 2;

$options = array(
    '1' => t('Yes'),
    '0' => t('No'),
    '2' => t('Empty')
);
$form['answer'] = array(
    '#title' => t('Your Answer'),
    '#type' => 'radios',
    '#required' => true,
    '#options' => $options,
    '#weight' => -1,
    '#default_value' => $answer,
);
// $form['#submit'] = 'mymodule_comment_form_validate'; Uncomment and add function like submit, for validation your and other submitted data.
$form['#submit'] = 'mymodule_comment_form_submit';
}

function mymodule_comment_form_submit($form, &$form_state) {
  $cid = 1; // TODO Here you should find CID - that will link your table record with Drupal comment Id record. Use print_r or devel dsm function for investigating structure of $form_state for seeking CID value.
  $object = array('cid' => $cid, $form_state['values']['answer']);
  drupal_write_record('my_module_comment', $object); // You table have 2 columns: cid and answer columns.
}


How to create a query about users in a Drupal Commons group including their location (State)?

To create such query (and report) you may want to look at the Forena module. You would use its report writing features (such as its WYSIWYG report writer and/or it's query builder) to first create a report that fits your needs. The result of it could be a tabular output and/or graph. After the report content matches the specifications, you could save it as (e.g.) a CSV file.

Here is a quote from one of the Forena community docu pages, i.e. Reasons for considering Forena:

  Reports created by Forena (combined with SVGGraph and mPDF) can be
  saved (exported) as PDF documents with embedded graphs. Other
  supported formats for saving a report are CSV, XLS, DOC, HTML, etc.

Similar samples

Refer to this online example in the Forena demo site for a report that is fairly similar to the kind of (tabular) report you could (easily) create:

Using Forena's Query builder you would create the required SQL statement (if you'd rather want to write the SQL with your favorite SQL editor that's another option).
Using forena's WYSIWYG report writer you would develop your custom report (if you'd rather want to write that report with your favorite XHTML editor that's another option).

Some more details about the sample report mentioned above:

Use the "Parameters" pulldown option, to select any other state.
Note the PDF hyperlink: using that link, you'll get a PDF version of that report. When creating such report, you could as well ask for other (or additional) report export formats, one of them is CSV (or XLS, DOC, HTML, ...). This is how the CSV equivalent version of that sample report looks like.

The Master Summary with drill down sample report demonstrates how you can also "link" various reports together (while it also shows some of the charting features of Forena). Click on either any of those bars in the chart, or on the total-hyperlink in tabular report below the chart. Doing so will bring you to the report "for the selected state" (= the first sample report mentioned above).

Direct access to data blocks

All data blocks are accessible directly via their url also, provided you have permission to access that block. Here are a few samples of that, for the sample report located at /reports/sample.states:

in XML format (= demo with anonymous access).
in JSON format (= demo with anonymous access).
in XML format (= demo without anonymous access).
in JSON format (= demo without anonymous access).

More info about supported export formats

Refer to my answer to "How to add a link to the CSV download to my module page, for a report created with Forena?" for more details about supported export formats.

Video tutorials

The Forena Video demos and tutorials contain quite some links to live demos. They should help a lot to get you started.

Disclosure: I'm a co-maintainer of Forena.


Here's the same issue on d.org.
In short: it's better to enable Search: search terms filter (Drupal core search module needs to be enabled too).


How to make a logo resize properly in a responsive theme

Add the following css to your site:

.view-logo img {
  max-width: 100%;
  height: auto;
}


How do I print a menu with links generated by my custom module?

Menus and paths are slightly different things...in hook_menu() you're defining paths that can be consumed; menus create the links to those paths - the two concepts aren't necessarily related (a path can exist without a menu link).

You can assign a particular router path to a menu using the menu_name property in your hook_menu() items, but that menu needs to exist already.

Fortunately Drupal provides a method for adding links to the top of a page through hook_menu(), and you only need to change one line:

$items['admin/custom/add'] = array(
  'title' => t('Add Custom'),
  'decription' => t('Add custom'),
  'page callback' => 'custom_add',
  'access arguments' => array('add custom'),
  'type' => MENU_LOCAL_ACTION, // <-- This one changed
  'file' => 'custom_add.inc',
  'file path' => drupal_get_path('module', 'custom') . '/includes',
);

That will put a link to 'Add Custom' at the top of the 'admin/custom' page; if you're using the Seven theme for administration it'll look like the 'Add Content' link on the content admin page:


How do I get the current language in custom user edit Twig file?

You can check language in twig as below:

{% if (language.getId() == 'en') %}
    Do something
{% endif %}


Remove id alias appending to confirmation page URL

Option 1 (preferred)

This can be done with some code in a custom module.

You can use hook_form_alter to add an additional submit handler to every webform:

function YOUR_MODULE_form_alter(&$form, &$form_state, $form_id) {
  // All webform id's start with webform_client_form so check for that
  if(substr($form_id, 0, 19) == 'webform_client_form') {
    $form['#submit'][] = 'my_webform_redirect';
  }
}

And then in the additional submit handler strip the query string form the URL:

function my_webform_redirect($form, &$form_state) {
  unset($form_state['redirect'][1]);
}

$form_state['redirect'] is an array that consists of 2 parts. The first is the actual URL, so in this case it will be 'contact-confirmation'. The second part is the query string (sid=12), so all we need to do is unset it and it won't be appended to the URL.

Option 2

If you are tracking lots of pages over your whole site then it may be desirable to implement a solution that ensures that no query strings will appear anywhere on the site. Do bear in mind that this will break any functionality that depends on query strings. For this solution you need to put the following in your .htaccess file:

RewriteEngine On
RewriteCond %{QUERY_STRING} !="" #if there is a query string
RewriteRule ^(.*)$ /$1? [R=301,L] #remove query string

For more information on this technique there is a blog article here.


One possible solution would be to alter the $theme_path global during hook_init(), although that would mean that all your theme files should be in another directory. I'm not sure if that's what you're going for.

If you just want to change some paths (ie for the stylesheets), alter the paths during hook_preprocess_page(), look up $vars['styles'] and change the paths there.


StringOverrides doesn't change the text in DCommerce "Add to Cart" Button

The fields I was trying to change ended up being hard-coded into drupal commerce, such that string Overrides, and even the Commerce Cart Overrides modules didn't help me get done what I needed to do completely.

So...I applied the hook_form_alter() functions in the bartik theme, because I couldn't get them to work in a stand alone module, although from what I read this would be better practice and then you don't have to remember what you changed where if you want to change themes etc.

So, combination approach got done what I needed in the end. Have to say, overall documentation is pretty opaque for a relatively easy fix and from googling, a relatively around a common problem.

Code snippet that might help:

function bartik_form_alter(&$form, &$form_state, $form_id){
dpm($form_id);
dpm($form);
if (commerce_form_callback($form_id, $form_state) == "commerce_cart_add_to_cart_form"){
$form['submit']['#attributes']['title'] = $form['submit']['#attributes']['value']=t("Add to Inquiry List");
}
if(strpos($form_id, 'views_form_commerce_cart_form_default')===0){
$form['actions']['submit']['#value'] = t("Update List");
$form['actions']['checkout']['#value'] = t("Submit List");
}
if(strpos($form_id, 'commerce_checkout_form_checkout')===0){
    $form['buttons']['continue']['#value'] = t('Proceed to final list submission.');
    }
if(strpos($form_id, 'commerce_checkout_form_review')===0){
    $form['buttons']['continue']['#value'] = t('Submit your inquiry list');
    }

}


Shawn.  OK, I had a content type of "listing." There is a "title" field which has the field type as "node module element" which is automatically created as a field by the view for this page.  This field, the title, links to a page displaying the full content.  I had to remove this automatic linking. I downloaded a couple of modules to hide the title, and created a new text field to replace the title field, strange enough, this was also converted into linkable text. I then edited "node.tpl.php" to remove the


As others have said, the user account with ID equal to 1 is a special account: It is one of the default accounts created by Drupal during its installation, and it is the only account to which every permission is assigned. (See @Clive's answer.)

What can be done is changing the password, and the email associated with that account.

Create a file in the same directory containing index.php, and add the following code.

define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$account = user_load(1);
$edit = array(
  'pass' => 'New password';
  'mail' => 'New email';
);

user_save($account, $edit);

With this code, everybody with access to the filesystem of the server can change the password, and the email of the user #1. I am not suggesting to change the password directly in the database because the password in clear; Drupal saves the hash obtained from user_hash_password(), whenever user_hash_password() is the function implemented by Drupal, or from third-party modules.

If Drush is available, changing the password is even easier. Everybody could execute the following command:

drush user-password <username> --password="<password>"


How do I get the username of the logged-in user?

You can use the global $user object:

An object representing the user currently visiting the site.
Contains preferences and other account information for logged-in users. When a user is not logged-in, the $user->uid property is set to 0.

e.g.
global $user;
$name = $user->name;
$id = $user->uid;

// or
$name = $GLOBALS['user']->name;
$id = $GLOBALS['user']->uid;


programmatically taxonomy update node DrupalDefaultEntityController error

Basically I would think that $value->tid when you are using it is not a number but an array. Because I do the same assignment and it works.

So I suspect you are misusing the taxonomy term you created. This is how I created the taxonomy in a function:

function create_new_term($term_name, $vocabulary_id, $language = LANGUAGE_NONE, $i18n_tsid = 0){
  $tid = db_insert('taxonomy_term_data')
  ->fields(array(
    'name'=>$term_name,
    'vid'=>$vocabulary_id,
    'language'=>$language,
    'i18n_tsid'=>$i18n_tsid,
  ))->execute();
  db_insert('taxonomy_term_hierarchy')
    ->fields(array(
      'tid'=>$tid,
      'parent'=>0,
  ))
  ->execute();
  print "Created new taxonomy term tid #".$tid." $term_name in $vocabulary_id<br>"."\n";
  return $tid;
}

And here is how I add that term:

$my_new_node->field_my_term['LANGUAGE_NONE'] [] ['tid'] = $returned_tid;

I hope this helps.


How do I update multiple rows in one single function call?

While you can probably update multiple rows using one call to db_query(...)->execute() (if you use a single SQL query that will updates multiple rows), that's not what the OP code shows. The code try to execute multiple SQL queries with a single call to db_query(...)->execute(), which is not supported by the API. Also, as stated in its documentation for Drupal 7, db_query() should not be used for update queries. Instead, use db_update().

The following would be the clean and safe way to do it with multiple db_update() queries

$counts = [
  30 => 4,
  32 => 5,
  34 => 1
];
foreach ($counts as $product_id => $count) {
  db_update('bestsellers')
    ->condition('product_id' => $product_id)
    ->fields(['count' => $count])
    ->execute();
}

It may also works with a query using a CASE in in the SET clause

db_query("
    UPDATE bestsellers
    SET count = CASE product_id
        WHEN 30 THEN 4
        WHEN 32 THEN 5
        WHEN 34 THEN 1
    END
    WHERE product_id IN (30,32,34)
")->execute();


You can try the Drupal Services, REST Server and 3-legged OAuth tutorial here. Just be pay intention in this part :

$oauth->fetch("$api_url/node/1");

This is just for creating the GET request. If you want to create the POST request. It should be something like.

 $oauth->fetch("$api_url/user/vote.json",array('nid'=>10),OAUTH_HTTP_METHOD_POST);


Backup_Migrate Module able to Create Backups but NOT Restore them

Please try with the Patch mentioned on following URL:
https://www.drupal.org/node/2320969#comment-9564267

Patch for make full site restore (and full site backup) work on Windows. The main
problem was in assumption that directory separator is always '/' but that's not true on Win. So wherever i've found '/' in operation on paths i've changed them to DIRECTORY_SEPARATOR constant.

Thanks!


How to exclude the result of one view from another one?

One thing that pops to mind, albeit dirty, is to use php in the argument and do:

views_get_view_result($name, $display_id = NULL)
Loop over resulting nids of your hot topics then explode them out separated by +
set the argument to exclude these nids.

Not the cleanest solution as it leaves you with php in the DB but it would work.


I believe the problem was due to the location of my .htaccess file. (The main problem was the Clean URLs.)

My original location was /var/www/drupal/sites/default/files; after, I moved it to
/var/www/drupal. The .htaccess file started to being read. Previously, it was not being read.

I hope this helps someone else! This also may not be the solution because I am having a different issue now.


How do I allow users to select published content on the site to be displayed on their profile page?

You might want to look into the Flag Module.  It provides links on nodes that allow them to be tagged/flagged. Then, with Views, you can create a block that will be displayed on user profiles with content flagged by that user.  In fact, it comes prepackaged with a "bookmarks" view that might be a good starting point for this.


Create a module for example module name is rose. In that module implement  hook_node_validate

function rose_node_validate($node, $form, &$form_state) {
       //Check to see if this is the node form data you want to change
    if ($form['#form_id'] == 'contentType_node_form') {
        //based on the value provided in
        $form_state['input']['field_name']['und'][0]['value'];
        $new_info_data = 'some logic'; //get the data you would like to save .
        variable_set('new_info', $new_info_data); //Save the data in a variable.
    }
}

Then implement a hook_node_presave. As per our example

function rose_node_presave($node) {
    //check if the node type is the one you want to change the value
    if ($node->type == 'content_type') {
        $new_info = variable_get('new_info'); //get the value which was set in validation variable_set()
        $node->field_name['und'][0]['value'] = $new_info;
    }
}

I have implemented this on Drupal 7. A user enters instagram user name and I get the instagram id from instagram api and save it. Let me know if more explanation is required.

In this implementation users enters only address I get the Lat and Lng based on the address provided and save it in the database.


In Drupal 7, Where is field settings data stored? (Not the field data)

Base field data is in field_config, and instance data is in field_config_instance. Rather than modifying them manually, though, you can always use the API:

$field = field_info_field('field_name');
$field['key'] = $new_value;
field_update_field($field);

Or for an instance

$instance = field_info_instance('node', 'field_name', 'article');
$instance['key'] = $new_value;
field_update_instance($instance);

Using the API will clear the appropriate caches, and it's just a better idea than editing the data manually.

Either way, make sure to backup the database first in case something goes horribly wrong :)


Views: Apply a wrapper to every 3 and 6 group of rows

A few tips about the code:

You also can make the logic in the preproccess or proccess hooks if you prefer
To complete the information given by Jack: Modular arithmetic . This theory help us to build our strategy.

Aplication in a preprocces hook to separate the logic from the template:

function YOURTHEME_preprocess_views_view_unformatted(&$vars){

   $vars['prefix'] = array();
   $vars['suffix'] = array();
   $group = 1;
   $last_row = count($vars['rows']) -1;

   foreach($vars['rows'] as $id => &$row){

     $vars['prefix'][$id] = '';
     $vars['suffix'][$id] = '';

     // Apply modular arithmetic
     $remainder = $id % 9;

     // First div => 3 items
     if($remainder == 0){
       $vars['prefix'][$id] = "\n
";
     }

     if($remainder == 2){
       $vars['suffix'][$id] = '\n
';
       $group++;
     }

     // Second item => 6 items
     if($remainder == 3){
       $vars['prefix'][$id] = "\n
";
     }

     if($remainder == 8){
       $vars['suffix'][$id] = '\n
';
       $group++;
     }

     // Close the div in case there are not enough items
     if($last_row == id && $remainder != 2 && $remainder != 8){
        $vars['suffix'][$id] = '\n
';
     }

   }

}

Your template in you theme that will overwrite the default template provided by views:

<?php if (!empty($title)): ?>

<?php print $title; ?>

<?php endif; ?>
<?php foreach ($rows as $id => $row): ?>
  <?php if (!empty($prefix[$id])){ print $prefix[$id]; } ?>
    <div <?php if ($classes_array[$id]) { print 'class="' . $classes_array[$id] .'"';  } ?>>
    <?php print $row; ?>
  <?php if (!empty($suffix[$id])){ print $suffix[$id]; } ?>

<?php endforeach; ?>


VBO calls entity_save after custom action is triggered. How to stop that?

This is an old issue, but I literally just had the same problem and after banging my head off of it all day I found upon a solution through the d.o issue queue.

https://www.drupal.org/node/2254871

I applied the patch from #42 and it solved it right away after setting 'behavior' => array().

Hope this helps someone else.


Changing user register/login pages into secure sub domain

Yes it is possible through Services module.

First you need to redirect http://www.mysite.com/admin URL to https://admin.mysite.com/ URL either through Apache redirect or through drupal redirection. Then you will capture all the information of user at this site (https://admin.mysite.com/) and consume the same at http://www.mysite.com/admin site through services module.

You can send user information in JSON or XML format, some other formats are also available there these too are more in use.

Now let's take a example:

Site: https://admin.mysite.com/
1. Created user signup page here with some fields. Here I am taking following fields and send these fields data using JSON to respective URL (http://www.mysite.com/user-register/user/register).

{
    "name": "testuser",
    "pass": "12346",
    "mail": "test@example.com",
    "conf_mail": "test@example.com",
    "field_mobile_number": {
        "und": [
            {
                "value": 12345678
            }
        ]
    },
}

2. Similarly for Sign in page, create form with two fields name and password and prepare following JSON that we would consume to this URL (http://www.mysite.com/user-register/user/login).

{
    "username": "admin",
    "password": "admin123"
}

That's done from this site. Now move on to another site.

Site: http://www.mysite.com/

Enabled Services module.
Create services end point.
For more security you can also use Oauth module.
Please go through following tutorial and follow the same steps and you would be ready to consume above services on this site.

Register User with Services (JSON) with Custom Fields

http://www.wdtutorials.com/2013/04/11/drupal-7-tutorial-web-services-basics


I realize this is an old thread but it shows up high in the Google search results.

Just set your submit button's Ajax event to 'click'. I believe its default value is actually 'mousedown' which won't make it trigger when the enter key is pressed within a field of the form.

If you set it to 'click', that event will trigger when the submit button is clicked as well as when the enter button is pressed within a form field.


Alter views exposed filter using any hook function

This will be work by using hook_views_default_views_alter function. This function should be defined in MODULE_NAME/views/MODULE_NAME.views.inc file. Need to include this file on .info file as files[] = views/MODULE_NAME.views.inc.

function MODULE_NAME_views_default_views_alter(&$views) {
        if (array_key_exists('MY_VIEW_NAME', $views)) {
          $options = array(
          0 => 'Blocked',
          1 => 'Active',
          );
          $display = $views['MY_VIEW_NAME']->display['MY_VIEW_PAGE'];
          $display->display_options['filters']['field_status']['id'] = 'field_status';
          $display->display_options['filters']['field_status']['table'] = 'field_data_field_status';
          $display->display_options['filters']['field_status']['field'] = 'field_status';
          $display->display_options['filters']['field_status']['value'] = $options;
          $display->display_options['filters']['field_status']['exposed'] = TRUE;
          $display->display_options['filters']['field_status']['expose']['operator_id'] = 'field_status_value';
          $display->display_options['filters']['field_status']['expose']['label'] = 'Status';
          $display->display_options['filters']['field_status']['expose']['operator'] = 'field_status_value';
          $display->display_options['filters']['field_status']['expose']['identifier'] = 'field_status';
          $views['MY_VIEW_NAME']->display['MY_VIEW_PAGE'] = $display;
          }
    }

Hope this may helpful for anyone who are facing same issue.


Is there a function to clear the watchdog log inside a module?

The best way to do this is via drush:

$ drush help watchdog-delete
Delete watchdog messages. Arguments or options must be provided to specify which messages to delete.

Examples:
 drush watchdog-delete all                 Delete all messages.
 drush watchdog-delete 64                  Delete messages with id 64.
 drush watchdog-delete "cron run           Delete messages containing the string "cron run succesful".
 succesful"
 drush watchdog-delete --severity=notice   Delete all messages with a severity of notice.
 drush watchdog-delete --type=cron         Delete all messages of type cron.

Arguments:
 severity                                  Delete messages of a given severity level.
 type                                      Delete messages of a given type.

Aliases: wd-del, wd-delete


Using the l() function within a node description field

If you already turned old links into node/28 format, you don't need to touch your content any more. You can simply use Internal Links module that will replace it live with the current alias. The benefit is - with this module if alias changes, content still links to a node by node's id, and links stays valid.

  The Internal Links Title filter inserts HTML title attributes into links to other nodes on a site (if no title attribute already exists) using the linked node’s title as the HTML title attribute’s value. It also replaces href values which are in the “normal Drupal path” form (e.g. ) with a URL alias, if one exists.

Emphasis mine.


Views : Make a block related to a page (with flag/addthis/privatemsg as fields in this block)

I found a way this week to get the good behavior.

i understood my mistake! My url was like that www.example.com/my-product/2 (made with pathauto)

When i selected content ID from URL my block was empty because he couldn't retrieve the good argument from the url (because my node id was in second position)
But when i go to www.example.com/node/2 it works fine

To resolve my problem i select raw value from URL  instead of content ID from URL (because with that option we can select which argument we want to retrieve --that was the second for me because of my custom url)

In summary i follow this step :

Add contextual filter : content: nid
click on it, go to WHEN THE FILTER VALUE IS NOT AVAILABLE
Click on Provide default value
Select raw value from URL
Select the argument you want to retrieve from the url (path component)
I check Specify validation criteria
Validator : content
Filter value format : node id
Action to take if filter value does not validate : no result

It was a stupid mistake :) but i learn some stuff :)


How to display events in chronological order?

Your screenprint and your generated SQL statement shows that your current view is FIRST sorted by node_created_order. Though from your question it seems that you want it to be sorted by "start date of the event".

So just delete the first field in your list of SORT CRITERIA and see what happens next ...


It can happen if you are using drush launcher (https://github.com/drush-ops/drush-launcher). This tool allows you to type "drush" in your Drupal directory, instead of "./vendor/bin/drush", but it can confuse xdebug.
Using "./vendor/bin/drush" may fix the problem.

Additionally, you may also have to set an environment variable in your PHP container:

export PHP_IDE_CONFIG="serverName=my_server"

... where my_server is the name of the server in

Preferences / Languages & Frameworks / PHP / Servers

where your path mapping is set in PHP storm.

You may also wish to enable the option: "Break at first line in PHP scripts" and then run your drush commands - as often it can be tricky to set breakpoints in the correct place when running drush.


Create Content Types that create other node for fields

You don't want to make a new node - just to show field value on separate page. Use Views module to accomplish that.

Create new View based on Content with Page display (path node/%/test_field).
Set Contextual Filter to Node NID (and make it global with "All display" option). Provide default value: Content ID from URL.
Choose field you want but remember to set "This page (override)" option.
Create as many page displays as you want with new path (based on the same rule - node/%/some_name) and select another field (under Fields)

That is how it should looks like:

[EDIT]
Install Sub-pathauto module for second level path aliases.


Multiple currencies in commerce kickstart

Commerce Multicurrency may help you, see this screencast form Commerce Guys.


This is not something that should be done in the theme layer. I would look at solutions like ACL or Content Access.

If you really need to code your own solution for some reason, create a custom module and use the necessary hooks, such as hook_permission.


How do I prevent a link on an overlay page from opening in another overlay page in Drupal 7?

I was having the same issue.

There is a patch here.


MEGA MENU please help trying to assign it the right region but no luck :(

It depends a bit on your theme but for bartik here is answer:

In theme info file add this:

regions[my_custom_region] = My Custom Region

Then copy page.tpl.php from the base theme, or else from modules/system directory into your theme's folder. Open it up, and look for the bit where it prints out the main menu. It will be something like this:

<?php if ($main_menu || $secondary_menu): ?>

        <?php print theme('links__system_main_menu', array('links' => $main_menu,
'attributes' => array('id' => 'main-menu', 'class' => array('links', 'inline',
'clearfix')), 'heading' => t('Main menu'))); ?>
        <?php print theme('links__system_secondary_menu', array('links' =>
$secondary_menu, 'attributes' => array('id' => 'secondary-menu', 'class' =>
array('links', 'inline', 'clearfix')), 'heading' => t('Secondary menu'))); ?>

<?php endif; ?>

Remove this bit, then add this in its place:

<?php print render($page['my_custom_region']); ?>

Now clear your cache and place your block inside it.

Rename the my_custom_region to whatever you like, but make sure it is same in info file and page.tpl file.

If you don't want to replace the main menu then you can just paste the new code underneath the main menu, and in the menu settings UI select no main menu to hide it.


Registration and Login form having different styles

take a look at the themekey module:

  ThemeKey allows you to define simple or sophisticated theme-switching
  rules which allow automatic selection of a theme depending on current
  path, taxonomy terms, language, node-type, and many, many other
  properties. It can also be easily extended to support additional
  properties exposed by other modules.


Is it possible to insert blocks into content using the paragraphs module?

you can install the Viewfield module, create a view, then create a Paragraph with a field of type Viewfield which allows you to insert the view as content of the field.


It sounds like you need to make a View of product display nodes, and not product entities.

The product display node has the product reference field on it, which provides the 'add to cart' formatter.

You can also show the product image and add other arbitrary text fields to the display node


There is a template_preprocess_panels_pane

/**
 * Implements preprocess_panels_pane().
 */
function YOURTHEME_preprocess_panels_pane(&$vars) {
}

Documentation

If you want to change the output of a field you have:

/**
 * Implements hook_panels_pane_content_alter().
 */
 function YOUR_MODULE_panels_pane_content_alter($content, $pane, $args, $contexts) {
  $content ...
}


The list of language objects is built up by the core function language_list(), which you can use to overwrite the global $language object if you need to:

// Get the list of languages
$languages = language_list();

// Set up the new language code
$new_lang_code = 'fr';

// Make sure the required language object is actually set
if (isset($languages[$new_lang_code])) {
  // Overwrite the global language object
  global $language;
  $language = $languages[$new_lang_code];
}


How to minify JS and CSS in D7 without using modules

This is actually a module, but the Speedy module minifies core JS, has a stable release, and is regularly updated.


Vote Up/Down Widget only visible to admins

Set the permission for authorized users to be able to vote.

There will be a checkbox you need to tick.

Visit /admin/user/permissions and look for permissions relating to this module.

See this page for more help.


Search Api, fulltext and string for search bar and facets

I had an issue similar to this with 2 separate fields, Country and City.
Country was a taxonomy term while City was a textfield. I wanted to use both for fulltext search and as facets. In my Search API Index I added related fields for my Taxonomy (Country) and used the name (Country:name) as a fulltext field for my search bar. The thing is that the City when indexed as a fulltext didn't work in combination with the Country facet, and when I changed it to string it didn't work with the search bar.

Solution:

Leave your field (City) as a string field
Go to your Search API Index
Click on "Filters"
Check "Aggregated Fields"
Add new field and select your desired field, for example "City" and aggregation type "fulltext"
Go to your view, where you use the fulltext search, click on it and in the Searched fields you will see the aggregated field you had added before.

It should work fine now. If not, try re-indexing the items, clear your cache, double check that the field is set to be indexed, etc.


How to disable error messages to screen while mysql service is down

Having just run across the same issue, to avoid hacking the core files you can set the default error reporting level in your site's settings.php by adding the following line:

$conf['error_level'] = ERROR_REPORTING_HIDE;

Since the error_level variable is normally set from the database the setting otherwise defaults to DISPLAY_ALL if MySQL is down.

Note: this means the error level can no longer be configured through the admin interface (admin/config/development/logging).


Field values added programmatically dispear after a certain time

(Re comments)

That's the reason then. Those fields being in state, which means drupal thinks they were deleted and is trying to delete conent in them.

Remove them from there. Probably OK to drop the whole rows, check all the other fields in there. You might have some deleted field tables that you need to clean up manually.

I've seen someone else have this problem, what we couldn't figure out is how it happened. Please open a core issue (probably critical) and try to describe what you did.. delete fields, config import, create through manual config import. Anything you can think of that might have caused this.


How to re-create content types using the feature module which removes deleted fields?

The answer to your question boils down to what is mentioned by the Features maintainer in this comment, i.e.:

  FInally going to mark this as "won't fix" until somebody proposes something better.

  1) Features will never do anything that might cause content to be lost on your site. This includes deleting fields. Just because you remove a field from a feature doesn't mean you might not still have content stored that would be lost if features auto-deleted it. I've never been in favor of any sort of auto-deletion.

  2) Now that fields are split into bases and instances, this gets even more complicated.

The next comment in that same issue includes a link to a 32 steps process, which describes Deleting a Drupal Field Saved in Features. IMHO this is "as good as it gets" today (and my recommended work around until further notice).


Making one term in a vocabulary priority and print it separately

Easiest non coding way make a separate vocab and disable tags and multiple select for the new vocab then theme as required.


Colorbox + jCarousel + slideshow + compact mode?

You basically want to output the images inside an HTML list, using, say views, and then install a jQuery plugin to do the slideshow for you.

You can use an existing module, however we often find it's easier to just install the jQuery plugin, and initialise your slideshow yourself.

Assuming your view outputs an HTML list, which is pretty easy to get set up, the rest isn't so much a Drupal question as it is a case of following the instructions for the exact slideshow plugin you're using.

We quite like http://jquery.malsup.com/cycle/ which has all the usual options, good documentation, and works well in a lot of different ways.


IE8 is detecting the pages as mobile media

As you haven't provided any information this is a complete guess, based on the assumption that you're using the Omega 3 theme with respond.js.

There's a known issue with IE8, respond.js and CSS aggregation. To fix it, you can implement hook_css_alter() in your theme like so:

function MYTHEME_css_alter(&$css) {
  // Enable respond.js to work with Omega.
  foreach ($css as $key => $value) {
    if (preg_match('/^ie::(\S*)/', $key)) {
      unset($css[$key]);
    }
    else {
      $css[$key]['browsers']['IE'] = TRUE;
    }
  }
}


How to add custom functionality on per-date base to nodes that use date fields for an event ticket system?

In the database (the appropriate table for your date field), you have a column called 'delta' wihch start from 0

In your example
Date A (delta = 0)
Date B - Date F (delta = 1)
Date G (delta = 2)

Your probably can add an hidden (for non-admin user) field in your node type (for example an textfield serialized array) to store the boolean value for each delta. This can be done programmaticly with rule an php algorithm on each node_save. In view you can also get the delta value


How do I have multiple copies of same menu, but with different disable options for each

Drupal doesn't support anything like that, and I must admit it doesn't make sense to me that it would.

As soon as you have two menus that need to show different things, you need two menus. Setting arbitrary rules on how that second menu should partially sync itself with another, arbitrary, menu, is a conceptual nightmare. I can't even imagine what the UI would look like for that.


Get nodes of specified content type with REST

The only way that core offers is building a view with a REST display. That is, in fact, the only way in core to have collections (a list of resources) for rest.

See https://www.drupal.org/project/graphql for another approach, that allows to execute a sort of query through services.


How is the file data in the database table file_usage created and managed?

The code used by Drupal to delete temporary files is the following one. (It runs during cron tasks.)

  // Remove temporary files that are older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
  // Use separate placeholders for the status to avoid a bug in some versions
  // of PHP. See http://drupal.org/node/352956.
  $result = db_query('SELECT fid FROM {file_managed} WHERE status <> :permanent AND timestamp < :timestamp', array(
    ':permanent' => FILE_STATUS_PERMANENT,
    ':timestamp' => REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE,
  ));
  foreach ($result as $row) {
    if ($file = file_load($row->fid)) {
      $references = file_usage_list($file);
      if (empty($references)) {
        if (!file_delete($file)) {
          watchdog('file system', 'Could not delete temporary file "%path" during garbage collection', array('%path' => $file->uri), WATCHDOG_ERROR);
        }
      }
      else {
        watchdog('file system', 'Did not delete temporary file "%path" during garbage collection, because it is in use by the following modules: %modules.', array('%path' => $file->uri, '%modules' => implode(', ', array_keys($references))), WATCHDOG_INFO);
      }
    }
  }

file_usage_list() is the function that queries the "file_usage" table.
The function that adds a row in that table is file_usage_add(); looking at the functions/hooks that calls it, I conclude that the "file_usage" table is used for managed files. Since you are not deleting the files with a row in the "file_managed" table, I would say you can avoid checking the "file_usage" table.


Drupal 8 Metatag and Media Entity modules to set meta image tags

If I understand your question correctly you'll need to do the following:

Check on your modules page that the "Metatag: Open Graph" submodule
is enabled.
Go to metatag config page (Configuration > Search and
metadata > Metatag).
Add a new "default metatag" and select your
content type in the "Type" selectbox.
Fill in the rest of the fields similar like following picture (just don't forget to use your own field names:

Here are some things you need to know about my tokens:

field_teaser_img: is the fieldname of my media entityreference on my
content type.
field_me_img: is the fieldname of my image field
on my media entity type.
facebook: is the imagestyle name I
created for these metatags
height, mimetype & width: are
property fields of the media entity type yet I didn't create those
fields but it does seem to work.

I hope this helps.


Configuring Aegir to Set Custom File Paths

The answer is to mv siltes/firstsite.com/files to /var/nasmount, then create a symbolic link to it.
(from inside your sites/firstsites.com directory,  mkdir /var/nasmount/firstsite.com, mv ./files /var/nasmount/firstsite.com, ln -s /var/nasmount/firstsite.com/files files).

I would put this in a script so this becomes a drush command, then make it run at the end of the aegir create a site process.

I'm not an expert of where to put this script and/or how to create it.


separate the page title from page content

as @Hodba Khalaf mentioned in comment Page title is a block go to admin/structure/block a block called Page title added by core

But you can render page content without specific field in twig by using without filter for example you can render page content without page title try something like:

    {{ page.content|without('bartik_page_title') }}

Note : in the example above page title block element is bartik_page_title because i use bartik theme so it could be different in your case, dump the page.content to get the key of your title page.


How can I make a module's configuration exportable by features?

Instructions are in the Features API.txt, which provides several examples of how to better integrate your module with Features.

The easiest way seems to be building your module around the CTools Export API. Here's a pretty good article explaining how to do that.


EntityMalformedException: Missing bundle property on entity of type node


Can nodes created using Feeds be updated automatically?

I believe as long as you have a primary/unique ID for each item in your CSV this should be very easy to do with the Feeds module.  When you do not have primary key to work with things get tough.


Distinguishing form being built for rendering versus submission

Take a look at the $form_state elements. You'll want to look at 'submitted', 'rebuild', 'cache', 'programmed', etc... depending on your use-case.  You can get a good idea of those elements and what they mean in drupal_build_form.  I typically use $form_state['submitted'].


How to include a caption (a cck field) in lightbox?

Both the caption and the description will be displayed on the image preview.


Detaching Drupal Behaviors of another module

we faced the same issue here we are using lightbox module what we did is we dint used any extra module in common we wrote a Behaviour to add a external class and added condition to when colorbox is added remove external class

Define your base URL in any module in it

"Drupal.settings.baseUrl"

/* external links*/
 Drupal.behaviors.external_link = {
    attach: function (context, settings) {
      $("body .view-content a").once(function() {
                    var anchorlink = '';
                    anchorlink = jQuery(this).attr('href');
                    if(anchorlink != "#" && !$(this).hasClass('lightbox-processed'))
                    {
                        if(!(anchorlink.lastIndexOf('http') == -1) && anchorlink.lastIndexOf(Drupal.settings.baseUrl) == -1 && !jQuery(this).hasClass("external"))
                        {
                            if($(this).parent().hasClass('lightbox-processed')){
                                    jQuery(this).removeClass("external");
                            }else{
                                    jQuery(this).addClass("external");
                                    var targ = "_blank";
                                    jQuery(this).attr("target", targ);

                            }
                        Drupal.attachBehaviors();
                        }
                    }
      });
   }
  };

instead of lightbox-processed replace your class
hope this will help you :)


For your use case, I'd suggest using Organic Groups or the Group module.

Both modules allow grouping users / content. So each family could be a group with the parents / kids as members. Address information would be stored using a common group page, while the parents could still have different profiles.

In a later stage of your site you could also create groups containing all kids of a class and so on.


You'll want to use the Rabbit Hole module for this.

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

You can block the view route for nodes by content type.


This is a global scope variable and you can access it by using $GLOBALS['base_url'] instead or calling the core base_path() function to pull it into your computed field definition.


When should I use the private file system instead of public file system?

You should use private file system for files to take under control of your drupal installation.

If you have some content with files and pictures you want to be visible only for certain users or groups, then you should save it in private file system. Perhaps paid content or sensitive content.

Content and images which is public to all do not need to be in private file system. For that it is better to use public file system to save server resources.

All files in public space are usable for everyone who knows the url.
Files in private space are not. You can get them only if drupal serves it to you.


Is there a way to create a taxonomy path redirect?

Instead of hook_term_path you can use hook_entity_info_alter.

A small example

function MYMODULE_entity_info_alter(&$entity_info) {
  $entity_info['taxonomy_term']['uri callback'] = 'MYMODULE_term_uri';
}

and then you can implement you version of MYMODULE_term_uri function.

Hope it helps.

Also if you want the D7 version of the module you mentioned you should try
http://drupal.org/project/entity_path


How to programmatically render a node's teaser using the theme layer?

node_view() is the standard function for rendering nodes, e.g.

$node = node_load(1);
$view = node_view($node, 'teaser');
$rendered = drupal_render($view);

There is a node theme defined by the node module (in node_theme()) but I've never actually seen it used.


I think you can use Access Control Lists. It does not have a UI on its own but your can use probably content access to give you the ACL functionality.

NOTE: After installing and configuring the ACL is not part of the user profile but part of the node (as you have suggested in your question)


How to add a pane (view content pane) to an existing panel page via a Feature module or programmatically?

This looks like the start of what can lead into you what I call "Features Hell". :)

It's possible to make features more maintainable and minimize conflicts if you organize them by small groups or single feature components. Here's what I mean:

You have content types X and Y
You have, I assume, panelizers for content type X and Y
You have views with content pane displays that you want to add to a
panelizer

This can be done by divided up your features into four different modules.

foobar_field_bases: contains the fields from content type X and Y under the "Field Bases" component. This stores the global settings of the fields.

foobar_content_types: contains content types X and Y from the features Content Types component, and the content type fields under the Field Instances component.

foobar_views: contains all your views

foobar_panels: contains all panel-related components such as panel layouts, panel renderers, panelizers, page managers.

It may seem like that's harder to maintain because you have more modules now, but consider your issue. You want to update the panelizer content with a view content pane. All you do is make sure the view is in foobar_views. If not, recreate foobar_views with your new view. If it is, update the foobar_views feature so it contains the new display in the feature module. Then do a feature update on foobar_panels.


How to copy forum structure Advanced Forum?

What you should do is something like an Install Profile: https://drupal.org/developing/distributions

You can create Install Profiles from exiting sites with:
https://drupal.org/project/profiler
https://drupal.org/project/profiler_builder

What I would do is make the first site exactly how you want it and then turn that into a Install Profile.

An easier way to do this if you have AEgir is to just clone your first site and then keep it as a template to clone others.


Redirect, change or replace the "user/register" link

The easiest solution I think here is just redirect it at the Apache (.htaccess) level with a rewrite rule:

RewriteRule ^user/register$ /civicrm/contribute/transact&reset=1&id=1 [NC,L,R=301]


Am I able to use dynamic parameters in libraries configuration files?

You should be able to use hook_library_info_build(). It's a new (to D8) hook that allows you to define libraries at runtime.
Here's the change record that talks about it's introduction. It's unlikely to go anywhere, but here's the description from the change record:

There was no way to dynamically register libraries. Using hook_library_info_alter() to register new library is possible but doesn't end well in alter/weight.
Therefore a new hook is created namely hook_library_info_build()

Alternatively; you could potentially add the hook as normal in your example.libraries.yml file, and then use hook_library_info_alter.


Set up Solr with the class EdgeNGramFilterFactory. This will not catch 'eautiful' instead of 'beautiful', but will give results on bea, beau, beaut and so on depending on minGramSize and maxGramSize. IMO this will be sufficient for most searches.


How to send password expire notification to users regularly?

Password Policy is by far the best module in D7 to manage your password requirements.

You can use this module to set an expiration time and send a notification email.


For the solr core name, try using just "drupal8" instead of "/index/drupal8"

Here are the settings I'm using locally:


Token Filter does the trick. After the module is enabled, you can edit or create create a text format that replaces tokens with text: admin/config/content/formats


Filter criteria affecting different displays in same view

Whenever you apply any filter criteria / sort criteria / contextual filters / relationships; you have to make sure you apply settings to current display (page/block) only. In this way the current setting doesn't interfere with other displays.


Removing div wrapper container of paragraph field and get only the plain text in twig

You shouldn't do {{ content.field_home_slide_snippet[0]|raw }}. You should do {{ content.field_home_slide_snippet }} and edit the twig template for field--field-home-slide-snippet.html.twig to have no HTML wrappers. Copy field.html.twig to your theme and edit as needed.


_title in *.routing.yml and title in *.links.menu.yml are translatable by default. Go to user translation (/admin/config/regional/translate) and search there for 'Assortment' and translate it.

The path is not translatable. See this similar question:

Translating paths in routing.yml

In the answer you find some ideas.


Programmatically load and submit the user form

You can try to prepoulate value of any form programmatically & submit like this

$form_state = array();
$form_id = 'invite_form';
$form_state['values']['email'] = 'abc@xyz.com';
drupal_form_submit($form_id, $form_state);

If you want to gather data during user save as mention in question use hook_user_presave.


EntityFieldQuery: number of field values as condition

Seems like stating the obvious but you need to count the number of values in 'field_images', then you can set the condition to check that result and make sure it is greater than 0.

There's a good overview of adding expressions and conditions with the count() function on this question.

You'll also need to perform a join between 'node' and the table that holds your field values before you make your count, something like this:

$query = db_select('node', 'n');
$query->join('field_images', 'fi', 'n.nid = fi.nid');
...rest of query


I have resolved it by commenting redirection code from hook_login and added redirection code related changes in ajax callback function itself. Here is my code.

function setMessage(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {

     $response = new AjaxResponse();
     $current= \Drupal::currentUser();
     if ($form_state->hasAnyErrors()) {
         $response->addCommand(new ReplaceCommand('#modal-form', $form));

     }
     else if (!$current->id()) {
         $response->addCommand(new ReplaceCommand('#modal-form', $form));
     }
     else {
         $command = new RedirectCommand(' ');

         return $response->addCommand($command);
     }
     return $response;
}


try http://drupal.org/project/views_geojson

with the latest version of views_geojson and openlayers you can define a view (of type geojson) that accepts a bounding box as a parameter.

With openlayers you can set the layer to use a bbox strategy so when you drag the map around it will send the bbox coords to the geojson view and just return points within that area.

I am new to Drupal and Im not going to lie this was a bit of a bastard to setup because there is not much documentation. I couldn't get the bbox contextual filter to work so I setup a custom filter that used top,bottom,left,right then wrote a rewrite rule in an .htaccess file that split the default parameter passed from the openlayers front end (a GET variable like BBOX=42,124,43,125) into the four filter parameters. This will NOT work if you expect your map to cross the equator or 0 meridian. But it works for me and I still hope to get contextual filters working at somepoint.


Insert some data in comment upon comment submit

Since you didn't say which version of Drupal are you using, I'll assume that you're talking about D7.

You need to use hook_comment_presave().

function YOUR_MODULE_comment_presave($comment) {
  // Do this only for new comments.
  if (!$comment->cid) {
    // This code will insert the subject as heading.
    $subject = '<h2>' . $comment->subject . '</h2>';
    $comment_text = $comment->comment_body[LANGUAGE_NONE][0]['value'];
    // Set the value.
    $comment->comment_body[LANGUAGE_NONE][0]['value'] = $subject . $comment_text;
  }
}

However, do bear in mind that you will need to handle somehow editing existing comments as well.

Hope this helps.


Taxonomy term not found using tid from term reference

First, don't use 'und', you should be using LANGUAGE_NONE instead.

Your code works, so you might have a data inconsistency on your database, are you sure that the term id 7 really exists?

You can use entity api metadata wrappers to access easier to the field information, or if you're not  using Entity API module, the function field_get_items is a better way to access the information.

$user_suppliers = array();
$items = field_get_items('node', $user_selling, 'field_suppliers');

foreach($items as $item) {
    $user_suppliers[] = $item['tid'];
}

$firstsupplier = reset($user_suppliers);
$first_supplier = taxonomy_term_load($firstsupplier);


You should check out https://drupal.stackexchange.com/a/54387/4387

function MYMODULE_some_form($form, &$form_state) {
  // If the form has been submitted, output something related to the submission
  if (!empty($form_state['values']['some_field'])) {
    // Get data from database and show second step fields.
    $form['user_name'] = array(
      '#type' => 'textfield',
      // ...
    );

  }
  else {
    // Otherwise build the normal form (first step).
    $form['user_id'] = array(
      '#type' => 'textfield',
      // ...
    );
  }

  return $form;
}

function MYMODULE_some_form_submit($form, &$form_state) {
  $form_state['rebuild'] = TRUE;
}


Need Module for Images/Video in Node, works with Views

For handling the video, check out the Media module or the Video module.  These will allow you upload, manage, and reuse video files.

For images, these features have been put into Drupal core, so you shouldn't need an extra module for uploading, managing, and displaying images.

Once set up with that, you can theme the display of the fields and if you choose, add other modules (such as Lightbox2) to enhance the user's experience).


Alter values available in node reference field based on term reference

It looks like I am late to answer your question :), but I hope this will help someone.

Using Dynamic dependent fields you can achive this, but it support Entity Referencefield not Node Reference
Documentation for Dynamic dependent fields


Extra "mystery" markup being printed to page

If I view source on the page you can see there is a unclosed anchor tag in this chunk:

Posted in Classroom Ideas & Resources

Is this a hard-coded chunk of html in a view? Looks like you have mixed around the closing


How to add different installation profiles in drupal 7

You might be looking for the Profiler Builder module:

  Profiler Builder is an extension of the Profiler installation profile simplifier. This module creates a downloadable tar package that gives you a well made installation profile and associated drush make file based on the site its installed on. This is a fast, simple way of creating a distribution with options that take into account either local host development or drupal.org packaging scripts.


connect apache solr to a custom search function

You dont need a module for this. Activate your solr module, index your content and the core drupal search will be replaced by the solr search.
There is nothing else you need to do. From then on, every search you make using the domain.com/search/site url will be automatically directed to solr.

It is just a matter of setting the right options in the solr module.


Will this work?
Yes
Is there a smarter method?
Drush + drush make
Drush is a command line tool that you can use for various things, one of them is to create a site. With a drush make file, you can save all of the modules you use (including version and even patches applied to them if needed). Once create you could recreate all of the modules by doing something like this:
drush make --no-core --contrib-destination=[path to the contrib folder like sites/all] [path to the make file]

You can read more about drush and drush make which has documentation about usage.
Also backup and migrate will or can add a drop syntax, so that it automatically drops tables when restoring the database. So using it, you wont need to wipe out your database completely. If need be, you can truncate it so you wont have to setup permissions again.


Which cache have to clear to update new hooks?

To register a new hook, you can clear the following caches:

cache_clear_all('module_implements', 'cache_bootstrap');
cache_clear_all('hook_info', 'cache_bootstrap');

More info: https://api.drupal.org/api/drupal/includes%21module.inc/function/module_implements/7


Is it possible to get original configuration when another Config Split is activated? (CONDITIONAL SPLIT is used)

This is a follow-up to my comment on your question with some references:

When using Configuration Split to distinctively use a certain conditional configuration on your environments, then you won't be able to access both, your development and production values at the same time (without reading in these splitted configurations manually).

The reason is, that configuration split hooks into the import/export process of your configuration. Once you import your configuration, the values for the respective environment will replace your database-stored configuration.

If you need to access both values within the same environment, you should change from config split to configuration overrides.

By keeping the production API value database stored across all your environments (in your configuration files that apply to all environments) and having your test API value defined as override within your e.g. settings.local.php file, you'd be able to access both values using Config::get and Config::getOriginal within your dev/staging environments, while only the database stored value will be available in your production site.


How do I filter a view for untranslated content?

You could use the following 2 views filters
Content: Revision translation affected (!= False)
Content: Default translation (= True)

for more details go to a more complete answer How to create a list of untranslated content in views?


How to check whether one's current User Points are negative with the Rules module?

global $user;
$num_pts = userpoints_get_current_points($user->uid, 'all');
$neg_pts = $num_pts < 0;


Message "No pending update" after update.php (update module)

The "no pending updates" message means that there are no DB updates to be run. At that point, you are safe to go on with your normal process, which may include a few more steps:

If you use features, check to see if they have been overridden.
Clear caches.
Take your site out of maintenance mode.


Domain Access separate home page per domain does not work

If you are using panels, you can create one homepage, but with separate variants for each domain. We use this approach for ~12 sites running on one drupal instance.


Multiple Relationships in CiviCRM Views Integration

You can do this with a custom module and using the preprocess views hook to pass in the contextual filter. The filters are passed into the $args[] variable.

You also may need to enable multiple values in a contextual filter, if you have more than one relationship from Contact A to Contact B, in this case this is multiple employers. This is under Contextual Filters > Advanced > Allow multiple values.

You do not add % to the path as you would normally do with a contextual filter as we are programmatically inserting it.

Create a custom Drupal module with the following code

/**
* @implements hook_views_pre_view().
*/
function HOOK_views_pre_view(&$view, &$display_id, &$args){

if($view->name == "my_view") {
      // Check that we are altering the correct view based on and $view->name
      civicrm_initialize();
      require_once 'api/api.php';
      //get the matching civi id for the current user
      //This is using Civicrm version 4.4.6

      global $user;
      //first get the current user's Civicrm record
      $params = array(
         'version' => 3,
         'sequential' => 1,
         'uf_id' => $user->uid,
      );
      /*The contact ID is in $result['values'][0]['contact_id']*/
      $result = civicrm_api('UFMatch', 'get', $params);

      $params = array(
          'version' => 3,
          'sequential' => 1,
          'relationship_type_id' => 5, /*get your relationship ID from /civicrm/admin*/
          'contact_id_a' => $result['values'][0]['contact_id'],
      );
      $result = civicrm_api('Relationship', 'get', $params);

      //temp stores the string which will be passed to the $args[] array
      $temp = "";

      //loop through the a => b relationships, and append all the ids of contact b
      foreach ($result[values] as $key => $value ) {
         if ($key > 0)
            $temp .= "+";
         $temp .= $value['contact_id_b'];
      }
      // populate the $args contextual filters array with the ids.
      $args[] = $temp;
   }
}


How to resend emails that Drupal already sent?

Step 1: Create a view of all these bookings

First think of a way to create a view (using the Views module) of all those bookings for which you want to resend such eMails.

Step 2: Create a Rules component for sending an eMail

Create a Rules Component that will be used in Step 3 to actually send your eMail. Here is an example of such Rules Component to be created:

{ "rules_send_booking_email" : {
    "LABEL" : "Send Booking eMail",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "user_to_notify" : { "label" : "User to be notified", "type" : "user" } },
    "ACTION SET" : [
      { "mail" : {
          "to" : [ "user-to-notify:mail" ],
          "subject" : "Some information about your booking",
          "message" : "This is an update about your booking with reference [user-to-notify:field_about_some_booking] ...",
          "from" : "[site:mail]",
          "language" : [ "" ]
        }
      }
    ]
  }
}

It uses (references) some field that was added to the "user" entity with machine name (say) field_about_some_booking. Feel free to adapt to any field name you have available. And/or use some other entity (eg a node about a booking?), instead of "user", to which this field might be related to. If you want, you can just import the above Rules Component (in Rules export format) in your own environment (via copy-paste), but make sure the machine name of the field matches with what you have available (otherwise the import will fail).

Obviously, the Subject and Content of the eMail may need review / tuning, while you might also want to use some other From eMail ID.

Step 3: Get VBO involved to actually trigger all the eMails

Transform the view from Step 1 into a Views Bulk Operations (=VBO) view. And have the actual VBO "operation" execute the Rules Component that you created in Step 2.

If you're not familiar with how to do so, have a look at the video about Using Rules components with VBO". If you want even more, then also watch the subsequent "Using Rules components with more than one parameter" video.

Attention: the size (volume) that needs to be processed might be another (extra) challenge (memory requirements, etc). Therefor you might want to also watch the video about "More details about VBO settings" ... Before you are tempted to use VBO for processing them all at once ...

Happy VBO-ing while Rules-ing!


Drupal use Node or not? And how to use them?

Nodes are for content, complex data managed by your website are not necessarily content. In Drupal 6 and before, using node for everything was a common practice because only nodes could benefit easily from the CCK, Views and other modules. Drupal 7 introduced the concept of entities. You can create new entity type and for one entity type your can have multiple bundles. Node is an entity type and the content types (or node types) are bundles. Using the Field API, fields are defined by bundle to attach values to entities.

So you don't need, and probably shouldn't, manage everything as nodes but instead defines your own entity types and bundles to store and manage your site data. The Entity API module provides a better API to manage entities and entity types to complete Drupal core's one. The Model Entities project provides a model entity and entity administration interface to kick-start your entity related development. For Field API usage, the Examples for Developers project provides the field_example. You can also use Features to easily export field definitions into code.


Drupal 7 - How to loop foreach in multiple value in custom view

I found it out; the correct code is the following one.

<?php foreach ($view->result as $id => $vue): ?>
  <?php if($vue): ?>
    <?php print $vue->nid; ?>
    <?php print $vue->node_title; ?>

    <?php foreach ($vue->_field_data["nid"]["entity"]->field_galerie_image['und'] as $val): ?>
      <?php print $val['filename']; ?>
    <?php endforeach; ?>
  <?php endif; ?>
<?php endforeach; ?>


If anyone's interested in what I did here: this is best done using Views and Panels. Determining if a user owned a certain item required Views PHP. Once I got that working, it was pretty extensible, and I was able to implement some other displays based on it.


Can you preprocess a specific region in template.php?

Well, you can define your own preprocess function if you want to, since you have all the elements for that. In the theme_preprocess_region function, you can simple do :

$function = 'yourtheme_preprocess_region_'.$variables['region'];
if (function_exists($function)) {
  $function($variables);
}

Then, you just have to define the a function for your region :

function yourtheme_preprocess_region_YOURREGION(&$variables) {

}


How can I count the number of nodes submitted by the current user?

You can use the Views module to do this.

Create a new view
Remove sort options, fields and other default settings
Add a field for "Content: Type"
Expand the "advanced" part on the right and set "Use aggregation" to "Yes"
Add yet another field for "Content: Type"
On the second "Content: Type" field, click "Aggregation settings"
Set the aggregation type to "count"
The second "Content: Type" should now look like "COUNT(Content: Type)"

THIS IS NOT MY SOLUTION LOOK HERE: Count of nodes by type


Revised:

Your directory structure is correct.  Your file directory permissions are not.  Your chmod a+w command gives read and write permissions.  In your case, to get rid error message you must have read and execute permission on the /sites/all/libraries/colorbox & /sites/all/libraries/colorbox/colorbox directories and read permissions on the 2 javascript files.   Colorbox.module does a file_exist call

if (file_exists($library_path .'/colorbox/jquery.colorbox.js') && file_exists($library_path .'/colorbox/jquery.colorbox-min.js')) {

Depending on your operating system, and setting, PHP's file_exists() function is handle differently.


Why are variables & CSS loaded in the overlay?

There is a misunderstanding on how the Overlay module works.
Suppose you are watching your front page, and you click on a link that opens the overlay. What Drupal will do in that case is:

render the front page using the theme you have set
render the overlay using the administrative theme you have set

The overlay is rendered as iframe using the Drupal.overlay.create() function defined in a JavaScript file used from the Overlay module.

/**
 * Create the underlying markup and behaviors for the overlay.
 */
Drupal.overlay.create = function () {
  this.$container = $(Drupal.theme('overlayContainer'))
    .appendTo(document.body);

  // Overlay uses transparent iframes that cover the full parent window.
  // When the overlay is open the scrollbar of the parent window is hidden.
  // Because some browsers show a white iframe background for a short moment
  // while loading a page into an iframe, overlay uses two iframes. By loading
  // the page in a hidden (inactive) iframe the user doesn't see the white
  // background. When the page is loaded the active and inactive iframes
  // are switched.
  this.activeFrame = this.$iframeA = $(Drupal.theme('overlayElement'))
    .appendTo(this.$container);

  this.inactiveFrame = this.$iframeB = $(Drupal.theme('overlayElement'))
    .appendTo(this.$container);

  this.$iframeA.bind('load.drupal-overlay', { self: this.$iframeA[0], sibling: this.$iframeB }, $.proxy(this, 'loadChild'));
  this.$iframeB.bind('load.drupal-overlay', { self: this.$iframeB[0], sibling: this.$iframeA }, $.proxy(this, 'loadChild'));

  // …
}

/**
 * Theme function to create the overlay iframe element.
 */
Drupal.theme.prototype.overlayContainer = function () {
  return '

';
};

/**
 * Theme function to create an overlay iframe element.
 */
Drupal.theme.prototype.overlayElement = function (url) {
  return '';
};

About the error you are seeing, it is probably caused by the fact you are accessing the $base_url variable without defining it as global variable (using the global $base_url; line).
You should not need to use that variable to generating the URLs for your site, as Drupal has url() and l(); the first function is used to generate a URL, while the second one is used to generate an anchor link, such as Example link.


I used this for my incoming feeds, changing http:// to https://

{ "rules_http_to_https" : {
    "LABEL" : "http to https",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "php", "rules", "feeds" ],
    "ON" : { "feeds_import_canada_com" : [] },
    "DO" : [
      { "data_set" : {
          "data" : [ "node:body:value" ],
          "value" : "\u003C?php\r\necho str_replace(\u0022http:\/\/\u0022 , \u0022https:\/\/\u0022, \u0022[node:body]\u0022 );\r\n?\u003E"
        }
      },
      { "data_set" : {
          "data" : [ "node:field-contestpageurl" ],
          "value" : "\u003C?php\r\necho str_replace(\u0022http:\/\/\u0022 , \u0022https:\/\/\u0022, \u0022[node:field-contestpageurl]\u0022 );\r\n?\u003E"
        }
      }
    ]
  }
}


Access to selected taxonomy terms on user profile field

I have achieved this functionality with the following method.

Created a taxonomy term type view which will list only the top level terms.

Added a relationship to view  Taxonomy term: User using Area

Added another relationship Taxonomy term: Parent term

Added a contextual filter on uid for currently logged in user.

This will list only those terms which are selected on user profile. And then display this view as a main menu in the panels.

And then using rules, I return Access denied if a user try to access the taxonomy term page which is not selected on his/her profile.

Hope it will help someone.


Displaying content according to the OG membership of the creator

In Drupal 6 you would add a relationship to the Organic Group: node then filter by Organic Group: user and use the relationship. I believe it should be something very similar by using the contextual filters...


Using File (Field) Paths with token value from Entity Reference field

Try to append :value to the field:

[node:field_organization:value]

For a reference field something like this:

[node:field_organization:0:entity:name]

If you want to look up all available tokens install the Token module and go to /admin/help/token.


How can I display a message when "add another item" on an Inline Entity Form Multiple field is clicked?

You can do this using JS. Add a click event listener on the Add item button. When the button is clicked you set a message.

Something like this should work:

$('.add-item-class').on('click', function () {
  const messages = new Drupal.Message();
  messages.add('You clicked the add item button!');
});

Make sure you have Drupal available in your JS file by adding it as a dependency in your libraries file.

js:
  path/to/js-file.js: {}
  dependencies:
    - core/drupal
    - core/jquery

Please note that the Drupal.Message() was first introduced in Drupal 8.7, so if you use an older version it would not work.

Another possible solution is to create a route that sets the message, using \Drupal::messenger()->addMessage('').

Your controller will do like this:

\Drupal::messenger()->addMessage($this->t('Your added an item!'));
$messages = ['#type' => 'status_messages'];
return new JsonResponse(['message' => Json::encode(\Drupal::service('renderer')->renderRoot($messages))]);

And your JS file like this:

$('.add-item-class').on('click', function () {
  $.get('/path/to/your-route', function (response) {
    $(context).find('.region-highlighted').prepend(JSON.parse(response.message));
    setTimeout(function () {
      $(context).find('.region-highlighted .messages').remove();
    }, 5000);
  });
});

This appends the message to the highlighted region and removes it after 5 seconds. You can place it anywhere you want.


Do you perhaps use Context Breakpoint? I had a similar experience using that module. The module states the following on its project page:

  Caching implications

  This module has implications for using the Drupal page cache. Check the README.txt under CACHING for a detailed
  explanation and possible solutions.

  A more detailed explanation is in the README.

I ran into the same situation and it is caused by the way Drupal 7 caches content. It only checks the URL. So if you were to open a page on a mobile phone, which already existed in cache, you will receive the desktop version.

The inverse is also true. If cache is emptied or outdated and the next user to request the page is using a mobile phone, that user will make sure the mobile version is stored in the cache and served to desktop users.

This is certainly true for Drupal's internal caching system, and disabling the Cache pages for anonymous users option solves the problem.
An alternative could be to use Context Mobile Detect. Which does seem to play nice with Drupal's page cache.


8 - Change taxonomy field's link text in view

In your view just add the field 'Taxonomy term: Link to Taxonomy term' and change the 'Text to display' to Read more.


WYSIWYG tinymce editor unwanted tags showing in drupal 7

Sounds like a text format settings issue, review the formats at

Admin > Config > Content authoring > Text Formats

e.g Filtered HTML > Limit allowed HTML tags

and add the allowed tags if necessary.


How can I edit a custom field with Rule and VBO of a NOT published node?

Cron runs as an anonymous user. Ensure that the view permissions allow an anonymous user to access. Set the access to role:

Then, set the role to anonymous:

That should allow you to bypass the regular permissions that would normally not allow you to see it.

Also, ensure that your rule includes a rule to save the entity. I'm not 100% sure that it will save the entities you reference automatically, but it is more clear.

Also also, you may need to check the permissions on your rules to ensure that they can be executed by anonymous as well:


Show specific submenu and mark specific item as active when front page or specific node type is opened

So finally I used the Menu Position Module, which works perfectly.


Perhaps this is not drupal standard, sometimes is needed to do things like that.

I prefer to create my own entities that to modify the node entity. This way if you use entity api as base this is integrated with views out of the box. Another approach to that not require coding is ECK module, you can define properties to the entity and this will be added on the same entity table as and extra column.


If the name of your form is modulename_admin_form() then you can add a function modulename_admin_form_validate(&$form, &$form_state).

In that validate function you can form_set_error() from in that validate function.


Installing Drush - permission denied error

You can follow following two links, they are simple two steps and make the Drush running perfectly with no issue, even you can upgrade drush with that.

(1) How to install the Drush using Homebrew. And after that follow following steps to Symlink the php file location between your servers and MAMP.

(2) MAMP: Symlink PHP to /usr/bin/php

I was facing the same issue and re-installed using above steps and this set of two links worked perfectly.


Experience with Drupal 7 Install Profile

I have 1 site in production (re)built every academic quarter off of an installation profile. I have various sites in development I am building using installation profiles.

It's a PITA to try and include content into an install profile in my opinion. It seems to be a great way to code up the functionality of a website. But I still rely on a BASH build script and Drush to run additional import stuff -- and tools just as Migrate, Taxonomy_csvimport and backup migrate to move "content" around places.

I do like "building" the site codebase using an install profile and would recommend the Profiler module to help you along. You can do alot with install profiles.


I believe you're looking for the Drupal Tiny-IDS module:

  Minimalist, but performant intrusion detection system that monitors Drupal for malicious activities and targets to be simple to understand and easy to use.

It attempts to detect:

XSS (Cross Site Scripting)
SQLi (SQL Injection)
Code execution (Local/Remote file inclusion, etc.)

And can 'react' in a bunch of different ways:

Log entry
Warning message (to the malicious user)
Mail alert
Rules integration (which you could use to disable the user account)

I think that ticks all the boxes :)


When should I create multiple Displays of a View instead of multiple Views?

Code-wise, both Views and displays are represented by objects. When a View is being processed, it loads all it's child displays into memory, regardless if you are rendering only one View in the page you are looking at. While database queries are executed only for the active display, the properties of the inactive displays are still loaded into memory.

This means that if you have 50 displays in one View, 50 displays will be loaded into memory, regardless if you are only displaying only one of them. So the answer to your question is yes, typically the more displays in a view you have, the more inefficient the View becomes memory-wise.

With that being said, I personally think that having anywhere between 2-10 displays in a View should prove negligible memory-wise. Having a discreet amount of displays in a View does serve it's practical purposes, after all (otherwise, why would they be there in the first place?).

As to your second question (performance impact of additional filters, etc), yes, adding certain parameters to your View will affect performance. If you want to know by exactly how much, you can go to admin/structure/views/settings (if you are in D7) and select Show information and statistics about the view during live preview, Show the SQL query, and Show performance statistics. Here is a screenshot of the performance screen:

If you are further interested in the behavior of the queries (how many rows are analyzed, which keys are used), you can copy the query from the Views interface (once you've selected "Show SQL query"), and analyze the query using the MySQL explain command. There's plenty of articles like this one for explain usage on Google.


Removing entity queue entries from a view

Yes that should be easy enough. In your view with the 100 projects you need to:

1)Add a relationship to the entity queue but DON'T make it required

2)That will make a filter called "Content In Queue" be available for you to add

3) Set that filter to "No"

And that's it any entities that are in the queue won't come out in that view now


search result not in prioritize order drupal 7

You can use default drupal's search from admin/config/search/settings and se Views module for searching specific fields. You need not write any code or Query to search in a Drupal site unless it is needed.