When developing a module, you should keep in mind the following notes.

The implementation of a hook done from a module is a function whose name is prefixed with the module short name (also called the machine name); from the hook name, take off the hook part, and replace it with the module machine name. For example, the implementation of hook_menu() done from example.module is example_menu(). If the module is example_menu.module, and the function is example_menu(), that is not considered the hook_menu() implementation for example_menu.module.
This also means, for example, that the hook_form_alter() implementation in example_form.module is not example_form_alter(), but example_form_form_alter(). As another example, the implementation of hook_form_FORM_ID_alter() done for altering the form returned from user_register_form() from example.module is not example_form_user_register_alter(), but example_form_user_register_form_alter(). (The form ID is user_register_form.)
Generally speaking, using uppercase characters in the module machine name doesn't create problems: PHP doesn't make differences between myModule_get_value(), and mymodule_get_value(), and $value = myModule_get_value() would call either myModule_get_value(), or mymodule_get_value().
Although, there is a case where using upper case characters in a module machine name would cause problems: when defining the update hooks for a module. drupal_get_schema_versions(), the function that returns a list of available updates, contains the following code.

// Prepare regular expression to match all possible defined hook_update_N().
$regexp = '/^(?P<module>.+)_update_(?P<version>\d+)$/';
$functions = get_defined_functions();
// Narrow this down to functions ending with an integer, since all
// hook_update_N() functions end this way, and there are other
// possible functions which match '_update_'. We use preg_grep() here
// instead of foreaching through all defined functions, since the loop
// through all PHP functions can take significant page execution time
// and this function is called on every administrative page via
// system_requirements().
foreach (preg_grep('/_\d+$/', $functions['user']) as $function) {
  // If this function is a module update function, add it to the list of
  // module updates.
  if (preg_match($regexp, $function, $matches)) {
    $updates[$matches['module']][] = $matches['version'];
  }
}

The last line executed from drupal_get_schema_versions() is the following one.

return empty($updates[$module]) ? FALSE : $updates[$module];

If the module name is myModule.module, drupal_get_schema_versions('myModule') will return just the functions with a name that starts with myModule_update, and ends with a number; functions like mymodule_update_7120() will not be included because the regular expression used from drupal_get_schema_versions() is case sensitive. This still applies to Drupal 8, as the regular expression is still the same used in Drupal 7.
Some hooks are called in specific moments. For example, hook_menu(), and hook_menu_alter() are called from Drupal 7 after a module has been enabled/disabled, or when the cache for the router information is cleared; hook_init() is not invoked for cached pages.
Once the hooks are invoked because a specific event happened, they will not called again until a similar event doesn't happen. They are not called in two successive page requests.
Drupal caches the list of hooks implemented from a module. If you are editing the code of an enabled module to add new hooks, you first need to disable and  re-enable the module, or Drupal will not notice there are new hooks.
Ensure that a return statement didn't sneak its way into one of your hook functions during a refactoring. It has the potential to break not only the hook that it appears in, but to cause a chain reaction that breaks other hooks as well, making the problem difficult to locate.


You need to create a display in your content type where you will put the field that you want to show in the tooltip.

Home » Administration » Structure » Content types » YOUR CONTENT TYPE » Manage display

Then in your view select in the format to show Content and in the View mode the display that you created before with your fields.


How can I add a wrapper around my nodes?

Copy the corresponding twig template of your view into your module/theme and name it properly after the view's display, fe. views--{type, fe. unformatted}--my-view-id--my-block.html.twig.


a roster lists the players on 1 team, correct? If the view is at a url like roster/TEAMNAME you want a listing of players where the contextual filter on teamname provided by argument 1 in the URL, or else 404 or hide the view.

If the roster is not on a URL but say a block on 1 players page (showing the rest of the player roster for his team) then I would add a Views Field View to the player content type that uses the player's own team as the argument to the View I describe above.

Contextual filters are good when you provide the context for the view (like a URL, or another field). relationships just help you to get more information into your view (like additional fields).


How do I add attributes to CSS in theme.info?

Since Drupal will use CSS aggregation (and doesn't have support for adding extra attributes via the info file or drupal_add_css), you will have to print out the style sheets yourself. This can be done with theme functions or by creating the markup in the html.tpl.php


Make sure the "user_1" has a role as "Supervisor".And also check "content type: Edit own content" permission in people->permissions has assigned to "Supervisor" Role.Finally clear the performance.


How to access an external MySQL database in a view if SQLite support is not installed?

The Forena module is shipped with 3 types of "sample" reports:

Reports about your own Drupal database (the drupal/* 'data blocks' in your screenprint), typically in MySQL database format.
Forena tutorials, which are actually also delivered in the format of "Reports" which refer to datablocks in XML format (the forena_help/* 'data blocks' in your screenprint).
Reports about some Sample database which is also delivered with Forena, in the format of an SQLite database (none of these Sample/* 'data blocks' are shown in your screenprint, as they are normally shown when PDO driver support for SQLite is available).

So the error shown in your screenprint is to inform you about something like "sorry, there is no SQLite support available here, so I can't handle the Sample database (which is in SQLite format)".

If however you have MySQL support available on the server where your MySQL data resides (eg: if it's on the same server as where Drupal resides, but just another MySQL database), then you should be able to use Forena for creating reports about that MySQL database. To access that MySQL database, you need to define (within Forena admin) a Data Connection to that MySQL database and 1 or more data blocks (SQL queries). And from then on you should be able to build your custom reports about that MySQL database, e.g. using the WYSIWYG report writer that comes with Forena.

Note: if you're interested in trying out Forena, use SimplyTest.Me to do so. If you do, and after you login to such site, you'll also get the same PDO driver support for sqlite not installed error message, after you visit the "/reports" link for the first time (or use the "My Reports" menu option in the Navigation menu). That error is shown because support for SQLite is not enabled on SimplyTest.Me. You get a similar error message if you visit the reports/sample.toc link (because the sample reports and graphs are using an SQLite database). However, reports such as these run just fine (they don't require SQLite):

/reports/help.toc.
/reports/drupaladmin.enabled_contributions (by the way: shows all enabled modules in such simplytest.me setup ...).


Can I refresh parent window through drupal_goto?

drupal_goto will can be used to reload the same window. if you are in iframe, then it will reload the iframe, if you want to refresh the whole page you need javascript and you can add it inline using drupal_add_js

  drupal_add_js('parent.location.reload();',array('type' => 'inline'));


Adding javascript to module and access drupalSettings without jQuery

You can try to set a weight on the js file:

  js:
    js/mautic_drupal_tracking_code.js: { weight: -18 }

There is a core issue, that the dependencies don't get the correct priority. The weight is a workaround for this:

Replace custom weights with dependencies in library declarations

If you can't get drupalSettingsLoader.js running in the correct order, you can for testing purpose put the code to load the json array at the top of your custom js:

(function () {

  'use strict';

  var settingsElement = document.querySelector('head > script[type="application/json"][data-drupal-selector="drupal-settings-json"], body > script[type="application/json"][data-drupal-selector="drupal-settings-json"]');

  window.drupalSettings = {};

  if (settingsElement !== null) {
    window.drupalSettings = JSON.parse(settingsElement.textContent);
  }
})();


Custom access callbacks for user entities not being called

The problem might be the execution order of the modules

  How to change access callback of user entity when entity module is installed? (how to make sure my alteration is the last)


While exposed filters don't change the path, they do in fact change the url by adding the filters in there as variables.  As an example, if you had a View with a page display at your/path and an exposed filter that filtered on content type, it would create this url after the exposed filter was selected:

www.example.com/your/path?type=NODETYPE

So, depending on what your exposed filter adds, you can create a link to

www.example.com/your/path/?filter=value

and go there directly.  Just look in your browser afterwards and you should see it, assuming you aren't doing something fun with AJAX here anyway.


How to hide an exposed filter block if the view results are empty?

@pierre's answer is a good one, however $view->total_rows is not always populated.

So you could do something like this instead, which will work no matter what:

function MODULE_views_pre_render(&$view) {
  if ($view->name == 'VIEW_NAME' && $view->current_display == 'DISPLAY_NAME') {
    if (empty($view->result) && empty($view->getExposedInput())) {
      $view->exposed_widgets = NULL;
    }
  }
}


Is it possible to replace more than one form element (wrappers) triggered by only one #ajax trigger element?

Instead of returning the HTML of the single element to update, your ajax callback can return an array of ajax commands. So it can return two ajax_command_replace to replace each element.

function ajax_example_simplest_callback(&$form, $form_state) {
  return array(
    '#type' => 'ajax',
    '#commands' => array(
      ajax_command_replace("#replace_div_1", render($form['element_to_be_replaced_1'])),
      ajax_command_replace("#replace_div_2", render($form['element_to_be_replaced_2']))
    )
  );
}


If your "membership" is already implemented as a role, you could use the Commerce License module (the Commerce License Role submodule).  In the UI, licenses can be assigned to have default lengths that will automatically be set upon purchase; if you need to change lengths, you can also configure rules to do so.


There is no enforcement in Drupal Commerce of any product catalog data model. The solution will depend on how you've configured your taxonomy vocabularies, really. If you have a single catalog vocabulary, simply add a multi-value taxonomy term reference field to the node type you're using to display products. This will let you assign as many categories as you want per product page.

When it comes to actually creating a View of the products, it isn't clear what you're attempting or why. A single View should be able to filter a group of nodes to any selection of or combination of taxonomy terms. You may need to export the View or paste a screenshot of your configuration to this question to get more specific help.


How do I write an additional field formatter for an existing field

Personally I'd say a formatter is the better solution.

There are only two hooks you need to implement:

hook_field_formatter_info()
hook_field_formatter_view()

For example:

function MYMODULE_field_formatter_info() {
  return array(
    'my_formatter' => array(
      'label' => t('My formatter'),
      // The important bit...
      'field types' => array('field_type'),
    ),
  );
}

function MYMODULE_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $settings = $display['settings'];
  $element = array();

  if ($display['type'] == 'my_formatter') {
    foreach ($items as $delta => $item) {
      $element[$delta] = array('#markup' => $item['value']);
    }
  }

  return $element;
}

For a more in-depth look, download the Examples module and look at field_example - there's plenty of code and documentation there to get you on your way.


How to fix entity property X doesn't support writing, when setting content type field values?

Short Answer: It is not possible to write to that field type using entity metadata wrappers. You may want to raise the issue with the maintainers of the module that provide that field type.

Long Answer: The Entity Metadata Wrapper you are using is provided by the Entity Module. This module extends Drupal's entities in various ways. One of the things it offers is to extend the information about fields, by offering it's own hook, hook_entity_property_info. This hook allows, amongst other things, to define a setter callback. This is the function that is used by the entity meta data wrapper to set the value of a field or property.

The error you are seeing implies that this function is missing for the field type you are trying to access.

The Entity module itself actually provides a default function for fields that do not define their own setter callback. What this means is that :

Either the module that creates the field you're using implements hook_entity_property_info and does not define a setter callback; or
Another module explicitely removes the setter callback from the field type you are using.

Either way, you cannot use entity_metadata_wrapper for that field type until the issue is resolved. You should raise it with the people who maintain the module providing that field type.


$nav-height is specified in the file _init.scss (in the sass directory of your sub-theme) and the $zen-grid-width is set by the Zen Grids extension in the _grids.scss file (and if you're developing a non-responsive theme it is set in the _fixed.scss in the layouts directory of your sub-theme).


How do I override a default view template from another module?

Your feature should implement hook_theme_registry_alter(). The use case you describe is exactly what that hook is for. The example code linked on the API page should get you started. The basic idea is to target the entry that corresponds to the entry that views_theme() is inserting into the registry, and change the template to match the one in your feature.


How to get all the content types that don't have nodes?

I know that you can use the 'entity.manager' service to get all the available content types and then through a loop look for all the nodes for each content types. But this way is very long and involve many database queries.

This is the short way that I found to obtain this information:

// Getting the database connection.
$connection = \Drupal::service('database');
$query_content_types = "SELECT DISTINCT SUBSTR(name, 11) as type FROM config WHERE name LIKE 'node.type.%'";
// Creating a temporary table.
$content_types_temporary_table_name = $connection->queryTemporary($query_content_types);

$query = "SELECT node_type.type, COUNT(nid) AS total
          FROM $content_types_temporary_table_name node_type LEFT JOIN {node} USING(type)
          GROUP BY type
          HAVING COUNT(nid) = 0
          ORDER BY type ASC";

$result = $connection->query($query);
dpm($result->fetchCol('type'));


This is a theming question and there's a choice to be made about whether to use a Views or a node template. By and large when displaying entities in views, I tend to use a particular view mode, because then I can display them similarly outside of Views if necessary. To do that:

Choose which view mode to use. In your case use the Teaser view mode, or if that's not an option create a new one.
Ensure your view's configured to display that view mode.
For more info, download and install advanced_help, and read from the Views help at least Row styles and its children Fields and Node.
Check in the node template you're using: is there a variable that would let you add a target attribute to the title link? (There isn't in core node.tpl.php but there might be in your theme.) For more info you can read Overriding themable output and Core templates and suggestions. I'd suggest using devel_themer to see what template is actually used - make sure you've done step 2 first. The template should either be node.tpl.php or start with node-- and end .tpl.php.
If there wasn't a variable in step 3, then modify the template to have one, eg. by adding $title_link_attributes.
Implement hook_preprocess_node(). Check if the node is of the correct type and view mode and modify the variable appropriately. (And if you created a new variable, ensure that you set it to the empty string for other view modes and content types to avoid warnings.) For more info, see Setting up variables for use in a template (preprocess and process functions).

Let me know if you have any questions, or if that approach isn't appropriate for any reason.

Btw I gave a non-JS answer because I thought that was a requirement, but now I'm not so sure.


Deciding which field should be on Product node and which on product variations

I think you're on the right track. If I'm not mistaken, a product display could be something like "Tee Shirt". The product variants would then be something like color or size. It's the same product with the core information, but the variants would be what ever is different, be it storage size or any other kind of variation from the original.

Edit: The product display can display any products. The variants are dependent on the actual product but the display can show anything.


Webform add data along with submitted values

For webform submission it is best to use hook_webform_submission_insert($node, $submission).
$submission->data will contain all the submitted values arranged against form components ids.

See my implementation how I arranged a webform as user register form.

function user_register_webform_submission_insert($node, $submission){
// Load information about form components
$comps = $node->webform['components'];
$fields = array();

//Extract the component info to get form_key=>cid to resolve relation
foreach($comps as $cid => $comp_info){
    $fields[$comp_info['form_key']] = $cid;
}

// Load the submitted data (field values)
$data = $submission->data;

//Prepare a user info
$user = array(
    'mail' => $data[$fields['mail']]['value'][0],
    'name' => $data[$fields['name']]['value'][0],
    'pass' => user_password(8),
    'status' => 1,
    'init' => $data[$fields['mail']]['value'][0],
    'roles' => array(2, 3),
);

$account = user_save(null, $user);
}


Have you included the condition “Entity is of type … Node”? Having to specify this condition may seem redundant, since you have already established this rule is triggered by the Event “After saving new content”. However, I have experienced that without this condition a very limited amount of tokens holding data from the node will be available to the Action and any Components invoked by the rule.
 Good Luck!
Susan


How do I create a menu item when a node is submitted?

Try using the menu_link_save function.

<?php
$item = array(
  'link_path' => 'node/' . $node->nid,
  'link_title' => $node->title,
);
menu_link_save($item);
?>


Block visibility using PHP to show Vocabulary and Terms not working

Modules written for Drupal 6 are not designed to work with Drupal 7. Some do, by fluke, but it's quite rare. Sounds like you have one of the more common ones, that doesn't.

I'm not sure what you mean by

  Does php4.4. not work on a php4.5 server?

I think you're confusing several things there, none of which would be related to Drupal.

If you want to know what versions of PHP Drupal supports, see the requirements. If you want to know what version your server supports, your hosting provider will be able to tell you.

Some modules have specific minimum PHP version requirements; you can find those in the module's .info file, and you'll also be informed in the UI if your system can't support it.


How to tell Custom Breadcrumbs which vocabulary to use?

I had the same problem on my site. I managed to fix it the hard way.

Edit custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.inc

Add these lines after line 20:

$query->condition("v.vid", 2); // 2 is the id of vocab You want to use
$query->orderBy('v.weight');
$query->orderBy('t.weight');
$query->orderBy('t.name');

So You have:

...
$t_alias = $query->join('taxonomy_term_data', 't', 'r.tid = t.tid');
$v_alias = $query->join('taxonomy_vocabulary', 'v', 't.vid = v.vid');
$query->fields( $t_alias );
$query->condition("r.nid", $node->nid);
$query->condition("v.vid", 2);
$query->orderBy('v.weight');
$query->orderBy('t.weight');
$query->orderBy('t.name');
$result = $query->execute();
$terms[$node->vid][$key] = array();
...


How to make Shipping services available in Rules tokens (data selectors)?

If the data about a product are not available when processing a "line item", you can make them available. To do so, use a technique similar to what is explained in my answer to "How to access commerce_product field of line-items using Rules to flag the Commerce Product?", which includes a Rules Component that looks like so:

{ "rules_perform_an_action_on_a_selected_line_item" : {
    "LABEL" : "Perform an action on a selected line item",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "selected_line_item" : { "label" : "Selected Line Item", "type" : "commerce_line_item" } },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "selected-line-item" ], "field" : "commerce_product" } }
    ],
    "DO" : [
      { "entity_fetch" : {
          "USING" : {
            "type" : "commerce_product",
            "id" : [ "selected-line-item:commerce-product:product-id" ]
          },
          "PROVIDE" : { "entity_fetched" : { "product_fetched" : "Fetched Product" } }
        }
      },
      { "drupal_message" : { "message" : "Some details about this product: Product ID = [product-fetched:product-id], Product SKU = [product-fetched:sku], Product Title = [product-fetched:title], Product Creator = [product-fetched:creator]" } }
    ]
  }
}

Here is a blueprint of what you need to do:

Create a Rules Component, similar to the above Rules Component. Just an import of that Rules Component should be enough (to get started and further improve it as detailed below).
Rework the Drupal Message shown via the last Rules Action in the Rules Component (Starting with "Some details about this product"), by also using any of the available tokens that you're interested in.
Execute that Rules Component inside your Rules Loop of the rule in which you want to loop over all line items.
Improve the Rules Component from Step 1 by creating whatever additional Rules Action(s) you need. Make sure to place these Rules Action(s) AFTER that Rules Action (in the Rules Component) that performs "Fetch entity by ID".


Drupal Views Date Views - Today in History (month, day)

Add to your view a contextual filter: add your date field and select "Provide default value: current date". Then, in Granularity (in the same field settings, lower), set the granularity to a "Day" so that only content that was marked for that day is displayed.


How do i add a background image to a imput submit button in my module?

You can attach it to any render array; the submit button itself seems as good as any:

$form['pixelpin_openid_connect_client_pixelpin_login'] = [
  ...
  '#attached' => [
    'library' => [
      'pixelpin_openid_connect/pixelpin_logo',
    ],
  ],
  ...
];


Jquery version issues: Flexslider doesn't works only with 1.5 and bootstrap needs 1.8+

I recommend the jQuery Multi module.

It allows you to use the default drupal jQuery version for most of you site, and use newer versions of jQuery just for plugins that require it.

It gives an administration page where you can choose which libraries to load using the newer jQuery.

It also has hooks you can use to tell it to load your libraries using different jQuery versions.

If you are writing custom js it also namespaces the jquery versions so you can do something like:

(function ($) {
  // All your code here
})(jq172);

That is how the module would namespace jQuery 1.7.2 and you can load your scripts like that to use the newer versions.

One thing to note is that if your plugins with new jQuery require things like jquery UI, jquery.once etc., that drupal core uses already, you have to make sure they are added a second time, so they are added to the normal drupal jquery and the newer one.


Assuming that you're using Drupal 7, take a look at the module Content as JSON. This should take care of the details and put you within the realm of the "drupal-way". There's also the Services module which might be overkill for what you're doing.

If you stick with file_get_contents then don't forget json_decode:

$received = file_get_contents("drupal://input"); // Use inputstream module.
$received = json_decode($received, TRUE);

Then you can play around as much as you'd like with the $received value.

Additionally, the inputstream module is invaluable in letting you get to the input stream more than once (if you try using php://input more than once, the second time, and those following, will return NULL).


How can I show average votes of fivestar nodes?

Consider a table similar to this one:

The Views Calc module can be used to transform that table so that the calculations in the last rows (with Count, Sum and Max) get added to it. So that the table looks similar this:

By replacing the columns '# Fish', 'Weight' and 'Big Fish' in the example above with 'field1', 'field2' and 'field3' (as in the question), and by asking for the 'average' to be added (instead of Count, Sum or Max), it should answer the question I think, no?

To ask for the 'average', just select it from the selection list as shown in this screenshot (instead of the ones selected in that screenshot):

For more details (step-by-step instructions), refer to the community documentation about the Views Calc module.


Install new site from existing config plus data migration

After doing some research I found multipurpose corporate profile a distribution which does the job and accelerates the development process.

It deserves discovering its key features.


I found a better way to access the node so this will work anywhere.

$this->entity();

Inside the current class it will load the entity, in this case, the node.

Happy drupaling!


Comments: "You are not authorized to post comments."

Go to: admin/people/permissions

Check de permission:

Post comments

Click button "save permission".


Showing fields from different bundles that are related

I figured it out using the Views Field View module. It basically gives you the ability make a subquery inside a view using a subview.

First I created a new index on organism with an aggregated field called Scientific Name that combines Genus and species. Then I made a view on that index with a contextual filter with Scientific Name (display empty text when filter value not in url; specify validation criteria).
Then I made the other view which uses the previously made view as a subview.

Well here's an intro tutorial for the module anyways: https://www.ostraining.com/blog/drupal/views-field-view/


Both the Login Toboggan and Email Registration modules allow your users to use their email when logging in.


How to create a redirect to point to the user's id?

Instead of redirecting the mydrupal.com/my-account to particular user ID as mydrupal.com/users/3

You should redirect them to mydrupal.com/user which will lead them to thier profile page if the user is logged in.


How to create custom preview for content type in Drupal 7?

Something like Page Preview may help you.


Changing text "Create new account" in /user tab

By writing a custom module that implements hook_menu_alter and alter the title of the menu.
Something like below.

mymodule_menu_alter(&$items) {
  $items['user/register']['title'] = 'New Text';
}

http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_menu_alter/7


What is the form ID of a submitted Webform to perform a custom redirect?

There are number of ways to do this:

Use rules on event "After saving a node" -> condition : "node is of type webform" -> action : "add redirect" ; path : node/[nid]/webform. Note: [nid] might not be the exact token, but you'll get the exact token in the replacement patterns in the Rules UI.
Implement hook_node_insert in your custom module which triggers after every new node is created, check for the $node->type if it is of type webform, and use drupal_goto to redirect to the form components page. Path node/{$node->id}/webform.
Alter the node_form for webform to add a submit handler and use
form_state['redirect'] = 'node' . $form_state['nid'] . '/webform';


How can I construct a table view with columns passed as a parameter?

What you'll want to do is create a new display (using the table style) on the fly and then use that display to render the output.

If you take a look at views exports, you can get an idea of how columns are added to new displays:

From commerce_cart.views_default.inc:

$handler = $view->new_display('default', 'Defaults', 'default');
$handler->display->display_options['title'] = 'Shopping cart';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
  'quantity' => 'quantity',
  'commerce_display_path' => 'commerce_display_path',
  'line_item_title' => 'line_item_title',
  'commerce_total' => 'commerce_total',
);

// Ignoring relationships...

$handler->display->display_options['style_options']['info'] = array(
  'quantity' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
      'align' => '',
    'separator' => '',
  ),
  'commerce_display_path' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
  ),
  'line_item_title' => array(
    'align' => '',
    'separator' => '',
  ),
  'commerce_total' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => 'views-align-right',
    'separator' => '',
  ),
);

  /* Field: Commerce Line Item: Quantity */
  $handler->display->display_options['fields']['quantity']['id'] = 'quantity';
  $handler->display->display_options['fields']['quantity']['table'] = 'commerce_line_item';
  $handler->display->display_options['fields']['quantity']['field'] = 'quantity';
  $handler->display->display_options['fields']['quantity']['relationship'] = 'commerce_line_items_line_item_id';
  $handler->display->display_options['fields']['quantity']['label'] = '';
  $handler->display->display_options['fields']['quantity']['precision'] = '0';
  $handler->display->display_options['fields']['quantity']['suffix'] = ' × ';
  /* Field: Commerce Line item: Display path */
  $handler->display->display_options['fields']['commerce_display_path']['id'] = 'commerce_display_path';
  $handler->display->display_options['fields']['commerce_display_path']['table'] = 'field_data_commerce_display_path';
  $handler->display->display_options['fields']['commerce_display_path']['field'] = 'commerce_display_path';
  $handler->display->display_options['fields']['commerce_display_path']['relationship'] = 'commerce_line_items_line_item_id';
  $handler->display->display_options['fields']['commerce_display_path']['label'] = '';
  $handler->display->display_options['fields']['commerce_display_path']['exclude'] = TRUE;

And so on. Then, just save the view (views_save_view()) and render the output. Commerce has a function called commerce_embed_view() that shows how to make this happen. This is slightly modified, though:

// You can get the ID after you save it.
$view->set_display($display_id);

// Set the specific arguments passed in. Optional.
$view->set_arguments($arguments);

// Prepare and execute the View query.
$view->pre_execute();
$view->execute();

// Return the rendered View.
return $view->render();


Extending an existing Plugin class results in Class not Found PHP Fatal Error

There is no D8 commerce_usps module yet. I found a development version on github, I pressume you're using this one.

The use statement uses the following structure use [namespace]\[classname]

So your use statement needs to be

use Drupal\commerce_usps\Plugin\Commerce\ShippingMethod\USPS

class ForExample extends USPS { ...


Display extra information adjacent to system_settings_form() output

I think this must be

// ...inside drupal_get_form callback
// $form has some form elements in it

if (!hay_problemas()){
  $form['warning'] = array(
    '#attributes' => array('class' => array('warning')),
    '#markup' => t('WARNING:  Filesystem permission are broken'),
    '#weight' => -10, //set position relative to other $form['key']
  );
}

return system_settings_form($form);


Filter views by current user taxonomy profile field

Because this is a comma separated text field, your best bet is with custom module that gives your view the ids in a 2+6+36+98 format.

https://drupal.stackexchange.com/a/222876/53677

In that answer, I described how to pass one value from a user field. For you, you'd need to load the taxonomy entity and work with that.

Then, to do multiple, you just need to add a bit of php to split your text field and turn it into the format above with +. You still only pass one argument and in your view, enable multiple values in the contextual filter's settings.

I can't give a longer answer until tomorrow. Btw, if that text field has node ids for books, you should use the entity reference module.


Cannot create a views for show content revision

The node_revision table doesn't contain a column for type, so you can't add the content type filter here. So don't fill in a content type for now and create the View for all types. Then add a relationship to Content in the ADVANCED section. Now all node fields are available in the View and you can add a filter for the content type in FILTER CRITERIA.


You should already have a path for this at drupal.dd/content/[author] based on how you have setup the contextual filter. If you are using a contextual filter, they will get appended to the path of the view, and it sounds like your view has a path of "/content".


You may need to share tables across database. You can read this note on how to share tables across instances. Though its not a good solution of what you want.

You can also use Services module to achieve this.


The module configuration page is just the one on /admin/config/content/honeypot, which has the following settings.

If you expect to see a difference on protected forms, there isn't anything visible. The module creates a form element that is hidden to users, but tools that automatically fill the form will fill also that, making clear they aren't human users.
The module also doesn't accept a form submission before time limits seconds are passed from the moment the form is rendered.

If you are testing a form using a user account with the administrator role, that has the Bypass Honeypot protection permission, so you will not see any hidden form element even watching at the HTML markup of the page.


User contributed image gallery, per node

You could just use the modules:
http://drupal.org/project/references
and
http://drupal.org/project/nodereference_url

This would work if users create new images as nodes. With the help of the second module you achieve that the relation between image node and parent node is automatically created and it also allows to set a link directly on the parent node (a la: create image for this content).

I don't think that you would need EVA in this case. The view to show all images per parent content is straightforward with one argument based on the relation.

What I describe above is pretty much the way you would have done it in Drupal 6 as well. You might get additional features (and maybe complexity) using the module entity reference and EVA.

Hth.


Achievement Popup notification doesnt appear on cache page

Thanks everyone for helping on this issue . I finally got it working by a small hack . Authcache does'nt render page from cache if there are outstanding drupal messages . so when the condition for popup is met i , put drupal_set_message('!', warning) . The next page is avoided from cache to display the drupal message ( which I hide by css ) and the pop up . subsequently on clearance of messages the autcache begins fetching cache until the next condition of pop up is met .


MSSql or SQL Server Wrapper for custom module?

Since you didn't specify a Drupal version, I'll try to answer for both Drupal 6 and 7.

Drupal 7

See http://drupal.org/project/sqlsrv

Drupal 6

Even if there would be SQL Server integration in the official db-api, it wouldn't help you much because with Drupal 6, you can only connect to multiple databases of the same type. This is why https://github.com/dereine/views_pgsql was created for example.

However, it might be an option to use the DBTNG project, which is a backport of the new Drupal 7 database abstraction layer and use that in combination with the sqlsrv project. I haven't tested that but it could work. And if not, maybe with a few changes (which you could contribute back)


Try uc_order_status_list

Parameters:

$scope - Defaults to all, but you may specify the scope for the order statuses you want listed based on their corresponding order state. Possible values are - all, general, specific, or any order state id.

$sql - Pass this parameter as TRUE to alter the return value for a SQL query.

$action - By default, this is empty. Since order statuses are cached, you can pass in 'rebuild' to reload the contents from the database if you are making changes to statuses on a page load.

Return value:
The return value will be either an array of status arrays (containing the keys id, title, state, and weight) or a string containing an array of status ids for use in a SQL query.


I need to group a view by first initial (A,B,C) but both A and a are considered separate groups

In Drupal 8, a workaround is with twig. Choose the option to Override the output of this field with custom text and then use twig to capitalize.
{{ my_field|upper }}


How to avoid custom module hook_node_presave being overriden by a profile module node_presave

The order of a module's hook invocation is determined by its weight. In Drupal 7 this set in the weight column in the system table.

This can be updated through SQL query by setting your module's weight to the heaviest (last) value.

# Update with the appropriate values for your install
drush sqlq "UPDATE {system} SET weight = [your_preferred_weight] WHERE type = 'module' AND name = '[your_module_name]"'

Or using a module like Modules weight if you need a UI.

See the Drupal.org documentation for more info..


How to make diffrent registration form for diffrent role

Multiple Registration module is the answer. I haven't tried it, but here is what it says

  This module adds ability to create role-specific registration pages.
  Example of situation when this module could help you:

  You need to create two user registration pages. One for general users
  and one, let's say, for hosters. You need to add several specific
  fields for hoster registration page and these fields should not be
  available on general user registration page. Furthermore, if you need
  some hosters fields only on user edit page, without showing these
  fields on registration page, this module could help you too.

Profile2 is another option. It lets you add different fields for different roles which are not part of user entity as opposed to above module.


Enable the Ajax in Views Basic Setting and remove $view->set_use_ajax(TRUE); and check.


There are compatibility problems with jQuery 1.6.x & D7. If you'd like to know the details here's the current outstanding feature request for it.


How to display unanswered questions when using the Answers module?

The demo site related to the 7.x.-4.x version of the Answers module uses a further enhanced version of the most recent dev release. Some of the views have been enhanced and will be pushed to D.O soon. These views are available already in Views Export format via files attached to comment #5 in issue #2783513).

The (new) view related to the questions has a tab titled "unanswered", which contains the list of all questions that are "unanswered".

So to actually answer your question, I suggest you experiment a bit with the updated view of questions as contained (in export format) in the issue mentioned above.

Disclosure: I'm a co-maintainer of this module.


How can I invoke hook function after the block is loaded?

To change the order of which module's hook will fire first when more than one module implements the same hook you can use hook_module_implements_alter(). It was created for exactly this kind of situation.


You have few options:

Use hook_views_data() to hook your custom tables with Views.
Use Data module as it features automatic integration with Views.
Reorder your setup to use Drupal's node type/user profile/entity, which has Views support out of the box.

Doing it really manually will be a waste of time, unless you need some very specific functionality that can be hardly achieved by using Views for it.

Views will also provide you with caching, paging and it will be easier to maintain it in the future.


Unknown directories /pipermail /poll accessible in Drupal 7

Drupal is a Dynamic Content Management system unlike old style files and directories where you find path specific directory.. Various features are available from modules in Drupal... Modules implements menu paths using hook_menu...

For your case, module exposes permissions settings which you can set in "admin/people/permissions" for different roles... Login as admin and access above page to set access permissions..


How do I know if I installed latest version?

You could try drush pm-updatestatus drupal and see if you get any results.


Adding a final review page to entityform, before submit

Rob, I created Entityforms.

  As far as I can see the preview page, on entityforms, is shown AFTER
  the data is saved.

Actually when the "preview" page is shown the submission hasn't been saved yet.


As an admin, how can I view individual user permissions for individual nodes?

You can use "Devel Node Access". After enabling it, you can add it as a block. It shows you a table with detailed permission for each content.


How can I use LESS in a subtheme in Drupal 6?

I am looking for a cleaner answer to this as well but I have found I need to create a main.css.less file in the subtheme and copy all the references which use the new subthemes variables (lib.less) and then they work.

Without copying the main.css.less into the subtheme the new variables don't work.

Maybe this is the correct way, but it doesn't feel right to me.


How to hide my hook_menu items from the navigation menu?

I think what you need is MENU_CALLBACK in 'type.

It's for hidden items like API calls that don't want to go in menus

https://api.drupal.org/api/drupal/includes%21menu.inc/constant/MENU_CALLBACK/7


need path of an image created using an image style

You can use image_style_url($style_name, $path)

Example:

$img_url = $node->field_image['und'][0]['uri'];
<img src="<?php print image_style_url("thumbnail", $img_url); ?>" />

Where you will be replacing thumbnail with the image style name you have in place


It seems there is no single remove command, so you need to:

Edit your composer.json file, e.g.

vim ~/.composer/composer.json

and remove line containing drush. Save the file.
Update Composer PHP packages by:

composer global update

It will remove a globally installed drush.

If you don't have composer command in your PATH, try php composer.phar instead.

See: How to remove a package from composer?.


The XML Sitemap module doesn't rebuild sitemaps on every node save/load; also, it's not cached like other artifacts in Drupal.

The module tracks XML Sitemap links and they are added/removed upon cron runs. So you'll need to run cron to rebuild your sitemap files.

You can also follow some of the steps in the Setting up your site map (7.x) documentation:

  Under "Inclusion" change "Excluded" to become "Included"
  To add pages linked from menus to the sitemap, visit the edit page for each menu whose items should be included (this would usually
  include the Main menu). Open the XML sitemap fieldset, and similarly
  change "Excluded" to "Included". Hit Save.
  Once that is all complete, go to Configurations --> Search and Metadata --> XML Sitemap
  Click on the Rebuild Links tab in the upper right
  Click on "Rebuild sitemap" even if the message says that you do not need to.
  Now you're taken back to the config page which shows you the link to your xmlsitemap which you can click and confirm that pages have
  been added


Table names without using curly brackets

You should always keep the curly brackets in there, if only for maintainability and portability of your system. What if the next release of Drupal requires those curly brackets? I'm not saying it will, but if a framework gives you guidelines it does so for a reason; you should probably follow them.

As for the performance benefit, I think you'll find it's negligible at best. db_query() runs this statement regardless of whether your string contains curly brackets or not in the first instance:

$query = db_prefix_tables($query);

So db_prefix_tables() will get run on the string regardless of whether or not your table names actually need prefixing or not.

I'd advise stepping through db_prefix_tables() and using that to decide whether or not you should remove the brackets for performance reasons; you'll probably be making your decision based on the performance of the lower-level strtr() function, which does all the string replacement work.

There's a condition in that function that depends on a global variable not being empty to continue...if you want to 'turn off' the database table prefixing (and limit any inherent performance losses), ensuring that the global variable ($db_prefix) is empty when you run your query would probably do the trick (though that might make your data susceptible to race conditions; it depends on your setup).

Make sure you don't turn $db_prefix off for the entire site permanently though, or you'll have to go through all core and contributed modules and remove the curly brackets from their queries too!


There is no specific module to do this but using as you mentioned Views, views exposed filters and taxonomy will give you what you want.


Link manually uploaded file to files-private folder

With the private file system you cannot link direct to the file path because navigation of the private files directory is prohibited.

You have to link to drupal's private file handling url, which will then check that the current user has the correct permissions to view the private file and if so grants them access and gives them  the file.

To utilise this you need to use drupal's system/files path.

So if your private files directory is files-private and you have a file files-private/filename.txt you would link to /system/files/filename.txt and drupal will handle the rest.

[Edit]
The above is still valid information, however to answer our question, yes the files need to be in the file_managed table otherwise file_file_download(), which handles private file downloads, will skip over your files because it uses file_load_multiple() to try to load your file from the database.

file_load_multiple() uses entity load and system_entity_info() defines the database table file file entities as file_managed.


Can't get Corresponding node references to work

Solved! It turns out that CNR does not support other languages than English in the stable version. I just installed the dev version and now it works wonderfully. Thanks for maintaining this useful module!


parent is not supported in Drush 9 aliases, but there are a couple of facilities that you can use.

Variables such as ${env.home} or ${foo.bar} can be used to inject environment and configuration values from Drush configuration into alias files.

An environment named common in any sitename.site.yml file will have its attributes copied into every environment defined in the same file.


How to display only the status message to anonymous users in page.tpl.php

This seems like a similar question to yours regarding printing messages. Additionally, this indicates that the message type is stored within the message object. You should just be able to iterate through a message object to get it. Something like

foreach (drupal_get_messages($messagesVariable) as $type => $messages) {
    if (($status_heading[$type] != 'error') || ($status_heading[$type] != 'warning')) {
        *perform your given action here*
    }
}


Why does my drupal 7 redirect me to the home page from any link?

It looks like you redirected the default user login page to somwhere else.

When I go to http://www.gelpalhano.org/?q=user, I get a HTTP 302 moved temp, followed by a 301 moved perm, followed by a 200 OK to http://www.gelpalhano.org/site/ (what appears to be your homepage).

Generally clean-urls would fail because your .htaccess if not configured properly, or because your web server is not configured properly. I saw your web host's headers say that the server is of type Microsoft, so I would not be able to suggest a fix for your particular setup (I only use the LAMP stack).

I can suggest however that to regain back access to your site, you substitute www.gelpalhano.org/?q=user for www.gelpalhano.org/?q=[the relative path to your user login page], and then once you've logged in, you can go to www.gelpalhano.org/?q=[the path where you turn on/off clean urls] and turn them off while you trouble shoot the issue. IMHO, this is a server setup issue, and I think you have more chances of having your issue resolved by researching and posting the same question at serverfault.com. Good luck and hope that my answer helps.


Adi provided a good answer. So update the code with:

drush up drupal

But after that always preform database updates (if required):

drush updb


try function form submit like:

function my_module_form_submit($form, &$form_state) {
  $line_max = variable_get('user_import_line_max', 1000);
  ini_set('auto_detect_line_endings', true);
  $filepath = $form_state['values']['file_upload']->filepath;
  $handle = @fopen($filepath, "r");
  // start count of imports for this upload
  $send_counter = 0;
  while ($row = fgetcsv($handle, $line_max, ',')) {
    // $row is an array of elements in each row
    // e.g. if the first column is the email address of the user, try something like
    $mail = $row[0];
  }
}


How to format QueryPath Xpath Mappings in Feeds Module

The context should be the outer most wrapper of each item, so if your XML is

<ooh>
  <occupation>
   <title>Some Title</title
  </occupation>
</ooh>
<ooh>
  <occupation>
   <title>Another Title</title
  </occupation>
</ooh>

The context would be //ooh and the children of 'ooh' would be entered as occupation and occupation/title.

If occupation is the outermost wrapper of each item like:

<ooh>
  <occupation>
   <title>Some Title</title
  </occupation>
  <occupation>
   <title>Another Title</title
  </occupation>
</ooh>

The context would be //occupation and the title would be entered as title


Just figured it out. I found this. All I needed was to flush all caches.


How to animate set of titles of a View using JQuery

Salam :). You need no new Views display type. Create a view of the latest news called it lnews and display it in a block, suppose it's machine name is block_0. select the titles as the Fields. You have to use PHP code inside that block (enable PHP Filter module). Use this code

<?php
$views = views_get_view("lnews");
$views->set_display('block_0');
$views->execute();

Now to get the titles use this code (to get the accurate code use kpr($views))

$setOfTitles = "";
foreach($views->result as $view)
     $setOfTitles .= $view->node_title."*";
$setOfTitles = rtrim($setOfTitles , "*"); // to remove the last `*`

So far you created a string of all of the titles which they are separated by a * sign. There is one more step left, Send this variable to a .JS file that contains

$(function(){

    $("#typed").typed({
        strings: [HERE IS YOUR STRING],
        typeSpeed: 30,
        backDelay: 500,
        loop: false,
        contentType: "html",
        loopCount: false,
        callback: function(){ foo(); },
        resetCallback: function() { newTyped(); }
    });

    $(".reset").click(function(){
        $("#typed").typed('reset');
    });
});

code, then explode the string to an array and send it to the strings object.

To send $setOfTitles variable from the above block to the JS file here is a few tutorials

How to pass values from php to javascript properly?
How to send variable from .php file to .js file in Drupal 7?
How to pass a PHP variable to javascript in Drupal 7

Now I assume you have successfully sent the variable to .JS file, call it's name var titles. use split() function to convert the string in to an array. Now this code should work:

var array_of_titles= titles.split("*");
$(function(){
    $("#typed").typed({
        strings: [array_of_titles],
        typeSpeed: 30,
        backDelay: 500,
        loop: false,
        contentType: "html",
        loopCount: false,
        callback: function(){ foo(); },
        resetCallback: function() { newTyped(); }
    });

    $(".reset").click(function(){
        $("#typed").typed('reset');
    });
});

This solution wont link the titles to the node page. The

foreach($views->result as $view){
     $setOfTitles .= $view->node_title."*";
     $setOFNIDs .= $view->nid."*";
}

creates list of node IDs. You can also pass the node IDs to the JS file and with some js processing link the titles to the /node/nid.

For example in the JS file instead of creating array of title create array of TITLE

UPDATE:

Sounds you had problem with sending the $setOfTitles variable to the javascript file. Use the following method:

In the PHP code I gave you above add this code

drupal_add_js(array('variableName' => $setOfTitles), 'setting');
drupal_add_js(path_to_theme().'/js/js.js');

Create a file in /js directory of your theme folder and rename it to js.js and in the js.js use this code

(function($, Drupal){
  Drupal.behaviors.backgroundAnimation = {
    attach: function(context, settings) {
      alert(Drupal.settings.variableName);
      alert(Drupal.settings.basePath);
    }
  };
})(jQuery, Drupal);

I tested this solution and it successfully alerted the variableName and basePath. So just insert the rest of the Javascript code I gave you above in the (function($, Drupal) function.


In your template.php the hook_theme implementation should look like that:

function dupublic_theme($existing, $type, $theme, $path) {
  return array(
    'page_node_form' => array(
      'template' => 'page-node-form',
      'render element' => 'form',
    ),
  );
}

Notice that in the return array 'render element' key is without underscore, and there is no 'arguments' key in Drupal 7 version of hook_theme(). It is replaced by 'variables' key, but the documentation states that:

  Each information array must contain either a 'variables' element or a
  'render element' element, but not both. Use 'render element' if you
  are theming a single element or element tree composed of elements,
  such as a form array, a page array, or a single checkbox element.

Another point that I notice is, that you used in your page-node-form.tpl.php file statements like:

<?php print drupal_render($form['title']);?>

I prefer to print the elements like that, and recommend you to do so:

<?php print render($form['title']);?>

It's a new function in Drupal 7 and it calls drupal_render() but first checks if the passed element is an array and also calls show() function if the element is set hidden.


LIghtbox2 hide header and footer regions

Not answering directly but proposing an alternative solution here:

If possible, switch to Colorbox, extend it with Colorbox Node and use it to easily display your nodes without header and footer like this:

My Example


Modifying a module's function from another module

All theme functions can be overwritten in template.php by replacing theme with phptemplate.
so your function in template.php should be like

phptemplate_nice_menu_build


Its not at all difficult. I tried it in Drupal 7.22

Goto Configuration => Site Information => Site Name =>

My Site This is my new website

Add whatever tags you like to have. But remember site title itself is already inside  tag, which means you have some restriction (Span tag is not container).

This is what it looks when I inspect it using firebug in mozilla.

In your case, its Good4You. Just by using css you can do the magic.


Modify node in hook_node_view() for Drupal 7

You can do this by implementing hook_node_view.

For example:

function my_module_node_view($node, $view_mode, $langcode) {
  switch ($node->type) {
    case 'my_node_type':
      $node->content['extra_link'] = array(
          '#weight' => 10,
          '#theme' => 'link',
          '#path' => 'path_to_content',
          '#text' => t('An extra link'),
          '#options' => array(
              'attributes' => array(),
              'html' => FALSE
          ),
      );
      break;
  }
}


How to change the order of attributes in the Ubertcart cart page

By looking at ubdercart's theme_uc_attribute_add_to_cart function and how it is themeing the output including attributes, it appears that you can achieve what you want by implementing hook_form_alter. I would start by finding the form_id, perhaps by adding a debug statement in the function. Then I would implement hook_form_alter and would alter the way the attributes are ordered to my desired order.
If this does do what you want, try and follow the logic to see where the attributes are being themed and/or built. Then hook into that mechanism (form_alter or a preprocess function) and  I am confident you will achieve what you want.
Hope this helps.


which: command not found

I don't really use Drush,  but that looks like it's dying when it uses the "which" command to locate PHP...  Drush is falsely reporting that PHP can't be found,  but it's because the command it uses to look for it ("which") is not available.


Disable language code in URL for default language

Under "admin/config/regional/language" you will see the list of languages. Click the edit link to edit the languages. In the edit screen, change the "Path prefix language code". If French is your default language, then keep this value blank for French.


Drupal local configuration clone. Only home page is accessible

I did face with a similar problem when moving my site from local machine to dev server. but here is what i did

Install Backup and Migrate to download the existing database and Backup and Migrate Files to your local drupal installation.
Go to http://local-site/admin/config/system/backup_migrate and then backup the default database and local files to download

Install fresh copy of drupal with new database at the server(or to the location where you are cloning.
Copy from http://local-site/sites/all/modules and http://local-site/sites/all/themes to their respective directories at the server(or your cloning destination)
Enable both the modules in step 1, from http://local-site/admin/modules
Go to http://cloned-site/admin/config/system/backup_migrate/restore and restore the database and local files by browsing for the exported data at step 2

and don't forget to enable the theme which you used on the local-site before using backup and migrate.


How can I add a class to a title of a view?

If you're using Views 3, you should be able to click on Style Settings on the field, Customize field HTML.  From there, you can set H1 as the HTML element or click on "Create a CSS class" to add a class.


@ is the error control operator, what it does is suppress notices/warnings and even script halting errors. You see it most commonly used with variable comparisons where the person coding didn't bother to check if a variable is set first.

if (@$unsetVar != $var) {
  @$unsetVar .= $non_existent_variable';
}

Suppresses the warning that $unsetVar is not initialised.

The proper way of doing this though would be using isset($unsetVar) to check that this variable is in fact initialized first, if not don't do anything with it, or assign it a default of some kind. Then neither the comparison or the concatenate will throw errors. Keeping this in mind can prevent some show stopping bugs later down the line as your applications become more complicated.

I'd personally advise against using @ wherever possible, if there's a notice/warning/error it's usually for a reason, using @ is a lazy fix and can make debugging a pain if something does go wrong.

Tl;dr, I'd avoid using @ where possible.


programmatically check if any field in a node is edited

what you could do is add custom validate handler and in there load node

$my_node = node_load($form_state['nid']);

What this will do is load node with values that are currently in the database. of course you should make sure that above is not invoked if you are adding new node.

Now, you have your 'old' values in $my_node and 'about to be saved' values in $form_state['values']. Loop through both and compare values.

This is not the most effective way but it should work.

Use debug() from devel if you are not familiar with $form_state['values'].


Running simpletest tests with clean urls on nginx

You should rewrite Drupal 7 URLs using  rewrite ^ /index.php last;. The more complete setup is (copied from my development setup):

server {
  listen 80;
  listen [::]:80;

  root [...];
  index index.php;
  server_name [...];

  location = /favicon.ico {
    log_not_found off;
    access_log off;
  }

  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  }

  # Deny all attempts to access hidden files
  location ~ /\. {
    deny all;
    access_log off;
    log_not_found off;
  }

  location / {
    try_files $uri $uri/ @rewrite;
  }

  location @rewrite {
    # Some modules enforce no slash (/) at the end of the URL
    # Else this rewrite block wouldn't be needed (GlobalRedirect)
    rewrite ^ /index.php last;
  }

  # pass the PHP scripts to FastCGI server listening on my unix socket
  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 256 16k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
    fastcgi_read_timeout 1200;
    # With php5-fpm:
    fastcgi_pass unix:/var/run/php5-fpm.sock;
  }

  client_max_body_size 100M;

  location ~ ^/sites/.*/files/styles/ {
    try_files $uri @rewrite;
  }

  location ~* \.(js|css|png|jpg|jpeg|gif|ico|woff|ttf|svg|eot)$ {
    expires max;
    log_not_found off;
  }
}


Is there any way to make a menu link *not* a link?

You can try the Special menu items module.

One of its features is:

  User can create a new menu item and place either <nolink> or <separator> to the Path field


Setting node title as view argument/path

I'm not sure if I understood you question but I think the answer is:

In Arguments set Node: Nid as argument. Then set Provide Default argument and choose NODE ID from URL.

Here are all the steps.

You have 2 different views to your node.

Normal view. URL-> mydomain.com/node/%nid/ shows your node content
Feed view. URL -> mydomain.com/node/%nid/tsv shows your feed.

But when you navigate to mydomain.com/node/%nid/tsv it does not work right? So what you're asking is how you "create" this URL in order to show the feed... is that it?

If that's the case, in VIEWS2:

Create a new PAGE display.
In Page settings (bottom left corner) there's an option called PATH. Set this to node/%/tsv.
Still in Page Settings theres an option called menu. Set this to Menu Tab if you wish to show a tab linking to your view. | view  | TSV |
In Arguments set Node: Nid as argument. Then set Provide Default argument and choose NODE ID from URL.
Validation set Basic Validation (or Node Type if the Feed is only available to certain node types)
In fields, select the fields you wish to show.
Add a filter to node published (to show only if the node is published) and a filter user role (to limit access to certain users)

And that's it... when you navigate to mydomain.com/node/%nid/tsv it shows the fields you selected.


change the list option based on the selection type

Seems like you are looking for Conditional Fields module...

  Conditional Fields allows you to manage sets of dependencies between
  fields. When a field is “dependent”, it will only be available for
  editing and displayed if the state of the “dependee” field matches the
  right condition. When editing a node (or any other entity type that
  supports fields, like users and categories), the dependent fields are
  dynamically modified with the States API. You can, for example, define
  a custom “Article teaser" field that is shown only if a "Has teaser"
  checkbox is checked.

See below image displayed in project page which suits your requirement.. Hope above module solves your problem..


BaseFieldDefinition setDisplayOptions ... type = 'string_textfield' ... unable to set default placeholder or size?

I think you need to be calling "setSettings" on the field, not passing the settings as a part of the display options.


$_FILES is

  An associative array of items uploaded to the current script via the HTTP POST method.

file_save_upload() takes as its first parameter

  A string specifying the filepath or URI of the uploaded file to save.

Your code essentially does this

$file = file_save_upload($_FILES, $validators, 'public://');

So you're currently passing an array to a function that's expecting a string.

You're probably looking for something along the lines of

$file = file_save_upload($_FILES['file']['name'], $validators, 'public://');


How can I delete old entries in locales_source

One way to get rid of unnecessary entries in locales_source is to run the following:

DELETE locales_source
FROM   locales_source
LEFT JOIN locales_target lt
using (lid) where lt.lid is null;

To get an idea of what this will remove from the table, you could check using:

SELECT count( * )
FROM locales_source
LEFT JOIN locales_target lt
USING ( lid ) WHERE lt.lid IS NULL;

I got the idea from : http://julian.pustkuchen.com/en/drupal-7-performance-blown-localessource-table

In my case, I had a lot of stale content in locales_source. I also had many pages where content was tagged as being translated, but the page included many call t('...') calls, which added unnecessary entries to the table. Long story short, I was able to safely remove over a million rows of data and site performance went from absolutely awful to humming along nicely.

YMMV, but it worked for me.


How to customize the webform field validation message?

One solution here is the String Overrides module.

  Provides a quick and easy way to replace any text on the site.

  Features

  Easily replace anything that's passed through t()
  Locale support,
  allowing you to override strings in any language
  Ability to
  import/export *.po files, for easy migration from the Locale module
  Note that this is not a replacement to Locale as having thousands of
  overrides can cause more pain then benefit. Use this only if you need
  a few easy text changes.

For your case, you can override the Phone module's default error message. By placing this string in this string:

  "%value" is not a valid North American phone numberNorth American
  Phone numbers should only contain numbers and + and - and ( and ) and
  spaces and be like 999-999-9999. Please enter a valid ten-digit phone
  number with optional extension.

And substituting whatever you need it to display.


The flag you are looking for is persistent_cache, field_cache is no longer used, that documentation is a bit out of date. You're welcome to update it :)

See the API documentation of the EntityType class for a up to date list, maybe that documentation page should just link to that instead of trying to maintain a duplicate list.

That said, unless you have almost as many or more writes/changes to your entity type as loads, I'd considering changing your architecture and either update the entity type through the API or invalidate the changed entities. But there can be cases where that doesn't make sense, e.g. because of mass updates and if those entities aren't very frequently. But for example displaying them in views can be quite slow if they need to be loaded all the time.

Also, speaking of views, while render_cache disables the caching of viewing an entity, I don't think it disables views row-level caching. Maybe it should, you should consider opening a core issue for that if you need that, otherwise your rows will still return cached output even if the entity is changed.


Adding Pager to entity referenCED field display

There might be better way of doing that.

But one of the way will be to use views module

Answer to question 1:

Go to your_site/admin/structure/types/manage/content_type/display
Change the reference field format to Rendered entity
Click the setting and make sure Show links is checked

Answer to question 2:

Install the module views if you don't have it already
Go to yoru_site/admin/structure/views/add
Give your view name for example read more button to parent content type
Unchecked Create a page and Check Create a block
Click Continue & edit
Change format to "Table"
Click add filed and select the fields you want to show
Click add Filter criteria and select the criteria you want
Click the Advance and Add Contextual Filters
SelectContent  Content: Nid"
Select Relationship as content entity referenced from your_xyz
Change the option for When the filter value is NOT available to Provide default value and select Content ID from URL.
Change When the filter value IS available or a default is provide to Specify validation criteria and select Content from Validator select field, and select the parent content.
Make sure Filter value format  is = to Node ID
Make sure Action to take if filter value does not validate is = Hide view
Click Apply
Add a Relationship, Click add and select Entity Reference
Click Save.
Go to yoru_site/admin/structure/block, search for the new view name black you just added.
Click configure change the Visibility settings  to content type and select the parent content type.
Set the Region where you want the black to be display.


If you do it like this, with the system.module callback for the parent item, you get the nice listing page when you visit 'admin/config/mymodule'

/**
 * Implements hook_menu().
 */
function MYMODULE_menu() {

  $items = [];

  $items['admin/config/mymodule'] = [
    'title'            => 'My configuration section',
    'description'      => 'This is the parent item',
    'position'         => 'left',
    'weight'           => -100,
    'page callback'    => 'system_admin_menu_block_page',
    'access arguments' => ['administer site configuration'],
    'file'             => 'system.admin.inc',
    'file path'        => drupal_get_path('module', 'system'),
  ];

  // Need at least one child item before your section will appear.
  $items['admin/config/mymodule/item'] = [
    'title'            => 'First item',
    'description'      => 'This is the first child item in the section',
    'page callback'    => 'mymodule_item_callback',
    'access arguments' => ['administer site configuration'],
  ];

  return $items;
}


hook_apachesolr_process_results having no impact on results

Grr. Someone outside of StackExchange suggested a few routes of debugging that would weed out issues having to do with interaction of my code with other code. One of those suggestions was to go back to a default theme and see if my change showed there. It did. I talked to my themer to see if he had any insight.

And, that's when we hit the "a-ha" moment: We were using a custom theme based off of Fusion. (Incidentally, when I switched to stock Fusion, everything worked correctly.) At that point, it was just a matter of flipping through all of the "Appearance" settings to find that under search results none of the checkboxes were ticked. Guess what happened when I ticked the "snippet" checkbox?? Yeah....

Though, we did learn something good here, at least: If you create a new theme as a custom sub-theme of an existing theme, your subtheme does not inherit the settings of its parent theme.


Taxonomy Menu Associated with a single content type

Please take a look at https://drupal.org/project/views_groupby. You should be able to:

Create a new view that has a filter of 'books' content type
Add a filter to ensure the node is published
Add a views group by to group on taxonomy term
Use the SQL count funtion built into views group by

Hope this helps


If you are able to build an entity query for the group members you can use $query->pager(). See block to display nodes using entityQuery with pager

If not, you have to calculate the pager variables yourself. There is only one example for a pager in core that is not using a pager query, the taxonomy terms overview OverviewTerms::buildForm. Or you can use pager_default_initialize().

And a third and probably quickest solution is to build a view for the group members.


Hiding nodes based on geographical location

I'm going to assume that you wouldn't mind writing a custom module for this. Lets call it say, my_mod. The use-case you have mentioned is perfectly suited to take advantage of the Drupal Node Access system.

A few assumptions:

You have a vocabulary, Locations that houses a growing list of locations with which either a user or a piece of content on your site can be tagged with.
Attach a Taxonomy Term Reference field field_location with this vocabulary to both products and users.
Say for a given user, based on his access, you "guess" his location from his IP and set/append this field for him.

Then all you need to do is let Drupal know that users can only see products that have been tagged with the locations that they are a part of using the Node Access hooks as shown below.

/**
 * Access realm that defines access control to content by user location
 */
 define('USER_GEOGRAPHY_REALM', 'user_geography');
 /**
  * Taxonomy term reference field. Allows tagging a user/node with a
  * a given term from the "Locations" vocabulary.
  */
 define('LOCATION_FIELD', 'field_location');

/**
 * Implements hook_node_access_records().
 */
function my_mod_node_access_records($node) {
  $grants = array();
  $items = field_get_items('node', $node, LOCATION_FIELD);
  // In the USER_GEOGRAPHY_REALM access realm, we say that a user
  // who has the grant ID equivalent to the {taxonomy_term_data}.tid of
  // a term with which the node was tagged is allowed to see it.
  foreach ($items as $item) {
    $grants[] = array(
      'realm' => USER_GEOGRAPHY_REALM,
      'gid' => $item['tid'],
      'grant_view' => 1,
      'grant_update' => 0,
      'grant_delete' => 0
    );
  }
  return $grants;
}

/**
 * Implements hook_node_grants().
 */
function my_mod_node_grants($account, $op) {
  if ($op == 'view') {
    // Reload to make sure fields have been attached.
    $account = user_load($account->uid);
    $gids = array(USER_GEOGRAPHY_REALM => array());
    $items = field_get_items('user', $account, LOCATION_FIELD);
    // In the USER_GEOGRAPHY_REALM, a user's grants are the different
    // locations that he is a part of.
    foreach ($items as $item) {
      $gids[USER_GEOGRAPHY_REALM][] = $item['gid']
    }
    return $gids;
  }
}

You are free to extend the logic to include per-location limits for a user if you'd like.

You may have to remember to disallow the user from editing his own Location field and can use hook_field_access() for this purpose.


Hide status messages generated from Commerce - Not required with use of Ajax add to cart module

I believe you're referencing the "Display an Add to Cart Message" Rule.  Looks like:

To disable this go to:
Configuration > Workflow > Rules > Disable - Display an Add To Cart Message.


HTTP Client Manager $request->getStatusCode() == 200 return?

The information from https://www.drupal.org/docs/contributed-modules/http-client-manager/introduction was wrong and was updated, now:
   if ($request->getStatusCode() != 200) {
      return $build;
    }


Is it bad to add js and css in template_preprocess for a custom block?

Generally, yes, you should use ['#attached'] in renderable arrays to add assets in a cache-compatible way. $block['content'] can be a renderable array if you make it an array instead of a string, so you're not too far off here. I'm not sure exactly what you're doing inside video_widget_add_js(), but if it's just adding a bunch of assets, then consider implementing hook_library() instead. Library implementations are attachable in ['#attached'].

In your case, however, the attached assets aren't your only problem. With block caching enabled, a cache hit bypasses hook_block_view() completely, instead retrieving the previously compiled $block array from cache. Since you use $node = menu_get_object() in hook_block_view(), you probably need the block to vary by page. However, the default block cache setting is DRUPAL_CACHE_PER_ROLE, which only varies by a user's role combinations.

You could set your block to cache with DRUPAL_CACHE_PER_PAGE instead, but the easiest thing to do without refactoring a bunch of your code is to set your block to DRUPAL_NO_CACHE.  DRUPAL_CACHE_PER_PAGE isn't hugely efficient anyway unless you have a lot of authenticated user traffic.

To set a particular cache setting on a block, edit the hook_block_info() implementation:

/**
 * Implements hook_block_info().
 */
function leadership_block_info() {
  return array(
    'leadership_all_companies' => array(
      'info' => t('Leadership block'),
      'cache' => DRUPAL_NO_CACHE,
    );
  );
}


Can't disable css caching and aggregation

Does your theme use the core Color module? I believe that module compiles and caches CSS files with the updated color values whenever the theme color pallet is changed. Just an idea.


How do I calculate outstanding balance for product inventory?

Balance Tracker creates a balance sheet to display account credits and debits belonging to users. It can be integrated with views.

  It also provides UI tools, Views integration, and an API to allow the
  site administrators or other modules to credit or debit a user's
  account. This is intended for any website or service which credits
  users for accounts, sales, or other activities, and needs to track
  payouts.

I'm not using this before. Hope it helps you!!!


Limiting node access to certain users based on an entity reference field. Which hook to use for when node is viewed?

In similar situation I used hook_entity_access. Also there is hook_ENTITY_TYPE_access so you can use the hook_node_access.


Cloning a Drupal website without content

Have a look at Config Installer. It allows you to the initial install already based on your exported configuration and so replaces step 2 and 3.

One problem is that you might notice that there is more "content" or non-configuration stuff than you'd think (unfortunately). Menu Links created in the UI are content, aliases are content, translations are stored in a separate table too, Taxonomies/Terms as well (Fine for something like a free-tagging field, but they are often used to define fixed structures as well, like sections on a news site).


Redirect anonym user after click on link

ok i found solution, i just changed link for anonym user

if ($view->name == 'questions_by_category' && $view->current_display == 'page') {
        if ($user->uid) {
            $vars['header'] = '
' . l('Ask your question', 'node/add/question') . '
';
        }
        if ($user->uid == 0) {
            $vars['header'] = '
' . l('Ask your question', 'user/login') . '
';
        }
    }


What can cause a site to hang when deleting a user?

For me, this has happened when there is a misconfiguration on hook_user in a custom module. Specifically, check all of your implementations of hook_user to make sure there are no functions that lead to additional calls for hook_user.

That is, if you have a module that calls foo_do_magic_to_user() under hook_user (or, some other function that hits hook_user), and foo_do_magic_to_user() calls user_save(), then you have an infinite loop on your hands.

Update

If you're absolutely certain that it's not a hook_user loop, then there could be any number of module-associated hangups. These often involve external services that are non-responsive (e.g. sending a "Goodbye" email but sendmail (or equivalent) isn' set up properly).

In your shoes, I would try:

1) Disable all non-core modules and see if the problem persists. If this still happens with only core modules, then you might have a deeper and more fundamental issue (correct version of PHP?)

2) If not #1, then re-enable contrib modules one-by-one and see which one is causing the issue. Inspecting that module's hook_user should give you a good clue as to what the root issue is. Most likely, one of the modules is calling some other service that is non-responsive.


There are two ways to do this:

Through PHP. This is the correct way. The code below would go in your theme's .theme file.

function YOUR_THEME_preprocess_links(&$variables) {
  // Determine which links should be removed. These are CSS classes, because
  // they are used as keys in the $variables['links'] array.
  $links_to_remove = array(
    // X comments link.
    'comment-comments',
    // X new comments.
    'comment-new-comments',
    // Add new comment.
    'comment-add',
  );
  // Loop through the links and remove them.
  foreach ($variables['links'] as $css_class => $link) {
    if (in_array($css_class, $links_to_remove)) {
      unset($variables['links'][$css_class]);
    }
  }
}

Through CSS. This is not the best way, but is faster:

.your-node-selector .node__links li.comment-comments,
.your-node-selector .node__links li.comment-new-comments,
.your-node-selector .node__links li.comment-add {
  display: none;
}


Text fields can store JSON data since JSON, by definition, is a serialized format. This is provided the JSON data fits the size of your text field. If you go this route, you should make sure your field is validated for valid JSON before saving and is under your storage limits.

If you want something more versatile, you might want to add your own custom field with the Field API. There's also the JSON Field module, but it only has a D8 release.


How to show a block on a set of subpages except one of them?

There's nothing in the core UI, no.
hook_block_list_alter() exists for exactly this sort of scenario, though:

Act on blocks prior to rendering.
This hook allows you to add, remove or modify blocks in the block list. The block list contains the block definitions, not the rendered blocks. The blocks are rendered after the modules have had a chance to manipulate the block list.

e.g.
function MYMODULE_block_list_alter(&$blocks) {
  if ($some_condition) {
    // Remove the block from the list.
    unset($blocks[$some_key]);
  }
}


Content type with multiple different flavours

You can use taxonomy to categorize the content. If you want categorize the content like form, policy, abuse etc... create a taxonomy vocabulary name as Document Type then add form, policy, abuse etc... as terms in it. Then Add a term reference field(in D7) in manage field settings. And also you can use Conditional Fields for display fields according to the document type.


How to implement node.js For updating data in my block?

node.js is event based. While implementing node.js have you implemented socket.io & express or you followed any other setup? By any means what you have to do in high level is,

Catch events on node CRUD or vote or if someone comments. Send these events to node server. Then emit those back to the clients.
In the front end your client javascript should listen to those events that you emit from the node server itself. Once you get those emitted events to your client just use jQuery/JavaScript in your client Javascript to update your block contents.

This is a highlevel algorithm that you have to follow. You can update your question with snippets of your code and may get more detailed answers.

EDIT # 1
Try to look in http://socket.io/get-started/chat/ for the event based implementation.
In that example you can see, a file called index.js. This is the node.js server file. And the index.html is the client. In both the files there are some events which are emitted. So I assume in your code you can add onclick function to emit an event to server. Then in the server you have to fetch the updated value. Then again emit a server event that will be received by the client.
I hope this makes sense. Well the implementation can become very complex.


Content type which contains a content creation as a slip form

You may use Organic groups module

  Enable users to create and manage their own 'groups'. Each group can have subscribers, and maintains a group home page where subscribers communicate amongst themselves.

"event-coordinator" will be group administrator and he will create and edit any content in the group. "audience" will be usual group member and he will edit only own content in the group


How to hide a field in a views row if the row is about content type article?

One of solutions is using Views Conditional module

  Views Conditional is a simple module that allows you to define
  conditionals (if xxx then yyy) with fields in views. Conditions
  include:

Equal To
Not Equal To
Greater Than
Less Than
Empty
Not Empty

  Views conditional allows you to output text based on the result of the
  condition.

  How to use Views Conditional in your Views:
  1. Create a view. Add some fields under "FIELDS".
  2. Click on "ADD" next to fields. Scroll down to "Views: Views Conditional", probably found near the bottom of the list.
  3. Add and configure fields...
  4. Choose a field to run a condition against, and provide values accordingly.
  5. Save, views conditional handles the logic and returns as specified.

For findout how it work  at Views Conditional Module (Drupal 7 Tutorial) - YouTube


In a view of products, add the word "Added" to all products already added to the cart

Sorry for the late answer, I meant to answer this, but for some reason got lost and today this Q just randomly popped into my mind.

If you think creatively, you can accomplish this using CSS like this:

1) Create an attachment clone of your cart, by clicking the +Add button and selecting attachment. Remove all fields and add a unique field to it, such as SKU. (Make sure you use For: this attachment override, so you don't affect your actual cart view).

2) Rewrite your SKU field to be like this

3) In in the header section of your products view, add the attachment clone of your cart.

4) In your Products view, wrap each product inside a div class that has the SKU#

...

You could try doing the re-writes through the Views UI, else you can use a template file (hopefully you know how to use template files in Views).


Mapping field columns with D8 migrate and d7_node source plugin

Something like this:

  body:
    plugin: iterator
    source: body
    process:
      value: value
      format:
        plugin: default_value
        default_value: filtered_html


How to set a node reference programmatically?

After updating the value in your entity metadata wrapper you need to be sure to also call the save() method to save your change. See this documentation on drupal.org.

Since you have an object, and not an id, the following should work.

// Set value for a single value field.
$nc_wrapper->field_comm_relationship = $oc_wrapper->field_call_site_ref->value();

or

// Set value for a multivalue field. Make sure to pass an array of objects.
$nc_wrapper->field_comm_relationship = [$oc_wrapper->field_call_site_ref->value()];

or

// Append an additional value to a multivalue field.
$nc_wrapper->field_comm_relationship[] = $oc_wrapper->field_call_site_ref->value();

and finally

// Save the host entity.
$nc_wrapper->save();

If you have ids, check out this answer. You can get an id instead of an object from the entity metadata wrapper like $oc_wrapper->field_call_site_ref->raw() instead of ->value();

Additional info for entity metadata wrappers can be found in this Death to Field Arrays! article.


you can use this module to import taxnonomy terms with any translations Taxonomy CSV import/export


If you are running on Gnu/Linux or Unix, you should be able to position yourself above the directory holding your code and use the following shell command:

grep -r print_r .

This will recursively search through the current directory and all the directories below it for the string "print_r" and print out all lines containing that string, prefixed with its file name.

For future debugging, I suggest you install the Devel module for debugging.  At least one of its debug printout functions (dpm()) will print where the debug statement is placed by name of file and line number if the object is complex enough to produce a Krumo accordion display of the object/array.

For simpler objects, use the second argument to dpm() to remind yourself where you placed it. E.g.:

dpm($uid, 'mymodule, line 42, $uid');


How can I move taxonomy terms to a different vocabulary and update term reference fields?

This tutorial suggests doing it via directly performing SQL queries to change the associated vocabularies for the terms in question.

The term reference fields should be by term ID. The term ID should not be changing, only the vocabulary value associated with the term entity.


Show 'log in' in user menu when not logged in

You can add a menu link to user/login, the access callback of that verifies that it is only shown to anonymous users. Just like user/logout is only visible for logged in users.

The definition of these callbacks() are, as mentioned in the other answer, in user_menu()


OBSERVATIONS

Default Drupal installations use MyISAM storage engine
Most plugins assume MyISAM storage engine for tables
Many have switched to InnoDB

What tables should or could be migrated to InnoDB, and which should remain MyISAM?
How do I convert a database from MyISAM to InnoDB?
FULLTEXT indexes not supported in InnoDB in MySQL 5.5
FULLTEXT indexes are supported in InnoDB in MySQL 5.6 (when it goes GA)

If is straightforwards to convert MyISAM to InnoDB, such as with the following:

ALTER TABLE node ENGINE=InnoDB;

Not so with NDB. For the table node, let's take the following approach:

mysqldump -u... -p... dbname --no-create-info node > node_data.sql

Then, load the table into the NDB Cluster

mysql -u... -p... -Ddbname -A < node_data.sql

and you let all the management nodes and SQL nodes determine where to store/shard the data.

If and only if you have the patience to

upgrade Drupal
avoid using FULLTEXT indexes (currently not supported by NDB)
apply plugins

drop FULLTEXT indexes
convert any MyISAM tables to NDB

migrate/reload data

then it is worth a shot.

Please post NDB Cluster questions in the DBA StackExchange.

DISCLAIMER : Not Drupal Expert, Not CMCDBA (not Cluster Certified), just CMDBA


Show content of type A in content of type B based on shared taxonomy term using views

Add a block view to show content of type A (products), add a contextual filter Content: Has taxonomy term ID, provide default value with PHP:

$node = node_load(arg(1));
return $node->field_term['und'][0]['tid'];

You can add safeguards, like is_int(arg(1)), is_object($node), $node->type == "product", etc. You don't need to if you add the block to a region and set it to be displayed on nodes of type B (producers) only.


I can't uninstall modules with Drush master-branch and almost no data on Google

The problem is not with Drush is with admin_menu. This is a bug on admin_menu not been ready. See more about this - admin_menu has broken d8-beta11 and i cant pm-uninstall

How to solve it ?

  (note, deleting the module rm -r modules/admin_menu and rebuilding
  cache brings the site back)

Source

Steps by Step Instructions

Open your terminal
Change directory to you root Drupal 8 core
Then remove the admin_menu project and then clear the cache.
rm -rf modules/admin_menu # Remove the directory.
drush cr # This will clear the cache

admin_menu is not ready, I will recommend you to use admin_toolbar for now.


Why the commit is not shown in the issue after it is closed as fixed?

It is more likely the case that the service that handles the issue updates was down for some period of time. Under normal circumstances pushing a commit to D.O. will update the issue referenced in the commit message no matter what the issue status is set to...


owerflow:hidden;

you missed spelled overflow

overflow: hidden;


Restricted nodes don't show up in search results

The default Drupal search respects the Drupal permission system, so if the user performing a search doesn't have permission to see a node, it won't appear in search results at all. To get around this, you'll need something that circumvents the permission system, either by altering the search function, or replacing it entirely.

You could take a look at the Custom Search module. It modifies Drupal's search, and gives you control over the default search options. However, I can't recall if it includes an option to show content you wouldn't otherwise have permission to see.

The other way you could do it is to create a custom view, add a filter for the field you want to search on, then under advanced, select "query options", and tick the "disable query rewriting" option. This will prevent the permissions from being applied to the view, so will allow users to see nodes they don't have access to. However, I'm not aware of any way of making a view search multiple fields from a single exposed filter, making it less than ideal for an alternative search box.


From the Drupal 7 API theme_search_result:

  This function is never used; see the corresponding template file
  instead.

Try overriding the page using search-result.tpl.php


View with multiple value fields: suppress display of repeated column values

The answer was obvious. For the Entity Reference type of field, don't use fields from the referenced entity (like e.g. "Title") from a relationship. Instead, use the field from the main entity (without relationship). As a result, it displays a title of the referenced entity anyway and not an ID or something.

But in this case, the field gets "Multiple Field Settings" config group, which should be set to "Display all values in the same row". I saw that solution before, but in my view there wasn't this config group at all. That's because I used a field from relationship, which apparently doesn't have a setting for multiple value, because in that entity it's single value, it's a title.


The publish date can change, like after unpublishing and republishing some content. The post date is rather fixed, it's the date the content is created...


What is the purpose of the user_data table?

This table is the backend for the User Data service. The User Data service is used to store data specific to users in the system.

You can set data like this:

\Drupal::service('user.data')->set($module, $uid, $key, $value);

Where:

$module = the machine key of your module

$uid = the UID of the user for whom data should be retrieved

$key = a key to identify which data you are storing

$value = the value to be stored

This data can be retrieved with the get() method:

$value = \Drupal::service('user.data')->get($module, $uid, $key);

$value will be equal to the $value you used when setting the data.


Query Database to Fill Dropdown Form API #states

You have the same variable ($options) for both fields. Use $options for $form['education']['year'] and $options1 for $form['health']['year'].


Drupal 7 is a lot different than Drupal 6 in many ways. What used to be called CCK, now called "fields in core" or "fields" is also different. Not all of the features that was in CCK is available in Drupal 7 fields, some are, but contrib modules is needed.

Regarding using PHP default values, I don't know of a module that does this. It's possible with hook_form_alter in a custom module, but this might not be what you are looking for.

I don't know of any way to gray out fields when editing an entity, other than again using hook_form_alter. The field permissions module might be able to help you, to deny users the ability to edit the field. It would then disappear entirely, but that could be a possible solution.


You can change the the text in view, in the settings of the field "Node:link"


Easiest way to add color to a title field?

Why not play with the styling? You can add text shadow or 50% dark transparent background to the text or add text outline as demoed here: http://css-tricks.com/adding-stroke-to-web-text/ All these options will give you a better contrast.


How to have a node which displays & interacts differently with different type of users?

There are many ways to accomplish this but here's one:

create content type Book
create content type Review
add a custom status field to Review (select list) and add the three states (admin approval, author approval, approved)
download and enable references module (also enable submodule node reference)
download and enable rules module (also enable rules ui submodule)
add a node reference field to Review (e.g. autocomplete widget)
create roles admin_reviews, author, reviewer
create view lists for reviews content and set permissions per role for admin_reviews, author and reviewer pages. Filter on field status of review for each role
use field permissions module to show / hide fields per role

create rules to set status of review (After saving new content -> set data value)


Unable to save contents once a  tag is added

Solved the problem. It has absolutely nothing to do with images. The web hosting company configured modsecurity and it broke the way Drupal does POST in some instances.