Omega 3.x base theme missing after Drupal upgrade

Where did you put your base theme?

It should be in the same folder as your theme "sites/all/themes". If you put it in the top themes folder, beside Bartik, Seven, etc, it was in the wrong place and this folder is overwritten when you update.

If his is the case you can probably just download it again and put it in the correct folder "sites/all/themes".


optimal way to remove unwanted js and css files from page

The AdvAgg module can do this fairly easily. Syntax for this is different between 6.x & 7.x. This is the hook syntax for 6.x. Works very similar to hook_css_alter() & hook_js_alter() in Drupal 7. Using these hooks is how to do it in D7 BTW.

hook_advagg_css_pre_alter(&$css, $preprocess_css, $public_downloads) {
  // Remove css files.
}
hook_advagg_js_pre_alter(&$js, $preprocess_js, $public_downloads) {
  // Remove js files.
}


Multiple contextual filters using or statements

In case anyone wants to know, I was able to accomplish this with some views hooks and will share my solution.

First you need to register view api information

/**
 * Implements hook_views_api().
 */
function mymodule_views_api() {
  return array(
    'api' => 3,
  );
}

Then you need to alter the view at pre build to include the "Global" term. I am using entity query to determine if there is any content with the Global term. If so I am adding that term as an argument.

/**
 * Implements hook_views_pre_build().
 */
function mymodule_views_pre_build(&$view) {
  // we were getting no results if the tid of the Global term was not 1
  // in some build instances it is not so we need to ensure that the default
  // value being passed is the actual tid of the Global term.
  if (($view->name == 'badge' || $view->name == 'promo_box' || $view->name == 'article'|| $view->name == 'tips') && $view->current_display == 'block') {
    $vocabulary = taxonomy_vocabulary_machine_name_load('site_section');

    $entityQuery = new EntityFieldQuery;
    $entityQuery->entityCondition('entity_type', 'taxonomy_term')
      ->propertyCondition('name', 'Global')
      ->propertyCondition('vid', $vocabulary->vid)
      ->range(0 ,1);

    $result = $entityQuery->execute();

    if ($result) {
      $term = array_slice($result['taxonomy_term'], 0);
      $view->argument['tid_1']->options['default_argument_options']['argument'] = $term[0]->tid;
    }
  }
}

And finally you need to switch the where statement to and or

/**
 * Implements hook_views_query_alter().
 */
function mymodule_views_query_alter(&$view, &$query) {
  //  Let's find out if we are attempting to load either the badge or promo box
  //  view. If so we need to alter the where clause to include an or statement
  //  in the conditional filter to also look for the global term in the site secttion
  //  taxonomy. I was not able to find a way to create an OR condition filter via a
  //  module so for now this is the best to do it.
  if (($view->name == 'badge' || $view->name == 'promo_box' || $view->name == 'article'|| $view->name == 'tips') && $view->current_display == 'block') {
    if (isset($query->where[0]) && isset($query->where[1])) {
      $query->where[0]['type'] = 'OR';
    }
  }
}


How to set start slide for views slideshow jcarousel

Try to add a contextual filter to the view that sorts the results putting the desired element in the first position of the carousel.

There is a nice reference for that: http://www.metaltoad.com/blog/using-drupal-contextual-filters-views


Found a article at drupal.org and trying to implement it

http://drupal.org/node/907542


What is the best way to add user points to existing users

One method here is to use the Userpoints API and execute a code snippet that will add the points for you. You can reference the userpoints API here. You can do something like this...

$initial_value = 10;
//@TODO: Build a list of all $uids in an array
foreach($uids as $uid) { =
  userpoints_userpointsapi(array(
    'uid' => $uid,
    'points' => $initial_value,
    'operation' => "Add Initial User Point Value",
  ));
}


If you are willing to use extra modules, instead of simple t() coding (as I do not believe this is possible for what you desire), install Profile2 and i18n Internationalization modules. Then, follow this guide in Profile translation and its documentation and that should set you straight.

Hope this helps.


How a anonymous user can view profile of authenticated user

In Drupal 7

/admin/people/permissions
Users - Section --> View user profiles!

Drupal 7 user Permission

In Drupal 6

/admin/user/permissions
user module --> access user profiles


Parent-child-grandchild relationship for content or comments

I would go with option B, as having answers as content types allows you to add other features like the Flag module for up-votes.
The automatic and invisible reference linking can be done with the Entityreference prepopulate module, once there is a Drupal 8 version. You could also port it yourself or make an equivalent custom module. The older Node Reference URL Widget module would even add a link to your Question node on the Create Answer page with the appropriate URL adjustment for the reference.


How to delete all but the current revision from the field_collection_item_revision table?

(Assuming a MySQL database)

Execute the following MySQL request:

DELETE fcir FROM field_collection_item_revision AS fcir
  RIGHT JOIN field_collection_item AS fci
    ON fcir.item_id = fci.item_id
  WHERE NOT fcir.revision_id = fci.revision_id;

We delete all revisions that are not present in the field_collection_item table under "revision_id".


Building Social Network with retweet like functionality

You can use the statuses module for this. See this post for discussion of retweet functionality with statuses.


If the images are of different sizes, it might look a lil sloppy. You can use CSS to set a particular height and width for all the images so that they look uniform and I guess overriding views-view-grid.tpl.php just for this is not the best way.


Is it possible to add a button to a field_collection?

I ended up asking Sacrilegious, one of the regulars in #drupal-support, and he offered this solution:

Define a new class in {module root}\Plugin\Field\FieldWidget names FieldCollectionCustomEmbedWidget.php

<?php

/**
 * @file
 * Contains \Drupal\{module}\Plugin\Field\FieldWidget\FieldCollectionCustomEmbedWidget.
 */

namespace Drupal\{module}\Plugin\Field\FieldWidget;

use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\field_collection\Plugin\Field\FieldWidget\FieldCollectionEmbedWidget;

/**
 * Plugin implementation of the 'field_collection_custom_embed' widget.
 *
 * @FieldWidget(
 *   id = "field_collection_custom_embed",
 *   label = @Translation("Embedded custom"),
 *   field_types = {
 *     "field_collection"
 *   },
 * )
 */
class FieldCollectionCustomEmbedWidget extends FieldCollectionEmbedWidget {

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

    $element['custom_button'] = [
      '#markup' => '
button text
',
      '#value' => t('button text'),
      '#attributes' => [
        'class' => [
          'my-custom-button-class'
        ],
      ],
    ];

    return $element;
  }
}

Then under Structure, I went into the settings for the form containing the field that needed this button, and under "Manage Form Display", I changed the widget type of the field to the newly added "Embedded Custom." Now the button is there.


Can I have a body apply to a different page than the current content type?

I'm not totally clear on what you are asking, but I will try to help anyway (and maybe with more clarification I can help further)).

It sounds like you have a gallery content type. Do you need these gallery images for anything else? Because it also sounds like you want an image to show up on the news article page. If that is the case, why not just have fields for the images, caption, and link in the news article content type? That way, when the person goes to edit the news article, everything is write there - both the fields related to the news article itself as well as the fields related to the gallery ones. I feel like this would make more sense to the person editing it anyway.

And then if you still need a separate gallery or something using the images that have been added, you can still use the images in the news article content type to make a separate view.


It supposed that the module has his own css, you need to edit those files but that is not a solution.

I recommend you to use some debugging tool like firebug and check what css you need to edit. Then write the css changes in your theme css file. With this logic if you update the module you will not loose all your custom changes.


I think using a template file will be the easiest way to do this.

In your view => click Theming information

  => Select the tpl file that suits you best

  => place that tpl file in your templates folder under your theme

  => for the content of the file

  => under Theming Information in your view click Display output

  => copy that content to your tpl and change the position of your header

  => come back to Theming Information and click Rescan template files - your newly added tpl(under your theme directory) should be highlighted(bold) now, which means you tpl is up and working!

Hope this helps.

[I am sure you might know how to do all this, yet putting it in details might help somebody else looking for the same solution who hasn't yet learned how to :)]


User logout automatically when the browser is closed

Okay, I changed the cookie_lifetime: 2000000 to 0 in local.services.yml file.

Then set the cookie in php by giving the last 2 arguments as 'true' ,this makes the cookie to be httponly and secure.

Thanks for your reference.


When is the filter value available to a context filter in a view?

At the very top of the contextual filter configuration window you have:

  This display does not have a source for contextual filters, so no
  contextual filter value will be available unless you select 'Provide
  default'.

The answer to your question When the filter is available? is short:

The filter is available only if has been provided.

Let say, you want to show a block with the content that depend on node id. Obviously you don't want to provide the node id by yourself on each node to see what the block content is. You don't need to provide it, because the node id is in the URL, so it's available. Of course the node id is not always in the URL, for example if you're viewing a user profile or a list of recently added articles. That's why this fieldset has been labeled:

WHEN THE FILTER VALUE IS NOT AVAILABLE

In this fieldset you can decide what to do when the filter hasn't been provided (display all results? provide default? .. many options there..)


There should also be a Formats tab at the top of that page. Here you can add additional formatting (like date or time only formats). After saving the format, go back to the first page and now you can select your newly created format as an option.


How do I add fields to the email field contact form?

You'll need to replace email_mail_page_form_submit with your own submit handler, because the Email module doesn't add extra form items to params automatically.

Firstly, copy the code from the function email_mail_page_form_submit in email.module and add phone and province to the params:

function MYMODULE_email_mail_page_form_submit($form, &$form_state) {
    // ...

    $params['object'] = $object;
    $params['subject'] = $form_state['values']['subject'];
    $params['name'] = $form_state['values']['name'];
    $params['message'] = $form_state['values']['message'];
    // Add your extra params
    $params['phone'] = $form_state['values']['phone'];
    $params['province'] = $form_state['values']['province'];

    // ...
}

Secondly, replace the submit handler on the form:

function MYMODULE_form_alter( &$form, &$form_state, $form_id ) {
    // contact form alterations
    // ...

    // email page form alterations
    if ($form_id == 'email_mail_page_form') {
        // add your phone and province fields
        // ...

        // override the email module's submit handler
        $form['submit']['#submit'] = array('MYTHEME_email_mail_page_form_submit');
    }
}

Then you can add them to the message as needed in HOOK_mail_alter.


You can use

function hook_block_view_BASE_BLOCK_ID_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) {
  //Change the title of the specific block.
  $build['#cache']['max-age'] = 0;
}

Also note that this does not disable the page cache for anonymous users. If you need that too, then you also need:

  \Drupal::service('page_cache_kill_switch')->trigger();


How to consistently redirect after saving on Add/Edit node form?

This does the trick ;)

The code below was added in hook_form_alter().

/* Set the desired redirect */
$form_state['redirect'] = 'node/add/lesson';

/* Then clear the "destination" value */
unset($_GET['destination']);
drupal_static_reset('drupal_get_destination');


Search index stuck at 0%, mysql error on public search, can't clear error

I have traced this particular problem to the Node View Permissions Module.  Disabling this module allowed my search to re-index and be seen by users who are not logged in.

There is a patch available here : https://www.drupal.org/node/2564273


Access variables populated in one page function for a different page function? Always null

First off, Drupal is bootstrapped every time a new page is requested. Even if both the pages  would be using the same menu callback, the global variables would be reset when passing from a page to the other one.

What you can do is using session variables, passing variables through the URL, or using a cache.
Passing variables through the URL would not use for complex variables, as there is a limit to the URL length accepted from browsers; using a cache would be a solution if the cached data should be available to more than one user, such as to user having the same rule; using session variables is the easier solution when the data to share are only for the currently logged-in users.

As for using the same callback, there is an example given in the hook_menu() documentation.

  function mymodule_menu() {
    $items['abc/def'] = array(
      'page callback' => 'mymodule_abc_view',
    );
    return $items;
  }

  function mymodule_abc_view($ghi = 0, $jkl = '') {
    // ...
  }

The menu callback would be used for http://example.com/abc/def, http://example.com/abc/def/222, and http://example.com/abc/def/333/aaaa. In the first case, $ghi and $jkl would get their default value; in the second case, only $ikl would get its default value; in the last case, none of the variables would get their default values.

That is true also for the form builder, with the exception that the first two arguments would be $form, and &$form_state.


How to grant "edit any file" permission only to files attached to a certain node type?

Maybe I've found a workaround.

Files editing is accessible in a general direct way (bypassing their nodes) by the following url:

www.mysite.com/file/[fid]/edit

So only through this link a Moderator can have access and edit ANY file (please tell me if this is correct).

So, doing:

/**
 * Implementation of hook_menu_alter()
 */
function helper_menu_alter(&$items) {
  // Provide custom access callback for direct files edit url
  $items['file/%file/edit']['access callback'] = 'helper_direct_file_edit_url_access_callback';
}

/**
 * Custom access callback
 */
function helper_direct_file_edit_url_access_callback() {
  // Disallow direct files edit url to everyone but superadmin
  if (!_helper_is_user_superadmin()) {
    return FALSE;
  }
  return TRUE;
}

Moderators with "Edit any file" permission (and everyone in anycase) cannot directly access to edit files, but they can edit files with media module through nodes they have edit access to (e.g. cars)

Do you think guys this could be a good workaround?

There is a better way to accomplish this?

Thank you very much


Composer error installing Address module

The problem seems to be that I had installed a previous version of the Address module in the sites/all/modules directory, which seems to have been confusing Composer. Composer installs into the modules directory, and after deleting the older copy, I was able to run the composer require command without problems.


Display HTML code in a Drupal field as plain text

Looks like you're looking for Code Filter.

  This module provides a simple text format (input filter) that handles <?php ?> and  tags so that users can post code without having to worry about manually escaping < and > characters with &lt; and &gt;.

It is the module used on Drupal.org for escaping markup.


In your hook_menu, create a menu item with 'type' => MENU_CALLBACK, like so:

$items['YOUR_MENU_PATH'] = array(
  'page callback' => 'YOUR_PAGE_CALLBACK',
  ...
  'type' => MENU_CALLBACK,
);

Then, in your page callback function, you can use the drupal_json_output($some_array) function to convert $some_array to json, and return it, all in one go.

I wouldn't use the .php extension in the menu path.


Custom Module Separate Settings for Each User

You need to create module with .install file that would help you to create custom table where you can store individual user API key. I am sharing with you some code to achieve this. It should be something like that. Rest your code will be same you just need to make some minor changes like use return $form instead of return system_settings_form(). You also need to write hook_form_submit() function.

Module Name: custom
1. custom.install

/**
 * Implements hook_install().
 */
function custom_install() {
    // Create tables.
    drupal_install_schema('custom_table');
}

/**
 * Implements hook_uninstall().
 */
function custom_uninstall() {
    // Drop tables.
    drupal_uninstall_schema('custom_table');
}

/**
 * Implements hook_schema().
 */
function custom_schema() {
  $schema = array();
    $schema['custom_table'] = array(
        'description' => 'Stored user api key',
        'fields' => array(
          'id' => array(
            'type' => 'serial',
            'not null' => TRUE,
            'description' => 'Primary Key: Unique ID.',
          ),
          'api_key' => array(
            'type' => 'varchar',
            'length' => 256,
            'default' => '',
            'not null' => TRUE,
            'description' => 'Store api key',
          ),
        ),
    'primary key' => array('id'),
  );
  return $schema;
}

custom.module

/* Submit hook function for submission form. */
function custom_form_submit($form, &$form_state) {
  // insert your api key in your custom table using db_insert() function or you can use db_merge() for both insert/update operation.
}


Generate classname from variable in template

Valid CSS identifiers (for example, element names, classes, and IDs in selectors) cannot start with a digit, or a hyphen followed by a digit. Html::cleanCssIdentifier(), which is called when a CSS identifier is created from a string, contains the following code.
  // Valid characters in a CSS identifier are:
  // - the hyphen (U+002D)
  // - a-z (U+0030 - U+0039)
  // - A-Z (U+0041 - U+005A)
  // - the underscore (U+005F)
  // - 0-9 (U+0061 - U+007A)
  // - ISO 10646 characters U+00A1 and higher
  // We strip out any character not in the above list.
  $identifier = preg_replace('/[^\\x{002D}\\x{0030}-\\x{0039}\\x{0041}-\\x{005A}\\x{005F}\\x{0061}-\\x{007A}\\x{00A1}-\\x{FFFF}]/u', '', $identifier);

  // Identifiers cannot start with a digit, two hyphens, or a hyphen followed by a digit.
  $identifier = preg_replace([
    '/^[0-9]/',
    '/^(-[0-9])|^(--)/',
  ], [
    '_',
    '__',
  ], $identifier);

As a digit is only replaced when it's the first character, or the second character when the first character is a hyphen, it's enough to  first concatenate a string that is an acceptable CSS identifier, as in the following code.
{% if title %}
  {%
    set classes = [
      'views-group',
      ('group-' ~ title)|clean_class,
    ]
  %}
  <h3{{ content_attributes.addClass(classes) }}>{{ title }}</h3>
{% endif %}
{% for row in rows %}
  {%
    set row_classes = [
      default_row_class ? 'views-row',
    ]
  %}
  <div{{ row.attributes.addClass(row_classes) }}>
    {{- row.content -}}
  </div>
{% endfor %}

The only difference with the code shown in the question is using ('group-' ~ title)|clean_class, instead of 'group-' ~ title|clean_class. The parentheses are necessary because | takes precedence over ~.
That is the only change needed to avoid that the first digit in the node title is replaced with an underscore. There is no need to change the code to add a single CSS class instead of two CSS classes.


How to display menu link language in List Link view of menu?

You're looking at making significant changes to the form builder menu_overview_form (e.g. via hook_form_alter()) or perhaps a complete replacement at the menu route admin/structure/menu/manage/%menu handler (e.g. hook_menu_alter()) in menu_menu().

Looking at the form builder shows the scope of the problem, it is making DB query that you'll need to augment with relevant logic for combining with language column. In addition, there is helper function, _menu_overview_tree_form() that builds out the form elements that is coupled with the $tree structure that's coupled with the result of DB query.

Given that, it might be easier for you to replace the route handler with your own custom form than trying to hack around the existing form. You certainly don't want to start hacking menu.admin.inc as your question implies.


In Rules, there is a simple action that will allow you access to a user's content profile information.  In your rule, select "Add an action" and choose Load Content Profile:

On the next page, first choose which user to load (ex. logged in user, acting user, content author, etc). This depends on what Event you chose for the rule. Next choose which profile content type you want to load and click "Save".

Now, other actions you add after the first step (loading the content profile) will have access to the fields of the user's content profile. If you have the Token module installed, settings for new actions should have a fieldset titled Token replacement patterns. Expand that fieldset and you should see another fieldset titled Replacement patterns for Content Profile.  Expand that one to see all content profile tokens that can be used however you like.  Ex:


Taxonomy view page for double nested terms

Show only grandchild nodes on Taxonomy term pages

In more words: Add nodes to Taxonomy term pages that are tagged with terms that reference the term shown on that page. This means that nodes that directly reference the TID will not be shown. Instead, we show nodes that have an additional Taxonomy link in between, a sort of grandchild connection.

We first introduce the "parent" connection (in your case it's "Architecture" from field_key_data). Then through it we bring in grandparent "Style" information from field_style. Since we want to show nodes that relate to that TID through that "lineage" we simply use Term ID Contextual filter with the "grandparent" Relationship.

Clone (Duplicate) the default Taxonomy term View (which is of Content type). It already has one Contextual filter (Has Taxonomy Term ID) that is responsible for showing all nodes tagged with that term. Remove it, we don't want parents, we're only interested in grandparent.
Add a Relationship Taxonomy term referenced from field_key_data.
Add another Relationship Taxonomy term referenced from field_style, it will use the first Relationship.
Add a new Contextual Filter Term ID, make it use the second Relationship, and configure it:
When the filter value is NOT available
Provide default value
Taxonomy term ID from URL
Load default filter from term page
When the filter value IS available or a default is provided
Specify validation criteria
Taxonomy term ID
Style (or whatever in your case)
Under Query settings choose Distinct because you'll see duplicated results because Relationships introduce many connections so to prevent it Distinct only shows each node once.

No need for Contextual OR BTW, we only have one Contextual filter anyway :)

BTW you can "require" both Relationships since this entire scheme relies on existence of grandchildren.


Drupal 7 custom block.tpl.php for specific region

To use a custom tpl.php file for "navigation" region, you should use region--navigation.tpl.php


How do I show only the latest post from each user in a view?

The problem is that you are trying to filter based on two things:

Show the most recent content by an individual user.
Show each user.

In Views, you can generally only filter one kind of entity (content OR users) at a time.

However, there is a module that can help, Views Field View.  This module lets you embed one view inside another.

So, you can do something like this:

Create a view that shows the most recent content for a single user (takes a contextual filter of UID, returns one result, sorted by descending most recent).
Create another view that shows all users except the logged in user.  Use Views Field View module to embed the first view and show the most recent post by each user.

I haven't done this exact implementation before, but I've used Views Field View for similar things.  There is a tutorial here.

If you use this module, do note this warning from the documentation:

  Please note that using this module can impact the performance of your
  site, if the views being rendered are very resource-consuming. It's
  highly recommended to use this module in conjunction with other
  modules that provide views caching.

  Good candidates to cache your views are the modules Views content
  cache and Cache Actions.


Transferring default user picture field to new user picture field

I think the easiest way would be to do it at the database level. Copy the old field contents into the new field.


How do I use an entity reference field as a sidebar navigation on a view?

Yes. Doing this with content types is really no different than with taxonomies. You can leverage the reference value with a Views relationship.
You description sounds like it would use two Views, one for the block of navigational links in the sidebar, and the other for the lists of projects.

For the first you just want a view of the categories. I'd use fields and rewrite the output to link to each category title to a url like /projects/{{category_title}}. "Rewrite output" is an option available in the modal for the field. Alternatively, and perhaps more straightforward is to use the option to "output as a link."

The second page display View is based on the project type, and has a relationship to the category. Create a contextual filter to pull the category title from the URL, matching whatever you set up in the block.


Please check on the Webform's hooks list Webform Module Hooks here. These hooks are associated with each webform activities.


Add "Post as anonymous" checkbox to forum topic creation

https://www.drupal.org/project/forum_cloakpost
This module allows registered users to post to a forum as an anonymous user, via a checkbox on the add node/comment page.


add_where() causes the view not to be displayed

It was a problem with accessing the global variables. In the end, I got it working with the following function:

function iamru_keyword_filter_views_query_alter(&$view, &$query) {

        $q1 = $GLOBALS["_POST"]["q1"];
        $q3 = $GLOBALS["_POST"]["q3"];

        if ($view->name == 'iamru_prepared_statement') {
            $query->add_table('field_data_field_keyword');
            $query->add_where(1,'field_data_field_keyword.field_keyword_value',  $q1, '=' );
        }

        if ($view->name == 'iamru_word_for_you_view') {
            $query->add_table('field_data_field_keyword');
            $query->add_where(1,'field_data_field_keyword.field_keyword_value',  $q3, '=' );
        }

    }


How can I do a cascading Entity Reference data entry or is it even possible?

I've not used it yet myself. But, if you want an out of the box solution you can try the Hierarchial Select module:

  This module defines the "hierarchical_select" form element, which is a
  greatly enhanced way for letting the user select items in a hierarchy.

  Hierarchical Select has the ability to save the entire lineage of a
  selection or only the "deepest" selection. You can configure it to
  force the user to make a selection as deep as possible in the tree, or
  allow the user to select an item anywhere in the tree. Levels can be
  labeled, you can configure limit the number of items that can be
  selected, configure a title for the dropbox, choose a site-wide
  animation delay, and so on. You can even create new items and levels
  through Hierarchical Select!

See the project page for a Demo page.

Depending on how complex your criteria is you could also consider the #states Form API of Drupal 7, or a simple jquery Ajax callback on your select tags in the form.


which version is this cache_set function belong to?

That looks like the D6 cache_set().

Pressflow versions are API compatible with the Drupal versions. So if your site is D5, you should use Pressflow 5.

Mixing up Drupal 5 and Drupal 6 code is a recipe for disaster. So if you are doing this stop. Pressflow 5 cache.inc includes this...

function cache_set($cid, $table = 'cache', $data, $expire = CACHE_PERMANENT, $headers = array()) {
  $headers = serialize($headers);
  $created = $_SERVER['REQUEST_TIME'];
  db_query("UPDATE {". $table. "} SET data = %b, created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $data, $created, $expire, $headers, $cid);
  if (!db_affected_rows()) {
    @db_query("INSERT INTO {". $table. "} (cid, data, created, expire, headers) VALUES ('%s', %b, %d, %d, '%s')", $cid, $data, $created, $expire, $headers);
  }
}

This is probably what you should use.


Seems that's the problem with the cache table. If you're running localhost. Just drop the existing cache table and recreate it.
Following is the query to create 'cache' table for drupal 7

CREATE TABLE `cache` (
 `cid` varchar(255) NOT NULL DEFAULT '' COMMENT 'Primary Key: Unique cache ID.',
 `data` longblob COMMENT 'A collection of data to cache.',
 `expire` int(11) NOT NULL DEFAULT '0' COMMENT 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
 `created` int(11) NOT NULL DEFAULT '0' COMMENT 'A Unix timestamp indicating when the cache entry was created.',
 `serialized` smallint(6) NOT NULL DEFAULT '0' COMMENT 'A flag to indicate whether content is serialized (1) or not (0).',
 PRIMARY KEY (`cid`),
 KEY `expire` (`expire`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Generic cache table for caching things not separated out...'


How to configure D7 so files get uploaded to a different server

I do something very similar.  If you're running infrastructure that is capable of this configuration, I recommend serving up a share on your file server (Linux or Windows Server) and just mount it in Drupal's public file path, wherever the public directory is for that particular field.

For example, take the following Samba configuration (found in /etc/samba/smb.conf if you run a Linux-based file server).  This comes at the very end of the file after all other configuration options:

[data]
    comment = Data directory
    browseable = yes
    writable = yes
    valid users = "@DOMAIN\Domain Admins"
    path = /data
    create mask = 0664
    force create mode = 0664

The valid users syntax there says "allows this group of users" to access this share.  In this case we're using PAM to hook up our file server to Active Directory, and this particular group is made available once you hook the two up.

On your web server, whatever is hosting your Drupal site, navigate to the public files directory.  Say the particular field you need to make the files available for is public://field_with_20k_files/.  You'd run a similar mount command like so:

sudo mount -t cifs -o user=domainadministrator,uid=domainadministrator,gid=apache //fileserver/data /path/to/field_with_20k_files

I have the gid set to whatever process is running the web server so it has access to that directory.  Most likely you'll want to ensure that the web service has read and write access to the web server is actually capable of uploading files.


One of the biggest changes at the architecture level of Drupal 7 is the introduction of entities as an abstraction for content. The old days of trying to cram everything in nodes is over. In short, you get all of the convenience of nodes without the overhead and unnecessary code (and in your case, the architectural challenge of "hiding" nodes from users, crawlers).

Drupal Commerce uses them for products. This allows the products themselves to be inaccessible to end users, but attached to the product displays and views for the end user to see and purchase.

Utilize the Entity Construction Kit (ECK). It will give you a nice UI to create your entities and then just use views to display them for the end-user.


Drupal custom Fullcalendar breaks jQuery version > 1.8

I have located the problem, sharing to whom it might concern.

Apparently there was a conflict between the contrib admin_menu rc4 version and jQuery, causing the fullcalendar to fail.

After upgrading the admin_menu to rc5, (latest release), all was fine.


Views Display output in tpl file not working

While not a direct answer, the best thing I've found to do in cases like these is to put a

<?php drupal_set_message('<pre>' . print_r($rows, TRUE) . '</pre>'); ?>

in the template to see what you have to work with.  But if you are talking about the Display template, I am pretty sure by that point the $rows variable has been populated with HTML so you may need to look at another template if you want to get fancier with the output.


How do I change the order of the Views row fields programmatically?

Go with one of Views API hooks, e.g: hook_views_pre_render

You can access Views rows by $views->result.


In D6, $node->taxonomy is an array of term objects keyed by the term id, eg:

  [145] => stdClass Object
    (
        [tid] => 145
        [vid] => 5
        [name] => nineohfour
        [description] =>
        [weight] => 0
    )

  [147] => stdClass Object
    (
        [tid] => 147
        [vid] => 5
        [name] => anotherterm
        [description] =>
        [weight] => 0
    )

Just put a drupal_set_message('<pre>' . print_r($node->taxonomy,true) . '</pre>'); in your template to take a closer look.  You can then go through that array with a foreach (or in_array)to find if a term is set and then act upon that.  I would do this in a _preprocess_node() hook though and set a variable to act upon in your node template instead of putting all that php logic in it.


As per documentation, there is a method just for that: ->isNull()

$query->isNull('myfield');
// Results in (myfield IS NULL)
$query->isNotNull('myfield');
// Results in (myfield IS NOT NULL)


navbar was enable. I disable it and the hambuger menu was gone.
Thanks for your help.


Get the css files , or compile the less ones , and copy them to your theme css folder , then modify your theme .info file so drupal can see the new css files


Override a node template and its associated translation

You can create a content type for the translations and use that content-type node template. node--CONTENTTYPENAME.tpl.php.
so you don't need to update it one by one with the node ID.


Lightbox2 image formatter in view not adding click event

Create a view and do settings as per the screenshot below.

Choose Formatter as described below for content:image

Now you will have thumbnail image of the style "timelinr" and when clicked it will come up with image style "timelinr-modal".
I tested above and it is working.


Add another item button goes missing with unlimited, repeating dates

This is not an issue. According to documentation found here - https://www.drupal.org/node/295239

  If the Date Repeat API is enabled, you will see 'repeating' as an alternative to allowing 'unlimited' multiple values.


There is a patch for the '?q' URL problem which occurs using openlayers-7.x-2.0-beta1, apply the openlayers-fix-marker-lang-path-1404912-3.patch (http://drupal.org/node/1404912) it should fix this for you.


Is there a list of default fields and default widgets for drupal 7

To get a list of all field definitions use field_info_fields()

Returns all field definitions.
Use of this function should be avoided when possible, since it loads and statically caches a potentially large array of information. Use field_info_field_map() instead.

You can ignore the second paragraph of that as field_info_field_map() hasn't actually been included in a Drupal release yet.
For widgets use field_info_widget_types()

Returns information about field widgets from hook_field_widget_info().


Drupal 6 clean urls without domain name (accessing via IP Address)

Clean URLs is not dependent on domain names it is disabled because your server doesnt support it. You need to enable mod_rewrite module in apache to get that option enabled.
Check out the server configuration section here.


Short of support directly in Drush, this is what I would recommend.

Keep your site in a structure something like this:

srv
. www
. . mysite.com
. . . .git
. . . custom-htaccess
. . . custom-robots.txt
. . . htdocs
. . . . .htaccess
. . . . robots.txt
. . . . ... other files in the Drupal root

I like to structure my Drupal files as shown above so that I have a place to keep files in the same git repository as my Drupal files without exposing them to the webserver (or worrying about hiding them from the webserver with custom .htaccess rules).

If you keep all of your customizations to .htaccess and robots.txt in separate files like this, it would be an easy thing to concatenate them on the end of the corresponding Drupal core files.  This structure might be a good starting point for a formal Drush feature that does the same thing.

Update: If you are not on shared hosting, you'll do much better to store your .htaccess customization on the Apache vhost conf file, and leave Drupal's .htaccess file unmodified. The syntax of this file is about the same as the .htaccess file. The first step is to find the right file; it's often in /etc/apache2/vhost.d or /etc/httpd/vhost.d, although on Debian distros such as Ubuntu it is in /etc/apache2/sites-available. Apache configuration is not a Drupal-specific topic; there's a lot of info about it available on the Internet.


I think what you're looking for is in this section: https://www.drupal.org/docs/theming-drupal/twig-in-drupal/twig-template-naming-conventions#s-views
Specifically,

views-view-field.html.twig based patterns are postfixed with the
view's field id (as in replacement patterns) to display a single field
in a view:

views-view-field--[viewid]--[view-display-id]--[fieldid].html.twig
views-view-field--[viewid]--page--[fieldid].html.twig
views-view-field--block--[fieldid].html.twig
views-view-field--[fieldid].html.twig
views-view-field.html.twig


How to replace the Secondary menu title with the current Username?

I think you can simply do this by making change in page.tpl.php file.

Just replace,

'text' => t('Secondary menu'),

with,

'text' => t($user->name),

save and clear cache.

Image-1: Before changing code (I have deleted line 'class' => array('element-invisible'), so text can be visible)

Image-2: After change,

Final code,

<?php if ($secondary_menu): ?>
      <div id="secondary-menu" class="navigation">
        <?php print theme('links__system_secondary_menu', array(
          'links' => $secondary_menu,
          'attributes' => array(
            'id' => 'secondary-menu-links',
            'class' => array('links', 'inline', 'clearfix'),
          ),
          'heading' => array(
            //'text' => t('Secondary menu'),
            'text' => t($user->name),
            'level' => 'h2',
            //'class' => array('element-invisible'),
          ),
        )); ?>
      </div> <!-- /#secondary-menu -->
    <?php endif; ?>


Webform for Drupal 8 allows you to give a role (or specific user) access to view and update submissions of a SPECIFIC webform to accomplish what you need

Goto Settings > Access of the webform in question and assign VIEW ANY SUBMISSIONS and  UPDATE ANY SUBMISSIONS to your Trusted user role

Than you have to give this user the URL to view and edit/update all the submissions.  For example for the contact form they should visit /admin/structure/webform/manage/CONTACT/results/submissions and they would be able to see all submissions and edit them.


You can render individual fields from the variation, setting up a relationship in the View Advanced Section: Product uses variations.

After the relationship is set, then you can select what fields you need to display, filter or order the view results.


Alter entity.user.canonical (/user/{uid}) route

There are at least two ways you could pursue to do what you're trying to achieve:

You can alter routes using a RouteSubscriber.
Listen for a event (likely KernelEvents::REQUEST), and respond appropriately.

The RouteSubscriber is probably a bit hard to do (I haven't written one yet, I just discovered their existence the other day), but is more in keeping with the older hook_menu_alter patterns from previous versions of Drupal.

The EventSubscriber is probably easier to write once you understand the event system (which requires some learning but is where lots of the future of Drupal internals is headed).


Using migrate, how can you set the default format to Full HTML?

In Drupal 6, when you import with the Migrate and Table Wizard modules there is a text field when mapping each field that is empty. Just type in full_html and each node when imported with have full_html entered into that row in the database.


creating a view showing nodes referenced from the currently selected node

Reverse Node References is indead a good solution as it should provide what your are asking for. It's documentation describe how to use for that exact purpose: query children nodes referencing a parent node matching a filter.

Another solution is the Node Referrer module which will create a auto-populated fields on the parent content type with references to all the nodes referencing it. You can then build a view using this field to create a relationship to the children nodes.


This is how Drupal Title system works.

You PageTitle| Sitename

If you wants any modification then you can install Metatag and Token Module.


Catch the English name of a translated taxonomy term (token)

Decipher's blog suggested the answer: I initially created a custom module to define a custom token to use in FileField Paths, and then I installed Custom Tokens module, and created same token as before.

Both methods worked, and at the end I'll use second method (installing Custom Tokens module, without my custom module), as it will be easier to create other tokens when needed.

Method 1:

/**
 * Implements hook_token_info().
 * gw_content_area_en is the token used as [node:gw_content_area_en]
 */
function MODULENAME_token_info() {

    $info['tokens']['node']['gw_content_area_en'] = array(
      'name' => t('Gw Content Area EN'),
      'description' => t('English version of field_gw_content_area'),
    );

    // Return associative array of tokens & token types
    return $info;

}

/**
 * Implements hook_tokens().
 */
function MODULENAME_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();

  // Check if token type is node
  if($type == 'node'){
    foreach ($tokens as $name => $original) {
      switch ($name) {
        // Check token is gw_content_area_en
        case 'gw_content_area_en':
          $tid = $data['node']->field_gw_content_area[LANGUAGE_NONE][0]['target_id'];
          $term = taxonomy_term_load($tid);
          $replacements[$original] = $term->name_original;
          break;
      }
    }
  }
  return $replacements;
}

Method 2:

Install Custom Tokens module;
Create a new token with following settings:

Token name: Gw Content Area EN
Token description: English version of field_gw_content_area
Token type: Nodes
Content:

$tid = $data['node']->field_gw_content_area[LANGUAGE_NONE][0]['target_id'];

$term = taxonomy_term_load($tid);

return $term->name_original;

New custom token used to set FileField Path.

Note: i18n_taxonomy module disabled.


Multiple Values in Custom Template Field

Slice the array?

foreach(array_slice($content['field_publications'], 0, 5) as $field_publication):


Everything you need is in the email message headers array.

$params['headers'] = array(
    'Bcc' => 'bcc_email@example.com',
    'Cc' => 'cc_email@example.com',
);

Here is an example implementation of drupal_mail() with bcc headers included.

$params = array(
    'body' => $body,
    'subject' => $subject,
    'headers' => array(
        'Bcc' => $header_bcc,
        'Cc' => $header_cc
    )
);

$email = drupal_mail('ModuleName', 'message_key', $to, LANGUAGE_NONE, $params, $from, true);

Using hook_mail() you need to add (thank you @clive):

/**
 * Implements hook_mail().
 */
function ModuleName_mail($key, &$message, $params) {
    switch ($key) {
        case 'message_key':
            $message['headers'] += $params['headers'];
    }
}


Problem installing Drupal 6.22 with Drush

I had a similar problem when trying to install Drupal 6.26 with drush 4.5 and 5.0 (I tried both).

You do not have to create the database.  You can but drush will drop it and re-create it.

I fixed my problem by doing :

drush site-install default --db-url=mysql://drupaldbuser:REMOVED@localhost/drupal-6-25

I used the profile default rather than standard since drupal 6.x uses default as the default profile.  The standard profile is the new default name in Drupal 7.

http://drupal.org/node/1410242#comment-5795114
http://knol.google.com/k/how-to-install-drupal-with-drush


how to check files/images which are more than 400 KB

You can try direct SQL query

select fid, filename from file_managed where filemime like 'image/%' and filesize > 400000;


Commerce Kickstart is a 'canned' solution, so you're limited by what's been 'hard-coded' already. This is fine, you just need to make some leaps of faith to use their product for your purposes.

You can't use the hierarchical structure of 'indented' sub categories of a Drupal taxonomy as an expected subcategory in Commerce Kickstart. It just doesn't understand it (yet). Unfortunately, you can only use a single level of category for each taxonomy category term. In Kickstart 2 - that's called the 'Collection' taxonomy. So don't add subcategories there and expect them to be shown. In some ways, this saves you some headaches.

You need to make a separate (again, single level of depth) taxonomy term for subcategory. You also need to set it to be a taxonomy of product classification (the checkbox thing in the Edit of the taxonomy).

With both separate, single level of depth, taxonomies, you then need to add these term reference selection boxes to your 'Product Variation' (and NOT Content Type).

You then need to put your brand, set up the same way as the other two, mentioned above, in your 'Content Type' (NOT product variation).

You then need to set up all of your Display Views, in both Content Type (CT) and Product Variations (PV). Look at the 'Tops' CT/PV set up to match that setup for guidance.

In this way, the 'All Products' view will work to allow you to filter by all terms of category, subcategory, and brand... or what ever other classification you can think up.


How to get the calculated sell price for the current user?

Find the tips:
Add this to the array return by my_price_formatters_field_formatter_info() :

'settings' => array(
    'calculation' => TRUE,
  ),

Like this:

/**
 * Implements hook_field_formatter_info().
 */
function my_price_formatters_field_formatter_info() {
    return array(
    'commerce_price_for_me' => array(
      'label' => 'Price my way',
      'field types' => array('commerce_price'),
      'settings' => array(
        'calculation' => TRUE,
      ),
    ),
  );
}

Then add this function:

/**
 * Implements hook_field_formatter_settings_form().
 */
function my_price_formatters_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $element = array();

  switch($display['type']) {
    case 'commerce_price_for_me':
      $element['calculation'] = array(
        '#type' => 'checkbox',
        '#value' => TRUE,
        '#title' => t('Show calculated price'),
        '#default_value' => empty($settings['calculation']) ? 'TRUE' : $settings['calculation'],
      );
      break;
  }
  return $element;
}

And this one too:

/**
 * Implements hook_field_formatter_settings_summary().
 */
function my_price_formatters_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $summary = array();

  switch ($display['type']) {
    case 'commerce_price_for_me':
      if ($settings['calculation'] == TRUE){
        $summary[] = 'Show calculated price.';
      } else {
        $summary[] = 'Show base price.';
      }
    break;
  }
  return implode('<br />', $summary);
}

Then amount (in $items or $entity) will be the calculated price.

And that's all folks.


Is the form running through drupal_get_form? This type of error can occur when using the generic render() fuction on a form that hasn't been prepared by drupal_get_form(). Check your hook_menu settings and make sure your page callback is set to drupal_get_form() with the form id as the page arguments(encapsulated in an array)

if you must use a custom page callback, make sure that you're piping the form based output through drupal_get_form() like so...

$output = drupal_get_form('form_id');


What would the snippet(s) look like for multiple google analytics tracking IDs?

Using Universal Google Analytics, in the Google Analytics Module 7.x-2.0 @ /admin/config/system/googleanalytics > ADVANCED SETTINGS > CUSTOM JAVASCRIPT CODE > Code snippet (after)

ga('create', 'UA-XXXXXXXX-Y', 'auto', {'name': 'foo'});
ga(function(foo) {
  foo.send('pageview');
});
ga('create', 'UA-XXXXXXXX-Y', 'auto', {'name': 'bar'});
ga(function(bar) {
  bar.send('pageview');
});


Taxonomy terms as arguments to an entity-reference view

Entity reference autofill may help you. Here is a quote about it (from its project page):

  ... gives Entity reference fields an option to populate other form fields with data from selected referenced entities.


A big thank to @No Sssweat  for the answer. My methodology was good, I done an error in the definition of the direction.

So, you need to include the core/jquery.ui.effects.slide in your libraries.yml file and follow this documentation http://api.jqueryui.com/slide-effect/.


How to hide authoring information on webform for Drupal 7

The author/date display is controlled in the edit form for the Webform content type, at http://mysite.com/admin/structure/types/manage/webform.

The checkbox you're looking for is here:


Poll Listing, Where admin can rate and user and rate a poll?

You could use the Advanced Poll Module.

Advanced Poll is a replacement to Drupal's poll module and provides multiple voting systems, decision-making tools, and management options.

For more details you could go through the README.txt of this module.


hook or similiar to automatically send any webform submissions to an email address, without manually adding a handler to each existing webform?

I am going to go ahead and say No, there isn't any hook or otherwise automated way to do this.

I looked at hook_entity_insert(), as leymaxx suggested. From looking at the Webform Submission entity at /src/Entity/WebformSubmission.php, it appeared to me that the Webform Submission entity is not what triggers the emails and handlers of the webform, but rather the Webform entity does.

Looking further at the Webform entity at /src/Entity/WebformSubmission.php, I found functions for invoking handlers, but these only appeared to loop through existing handlers already attached to the Webform entity. So, there is no way to call an arbitrary handler on a webform.

What I'm going to do is create a custom handler, attach it manually to existing webforms, and use this recipe that I referenced in my question to have it automatically attached to new webforms as they are created.

Edit We are using config_export on our site, which has yamls for all of our current webforms. Because of this, I was able to copy and paste the additional email handler into the yaml, and do a config import, to update existing webforms. This saved some time over manually editing them in the web interface.


Enable the "sticky" option within publishing options for 5 of your nodes. Then create a view (using the Views module) and for this view, within the "Sort criteria" of it, make sure to add  "Node: Sticky" as your primary sort criterium (using the Views UI).

When adding this sort criterium to your view, you'll also see "...To list sticky nodes first, set this to descending." (which is what you seem to be looking for).

To finish enter a path for the Views result, and use this path to set it as your frontpage.


how to bring Core forum discussion with comment on front page

You can create views of type Forum topic. and put the views page on your sites front page.

navigate to [your-site]/admin/config/system/site-information  change the default front page to your views page link.


Language fallback for unpublished translation

I never used it, but this module seems correspond to your problem https://www.drupal.org/project/multilink


I have managed to solve this problem, and I'm posting my own answer here in hopes that it will help someone else struggling with this.

First, when creating a Display Suite Custom Layout, follow the directions here: [https://www.drupal.org/node/1098068][1]

Then, if you are defining custom regions like I am, the trick is to create custom regions in your Drupal theme. To do this, go to sites/all/themes and enter the folder containing your theme. Then find your theme's .info file.

This should be where the regions in your theme are stored and created. To set up the regions that will work with the php code listed above, enter:

your_region_name = [name_of_custom_region]

I created 7 regions this way. For example, my first region is named:

introduction = [introduction]

This may be slightly different given how your theme is set to define regions, but this is what worked for me. I entered my new regions after the pre-existing Content region defined in the theme. (I have no idea if that makes a difference, but that is what worked for me.)

After you have defined the regions, insert and alter the php code from the question above in your Display Suite tpl.php file. (The link in the first step shows you how to define this file.)

You will then change some of the php code to reflect your custom regions. For example, if you defined your first region as "introduction" the code should look like this:

    <<?php print $introduction_wrapper ?> class="introduction<?php print $introduction_classes; ?>">
    <?php print $introduction; ?>
  </<?php print $introduction_wrapper ?>>

You will then need to alter the code each time, entering the next region name that you defined in the .info file in order.

Lastly, you will need to update your Display Suite custom layout .inc file.
I did this by defining each newly created custom region that I wanted to show up on the custom layout within Drupal. As an example, my code looked like this in the end:

    <?php
function ds_ds_bamboo () {
  return array(
    'label' => t('Bamboo DS'),
    'regions' => array(

    'articletitle' => t('Article Title'),
        'titleimage' => t('Title Image'),
    'introduction' => t('Introduction'),
    'entry1' => t('Entry 1'),
    'entry2' => t('Entry 2'),
    'entry3' => t('Entry 3'),
    'author' => t('Author Bio'),
          ),
    // Add this line if there is a default css file.
    'css' => TRUE,
      );
}

Doing this will create row-like regions that will allow you to neatly group Drupal fields together, giving you a template for future content.

As an example, my "entry1" region contains an image field, text field, another optional image field and text field, as well as a video embed field. Due to the structure of the code and Display Suite's field management, all of the fields and their content are kept nice and tidy within the custom region.

I hope this helps if you're struggling with defining custom layouts in Display Suite!


Will Migrating Content Between Sites Preserve CKEditor Styles?

Yes, as long as you keep your database integrity when migrating.

CKEditor basically adds HTML tags and attributes to your data, which are saved in your fields' tables in the database. So, for example, if you have a body field that contains  text formatted like "Hello, body", and take a look at your field_data_body table, you will see something like this:

Hello, body...


Date Repeat: Display only the first and last instances of a series?

This is an old question, but I thought I'd put in my two cents.

The only way I can think to accomplish this is with custom PHP and a call to the database. You could collect all of the dates for an event an then just show the first and last. The name of the repeat rule is saved in the field_date_rrule column and could be parsed from there.


Use Ajax to load full node including comments and comment form

This modules contains a lot of extra code for your case and probably make too much unnecessary actions. You should to make a little script to make jQuery.ajax that make request, insert your node with comments in  and connect it to your theme. This modules made request by Query.ajax too.

Less code - faster action and may the force be with you.


Views doesn't use typed arguments as it doesn't understand them anyway. Why do you need that to work? You can just load it where you need it? And if you have code that relies on that being an object then that code is wrong and will also fail on node/N/revisions for example.

What might work is defining such a page with page_manager, that will allow to define the right type.. but on the other hand, page manager does not yet support defining local tasks.


Translation of BlockBase (ConfigurablePluginInterface)

The key was in creating mymodule.schema.yml in mymodule/config/schema/mymodule.schema.yml

with content of a kind

block.settings.myblock:
  type: block_settings
  mapping:
    Heading:
      type: text
      label: 'Heading'
      translatable: true

also

$config = $this->getConfiguration();

is not needed
using

$this->configuration['heading']

insted

\core\modules\system\src\Plugin\Block\SystemBrandingBlock.php -- is a good example


Node feedback module offers a check box on the node form asking the author to allow the visitors of the node to send feedback/request for the node using the personal/site wide contact form. It is also possible to view URL from which node, for that you have set token. See the below image, possible to set available fields token.

For Drupal 6:

Author Contact shows a contact form that contacts the author of the current node.
You can set the tokens for title to show in email as well as in fields. I am using this in my website see the Interested in this Property


db_select query for given sql query with equi join

You can built any type of select query using db_select, you can see in detail on following url
https://api.drupal.org/api/drupal/includes!database!database.inc/function/db_select/7.x


That should be there. Make sure that you add a relationship to the user/author of the nodes that you are displaying, that might be the missing piece.

Note that this is the only available views integration as of now. Privatemsg and it's group of submodules rely heavily on dynamic queries and being able to alter them. That and the rather complex queries which can't be replaced by Views easily.


There are two ways of doing this:

Using Modal Frame API
Using CTools

I've used both to successfully create modal popups with embedded forms. In both cases I first needed to create the form using Drupals form api and then assign an event for either MFA or ctools to bind to.

Overall I found MFA easier to get something up and running but ultimately ctools is more powerful and will give you a better understanding of a module that is now used widely throughout contrib modules.

Both modules documentation is the best place to start, MFA has great documentation pages and ctools has some excellent sample modules in the project itself.


How/where is the marker layer added to the Google Map with the Gmap Module?

So, I got the answer from reddit.com/r/javascript. All the map settings are stored in the drupal.settings js variable, you can access it from the console in drupal.settings.gmap.auto1map.markers


I'm inclined to believe this is a MIME type (or Content Type) configuration issue on the server because the "X-Content-Type-Options nosniff" would bypass this kind of problem.  That header is telling Internet Explorer to not extract MIME type info from the server response.

IE is very unforgiving these days (since IE 10 or so) with respect to the MIME type reported by the server. If your server is reporting that Jpegs are text or pngs, for example, Internet Explorer will fail to render it even if the extension is a well-known extension like "jpg."

Adding/Correcting MIME Types in Apache

You have many different ways to fix your server's reported mime type.

.htaccess (overrides server configuration)

If you're stuck with just editing your .htaccess file, add AddType image/jpeg jpeg jpg jpe to it in order to override whatever is happening with the server.

mime.types or httpd.conf (actually fixing the server configuration)

If you have full access to your server, try to locate the "mime.types" file on your server (assuming it exists) or add the "AddType" line to your httpd.conf file if jpegs aren't defined anywhere.  It's possible that the "jpg" extension or "jpeg" MIME type already exists in one of these files and is just not correctly configured.

A restart of Apache will make sure config changes are in place when you see if the problem is fixed, too.

See also

If this problem persists, there is also another question in Stack Overflow at: https://stackoverflow.com/questions/27934411/images-failing-to-load-in-ie-with-dom-7009-error-unable-to-decode-in-console that has many alternative causes.


Drupal unexpected "Fatal error: Class name must be a valid object or a string [...] common.inc" on every page

The error means that Drupal can't find the entity type information for a entity that it tries to load.

Add var_dump($entity_type); in there and reload the page. The last one that it's going to print (if there are multiple) is the culprit. What you need to do then depends on the entity type. It could for example be that you disabled a module which is still being called.


The fields option is generally faster, because it performs only 1 database query (2 if there's a pager in use).  The teaser display requires a node_load(), which causes numerous hooks to fire and many more queries.


The Features module has its own tests that verify that the operations done on a feature (e.g. adding or reverting it) as successful. Drupal already has tests to verify that for example, users with the right permission can read/write/update a node, or that a Drupal variable is effectively saved. The Views module should have its own tests to verify that exporting/importing a views is done correctly.

Apart from those tests, you should not have any reason to write tests for the Feature module, as the existing tests should already covers any possibility. The only case I would write a test for a feature is when the feature is using custom code you wrote.


Store only a resized version of an enormous uploaded image

Yes, that functionality is in Drupal core as default.

In Image field settings (your Content type -> Manage fields) set for Maximum image resolution to 800x800px. Drupal will resize image size and save only resized version of it.


Filter to only nodes with an image in an imagefield

If you filter by one of the image field's subfields (e.g. fid, delta, language, width, height, etc), you may end up with duplicate rows in the results, which is usually not desirable. To avoid that, just filter by the "image_field_name:delta" field instead, setting the Operator to "Is equal to" 0. That should filter out all rows without images, and without creating duplicates.


How can I use the Comment field as a way to privately message the node author?

I see some potential pitfalls with this approach:

It probably won't be quite as simple as you describe because I guess you'd also like commenters to be able to see their comments, and replies to their comments, while hiding other people's comments. (Or am I wrong?)
You mention you'd like to allow anon users to comment, so you need some way to differentiate one anon user from another (if they're able to see their own comments, but not others).
It won't play nicely with page caching (at least without a bit of effort).
It might make life a bit more difficult if you want to have normal comments on a content type at some point. (Eg. should the comment moderation tools be showing comments which are actually private messages?)

If you do want to go down this route however you can use hook_node_view_alter().


Link Taxonomy with Node via Feeds, Entity Reference and Views

OK so I decided to scrap the Taxonomy Vocabulary and use new Content Types instead.

Haven't been able to figure out a good way to link multiple Taxonomy Vocabularies to Content Types via importing in Feeds and using Entity Reference with Views.


Omega override simple-layout.tpl.php for content types

So, I was able to accomplish this using the following:

tl;dr: Create another layout extension, and use theme_omega_layout_alter(&$layout) to switch.  That's the preprocess function I had to track down.

(assuming use of included layout *simple-layout* and you want to create a layout for node type plain-page [the naming convention doesn't matter])

Copy themes/_your-theme_/layouts/simple to themes/_your-theme_/layouts/plain.
Modify the file names:

simple.layout.inc -> plain.layout.inc
simple-layout.tpl.php -> plain-layout.tpl.php

Modify plain.layout.inc (It's just like a .info file for a theme, self-explanatory)
Modify plain-layout.tpl.php to suit your needs (In my case, I need to remove everything except render($page['content']).
Open themes/_your-theme_/template.php and add theme_omega_layout_alter(&$layout):

// this is specific to my use case
// change 'theme' to your theme name, as you would with any
// preprocess function
function theme_omega_layout_alter(&$layout) {
  $cPath = current_path();
  if (strpos($cPath, 'invite-print') !== 0) {
    $layout = 'plain';
  }
}

The following is only necessary if you want to change parent structure (<html>, <head>, etc.), which I needed to

Open themes/_your-theme_/preprocess/html.preprocess.inc and put this in:

 // this is specific to my use case
 // change 'theme' to your theme name, as you would with any
 // preprocess function
 function theme_preprocess_html(&$variables) {
   $cPath = current_path();
   if (strpos($cPath, 'invite-print') !== 0) {
     $variables['theme_hook_suggestions'][] = 'html__plain_page';
   }
 }

Create /themes/_your-theme_/templates/html--plain-page.tpl.php and modify as necessary.

It felt like overkill for my situation (having to create entire new layouts) but I understand why it was done - it's crazy powerful for sites that need to make drastically different layouts for different pages.  Think different regions, stylesheets, js, etc - completely different .info files, essentially.

Hope this helps someone!


Service module costume response after creating node

You have following hook to do the response modifications,

function hook_services_request_postprocess_alter($controller, $args, &$result) {

}


Drupal Form Ajax not updating form on first click

Try changing the button type to "submit", and specifying a custom submit handler:

$form['info']['ticket']['subscribe'] = [
    '#type' => 'submit',
    '#submit' => [['ticket_submit_handler']]
    '#ajax' => [
        'callback' => 'ticket_ajax_callback',
        'wrapper' => 'ticket-info-form',
    ],

    // ...
];

In the submit handler:

Change any variables in form_state storage that need to persist.
Tell the form to rebuild itself (instead of doing a redirect after submission), in order to keep the form state.
Do other stuff.

e.g.

function ticket_submit_handler(&$form, &$form_state) {
    $form_state['storage'][] = ;
    $form_state['rebuild'] = TRUE;
    // ...
}

In the AJAX callback:

Return the part of the form that will replace the 'wrapper'. In your case, it seems to be the entire form.
Don't do anything else here.

e.g.

function ticket_ajax_callback(&$form, &$form_state) {
    return $form;
}

AFAIK, when the user clicks your AJAX button, the following functions will run, in order:

Form validation (if any).
ticket_submit_handler
Form builder, to rebuild the entire form, even if we only need a part.
ticket_ajax_callback, which returns a part of the form, which is sent to the browser.

For more information, see the example code in the Drupal 7 documentation.


on a multi-language site 'Entity translation' prefs don't show 'node' option

I just recently had this problem and after 6 hours of searching for a solution I tried the following, which seems to work for me:

Without having Entity Translation installed first update Internationalization (i18n) to the latest version. Then setup the necessary submodules like "Field translation" that you need from Internationalization.

After this is all done then download and enable Entity Translation, go to Entity Translation settings under /admin/config/regional/entity_translation and enable "Content" under "Translatable Entity Types".

If you haven't configure any of your content types to be translatable with field translation (under publishing options) you won't see anything here.
So after doing this for at least one of my content types this page showed the Content tab to add the correct settings for each content type.


How can I theme the Captcha/ReCaptcha error message?

Believe I found a solution.

Since I am using the captcha with Webforms I inserted the below JS to the form and it seems to be working without any drawbacks.

(function ($, Drupal) {
Drupal.behaviors.myModuleBehavior = {
attach: function (context, settings) {
$( "[role=alert]" ).dialog();
}
};
})(jQuery, Drupal);


How do I show or hide a Views block based on a boolean field in the displayed node?

Forget views.

Go to the visibility settings for the block (under /admin/structure/block) and set the Page Visibility to only show on "Pages on which this PHP code returns TRUE".

Then check your boolean field with the following code:

$node  = menu_get_object();

return (isset($node->field_boolean[LANGUAGE_NONE][0]['value'])) ? $node->field_boolean[LANGUAGE_NONE][0]['value'] : FALSE;

Then place the block on the page where you want it.


How to register Field Handler class with Migrate module

From this blog post it looks like you register the field type from within your custom class:
http://openconcept.ca/blog/mmallett/migrating-data-using-drupals-migrate-module

as such:

class MigrateCUSTOMFIELDNAMEFieldHandler extends MigrateFieldHandler {
  public function __construct() {
    $this->registerTypes(array('email'));
  }
// more stuff in your class ...

Without such information migrate usually just silently ignores the field, or try to work with it in any way. The same rule for an improperly named/implemented Migration class -- you just don't see it in drush ms.

EDIT:

From the blog post, actually from MigrateExtras README:

  The Migrate Extras module provides extensions to Migrate
  (http://drupal.org/project/migrate) to support various contributed
  modules. The ideal place to implement migration support for a
  contributed module is in that module. That way, the migration support
  is always self-consistent with the current module implementation -
  it's not practical for the migrate_extras module to keep up with
  changes to all other contrib modules. Support for contributed modules
  may be added to migrate_extras for two reasons - if the module's
  maintainer does not accept a patch providing migration support, or as
  an intermediate step before submitting such a patch to the other
  module.

  In cases where modules supported by migrate_extras end up implementing
  the support themselves, you could at least temporarily end up with
  redundant implementations. The extra implementation may be disabled at
  admin/content/migrate/configure.

Anyway, if you then look at:
http://drupalcode.org/project/migrate_extras.git/blob/9843c3b2c003e8bd19bb370e6eb6b2264f13eca1:/migrate_extras.migrate.inc

They declare their migrate API integration thus:

/*
 * Implementation of hook_migrate_api().
 */
function migrate_extras_migrate_api() {
  $api = array(
    'api' => 2,
    'destination handlers' => array(
      'MigratePathautoHandler',
      'MigrateExtrasNodeFlagHandler',
      'MigrateExtrasUserFlagHandler',
    ),
    'field handlers' => array(
      'MigrateAddressFieldHandler',
      'MigrateCckPhoneHandler',
      'MigrateGeoFieldHandler',
      'MigrateIntervalFieldHandler',
      'MigrateNameHandler',
      'MigrateMediaFieldHandler',
    )
  );
  return $api;
}

You probably want to list your FieldHanlder in a similar fashion (but with your class name). You probably also want to add it to the files[] array of your module so it is autoloaded and Migrate sees it.

Your new FieldHanlder should be listed at admin/content/migrate/configure

... if you read the blog post provided, it explains this oddity of FieldHandlers ...


How to show one field in more than one regions?

You can achieve this using Dynamic fields in Display Suite Module. Check this ans.

Please find the detailed steps below to achieve this:

Navigate to Manage Display page of Content Type and click on "Add a Dynamic Field".

Add Unique Label (e.g. "Duplicate Field") to Field and Select valid Entities (e.g. "Node") based on your requirement.
Click on Save.

This will create a Dynamic Field and Display on Managed Display page of Entities you've selected.
Re-position newly created field (i.e. Duplicate Field) into another region, say as Footer and click on Settings icon as shown in screenshot.

This will open a display settings for this field. Click on Select Content, to select the field you want to display the content of.

From left menu, select Node and then click on Node field (e.g. "Field: Body (body)").

On next screen, change settings based on your requirement for displaying label, display formatter and click on Continue.

Click on Finish

Now you need to tell Display Suite that I've selected field and attached it to Dynamic Field by clicking on Update Button.

This will show a preview of Field Name, you've attached to Dynamic field.

Click on Save of Manage Display Page.


How to create a renewal request from the subscription page?

If I understand your question correctly, you are using the Entity reference module on you subscription content type to point to a (new) node of the type renewal_request.

The Entity connect module extends the Entity reference field by providing an add and edit button:

  The "add a new" button will enable you to add / create a new entity. The first  form will be cached then the new form will be generated. Once the new form is  completed and saved the user will return to the original form.

  The "edit" button will take the user to the edit form of the referenced entity. Once the user is done editing, he is sent back to the previous form.

You could also use the Inline Entity Form module:

  Provides a widget for inline management (creation, modification, removal) of referenced entities.


How to Unit Test Entity Reference Field Value

This is a good example of a test that would probably be better suited as a kernel test rather than a unit test since it's dealing with the Field API which can get tricky to mock, and is probably better to test with the real thing.

To test this as a kernel test you need to ensure the following:

Either create your field field_symbols directly in the test's setUp method or place the field config and storage YAML files in a module's config/install directory, and enable that module for the test.

You'll need to also enable the node module, and any other module's that your code depends on

Then, in your test you can execute the custom code and ensure the expected values are set:

public function testFieldSymbols() {
  $node = $this->createNode();

   // Do this, or retrieve the service if your class is a service.
   $fixture = new ClassIAmTesting();

   $fixture->populateSymbols($node);

   $this->assertEquals('expected field value', $node->field_symbols->target_id);


How to make same javascript code work on more than one same kind of field?

Hmmm, this is a kind of tricky one! Because you want the element corresponding to the button you clicked to be the only one that toggles, correct? Not all of the elements?

I think you want something like this for your code, where everything between [] is replaced with the relevant selector. So [BUTTON CLASS] would become the class that you apply to all the buttons, such as "button", not the ID that only gets applied to a single button ("button1", "button2", and so on). Likewise, [CHILD CLASS] would be replaced with a class that you apply to all elements that you have IDs such as "p1", "p2", etc on.

(function ($) {
  Drupal.behaviors.myfunction = {
    attach: function(context, settings) {
      $( ".[BUTTON CLASS]" ).each(function (index) {
        $(this).click(function() {
          $(this).parent().children(".[CHILD CLASS]").toggle("slow");
        });
      });
    }
  }
})(jQuery);

Hope that helps!

Edit
Updates made to the code to get the button parent and then the #p1 from there. It assumes that the #p1 and the #button1 are both children of the same element.

Edit 2
Given the structure

<button class="button1">Toggle</button>

<button class="button2">Link</button>

Text to be written here

<button class="button1">Toggle</button>

<button class="button2">Link</button>

Text to be written here

<button class="button1">Toggle</button>

<button class="button2">Link</button>

Text to be written here

The following JS does what you want, I believe:

$( ".button1" ).each(function (index) {
  $(this).click(function() {
    $(this).parents('.buttoncontainer').children(".p1").toggle("slow");
  });
});


BigPipe messing up JS, is there a BigPipe ready() equivalent function?

You must not ever rely on document.ready when you write js for drupal. You should use drupal behaviours; If used properly this will ensure that your code runs both on normal page loads and when data is loaded by AJAX (or BigPipe!)

Also read this interesting post on drupal issue queue JS relying on document.ready event does not work with BigPipe


How can I display latest post in another menu tab?

You could use taxonomies.  First, navigate to admin/structure/taxonomy and create a taxonomy with the terms you want to have tabs for (e.g. QUESTIONS, TAGS, USERS, BADGES, UNANSWERED).  Hover over each of the terms in the list terms to discover their default paths.  Let's say you note that "BADGES" has been assigned the path "taxonomy/term/7"

Now, all you need to do is to create an item in your main menu to display tagged articles. So navigate to admin/structure/menus and add the following link to the main menu. Set Menu link title to "BADGES", and Path to "taxonomy/term/7".  Repeat for other taxonomy terms you want to access via a main menu tab.

Now, you have tabs in your main menu called "BADGES", etc.  Under each tab content tagged with its taxonomy term will appear automatically, so to make content show up under the BADGES tab, tag it with "BADGES".  If you're using Drupal 7, the default article content type already has a taxonomy field.  But you can add a taxonomy field to any content type if it is missing.

You can now refine this by customizing how things are listed using Views to create customized listings. You can also hide the numeric paths with the use of URL aliases if you want (so the path appear to the user as badges instead of taxonomy/term/7.)


Where is the configuration actually saved in the system?

Nowhere, most of configuration is located in database including webform.

With config module, you may find webform configuration in admin (yml) : /admin/config/development/configuration/single/export

First, select webform in configuration type, then the configuration you need to export.

NB : have a look at sources https://github.com/drupalprojects/webform/blob/8.x-5.x/src/Entity/Webform.php , most of drupal contributions are built the same way, webform extends ConfigEntityBase and these are typically stored in database (config table as a blob)


Define custom view page template with theme_hook_suggestions

Your approach is fine. The only problem is with the name of the hook suggestion and the equivelant tpl.php file.

Since you are preprocessing views_view the hook suggestion should be named something that starts with views_view ex: views_view__[anything]. Note that all the undersores will be replaced with dashes for the filename. So it should be something like views-view--[anything].tpl.php

For example:

/**
 * Implements hook_preprocess_views_view().
 */
function MYTHEME_preprocess_views_view(&$variables) {
  // Some logic to decide if the hook_suggestions should set or not
  // ...
  $variables['theme_hook_suggestions'][] = 'views_view__foo';
}

And the filename will be views-view--foo.tpl.php


Where in Drupal database do I store additional file properties?

You might want to look into the Media project which provides bundles for files and allows to add fields to them.

Another approach would be to use a module like Field collection which allows you to group a number of fields into a group that you can add as a field to another entity. That field can then have an unlimited amount of values which allows you to attach n fiels + meta information to your node.


How do I use the time function in Views Math expression?

If you are using the Views PHP Field, http://drupal.org/project/views_php, you can enter in custom php field information. I would take the original date variable and subtract the date as of now to get the value you want:

  //Just creating a random freshman grad date

  $graduation_year = (date('Y-m-d', strtotime('+4 year')));

  $now = (date ('Y-m-d', (strtotime('now'))));

  $diff = abs($graduation_year - $now);

Based on the absolute difference in years you can do validation in your views field that validates this information and sets the student as a freshman, sophmore, junior or senior (assuming highschool :) ) based on the $diff value of 1,2,3,4.

That validation would look like:

if ($diff == 1) {
print('Senior');
}
elseif($diff == 2){
print('Junior');
}
elseif($diff == 3){
print('Sophmore');
}
elseif($diff == 4){
print('Freshman');
}

I didn't put exception handling but you get the idea.


how to create next and previous month menu link in calendar in drupal 7

Use Calendar Module.

From project page..

  This module will display any Views date field in calendar formats, including CCK date fields, node created or updated dates, etc. Switch between year, month, and day views. Back and next navigation is provided for all views. Lots of the Calendar functionality comes from the Date module, so any time you update the Calendar module you should be sure you also update to the latest version of the Date module at the same time.

Hope this will help you.


Adding CSS around taxonomy terms in node field

I did this in preprocess_taxonomy_term(), and just added to classes_array.


Add a filter to my view before executing

Another way is to add the filter as an exposed filter in the view and then set it programmatically like this:

// Set created date range filter.
$item = $view->get_item($display_id, 'filter', 'created');
$item['value']['min'] = $settings['min'];
$item['value']['max'] = $settings['max'];
// Disable exposed filter in UI, for programmatic filter.
$item['exposed'] = FALSE;
$view->set_item($display_id, 'filter', 'created', $item);

That should come before $view->pre_execute();

You can also add a completely new filter in a similar way, by building up a valid $item to use with $view->set_item.


Commenting on each paragraph of node body

$contentis defined in node.module in the function template_preprocess_node().
You can add elements to the nodes content using hook_node_view()(D7) or hook_nodeapi() (D6).

See the accepted answer of this question for more details.


How to force Feeds to import content? (Feeds too lazy to import every minute)

Check the minimum refresh period in your feeds setting; feeds will not import anything if the last import is more recent than that setting.


How to create a view mode preview within the display suite module

View modes are a Drupal concept, and layouts (in this context) are specific to Display Suite. Selecting a preview image for a view mode (if it can be done) has got nothing to do with Display Suite. The preview images that Display Suite show is specific to the layouts that it offers.

In Display Suite, you can define your own custom layouts, and there are a few ways of doing so. Some modules add layouts as well. To investigate how a module does that, download Display Suite Bootstrap Layouts and have a look at the files. You will see the module file, wherein the layout is declared as such:

$layouts['bootstrap_12'] = array(
    'label' => t('Bootstrap One Column: 12'),
    'path' => $onecol . '/bootstrap_12',
    'regions' => array(
      'central' => t('Content'),
    ),
    'form' => TRUE,
    'image' => TRUE, // this tells it that there is an image for the layout
  );

Note the key 'image' is set to TRUE to indicate the presence of an layout image, which you will find in the sub folders.

The template files that goes with this declaration is found in layouts -> onecol -> bootstrap_12 -> bootstrap-12.tpl.php and looks like this:

<<?php print $layout_wrapper; print $layout_attributes; ?> class="<?php print $classes; ?>">
  <?php if (isset($title_suffix['contextual_links'])): ?>
    <?php print render($title_suffix['contextual_links']); ?>
  <?php endif; ?>
  <div class="row">
    <<?php print $central_wrapper; ?> class="col-sm-12 <?php print $central_classes; ?>">
      <?php print $central; ?>
    </<?php print $central_wrapper; ?>>
  </div>
</<?php print $layout_wrapper ?>>

<!-- Needed to activate display suite support on forms -->
<?php if (!empty($drupal_render_children)): ?>
  <?php print $drupal_render_children ?>
<?php endif; ?>

Here you can see how the central region defined in the module file is rendered within the template using a naming convention.

You can add layouts to this module directly if you want by following the convention above. But better would be to define them in your own theme folder so that you don't wipe out your changes during an upgrade.

You can do that manually or using drush, and the layout files will live in a subfolder 'ds_layouts' within your theme folder. The process is fully described in Adding custom layouts to your theme. It is really very easy to do, and well worth the effort.

So to come back to your question, in order to associate a preview image with a view mode, you could declare a new layout with a peview image that is used only for a specific view mode, thereby creating a one-to-one relationship between them.


If the problem is simply that orders are being marked "paid in full" while still in checkout and then having their statuses overridden when the checkout completion rules run, why don't you just add a condition to the default checkout completion rules to not change the order status if it's already completed?


How can I tell if I'm on a taxonomy page in preprocess_page?

Unfortunately I don't think there is anything that the hook gives you directly that you can use in this instance. However you can always check the route name to determine if you are on a taxonomy term page.

// Will be "true" if you are currently on a taxonomy term page.
if (\Drupal::routeMatch()->getRouteName() == 'entity.taxonomy_term.canonical') {

  // Since this is a taxonomy term page, you may wish to get the term ID.
  $term_id = \Drupal::routeMatch()->getRawParameter('taxonomy_term');
}


How to create Subtheme of Omega while Omega Tools and Drush both has some disclaimer and Moved to Github?

I'm speculating a bit, but Drush surely moved to github from the project page on d.o because it simply isn't a module. It is:

  a command-line shell and scripting interface for Drupal

So if you're thinking it's a module that needs be installed and enabled in your site, it isn't. It's a separate utility that needs to be installed on your machine.

You're absolutely right to want to stick with getting it installed for working with Omega, it does make life a lot easier. You can do so by following the detailed instructions on the github page.

There are also a bunch of questions in the composer tag that should help if you get stuck.


You should definitely have a look at the Identification module. Some details (from its project page):

... allows users to login with a custom identification number (or string). To configure this module, the site builder creates a (or specifies a pre-existing) field on the user entity. The value stored in this field for a particular user can then be used as the identification login credential.
Use Case
An organization that wants users to be able to login using a custom identification number and password. This means each user account will have three unique identifiers:

core user name
core user e-mail address
custom user identification number (or string)

Credits (and kudos) to tyler frankenstein!
Note: This answer applies to both D7 and D8.


How to use another php version for drush 9?

Try editing both the .bash_rc and .bash_profile files so that you include the directory where the version of PHP you want is FIRST (before existing PATH):

(add this line or adjust if existing):

export PATH="/opt/php70/bin:$PATH"

As a last ditch effort, you can set the env variable drush looks for as well in these files:

DRUSH_PHP=/opt/php70/bin/php


Yes, Boost can do this actually. Here's a video that explains it: http://www.drupalove.com/drupal-video/how-can-boost-help-my-site

Pages which are set to static cache will remain running while in maintenance mode.


This is a method call, the theme method is invoked on the $view->field[$id] object. The method is likely views_handler_field::theme but it may have been overrided by the  views_handler_field subclass used for a particular field handler. Usually, the method will eventually ends up calling the theme() function to use a defined theme function or template for the field (if this is a CCK field, a formatter will likely be used).


Where to modify feed status to change number of created and updated nodes

in feeds.pages.inc, function feeds_source_status() the status information is shown for the importer, including the number of imported items. The number of items is calculated in FeedsProcessor::itemCount() in plugins/FeedsProcessor.inc.

The message of how many entities were created and updated happens in FeedsProcessor::process(). FeedsSource::$state keeps track of these numbers. The case where these numbers might not be accurate is if the same entity is updated multiple times in a single import. Usually, this is caused by a configuration error: the target that is configured as unique appearantly isn't unique in the source.


Views and Panels: Exclude already displayed items from view

If your views are not using pager then its easy just add a contextual filter with the following php code

$offset = 5

However, it is very unlikely. The best path is to use hook_views_pre_view($view)

Something like this

function YOUR-MODULE-NAME-HERE_views_pre_view($view, &$items) // note the '&' here!
{
  global $pager_page_array;

  // if this is our view...
  if ($views->name == "my-view-name"
       // ..and we're on its first page...
       && $pager_page_array[0] == 0 ) {
    $items = array_splice($items, 0, 5); // ...then eat up the first 5 nodes
  }
}


drupal_render() and formBuilder's getForm

There are almost no reasons to manually call drupal_render(), you can use/return render arrays almost anywhere, controllers, blocks and also in twig templates.

If you do $variables['form'] = $your_form;in preprocess, then {{ form }} in your template should just work.


not able to display the real name of the users

Did you try real name module before write your own code?

I did not use 6.x version, but i guess it will be more flexible than your solution.


Remove or hide the submit button on search block in Drupal 7

One of the standard ways to do this would be to use hook_form_alter() and add the attributes to the actions element directly:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'search_block_form') {
    $form['actions']['#attributes']['class'][] = 'element-invisible';
  }
}


Try this code

$.ajax({
    url: Drupal.settings.basePath + 'views/ajax',
    type: 'POST',
    dataType: 'json',
    data: 'view_name=custom_package_form&view_display_id=block_56',
    success: function(response) {
      var output = response[1].data;
      $("#output-venue").html(output);
    },
    error: function(data) {
        alert('An error occured!');
    }
});


is it possible to add a permission to only one user , without creating role for him?

Assuming you're using Ubercart this would be super easy by using hook_order through your own module: http://www.ubercart.org/docs/api/hook_order. I do this exact same thing with one of my other sites.

I can't go into it all, but essentially it flows like:

//make sure the order is complete and payment is received:

function sitetheme_order($op, &$arg1, $arg2) {
{
 // on the final update check this order
 if ($op == 'update' &&
     $arg1->order_status == "payment_received" &&
     $arg2 == "completed")
 {

In order to keep this short I can't include everything, but I have short loop written that loops through the order until it meets a condition like "Tickets". Then, I'll assign a role and do some other stuff. Like:

//If they bought tickets, assign them the role "TicketHolder"
if ($node->type == 'tickets') {
  //I assign some vars, for example the ID of the user role:
   $ticketUser = $node->uid;
   $customerRole = 16;
   //Assign this user the "TickHolder" role after the sale is complete
       $data = array(
       'uid' => $ticketUser,
       'rid' => $customerRole,
        );
   drupal_write_record('users_roles', $data);

That would be it. In your case you check to see if they purchased rights to create blog content, then assign the role.


How to add payment method field to the footer of an order summary view?

Why is it? Fields are meant to go in the fields section and not in the footer.

An easy workaround solution is to create an attachment view contenting only the field in question and attach it after your current view.

To do this, in your view, click on +Add and select attachment.

Then you should have a cloned copy of your original view. When you add or remove fields make sure you select at top This attachment (override). If you do not do this, your changes will affect all of your views.

In your first/original view: In footer click on Add and select Global: View area. Select your attachment view and check mark the inherit contextual filters box.

  Note: If your first/original view is a Master, when you add the attachment, you will not have the For:
  Display box,  such as in the last picture (on step 3).

  If that is the case, all your views will get an attachment, including the
  attachment. Therefore, you will have to switch to the attachment view and
  select "This attachment (override)" and remove the footer from the attachment.


Problem with swfobject_api or jwplayer module

Your template file should be called page-front.tpl.php, not front-page.tpl.php. Once you've renamed it flush your caches and it will work!


how to create single flag for choosing multiple bookmarks?

This is possible but you need to use the Flag API hooks and the Flag Actions module. Enable the Flag Actions module that comes with the Flag module if you haven't already. You will now have an option under the flag tab on the triggers page to fire off an action based on whenever anyone flags something with your flag.

/admin/structure/trigger/node

None of the actions available will match what you are trying to do but you can create one. In your site module (or create one), you need to just define two functions: the action definition hook, and the function that fires.

For the action definition, you're using hook_action_info() to declare a function

/**
 * Implements hook_action_info().
 */

function YOURMODULE_action_info() {
  return array(
    'MYFLAG_action' => array(
      'label' => t('Action to take after MYFLAG is flagged'),
      'type' => 'node',
      'configurable' => FALSE,
      'triggers' => array('any'),
    ),
  );
}

and then you want to create the function to trigger your taxonomy flag

/**
 * Action function for report action
 *
 * @see action_example_action_info()
 */
function MYFLAG_action(&$entity, $context = array()) {

   // Use the name of the taxonomy flag here
   $MYFLAG = flag_get_flag("name of taxonomy flag");

   // add logic to find your taxonomy_id, probably from the node object available through the $entity variable

   $taxonomy_id = ( SOME OPERATION )

   //execute the flag operation
   $flag->flag('flag', $taxonomy_id);

}

Finally, flush cache and go back to your triggers page to associate the trigger of flagging a node with your new custom action.


Get a contextual filter for a View in Drupal 8

In D8 the settings of a view are stored in a configuration entity. You can load the entity with View::load() or get it from the view executable directly and then load a display and check the contextual filters (stored in the key arguments of the display options):

$storage = $view->storage;
$display = &$storage->getDisplay('default');
$arguments = $display['display_options']['arguments'];

'contextual_filter' => !empty($arguments) ? 1 : 0


I have fixed this issue by using hook_views_data_alter(). Earlier the custom handler for the select field was defined in hook_views_data().