I wrote this THEME_menu_link override to add a destination parameter to login links:

e.g in template.php:

/**
 * THEME_menu_link override
 * Add unique class (mlid) to all menu items.
 * Add destination param to login link
 */
function THEMENAME_menu_link($variables) {

  $element = $variables['element'];
  $sub_menu = '';

  $element['#attributes']['class'][] = 'menu-' . $element['#original_link']['mlid'];

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  // Add destination to login link
  if ($element['#href'] == 'user/login') {
    $status = drupal_get_http_header('status');
    // don't add dest back to 403 etc..
    if(strpos($status, '403') !== FALSE){
      $dest = drupal_get_destination();
    }elseif(strpos($status, '404') !== FALSE){
      $dest = array('destination' => 'home');
    }elseif(strpos($_GET['q'], 'user/register') !== FALSE){
      $dest = array('destination' => 'home');
    }elseif(strpos($_GET['q'], 'user/login') !== FALSE){
      $dest = array('destination' => 'home');
    }elseif(strpos($_GET['q'], 'user/logout') !== FALSE){
      $dest = array('destination' => 'home');
    }else{
      $dest = array('destination' => drupal_get_path_alias());
    }
    $element['#localized_options']['query'] = $dest;
    $element['#attributes']['class'][] = 'login';
  }

  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}


Stop Drupal from redirecting to "Reset Password" on user account activation

Go to: admin/config/people/accounts

Edit: Welcome (no approval required) Email

Replace "[user:one-time-login-url]" with "[user:validate-url]"

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


Workbench Delete or Unpublish Multiple Nodes

I cloned the ie. needs-review view

and added field "views bulk operations: Content", marked a few possible actions,

rearranged the fields so bulk ops are first col as one expects

and that's it.


When user.private_tempstore gets deleted

Private tempstore data isn't deleted when you log out, it is usually deleted after a predefined, fixed amount of time.

If you want data that is deleted on logout, then either store in the session or store it somewhere with a random key that you put into a session (Useful when it is data that is no commonly needed on every request and/or larger than just a simple scalar value)


Gmap Location in views - exposed filter by distance/proximity and post code

It's a bit hard to say for sure but my guess is that you have missed a step when installing the location module.

For post code proximity searching the location module uses a database of postcodes and their coordinates to convert the postcode to the lat/lon coordinates that are then used to calculate whether other locations fall in the request distance.

See installation step 6 in the INSTALL.txt file of the location module.

  (Optional) Import a postal codes database for the countries served by your    website, to support proximity searches and other useful
  features. Postal    code databases may be found in the "databases/"
  sub-directory of the    Location module directory. The files are in
  the format of zipcodes.CC.mysql,    where CC is a two-letter country
  code such as 'us' or 'de'.

  Note: If your site is using table prefixes, you will need to adjust
  for this    manually, by opening the file in a text editor and
  replacing 'zipcodes' with    'prefix_zipcodes' throughout.

  To import the files from the command line, enter the following:

  cd sites/SITENAME/modules/location
   mysql -u username -p database-name < database/zipcodes.us.mysql

Note that this proximity functionality may not work for some countries if the data is not available.


How do I add a Commerce product type to a feature?

As it turns out, product type export is not supported in the core Commerce module.  Instead, you need to install the Commerce Features module.


Render with custom style all contents of a content-type from custom module

If you want to just use the views module.  Set your view to use fields.  Filter by content type and set your display to using HTML List style.  Pickout the fields you want to display (Image, Title).  You can then add your custom javascript through a module or your theme so that it actually runs as a slideshow.

There are other modules that can handle this as well like views_slideshow and owlcarousel.

If you want to keep the code all in your own module, you may want to take a look at this article:

http://www.sitepoint.com/building-drupal-7-module-show-latest-nodes/

It shows you how to create your block, how to query the database, how to use the theme('item_list', $theme_args).  It should be straightforward.


Content Type vs. Taxonomy | Example TV Series

I would do it the A) way and use Entity reference module to "link" episodes to series. That way you can use watever fields you want in your content types (including taxonomy for genre for example).

  The Entity Reference Module is used to relate entities (nodes, terms,
  users, etc...) to one another.

After that, you can display content types with Views showing Series with list of episodes.


Drupal 7: customise archive view to show only blogs from one user

Add a "User" relationship, then just add the corresponding contextual filter. If absolutely necessary, you can set the contextual filter to always use the default value, and set it to be a raw value from the url, and set the number to wherever the username is in the url path.

Example:
url = http://mysite.com/user/USERNAME/blog/archive
raw value from path number = 2 (/user/USERNAME -- it's the second part of the path)


How to use addTranslation() on an entity's multi-value paragraph?

You have to loop over the multi-value field:
foreach ($lang_node->field_images_descriptions as $delta => $item) {
  $item->entity->addTranslation($lang_code, [
    'field_product_description' => $desc[$delta],
  ]);
}

$lang_node->save();


Different CSS files for different browsers

The Conditional Stylesheets module allows themes to easily add conditional stylesheets to a theme's .info file.

This module is already used by the Zen, Layout Studio, and Tendu themes.


Drupal 7 vbo, is there an option to input text to operations?

You can do this with Rules for example, every "Action set" Rules component that you create is exposed to Views Bulk Operations and all the parameters you configure for your action set will be available for use in the view.

I've created a simple view listing all nodes and an action set that exposes the title so you can modify it with a textbox.

Here's the view:

$view = new view();
$view->name = 'vbo_test';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'VBO_Test';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'VBO_Test';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
  'title' => 'title',
  'views_bulk_operations' => 'views_bulk_operations',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
  'title' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'views_bulk_operations' => array(
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
);
/* Field: Content: Bulk operations */
$handler->display->display_options['fields']['views_bulk_operations']['id'] = 'views_bulk_operations';
$handler->display->display_options['fields']['views_bulk_operations']['table'] = 'node';
$handler->display->display_options['fields']['views_bulk_operations']['field'] = 'views_bulk_operations';
$handler->display->display_options['fields']['views_bulk_operations']['label'] = '';
$handler->display->display_options['fields']['views_bulk_operations']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['views_bulk_operations']['vbo']['entity_load_capacity'] = '10';
$handler->display->display_options['fields']['views_bulk_operations']['vbo']['operations'] = array(
  'action::node_assign_owner_action' => array(
    'selected' => 0,
    'use_queue' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::views_bulk_operations_delete_item' => array(
    'selected' => 0,
    'use_queue' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::system_message_action' => array(
    'selected' => 0,
    'use_queue' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::views_bulk_operations_script_action' => array(
    'selected' => 0,
    'use_queue' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::node_make_sticky_action' => array(
    'selected' => 0,
    'use_queue' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::node_make_unsticky_action' => array(
    'selected' => 0,
    'use_queue' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::views_bulk_operations_argument_selector_action' => array(
    'selected' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
    'settings' => array(
      'url' => '',
    ),
  ),
  'action::node_promote_action' => array(
    'selected' => 0,
    'use_queue' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::node_publish_action' => array(
    'selected' => 0,
    'use_queue' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::system_goto_action' => array(
    'selected' => 0,
    'use_queue' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::node_unpromote_action' => array(
    'selected' => 0,
    'use_queue' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::node_save_action' => array(
    'selected' => 0,
    'use_queue' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::system_send_email_action' => array(
    'selected' => 0,
    'use_queue' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::node_unpublish_action' => array(
    'selected' => 0,
    'use_queue' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::node_unpublish_by_keyword_action' => array(
    'selected' => 0,
    'use_queue' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'rules_component::rules_vbo_test' => array(
    'selected' => 1,
    'use_queue' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
);
$handler->display->display_options['fields']['views_bulk_operations']['vbo']['enable_select_all_pages'] = 1;
$handler->display->display_options['fields']['views_bulk_operations']['vbo']['display_type'] = '0';
$handler->display->display_options['fields']['views_bulk_operations']['vbo']['display_result'] = 1;
$handler->display->display_options['fields']['views_bulk_operations']['vbo']['merge_single_action'] = 0;
$handler->display->display_options['fields']['views_bulk_operations']['vbo']['force_single'] = 0;
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'vbo-test';

And here's the action set:

{ "rules_vbo_test" : {
    "LABEL" : "VBO_TEST",
    "PLUGIN" : "action set",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : {
      "node" : { "label" : "Node", "type" : "node" },
      "title" : { "label" : "title", "type" : "text" }
    },
    "ACTION SET" : [ { "data_set" : { "data" : [ "node:title" ], "value" : [ "title" ] } } ]
  }
}

More info can be found in this nodeone screencast: http://nodeone.se/en/using-rules-components-with-vbo

If you need to update the value of a field that is not available in the action set, you can expose "Rule sets" as well to VBO, that allows you to use conditions, particularly the Entity has field condition that will pull the field out of the entity and make it available to Rules UI:

    { "rules_test_rule_set" : {
    "LABEL" : "Test Rule set",
    "PLUGIN" : "rule set",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : {
      "node" : { "label" : "node", "type" : "node" },
      "text" : { "label" : "text", "type" : "text" }
    },
    "RULES" : [
      { "RULE" : {
          "IF" : [
            { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_options" } }
          ],
          "DO" : [
            { "data_set" : { "data" : [ "node:field-options" ], "value" : [ "text" ] } }
          ],
          "LABEL" : "my rule"
        }
      }
    ]
  }
}

You can do this with arbitrary fields based in a data type that rules have info about, what I don't think you can configure is the widget exposed for this operation.


how to put markup around indiviual radio buttons

According to the Forms API matrix you can.  See https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#radio  Have you tried some code to see if it does what you are looking for?

You can set '#options' for the radios to be a variable:

$rads = array(
  0 => '' . t('Yes') . '',
  1 => '' . t('No') . '', );

$form['fldset8']['exp_radios'] = array(
 '#type' => 'radios',
 '#options' => $rads, );


For anyone attempting something similar I ultimately modified the user files module
and used the hook_file_download to only allow group members to download protected content by using the built in is_og_group_member function.


store session variable and access it through javascript?

Accessing a session variable in Drupal is not different from how it is done with plain PHP: with $_SESSION.

As for reading them with JavaScript, it is enough to use code similar to the following one.

// PHP
drupal_add_js(array('myModule' => array('key' => $_SESSION['key'])), 'setting');

// JavaScript
key = Drupal.settings.myModule.key;


How to skip empty and missing values from a migration

It is difficult to help without seeing the structure of your source file (at least 1 sample record). But, here are some pointers:

At first glance, the error message says something about a source plugin exception. I believe the error might be stemming from the source plugin configuration.
The approach you are taking with skip on empty seems to be in the correct direction.
Depending on the data that the field contains, you might have to handle it differently. I usually add the following to debug exactly what is being received by a particular field process. Also, make sure that the value being sent to the migrate_lookup plugin is an array.

# ...
process:
  field_point_of_contact:
    - plugin: callback
      callable: print_r
      source: name
# ...

Have you tried removing the skip on empty part? I don't remember correctly, but migrate lookup might be skipping empty values by itself.
An array with empty strings is not considered empty. If your source provides values like [''], you might have to send the array through an array_filter() to remove empties.

I hope this helps. If it doesn't, you might want to share one row of fake data.


How to grant user points to the product creator after the product is sold?

It is complicated rule.

I can say that you need in rule or maybe in Rule component (I'm not sure) U need also add:

"Calculate a value" action to calculate the points which should be added to user balance.
commerce-price:amount * 0.7
(here will be created some new value. EX.: point_to_plus
After use "Calculate a value" action one more time to sum current points and new.
current points + point_to_plus = final result.

If you use the user points module first load user points.
Some thing like that.
Af course you need to loop over each line item of the order.
I do know how to do it correct.
Maybe some one will help you!
Good luck!


How to register a new PHP function in Twig?

In the docs it says:

  Functions

  To register a new filter you should implement hook_twig_function() and
  return an indexed array with unique keys and new Twig_SimpleFunction
  as value.

function my_module_twig_function(){

To answer your question:

  My simple question is: where should I implement my functions?

Notice how it uses "my_module", so clearly in your custom module .module file is where these function(s) should be added. If you don't have a custom module yet, then you will need to create one.

So if your custom module is named Hello Kitty, then in hello_kitty.module

function hello_kitty_twig_function(){
    $functions = [];
    $functions['coolfunction'] = new Twig_SimpleFunction('coolfunction','hello_kitty_coolfunction');
    return $filters;
}

function hello_kitty_coolfunction($param_1,$param_2...){
    // do what you need to do, and return something.
}


Getting rid of module-specific control logic

If you want to provide Views with your module, dependent on enabled modules, you can implement

hook_views_default_views

  This hook allows modules to provide their own views which can either
  be used as-is or as a "starter" for users to build from.

  This hook should be placed in MODULENAME.views_default.inc and it will
  be auto-loaded. MODULENAME.views_default.inc must be in the directory
  specified by the 'path' key returned by MODULENAME_views_api(), or the
  same directory as the .module file, if 'path' is unspecified.

  The $view->disabled boolean flag indicates whether the View should be
  enabled (FALSE) or disabled (TRUE) by default.

In that hook implementation, you can check if the relevant module is enabled with module_exists or function_exists when defining that View or component of the View and return the View definition(s) accordingly.


Views: if fieldvalue (external link) is set, use it, if not, link to node

There is no direct way of using conditionals inside of Views.  However, you might be able to fake it out with something like this:

Order the fields in your view in nid, external link, title order.
In your external link field, set empty field behavior to node/[nid]
Always use it as the link in the last rewrite.

In my just woke up and enjoying espresso before getting to some real work state of mind, this should do what you are asking for, eg, linking to node/nid if there is no external link, but using it if it exists.


In Drupal 7 you can using

Menu Icons module

  This module allows you to upload an image in the menu-item's configuration form.

Programmatically

Allow images in menu items in Drupal 7 OR Use images for menu items in Drupal

Reference:

Replacing menu items with images


How do I prefill a paragraph field in a node form?

In the form display for that content type you can tell the paragraph field to have a default paragraph selected. So when new nodes are created it will appear there

Then on your actually paragraph you'd need to set the default values for each field it contains (Just by editing those fields on the paragraph and setting the defaults)


To speed up the code, I was hoping that I could store the mysqli-connection object in the cache

It doesn't work like that. For one thing a database connection cannot be serialised (not in any meaningful way at least, as you've discovered). Once the page request is done with, the connection is closed. You can't force it to stay open by maintaining a reference to it, as that physically won't work when you come to accessing the network.

Separately, you should never have any cause to use mysql_connect() in Drupal (or ever if you want to be technical - it was deprecated a long time ago). Drupal's database connection is as optimised as you'll need such a thing to be, so you should just use that.


how to include external php file in drupal 8

I am not sure from your question which phpexcel library you are using, so there are potentially different answers, here is one:

1. On Packagist

If like in the case of mvlabs/mvlabs-phpexcel you would do the following:

on the command line:

composer require mvlabs/mvlabs-phpexcel

Then in the file where you are wanting to use it you can simply add a "Use" statement (as per this answer):

use ExternalPackage\namespace\Foo;

Drupal 8 does an auto-include and is "aware" of all the PHP libraries inside the vendor folder.


Turns out I used the wrong field name. My field is called field_meta_tag instead of field_meta_tags as used in the question above.


Setting a user as an administrator via drush command line?

drush help user-add-role
Add a role to the specified user accounts.

Examples:
 drush user-add-role "power user" 5,user3  Add the "power user" role to the accounts with name, id, or email 5 or user3, uids 2
 --uid=2,3 --name=someguy,somegal          and 3, names someguy and somegal, and email address of billgates@microsoft.com
 --mail=billgates@microsoft.com

Arguments:
 role                                      The name of the role to add
 users                                     (optional) A comma delimited list of uids, user names, or email addresses.

Options:
 --mail=<me@example.com>                   A comma delimited list of user mail addresses of users to operate on.
 --name=<foo>                              A comma delimited list of user names of users to operate on.
 --uid=<3,5>                               A comma delimited list of uids of users to operate on.

Aliases: urol

So, for your use case:

drush user-add-role administrator USERNAME


How do I import blogs from Drupal 6 to 7?

You should use the excellent Migrate module for this. Another quick way to do this, is using the Feeds module, which lets you import data using RSS and a variety of other formats.


How to configure access for creating a custom LMS?

I recommend you have a look at the Group module, which may be considered as a possible alternative to the Organic Groups module, and which you seem to be familiar with already.

Have a look at my answer to "What are the features of the Group module versus Organic Group module?" for details about:

How both modules compare to each other.
Integration with various modules that you might want to take advantage of also.

Resources

Community documentation for the Group module.
Video tutorial "How to use the Group module in Drupal 8 to manage editorial access control to different areas of a web site".
Podcast "Using the Group module as an Alternative to Organic Groups in Drupal 7 and 8".

Sample configuration

Below is an example of a possible configuration, which may help to get you started with possible configurations (using the Group module):

Group type ID ! Group type ! Group role ID ! Role
--------------+------------+---------------+------------
 1            ! Class      ! 3             ! Instructor
 1            ! Class      ! 4             ! Student
 2            ! Customers  ! 5             ! Lead
 2            ! Customers  ! 6             ! Prospect
 2            ! Customers  ! 7             ! Licensed Customer
 2            ! Customers  ! 8             ! Sales
 2            ! Customers  ! 9             ! Support
 2            ! Customers  ! 10            ! Accounting
 2            ! Customers  ! 11            ! R&D
 3            ! Project    ! 12            ! Project Manager
 3            ! Project    ! 13            ! Developer
 3            ! Project    ! 14            ! Customer

Group Types

The above example consists of 3 group types:

Class.
Customers.
Project.

Group Roles

For each of the 3 group types, there are specific Roles defined, some more details about some of them:

for the Class group, these are the 2 roles that are configured:

Instructor.
Student.

for the Project group, these are the 3 roles that are configured:

Project Manager.
Developer.
Customer.

These are the Group Specific Roles: these roles can be configured per group type and will only be available on groups of that group type. As an example, for group type "Class", the defined roles are Instructor and Student (which are not available for the other group types.

On top of the group specific roles, there are also Special Global Roles: These are the special (hardcoded) roles named Outsider (= a signed in user that did not join a group) and Member  (= a signed in user that did join a group). These cannot be defined by the Drupal administrator, and they are always available for any group. These roles can have different permissions sets for each group type. Special case: the role Anonymous is related to a user that is not signed.

Groups

Each of the configured group types can have any number of Groups.

Examples of groups:

for the Class group type, there could be these Groups:

Getting started with Drupal.
Drupal for site builders.
Become an expert in using the Rules module.

for the Customers group type, there could be these Groups:

Service Requests.
Order Processing.
Sales Orders.
Relationship Management.

Permissions

For each of the configured group types, you can then also configure for each Content Type which Role has what kind of access (= none, view, create, edit, delete). Be aware: even though this looks similar to Drupal's permission configuration, these permissions are not the same permissions (they are specific to the Group module).

PS: this answer applies to either D7 or D8.


Gmap Views - Proximity filter for user locations based off of a specific node location

This is really a Views question. You can specify a Relationship and a Contextual Filter under the Advanced tab in Views.

I don't know the specifics for Gmap Views, but the principle is the same: You'd make a view of users, with a contextual filter of content:NID. Then you'd create a relationship to nodes based on the location. Gmap Views might give you a way to say 'within x miles of'... This is Views' way of creating a JOIN query.

Then on your content you'd add a Viewfield and tell it to pass the NID to the view. This will attach the view to your node and generate the view of users nearby.

Helpful tutorial about relationships here. Start at about 1:00 if you're impatient. :-)


How to disable default extension validation in Drupal's #managed_file Form API element?

The answer comes from the following code used by file_save_upload().

  if (isset($validators['file_validate_extensions'])) {
    if (isset($validators['file_validate_extensions'][0])) {
      // Build the list of non-munged extensions if the caller provided them.
      $extensions = $validators['file_validate_extensions'][0];
    }
    else {
      // If 'file_validate_extensions' is set and the list is empty then the
      // caller wants to allow any extension. In this case we have to remove the
      // validator or else it will reject all extensions.
      unset($validators['file_validate_extensions']);
    }
  }
  else {
    // No validator was provided, so add one using the default list.
    // Build a default non-munged safe list for file_munge_filename().
    $extensions = 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp';
    $validators['file_validate_extensions'] = array();
    $validators['file_validate_extensions'][0] = $extensions;
  }

In your case you should use the following array.

  'DownloadFile' => array(
    '#upload_validators' => array(
      'file_validate_extensions' => array(),
      'file_validate_size' => array(variable_get('mymodule_image_size', 2 * 1024 * 1024)),
    ),
  );

In that way $validators['file_validate_extensions'] is set, but $validators['file_validate_extensions'][0] is not. As result, the code will not set $extensions, and the following code will not be executed either.

  if (!empty($extensions)) {
    // Munge the filename to protect against possible malicious extension hiding
    // within an unknown file type (ie: filename.html.foo).
    $file->filename = file_munge_filename($file->filename, $extensions);
  }

The code has a strange way to check if the list is empty; it assumes the array is empty of there isn't an item with index equal to 0.
I would have rather used the following one, which would not make assumptions about the lower array index being used.

  if (isset($validators['file_validate_extensions'])) {
    if (empty($validators['file_validate_extensions'])) {
      // If 'file_validate_extensions' is set and the list is empty then the
      // caller wants to allow any extension. In this case we have to remove the
      // validator or else it will reject all extensions.
      unset($validators['file_validate_extensions']);
    }
    else {
      // Build the list of non-munged extensions if the caller provided them.
      $extensions = array_shift($validators['file_validate_extensions']);
    }
  }


Language switcher with country code and title

You have to copy and paste the entire theme_links function and rename it like
you did mytheme_links__locale_block

function theme_links__locale_block($vars) {
  $links = $vars['links'];
  $attributes = $vars['attributes'];
  $heading = $vars['heading'];
  global $language_url;
  $output = '';

  if (count($links) > 0) {
    // Treat the heading first if it is present to prepend it to the
    // list of links.
    if (!empty($heading)) {
      if (is_string($heading)) {
        // Prepare the array that will be used when the passed heading
        // is a string.
        $heading = array(
          'text' => $heading,
          // Set the default level of the heading.
          'level' => 'h2',
        );
      }
      $output .= '<' . $heading['level'];
      if (!empty($heading['class'])) {
        $output .= drupal_attributes(array('class' => $heading['class']));
      }
      $output .= '>' . check_plain($heading['text']) . '</' . $heading['level'] . '>';
    }

    $output .= '
';

    $num_links = count($links);
    $i = 1;

    foreach ($links as $key => $link) {
      $class = array($key);

      // Add first, last and active classes to the list of links to help out themers.
      if ($i == 1) {
        $class[] = 'first';
      }
      if ($i == $num_links) {
        $class[] = 'last';
      }
      if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
         && (empty($link['language']) || $link['language']->language == $language_url->language)) {
        $class[] = 'active';
      }
      $output .= '
 $class)) . '>';

      if (isset($link['href'])) {
        // Pass in $link as $options, they share the same keys.
        $output .= '
';
        // This will give the native name of the lang like 'Français'
        $output .= l($link['language']->native, $link['href'], $link);
        // This will give the name of the lang like 'French' if the website is in English
        // $output .= l($link['language']->name, $link['href'], $link);
        $output .= '
';
        $output .= '
';
        $output .= l($link['title'], $link['href'], $link);
        $output .= '
';
      }
      elseif (!empty($link['title'])) {
        // Some links are actually not links, but we wrap these in  for adding title and class attributes.
        if (empty($link['html'])) {
          $link['title'] = check_plain($link['title']);
        }
        $span_attributes = '';
        if (isset($link['attributes'])) {
          $span_attributes = drupal_attributes($link['attributes']);
        }
        $output .= '
';
        // This will give the native name of the lang like 'Français'
        $output .= '' . $link['language']->native . '';
        // This will give the name of the lang like 'French' if the website is in English
        // $output .= '' . $link['language']->name . '';
        $output .= '
';
        $output .= '
';
        $output .= '' . $link['title'] . '';
        $output .= '
';
      }

      $i++;
      $output .= "
\n";
    }

    $output .= '
';
  }

  return $output;
}

Inside the code you will find the version for mobile and desktop with class added.

    $output .= '
';
    // This will give the native name of the lang like 'Français'
    $output .= l($link['language']->native, $link['href'], $link);
    // This will give the name of the lang like 'French' if the website is in English
    // $output .= l($link['language']->name, $link['href'], $link);
    $output .= '
';
    $output .= '
';
    $output .= l($link['language']->language, $link['href'], $link);
    $output .= '
';

Then you'll have to hide the link (display:none;) in CSS depending on the resolution of you screen (with media queries)


The problem is in your flood_control.settings.yml.

flood_control:
  user_failed_login_ip_limit: 50
  ...

This way, to get user_failed_login_ip_limit you must use $this->config(flood_control.settings)->get('flood_control.user_failed_login_ip_limit'). Or just remove flood_control: on first line for better use.


Views programmatically remove node access (tag)

Found it:
MYMODULE_query_node_access_alter().

$query->condition contains al de realm conditions, these can be adjusted here.


You've got several issues here:

PHP runs on the server, JavaScript runs on the client's browser so they don't know about eachothers variables.
You're not doing anything with your $.get(..) results, you need to do something with the results of the ajax get request in a success or complete callback.
You're calling a URL to a full page, i'm assuming you want just the image.

If your image names follow the naming convention I see where the thumbnails use /230x130/ in the path and the larger image uses /imba/ instead, then use the code below instead of your current click event:

slideShowIndex = 0;

$('#big-image-slider img.imagecache-imba').load(function(){
  hideSlideLoader();
});

$('.small-images a').click(function(sender){
  sender.preventDefault();
  showSlideLoader();
  var lnk = $(this);
  slideShowIndex = $('.small-images a').index(lnk);
  var imgUrl = lnk.find('img').attr('src').replace('/230x130/','/imba/');
  $('#big-image-slider img.imagecache-imba').attr('src', imgUrl);
  return false;
});

function showSlideLoader() {
  //$('#big-image-slider').html('')
  var loader = $('#big-image-slider .loader');
  if(!loader.length) {
    console.log('creating loader');
    loader = $('')
    $('#big-image-slider').append(loader);
  }
  $('#big-image-slider .imagecache-imba').hide();
  loader.show();
}

function hideSlideLoader() {
  $('#big-image-slider .loader').hide();
  $('#big-image-slider .imagecache-imba').show();

}

$('.left-arrow').click(function(){
  if(slideShowIndex > 0) {
    moveSlideIndex(slideShowIndex--);
  }
});

$('.right-arrow').click(function(){
  if(slideShowIndex < ($('.small-images a').length - 1)) {
    moveSlideIndex(slideShowIndex++);
  }
});

function moveSlideIndex(index) {
  $('.small-images a:eq(' + slideShowIndex + ')').click();
}


How do I add a link to a menu from a module in Drupal 6?

You are using a wildcard in the path node/%node/jobs. If you want Drupal to show a menu link, you have to tell it how to figure out the %node argument. You can do it with a function named node_to_arg.

The function name, actually, is [wildcard]_to_arg. I suggest you change the wildcard to something different, since there are several menu paths with %node in it. If you relied on node_load to return you a node object, you can just call it from [wildcard]_load.

There is documentation on [wildcard]_to_arg and you can see how user_uid_optional_to_arg implements it for the user/%user_uid_optional path.


Our official migration path lives in Commerce Migrate and contains migrations for Commerce 1.x, Ubercart 2.x (D6) and Ubercart 3.x (D7). Improvements are released monthly.


Display the method of payment of an order on the invoice pdf comerce billy

You can use code below to get the payment method of an order by passing order id to the function. The order id on Commerce billy template file can be easily found in this variable $content['commerce_customer_billing']['#object']->order_id and some other variables as well:

$order_id = $content['commerce_customer_billing']['#object']->order_id;

$payment_method = '';
$order = commerce_order_load($order_id);
$r = explode('|', $order->data['payment_method']);

if (count($r) > 1){
  $rule = rules_config_load($r[1]);
  $payment_method = $rule->label;
}

After using this function, you can print the payment method on your bill by printing $payment_method variable.


What could stop a component appearing on the front end?

In this instance it was an error in the component's render function

gallery_grid_render($subtype, $conf, $args, $contexts) {

where it was returning the information to the block.

$block->content = theme('this_name_was_wrong', $tpl_vars);


Drupal 6 as a call logging system - question about node performance & scalability

This is quite a subjective question. Your best bet would be to ask on some of the Drupal groups that handle this stuff like Drupal High Performance.

There are so many factors in making a drupal site scale it's hard to list them all.

Pressflow is a drupal distro that is built for scaling, they also have some great blog articles on scaling.


If the code in myid_inputting() and myid_printing() is different and large, you might want to keep these callbacks separate. I generally avoid having too many lines in one file, so whenever it's possible to logically organize the code of your module into files, it's better to do so.

Regarding the code that is redundant: I always have a separate file with helper functions where I store functions that need to be shared. Include this file at the top of the .module file, and you're all set. You can see an example in my D7 module boilerplate on Github.

Here's how you would include the helpers file (this would go at the top of the .module file):

// Load the helper functions.
require_once dirname(__FILE__) . '/YOUR_MODULE.helpers.inc';

Back to your case - leave different code in separate files, make helper functions for the rest and move it to YOUR_MODULE.helpers.inc. This works great for very large modules as well, and is self explanatory when more people are working with you on a project.

Hope this helps.


Display Suite label below field, instead of above or inline

theoretically you should create a custom field template file overriding the default one.

If you're using Display Suite Extra

1) On DS field settings select "Drupal default" as field template

2) Override the field template following the standard drupal suggestions (see below)

Unfortunately this will not work due to a bug: http://drupal.org/node/1885480

Instead if you're not using Display suite, you'll be able to override the field template without any problem.

Override a field template is quite easy:

1) copy the "field.tpl.php" from /modules/field/theme directory and paste it on your theme directory.

2) rename the file following the rules documented on this page: http://drupal.org/node/1089656

3) change the field-???.tpl.php content moving the label below the field content like:

<div class="<?php print $classes; ?>"<?php print $attributes; ?>>
  <div class="field-items"<?php print $content_attributes; ?>>
    <?php foreach ($items as $delta => $item): ?>
      <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?>

    <?php endforeach; ?>

  <?php if (!$label_hidden): ?>
    <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;

  <?php endif; ?>


How do I migrate to a existing taxonomy reference field?

I've rewritten my yml to use:

field_special:
  plugin: iterator
  source: field_special
  process:
    target_id: tid

And written a preparerow function in my class to output an array as source property:

  /**
   * {@inheritdoc}
   */
  public function prepareRow(Row $row) {
    $nid = $row->getSourceProperty('nid');

    $result = $this->getDatabase()->query(
      'SELECT
        GROUP_CONCAT(field_special_tid) as tids
      FROM
        {field_data_field_special} fs
      WHERE
        fs.entity_id = :nid
      ',
      array(':nid' => $nid)
    );
    foreach ($result as $record) {
      if (!is_null($record->tids)) {
        $row->setSourceProperty('special', explode(',', $record->tids));
      }
    }
    return parent::prepareRow($row);
  }

This workaround will do for now, but if you have a better answer please post so I can accept your answer.


Use hook_form_alter to hook into the form and programmatically insert the captcha element or adjust the weight of the element or pur the element inside the fieldset.

function example_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'YOUR_FORM_ID') {
    // 1. Put the captcha element inside the fieldset

    // OR

    // 2. Associate the capthca element to the form
    //$form['captcha'] = array(
    //'#type' => 'captcha',
    //'#captcha_type' => 'image_captcha/Image',
    //);

    // OR

    // 3. Adjust the #weight attribute in the form
  }
}

References

FORM API

How to add a CAPTCHA programmatically

If you need more details please let me have the $form variable in txt format.


Custom Entity - use taxonomy fields in views

You didn't say that you wanted to do this programmatically, so I'll give you the answer for doing it in the UI. Since you have defined the field game_category as an entity_reference, you can add a relationship in your view to Taxonomy. See Add a relationship to a view for an example.

Then, any field in Taxonomy will be available in your view, including the name. Since this is built into the Views UI by default, you do not need any of your getViewsData() custom code.


Where do I edit the HTML surrounding a field's output?

In Drupal, you don't edit any file belonging to a module/theme you didn't create.

Rather, in your case, you use the hooks Drupal makes available to change the output a module or a theme creates with a theme hook.
In the case of an image field created with the field API, the theme hook that outputs the HTML for the image field when it is rendered on page is theme_image_formatter(). What you need to do is overriding that theme hook in a module or in the theme you use for the site.

Since you don't need to totally change the output from that theme hook, you just need to implement hook_preprocess_image_formatter(&$variables) and add your attribute to $variables['item']['attributes'].

Keep in mind that hook_preprocess_image_formatter(&$variables) is invoked for every image field used by Drupal, so you need to be sure you are altering the output of the right image field.

As per implementing hook_preprocess_image_style(), this hook is not necessarily called for an image field, since theme_image_formatter() contains the following code.

  if ($variables['image_style']) {
    $image['style_name'] = $variables['image_style'];
    $output = theme('image_style', $image);
  }
  else {
    $output = theme('image', $image);
  }

It is just invoked when the image field uses an image style. Plus, it would be invoked every time an image style is used, which doesn't necessarily mean when a image field is rendered on a page.

Similar problem there is with hook_preprocess_field(), which would invoked every time a field is rendered with theme('field').


One exposed filter with different values in one view

you can use views autocomplete filters, add all fields you wish in the view, including the ones with a relationship (can be: contentypes, commerce products and commerce line itmes with propper relationships), then on add an exposed filter choose: Global: Combine fields filter, and on filter settings select all fields you wish to filter on, like the image below. This wokrs on D7 & D8. Enjoy.


Depending on what level of access your users have the ElFinder module is capable compressing and making a directory available for download.

What directory are you allowing your users to download?  Be extra careful that they cannot download critical files like /sites/default/settings.php!


Show Webform Confirmation message in popup window

Without doing any coding to achieve this you could use a module like Purr Messages and then adjust the style of it's output with CSS, this would apply to all system messages though..

Otherwise like zerocoolhotone mentioned, the simple dialog is an effective way of achieving this too.

Regarding your second question, it's a bug/issue with webform, if memory serves me right you can use the development snapshot to overcome it temporarily until they roll it out.


Pasting into CKEditor creates divs instead of paragraphs

I believe this problem is unique to the Chrome browser, i.e. when pasting text directly into the WYSIWYG you get divs instead of paragraphs. In Firefox, for instance, you get paragraphs instead.

One workaround is to use the "Paste as plain text" or "Paste from Word" buttons. This should give you paragraphs instead of div tags.

You could also click the "Source" button and paste the text, then when clicking "Source" again the text should be converted into HTML with paragraphs.


You can force the buttons to submit normally by unbinding the javascript events using something like this in a form alter:

// Disable ajax upload for file field
drupal_add_js("jQuery(function() { jQuery('#edit-field-image :submit').unbind(); });", 'inline');

It would be nice if there was a way to not have the javascript bound in the first place by manipulating the $form (or something else).


How do I remove the "Request New Password" link?

The No Request New Password module is probably the easiest way to go, though you'll need to dig for the 6.x releases. This disables any request to user/password, so this path with neither be accessible directly nor display in menus/tabs/links.

Alternatively, you can put its main function into your own custom module:

 /**
  * Implementation of hook_menu_alter().
  */

 function MYMODULE_menu_alter(&$callback) {
     $callback['user/password'] = array('access arguments' => array(FALSE));
 }


Confused about Owl carousel with Paragraph

You have to separate between two components:
A) Markup generated on server-side by Drupal, which is used as base structure for Owl carousel.
B) Markup modified by Owl in the client's browser.

Drupal render's something like

  {% for item in paragraph.field_client_image %}

  {% endfor %}

The code above is not really depending or specific for Owl carousel.

The thing transforms it to a carousel is a JS call similar to

$(document).ready(function(){
  $(".partners").owlCarousel();
});

somewhere else in a JS file of your theme or a module. This is the "magic" that transforms the server-rendered HTML to something like your screenshot is showing (adding additional
s, classes and styles)


How can I have a node with the URL /themes

In your .htaccess file, the URL re-write has the a code to point the path to the respective folder, if present.. you can change that!


Print a text if a view result is equal to a certain value

If I understand well your question, I guess that you can make this in a rough way from a template View. Inside this template file you can add the respective conditional to show your text.

Here is the part of views-view-unformatted.tpl.php when each result is printed:

<?php foreach ($rows as $id => $row): ?>
  <div class="<?php print $classes[$id]; ?>">
    <?php print $row; ?>
  </div>
<?php endforeach; ?>

Then, you can parse $row to catch the respective value and print a message. You can use preg_match() to match the value For example, instead of <?php print $row; ?> you could use:

<?php
  if (preg_match("/(here text to match)/i", $row)) {
    print "Aha!:" . $row;
  }
  else {
    print $row;
  }
?>

I guess you can improve this seeking per target fields.


How to edit Drupal core rdf.module functionality

You can add the following preprocess function to template.php in your custom theme. The RDF module is preprocessing the variables used by the theme_username() function. Your custom theme can also preprocess these same variables and override the values set by the RDF module.

/*
 * Implements THEME_preprocess_HOOK().
 */
function YOURTHEMENAME_preprocess_username(&$variables) {
  $variables['attributes_array']['xml:lang'] = 'en';
}


User subscriptions using Webform and Rules

I eventually solved this by using the Flag module and doing everything as suggested in this tutorial.


In my opinion it's not necessary to add the relationship. When you have added the presenters in the Meeting node by use the node reference. You can just add the Presenters field (node reference field) in the Field section of the view without using relationship. Because the node reference is already taking care of the relationship part.

Does this help in any way?
Let me know.


Translating "Content: Link" in a Drupal 7 View

I won't didn't put this as an answer as it may not be exactly what you want, the Translation Table module will let you set translations for arbitrary strings in the system.

Since Views is almost definitely going to pass the 'Read more...' string through the t() function that module will make your translation work for as many languages as you like across the site


How to add custom submit logic to search_block_form?

You can do this in hook_search_preprocess():

  Preprocess text for search.

  This hook is called to preprocess both the text added to the search
  index and the keywords users have submitted for searching. The same
  processing needs to be applied to both so that searches will find
  matches.

This is not part of the preprocess in theming. This hook is called directly from the search module. Btw. German umlauts are already replaced by default.


How to stop a Views block from displaying to administrators, such as user/1?

Below is an answer to what I think this question is really about, i.e. "I would like to not see it. Is there a way to stop it from displaying to admins?". And to make the challenge a bit tougher, not for a user with role "Administrator", but assuming "... you are talking of the user with ID equal to 1 ...".

My short answer to it is "Yes you can" ... read on for more details ...

Part 1: Rules block visibility

You should be able to get this to work using the Rules block visibility module. Here is a quote from its project page:

  The Rules block visibility module allows Rules components to be used to control block visibility. This provides Drupal administrators and developers extreme flexibility in controlling when blocks should be displayed on their websites, in addition to the default visibility options provided by Drupal.

  The general idea is that if you can do it with Rules, you can use it to control block visibility, so the possibilities are limitless:

  Need to show a block only for users registered more than a month ago?
  Perhaps you have a block that must be shown only between 8am-5pm on weekdays?
  What about displaying or hiding a block based on current weather conditions?

  All of this can be done by using Rules block visibility.

With that, and as per the "if you can do it with Rules, you can use it to control block visibility" above, you've reduced your question to making Rules intercept the actual user who's using the site, i.e. if it is YES or NO (a boolean, right?) the user with uid = 1.

Part 2: Create an appropriate Rules Component

The Rules block visibility module doesn't have a lot of documentation, except in the README.txt that comes with this module. Here is what the crucial part of it is (to get the idea):

  Configuration is done on a per-block basis. To control a block
  visibility using a rule component, go to the block settings page,
  scroll down to the "Rules" tab, and select the Rules component that
  you want to use.

  Notice that to be able to be used by this module, a Rules component
  must be constructed in a very specific way. See the next section for
  more information.

This module comes with 2 sample Rules Components, that should help to understand the KeepItSuperSimple concept behind it.

By looking at these samples, I was able to create another Rules Component which looks like so:

{ "rules_block_visibility_hide_block_for_user_1" : {
    "LABEL" : "Hide block for user 1",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : {
      "module" : { "label" : "Module", "type" : "text" },
      "delta" : { "label" : "Delta", "type" : "text" },
      "result" : { "label" : "Result", "type" : "boolean", "parameter" : false }
    },
    "IF" : [
      { "NOT data_is" : { "data" : [ "site:current-user:uid" ], "value" : "1" } }
    ],
    "DO" : [ { "data_set" : { "data" : [ "result" ], "value" : "1" } } ],
    "PROVIDES VARIABLES" : [ "result" ]
  }
}

You should be able to import this rule in your own environment.

What this Rules Component does is "only" return a boolean (1 or 0), based on the condition if the user's uid is YES or NO equal to 1.

With that, we're coming close to an actual answer to your question. But note that, as a variation, you could also have used a rules condition like "does this user yes or no have a role like administrator".

Part 3:

Head over to the "Block" settings for the block you want to hide for the user with uid = 1. At the bottom of it's settings, within the typical "Visibility settings", there is now (after you enabled the Rules block visibility module as in Part 1) an extra tab labeled "Rules". Using that tab will allow you to select a "Rules Component" that will do what's documented below that selection list field, ie: "Show this block only if the selected rule returns a positive value. Important: to be listed here, a block visibility rule must have specific parameters and return values.".

And guess what, in my case I just selected my Rules Component from Part 2

Notes:

It doesn't matter what type of block it is (created by a view, or something else), it works in all cases.
This answer applies to D7.


403 Forbidden when creating a page with RESTful API

The tutorial example using Dev Client is probably what is throwing you off because PHP_AUTH_USER and PHP_AUTH_PW are not valid request headers for Drupal 8 REST. The tutorial does give a curl command using the --user parameter which should do the correct behavior - add an Authorization header. I demonstrated this by manually adding that request header in User login REST format.

Content-Type: application/hal+json
Accept: application/hal+json
Authorization: Basic admin_username:admin_password


The Drupal 6 version of db_query supports placeholders.  The best explantion of these is probably the Writing secure code article.

A (contrived) example would be

$query = "
  SELECT node.nid FROM {node} node
  INNER JOIN {content_type_foo} content_type_foo ON content_type_foo.nid = node.nid
  WHERE content_type_foo.field_foo_value = '%s'
";

$foo = $_GET["foo"];
$nid = db_result(db_query($query, $foo));

The referenced article also shows how to use placeholder arrays for handling a variable number of arguments, like for WHERE IN queries.

The second edition of Pro Drupal Development, which covers Drupal 6, is also a good reference for using the database abstraction later.


Display field in views-view-field--field_title.html.twig

URL FORMATTER module

This module add a url formatter for image field. Then you can output image url directly.

Enable the module, then in views, click on your image field, and change the Formatter to Image url.
{{ field_with_image_url }}  // will display url instead of picture


See new documentation page for geofield that shows how to setup a basic proximity search (it is based on MotoTribe's answer, but with a bit more info)

As requested, some of the link content:

Instructions

Required modules

You must download the latest modules. These instructions have been tested with the 'dev' versions of geocoder, geofield, and addressfield modules. I believe these modules have a dependency on geophp, maybe others, install any dependent modules that you are instructed to when installing. Make sure to download the 'dev' versions!

Steps

Setup your content type:

Create a content type for whatever you want to locate (e.g. Dealers, Stores, etc)
In manage fields: Add an addressfield field to the content type (use options as you see fit).
In manage fields: Add a geofield field to the content type. When adding, make sure to select 'Geocode from another field' from the 'widget' dropdown! The geofield option are pretty straightforward, just make sure to select the addressfield field you created earlier for the 'Geocode from field' option.
Now, create a few records with addresses using your new content type.

That was easy! Now, let's setup the view result...

Setup your views query:

Create a view, can be any kind. Select the content type you created earlier for the results.
Add a field: '[name of your geofield] - proximity' (there are a number of geocoding related fields, you want the one with '- proximity' appended)
In the field settings: For the 'Source of Origin Point' field, select 'Exposed Geofield Proximity Filter'.
Add any other identifying fields, such as title, address, etc.
Add a new 'Filter Criteria' for your view for the '[name of your geofield] - proximity' field.
Choose 'Expose this filter to visitors, to allow them to change it'
For 'Operator', choose 'Is less than', because you want results that are closer than a certain distance from the value your users enters, e.g. less than 100 kilometers, etc.
For 'Source of Origin Point', choose 'Geocoded Location', which will allow the user enter friendly values such as city, state, zip/postecode, state, etc. (basically, anything you can put into Google location searches).
For Geocoding Service, choose 'Google Geocoder'.
Add a Sort Criteria: '[name of your geofield] - proximity'. Also, remove any other sort filter already existing, since sorting by date first will foil your proximity filter!
Set to sort ascending, since you probably want to show the closest results first.
Set 'Source of Origin Point' to 'Exposed Geofield Proximity Filter'.
Test your new proximity search!


get list of product line item in rule php

This is a good way to get them

$line_items = $commerce_order->commerce_line_items['und'];
 foreach($line_items as $lid) {
 $line_item = commerce_line_item_load($lid['line_item_id']);
$pid[] = $line_item->data['context']['product_ids'][0];
//also you  can load products
//  $product =  commerce_product_load($pid);
 }


Trim whitespace from Float fields before validation

Add the following to a custom module:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  //dpm($form_id);
  if ($form_id == 'BUNDLE_NAME_node_form'){
    $language_float = $form['MACHINE_NAME_FIELD']['#language'];
    $form['MACHINE_NAME_FIELD'][$language_float]['#after_build'][] = 'MYMODULE_field_float_rectify';
  }
}

function MYMODULE_field_float_rectify($element, &$form_state) {
  $children = element_children($element);
  foreach($children as $child){
    $element[$child]['value']['#value'] = trim($element[$child]['value']['#value']);
  }
  return $element;
}

I would think you can also add it to your admin theme's template.php file, but it seems to be more appropriate to add it to a module.


How to find which content types have comments enabled?

I searched but I found nothing relative, so I take the initiative to answer my own question.

MySQL seems to be the answer:

mysql> select type from comment c, node n where c.nid = n.nid group by type;
+------------------+
| type             |
+------------------+
| my_content_x     |
| my_content_y     |
| my_content_z     |
+------------------+

This can be equally used:

mysql> select entity_type, bundle from  field_data_comment_body group by entity_type, bundle;
+-------------+-------------------------------+
| entity_type | bundle                        |
+-------------+-------------------------------+
| comment     | comment_node_my_content_x     |
| comment     | comment_node_my_content_y     |
| comment     | comment_node_my_content_z     |
+-------------+-------------------------------+

All nodes which at least have one comment:

mysql> select type, n.nid from comment c, node n where c.nid = n.nid group by n.nid  order by type;
+--------------+------+
| type         | nid  |
+--------------+------+
| my_content_x |  115 |
| my_content_x |  90  |
| my_content_y |  521 |
| my_content_y |  295 |
| my_content_z |  127 |
| my_content_z |  11  |
+--------------+------+


Autocomplete textfield displays value when selected and not label

To get this working I had to create a hidden field to store the value and use a custom selectHandler applied via class.

JavaScript File

(function ($, Drupal) {

  'use strict';

  /**
   * Override drupal selectHandler function
   */
  function customSelectHandler(event, ui) {
    var valueField = $(event.target);
    if($(event.target).hasClass('MYCUSTOM-autocomplete')) {
      var valueFieldName = event.target.name+'_value';
      if($('input[name='+valueFieldName+']').length > 0) {
        valueField = $('input[name='+valueFieldName+']');
        // update the labels too
        const labels = Drupal.autocomplete.splitValues(event.target.value);
        labels.pop();
        labels.push(ui.item.label);
        event.target.value = labels.join(', ');
      }
    }
    const terms = Drupal.autocomplete.splitValues(valueField.val());
    // Remove the current input.
    terms.pop();
    // Add the selected item.
    terms.push(ui.item.value);

    valueField.val(terms.join(', '));
    // Return false to tell jQuery UI that we've filled in the value already.
    return false;
  }

  Drupal.behaviors.myCustomAutocomplete = {
    attach: function(context, settings) {
      // attach custom select handler to fields with class
      $('input.MYCUSTOM-autocomplete').autocomplete({
        select: customSelectHandler,
      });
    }
  };

})(jQuery, Drupal);

Form PHP

$form['my_field'] = array(
  '#type' => 'textfield',
  '#attributes' => ['class' => ['MYCUSTOM-autocomplete'],],
  '#autocomplete_route_name' => 'mymodule.myfield_autocomplete',
);
// field value
$form['my_field_value'] = array(
  '#type' => 'hidden',
);

On our forms we also have an AJAX callback on the autocompleteselect event, and I've noticed the value for the hidden field is blank but the userInput on the $form_state has the value.

Problem with this is the splitValues function may not work well for the labels, since it appears to be comma-delimited. You may want to write your own to handle it. It also won't work well if using the same form twice on a page, but there may be a way to narrow down the selector on the hidden field.


Because you need to login from external script...  Your external script is always anonymous to Drupal since no session has been created for external script user....

If you are trying to load all online users in an external script you can check who's online block implementation in user module..


View filter on date "Less than or equal" AND NULL(empty)

Well I could figured out this for myself, if anyone need it here is what you need to do:

Go to sites/all/modules/views/handlers/views_handler_filter_numeric.inc
In there:

a. Inside the function operators()->$operators = array(

b.

'custom' => array(
'title' => t('Title you want for your operator'),
    'method' => 'op_custom',
    'short' => t('<='),
    'values' => 1,
 )

c. Then around line 255 or so create a new function:

function op_custom($field) {
  $or = db_or()
  ->condition($field, $this->value['value'], 'IS NULL')
  ->condition($field, $this->value['value'], '<=');
  $this->query->add_where($this->options['group'],$or);
}

And you can choose that operator now in your Data Filter.

I hope this helps, any questions let me know as PM or comments, take care


How to send email to submitter in a webform?

You can set a e-mail field in the webform, whether it is hidden or not is up to you. You should then set the current users e-mail address as the default value. For this, you will need hook_form_alter()

function YOURMODULE_form_alter(&$form, $form_state, $form_id) {
  //drupal_set_message($form_id); (uncomment this to get form id)
  if ($form_id == 'your_webform_id') {
    global user;
    if ( $user->uid ) { //check user is logged in
    $form['field_email']['und'][0]['value']['#default_value'] = $user->mail;
    }
  }
}


How to rename image filename and make same as title field value

It looks like you should be able to do this using the Filefield Paths module. This will allow you to use tokens based on node fields to rename the file on upload.


How to add a custom link to login form block with hook_form_alter

In Drupal 7 you can use #markup attribute, as suggested by MOLOT

/**
 * Implements hook_form_alter()
 */
function hook_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'user_login':
    case 'user_login_block':
      $form['link'] = array('#markup' => l(t('Link text'),'node'));
      break;
  }
}

Note:

hook_form_alter
Forms API reference


Is there a "description" field for Rules actions?

This is so needed.  I agree.  Luckily, it's in the works: http://drupal.org/node/1244738

I'd add your vote to that Drupal module issue!  :-)


Output taxonomy term in views unformatted using twig

You're a little light on details about your setup, but I can make a suggestion based on what I see. I don't know how you're settings the term variable, but row will have access to the node (assuming this is a node view) that represents the row being displayed. You can do something similar to

{{ row.content['#node'].field_tags.getValue().0.target_id }}

(assuming field_tags is your term reference field) to print the referenced term ID.

Edit: just realized how long ago this was asked... Not sure why it was showing at the top of my list. Anyhow, hopefully helpful to someone!


How do I change the description of a view?

When you edit a view, on the top right corner there is an Edit view name/description button.


Remove output of author username and blog link of news snippets from search results

Consider using Display Suite module.

To make changes to search results for article content type, Goto admin/structure/types/manage/article/display and enable the search result custom display.

Then visit admin/structure/types/manage/article/display/search_result and add or remove the fields as per your requirement.


Is there a way to create a hotel roommate system for a conference?

There is no off-the-shelf module to do this, but you could set something up with a custom Room share request content type and then Rules and Entity Reference to handle the scheduling and assignments.  Combining Rules, fields (via content types), and entity references should be flexible enough to handle such a workflow but it will require a little work to set up and may be too much work in your case.

Unless this is a huge conference, you might just go with the built-in forum module and allow users to post to the forum if interested and sort things out themselves.  It requires very little set up and that way if your users don't actually use/need the feature then you won't waste time developing it.


Try stripping the line breaks. Like they should be all going in one line.


How to enable drag and drop picture upload into CKEditor?

Most drag&drop upload solutions are meant for image / file upload fields, but there is one more that integrates with CKEditor: the media module. According to its project page:

  Features: […] Drag and drop upload (requires the Plupload module).

Choose the 7.x-2.x branch, it reportedly has better drag&drop image upload capabilities. Integration of media with CKEditor happens via the wysiwyg module, so if you deploy CKEditor instead via the ckeditor or editor modules, it may not work even if overriding dependencies, because these integrations have slightly differing APIs to talk to CKEditor.


Check if viewing teaser in hook_node_access

This is not possible in hook_node_access, Drupal does not allow for this so easily. Instead, you could use module Premium Content (https://drupal.org/project/premium_content) and do this in configuration.

Btw., this question has already been answered:
Show teasers to anonymous visitors but not allow access to the body/node


What could cause the site to suddenly start dying with the "Call to undefined function entity_get_info()" error?

You have a classed FieldCollectionItem object in your variables table. Drupal 7 isn't designed to handle this.

When you use variable_set() to save an object to the variables table, the object must first be converted into a string using serialize(). Later, it will have to figure out how to convert that string back into a FieldCollectionItem object, and it will call the __wakeup magic method on the class to help it figure out how to do that. It turns out that __wakeup method requires code that isn't bootstrapped yet at the time that Drupal reads from the variables table, so you get the fatal error.

But you're not hosed. It looks you probably saved the object in the 'roles_to_pass' variable. If you can edit your database, try removing that record from the {variable} table, then clear your cache tables.


How to access current menu level/depth when overriding THEMENAME_menu_tree__MENU($variables)?

Looks like this question is way past its expiry date, but who knows this might help someone :)

I must confess, I have never used this hook function before (THEMENAME_menu_tree__main_menu).  I had a quick look by implementing it in my current project, and you are only getting back HTML.  I think you are going to have a tough time styling individual items in the HTML you are getting back.

In my current project I render my menu a region template file (region--header.tpl.php to be exact).  Obviously this means I have a 'header' region defined in my mytheme.info file.

So in page.tpl.php I have

<?php
  if (isset($page['header'])) {
    print render($page['header']);
  }
?>

which basically defers rendering to region--header.tpl.php In this file I:

$menu = menu_tree_all_data('main-menu');
foreach ($menu as $menuItem) {
  // Extract info I want and render
  // $markup = ......
}

$print $markup

Basically I build my own HTML that will render the menu.

I have a couple of 'utility functions' to get the data out of $menuItem - let me know if you are interested.

As a side note - if you just want to figure out what level you are on - you could always call menu_get_active_trail().  You should be able to figure out what 'level' you are on with the info in that array.

Hope this helps.


How to change the View Mode based on theme?

Since your mobile theme is a different theme a viable alternative is to just use the same display modes everywhere and then theme that display mode differently by overriding the node.tpl.php file differently in each theme.


Sounds like you want Paragraphs or Field Collection.

Basically, the idea with these modules is to group two fields (office + address) as a set within an entity and then embed that entity in your content type.

For Drupal 8, Field Collection recommends using Paragraphs, so that's the module I would use.  For Drupal , I would use Field Collection.


How do I know from which page the users are coming?

If you have control over the Urls linking to your target page, append a page-specific parameter. Suppose the page you are linking to is http://www.example.com/target-page:

On the first referring page, make this Url: http://www.example.com/target-page?referer=page-1
On the second referring page, make this Url: http://www.example.com/target-page?referer=page-2

Then in your hook_menu_breadcrumb_alter function, the referer will be available in the $_GET variable, and you will be able to do something like this in the template.php file for your theme:

function mytheme_breadcrumb(&$variables) {

  if (request_uri() == '/target-page') {
    switch($_GET['referer']) {
      case 'page-1':
        $variables['breadcrumb'][] = l('First referring page', '/page-1');
        break;
      case 'page-2':
        $variables['breadcrumb'][] = l('Second referring page', '/page-2');
        break;
    }
  }
}

If you don't want to add parameters to the Url, and are not using HTTPS, you could use the approach above except with $_SERVER['HTTP_REFERER'] in the switch statement. Or alternatively, you could set a cookie on the referring pages and read it on the target page.

The example above is probably the easiest way to manipulate breadcrumbs but strictly speaking, there should not be business logic in a theme function. See these questions for more detailed info on how to manipulate breadcrumbs:

Altering the breadcrumb contents
Move user profiles under a menu item
https://stackoverflow.com/questions/10087168/how-to-add-breadcrumb


For flag count on entities use:

$flag_service = Drupal::service('flag.count');
$counts = $flag_service->getEntityFlagCounts($node);

For flag count on flag entity use:

$flag_service->getFlagFlaggingCount($flag);

You can find all functions from the Service here:

/modules/contrib/flag/src/FlagCountManager.php


Libraries shared by more than one installation?

Sometimes different module versions use different library versions. For example an upgrade for a module comes with supporting the next library version.

AFAICT if you're after simplifying your maintenance, and the sites you're hosting are similar in their features, it makes sense to also set the modules to also be shared.

That is, the entire Drupal installation. This is called a multisite installation and I've been satisfied with that type of a solution when having a cluster of smallish Drupal sites that use the same modules (and libraries) but different themes.

Multisite Drupal

This way you only maintain one Drupal folder on your host (or at least one Drupal for more than one site, you can still have more Drupal folders for more sites if you like, independent of the multisite one).

Each site has its own database.

Advantages are that when you need to update the modules or core you do it only once on that folder, but don't forget to perfom database updates on all the sites that use that Drupal folder, so they will all have to be in Maintenance mode at the same time.

The downside is that when you need to update, you have to do them all.

Each site usually has a special theme, so themes are placed under the specific sites' folder, not under themes/ where the shared themes are.

You can still have individual sites use a special module that you don't want on other sites in the "cluster", just put it under the site's folder and not in the general one.

Libraries will be shared across all sites, but if the modules used across the sites are also of the same version, you win because you've simplified your maintenance.

To clarify, you don't need to enable all the same modules for all sites within a multisite "cluster". The enabled modules don't even need to overlap! One site can use modules a, b, and c, and the other site can use modules d, e, and f. It's only about keeping the versions the same across the sites to simplify the maintenance.


No this is a video scaling and proportion issue for the player (or your embed code size). If Vimeo allows you to not show these black bars (you'd have to goto the Vimeo site and compare many many videos) ... you would need to figure out the correct aspect ratio to record you're video at so that these bars are not needed in the embed width of the player.


webform can be programatically save, as shown in below example,

  $node = node_load($nid); //nid is the node id of your webform
  global $user;

 //the values to save
  $data = array(
    1 => array('value' => array($first_value)),
    2 => array('value' => array($second_value)),
  );

  $submission = (object) array(
    'nid' => $nid,
    'uid' => $user->uid,
    'submitted' => REQUEST_TIME,
    'remote_addr' => ip_address(),
    'is_draft' => FALSE,
    'data' => $data,
  );

  module_load_include('inc', 'webform', 'includes/webform.submissions');
  webform_submission_insert($node, $submission);
  webform_submission_send_mail($node, $submission);


How do I find what content is supplying my current page?

Take a look if you can see the contextual "settings wheel" in the top right corner.
This can provide you with a direct link to edit the "page"/"view" or Panel that you are on


How can I add HTML tags into menu title?

You need to tell drupal that the string is safe. When you use t() this is done  automatically. But this would make no sense here, because there is nothing to translate.

In this case you can use an untranslatable markup:

use Drupal\Core\Render\Markup;

function adminimal_theme_preprocess_menu(&$vars) {
  if ($vars['menu_name'] === 'main') {
    if (isset($vars['items']['standard.front_page'])) {
      $vars['items']['standard.front_page']['title'] = Markup::create('<i class="icon-home"></i>');
    }
  }
}


How do I synchronize users and their roles between sites?

Hope the question is for Drupal 7 or lesser. If it's for Drupal 8, the solution is close to impossible. And for future Drupal versions, as per the current plan for Drupal 9, multi-site option itself shall not be available, which mean sharing user role using Drupal's default options, is clearly impossible.

In Drupal 7 or lower, in the multi-site setup, it's very easily possible to configure each site to use different databases for their contents, and share the same table (from same database) just for users, roles, sessions, etc. If you don't want to share users, but want to share only roles, even that is possible. For this, the settings.php for site A and site B has to be as below:

settings.php for Site A:

/*
 * Database Settings for 'Site A'
 */
$databases['default']['default'] = array (
    'database' => 'site_a_db_name',    // Specify Site A's main database name
    'username' => 'site_a_db_username',
    'password' => 'site_a_db_password',
    'prefix' => array(
        'default' => 'site_a_prefix_',    // Prefix for all tables in Site A's main database (specified above), other than for the tables specified below
        'role' => 'shared_db_name.shared_prefix_',              // Shared database name and prefix for the 'role' table
        'users' => 'shared_db_name.shared_prefix_',             // Shared database name and prefix for the 'users' table
        'authmap' => 'shared_db_name.shared_prefix_',           // Shared database name and prefix for the 'authmap' table
        'sessions' => 'shared_db_name.shared_prefix_',          // Shared database name and prefix for the 'sessions' table
        'profile_fields' => 'shared_db_name.shared_prefix_',    // Shared database name and prefix for the 'profile_fields' table
        'profile_values' => 'shared_db_name.shared_prefix_',    // Shared database name and prefix for the 'profile_values' table
    ),
    'host' => 'localhost',
    'port' => '3306',
    'driver' => 'mysql',
    'collation' => 'utf8mb4_general_ci',
);

settings.php for Site B:

/*
 * Database Settings for 'Site B'
 */
$databases['default']['default'] = array (
    'database' => 'site_b_db_name',    // Specify Site B's main database name
    'username' => 'site_b_db_username',
    'password' => 'site_b_db_password',
    'prefix' => array(
        'default' => 'site_b_prefix_',    // Prefix for all tables in Site B's main database (specified above), other than for the tables specified below
        'role' => 'shared_db_name.shared_prefix_',              // Shared database name and prefix for the 'role' table
        'users' => 'shared_db_name.shared_prefix_',             // Shared database name and prefix for the 'users' table
        'authmap' => 'shared_db_name.shared_prefix_',           // Shared database name and prefix for the 'authmap' table
        'sessions' => 'shared_db_name.shared_prefix_',          // Shared database name and prefix for the 'sessions' table
        'profile_fields' => 'shared_db_name.shared_prefix_',    // Shared database name and prefix for the 'profile_fields' table
        'profile_values' => 'shared_db_name.shared_prefix_',    // Shared database name and prefix for the 'profile_values' table
    ),
    'host' => 'localhost',
    'port' => '3306',
    'driver' => 'mysql',
    'collation' => 'utf8mb4_general_ci',
);

As shown in the above code, under 'prefix' array, we can specify separate database and prefix for each different table used in the site. Other than those tables exclusively specified in the 'prefix' array, for all other tables, the prefix specified as 'default' shall be used.

In Drupal 8, user/role/session sharing is not as easy as in Drupal 7, because in Drupal 8, many of the informations, including the user roles, are part of a shared table (that shared table is meant for storing many different variable values, and roles are just part of that).


Add conditional redirect to Views exposed filter (using BEF)

A sketch of an idea, for prototyping.
Once this works for you, you could move this javascript code into a render array via form alter. Here are some links for that:

https://api.drupal.org/comment/31448#comment-31448
https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#attached

Prototyping: Inside the header area of your view you can insert a js snippet inside of a 'Global: Text area' field (use the full html text format to avoid stripping of html tags):

And here is an example snippet to get you started, I am targeting the node's status exposed filter from my sample view:

<script>
(function($) {
  $( document ).ready(function() {
    $('#edit-status').change(function() {
      switch($(this).val()) {
        case 'optionA':
          window.location = "https://www.drupal.org";
          break;
        case 'optionB':
        case 'optionC':
          // grouping option together if they have the same target url
          window.location = "https://petrakis.design";
          break;
        default:
          // default code block, simply exit
      }
    });
  });
})(jQuery);
</script>

Hope this helped!


Showing user image for custom comments created in a view

Try adding a "Relationship" to the comment author, and then add the user picture from the updated field list.


Why would my /admin/reports/dblog get "stuck" on only showing "page not found" errors?

Try having a look in your server error_log file that will probably tell you what's causing the problem. My guess is an unsupported character or something has been recorded in a log message.

You could just try clearing the actual log table in the database. Looks like you're on drupal 7 so you'd want to truncate the watchdog table to remove all logged errors


Override locale_block_view in custom module

I've fixed it like this:

function theme_links__locale_block(&$variables) {
    $links = array();

    foreach($variables['links'] as $link)
    {
        $link['title'] = $link['language']->language;
        $links[] = $link;
    }

    $variables['links'] = $links;

    $content = theme_links($variables);
    return $content;
}


Run DB query and fetch fields in block--block--ID.tpl.php

It sounds like you want to enable Tokens on your site and use a token to show the subdomain name in your block, after adjusting the Input Format for the block.

There really isn't coding involved, unless the subdomain module does not provide token support (then implement hook_token_info).


handling non-node based items with ubercart

Having dealt with this exact circumstance before, we had a content type named 'bundle' which was purely a placeholder for the product details in Ubercart.

The user views the product and clicks 'add to cart' and in the cart is an instance of this 'bundle' with the product details in it.

Its far from a good solution and I would definitely be looking at creating a node for each of the products you have for sale - You could even create the nodes when 'added to cart' so you didnt need to add any in advance.

Ubercart has a great API for manipulating cart contents and line items, have you looked at that at all?


I seem to have solved my issue, i will try to elaborate for future reference and also for any one who may need this.

First, it seems i missed the "Bulk operations settings" section as it was collapsed by default. But one of the options under it is "Display operations as" which provides two choices (1) Dropdown selectbox with Submit button and (2) Each action as a separate button

The second option was what i needed to get the buttons i wanted.

Then for bulk updating a custom field of my content type, i added hook_action_info() into my custom module and created a custom action that would become visible where the "Modify Entity Value" option was.


Detecting if site is inside iframe - loading custom CSS

You could...

munge the window.location object to add the additional param, but that will force the page to reload. From there you can access the param in Drupal and write server-side code to do a drupal_add_css().
Use jQuery (which comes with Drupal) to add the CSS directly.
Use jQuery to add a link to the remote stylesheet.

Example of the third method:

if (top !== self) {
  var cssURL = 'http://example.com/my/stylesheet.css';
  $('head').append('<link rel="stylesheet" href="' + cssURL + '"/>');
}

I would think that as long as you can predict the stylesheet name, the last option is going to be the most elegant.

Note that you would want to add the JavaScript to the document with drupal_add_js() in Drupal.


How to unpublish a node with vocabulary term X after Y hours?

Use the Rules module for this, by performing these steps:

Create a Rules Component to unpublish a node, which is like a getting started with Rules Components.
Create a Rule like so:

Rules Event: After saving a new node.
Rules Conditions: check if "it has a specific category - category is based of course on taxonomy's vocabulary" (as in your question).
Rules Action: schedule the execution of the Rules Component, to be executed after 24 hours. You'll have such Rules Action available if you enabled the rules scheduler (sub-module of Rules). This will actually execute the Rules Component "next time cron runs". So make sure to take that into account also to set the frequency of your cron jobs, and/or schedule the Rules Component a bit before the 24 hours have passed (whatever fits for your case). Note that the one who can edit the rule will be able to "predefine" when the Rules Component will be executed.


From Webform vs. CCK (or D7 Field module):

  Webform submissions are not nodes. This means that you can't use Views with submissions, ...


As a rule, we should never make changes in core files. If you will read the readme.md file in omega theme, you will see the following,

  Omega 4.x is a base theme and as such should never be used or
  modified directly. Instead, you should use the sub-theming
  functionality provided by Drupal.

  The easiest way to create a new Omega-based sub-theme is by using
  Drush. Omega comes with a very
  easy-to-use Drush command for generating sub-themes through a
  command-line wizard. You can start the sub-theme creation wizard by
  invoking drush omega-wizard in the command-line.

So you should first create omega sub-theme which is quite easy process and then make changes in sub-theme's block.tpl.php file.


The easiest thing to do is to get a version of git for your machine.  On Windows, TortiseGIt works reasonably well.  You can then use that to checkout a version of the sandbox module.  If there are patches, you can apply them to the module.  Then you just need to upload the module to your Drupal site with your normal methods (don't forget to run update.php).

A lot of this is made easier if you are using an IDE, as newer ones are well integrated with git.


The function you are showing is an implementation of hook_builder_content_info(). Without seeing the code that calls that hook, I cannot answer about removing the vertical tabs, but I can just give some hints.

If the module also invokes hook_builder_content_info_alter(), which is normally done from the majority of the Drupal modules using hooks, you can implement hook_builder_content_info_alter() in a module.

/**
 * Implements hook_builder_content_info_alter()
 */
function builder_gc_builder_content_info_alter(&$contents) {
  unset($contents['node']['group']);
}

The alter hook could get other arguments, but the structure to change is always the first.

If the module doesn't invoke any hook_builder_content_info_alter() you need to:

Avoid Drupal invokes builder_builder_content_info()
Implement hook_builder_content_info() using the same code used by builder_builder_content_info() but without those parts that you don't want

This can be done with the following code.

function builder_gc_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'builder_content_info') {
    // Remove the implementation done from that module.
    unset($implementations['builder']);
  }
}

function builder_gc_builder_content_info() {
  $blocks = _block_rehash();
  $contents = array();
  if (!empty($blocks)) {
    foreach ($blocks as $key => $block) {
      $contents[$block['delta']] = array(
        'info' => $block['info'],
        'type' => 'block',
        'group' => t('Block'),
        // This is name of group to collect contents in a tab
        'block_module' => $block['module'],
      );
    }
  }

  // node add content
  $contents['node'] = array(
    'info' => t('Adding existing node'),
  );

  //Custom text
  $contents['custom_text'] = array(
    'info' => t('Custom text'),
    'group' => t('Text'),
  );

  // Custom heading
  $contents['custom_heading'] = array(
    'info' => t('Custom heading'),
    'group' => t('Text'),
    'no_title' => TRUE,
  );
  // Insert image
  $contents['image'] = array(
    'info' => t('Insert an image'),
    'group' => t('Image'),
  );

  $contents['youtube'] = array(
    'info' => t('Youtube'),
    'group' => t('Video'),
  );
  $contents['vimeo'] = array(
    'info' => t('Vimeo'),
    'group' => t('Video'),
  );

  $contents['icon'] = array(
    'info' => t('Icon'),
    'group' => t('Icon'),
  );
  return $contents;
}

The code I am showing should avoid the information is shown in vertical tabs, but it doesn't avoid the vertical tabs are created. The only way to be sure is to alter the function that invokes hook_builder_content_info(). Using hook_builder_content_info_alter(), you are sure to alter the value returned from all the hook_builder_content_info() implementations, while the other snippet I shown just alters the value returned from a module. If there are two modules passing 'node' as group, the vertical tab will be created, since I am not altering what returned from the other module.

Also, the code I am showing removes the 'group' property, which I am guessing sets the vertical tab where the information is shown, similarly to the #group property used by fieldsets.

Alternatively, you can use the following code, which removes completely the information about the part you don't want to see.

// Case 1.

/**
 * Implements hook_builder_content_info_alter()
 */
function builder_gc_builder_content_info_alter(&$contents) {
  unset($contents['node']);
}

// Case 2.

function builder_gc_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'builder_content_info') {
    // Remove the implementation done from that module.
    unset($implementations['builder']);
  }
}

function builder_gc_builder_content_info() {
  $blocks = _block_rehash();
  $contents = array();
  if (!empty($blocks)) {
    foreach ($blocks as $key => $block) {
      $contents[$block['delta']] = array(
        'info' => $block['info'],
        'type' => 'block',
        'group' => t('Block'),
        // This is name of group to collect contents in a tab
        'block_module' => $block['module'],
      );
    }
  }

  //Custom text
  $contents['custom_text'] = array(
    'info' => t('Custom text'),
    'group' => t('Text'),
  );

  // Custom heading
  $contents['custom_heading'] = array(
    'info' => t('Custom heading'),
    'group' => t('Text'),
    'no_title' => TRUE,
  );
  // Insert image
  $contents['image'] = array(
    'info' => t('Insert an image'),
    'group' => t('Image'),
  );

  $contents['youtube'] = array(
    'info' => t('Youtube'),
    'group' => t('Video'),
  );
  $contents['vimeo'] = array(
    'info' => t('Vimeo'),
    'group' => t('Video'),
  );

  $contents['icon'] = array(
    'info' => t('Icon'),
    'group' => t('Icon'),
  );
  return $contents;
}

If this code doesn't work, you could follow the following steps, in order to change the module behavior:

Check which function is invoking hook_builder_content_info()
Verify if there is a reference to that function in one of the hooks Drupal uses (e.g. hook_menu()); the reference could be either direct or indirect (i.e., the reference is for a function that calls the function invoking hook_builder_content_info())
If this is the case, using the alter hook Drupal uses (e.g. hook_menu_alter()), you can change that reference with a reference to a function you write, which uses the code the original function uses, without the part you don't want.

In this way, you aren't directly altering the values returned from hook_builder_content_info(), and you need to copy more of the code used from the module for which you are altering the behavior; this is also means that, for every minimal change in the module you bought, you need to check your code to be sure it doesn't alter the expected behaviour.


How to implement a Dropbox-like functionality for authenticated users to upload files?

Check out the filedepot module.

  The filedepot module is full featured Document Management module that
  has a google docs like feel. It fulfills the need for an integrated
  file management module supporting role and user based security.
  Documents can be saved outside the Drupal public directory to protect
  documents for safe access and distribution.

It works great as a ftp-like solution which allows users to upload files, except that it has a UI and is accessible the same way as default drupal pages. Lots of configuration available so you can limit the actions of users. You can also integrate organic groups with filedepot and create groups and folders available only to certain groups, if you want to get into private files for users.

or create a webform for authenticated users only and give them a file upload widget. Then you can browse the submissions in a tabular format. This allows users to upload files but not browse them if you set the permissions up properly. They will still be able to see their upload of course.


how to apply tag functionality on drupal 7 nodes?

You must add a term reference field to the content type, and choose your vocabulary.

See the below screenshot of a view to see how to show tags for nodes in a view.


Hi checkout you view setting
like this http://prntscr.com/bscbkf
then add filter on it
http://prntscr.com/bscc0e
now you can see result
http://prntscr.com/bsccbh
Also explain some more details


I pulled this out of one my themes:

<div class="menu">
    <?php
        print theme(
            "links",
            array(
                "links" => menu_navigation_links("MENU-NAME"),
                "attributes" => array(
                    "class" => array(
                        "links",
                        "menu-links"
                    )
                )
            )
        );
    ?>
</div>

Alternatively, you can use Menu Block module and assign a menu block to a region, thus removing all of the ugly code from above from your theme file.


How to Disable new terms (free tagging) with Taxonomies?

There seem to be two possible solutions which are mentioned here http://fooninja.net/2012/08/03/drupal-autocomplete-term-widget-disable-creation/ and you have also mentioned them in your question.

Excerpt from the post,

  There are in fact two solutions. One is the Content Taxonomy
  module. However, I didn’t feel like installing yet another module
  for such a simple thing. The second solution is patching the core
  taxonomy module:

  A kind soul on the Drupal forum, j.stuyts, posted a small patch
  that adds an option to disallow autocreation. All you need to do is
  download the patch (1078878-DisableAutoCreation-D7-UTF-8.patch)
  to the Drupal 7 root directory and run.

  If you then go to Structure » Content types » [Your content type] and
  edit a Term reference field that uses the Autocomplete term widget,
  you’ll see a new option at the bottom: “Allow autocreation of new
  terms” (checked by default).

Although hacking in core is never recommended but you can use patch till the time you get better solution.


How to prevent a user from deleting an entity referenced node before deleting the referencing (child) node first?

You can use hook_node_access:

  Modules may implement this hook if they want to have a say in whether
  or not a given user has access to perform a given operation on a node.

The second parameter for this hook is $op:

  $op: The operation to be performed. Possible values:

  "create" "delete" "update" "view"

And the return values are:

NODE_ACCESS_ALLOW: if the operation is to be allowed.
NODE_ACCESS_DENY: if the operation is to be denied.
NODE_ACCESS_IGNORE: to not affect this operation at all.

So, you should implement that hook, check if the node being deleted is of type ItemRequest and if yes collect all the ItemOrder that point to it. If none are collected you can return NODE_ACCESS_IGNORE, if there're ItemOrder pointing to the ItemRequest return NODE_ACCESS_DENY.

While you can hook into the node form and add a custom validator that doesn't prevent user to delete the node using other means (admin content view, for example). This method can prevent any action trying to delete a node.


How to include CSS for a custom admin theme?

You can add yourstyl.css in admin theme's .info file.
Just goto your active admin theme, find and open its .info file and place a simple line here; stylesheets[ ] = css/yourstyle.css . It works like a charm.