Contextual filter with taxonomy term that is not in the url

Instead of creating a node view create a taxonomy view.

In that provide two relationships:

Taxonomy term: Content with term;
Taxonomy term: Content using {Name of the taxonomy field in the
content type}*;
Add a contextual filter of the type Content : Title;
Use the first relationship for the contextual filter, Make necessary changes in the more option such as change to lower case turn space to dashes etc;
Add the required fields from the content with the relationship set to 2);

You are good to go.

EDIT : As per the discussion There was another need to also show the nodes under a term and its sub terms.

Create a view of the type content;
Add the required fields;
Add a contextual filter of the type Content: Has taxonomy term ID (with depth) and select the depth a value as deep as the hierarchy you have in the taxonomy.

Now when you pass the term id as the input it would show all the nodes under that taxonomy term including the child nodes.

If you wish to change the url to have the term name instead of the term ID Do the following.

In view give the path as taxonomy/term/% this will override the default taxonomy path;
Install Pathauto Module this depends on Tokens module so have to install that as well;
In Configuration -> URL aliases you have a tab called Patters;
Set the pattern of the "TAXONOMY TERM PATHS" to what you would like it to be. Make sure that the last value is [term:name] so if you want the path to be category/carrot you should give it as category/[term:name];
If you have already added the taxonomy terms then you would need to do the "BULK UPDATE" which is again a tab on the URL Alias page.

Now when you visit the page category/termname you will see all the nodes under the term including the child terms.


Migrate files attached to comments from D6 to D7

Consider looking at this Github link mentioned in Comment #35 of Issue # 554986 ...

If it works for you, then please add an appropriate comment about that in that issue (which currently has status "needs review" ...). And of course let us know about it around here also ...


If you need nid of current node as token, then just add Content: Nid in field list, and check exclude from display before saving it. Move this field at the top of the list & you will be able to use it as token in any other field under Rewrite Result.

But if you want to use nid of entityreference field as token, then you need to a Relationship under Advance tab in your view. Then after follow the same process which I explained in first paragraph. But this time you will have to use your added relationship.

For custom Add More link, just add Global: Custom text in field list & put HTML for this Add More link.


Problem with drupal $queue->DrupalQueue::get and $queue->createItem

You have to add the 'time' key in de function modulename_cron_queue_info() because the default call time for the queues are 15 seconds. In order to update 100000 nodes you need to asign more time, so you have to try adding time until all 100000 nodes are updated:

$queues['my_module_batch'] = array(
  'worker callback' => '_my_module_process_queue',
  'skip on cron' => FALSE,
  'time' => 60,
);


Drupal 7, language changes back to EN after clicking on any link

in configuration, admin/config/regional/language/configure, modify language detection, the order there determinies wich language to use, it depends on how your languages are set, try moving on first place what you think how is confugured your site, set defalut value last. here are my settings on one site, your may be different.


I use Semantic Views to remove a lot of the cruft from views.

  This Views plugin makes unformatted styles, field row styles and other
  output more readily configurable without needing to override template
  files. Instead of overriding row style templates for views where you
  want to specify different HTML elements (tags) and class attributes,
  you can specify these inside the Views UI and avoid overriding
  templates for each view.


If you just want to check if it has a value, you can add a check if it exists, so on row 6:

<?php if (isset($fields['fields_photo']->content) && $fields['fields_photo']->content) { ?>

Otherwise do a <?php dpm($fields); ?> to see what is actually available to use for your theme.

It couldn't be that you have set it to "Exclude from display"?


How can I serve a "410 Gone" HTTP status AND redirect my removed content?

You can always output HTTP 410 header and redirect human users using JavaScript in a body:

var delay = 10000; //Your delay in milliseconds
setTimeout(function(){ window.location = URL; }, delay);

JavaScript from this answer.

Note that by rfc2616:

  The 4xx class of status code is intended for cases in which the client seems to have erred. Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable to any request method. User agents SHOULD display any included entity to the user.

Emphasis mine. So, JavaScript outputted inside HTML body should work. But of course it is not guaranteed it will.

Your content is not nodes, so you probably have implemented hook_menu. If not, you can alter existing implementation with hook_menu_alter. What you need is to:

Using access callback and/or access arguments, ensure user gets the access permission to deleted content. If not, he will see 403 or 404, as this is Drupal's default behaviour for unpublished / deleted data.
In page callback test if content is valid, deleted or never existed.

If valid, default to the callback you are using now.
If deleted, use drupal_add_http_header to add "410 gone" header as appropriate. Output nice human readable page (optionally with JavaScript redirect, search box or anything appropriate).
If never existed, either default to what you were using already, or implement 404 the way you implemented 410 above.

Google says:

  We recommend that you always return a 404 (Not found) or a 410 (Gone) response code in response to a request for a non-existing page.


Views Pager Add rel="nofollow to ALL Pager Links

Not sure of a hook right now for something cleaner. An alternative that will allow you to do what you want,

function hook_views_post_render(&$view, &$output, &$cache) {
    dpm($output);
}

You can use a regex, something like,

(<li.*pager-item.*><a)(.*)

That will give you two groups.
- Group one with every list of items and the opening tag of the anchor.
- Group two with the rest of the line

You can use this to iterate over and add in between both groups,

rel="nofollow"

Of course, you post an answer and find some information. You may want to see if you find these hooks useful, https://drupal.stackexchange.com/a/140867


It is preferable to use variable_get() instead of $GLOBALS['conf']['var'].

Despite being gone in Drupal 8, you always want to program to the API instead of programming to the implementation.

It is highly unlikely, but there could be some change that pops up in Drupal 7 where there is a difference between the two.  For example, a future version could include a hook_variable_alter() to allow modules to muck with variables between the database and their usage.


Drush does not work after I sudo su to another user

Found the answer here:
https://superuser.com/questions/453988/whats-the-difference-between-su-with-and-without-hyphen

  The difference between "-" and "no hyphen" is that the latter keeps
  your existing environment (variables, etc); the former creates a new
  environment (with the settings of the actual user, not your own).


How to get list of all keys defined in the routing e.g path, defaults, options etc and how can we add new custom key?

Add a route enhancer:

Example how _form gets replaced by _controller:

Drupal\Core\Routing\Enhancer\FormRouteEnhancer:

<?php

namespace Drupal\Core\Routing\Enhancer;

use Drupal\Core\Routing\EnhancerInterface;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;

/**
 * Enhancer to add a wrapping controller for _form routes.
 */
class FormRouteEnhancer implements EnhancerInterface {

  /**
   * Returns whether the enhancer runs on the current route.
   *
   * @param \Drupal\Core\Routing\Enhancer\Route $route
   *   The current route.
   *
   * @return bool
   */
  protected function applies(Route $route) {
    return $route->hasDefault('_form') && !$route->hasDefault('_controller');
  }

  /**
   * {@inheritdoc}
   */
  public function enhance(array $defaults, Request $request) {
    $route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
    if (!$this->applies($route)) {
      return $defaults;
    }

    $defaults['_controller'] = 'controller.form:getContentResult';
    return $defaults;
  }

}


Why is my .htaccess not working when uploaded to a Pantheon server?

Because Pantheon servers use Nginx, and they don't enable .htaccess support.

You should contact them directly to discuss your options (if you're lucky and/or have a high enough subscription they'll probably add some custom rules to the nginx conf for you).


How do I convert a database from MyISAM to InnoDB?

As a MySQL DBA, I trust MySQL to do the conversion by having MySQL write the script for me.

Form the Linux command run this query

mysql -h... -u... -p... -A --skip-column-names -e"SELECT CONCAT('ALTER TABLE ',db,'.',tb,' ENGINE=InnoDB;') FROM (SELECT A.db,A.tb,A.tbsize FROM (SELECT table_schema db,table_name tb,(data_length+index_length) tbsize FROM information_schema.tables WHERE engine='MyISAM' AND table_schema NOT IN ('information_schema','mysql')) A LEFT JOIN (SELECT table_schema db,table_name tb FROM information_schema.statistics WHERE index_type='FULLTEXT') B USING (db,tb) WHERE B.db IS NULL) AA ORDER BY tbsize" > /root/ConvertMyISAM2InnoDB.sql

The script will convert the smallest tables first. This script was also bypass any MyISAM tables that have FULLTEXT indexes.

Ater looking over the script, you can simply run it in MySQL as follows:

mysql -h... -u... -p... -A < /root/ConvertMyISAM2InnoDB.sql

or if you want to see the timing of each conversion, login to mysql and run this:

mysql> source /root/ConvertMyISAM2InnoDB.sql

This should not get messed up because a full table lock happens when the conversion is being executed.

Once all tables are converted you need to tune the MySQL settings for InnoDB usage and scale down the key_buffer.

Please read this for setting the InnoDB Buffer Pool : https://dba.stackexchange.com/questions/1/what-are-the-main-differences-between-innodb-and-myisam/2194#2194

Please read this also : https://drupal.stackexchange.com/questions/1715/what-would-the-optimal-mysql-configuration-for-a-drupal-7-site-be/2367#2367

Give it a Try !!!


How to make a custom page.tpl.php file for a views page?

I agree with sheena_d's advice above -- it sounds like what you are trying to accomplish could much more easily be accomplished by using simple pages. That said, here is one way you could do this using views overrides in your template.php theme file.

What you're after is this command:

$variables['template_files'][] = "your-new-view.page.tpl.php";

but you need to get Drupal to hook into this somehow. One way to do this is with a views preprocess function, added to your template.php file:

function <your-theme-name>_preprocess_views_view__<your-view-name>(&$variables) {
    $variables['template_files'][] = "your-new-view.page.tpl.php";
}

You would need to replicate this function for however many views you want to override the page.tpl.php file for.


How I edited the Collection Products view

I needed to get rid of the  surrounding the field. Did so by editing the view template file:

Copied the file views-view-list.tpl.php to a Template folder inside my theme folder and renamed it views-view-list--collection-products--page.tpl.php

Removed the  around

See these sources on view templates:

http://drupal.org/node/352970

http://www.templatezine.com/2010/03/views-styles-and-theming-how-to-redefine-html-output/

In the View:

I added the field Taxonomy term: Rendered Taxonomy term
    Check "Exclude from display"
    View mode "Taxonomy Term Page"

Under Format > Settings
    Made Taxonomy term: Rendered Taxonomy term a Grouping Field

I also removed the header from the view since I had an image in the Rendered Taxonomy Term.

I also removed the 2 Taxonomy Term Name fields since the name came in with the Rendered Taxonomy Term.


Where can I add core  elements with Views RSS

It sounds like you're missing a couple things. First, make sure that you have the Views RSS: Core Elements submodule enabled -- this is what allows you access to the many other fields. This may already be enabled and if so, the reason you're not seeing the fields is that you need to switch your format to RSS Feed - Fields, ex:

by clicking the 'RSS Feed' link in your Format Settings.

Now, when you adjust the settings for this, you'll see the options for the item elements you were looking for.

You'll need to add the appropriate fields from your content to have them appear in the select lists.


How to change the system path of a taxonomy vocabulary to correspond a view

I solved my problem installing the module: Taxonomy Views Integrator -  https://www.drupal.org/project/tvi.

It's easy to set a view to display both taxonomy terms and vocabularies.


Can the recently read module show multiple nodes?

From the content of your question, I have the impression that you misunderstand what the Recently Read module is about. More specifically (from its project page): it keeps track of "... the history of recently read content (nodes) both to anonymous and authenticated users ...".
Anonymous users is a special case, but for logged in users each user has his/her own "history".
Issue #1973526 also confirms that, here is part of what that says:

Since you don't want your database getting forever more massive for no good reason (it is likely you will only ever be showing the last 5 or 10) it would be good to have an option to limit the maximum number of entries in the recently read table for each user.
For example I can set it to 5 and the database would only ever have 5 entries per user at most.

It would be interesting to know, for your environment, how many nodes (more then one?) you visited with the user you are logged in with (if you are logged in). To remove any doubt about that, consider editing your question by adding some scenarios (+ results you get) like "user 1 visited node a, b and c; user 2 visited b, p, q, r, s, z, ..."; anonymous user visited k, l , m ..."


You may have something like url('none'); specified for a background (or list image, etc.) in your stylesheets.


For what it's worth and consideration. Make sure your php.ini is configured correctly and that your. upload_max_filesize and max_file_uploads settings are adequate. My numbers are arbitrary, but I've had similar issues that require this general adjustment.

Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 200M

; Maximum number of files that can be uploaded via a single request
max_file_uploads = 200


You can use the Drupal message system.

Ex: drupal_set_message(t('Error message goes in here'), 'error');

In you case: drupal_set_message(t($yourvariable), 'error');


How to replace current symbols with font awesome icons in every pager?

If you look at function theme_pager you see this line:

 $li_last = theme('pager_last', array('text' => (isset($tags[4]) ? $tags[4] : t('last »')), 'element' => $element, 'parameters' => $parameters));

which eventually leads you via theme_pager_last to function theme_pager_link which has this bit of code:

return '<a' . drupal_attributes($attributes) . '>' . check_plain($text) . '</a>';

where check_plain is the function that converts html to text.

so you need to supply your own version of theme_pager_link. Look at this post and others for information on how to do that:

How to override theme functions in Drupal 7


How do I incorporate an if-statement within my array to hide/display a link?

You can use below code snippets:

$field = $form['status'][$key]['status'];

if (strip_tags($field) == 'A')
echo l(t('Change'), 'rooms/avail_room/' . $key . '/' . arg(1), array('attributes' => array('class' => 'room-stat-avail'))),
else{
echo "";
}


How to get a variable from FieldWidget in the same modules Template

You already pass the template variable sign_src to your template. Now you want to pass an additional variable. You can easily do this by extending your hook_theme implementation:

/**
 * Implements hook_theme().
 */
function signature_theme() {
  $theme = [];
  $theme['signature'] = [
    'render element' => 'element',
    'variables' => [
      'sign_src' => NULL,
      'text_area_id' => NULL,
    ],
  ];
  return $theme;
}

Then pass the ID into your template like this:

$value = $items[$delta]->value ?: '';
$text_area_id = 'signature_field_' . $items->getName();

$file_upload_help = [
  '#theme' => 'signature',
  '#sign_src' => $value,
  '#text_area_id' => $text_area_id,
];

And use it in your template like this:

{{ text_area_id }}

Edit: Some further suggestions for your code snippets:

Wherever possible, you should leave rendering to the theming engine and avoid manually calling the \Drupal::service('renderer')->renderPlain() method. Your description will do just fine with the render array. Your #suffix can be changed to a distinct child element of your widget element (note: there is no hash before):

$element['#description'] = $file_upload_help;
$element['suffix'] = $sign_thumb;

In your template, you can change the empty check to

{% if sign_src %}
  <img src="{{sign_src}}" class="sign-img" />
{% endif %}

And should wrap the src URL into quotes.

A final note about the URL itself: It seems to be a user given value. If so, consider using UrlHelper::stripDangerousProtocols before you pass it into the template.


How can I run a jQuery script in the admin overlay?

You'll need to go in and do a form_alter on the admin overlay pages that you are wanting to modify. You will need to add an item to the ['#attached'] attribute on the form to attach your JS. You can read more about attaching JS to forms in the Drupal Form API documentation.


How to display multiples jQueryUI progressbars in a page in Drupal 7?

Your first code example for the progress bar has a small syntax error (missing a }); at the end of the line). I'm not sure exactly why your second example doesn't work, (I didn't try it) but this code works perfectly for me using your HTML as an example:

drupal_add_js("
  (function($) {
    $(function() {
      $('.progressbar').each(function() {
        var val = $(this).attr('rel');
        $(this).progressbar({ value: parseInt(val) });
      });
    });
  })(jQuery);",
  'inline'
);

This code produces:

EDIT

I've just noticed you have some invalid HTML in your code which probably won't help. You're wrapping <h4> and <div> tags in a <p> tag, which is invalid XHTML. It might not be the problem but it would be better practice to change that <p> to a <div>.


How do I check a form is a node type form?

In the case you are referring to the node edit form (the form that allows you to edit a node), instead of hook_form_alter(), you need to implement hook_form_BASE_FORM_ID_alter(), which is a specific implementation of hook_form_alter() used when you know the form ID of the base form. In your case, you need to implement hook_form_node_form_alter() exactly how the Book module does with book_form_node_form_alter().
function book_form_node_form_alter(&$form, &$form_state, $form_id) {
  $node = $form['#node'];

  // Omissis.
}

$form['#node'] is set by node_form(), which contains the following code. (Note the comment, which says that $form['#node'] is going to be removed in Drupal 8, and that modules should instead use $form_state['node'].)
// @todo D8: Remove. Modules should access the node using $form_state['node'].
$form['#node'] = $node;

In the case you are referring to the form you find at admin/structure/types/manage and that allows you to edit the properties of a content type, you need to implement hook_form_FORM_ID_alter(), which a specific implementation of hook_form_alter() done for a specific form ID, which in this case is node_type. This is what does the Comment module with comment_form_node_type_form_alter(). If you need to know the content type for which the form is shown, you can use $form['#node_type']->type.


How to unpublish nodes 50 days after they are created by using the Rules module?

Have you looked into Rules Scheduler? The process is similar in that you create your rule, create a component that unpublished content, then use Rules Scheduler in the original rule as the action to run the component 50 days after "date published". Here is a video of scheduling nodes to be published after X time that you can follow: http://www.youtube.com/watch?v=OgRKLXRbPX8 .


They're here

In the codebase: core/modules/views/views.api.php.
On the web: https://api.drupal.org/api/drupal/core%21modules%21views%21views.api.php/8.5.x

As always, only *_alter hooks and hook_theme can be implemented in a theme. Any other hook needs to be implemented in a module.


How is the node revision ID getting updated?

drupal_write_record handles that.

vid is the primary key on the node_revision table, as declared in node_schema, and drupal_write_record knows that because it introspects the schema when writing the record.

From there it just takes the ID returned from the database query, and populates the correct property on the object that was passed in. In this case, that's the vid property on the node object.


As Kevin says in his comment, Drupal will do most of the work for you if you use view modes on the referenced content type:

/admin/structure/types/manage/{referenced-content-type}/display

In your case, you might want to modify the Teaser view mode so that it hides all fields except for Name and Description. (If you are already using the Teaser for something else, you can create a new view mode.)

Then, when you render the entity reference field, just use the format "Rendered Entity" and configure the view mode that you wish to render (e.g., Teaser).


This is actually a really annoying Fivestar bug:

http://drupal.org/node/1370526#comment-5367970

The problem is now fixed.


Normally a default value is configured in the field configuration. Either static in default_value or dynamic in default_value_callback pointing to a callback function which returns the default value.

For your original question, how to do this in one of the field plugins, see No way for a field to dynamically set default value and especially #6:

  I resorted to creating widgets (extending the base widgets), whose
  only concern is to set the default value dynamically according to
  contextual values, e.g. I have a widget that presets a default value
  to an entity name referenced by the logged in user, something like
  this:

/**
 * Define the {@link AcmeWidget} class.
 *
 * @FieldWidget(
 *   id = "acme_widget",
 *   label = @Translation("Acme Textfield"),
 *   field_types = {
 *     "string"
 *   }
 * )
 *
 * @package Drupal\acme\Plugin\Field\FieldWidget
 */
class AcmeWidget extends StringTextfieldWidget {

  /**
   * {@inheritdoc}
   */
  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {

    // Call our parent but set the value using our default value function.
    $element = parent::formElement($items, $delta, $element, $form, $form_state);

    // Get the current user organization's name.
    $user = User::load(\Drupal::currentUser()->id());
    $organization = $user->get('field_organization')->entity->title->value;

    // Set the default value if a value hasn't been set.
    $element['value']['#default_value'] = $organization;

    return $element;
  }

}


How do I get the views pager to display (after adding an view header)?

To save you wading through the comments which led to this answer, here it is in summary:

The problem was that the 2nd view included in the Header of the main view also had a pager on it.

Two solutions:

Views can cope with having more than one pager, with a bit extra config: you have to set the Pager Id field on one of the Views Displays to an integer not in use by other views/displays on that page (e.g. 1 instead of 0).
In my case I realised that the attached header view did not actually need a pager (it was only ever going to display one result - the description for the taxonomy term), and I should have selected "show fixed number of results" instead of a pager option. Changing this fixed the problem.

Hope this answer is useful for someone else getting stuck!


How to define alias dependent Drush extensions?

Instead of installing the drush extensions in a user specific scope within your user's profile, you can install them on a per-project (Drupal instance) base in your {PROJECT_ROOT}/drush folder.

Drush 9 checks for the existence of a drush folder one level above the Drupal web root.

This is easiest to manage by utilizing Composer for dependency management and adding a Drush installer path, Drush and any Drush extensions to the composer.json file. But of course you can also setup everything by hand.


How to set up a cron job that runs for a specific rule?

What I really need is the Session component to run every hour and the Event component to run every 15 minutes?

According to your screenshot, it seems you're only running Cron once a day, so even having a shorter schedule than that will not work unless your Cron runs at those needed intervals.
Re-configure your crontab to run at the shortest interval needed. In your case this will be 15 minutes. The configuration of each of those schedules should still ensure that whichever cron hook is only run at the specified times.


Try to use Attachment Links module. Read the README.txt file for better understating.


Keep the URL alias for a node when using href

You can use global redirect so that it does a 301 redirect to the aliased url.

I would recommend you additionally use path redirect so that you can keep old aliases and redirect them to the new one. That way you don't even have to worry about using the unaliased url.


Drupal show breadcrumbs on certain nodes

When using the path breadcrumbs module it doesn't append the title to the end unless you add it yourself when configuring the breadcrumbs.

It is quite possible that what is adding the title is your theme.

For example the zen theme has an option to show the page title at the end of the breadcrumbs, as do lots of other themes.

To get to these settings, on your site go to admin/appearance and then click the settings link for whichever is your theme.


List of modules in D7 that might provide similar functionality.
  http://drupal.org/project/core_library
  http://drupal.org/project/agrcache

It is what reported in the project page for Advanced CSS/JS Aggregation, which is where your link takes to.


It is Configurable. Go to

  Admin -> Configuration -> CKEditor

And Edit the relevant profile in the text formats.(In your Case choose edit the fullhtml) Choose
Editor Appearance
and there will be a Drop down to choose User Interface Color, Select CKEditor Default. If its already default then there must be some CSS override.


One way to facilitate this is to use Taxonomy Views Integrator. You will be able to create views and set vocabulary or terms to use those views instead of the default taxonomy page from core Drupal.


Reasons for subsequent Broken/missing handler in Views?

Please follow the following guides:

Upgrading Drupal core
Migrating D6 Content Construction Kit (CCK) to D7 Fields
Migrating image fields

Also:

Make sure that you've enabled all the field modules such as image and views related
Changed field type: The 'field_source_file' field type
will be changed from 'filefield' to 'file' is just information; it's nothing to worry about
To fix the Broken/missing handler message, you have to identify the right modules which provide these handlers and enable them


If the Supplier field lives in the user profile you could make the Product fields dependent on the Supplier field using the Conditional Fields module, grant various roles field/taxonomy term access to Product fields using the Field Permissions or Taxonomy Permissions module, and then create a rule that fires based on Supplier field values that modify user role assignments accordingly

Then you would add all Supplier and Product fields to your view, hiding each Product field in the display, and then add a Global: Custom text field called "Products" and use replacement patterns to reference each of the hidden fields one after the other. (Make sure the hidden fields appear before the Global: Custom text field.) Anything that comes up empty simply won't appear.

If those fields live in a node, that may require a slightly different strategy, but the idea should be more or less the same.


How to add where clause to custom Drupal view

You can implement hook_view_query_alter() to add where condition.

function MODULE_NAME_views_query_alter(&$view, &$query) {
  if ($view->name == 'view_name') {
    $query->add_where(1,'node.nid',$value,'=');
  }
}


Add textfield as option for checkbox 'other' entry

The easiest way is to add the Select or Other module.

It lets you define these using the Form API, CCK, Webform and some others.


Error running BrowserTest (Drupal\Core\Config\Schema\SchemaIncompleteException: No schema ...)

The Schema file is: https://github.com/aneek/rate_limiter/blob/develop/config/install/rate_limiter.settings.yml

No, that is not the schema file, that is the config file for which you need to create a configuration schema.

Tests by default enforce that your configuration has a schema, which is useful for supporting configuration translation and additional upcoming functionality like validation.

See Configuration schema/metadata for more information on how to create that.


How can I make a View that shows the number of nodes attached to per taxonomy term?

This may help get you started. What you want to do can be accomplished by creating a views entity with a taxonomy argument that returns 'display summary when argument not found.'  In that setting as well is an option to display the number of nodes, (339) for example, that have that term attached to them.

http://drupal.org/node/301485#comment-1065230

Check out that link and post back with questions.


How to remove Input format from comment form?

Administer > Site Configuration > Input Formats

Click configure for each of the formats, and edit which roles can see which format.

You can also look at Better Formats.

  Set the default format per role. Set the default format per content
  type. Control allowed formats per content type. Hide format tips. Hide
  more format tips link. Hide format selection for nodes, comments, and
  blocks seperately, forcing the default to be used. Expand the
  selection fieldset by default. Disable the expand/collapse of the
  selection fieldset. Set selection fieldset title. Set more format tips
  link text. Set default formats for nodes and comments separately.
  Sensible defaults and fail overs for ease of use. Works with CCK
  textareas. Works with Panels comment form. i18n module support for
  user defined strings

.

Also if you want to hide it completely you can also unset the filter form element in your form alter but I don't think it is the right way to do it.

unset($form['comment_filter']['format']);

NOTE: If you do so you will loose out on text processing and checks which drupal makes to make sure the html is safe.

This should also work

$form['comment_filter']['format']['#access'] = FALSE;

This will make sure the format is not accessing to anyone.

Try this

function modulename_form_alter(&$form, &$form_state, $form_id) {
 if ($form_id == 'comment_form') {
  $form['comment_filter']['format']['#access'] = FALSE;
 }
}


What is the difference between using Drupal as a CMS and using it as a Portal?

Is this using Drupal as a CMS or a Portal?

I would say "CMS", and probably even "CMF" (Content Management Framework). E.g. using things such as Webservices.

  Does this go against the philosophy of what Drupal is for?

No, it's just 1 out of dozens of usages of Drupal.

  I want to use Drupal 8 if it matters.

Depends how much in a hurry you are, but I'd strongly recommend to not yet use D8 in production. Some more details on that:

Use Drupal 7 if you want to build production ready sites today, or in the near future.
Use Drupal 8 to get ready for "the future". To answer the (next) predictable question (= by when would I have to be ready for that), be aware of the famous quote from "Mr. Dries", which is something like: Drupal 8 will be ready when it's ready ....

Some more words/thoughts about D8

I do not think the D8 development architecture will change anymore (therefor it's too late).
So to start developing with D8 with a production date far away from today might make sense. And if you adapt to the new (OOP) stuff with Symphony, etc, then you probably don't need many more changes by the time D8 gets released.
Be careful however with an assumption like "... D8 is just about ready". Even if there are only a seven critical issues left before RC1.
D8's first beta was released at DrupalCon A'dam (2014). And I wouldn't be surprised if somewhere between Sept 17, 2015 and Sept 24, 2015 the first RC1 would be released (at DrupalCon Barcelona). But from then on an official release will not be just a matter of weeks (I "hope" for somewhere in 2016 ... and would "love" it to be in "2015" still).
The key challenge after D8 is released will be the contrib modules you'd need: if you can get the job done with hardly any contrib modules (now that Views is in core), then you're fine. But what if you'd depend on modules that only support D7? Or modules that don't have a stable D8 release yet, such as the Rules module?

Future-Proof your Drupal 7 site

To make transitioning to Drupal 8 easier, there are quite some decisions can you make now on your current or new Drupal 7 sites.

For more details on that, refer to the (amazing I think) presentation of David Reid about all those amazing contributed modules in Drupal 7, which are like backports of new Drupal 8 features.


Configuration settings of Authcache for roles

Authcache will only attempt to cache a page and deliver a cached page respectively if every single role of the logged in user is authcache enabled.

Consider the following example:

Five roles are defined on the website (including the built-in ones): anonymous, authenticated, customer role 1, customer role 2, administrator.
Three roles are enabled for authcache: anonymous, authenticated, customer role 1
User Customer A has the following role: customer role 1
User Customer B has the following role: customer role 2
User Customer C has the following roles: customer role 1 and customer role 2
User Customer D has no additional roles
User Administrator has the following role: administrator

This will lead to the following behavior:

Authcache will kick in for every anonymous user (anonymous role is authcache enabled).
Authcache will kick in for Customer A (customer role 1 is authcache enabled).
Authcache will not kick in for Customer B (customer role 2 is not authcache enabled).
Authcache will not kick in for Customer C (customer role 2 is not authcache enabled).
Authcache will kick in for Customer D (authenticated is enabled)
Authcache will not kick in for Administrator (administrator role is not authcache enabled).


I can't add to cart without HTTPS enabled

The problem was that commerce_cart.module requires a valid session or logged-in user.  The security settings of the OP's site prevented sessions being sent out to HTTP requests.
While the OP solved this problem via PHP.ini, there are other valid solutions:

Adding session.cookie_secure = 0 in settings.php
Requiring all users to use HTTPS.
Preventing the cart from displaying to anonymous users.


Checking if user is logged into Drupal from another php application using Drupal services and REST

I would recommend using OAuth2.0, check out OAuth 2.0, assuming Drupal 8, otherwise there's the OAuth 1.0 for Drupal 7 (or if you're not using SSL with D8 for some reason).

This is the same tech that Facebook and Google use when you want to let people log into your site/app using their 3rd party credentials, so it should be robust enough if I understood what you were asking.


Views - Exposed Filter for 2 Field Collections with Same Fields

You need to make the base table for your View the Field Collection table rather than the Node (content) table.  You'll need to add a filter to only show the type(s) of Field Collections you wish to query.

Now you'll be querying all Field Collections of the selected type(s), regardless of whether they're considered authors or editors.  Simply add exposed filters to query on the first_name and last_name fields.

The real question is: what do you want actually displayed?  If you only want data attached to the Field Collections displayed then that's easy enough.  If you want to pull data from the host nodes beyond merely the NID then you're going to end up with 2 separate relationships to the nodes (one for each field) and you're probably not going to be able to get the UI you want out of that.

A much easier approach to all of this would be to put all of the "people" related to a node in a single Field Collection field and differentiate between Author and Editor by way of an additional "type" field in the Field Collection.  You could then construct very straightforward views to query across all types of related people.


Block display using wildcard, non-greedy

Note that you can use arg(x) where x is the position in the path starting from 0, so you could do something like this as well:

<?php
if (arg(0) . arg(1) == 'commerce_storestore' && !arg(3)) {
  return TRUE;
}
?>

You could also use drupal_match_path() like so:

<?php
if (drupal_match_path(current_path(), "commerce_store/store/*") && !arg(3)) {
  return TRUE;
}
?>

Cheers,


drupal login not working offline because of reCAPTCHA

uninstall recaptcha, can easily be done with drush

cd path/to/project
drush pmu recaptcha

drush is a command line utility for drupal and can be easily installed following this guide's setup drush section
I can't backup my website on a shared server because memory runs out. What can I do?


How can I show help to a user one time only?

You need to track some where whether user visited a page or not. It should be database. Only module which does is statistics module. More over to integrate that with Field descriptions nothing but inline help you need to write custom code using a module. Since its very specific use case i can say that no contributed module available which can solve your use case out of the box.


How to set access arguments visible to all

function emailf_menu() {
  $items = array();
  $items['emailfrequency'] = array(
    'title' => 'Manage email Frequency',
    'page callback' => 'emailf_page',
    'access arguments' => TRUE
  );
  return $items;
}

'acces arguments' => TRUE will allow access to all users, including anonymous


How to make nodes to be aware that they were added to menu programatically

Got it - I had to use drupal_get_normal_path($node_alias) on path added to menu. I hope that will be helpful for someone.


Related nodes by taxonomy term in a view block

I've done a little tweaking myself, and I seem to have gotten a working solution here.

Create a new block for the nodes you'd like to display
Add a new Contextual Filter: Content: Has Taxonomyterm-ID
Select: "when the filter is not available, provide a default value: Taxonomyterm-ID from URL."
Put a check next to "Load Standard Filter from node-page, useful for related taxonomyblocks"
And you will probably want to limit the vocabulary as well

In order to exclude the current Node you have to add a second Contextual Filter for Node-ID, provide default value as the content ID from URL and at the bottom of the modal pop open 'More' and check 'Exclude'


Some thing like this:

    $tid = $items[0]['tid'];
    $term = taxonomy_term_load($tid);
    //it turn out that taxonomy_term_load gets empty array for my custom field
    //that's why  after some poking around Drupal API i come up with the following
    $term_page =  taxonomy_term_view($term, $view_mode = 'full');
    $term_url = taxonomy_term_uri($term);
    $image_url=$term_page['#term']->field_client_logo; //this is my custom field name
    $image = theme('image', array(
      'path' => $image_url['und'][0]['uri'],
      'alt' =>  $term->name,
      'title' => $object->title,
    ));
    return l($image, $term_url['path'] , array('html' => TRUE));


Sure.  Take a look at the file drupalorg_testing.make.bootstrap in the drupalorg_testing project.  The relevant part is:

projects[drupalorg_testing][type] = "profile"
projects[drupalorg_testing][download][type] = "git"
projects[drupalorg_testing][download][revision] = "master"

Usually, when building a profile, you will download only Drupal core and the profile in the bootstrap makefile, and put all of your other modules in the makefile that is bundled in the profile.  If you are making a makefile that makes use of someone else's profile, then you may include your additional modules in your top-level (bootstrap) makefile.

If you ever want to move a module from one location to another, you'll want to use the registry rebuild tool.  It will fix up the system table to account for the module's new location.


You can access it directly from the node variable like: $node->field_temperature[0]['view'].

If you want to see what values are actually on the node, I'd suggest var_dump($node); in the template to check out what fields/values you can access.


There's a much easier way.

Go into the DB and change the email address field of the user with id 1 and set it to your email address.
Go to http://mysite/user and click on the password recovery link.
Enter your email address and you'll get a password recovery link.

Of course this assumes that your dev systems allows drupal to send mails out of the box. This is true for most linux and osx boxes but not for Windows.


Upload a file by Ajax without submitting the form

This code uploads one file with Ajax, attaching it to an existing node's file field. The content type is file_test, and the field is field_da_files.

(I'm not a professional programmer, so there are no doubt better ways to do this.)

Here's some HTML/JS that talks to a Drupal controller. It sends the node id, and the file to be stored.

In uptest.html.twig:

NID <input type="text" id="nid" name="nid">

<input type="file" id="file" name="file" />
<input type="button" class="button" value="Upload" id="but_upload">

In library JS file:

(function($, Drupal) {
  Drupal.uptestInitialized = false;
  Drupal.behaviors.uptest = {
    attach: function(context, settings) {
      if (Drupal.uptestInitialized) {
        return;
      }
      Drupal.uptestInitialized = true;
      $(document).ready(function() {
        $("#but_upload").click(function() {
          var fd = new FormData();
          var files = $('#file')[0].files[0];
          if (! files) {
            alert("No files");
            return;
          }
          var nid = $("#nid").val();
          if (! nid) {
            alert("No nid");
            return;
          }
          fd.append('nid', nid);
          fd.append('file', files);

          $.ajax({
            url: '/uptest-save',
            type: 'post',
            data: fd,
            contentType: false,
            processData: false,
            success: function(response){
              let result = response.success;
              if (result){
                alert('yay!');
              }
              else {
                let msg = response.message;
                alert('file not uploaded: ' + msg);
              }
            },
          });
        });
      })
}}})(jQuery, Drupal);

Routing file:

uptest.default_controller_hello:
  path: '/uptest'
  defaults:
    _controller: '\Drupal\uptest\Controller\DefaultController::hello'
    _title: 'uptest'
  requirements:
    _permission: 'access content'

uptest.default_controller_upload:
  path: '/uptest-save'
  defaults:
    _controller: '\Drupal\uptest\Controller\DefaultController::saveFile'
    _title: 'Save'
  requirements:
    _permission: 'access content'

In the controller:

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\File\FileSystemInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use \Drupal\Component\Utility\Bytes;

public function hello() {
  $renderable = [
    '#theme' => 'uptest',
    '#cache' => [
      'max-age' => 0,
    ],
    '#attached' => [
      'library' => [
        'uptest/uptest',
      ],
    ],
  ];
  return $renderable;
}

public function saveFile(Request $request) {
  $nid = $request->get('nid');
  if (!$nid || !is_numeric($nid) || $nid < 0) {
    return $this->makeUploadErrorResponse('Bad NID format');
  }
  $node = $this->entityTypeManager->getStorage('node')
    ->load($nid);
  if (!$node) {
    return $this->makeUploadErrorResponse('No node with nid of ' . $nid);
  }
  /** @var \Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile */
  $uploadedFile = $request->files->get('file');
  if (!$uploadedFile->isValid()) {
    return $this->makeUploadErrorResponse('Invalid file upload.');
  }
  //Get uploaded file metadata.
  $uploadedFileName = $uploadedFile->getClientOriginalName();
  $uploadedFileExtension = $uploadedFile->getClientOriginalExtension();
  $uploadedFileSize = $uploadedFile->getClientSize();
  $uploadedFilePath = $uploadedFile->getPathname();
  //Get node field metadata.
  $nodeFieldMetadata = $this->getFileFieldMetaData('file_test', 'field_da_files');
  if (!$nodeFieldMetadata) {
    return $this->makeUploadErrorResponse('Problem loading file field metadata.');
  }
  //Check uploaded file's extension.
  $allowedExtensions = explode(' ', $nodeFieldMetadata['extensions']);
  if (!in_array($uploadedFileExtension, $allowedExtensions)) {
    return $this->makeUploadErrorResponse('Extension not allowed.');
  }
  //Check the file size.
  $maxSizeAllowed = Bytes::toInt($nodeFieldMetadata['max file size']);
  if ($uploadedFileSize > $maxSizeAllowed) {
    return $this->makeUploadErrorResponse('File too large.');
  }
  //Check cardinality.
  /** @var \Drupal\file\Plugin\Field\FieldType\FileFieldItemList $fieldValueInNode */
  $fieldValueInNode = $node->get('field_da_files');
  $fieldAttachedFileItemList = $fieldValueInNode->getValue();
  $nodeFileFieldNumAttachments = count($fieldAttachedFileItemList);
  $allowedCardinality = $nodeFieldMetadata['cardinality'];
  if ($nodeFileFieldNumAttachments >= $allowedCardinality) {
    return $this->makeUploadErrorResponse('Maximum number of files for this node already reached.');
  }
  //OK. Attach the file.
  //Prepare the directory.
  $directory = 'private://' . $nodeFieldMetadata['directory'];
  $result = file_prepare_directory($directory, FileSystemInterface::CREATE_DIRECTORY);
  if (!$result) {
    return $this->makeUploadErrorResponse('Error preparing directory.');
  }
  //Read the file's contents.
  $fileData = file_get_contents($uploadedFilePath);
  //Save in right dir, creating a file entity instance.
  $savedFile = file_save_data($fileData,
    $directory . '/' . $uploadedFileName,
    FileSystemInterface::EXISTS_RENAME
  );
  if (!$savedFile) {
    return $this->makeUploadErrorResponse('Error saving file.');
  }
  //Attach to the node.
  $node->field_da_files[] = [
    'target_id' => $savedFile->id(),
  ];
  $node->save();
  return new JsonResponse([
    'success' => TRUE,
  ]);
}

/**
 * Make a response for file upload attempt with an error message.
 *
 * @param string $message The error message.
 *
 * @return \Symfony\Component\HttpFoundation\JsonResponse Response to return to client.
 */
protected function makeUploadErrorResponse($message) {
  $result = [
    'success' => FALSE,
    'message' => $message,
  ];
  return new JsonResponse($result);
}

/**
 * Get metadata for a file field.
 *
 * @param string $contentType Content type with the field.
 * @param string $fieldName Name of the field.
 *
 * @return array|bool Metadata, or false if a problem.
 */
public function getFileFieldMetaData($contentType, $fieldName) {
  if ($contentType === '' || $fieldName === '') {
    return FALSE;
  }
  $entityFieldManager = \Drupal::service('entity_field.manager');
  $fields = $entityFieldManager->getFieldDefinitions('node', $contentType);
  if (!$fields || count($fields) === 0) {
    return FALSE;
  }
  //Get file field definition.
  if (!isset($fields[$fieldName])) {
    return FALSE;
  }
  /** @var \Drupal\field\Entity\FieldConfig $fieldDef */
  $fieldDef = $fields[$fieldName];
  //Get settings, doesn't include cardinality.
  $directory = $fieldDef->getSetting('file_directory');
  //Resolve tokens.
  /** @var \Drupal\Core\Utility\Token $tokenService */
  $tokenService = \Drupal::service('token');
  $directory = $tokenService->replace($directory);
  $fileExtensions = $fieldDef->getSetting('file_extensions');
  $maxFileSize = $fieldDef->getSetting('max_filesize');
  //Get cardinality.
  /** @var \Drupal\field\Entity\FieldStorageConfig $fieldStorageDef */
  $fieldStorageDef = $fieldDef->getFieldStorageDefinition();
  $cardinality = $fieldStorageDef->getCardinality();
  //Return results.
  $result = [
    'content type' => $contentType,
    'field' => $fieldName,
    'directory' => $directory,
    'extensions' => $fileExtensions,
    'max file size' => $maxFileSize,
    'cardinality' => $cardinality,
  ];
  return $result;
}

Hope that helps.


Is there a html5 video player for Drupal 6 that run well on ios device?

Yes; try jPlayer: http://drupal.org/project/jplayer

Note that you might be better off implementing this directly (as I did recently) than using the module since the module supports the older version. You will also need m4v files to play video on iOS devices.

I implemented it by following their Quick Start Guide and placing the HTML and JS into my theme, tailored of course to be Drupal-friendly (i.e. using Drupal.behaviors for the JS and using preprocess functions to set file paths properly).

It works well, and my iOS-using client was able to listen to audio (I implemented it for audio) from their iOS device without issues.


Using Zurb Foundation without installing the required dependencies: npm, gulp, bower, etc

Alternatively, you could simply use the ZURB Foundation theme

  Do you like grid systems? How about rapid prototyping? Do you believe
  in mobile first? Then this theme is for you! Foundation is made by
  ZURB. This theme implements the Foundation framework for Drupal.


Try creating a Rule Set Component and call it from a reaction Rule.
(https://drupal.org/node/1300024)


How do I get the generated HTML ID of a form element?

I know this is two years late but for anyone looking back at this, a way to get the element IDs is to use Drupal Form API's #after_build attribute to add a callback once the form has rendered.

$form['#after_build'] = array('mymodule_afterbuild'); // The callback can be called anything.

Then your function would look something like:

function mymodule_afterbuild(&$form, $form_state) {
  // Get the element ID.
  $id = $form['title']['#id'];
  // Then do something, such as passing it into Drupal settings to access with Javascript.
  drupal_add_js(array('mymodule_js_settings' => array('title_id' => $id)), 'setting');
  return $form;
}

Edit to say that the #after_build attribute can be used on individual elements in a form like so:

$form['title']['#after_build'] = array('mymodule_afterbuild');

This actually makes it easier to get the IDs, especially if you're using fieldsets, field collections or other complex field data structures.


save and generate pdfs nodes with options

Part 1: Rules should allow you to save a PDF to the server. Step 4 on this page explains how to do so using Webforms (and Webform Rules), but it should work for node-generated PDFs: http://areatype.com/blog/create-email-pdf-files-drupal-webforms

Part 2: You can absolutely pass arguments to a Views PDF. Aren't you already doing that with the NID?


page-node-nid.tpl.php is not used as template file

Have a look at the Drupal 6 Template suggestions, The list of suggested template files is in order of specificity based on internal paths. One suggestion is made for every element of the current path, though numeric elements are not carried to subsequent suggestion, order of execution is as below:

page-node-edit.tpl.php
page-node-[node_id].tpl.php
page-node.tpl.php
page.tpl.php

  So basically you don't need to use the "TEMPLATE_preprocess_page" for using "page-node-[node_id].tpl.php" for template suggestion as it is provided by default. May be the problem is of "clearing the cache", try once after clearing the cache.

In Drupal6,  page-node-[node_type].tpl.php is not available by default, to make it work we customize the suggestions in the TEMPLATE_preprocess_page as done by you.

If you want more specific templates than you can customize the template suggestions as your requirement in TEMPLATE_preprocess_page. Example as below:

// Implement TEMPLATE_preprocess_page.
function TEMPLATE_preprocess_page(&$variables) {
  if ($variables['node']->type !== '') {
    // For using "page-node-[node_type].tpl.php" for template suggestion.
    $variables['template_files'][] = "page-node-" . $variables['node']->type;

    // For using "page-node-[node_type]-[node_id].tpl.php" for template suggestion.
    $variables['template_files'][] = "page-node-" . $variables['node']->type . "-" . $variables['node']->nid;
  }
}

After using the above code you can use the additional template suggestion as below:

page-node-[node_type]-[node_id].tpl.php
page-node-[node_type].tpl.php

NOTE: Don't forget to clear the cache after making changes to template files otherwise the changes won't reflect back.


If you are meaning the Drupal dashboard (admin/dashboard), there is a documentation page on how to customize the dashboard.

If you want to go further on the customization of the dashboard, there are modules like Homebox that can be useful.


Update theme table using callback function in Ajax

You can access the values of the form elements using the $form_state parameter. So when you have the value of the select element, you can perform the query as required, build the table using theme_table and return the result. The returned result can be replaced or appended to the ajax wrapper defined in your form.


When should I use collect an end date for a field, instead of using 2 separated date fields?

Why having two fields if one will be enough to serve the purpose?

Your question itself states that you need a "Start Date and End Date" so I think option 2 will be better, as it's simpler and could perfectly solve the problem you are facing. Also, the Date module is highly flexible, so displaying your dates in different formats will be easy enough.

On the other hand, only reason that comes to my mind for having 2 separate fields could be for re-usability, for example, if you wanted to reuse only one of your fields in another content type.


Updating duplicate Flags AND one or more Views blocks on a page on Flag click

I just ran into the same problem. This is how I handled updating duplicate flags on a page:

    $(document).bind('flagGlobalAfterLinkUpdate', function(event, data) {

        if(data.flagStatus == "unflagged"){
            $('.flag-favourite-' + data.contentId + ' a').each(function(){
                if(!$(this).find('a').hasClass('unflagged')){
                        ($(this).html(data.link.innerHTML));
               }
            });
        }
        else{

            $('.flag-favourite-' + data.contentId).each(function(){
                if(!$(this).find('a').hasClass('flagged')){
                        ($(this).html(data.link.innerHTML));
               }
            });

        }
    });

change out the term favourite with the machine name of you flag and it should work...


Track clicks in Drupal 7 and querying with Views

You want analytics/statistics tracking on some urls ? This has little to do with emails, or Views.

Typically you would use something like Google Analytics. There is a free open-source version with Drupal integration called Piwik. The Piwik module lets users see analytics detail(s). You may be able to setup a "Goal" per user of the urls they should be able to see tracking for, see also the sister module Piwik Reports.

The builtin Statistics module can count page views ... you could try to integrate it into Views maybe if you want. The Statistics Pro module has no D7 port yet, and sounds like what you want.


I'm working with this module right now too.

Once the module is enabled (and the required tcpdf library is intalled), you will see a new "Generate PDF" tab when editing each of your webforms. This is where you can add your PDF template under "Content of the PDF Document"

If you enter stuff here, it overrides anything you may have set globally (under /admin/config/content/webform2pdf).

You can use html and tokens here, for example...

INTERN NAME: [submission:values:intern_name]

I hope this helps.

If you get this working, maybe you (or somebody reading this) can help me with a problem I'm having: I want to add conditional logic for some of my fields so they only show up in the PDF if a value is entered.

I tried this via the interface (I have PHP filter module installed), but it resulted in a completely blank PDF, so now I'm going to try doing a template override instead.


A multisite configuration is used when a web server is associated to different domain names, and you want the web site to appear different when accessed from different domains. (If you want the web site appears the same in both the domain, there isn't any special Drupal configuration to follow.)

Suppose that your web site answers to example.com, and example.org. You can have two different settings.php files:

sites/example.com/settings.php for example.com
sites/example.org/settings.php for example.org

In the case those files are not found, Drupal would use the default one (sites/default/settings.php).

The same can be done for subdomains.

On your Mac, you should edit your hosts file (/private/etc/hosts) to add something similar to the following one:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
127.0.0.1 first.localhost
127.0.0.1 second.localhost

In this case, the following files would be used:

sites/first.localhost/settings.php for first.localhost
sites/second.localhost/settings.php for second.localhost

If those files are not found, Drupal would look for the following ones (and other files as well):

sites/localhost/settings.php
sites/default/settings.php


Attaching comments to blog post promoted to front page

The reason you do not see comment form on content promoted to front page is because by default comment form shows on full node view.So following code may help you.

function mymodulename_node_view($node, $view_mode, $langcode) {
  if(drupal_is_front_page() && $node->type == "your_content_type") {
      $node->content['comments'] = comment_node_page_additions($node);
  }
}


Use rules. When the order is completed, use the actions contained in the  userpoints_rules submodule to manage your userpoints. You might choose the "When an order has been paid in full" or you could just watch for orders moving in status to "Completed."


How to add custom views display formats to a view?

further to what @Danny Englander says, you can find the export option for a view to the right of the display list:


That happens because template_process_page() contains the following code.

if (!isset($variables['title'])) {
  $variables['title'] = drupal_get_title();
}

drupal_get_title() calls check_plain().

// During a bootstrap, menu.inc is not included and thus we cannot provide a title.
if (!isset($title) && function_exists('menu_get_active_title')) {
  $title = check_plain(menu_get_active_title());
}

The only way you have to add HTML to the title is using hook_preprocess_page() and set $variables['title'].

Keep in mind that $variables['title'] is also used as value for the <title> tag, and browsers should not expect HTML tags inside that tag.

  Titles may contain character entities (for accented characters, special characters, etc.), but may not contain other markup (including comments).

To change just the node title, you should implement hook_preprocess_node() and set $variables['title']. By default, template_preprocess_node() sets it using $variables['title'] = check_plain($node->title);.
As side note, for the node title, Drupal 8 uses $variables['label'], not $variables['title'].


How do I show the site-wide contact form on a page in Drupal 7?

You could create a custom block in a module and embed the form there. Something like this (I haven't tested this code!):

/**
 * Implements hook_block_info().
 *
 * This hook declares what blocks are provided by the module.
 */
function MODULENAME_block_info() {

  $blocks['contact_block_form'] = array(
    'info' => t('Contact Form'),
    );

  return $blocks;
}

/**
 * Implements hook_block_view().
 *
 * This hook generates the contents of the blocks themselves.
 */
function MODULENAME_block_view($delta = '') {
  //The $delta parameter tells us which block is being requested.
  switch ($delta) {
        case 'contact_block_form':
      $block['subject'] = t('Contact Us');
      // Load contact pages inc as the form definition sits there.
          module_load_include('inc', 'contact', 'contact.pages');
      $block['content'] = drupal_get_form('contact_site_form');
    break;
  }
  return $block;
}

Hope this helps


How can I add a contextual filter with taxonomy term name as entity reference?

The direct Product (which is a Taxonomy reference in your case) Contextual filter only works with term IDs, not their names. So you can make it work only if you choose the term ID in the validation settings.
To use the term name as the contextual filter you have to add the Relationship for the taxonomy reference field, which you seem to have done.
Now you can add the Term Name Contextual filter, from the Taxonomy term Category. (Remove the Contextual filter for the Product field that you currently have.) You didn't have the Term Name available under Contextuals before you added the Relationship. That Contextual will use the Relationship automatically.
When you add the Term Name contextual you will be able to set up the term name Validation, and you'll need to enter the term names in path arguments and in Views Preview field to test it.


How to display a Rules Link only if access to display the linked content was granted?

From the (my) accepted answer to your related question (= How to access node properties of another node using the Rules Link module?), I do remember that apart from the Content Access module, you ALSO use the ACL module.

However, even though via the ACL module you do get some extra Rules Actions (such as content_access_action_user_grant), there doesn't seem to be (or at least I have not found it yet) a Rules Condition that you could use to check that "the current user already bought the node" (as in your question here).

Too bad, if IT IS NOT available, then just MAKE IT available. For that, you can use the Flag. If you then configure a (non-global) flag, you could use that flag like so:

When configuring the flag, only allow it for bundle 'Classified Ad'. And make sure to only grant access to the flag to users with a role like "special role for Classified Ads" (name it what you want), to avoid the link to flag such nodes would be shown to unauthorized users (due to which they could flag the node just using the UI, which you do not want to happen).
Around the time the user buys access to your 'Classified complete' node, perform an additional Rules Action to "flag the 'Classified Ad' node by the current user as bought", and with the machine name of the flag (say) 'node_bought' (pick whatever fits).
Within the Rules Link, use a condition like "Is the node flagged with the 'node_bought' flag by the current user?".

Below is a (rather basic) Rules Component (= condition set (AND) "Rules link: authenticated user Link contact infos condition") with machine name to match your existing Rules Link also, as in your linked question. And which you could use for this (change the machine name of the flag from 'node_bought' to your flag's machine name, prior to importing this):

{ "rules_link_condition_access_to_contact_info_links" : {
    "LABEL" : "Rules link: authenticated user Link contact infos  condition",
    "PLUGIN" : "and",
    "OWNER" : "rules",
    "REQUIRES" : [ "flag" ],
    "USES VARIABLES" : { "node" : { "type" : "node", "label" : "node" } },
    "AND" : [
      { "flag_flagged_node" : {
          "flag" : "node_bought",
          "node" : [ "node" ],
          "flagging_user" : [ "site:current-user" ]
        }
      }
    ]
  }
}

Something I'm unsure about right now (= homework for you to QA-test): as per that "special role for Classified Ads" (see before), the (extra) Rules Action to flag the node may fail (not authorized for current user). If that's the case, then just add these 2 extra Rules Actions as a work around for that:

Grant access for current user to "special role for Classified Ads", right before the Rules Action to flag the node.
Remove access for current user to "special role for Classified Ads", right after the Rules Action to flag the node.


What are the major differences between Drush versions 3 & 4?

There's a lot of new user management stuff

user-add-role    Add a role to the specified user accounts.
user-block   Block the specified
user(s). user-cancel Cancel a user account with the specified name.
user-create  Create a user account with the specified name.
user-information Print information about the specified user(s).
user-login   Display a one time login link for the given user account (defaults to uid 1).
user-password    (Re)Set the password for the user account with the specified name.
user-remove-role Remove a role from the specified user accounts.
user-unblock Unblock the specified
user(s).

The cache clear functionality has become more fine grained
The backup folder for module updates now appears outside of webroot and you have greater control during updates over which modules to update (security updates only)

Check out http://docs.drush.org/ for more information.


I suggest you try to avoid using simple textfield for the Postcode. Then you can use 2 dependent fields. The first field will be the select of employees number range. The second will be one of postcode selects, depending on the first choice. Then you can use the standard functionality: using select field key as the email.

If for a fixed employee number range you have individual emails for different postcode values then it is straitforward.

If not, still you can do it if all postcode values could be grouped into ranges, so that each range gets its own email (define select values for postcode ranges same as you did for employees number).


Redirect users on first time login to a particular page

This is actually very simple in D7 using the Rules module. All you have to do is see if the value of the user's Last Access field is empty. When an account is created, the initial value of the Last Access is empty.

The value of this field is not set until sometime AFTER the rules have been run. So, all you have to do is setup a conditions in rules that check:

Data value is empty
site:current-user:last-access

Here is an export of my rule and it has been working fine. If anyone finds any issues, please let me know. You should be able to import this rule into your site.

{ "rules_first_time_login" : {
"LABEL" : "first time login",
"PLUGIN" : "reaction rule",
"WEIGHT" : "1",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "user_login" : [] },
"IF" : [
{ "data_is_empty" : { "data" : [ "site:current-user:last-access" ] } },
{ "user_has_role" : { "account" : [ "account" ], "roles" : { "value" : { "16" : "16" } } } }
],
"DO" : [
{ "drupal_message" : { "message" : "Welcome to Drupal Camp Florida. Please submit your session proposal below." } },
{ "redirect" : { "url" : "node/add/sess?destination=/admin/dashboard" } }
]
}
}

The role with a value of "16" is a role of "Speaker".


As the exception message says, there is no english translation for that node.

The node is already in the translation that Drupal determined is the best available translation for this page.

If you do want to get a specific translation, you need to check with hasTranslation() first or use \Drupal::service('entity.repository')->getTranslationFromContext($entity, $langcode);


How to hide the title field in create content (Drupal 6)?

The Automatic Nodetitles module in conjunction with the Token module is perfect for this.  From the project page:

  "auto_nodetitle" is a small and efficient module that allows hiding of
  the content title field in the form. To prevent empty content title
  fields one can configure it to generate the title by a given pattern.

  When the token module is installed it's possible to use various node
  data for the auto generated title - e.g. use the text of a CCK field
  (since 5.x).

  Advanced users can also provide some PHP code, that is used for
  automatically generating an appropriate title.


Get information from a node that has just been saved to update a different node

In hook_node_insert($node) you cannot reliably read saved node's data from database, but you can read data from $node object provided to that hook.


Display main menu vertically (Drupal. 7.9)

You need to use Firebug and find the style rule that is being applied to the <li>elements that will be displaying them inline. Firebug will tell you where the CSS is being loaded and this will lead you to the culprit. One tip is to make sure you're not aggregating CSS so you can find the correct stylesheet. If it isn't theme specific it may be CSS being loaded by a module, but I am confident that there is some CSS there that is creating the result you're seeing.


Your callback function is in your theme's template.php file, which is only loaded when that theme is being used.

I'm assuming your admin backend uses a different theme, so it can't find your callback function on admin pages.

The best solution would be to move the logic into a custom module; it's not theme related functionality so best practice would be to move it there anyway, even if it wasn't causing a problem.


How to display results tagged with just one term ID when there are multiple filters

When I tried using the taxonomy term pages approach, I could not figure out how to get the fields displaying properly.  The fields displayed were based on the teaser in my Blog content type.  And using exposed filter option was not a solution since my use case was to only display results based on one tag.  What worked for me:

1) Add new view to existing Blog View

2) FORMAT: 'Unformatted list'
    SHOW: 'Fields'

3) FIELDS: [add fields that you need displayed]

4) FILTER CRITERIA: 'Content: Published (Yes)'; 'Content: Type (= Blog)'

5) PATH: '/blog/[YOUR VOCABULARY NAME]/%'

6) CONTEXTUAL FILTERS: 'Content: Has Taxonomy Term ID'

WHEN THE FILTER VALUE IS NOT IN THE URL: 'Display all results for the specified field'

WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED: select 'Override title' and in the input field, enter: '[YOUR VOCABULARY NAME]/%1'

select 'Specify validation criteria'

Validator drop-down, select 'Taxonomy Term'

Vocabularies: select appropriate Vocabulary name

Filter value type drop-down: 'Term name converted to term ID'

select 'Transform dashes in URL to spaces in term name filter values'

Action to take if filter value does not validate: select appropriate one that works for your needs (in my case: 'Display contents of "No Results found"')

If you need to display the term name in the heading on the results page, in the same view > HEADER > Add 'Global: Unfiltered Text' > then in text area, add something like "VIEWING RESULTS FOR [YOUR VOCABULARY NAME] / %1"

Save the View.  Since I had multiple filters, I cloned the above view and renamed everything. So, I ended up adding 3 additional views to my existing Blog View.

I had previously set URL aliases for Taxonomy Term Paths, so I removed these

Also, I had to go back to my Taxonomy Terms individually and delete the URL alias that was generated from the pattern

To have the list of tags displaying on the right with the desired URL structure of /blog/[YOUR VOCABULARY NAME]/[YOUR TERM NAME], I created a separate new view:

SHOW: 'Taxonomy Terms' of type '[YOUR VOCABULARY NAME]'

Create a Block

'Unformatted list' of 'Fields'

FIELDS: 'Taxonomy: Term Name' > click this and unselect 'Link this field to its taxonomy term page'.  Then expand "Rewrite Results" section and select 'Output this field as a link' > in the Link path: 'blog/[YOUR VOCABULARY NAME]/[name]' (the [name] at the end of the url structure should appear as you see it with the square brackets) > select 'Replace spaces with dashes' > Transform the case to 'lower case' > click Apply

FILTER CRITERIA: 'Taxonomy vocabulary: Machine Name (= [YOUR VOCABULARY NAME])'

Save the View

Then in Structure > Blocks, place the block in the appropriate region

Hope this helps someone!


Set up a script to call drush at regular intervals. There are several drush commands to manage migrations, such as drush migrate-status.


Adding prefix and suffix to a content type field

You can add prefix and suffix in the display settings of the field with the Simple Field Formatter module

Download and enable the module
Go to admin/structure/types/manage/mycontenttype/display
Click on the settings icon for the specific field


Eyal is correct. FormState has a method getTriggeringElement. See the original change record for details.

$form_state->getTriggeringElement();

and if you want to get id try

$triggerdElement = $form_state->getTriggeringElement();
$htmlIdofTriggeredElement = $triggerdElement['#id'];


Use this

In place of name put button name.

$form['name']['#value'] = t('Name');

Hope this will work


It really depends on what you are trying to accomplish.

If you need any Drupal feature, like commenting and tagging, or want to integrate with modules like Fivestar or Flag, then you need a node (or other entity).  If you want to get into the theming system, then I think you have no real choice.  The way I normally accomplish this is to have a hook that runs hook_node_load, does a call out to the remote system (either REST or direct DB), and then builds up a data structure and sticks it somewhere in $node.  You then have some preprocess functions to make the data available to the node templates, or you have a hook_node_view to get the data into the $node->content render array.  The next time I need to do this I will likely try to use the Field Storage API with content types defined by hook_node_info.

With this approach, the only thing the node is really used for is to have a $nid / $vid pair available to the rest of Drupal for other modules to work.  The content type that you are using typically only needs on field in it to store the primary key in the remote system.  I usually also copy over the title to the node to make it easier to identify in the admin UI.

Though all of this may seem hard, it is actually pretty straightforward and mostly easy to implement if you are familiar with the API.

Just remember that what you need to do now may not be what you want to do in the future.  Preparing for this by having true nodes available may make better sense in the long run.


How do I allow facets on my full content display page?

So I've decided this does not need to be done. When a user gets to the product page (however they land there), they simply click the next level of the breadcrumb link to get to that parent group.

Here are some examples of how this is shown is various e-commerce sites:

Macy's product page (no facets showing): http://www1.macys.com/shop/product/louis-raphael-pants-hidden-extention-pleated-pants?ID=796776&CategoryID=89#fn=sp%3D1%26spc%3D546%26ruleId%3D60%26slotId%3Drec%281%29
Then you click on "Pants" on the breadcrumb link and you see the facets: http://www1.macys.com/shop/mens-clothing/mens-pants?id=89

I hope that helps others who may have this question.

Best,

Tom


How do I get only node IDs from the search results?

This is because the fields() method of the SearchAPIQuery class makes the search in fields with datatype fulltext.

In order to get the nid in the result, you have to ensure that its value is being indexed by search_api. You can check that at /admin/config/search/search_api/index/my_index/fields (my_index is the name of the index in this case).

To filter using the nid field you might have to use the condition method instead. The following should work:

$index = search_api_index_load('my_index');
$query = $index->query();
$query->keys($search_terms);
$query->condition('nid', $val); // The third parameter "operator" defaults to "="
$results = $query->execute();
return $results;


updating field value of a content type with query

Why not you use field API field_attach_update() instead, it can save the node_save() process.

For example take this.

  $node = new stdClass();
  $node->id = $id_value;          // node id
  $node->type = $bundle_value;  // aka content type

  $node->field_fieldname[LANGUAGE_NONE][0]['value'] = 'some value';
  field_attach_update('node', $node);

Reference: http://www.urbaninsight.com/2011/10/24/saving-nodes-fields-without-saving-node-itself


What is the proper way to set up an AWS Auto-Scale group?

Drupal considerations are similar to WP, Magento and Stateless applications.

Share your code across your auto scaling group via AWS EFS, Lsyncd, S3 or NFS.
Use CDN + S3 for static content
Separate Database (AWS RDS)
Make sure to use Varnish and NGINX.
Use Github/BitBucket and define a development workflow system.
Cache and manage session via Redis/Memcached.

More details: https://www.clickittech.com/cloud-computing/scaling-in-the-cloud/

The above link is an article about the Art of scaling which considers Drupal, WP and Saas Applications.


Date API: Proper method of parsing dates

How can I use the Date API to obtain DateObject from the event date
  stored on the node?

Offhand, I'm not 100% sure the right way to do this. It sounds like you want to use the DateObject to perform some calculations -- not just to run through a theme field_formatter. This date issue thread has some code kinda trying to use date fields and their values, but doesnt help much.

Simply because I can understand it (and have used this module myself) I recommend trying out the sub-module of Date, date_api, and an additional 3rd party module: field_extract.

With field extract you can easily (and correctly) access a fields value for instance as a timestamp:

  // Extract from a date, this extracts the first value and provides a
  // formatted date output, uses the specified format, by name.
  $event_timestamp = field_extract_value('node', $node, 'field_event_time', 0, array('format' => 'timestamp'));

You can then use the DateAPI to create a DateObject:

$date = new DateObject($event_timestamp);

  How can I determine whether the stored event is an
  all day event?

Use the date_is_all_day() function found in the date_api module, it compares 2 date fields to check if they encompass a full day.

 function date_is_all_day($string1, $string2, $granularity = 'second', $increment = 1) { ... }


Can I use ajax to target multiple form elements from one input?

It appears that you can target different parts of a form using ajax commands, however you must choose to return only one of either:

HTML or
A renderable array or
An array of AJAX commands

In the situation I originally wrote about, I was trying to return both an array of AJAX commands and a renderable array, which doesn't seem possible.

Code in the examples module demonstrates targeting different parts of a form using an array of AJAX commands:

function ajax_example_advanced_commands_html_callback($form, $form_state) {
  $text = $form_state['values']['html_command_example'];

  $commands = array();
  $commands[] = ajax_command_html('#html_div', $text);
  $commands[] = ajax_command_replace("#html_status", "
Updated html_command_example with text=$text;  " . date('r') . "
");
  return array('#type' => 'ajax', '#commands' => $commands);
}

In this code sample, #html_div is getting $text, and separately #html_status is getting "Updated html_command_example with text=$text;  " . date('r') . ""

Two different locations on a form with two different pieces of information from the one ajax callback!

Looking again at what I was working on, I realized that I didn't need to return the node title field at all. It will only be a utility field, used for sorting data in lists.

I have hidden the field on the node form and it is populated the second time my form is built when my original ajax callback is triggered.


drupal_set_message on node edit page shows twice with theme hook

Form alter changes the form when it's being built for display.

If you want to use the value on the node after update, use a hook like

hook_node_presave or
hook_node_update

instead.

To tweak your code snippet, something like:

/**
 * Implements hook_node_presave
 */
function mymodule_node_presave($node){
  if ($items = field_get_items('node', $node, 'field_vacature_scheduled_for_unp')) {
    $vacature = reset($items); // Use first field item value
    $expirydate = date("F j Y", $vacature['value']);
    $items = field_get_items('node', $node, 'field_unpublish_date')
    $unpublish = reset($items); // Use first field value
    if ($unpublish['value'] < time()) {
      drupal_set_message(t("This vacature has expired."), 'status', FALSE);
    }
    else{
      drupal_set_message(t("This vacature will expire at: "). $expirydate, 'status', FALSE);
    }
  }
}


This answer is based on the tutorial http://www.stonemind.net/blog/2008/02/07/tips-for-implementing-a-subscription-based-drupal-site/.
Here is further information in EC subscriptions:Role products
http://drupal.org/node/88239

Firstly the user needs to install various modules

All modules in the E-Commerce Core package.
Your payment gateway choice.
Generic Product
EC Recurring.
EC Role.

It is important to note that subscription are intangible. They are not solid objects and therefore don't have an arrival time. For this reason the type of product is a "Non Ship able product"
E-Commerce configuration (at /admin/ecsettings)

The tool mentions that the way rebelling is achieved is due to the cron tasks. So therefore its imperative that is can be achieved.

Multiple roles can be purchased to achieved so there can be different types of subscriptions. To enable only certain users to access  certain content the node option premium module.  http://drupal.org/project/nopremium. This is the replacement for the module premium that was used in drupal 6.

If you want different types of roles to be only able to see a teaser. You can use the contemplate module to achieve this task. This means that you could have content that certain users will not be able to see. A good example is news site which give a teaser and ask you to register to find out more information.

http://drupal.org/project/contemplate


Price field with Currency outside of commerce and ubercart

I'd go with Commerce Price (part of Commerce). You don't need to enable the rest of Commerce.
The price module itself is relatively small (while giving you price calculation, and Rules integration for free, if you need it), and the rest of Commerce won't be loaded, taking only space on your hard drive, which probably doesn't concern you much.

That's the beauty of Commerce separation, you can use only a few modules that give you exactly what you need. I've seen that happen in many projects.


How to sort users in a view by the number of nodes authored of a specific node type?

Not sure if I understand you correct, but have you tried setting up a normal filter:

Content: Type (= nodetype)


Trying to get a property of a non-object in 'mymodule_node_access()'

$node in hook_node_access() can be either a string for the content-type or a node object.
I had to test if it was a string or an object.

if (is_string($node)) {
  return NODE_ACCESS_IGNORE;
}
else {
  // ...
}


How can I automatically flag new comments?

Flag ID should be the ID of the flag being set. If you go to /admin/structure/flags, and Edit the flag, the machine name/ID of the flag will be at the end of the URL -- so /admin/structure/flags/manage/{flag_id}.
I've not used Rules on D8, but for Entity ID, if you click "switch to data selection" and then click the field, I think it should give you some autocomplete options to help select the data you want. You'll likely end up with something like "comment:id".


Your PHP is incorrect :(

The second line should read $name = $user->name;.


Need help defining IE specific stylesheet with Zen Starter-kit and Conditional Stylesheet Module

If this link is in your head it is like if the css file is in a folder under the currrent one. You need a first backslash: <!--[if IE]><link rel="stylesheet" type="text/css" href="/sites/all/themes/THEMENAME/css/ie.css" /><![endif]-->

As you can see in the answer you linked the definition in .info file has to look like

stylesheets-conditional[IE][all][] = css/ie.css

not

stylesheets-conditional[if IE][all][] = css/ie.css

(I just have it from this answer - never used this module). Honestly I would not install a module just to add conditional comments for IE. It is easier and saves performance eating module to put them simply into the html.tpl.php - you just have to keep the right paths.

stylesheets-conditional[!IE][all][] = css/ie.css

Makes absolutely no sence - I do not know if this module could interprete that. But at least no browser in the world would read a css file in such a conditional comment: every browser except IE ignores conditional comments. So you tell the only browser who reads them that this file is notfor it to use... you got it :)


Webform: request submitted values in all page breaks

You can retrieve submitted values across all pages from $form_state['storage']['submitted'].

Note that this represents values from past pages and not the current page. Here is the code I use to get them all (past & current) page values into a single array:

$values = _webform_client_form_submit_flatten($node, $form_state['values']['submitted']);
$values += $form_state['storage']['submitted'];


Allow to change site logo without giving too many privileges

You could implement hook_menu_alter() to change the permission associated with that page, and use other permissions to decide which form fields should be visible to the currently logged in user. In this case, instead of using $element['#access'] = FALSE, you should use $element['#access'] = user_access('your custom module permission').
In the case you are only interested to allow some users to change the site logo, then you can use your custom permission for the page containing that settings form, and then use the "administer site configuration" permission for the form fields only the site administrators should see ($element['#access'] = user_access('administer site configuration')).

function mymodule_menu_alter(&$items) {
  if (isset($items[$menu_path]) {
    // Use the following line if the access callback already used is not user_access().
    $items[$menu_path]['access callback'] = 'user_access';
    $items[$menu_path]['access arguments'] = array('your custom module permission');
  }
}

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == $form_to_alter) {
    $form[$element_id]['#access'] = user_access('administer site configuration');
  }
}


How do I calculate the total of a shopping cart?

You can use array_merge() to merge two arrays into one.

It looks like you're trying to overengineer things. This is a simple solution:

$combined = array();
for ($i = 0; $i < count($jcartItemQty); $i++) {
  $combined[] = array($jcartItemQty[$i], $jcartItemPrice[$i]);
}


How to create a basic message - notifications system displaying a real time message counter badge?

For real time messages, you will need the Node.js integration module. You can use Heartbeat, the Taskbar and the Message modules together to show notifications.


Bypassing Drupal's htaccess rewrite for static page

Look at Drupal's .htaccess, lines 110 to 113:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]

It means if you create directory "products", every static file that's there will be served and all the rest will be directed to Drupal. Simple as this. If it's not working for you, you need to provide more details or fill a bug report.


Your PHP is incorrect for what you're trying to accomplish.

Drupal has field_get_items() for this purpose, though:

$items = field_get_items('node', $node, $field_name);
...


Properly override template_preprocess_book_navigation function in Drupal 8 Book module

You can put a template_preprocess() function in a custom module or your theme mytheme.theme file.
It depends on what you want to achieve.
If this preprocess function is specific to the theme (for example, the results are used in a theme template), then you should put it in mytheme.theme.
But, if you put the code in mytheme.theme and then change themes, your book navigation will no longer behave as expected.
So, if the preprocess function does general processing that you might want to use in multiple themes, and it doesn't do anything theme-specific, then it's better to put it in a custom module.  (This is probably your use case.)


What is the recommended method to add an RSS icon to an Open Scholar scholar site?

If you have a footer menu, you could add the RSS feed to it, and then attach a bit of CSS to your theme.  The exact selectors would depend on what is being output, but you could do something like:

ul#footer-menu li.menu-1234 {
  padding-left: 20px;
  background: url(/path/to/rss.png) left center no-repeat;
}

You may need to adjust other styles to get the whole icon to appear.

There are bunches of sites with royalty free RSS icons.


Override html.tpl.php by content/node type

replace

$vars['theme_hook_suggestions'][] = 'html__' . $node->type;

with

$variables['theme_hook_suggestions'][] = 'html__' . $node->type;


Using Panels - Node Template.. How do i pass additional arguments for my blocks?

You need to use content pane for the view to make it accept arguments.

Then when you insert the content pane, you should be able to use the node and all fields on the node using a token system to pass any variable to the view pane. How you setup the content pane determines which types of variables it will accept.


On administration forms system_settings_form is normally used to return form,
so the element id is same as the variable name without the "#edit-" with underscores.

For example on: /admin/config/system/site-information

id="edit-site-mail" -> drush vset site_mail peter@email.com

To turn off the email verification:

"edit-user-email-verification" -> drush vset user_email_verification 1

Drush returns all variables that match with your variable name, so if you only know part of the name you can try:

drush vget email

returns all matches:

user_mail_status_canceled_notify: 0
user_mail_status_canceled_subject: "Account details for [user:name] at [site:name] (canceled)"
reroute_email_address: "debug@email.net"
reroute_email_enable: "TRUE"

Module devel (https://drupal.org/project/devel) let you check all drupal variables on this menu callback: /devel/variable


Date module shows time field +5:30 ahead from input

It seems as default behavior of date module if you check its documentation you can see:

Time zone handling

There are 5 different options for field Time zone handling:

Site's time zone - When entering data into the field, the data entered is assumed to be in the site's time zone. When the data is saved to the database, it is converted to UTC. When retrieved from the database, the data is converted to the Site's time zone for anonymous users or the User's time zone for logged in users when User-configurable time zones is enabled.

Date's time zone - With this option enabled, the date field adds a select box to explicitly specify the time zone for the date entered. When the date is saved to the database, it is not converted & the time zone information is saved with the date. When retrieved from the database, no conversion is performed and the date is displayed exactly as entered.

User's time zone - When entering data into the field, the data entered is assumed to be in the user's time zone. When the data is saved to the database, it is converted to UTC. When retrieved from the database, the data is converted to the Site's time zone for anonymous users or the User's time zone for logged in users when User-configurable time zones is enabled.

UTC - When entering data into the field, the data entered is assumed to be in UTC time zone. When the data is saved to the database, it is converted to UTC (e.g. no conversion necessary). When retrieved from the database, the data is converted to the Site's time zone for anonymous users or the User's time zone for logged in users when User-configurable time zones is enabled.

No time zone conversion - The date entered is not converted when saved to the database. When retrieved from the database, the data is NOT converted and is displayed exactly as entered.

so currently your settings are in site's timezone which is assuming that you entered date is in UTC hence the retrieved date is site's timezone which is UTC+5:30 switch setting s to No time zone conversion and you can see retrieved date as entered one.


How can I do "Buy one get two free" with Ubercart?

I found the solution using Ubercart Custom Price module and the code below.

// Load the current shopping cart.
      $items = uc_cart_get_contents($cid = NULL, $action = NULL);

    // Count the number of items
      $number_of_items = count($items);

    $firstPrice = 10;
    $secondPrice = 0;
    $thirdPrice = 0;

    switch ($number_of_items) {
      case 0:
        $item->price = $firstPrice;
        break;

      case 1:
        $item->price = $secondPrice;
        break;

     case 2:
        $item->price = $thirdPrice;
        break;
    }


Fatal error undefined function taxonomy_get_tree()

Maybe the taxonomy module is just loaded after yours... Have you tried to load the taxonomy module before calling taxonomy_get_tree()? :

drupal_load('module', 'taxonomy');
$tree = taxonomy_get_tree(6, $parent = 0, $max_depth = NULL, $load_entities = FALSE);
print_r($tree);


How to set end date relative to start date in date range field

The current widgets in core for the Datetime Range module do not allow this.

You would need to create a custom widget for this.  Off the top of my head, I would create one that extends DateRangeWidgetBase() and mostly mirrors what DateRangeDefaultWidget() does, except to collect a relative period in a plain text field for the end date.  Then, add a massageFormValues() function to turn the relative date into an absolute one, and then call parent::massageFormValues().  You may also be able to do this with a #process callback on the end date element, but I forget which of the two runs first during form processing.


How do you force drupal 7 to make a new revision every time you edit a node?

Just like in Drupal 6, you enable this in the content type settings. At admin/structure/types, click edit for the content type you want to enable this and then check "[] Create new revision" under Publishing options.


How to get a conditional dependency to work?

As an alternative solution to using the conditional fields module (cfr your comment in your question), you can use the Rules module for this. Here are some details (the pseudo code) about how to do so:

Rules Event: Before saving content.
Rules Conditions:

Check for "entity has field" (for field = Enable)
Check for "entity has field" (for field = Photos Gallery)
Compare the value of the "Enable" field, for both the original value (before editing the field) and the (new) updated value, to verify if they enabled (checked) this field.
Check if field "Photos Gallery" is empty.

Rules Action: display an error message to explain that your validation failed. For an example of how to display an error message using rules, refer to my answer to "How to make the permissions of a module more granular?" (which actually includes 2 actions, you only want the drupal_message part of it (probably not the redirect to somewhere else).

To understand the need for those Rules Conditions "1." and "2.", have a look at my answer to "How to check in a rules condition if an image field has value?"

Should be straight forward to "develop" such rule, no (PHP) coding at all involved (only site building using admin UI).

Video tutorials

If you're not familiar (enough/yet) with Rules, checkout the 32 (!!!) great, and free, video tutorials Learn the Rules framework, organized in 7 chapters.


How can I trim the display of text and expand with "more" link?

Look, up in the sky.  It's a bird.  It's a plane.  It's...... sorry.  This is a job for jQuery. A quick google of "jquery more less toggle" (without the quotes lol) will show lots of examples.


how to provide security to user Profile?

Using profile2 module you can create private profile. This module provides the following items :

  With profile2 user account settings and user profiles are conceptually different things, e.g. with the "Profile pages" module enabled users get two separate menu links "My account" and "My profile".
  Profile2 allows for creating multiple profile types, which may be assigned to roles via permissions (e.g. a general profile + a customer profile)
  Profile2 supports private profile fields, which are only shown to the user owning the profile and to administrators.