Twig conditional render if specific field in array of referenced entities contains text

I'd always do data checks on the entity object (in this case node), and not on the render array content. The second part is the magic .entity to get the linked referenced entity from the host's entity reference field:
{% set render_something = false %}
{% for field_item in node.field_entity_reference %}
  {% if not field_item.entity.field_to_check.isEmpty %}
    {% set render_something = true %}
  {% endif %}
{% endfor %}

{% if render_something %}
  <div class="my_wrapper">
    ...content...
  </div>
{% endif %}

Be warned though data behind .entity is usually not cache-safe (but it is cache-safe in this special case with Paragraphs, because their revisioning is directly tied to their host entity)


How to get node id in a block_view theme page?

You want menu_get_object() to obtain the node object when visiting a node page.


Clear example on how to use #theme for form API

You're so close...the name of the render element is arbitrary, it's just a name so you can pick it up at the other end. Or, put more eloquently:

  The name of the renderable element or element tree to pass to the theme function. This name is used as the name of the variable that holds the renderable element or tree in preprocess and process functions.

So:

function MYTHEME_theme() {
  return array(
    'custom_func' => array(
      'render element' => 'my_element',
    ),
  );
}

function MYTHEME_custom_func($variables) {
  $element = $variables['my_element'];

  // Use the values in the $element render array to build markup.

  return $element;
}


In Drupal Commerce you can just make product types and it will generate product displays (content types) meant for building the presentation. The product type holds all the meta data about the product itself.


Adding a form to a product drupal commerce

Your looking for product variations. Here are the official docs.

  Product attributes are the descriptors we use to define kinds of
  products. For example, we could describe a tshirt by the color and
  size. These attributes mean that in the real physical world your store
  may only carry one red shirt, but you have three sizes or three
  "variations." Commerce software must deal with product variations in a
  flexible way. Here's how Drupal Commerce abstracts it:

  Product Types. A product type is a specific bundle based on a custom
  product entity. Each bundle can have fields attached to it, including
  pictures and other kinds of information.<

  Product "Informational"
  Fields. Any field on a product can be a simple "informational" field.
  Typical informational fields include an image of that specific
  configuration of a product. For example, if you sell a tshirt with a
  cool print in multiple colors, each product with a different color
  could have an image field that, when displayed on the product display
  node, will change when you select different attributes (like color).

  Product "Attribute" Fields. Any field on a product type with a defined
  list of options (list of text options, list of taxonomy terms, list of
  colors). The attribute fields are special because of the way they turn
  into selection widgets on a product display. Often you will pair an
  attribute field (like a color dropdown) with an information field
  (like an image field) to let the user "select" the blue tshirt and the
  Drupal Commerce system will quickly load the picture associated with
  the blue product.

  Product Displays. If needed at all, these are
  groupings of products. You can reference any type and number of
  products on a product display. In order to make use of product
  displays, we recommend only showing one type of product per product
  display. The product display is where you typically see the product
  with drop downs to "configure" or "order" the right kind of product.

For the different pricing of the variations refeer here: Automatic product variations pricing.


Multiple upload image using managed_file

In Drupal 8, add '#multiple' => TRUE

Example:

$form['images'] = array(
  '#type' => 'managed_file',
  '#upload_location' => 'private://images/',
  '#multiple' => TRUE,
  '#upload_validators' => array(
    'file_validate_extensions' => array('png gif jpg jpeg'),
    'file_validate_size' => array(25600000),
    'file_validate_image_resolution' => array('800x600', '400x300'),
  ),
);

More about form api: Introduction to Form API


Lots of permissions errors, should the entire site be set to www-data?

You should never give the files directory 777 permissions unless your workin on a local machine. Still then it is bad practice.

Every file in the system needs to be readable by the system user your webserver is using. Every directory should be readable, writable and executable by the same user. The same could be said for the webserver group.

I always set the user to my local user and the group to a group that is readable by my user account & the webserver account. The files directory (and his subdirectories) could be set to a simple 775 so the user and the group have permissions to it. All other users should only be able to read & execute the directory.
As for the files inside the files directory, they should be readable and writable to the local user and the webserver group & only readable for all other users. They should be set to 664.

The same could be said about your private directory, which I just noticed in your error post.


Create a rule at the event of "Cron maintenance tasks are performed"?

you could use hook_cron_queue_info to create a task that sits in a queue and happens on a timer. This would account for the potentially long duration of the task you mention.


Image getting delete away by the cronjob later in drupal 7 using theme settings

A quote from the docs:

  Note: New files are uploaded with a status of 0 and are treated as temporary files which are removed after 6 hours via cron. Your module is responsible for changing the $file objects status to FILE_STATUS_PERMANENT and saving the new status to the database. Something like the following within your submit handler should do the trick ...

You would need to put the example code that follows in the docs, into a function that you add as a submit handler:

$form['themeA_settings']['header-page']['header_background_file'] = array(
  '#type' => 'managed_file',
  ...
  '#submit' => array('your_custom_submit_handler'), // <-- This line is new
);

The function itself could look like this then:

function your_custom_submit_handler($form, &$form_state) {
  // Load the file via file.fid.
  $file = file_load($form_state['values']['my_file_field']);
  // Change status to permanent.
  $file->status = FILE_STATUS_PERMANENT;
  // Save.
  file_save($file);
  // Record that the module (in this example, user module) is using the file.
  file_usage_add($file, 'user', 'user', $account->uid);
}

You can of course reuse that function for all your files.


How to display select query results using ajax in a form in drupal7

Without specifics it's tricky to answer your question but here's a very basic example:

function MYMODULE_some_form($form, &$form_state) {
  $form['select'] = array(
    '#title' => 'Option',
    '#type' => 'select',
    '#options' => drupal_map_assoc(array(1,2,3)),
    '#ajax' => array(
      'wrapper' => 'some-form-results-wrapper',
      'callback' => 'MYMODULE_some_form_ajax'
    )
  );

  $form['results'] = array(
    '#prefix' => '
',
    '#suffix' => '
'
  );

  // If the form has been submitted, build up your results and display them
  if (isset($form_state['values']['select'])) {
    $rows = db_select('some_table', 't')
      ->fields('t')
      ->condition('some_field', $form_state['values']['select'])
      ->execute()
      ->fetchAll();

    $header = array();

    $form['results']['#markup'] = theme('table', array('header' => $header, 'rows' => $rows));
  }
  else {
    $form['results']['#markup'] = '
The results will appear here when you change the dropdown option.
';
  }

  return $form;
}

function MYMODULE_some_form_ajax($form, &$form_state) {
  return $form['results'];
}

You might want to check out the ajax_example module included as part of the Examples module, it has a lot of code and comments that will help you understand what every piece of the above example does.


How to display time with different field in calendar?

Solved this by adding field group in calendar style display.

Added time field in views and edit the settings of calendar style plugin. There is a option to group field by hour. I selected my field.


$form_state values show node title instead of integer

Whatever you set as the array keys for options will be the values, so if you want to see option content rather than value, you need to set it up like that:

$form['select_field'] = array(
  '#options' => array('Text' => 'Text', 'More Text' => 'More Text'),
);

Or, leave the numeric keys where they are, and refer back to the original options array in your submit handler:

$selected_index = $form_state['values']['select_field'];
$display_value = $form['select_field']['#options'][$selected_index];

If you go with the first option, drupal_map_assoc() will probably be useful.


Role can't see CKeditor options on Body field

After some trial-and-error, changing role permissions, I was able to narrow things down.

I have a module called Simplify installed. When the permission "View hidden fields" is UN-checked, the role cannot see CKEditor. When I check that, everything works as intended.


Kernel Base Test: Create node content types and taxonomy vocabularies via configuration?

Here is documentation for using the configuration.
So for example, if you want to load Tags Vocabulary you will do:

$config = \Drupal::service('config.factory')->getEditable('taxonomy.vocabulary.tags');
$description = $config->get('description');

$description contains the description of the vocabulary. In this way, you can load what you want from the yml file.


How to change "Add new node" button label?

I suggest you take a small form_alter sample module code and start changing in it. Pl also see this video.

You can also do it easily using String Overrides module.


How do you use 'drush site-install' to install a multisite with separate databases using a single command?

In the link you provided, @greg_1_anderson mentioned using --sites-subdir. This option is used to create a site folder under <DRUPAL_ROOT>/sites/.

For example, if you run drush si --sites-subdir=example1.com, it will create a example1.com folder under <DRUPAL_ROOT>/sites/, settings.php will also be generated in this folder. It contains the database configuration.

Since it is a multi site structure, you may not want to share the same database. You have to specify the database information with --db-url.

For example:

DB: MySQL
root username: username
root password: password
host: localhost
table name: example

You can specify above information with --db-url=mysql://username:password@localhost/example.

A more complex example involving setting more sites for a multi-site configuration could be the following.

drush si --sites-subdir=example1.com --url=mysql://username:password@localhost/example1
drush si --sites-subdir=example2.com --url=mysql://username:password@localhost/example2

Moreover, if you want to have different database credentials for different sites, you can dynamically create the separate username and password at the same time.

drush si --sites-subdir=example1.com --url=mysql://user1:newpassword1@localhost/example1 --db-su=username --db-su-pw=password
drush si --sites-subdir=example2.com --url=mysql://user2@newpassword2@localhost/example2 --db-su=username --db-su-pw=password


Dynamic select lists (dependent dropdowns)

On your callback function, you need to setup a callback help. Basically getting your form data. Now my code is for D6 so some functions might be slightly different but check this out.
I left some of my tweaks in there. You'll just have to adjust accordingly.  but the big thing is the callback helper function.

function MOD_js_callback() {

// use of ajax callback helper to set form variables again
$form = MOD_callback_helper();

// grab form['datacenter_devices'] data and drop into changed_elements
// simply to not confuse rebuilt form with 'global' form
$changed_elements = $form['datacenter_devices'];

// Prevent duplicate wrappers.
unset($changed_elements['#prefix'], $changed_elements['#suffix']);

// concat status_messages and call drupal_render to render elements array for output.
$output = theme('status_messages') . drupal_render($changed_elements);
drupal_json(array(
    'status'   => TRUE,
    'data'     => $output,
));
}
function MOD_callback_helper() {

$form_state = array('storage' => NULL,'submitted' => FALSE);

$form_build_id = $_POST['form_build_id'];
$form = form_get_cache($form_build_id, $form_state);
$args = $form['#parameters'];
$form_id = array_shift($args);
$form_state['post'] = $form['#post'] = $_POST;
// Enable the submit/validate handlers to determine whether AHAH-submittted.
$form_state['ahah_submission'] = TRUE;
$form['#programmed'] = $form['#redirect'] = FALSE;
drupal_process_form($form_id, $form, $form_state);

$form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);

return $form;
}


There is a bug in dashboard.module.

Quick and silly solution: disable, uninstall, enable and reconfigure again the Dashboard module. Remember: You will lose all dashboard settings you made :)


Node reference: Select an exisiting node, or create a new one


How to include a form in a listing page?

The quick and dirty way to print a form defined by hook_form is to use the drupal_get_form function:

print render(drupal_get_form('content_form'));


Custom block that's always the first thing in a region?

Your "custom HTML wrapper" is only useful for the Javascript, so you are looking at this the wrong way: the HTML generated by Drupal should not contain it, and it should be the job of the Javascript to transform the markup of the region to fit its use.

You probably want something like this:

$('<your selector>').each(function() {
  // Wrap all the content of the region inside a wrapper.
  $(this).wrapInner('
');

  // Create a link and insert it into the region.
  var link = $('
' + Drupal.t('Click here') + '
');
  link.prependTo($(this)).click(function() {
    // Your custom logic.
  });
}


Taxonomy view - showing term searched for in header

I think @Neograph734 has eluded to the answer here.

If you add a field for taxonomy term name but don't display it (exclude from display), you can add a header field of type "Global Text" and render the term name from the collection of tokens that are representing the fields.


How to preserve kint output upon form submit redirection?

Use ksm() instead of kint().

I ran into the same issue when I want to inspect the entity after saving, using drupal's hook_entity_presave and kint

I found this article on how to print variables using kint() which explains that ksm() prints the output inside the drupal page (not before as kint()) does.

So this example prints the entity without redirecting:

function mymodule_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
  ksm($entity->toArray());
}


What does extension-provided configuration mean in Config Snapshot?

As commented by Clive,

  “Extension” seems just to be being used as a catch-all term for
  modules, themes and installation profiles. Those three are the only
  things that can provide config outside of core, so it seems a safe bet


how to create custom template for a product type in drupal 8 commerce

by default drupal 8 uses commerce-product.html.twig. you can find it from modules/contrib/commerce/modules/product/templates/ and copy and paste it to your template folder in your theme.

and to create separate template file for each product type you can add --product type at the end of file name. for example if you have shoes product type then you should create a file commerce-product--shoes.html.twig.

then drupal uses the new template for shoes product type only.


Actually, user_save() returns a user object, not TRUE. If it doesn't return FALSE, then the function was successful and you can use the returned object to log in that user.

For example, supposing that $user is the user object returned from user_save(), you can use the following code to replace the currently logged in user with that user (the code is for Drupal 7).

drupal_save_session(FALSE);
$original_user = $GLOBALS['user'];
$GLOBALS['user'] = $user;

// Do what you need.

$GLOBALS['user'] = $original_user;
drupal_save_session(TRUE);

The code can be used to do some actions impersonating another user, or when a user follows a link reported him in an email, which allows the user to log in. In the latter case, the last two lines should be removed from the code executed.

Without setting the value of $GLOBAL['user'], there isn't any way to let Drupal think a user is logged in.

user_authenticate() is not working because you are not passing the password for that account. In fact, Drupal doesn't save the password in any places; it saves the hash of the password, but that is not what user_authenticate() needs, as reported from its documentation page:

  Parameters

  $name User name to authenticate.

  $password A plain-text password, such as trimmed text from form values.

  Return value

  The user's uid on success, or FALSE on failure to authenticate.

The function passed its $password parameter to user_check_password(), which execute the following code:

  if (substr($account->pass, 0, 2) == 'U$') {
    // This may be an updated password from user_update_7000(). Such hashes
    // have 'U' added as the first character and need an extra md5().
    $stored_hash = substr($account->pass, 1);
    $password = md5($password);
  }
  else {
    $stored_hash = $account->pass;
  }

  $type = substr($stored_hash, 0, 3);
  switch ($type) {
    case '$S$':
      // A normal Drupal 7 password using sha512.
      $hash = _password_crypt('sha512', $password, $stored_hash);
      break;
    case '$H$':
      // phpBB3 uses "$H$" for the same thing as "$P$".
    case '$P$':
      // A phpass password generated using md5.  This is an
      // imported password or from an earlier Drupal version.
      $hash = _password_crypt('md5', $password, $stored_hash);
      break;
    default:
      return FALSE;
  }
  return ($hash && $stored_hash == $hash);

As you see, $account->pass is used as stored hash of the password, while you are passing that value as password.


How can I allow users to search for other users based on profile information

You can achieve this by using views contextual filters.

or you can use advanced search for users

http://www.yoursite.com/search/user

set the user permission accordingly to view advanced search


Drupal 8 CKEditor dynamic internal links plugin?

I'm the maintainer for Linkit module.

Linkit 8.x-5.x is solving the problem you describe with static URL:s.

The new version is using data-attributes (UUID and some other values) that calculates the URL in "run time".
That solves the issue.

Remember to also enable the Linkit filter in your text format configuration.
Also, make sure that the data attributes are added to the HTML filter allowed values if you use that filter.


Service to browse all contrib modules on drupal.org

This excellent script written by rocketeerbkw will create a text file containing the name of every d.o contrib module, giving you everything you need to get started:

/**
 * Download a full list of all modules on drupal.org by using the API. More info
 * at https://www.drupal.org/about-drupalorg/api.
 */
$url = 'https://www.drupal.org/api-d7/node.json?type=project_module';
$modules = array();
do {
  print $url . PHP_EOL;
  $options = array(
    'http' => array(
      'user_agent' => 'get_list_of_modules.php from https://github.com/rocketeerbkw/drupal_function_stats',
      'header' => 'Accept: application/json',
    ),
  );
  $context = stream_context_create($options);
  $response = file_get_contents($url, false, $context);
  $data = json_decode($response);
  foreach ($data->list as $module) {
    $modules[] = $module->field_project_machine_name;
  }
  $url = isset($data->next) ? $data->next : FALSE;
  // The next links are always provided without a format [#2253947].
  // Formatless URLs are 301 redirected to format URLs but strip all query
  // query parameters [#2364755].
  $url = str_replace('node?', 'node.json?', $url);
} while ($url);
$file = fopen('project_usage.txt', 'w');
fwrite($file, implode("\n", $modules));
fclose($file);

An example output is here:

https://raw.githubusercontent.com/rocketeerbkw/drupal_function_stats/master/project_usage.txt

Once you've got that data the only tasks are deciding where/how to store it, and creating the UI to manage it.


How can I programatically change the color of node title in views results?

An easier (and more maintainable) way to achieve this would be to set a class in your span, instead of hardcoding the style. Something like the following:

$span_open = '<span class="my-title">"';

You can then add a CSS file to your module, so that you can better specify the color, also overriding the a tag. For instance:

.my-title, .my-title a {
  color: green;
}

For more details about adding CSS to your module, see https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_add_css/7.x


Is there an easy way to include a Facebook remarketing tag in my D7 site?

Turned out to be very simple. All I had to do was paste the code into the <head> part of html.tpl.php from within the /templates/ folder.


Access A Referenced Node's Fields - Field Level Templating

In item.content is a render array and usually you can access a referenced entity in a '#' key (for most display settings):

{{ item.content['#node'].field_name.value }}

Field Object

Another way to get the field values is using the field object in element['#items'] and loop through the FieldItemList:

{% for item in element['#items'] %}
    {{ item.entity.field_name.value }}
{% endfor %}

Then you are independent from the display settings of the field.

For background information see this blog post from Berdir https://www.md-systems.ch/blog/techblog/2017/02/20/twig-and-entity-field-api-or-how-to-take-control-of-nodehtmltwig for the difference between formatted output and the underlying objects. In a field template you don't need to go back to the parent node object, because you can access directly the field object. You can get the parent node from element['#object'] though, if you want to access other fields.


In your screenshot above there is a "Send to all Affiliates" checkbox and then checkboxes for each individual domain. If you leave the "Send to all Affiliates" checked it overrides the individual checkboxes.

So, the solution for you is to uncheck the "Send to all Affiliates" checkbox.


This specific signup type is called OpenID. And it allows an external login provider to login users on your site.

You can have a look at OpenID Connect module. Which has a beta version for Drupal 8 available, and according to the module page already ships with a Google implementation.

  OpenID Connect 1.0 is a simple identity layer on top of the OAuth 2.0
  protocol. It allows Clients to verify the identity of the End-User
  based on the authentication performed by an Authorization Server, as
  well as to obtain basic profile information about the End-User in an
  interoperable and REST-like manner.

I am not sure about Facebook, but it might be that is in another contrib module or easy to implement yourself. (I didn't look for it.)


Commerce Recurring framework with customizable products

Make a version of the product for each period:

Toothbrush (Monthly)
Toothbrush (Quarterly)
Toothbrush (Bi-annual)

etc.

Then, add each of those products to the product reference. Your customer will then be able to choose which subscription they want.


How can I set value to hidden field (Form Api) and send them with post method?

To summarize the question : I use an API where a SHA signature had to be sent along the form . That signature is calculated based on the other form inputs, so it had to be calculated after the user clicks the submit button and it had to be sent as a form field with POST method .

In buildForm(), I have :

$form['#action'] = 'https://url-webservices.fr/';

It is like it is executed before I can call validateForm() where I can set the value I need.

I've searched a lot for a solution but didn't find an easy way like set a news value in submitForm().

So here is a solution. I'm not completely happy with it but it works.

I've built a 2 steps forms.

In first step, the $form['#action'] is empty. After validation, I set a value to $form['#action'] and to the form fields I need :

$form_state->setValue('action', $url_action);

I also change the text of the submit button with something like "confirm".

Then user could confirm and validate the form.

All the mechanic of the 2 steps could be seen in that answer (thanx to Clive) :

How to use ConfirmFormBase to confirm the action of another form?


New scheduled rule knocks out existing scheduled rule

Make sure the Identifier for the scheduled task is unique. Adding the node ID of the node that completed the workflow could work to ensure the Identifier field is unique.

A new task will replace an existing task with the same Identifier. This happens because the Identifier value is the key each task is stored with in cron.

Check out this free video Introducing Rules Scheduler for more tips.


Add element inside main menu block, but outside navigation

To accomplish all your goals, you need to implement these three functions:

hook_preprocess_block()
theme_menu_tree()
theme_menu_link()

Create one template file for the block with your menu.

template.php

/**
 * Implements hook__preprocess_block().
 */
function YOURTHEME_preprocess_block(&$variables, $hook) {
  // allow to use block templates depend on delta
  // example: delta = main-menu ; template file: block--main-menu.tpl.php
 if ($variables['block']->delta == 'main-menu') {
    $variables['theme_hook_suggestions'][] = 'block__' . str_replace('-', '_', $variables['block']->delta);
 }
}

/**
 * Main menu
 * Implements theme__menu_tree().
 */
function YOURTHEME_menu_tree__main_menu($variables) {
    global $level;
    $div = ($level == 1) ? '
 ... some div next to the main ul ...
' : '';
    $ul = '
' . $variables['tree'] . '
' . $div;
    return $ul;
}

/**
 * Main menu
 * Implements theme__menu_link().
 */
function YOURTHEME_menu_link__main_menu($variables) {

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

  // global menu level variable.
  // within theme_menu_tree() at first level has always value = 1
  // but not here, that's why $depth will have to be defined separately
  global $level;
  $level = $element['#original_link']['depth'];

  // if you will need $depth, it must be defined separately
  // $depth = $element['#original_link']['depth'];

  // submenu
  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }

  // link output
  $output = l($title, $element['#href'], $element['#localized_options']);

  // if link class is active, make li class as active too
  if(strpos($output,"active")>0){
    $element['#attributes']['class'][] = "active";
  }

  $attr = drupal_attributes($element['#attributes']);
  return  '
' . $output .$sub_menu . "
\n";
}

block--main-menu.tpl.php

<?php
/**
 * @file
 * theme's implementation to display a block with the main menu.
 */
?>

        <?php print $content; ?>

 ... some div next to the main navigation div ...

Results


There are some other modules you can try:

Taxonomy Access Control

Taxonomy Access Control Lite

A short but good tutorial for Taxonomy Access Control is available at Control Who Can View Drupal Nodes: Taxonomy Access Control


How to rename a content type programmatically

Looking back on this after a year, I can't reproduce my own problem. This code works, even for content types defined by modules, not created through the UI:
$type = node_type_load('my_content_type');
$type->name = 'A new name';
node_type_save($type);


$zen-column-count: 10;

.container {
 @include zen-grid-container;
}
.column1 {
 @include zen-grid-item(3, 1);
}
.column2 {
 @include zen-grid-item(7, 4);
}

You include 10 columns, and use 3 for 30% and 7 for 70%. Reason being that columns are of equal width and if you want to implement two unequal columns you have to use multiples of a common denominator.


Check if the Contextual links module enabled. That could be doing it, or if Contextual links is enabled check that you have permission for your account.

This may be related: https://drupal.org/node/1450840

Also check if Views UI enabled. (if needed, may not be relevant)


I was printing the array out incorrectly. Using this code to print works:

drupal_set_message(''. print_r($submission, TRUE) .'');


Add an attribute to $variables from a Controller

Rendered output from a controller or other page elements like blocks or menus don't have direct access to the variables of a page/html preprocess hook. You can however attach metadata to the render array which then bubbles up to the page level when rendered, for example html_head or css libraries. In your case one possible way would be to attach a placeholder to the render array of the controller, which then replaces a placeholder class in the body tag. But I still would prefer to get the node via the route parameter, see the linked topic in the first comment.

A code example how to replace a body tag class from a controller. First add a placeholder class in the preprocess hook:

/**
 * Implements hook_preprocess_HOOK() for html.html.twig.
 */
function mymodule_preprocess_html(&$variables) {
  $variables['attributes']['class'][] = 'body-placeholder-class';
}

And then attach a placeholder to the build array to replace this class from the controller:

$build['#attached'] = [
  'placeholders' => [
    'body-placeholder-class' => [
      '#markup' => 'class-replaced-by-controller',
    ],
  ],
];
return $build;


As suggested in another post, I used this code:

$block = block_load('featured_content', '1');
$output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
print $output;

This worked perfectly!


How to use Views Page + Attachment to show parent and children nodes?

It sounds like you're getting stuck messing with relationships in the view - this shouldn't be needed to do what you're trying to do.  You can accomplish this with these basic settings:

Lesson: All your lesson fields + term reference to category

Exercise: All your exercise fields + term reference to category

Your view's page display just needs to be set up to display content of type lesson.

The part that I think you're missing is setting the contextual filter.

Add the contextual filter Content: Has taxonomy term ID
Provide default value -> Taxonomy Term ID from URL

Your attachment should be set to show the exercise content type.  Add the same contextual filter to this display and make sure you have inherit contextual filters checked.

This will give you a page that displays the lesson, followed by all exercises tagged with the matching category.


You find the block_content entity in the template variable elements to get the ID:

block.html.twig:

{{ elements.content['#block_content'].id() }}


Menu not showing for 1 server of two cloned servers

After a heavy duty migration like that, I would try going through the standard Drupal debugging steps first:

Clear caches.
Re-save theme settings (admin/appearance/settings/mytheme).
Rebuild permissions (admin/reports/status/rebuild)
If you are using the Features module, double check that things are identical to the old instance. You may need to revert some features components.
Check the status report and error log at admin/reports.

Good to cover your bases before you start digging deeper.


Block with the same function as page of Taxonomy term view

Set up a new view of type "node"
Give the view a "block" display (not a page)
In the "advanced" section of the view (on the right) create a relationship to "taxonomy term"
you can set up a "contextual filter" based on "taxonomy term".
The trick to making this work with a block is to select the "Provide default value" option and select "raw value from url" "path component 3". This will send in the id of the parent term from the url (works even though your term is aliased).
Go to admin->blocks and put that block in the "footer" region; set it to only appear at the url taxonomy/term/* (this will work even though your term is aliased).


Programatically altering a field formatter in Views

If you wish to display a field in a different way, there are a different ways to go about it.

Create a field template in your theme and change there. Just copying the field.tpl.php file would work changing the way the field is rendered on a node page. Note that field.tpl.php is a generic template which would be called on each field. You might want to try the specific template names like : field--article.tpl.php would get applied to all fields on article content type; field--body.tpl.php would get applied to body field on any content type; and field--body--article.tpl.php would only get applied to body field on the article content type.
Overriding the theme_field() function. E.g. Implementing the following functions in your theme's template.php file would do the same as with template copying THEMENAME_field__body__article(), THEMENAME_field__article(), THEMENAME_field__body(),
THEMENAME_field().
If the field is rendered in a view you could override it with the view template. To find out the specific template which you would need to override, click on "Theme: information" under the "Advanced" settings in the view to find the field template that applies to your field.
By creating your own custom field formatter by using this blog post. This will display the formatter in the dropdown as you intend.
There is also a module which helps your create custom formatters, which are ctools exportable. Which means you could easily featurize them. More about the module:

  The Custom Formatters module allows users to easily create custom CCK/Field Formatters without the need to write a custom module. Custom Formatters can then be exported as CTools Exportables/Features or Drupal API Formatters.


How to sort view search results by giving custom relevance weights?

Drupal core's search can't really do this. You'll need to use something like the Search API contrib module (https://www.drupal.org/project/search_api).

Search API allows you to plug in different backends ("servers") for the search database. I have the most experience with Solr, rather than the "database" backend. Solr, for sure, lets you not only choose which fields get indexed, but also how much relevance each field is awarded when a search matches. That is, you can say to index the title of the node as a Fulltext, with a score (weight) of 5, but index the body as Fulltext with a weight of 4.


Get info from entity reference using PHP

You just need to get the target_id from each of the field values, which you can do by looping through $info:

$uids = array();
foreach ($info as $field_item) {
  // Entity reference fields store their data in the 'target_id' column
  $uids[] = $field_item['target_id'];
}


You can tackle this problem from both sides, with a ckeditor plugin as @Sssweat suggested and on the drupal side with a filter plugin.

This is an example from core which adds classes to tags. This code looks for the attribute 'data-align', but you can also look for tags:

namespace Drupal\filter\Plugin\Filter;
use Drupal\Component\Utility\Html;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
/**
 * Provides a filter to align elements.
 *
 * @Filter(
 *   id = "filter_align",
 *   title = @Translation("Align images"),
 *   description = @Translation("Uses a data-align attribute on &lt;img&gt; tags to align images."),
 *   type = Drupal\filter\Plugin\FilterInterface::TYPE_TRANSFORM_REVERSIBLE
 * )
 */
class FilterAlign extends FilterBase {
  /**
   * {@inheritdoc}
   */
  public function process($text, $langcode) {
    $result = new FilterProcessResult($text);
    if (stristr($text, 'data-align') !== FALSE) {
      $dom = Html::load($text);
      $xpath = new \DOMXPath($dom);
      foreach ($xpath->query('//*[@data-align]') as $node) {
        // Read the data-align attribute's value, then delete it.
        $align = $node->getAttribute('data-align');
        $node->removeAttribute('data-align');
        // If one of the allowed alignments, add the corresponding class.
        if (in_array($align, array('left', 'center', 'right'))) {
          $classes = $node->getAttribute('class');
          $classes = (strlen($classes) > 0) ? explode(' ', $classes) : array();
          $classes[] = 'align-' . $align;
          $node->setAttribute('class', implode(' ', $classes));
        }
      }
      $result->setProcessedText(Html::serialize($dom));
    }
    return $result;
  }
}

The scaffolding of a custom filter module is very simple. See the tutorial:

https://www.lullabot.com/articles/creating-a-custom-filter-in-drupal-8


How do I use the Print Module with a Custom Form Module?

In the configuration page of the Print module at admin/config/user-interface/print, there is a section 'Show link in system (non-content) pages'.

If you select Show on only the listed pages. and enter the path of your form (glatfelter_forms/form_scorecard) in the textarea below, there will be a print link on that page.


All Blocks in One Theme Automatically Disabled

I haven't run into this specific problem, but I would advise getting as much of this as you can into Features - that way you can easily revert it all back, should this problem recur, and you wouldn't have to do it manually.


Edit meta tags per entity via field or entity property?

Yes, there is.

All you need to do is add the Meta tags field to the node types where you want to have this.


How to select sub-terms in taxonomy when creating content?

Simple Hierarchical Select is the module for the job.

  Simple hierarchical select defines a new form widget for taxonomy fields to select a term by "browsing" through the vocabularies hierarchy.

Just change the widget-type of field Tags to "Simple hierarchical select" after you install the module. This guide might come handy if you're running 7.


Views: Define table without describing it as a base OR join table?

You should be able to add a relationship by using hook_views_data. You should however not use the join, but the relationship (right below the huge php comment on the linked page):

// Node ID table field.
$data['example_table']['nid'] = array(
  'title' => t('Example content'),
  'help' => t('Some example content that references a node.'),

  // Define a relationship to the {node} table, so example_table views can
  // add a relationship to nodes. If you want to define a relationship the
  // other direction, use hook_views_data_alter(), or use the 'implicit' join
  // method described above.
  'relationship' => array(
    'base' => 'node', // The name of the table to join with.
    'base field' => 'nid', // The name of the field on the joined table.
    // 'field' => 'nid' -- see hook_views_data_alter(); not needed here.
    'handler' => 'views_handler_relationship',
    'label' => t('Default label for the relationship'),
    'title' => t('Title shown when adding the relationship'),
    'help' => t('More information on this relationship'),
  ),
);


The default Drupal setup is to display a list of all nodes that have their "promoted to front page" box checked.

If you want to display a single node rather than that list, you can create that page and then change the default front page in admin/configuration/site-information by pasting in that page's path to the front page field.

If you would like to display a list that is different from the default list, (like, you want to add filters or display fields or something) then you can install and use Views to override the default or to create a new page and set it as the main page in site-information settings as described.


How to get the input value with preprocess from a Fulltext Search Filter exposed form

Maybe not exactly what you're asking for, but the one way to approach this is to use hook_preprocess_views_view(&$variables) and modify the contents of the header, or add a variable containing the string you want and then it in above/below the header in a views-view.tpl.php template override. If the search string isn't available through $variables, you can probably grab it from the url since it's likely included as a query string.
To get the query string from the url and add it to the template variables you'd do something like the following in your module or theme:
/**
 * Implements hook_preprocess_hook()
 */
function my_module_preprocess_views_view(&$variables) {
  // Get the query string from the url.
  // it will be on something like ?the_search_string=big+banana.
  $search_string_raw = $_GET['the_search_string'];

  // Decode the url to remove special chars
  $search_string_decoded = urldecode($search_string_raw);

  // Add it to $variables so it's available in views-view.tpl.php
  $variables['search_string'] = $search_string_decoded;
}

This will make the search_string available in views-view.tpl.php. You can then print it in there with
<?php if($search_string): ?>
  <?php print $search_string ?>
<?php endif; ?>

// or

<?php

if($search_string) {
  print $search_string;
}

To clarify how hook_preprocess_hook works -- the first "hook" is your module name, and the second is the name of the template that you're targeting. Since we are targeting views-view.tpl.php, we use hook_preprocess_views_view.
In general, the easiest way to get started inspecting php variables is to dump them to the screen. For Drupal 7, I'd recommend installing https://www.drupal.org/project/kint on your site. This will let you print variables to the screen to help you dig into their values and see what's in there. You'd do like:
function my_module_preprocess_views_view(&$variables) {
  kint($variables);
  // or
  kpr($variables['header'])
}

Then you can see what's actually inside of $variables and grab/modify the values in there.


Number of paragraph items and translation

Not really in an easy way. We're working on an alternative approach to making the field translatable in the experimental paragraphs collection project: https://www.drupal.org/node/2846682.

Basically, this adds a setting to optionally control visibility of a paragraph in another language. This is a useful approach for use cases where differences between language are the exception and not the rule.

You can also build something similar yourself with a standard list field or an entity reference field to languages and then implement something in preprocess, twig or entity access to hide the paragraphs based on that.

But the only way to have completely different paragraph structures is to have the field translatable, and that's still a work in progress.


How do I add rel="nofollow" to links in blocks/menus/etc?

I think this is the module you are looking for:

http://drupal.org/project/menu_attributes

With Menu Attributes you can set the rel attribute (among many) on the admin section.


Dynamic Taxonomy Filter dropdown with childs in Drupal 7

You need to use Ajax and the drupal form api to build this type of search form.

I recommend looking at the Taxonomy Edge module to make "finding the children terms of some parent" really easy, because the SQL can be annoying. Then you can just focus on the Ajax needed. Drupal has great support for Ajax!

I recommend looking here on drupal.stackexchange to find ajax examples of which there are plenty. I'm nearly positive there is an example of this type of ajax "update the form with some new options or div" in the Drupal 7 Developer Examples module.


Add radio buttons and text field together to theme-settings.php

I think the select_or_other module is what you are looking for. it let's you create a select box or checkboxes with textfield as last option.


Views keeps crashing when I change setting

It is jquery version issue. Views is not crashing, It is returning json response which  Drupal is not handling properly due to jquery version issue. If you are using jquery_update module. Change the jquery version to 1.5 or older. If not; use this module. Latest jquery_update module allow you to set different jquery version for administrator pages and actual site nodes. Set the jquery version 1.5 or older for administrator pages and higher for actual site nodes if needed.


Interesting question, but I wonder if the Views Slideshow module can do what you're trying to achieve. Therefor you may want to consider the alternative modules, as detailed below.
Use the jCarousel module
Your question seems to be a variation of "Help with a Slideshow of Multiple Images in a Single Node", in which the Views Carousel module was recommended as a possible solution/alternative.
However the successor of that module in D7 is the jCarousel module. So maybe you want to give that module a try?
Use the Field Slideshow module
Another module to consider as an alternative, is the Field Slideshow module. Here is a quote about it from its project page:

Provides a Slideshow formatter for Image fields, using JQuery Cycle plugin.
Compared to Views slideshows, building the slideshow from multiple nodes, this module builds it from a single node, with a multi-valued Image/Media/Field Collection field.

This excerpt seems like pretty close to what is contained in the question details, no?
Curious to hear if either of these modules help somehow ...


Firstly, here are some of the ways NOT to pass links to the t() function:

// DO NOT DO THESE THINGS
$BAD_EXTERNAL_LINK = t('Look at Drupal documentation at !handbook.', array('!handbook' => ''. t('the Drupal Handbooks') .''));

$ANOTHER_BAD_EXTERNAL_LINK = t('Look at Drupal documentation at the Drupal Handbooks.');

$BAD_INTERNAL_LINK = t('To get an overview of your administration options, go to !administer in the main menu.', array('!administer' => l(t('the Administer screen'), 'admin'));

And these are the accepted ways to pass that type of arg:

// Do this instead.
$external_link = t('Look at Drupal documentation at the Drupal Handbooks.', array('@drupal-handbook' => 'http://drupal.org/handbooks'));

$internal_link = t('To get an overview of your administration options, go to the Administer screen in the main menu.', array('@administer-page' => url('admin')));

This all comes from Dynamic or static links and HTML in translatable strings, which contains justifications for that reasoning.


Can't create foreign key using SCHEMA API

Schema Reference

  Foreign key definitions were added in Drupal 7 for documentation
  purposes only, and do not modify the database.


Using drupal_goto for checkout redirection to add $_GET variable, but gets overwritten

drupal_goto should work just fine. You can confirm (e.g with Firebug) that it does the initial redirect to where you want (including foo=bar).
Then you'll see a second redirect to the plain URL which is being performed by another code/module that you haven't told us about.


$text = l('); looks wrong. "l" is function to create links, i guess thats what is failing here. Try to remove it and leave just $text = '';.

For reference on "l" see drupal api page - please note that there is also 'HTML' parametr in "l" function that you should set to true, since you are passing HTLM code in $text to that returning "l".

  'html' (default FALSE): Whether $text is HTML or just plain-text. For example, to make an image tag into a link, this must be set to TRUE, or you will see the escaped HTML image tag. $text is not sanitized if 'html' is TRUE. The calling function must ensure that $text is already safe.


Integrate core search block with search_api and Solr

I think he/she means http://drupal.org/project/search_api_page provides search blocks automatically.  You could also create view that provides that block.

You could also replace the core Search module with Search api + http://drupal.org/project/search_api_db.


What you basically need to do is add headers to your email. You can implement a solution like the one that can be found in this Drupal.org's comment. The code is pretty much straightforward:

$body = '';
$body .= variable_get('email_content');
$body .= '';
$my_module = 'foo';
$my_mail_token = 'bar';  // A key to identify the e-mail sent
$from = 'tanvir@gmail.com';
$message = array(
  'to' => '"'.addslashes(mime_header_encode('Winnie Pooh')) .'"<james@gmail.com>',
  'subject' => t('Example subject'),
  'body' => $body,
  'headers' => array(
    'From' => $from,
    'MIME-Version' => '1.0',
    'Content-Type' => 'text/html;charset=utf-8',),
  );
$system = drupal_mail_system($my_module, $my_mail_token);
  if ($system->mail($message)) {
    // Success.
  } else {
    // Failure.
  }

Keep in mind that if your needs for html mailing become more complex and you need to theme your mails using template files or filter the mails' contents after the theme has applied, you can check the HTML Mail module.


MAXVALUE is a reserved word in MySQL (Maria). Change maxvalue to topvalue or something else.


How to send monthly newsletter if the site is complex and has a lot of content types?

There are a plethora of newsletter generation modules in various states of support. But if you want a first class newsletter that your audience reads you almost certainly want to take the time to write and layout the newsletter in a tool meant for the job (Mailchimp's interface or a competitor).

Newsletter generators are very appealing and can be effective if you have lots of very targeted segmentation of your list. But most of the time if you are sending one news letter to the entire list they are more overhead than value.

Most of the use cases people look to a generator to support are signs of a poor communications strategies. For example: I want to send a daily newsletter about XYZ and don't have the time to write it carefully every day -- does your audience want get and read that much auto-generated mail? Or Laying out my message is too hard to get it right every time -- use a better email newsletter tool that does the job better.


I can't say this is the best way, but may be it may help you.. So, my approach is like this:

function MYMODULE_preprocess_node(&$variables)
{
  if ($variables['teaser'] && $variables['type'] == 'TYPE') {
    $titleField['title'] = array(
        '#markup' => '<div>' . $variables['title'] . '</div>'
    );

    array_push($variables['content'], $titleField);
    ...
  }
}


How can I wrap form content in bootstrap divs?

The way you are suggesting works fine. (I just tested it). Try to clear your cache and hard refresh the page. If you do:

<input{{ attributes }} />{{ children }}

you will have your form inputs wrapped in that div.

The other options is to use the form-element.html.twig or you can use the hook_form_alter and add prefix and suffix to your fields.


You can follow the below steps

Create a Relationship of the type "File Usage: File"
This will bring up additional Fields. You can add the filed called File: Path (Path) and select the above relationship.
Check "Display download path instead of file storage URI" This would give you the entire path. You can use the same any where in the view.

Once you add the relationship you would get additional fields related to the file. For example if you want to print the size of the file you can use the field "File: Size" etc.


The problem probably is you have two .htaccess files rewriting URLs to index.php (Drupal) or index.html (Ionic). I think you need to adjust Drupal's rewrite rule because it is in the top level:
  # Pass all requests not referring directly to files in the filesystem to
  # index.php.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.php [L]

For example by adding this condition:
RewriteCond %{REQUEST_URI} !^/webapp


Is it possible to make a nested Search API query?

The AND ((field1 = value AND field2 = value) OR (field1 = other_value AND field2 = other_Value)) IS possible with sub-filters. For anyone else who ends up here trying to sort this out (as I did before working out the correct solution) you can create the above like this:

$filter = $query->createFilter('OR');

$subfilter1 = $query->createFilter('AND');
$subfilter1->condition('field1',value);
$subfilter1->condition('field2',value);

// Add this subfilter to the main filter.
$filter->filter($subfilter1);

$subfilter2 = $query->createFilter('AND');
$subfilter2->condition('field1',other_value);
$subfilter2->condition('field2',other_value);

// Now add the second subfilter
$filter->filter($subfilter2);

// Apply the filter to the query.
$query->filter($filter);


How to customize the default search block form template?

The search block is provided by the core module Search. If you install this module the block will be available in the block layout, when you place a block.

Probably you have already done this by installing the standard profile.

To customize the search form you can use a form alter hook.

For example put this function in mytheme.theme to change the search button:

function mytheme_form_alter(&$form, $form_state) {
  if ( $form['#form_id'] == 'search_block_form' ) {
    $form['actions']['submit']['#value'] = t('Search my Website');
  }
}


How some hooks works, if doesn't return anything and doesn't have any references

The $account variable is a PHP Object.

In PHP, Objects are (for the most part) passed by reference, so any changes you make to the variable passed in will be persisted to the object in memory.

The only difference syntactically is that you don't need the ampersand before the variable name in the function signature - it's implied.


It's hard to know from your question, which part you're having a hard time with exactly, so I'll just be general in my response:

Typically, when you set up a view, you're getting either users, or content, or terms, or comments -- those are very different types of data.  Typically, a view will not give you all those things together in one display.

So my suggestion would be to try to get each of the different stat types in separate views, and then you can always combine multiple views in one page or block for display purposes at the end...

So, when you start creating a new view, select the correct type of content to show on the first view setup screen (I'm assuming you're using Drupal 7 - it's always useful to specify in your question or via a tag). In Drupal 7, that first view setup screen will prompt you for the type of data you're going to be displaying, so select 'Content' for the revisions stat view or 'Taxonomy term' for the tagging stat view or 'Users' for the user stat view, etc.

Then go from there... just try to do these separately and that would be easiest!!


Why are all files (except index.php) being redirected to 'index.html'?

There is a Rewrite Rule written in .htaccess as,

# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize().
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]

This may be your problem.

There are few assumptions that can be the reason why its happening :

Please check the method you the using to access files.
It might be your server issue which does not provide correct access rights for accessing the files
Your files are not properly placed in correct locations.


Custom module over ride blazy.html.twig template

I found the issue to override the module template you have to call the modules name in the _theme hook $return['blazy'].

function slider_overlay_text_theme($existing, $type, $theme, $path)
{
    $templates = $path . '/templates';

    $return['blazy'] = [
        'template' => 'blazy',
        'path' => $templates
    ];
    return $return;
}


Multisite: Only Drupal Root recognized for subpath

Adding a rewrite rule into the .htaccess file fixes the problem. Without the rewrite rule for this path, the default rewrite rule goes into effect, pointing to the example.com/index.php instead of example.com/sub/path/index.php.

Disadvantage: I will have to patch .htaccess every time I upgrade Drupal core.

RewriteCond %{REQUEST_URI} ^/sub/path/(.*)$
RewriteRule ^(.*)$ /sub/path/index.php [L,QSA]


Ability to create forms for each node in Drupal 7

This is pretty much the use case of the Rate module. By using a custom widget, you can present arbitrary label/value options for the user to select (e.g. Yes = +1 / No = -1).

The only difference is that they're presented as hyperlinks instead of radio selects. With some front-end customization, you probably could change that as well.


My custom module does not show persian or arabic texts!

You have to install Locale module. Then you have to configure Arabic language.

To get our languages hooked in, let's enable the core module, Locale.
Go to Languages section in admin -  admin/config/regional/language:
Click Add Language button

Then select Arabic form the drop down and save.

That's all you have to do :)


Programmatically querying via SearchApiAcquiaSearchService

The solution to this (also updated on the Drupal.org node commented above) is:

To skip this part:

$solr = new SearchApiAcquiaSearchService($server);
$result = $solr->search($query);

And simply do:

$result = $query->execute();


Difference between theme preprocessor & processor function?

For the template

If the page is "/my-node", the page template will be "page--my-node.tpl.php".

For the Prepocess

But you cannot using it "themename_preprocess_my_node(&$vars)" because my-node isn't a hook ! You can find differents hooks with this page http://api.drupal.org/api/drupal and with the search box,  type 'theme_'. You can see the differents hooks for the preprocess


You have to set the target attribute in the form tag itself:

$form['#attributes']['target'] = '_blank';

Put this code somewhere in your form function.

Update:

To get this functionality to a particular button, you have to be tricky.

$form['save_and_print'] = array(
      '#type' => 'submit',
      '#value' => t('Save and Print'),
      '#attributes' => array('onclick' => 'this.form.target="_blank";return true;'),
);

When clicked, this will set the parent form element's target attribute to _blank which opens in a new tab when pressed.
If you clicked the button once and when you click some other button in the same form, it will open in a new tab as well because the previous onclick event set the target attribute to _blank.

To workaround, you have to set this onclick event to ALL submits.

To submit the form in same page/tab:

$form['save'] = array(
      '#type' => 'submit',
      '#value' => t('Save'),
      '#attributes' => array('onclick' => 'this.form.target="_self";return true;'),
);

To submit in a new tab:

$form['save_and_print'] = array(
      '#type' => 'submit',
      '#value' => t('Save and Print'),
      '#attributes' => array('onclick' => 'this.form.target="_blank";return true;'),
);

demo


Using `hook_field_attach_presave` for replacing characters

hook_field_attach_presave() was removed some time ago, there's no such operation in Drupal 8.

You can, however, use hook_entity_presave() or  hook_ENTITY_TYPE_presave() instead.


Is it possible to request multiple nodes in one request using Services?

Enable the index crud operation on resources tab. After that you should get all the entities that are accessible to your authenticated request. I had to use hook_entity_info_alter and custom access callback to provide everyones entities of specific type for my api role user.


How do I embed a node information/content into another node?

Depending on your layout and other details there are a few ways to handle the display of the content from your related entity.

The most basic (and therefore limited) way is to go to Manage Display first on your article content type and adjust the settings for the format. It is likely already "rendered entity" (if not set that) and then click the gear to the right and set the view mode to be Default or Teaser. Once that's set, switch to manage the display of your authors and make sure the fields you want to display on your article pages are enabled.

The draw back to this approach is that it can have side effects unless you create extra view modes and are careful about when those modes are displayed.  For example, if you change the teaser settings any place the author teasers appear will change to match. If you install Display Suite you will have additional options to control the layout of both content types within the Manage Display form.

A common approach is to use views. With Views you can create a block that displays the author information, and then you can carefully place that block where ever you need. There is a reasonably good tutorial on Drupal.org for how to set something like this up in a general case.

If you'd like to do more research on options I suggest searching for things like "drupal views entity reference" or "drupal ds entity reference".


Apache Solr Search, add taxonomy field in search results

To show the field you have added to your Solr index you first need to add it to the search result. Add this to template.php

function template_preprocess_search_result(&$variables) {
  $variables['im_field_arbo'] = $variables['result']['fields']['im_field_arbo'];
}

Then in your search-result.tpl.php you can access the field like this:

<?php if ($im_field_arbo): ?>
  <?php print $im_field_arbo; ?>
<?php endif; ?>


Exporting a custom module from one instance to another

Here are the steps you need to do:

Before you try anything, make sure you have a backup of everything
Copy the module directory into the correct directory in the other Drupal site
Enable the custom module

from the /admin/modules page
from the command-line using the drush en MODULE command

If the module requires any configuration, then you will have to do the configuration on the second website as well

If you have used the features module, it can be helpful in transferring module configuration


General error: 2006 MySQL server has gone away

Shared hosting companies do not give away the SUPER privilege. If you have it, you can easily set max_allowed_packet  to 512M by just running this :

mysql> SET GLOBAL max_allowed_packet = 1024 * 1024 * 512;

No restart is required. Then, all incoming connections thereafter can have a 512M packet.

You cannot do this:

mysql> SET max_allowed_packet = 1024 * 1024 * 512;

because you get

ERROR 1621 (HY000): SESSION variable 'max_allowed_packet' is read-only. Use SET GLOBAL to assign the value

The only alternative I can think of is to switch to Amazon EC2 and install MySQL there. That way, you can have free rein to edit my.cnf/my.ini and have the SUPER privilege.


Session variable lost after setting it in ajax call

I'd assume those are 2 different sessions; use session_id()in both contexts to confirm.

To make sure you're using the same session, just implement your AJAX path inside Drupal, with hook_menu()


Core listed as outdated, but composer is not updating it

Eventually, I fixed this issue running a global:

composer update

Still don't understand what was blocking me from updating drupal/core.


Logic on Node Add Page for Specific Content Type

Hiding options such as publishing and URL aliases is accomplished through the use of user roles and permissions. Visit /admin/people/permissions on your site to see what I mean. Enable the help module for more (contextual) assistance.

If you want to perform additional modification beyond basic access control, then, seeing as to how you are attempting to customise a form, you would need to implement a Drupal hook named hook_form_alter(). You will need to do this in a custom module - if you haven't done this before, it's a lot easier than it sounds :)

There should be plenty of information and guides on SE, d.o as well as Google on how to use this hook to modify forms. But the one reference that you definitely need to be aware of is the Form API reference.

Since you want links to the node-add form to be visible, rather than controlling access to the page based on the FB-authentication status, you can check the status during the form_alter and either add a message and disable the form, or as is usually done, set an error message or notice (using drupal_set_message()) and redirect them to a page where they can log in via FB; the message/notice will be displayed at the destination.


Querying a custom table does not return latest results for anonymous user

Try to user drupal select instead of normal query something like following:

  // Add this use at the top of the file
  use Drupal\Core\Database\Database;

  $connection = Database::getConnection();
  $query = $connection->select('mytable', 'my_table')
    ->condition('id', $key, '=');
  $result = $query->execute()->fetchAll(PDO::FETCH_ASSOC);


Can Joyride Jquery Button take us to another page?

I'm not sure about joyride but you could write some javascript to listen for when the last popup  has appeared and afterwards use

window.location.href = 'someurl.com';

Or some such to move the user to a new page.


Alternate links in a multilingual site Drupal 7

You can use Meta Tags module for canonical links.

  The Meta tags module allows you to automatically provide structured
  metadata, aka "meta tags", about your website. In the context of
  search engine optimization, when people refer to meta tags, they are
  usually referring to the meta description tag and the meta keywords
  tag that may help improve the rankings and display of your site in
  search engine results.

  Meta tags have additional uses like the Open Graph Protocol used by
  Facebook, specifying the canonical location of content across multiple
  URLs or domains.


Is it possible to use civicrm stand alone profile page to edit existing contacts?

Generally agree with the previous commenters -- you can do an edit screen using "civicrm/profile/edit", and "webform_civicrm" is generally the next level to go if you want the effect of a standalone profile managed in a Drupal-way. There are hooks for manipulating Civi's profile screens, but they're different from the hooks of typical Drupal forms.

For completeness, we should add some links about Civi's profile hooks. The most concise reference I can think of is:

https://github.com/civicrm/civicrm-core/pull/1144/

It's a bit dense, so let's drill down on an example section:

civicrm/profile/edit:
    CSS: form#Edit .crm-profile-name-{NAME}
    Region: profile-form-{NAME}
    Hooks: buildProfile($name), validateProfile($name), processProfile($name)

What this says: If you're dealing with the page "/civicrm/profile/edit?gid=X", then there are three ways to precisely customize that profile (and no other profiles). All three require that you know the {NAME} of the profile. (This is internal name that corresponds to the DB field "civicrm_uf_group.name".)

To customize with CSS or jQuery, use a selector like "form#Edit .crm-profile-name-{NAME}". (As always, it's helpful to "View Source" and see the precise tags on your form.)
To append/prepend content programmatically, use a region named "profile-name-{NAME}".
To execute code while processing the profile, you can use hook_civicrm_buildProfile($name), hook_civicrm_validateProfile($name), or hook_civicrm_processProfile($name).

For information about other Civi hooks, see wiki.civicrm.org/confluence/display/CRMDOC/Hook+Reference .

(NOTE: I left some links as plain-text because stackexchange limits the #links from new users.)


Goal: 1 Webform as Block, Multiple Nodes with block in Panel pane

You can create a view for this web form node, and display it as block.
This will work.


How do I debug "unexpected % in php_eval()"?

This error is from php code in a text field.

  Speaking of debugging, errors in eval()’d codes throw up error
  messages that don’t provide much help in identifying or locating the
  error. There’s a good chance you might have to go through your
  database manually to find and fix the error. Such errors might even be
  fatal in certain instances, for example, if the error is in a block
  that is displayed on all pages.

Source: http://valuebound.com/resources/blog/enabling-php-filter-in-drupal-7-core-what-can-go-wrong


Edit content if (taxonomy) Country = United Kingdom

I have used the Taxonomy Access module before and it should work for what you need to do here.

I'm making some assumptions here:

1) You have a vocabulary called "Country" and "United Kingdom" is a term in that list.

2) You have a field of type "Term Reference" on your content type(s) and it using the "Country" vocabulary.

3) You have a field of type "Term Reference" on your account settings - /admin/config/people/accounts/fields and it using the "Country" vocabulary.

Now, make sure your permissions are set properly:

1) go to /admin/config/people/taxonomy_access

2) "edit access rules" for the "authenticated user" to get to this page:

3) Under "New" you need to select the term you want to manage access for. Hit the "Add" button.

4) Once added, the term with show under the "Tags" heading in the table. I am using the "Tags" vocabulary here, but yours will say "Country".

5) Now you can modify the permissions for View, Update, Delete, Add Tag and View Tag. There is an explanation of these fields as well as how to manage the permission on the bottom of that page, so I wont include it here.

After you have done this, you can login as an authenticated user and the permissions configured above will control the access to your content.


Views data export user role field value missing from exported csv file

I found this is a bug in the module itself, and the following patch will solve the issue.

Discussion: https://www.drupal.org/project/views_data_export/issues/2789531#comment-13345278

Patch: https://www.drupal.org/files/issues/2019-11-08/views_data_export_batch_empty_fields.patch


How do I create a custom theme, or layout using images?

You should download a theme such as AdaptiveTheme  or Zen as a base and then create a sub-theme.


How to pass values or data from a page to a webform using webform link field?

Add a webform reference field to the content type and put the default values in

Default submission data (YAML)

and you see this example provided by the field:

# This is an example of a comment.
element_key: 'some value'

# The below example uses a token to get the current node's title.
# Add ':clear' to the end token to return an empty value when the token is missing.
title: '[webform_submission:node:title:clear]'
# The below example uses a token to get a field value from the current node.
full_name: '[webform_submission:node:field_full_name:clear]


Setting a block region doesn't work unless you set status to 1, and clearing your cache of course.


How do I provide a "delete" link for comments?

On Drupal 6, users with the permission of administer comments and create comments are able to delete comments. The code that adds the delete link for comments is contained in comment_links().

  if (node_comment_mode($comment->nid) == COMMENT_NODE_READ_WRITE) {
    if (user_access('administer comments') && user_access('post comments')) {
      $links['comment_delete'] = array(
        'title' => t('delete'),
        'href' => "comment/delete/$comment->cid",
      );
      $links['comment_edit'] = array(
        'title' => t('edit'),
        'href' => "comment/edit/$comment->cid",
      );
      $links['comment_reply'] = array(
        'title' => t('reply'),
        'href' => "comment/reply/$comment->nid/$comment->cid",
      );
    }

Similar code is present in Drupal 7 and higher.

Third-party modules allows other users to delete comments.

Comment Delete allows the comment authors to delete the comment they created. The module is for Drupal 6.
User tweaks, a module I maintain, allows the comment's authors to delete their own comments; it also allows users to delete any comment, or any comment associated with nodes of specific content types. In both the cases, the user needs an additional permission, but not the permission to administer comments. The module is for Drupal 7.


The system_modules() form is the one that provides that module list.

You can form alter that in a custom module like so:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function MODULE_NAME_form_system_modules_alter(&$form, &$form_state, $form_id) {
  // Loop through the array of module packages.
  foreach (element_children($form['modules']) as $package) {
    // Loop through the array of module rows for each package.
    foreach (element_children($form['modules'][$package]) as $module_filename) {
      // Add an extra operation link for each module row.
      $form['modules'][$package][$module_filename]['links']['new_operation_link'] = array(
        '#type' => 'link',
        '#title' => t('Link text'),
        '#href' => 'link/url',
        '#options' => array(
          'attributes' => array(
            'class' => array('module-link', 'module-link-configure'),
            'title' => t('Link hover text'),
          ),
        ),
      );
    }
  }
}

Note that you need to change MODULE_NAME to the name of your module and you have the change the link key, text, url, etc. to meet your requirements.

[EDIT]
I have now tested it and it works.
Here is a working example with the placeholder values changed to make a link to google.

/**
 * Implements hook_form_FORM_ID_alter().
 */
function MODULE_NAME_form_system_modules_alter(&$form, &$form_state, $form_id) {
  // Loop through the array of module packages.
  foreach (element_children($form['modules']) as $package) {
    // Loop through the array of module rows for each package.
    foreach (element_children($form['modules'][$package]) as $module_filename) {
      // Add an extra operation link for each module row.
      $form['modules'][$package][$module_filename]['links']['google'] = array(
        '#type' => 'link',
        '#title' => t('Google'),
        '#href' => 'http://google.com',
        '#options' => array(
          'attributes' => array(
            'class' => array('module-link', 'module-link-google'),
            'title' => t('Go to google'),
          ),
        ),
      );
    }
  }
}

You can also use relative internal links instead of the external google link above.


Add state for Germany and drop-down menu

Address Field module uses a plugin system for building the address fields. You should create an address field plugin in your custom module.

hook_form_alter() wouldn't help much in this case.

To create a plugin for Address Field, you should first implement hook_ctools_plugin_directory() in your module to tell you have an addressfield plugin and where they live:

function YOURMODULE_ctools_plugin_directory($module, $plugin) {
  if ($module == 'addressfield' && $plugin == 'format') {
    return 'plugins/format';
  }
}

Then, create the folders plugins/format in your module. The folder names are up to you. Under this folder create an .inc file, and give it a relating name, like german-states.inc.

In this file, you should define a $plugin array, which holds the information about your plugin, including the callback function name. Then define a function which can add new form elements, edit existing form elements etc.

$plugin = array(
  'title' => t('German States'),
  'format callback' => 'YOURMODULE_format_german_states_generate',
  'type' => 'name',
  'weight' => 0,
);

function YOURMODULE_format_german_states_generate(&$format, $address) {
  // Add new form element for German states
  if ($address['country'] == 'DE') {
    $format['locality_block']['administrative_area'] = array(
      '#title' => t('State'),
      '#required' => TRUE, // Set this FALSE if you don't want it to be required.
      '#attributes' => array(
        'class' => array('state'),
        'x-autocompletetype' => 'region',
        'autocomplete' => 'region',
      ),
      '#options' => array(
        '' => t('--'),
        'BW' => t('Baden-Württemberg'),
        'BY' => t('Bavaria'),
        'BE' => t('Berlin'),
        'BB' => t('Brandenburg'),
        'HB' => t('Bremen'),
        'HH' => t('Hamburg'),
        'HE' => t('Hesse'),
        'NI' => t('Lower Saxony'),
        'MV' => t('Mecklenburg-Vorpommern'),
        'NRW' => t('North Rhine-Westphalia'),
        'RP' => t('Rhineland-Palantine'),
        'SL' => t('Saarland'),
        'SN' => t('Saxony'),
        'ST' => t('Saxony-Anhalt'),
        'SH' => t('Schleswig-Holstein'),
        'TH' => t('Thuringia'),
      ),
    );
  }
}


Update manager fails to move files from tmp

After reading Enable FTP on your server i applied the changes as mentioned in the /etc/vsftpd/vsftpd.conf file.

The changes applied are

Linux Instructions (UNSECURED):

Step 1:  sudo  yum  install  vsftpd

Step 2:  sudo emacs /etc/vsftpd.conf
Uncomment these settings:
listen=YES
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES

Step 3:  sudo service vsftpd restart

i then changed the ownership of the drupal root to apache user

chown -R apache:apache /home/user1/www

and this fixed the problems for me. am able to install themes via FTP method.

Please note - the method i've used is potentially insecure. Don't use on production server.

Thanks.

Yashesh


An attachment is just like any other view (except that it is attached to other views), and so can be manipulated as such:

In template.php:

function THEMENAME_preprocess_views_view_fields(&$vars) {
  if (isset($vars['view']->name) && $vars['view']->name == 'VIEW_NAME' && $vars['view']->current_display == 'ATTACHMENT_NAME') {
    foreach ($vars['fields'] as $id => $field) {
      if ($id == 'FIELD_NAME') {
        $vars['fields'][$id]->content = 'new value';
      }
    }
  }
}

Remember to clear your cache.


I have managed to coerce the system into providing the desired result, but I'm not entirely happy with the method.
I have the main function listed in my module's .info file as previously stated.
The function that builds the dot script is a "menu callback", triggered from a views display. I have mimicked the method found here.

After the dot script is built, the function returns:

 <?php
 $gvdata = $gv->parse();
  $return = '

';
  $return .= '<textarea id="dotscript" rows="20" cols="80" width="100%" wrap="off">';
  $return .= $gvdata."\n\n";
  $return .= '</textarea>';
  return $return;
?>

I get the javascript into the output using the js_injector module to put the following into the footer:

    jQuery(document).ready(function () {

  var svg_div = jQuery('#svgarea');
  var graphviz_data_textarea = jQuery('#dotscript');

  function UpdateGraphviz() {
    svg_div.html("");
    var data = graphviz_data_textarea.val();
    // Generate the Visualization of the Graph into "svg".
    var svg = Viz(data, "svg");
    svg_div.html("
"+svg);
  }

  // Startup function: call UpdateGraphviz
  jQuery(function() {
      UpdateGraphviz();
  });

});

It seems to me there should be a more elegant way to do this.


You can un-require the field. Navigate to:

  /admin/structure/types/manage/[content_type]/fields

and un-require there.


WSOD after migrating to another site? Troubleshooting a site migration

Remember to check the PHP version. It's running on PHP 4.


How can I show a flag link only for the "deepest" terms for a field with multiple values using hierarchical select?

Have you tried checking the $level variable? I have never used this module but the fact that there is a variable named $level suggests to me that this could be checked to only apply your flag link to the last 'level'.

edit in relation to comment:

Try this.

function theme_hs_taxonomy_formatter_lineage($variables) {
  $output = '';
  $lineage = $variables['lineage'];
  $separator = theme('hierarchical_select_item_separator');

  // Render each item within a lineage.
  $items = array();
  foreach ($lineage as $level => $item ) {
    dpm($item);
    $line  = '';
    $line .= drupal_render($item);
    //this adds a flag link to every term, not just the last term
    if(!count(taxonomy_get_children($item['#options']['entity']->tid))){
      $line .= flag_create_link('hobbies_and_interests', $item['#options']['entity']->tid);
    }

    $line .= '';
    $items[] = $line;
  }
  $output .= implode($separator, $items);
  return $output;
}


How do I validate a number against a list of valid numbers?

You can create a custom webform validation.

In a custom module you will need to implement CUSTOM_MODULE_webform_element_alter in which you will define a new validation method.

You have to implement the callback method validate() as it is described in the documentation above.

In your validate method you have to compare the submitted value with your vocabulary terms using something similar to the following code

// ...
$vid = 'vocabularyname';
$terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid);
foreach ($terms as $term) {
    if($value == $term->name){
        // ... found
    }
}

About the 2nd part of you question / conditional enabling of fields

Webform built-in conditional logic probably cannot handle it as it only depends on values and NOT validation state of another field.  Perhaps it can be done using conditional_fields but I have not personally tried it.


how to use two different feeds on one drupal

I was able to create a page view w/ two RSS icons with the following steps.

Create a view with a page display.

Add a first "feed" display. You can customize what you want the feed to return here.

Set a path for the first feed display.

Attach the first feed display to the "page" display.

Repeat steps 2-4 to create and attach a second feed display. It should look something like this.

Save the view and view the page. There should be two separate feed icons.

I hope this helps!


Restricting blocks to certain URL paths without sub paths

That's not possible with the default path visibility condition.

If you need that, then you need to write your own condition plugin that allows to both have a white and a blacklist instead of just one or the other.


Taxonomy term not localized correctly in multilingual site in Drupal 7

I had the same problem. I enabled 'Synchronize translations' (i18n_sync) module. This solved it. It is bundled with i18n module.

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


Howto get ID on newly created content through Drupal 8 REST POST

Looking at the response code for POST requests, we can see that there's no body but a header set to the full URI of the node. You can save that URI or explode it/parse it to get just the nid.

  // 201 Created responses have an empty body.
  return new ResourceResponse(NULL, 201, array('Location' => $entity->url('canonical', ['absolute' => TRUE])));


Alternative admin-side content browsing - module?

I'm not sure if I understand what you're looking for in the admin pages, but I do know that Views is a great tool to build custom admin pages, especially when combined with Views Bulk Operations.


Is there an easy way to define a "global" if isset condition on node.tpl.php?

No.  Consider the case where one field is not set.  Either the global if fails and nothing is printed or you are right back to those errors.  This is one of the shortcomings of coding in the theme layer.


The $account argument have the data that you like, but the password is protected.

It's not the best practice, but you can use reflection to get it:

/** @var \Drupal\Core\Field\FieldItemList $passObject */
$passObject = $account->get('pass');
/** @var \Drupal\Core\Field\Plugin\Field\FieldType\PasswordItem $passItem */
$passItem = $passObject->get(0);
$reflection = new \ReflectionClass($passItem);
$reflectionProperty = $reflection->getProperty('values');
// This do the magic.
$reflectionProperty->setAccessible(true);
$pass = $reflectionProperty->getValue($passItem)['value'];

See more about hook_user_insert here.


The simple way is search this URL in your codes completly , if you reach bash command prompt you can  do it by grep   command .


Local tasks not correctly limited to base_route

You can use hook_menu_local_tasks_alter() to see what all elements are added and can remove elements based on any conditions you like.


Payment Method displays after Page Refresh

Solved by unchecking Free order from Payment Method.


This is a known problem in Drupal 7. The "Run the Clean URL test" button does not behave like that page says it does, and this can be very confusing. Please see "Run the clean URL test" UX is broken; basically, what it comes down to is that the logic and UX of that page is broken, but the clean URL system itself (ie. the part in Drupal core that makes clean URLs work) does not contain any (known) bugs.

If you cannot enable clean URLs (you don't see the checkbox to enable it), this means that a test has already been run, it returned a negative result, and you should check your server configuration. See drupal.org - Clean URLs for documentation.

PS. If you can, test the patch from comment #87. This patch will improve the UX on the clean url's page, but it will not solve problems with an incompatible server configuration.


check box with dynamic content and error with submit handler

Make sure you understand the processing flow of drupal forms. See an illustration here for example: https://www.drupal.org/node/165104

The basic flow is like this:

First request

Form build to represent the form to the user
User hits submit which results in a new request to the server

Second request

Form gets rebuild by calling the form builder (basket_form)
Form gets processed (validate and submit handlers are called)

The error message that you see results from the fact, that after the user hits the submit button, the form is first rebuild. Because you are using the $_SESSION to store your values (you should use the $form_state['values'] array instead) the checkboxes will not be build. And when drupal processes the form after the internal rebuild, it recognizes, that form items have been submitted that are not part of the form.

Also this might help: http://proofgroup.com/blog/2008/jul/debugging_mysterious_illegal_choice_has_been_detected_please_contact_site_administrato


Where should twitter embed javascript go in a ctools plugin

There's nothing "special" either about "Twitter embed" or "javascript and plugins".

The solution is the same as for other javascript includes, put the javascript in [module]/js/file_name.js, and call drupal_add_js() on it.


Drupal commerce donate: Safely update to dev version of module on live site

If you go through the normal process to update the module (which for me means drush dl --dev commerce_donate in this case - or you might download & un-tar the module directly), no uninstall will be necessary.  In general you should not uninstall a module before installing an update, for exactly the reason you fear.


Uploading Image to s3 turns to horizontal always

Without knowing the origin of your images nor the s3f module I'm rather guessing  your problem consists of the two following parts:

the EXIF data of your images probably contains information that says 'this image should be displayed horizontally
the s3fs module or actually drupal's image module respects the information about the image orientation – but that's different from your expectation (could also be that the problem is that the info about the orientation is not respected)

According to this I would suggest you try either (or both) of the following:

try to strip the EXIF data in case you don't need it, for example by saving "websafe" from Photoshop or the like
Try to 'teach' drupal the correct exif orientation – for example by using the EXIF Orientation module.


Rules sometimes don't convert saved node to nid

So, the problem was in the entity reference field Rules were operating on (when adding value to it). The only solution I was able to come up with was to create a new field.


How to embed javascript into content region

Never use php filter, it's one of the worst inventions in Drupal.

You can create a region in your info theme.  Then, use the preprocess hook like that:

function hook_preprocess_region(&$vars) {
  // Region names of (header|footer) collide with drupal_add_js()'s
  // (header|footer) labels.
  $scope_theme = 'your_region';
  if (!empty($scope_theme) && $scope_theme != 'footer' && $scope_theme != 'header'
    && $vars['region'] == $scope_theme) {

    // Inject javascript into page.
    $javascript = drupal_get_js($vars['region']);
    $vars['content'] = $javascript . $vars['content'];
  }

}

And finally, fire your drupal_add_js using the region you defined wherever you prefer... But never in php filter


The responsive menu (Sidr menu) is not working with anchors

The solution to this question is here: https://www.drupal.org/node/2697767


Member list with Demographic Data - is there a module or how do I build a View?

Creating a view of type user will allow you to extracts necessary user and profile fields to list in you view.

Go to admin/build/viewsthen click onAdd.
Define view name, description, tag and select view type as user.
Add you display type page or block
Alter/Override views settings
Add fields, the list can expand
Select view's format style as table, and configure this style for fields to sortable.

For demography point of view there are few date specific fields like created, last login.

This list can grow depending on module extending user entity e.g. profile


Rules react on event for file_managed table?

I have looked and it is not an easy thing to accomplish with rules/drupal strictly. So instead I took a different approach that works great :)

I have a separate database that I use for various things which is added through my settings.php so available to drupal. I have added a newfiles table to this db. I then use on the file_managed table a trigger:

CREATE TRIGGER `newfile_trigger` AFTER INSERT ON `file_managed` FOR EACH ROW INSERT INTO otherdb.newfiles (fid,uid,filename,uri,filemime) VALUES(NEW.fid,NEW.uid,NEW.filename,NEW.uri,NEW.filemime);

In my custom module I then have a hook_cron that looks up the entries on the newfiles table every minute, performs the necessary functions and then deletes the row.


Solution is dead simple. 'Use Ajax' option in View settings must be enabled.


How to prevent user from viewing profile

There'd be a few ways you could do it, the fastest might be to create a user-profile.tpl.php and do a check for the user's group.


If you just use l($text, $path, array $options = array()) you can simplify your code and it will take care of check_url for you.


Can I remove write protection for all Drupal files?

Yes, although it will disable the installation of modules through the web interface (it writes in sites/all/modules), but I would consider that a feature.

You also probably want to use 0644 for files (rw/r/r), and 0755 for directories (rwx/rx/rx). By convention, you don't want files to be executable unless they are really meant to be.

Here is the official Drupal documentation on the issue:
https://www.drupal.org/node/244924

And this answer also has good advice:
What is the suitable file permission for 'files'?


I think the answer relies on the way you organize your content. I imagine bands could be a content type, with fields like bio, discography, pictures, videos and whatever, and a field with multiple values to add users, beeing the band musicians.

The users get their own fields from which bio. Then you can display a list of teasers of musicians in the band node, with a link to complete profile and bio.

EDIT : (for lazy or busy musicians :) I guess NY Big Band staff i.e knows all members's emails, names...

Create a role "band manager" with the rights to create user accounts
When an account is created by this role, set up a rule to send an automatic email to notify the musician,  that an account has been created for him and he's welcome to check if his information is correct.

This way you 'll have a unique "musician content", without SEO duplicate problems, and you 'll also improve the involvement of musicians in your website.


Drupal 6 - How to check which module is caused high loading(high CPU usage)

I'd also try a PHP profiler which gives you a lot of metrics. Take a look at the XHProf module. Here is an excerpt about it from the module's project page:

... allows you to profile your Drupal application using the XHProf profiler from facebook.
It also provides a native Drupal UI (as opposed to facebook's original php front end) to view the profiling data. Having this in Drupal provides several advantages:

Simpler setup
No need to setup extra vhosts
Limit access via roles and permissions
Use alternative storage backends such as MongoDb


It looks like they use the multifacet module.
As for "help me to style like this site,“ that's a very broad request.


render() is not returning anything on custom theme

Simple, and frustrated I spent so long on this.

I copied the tpl file from the module to my theme assuming I could customise it there. But when I deleted it from my theme directory it just started working. The template page inheritance is confusing...


goto admin/content and press delete per page next to its title. You don't have to Edit the page. You will have to confirm your delete choice.


How do I create a administration page (with overlay) through the UI

You're probably looking for the Overlay Paths module:

  This is a simple module that enables site builders to use the built-in Overlay for non-admin pages.

However, if the path you've got for the node is under /admin I'm pretty sure that if you configure permissions properly you won't need that module; the overlay should pop up automatically. You'll need to give your users the "Use the administration pages and help" permission, as well as the one to actually use the overlay.

As it's a node, whatever node access solution you have in place will determine the access beyond those two permissions.


How to create a confirm popup when delete item with field collection?

Here is what i did, to handle the deletion of a field collection item for a node:

Created a hook of type hook_node_view() in my custom module and
overridden the delete link for the field collection items, so that
they point to a custom path, that is declared in my custom modules
hook_menu().
Now the custom path is mapped to a template file (passing the field
collection item id).
The logic inside the tpl file processes the deletion of field
collection item (passed by id) using entity_delete_multiple() and
sets a custom message to be displayed back to the node view page.

more details


Daily cron job to download and email Webform submissions file

Using a custom module, you can implement hook_cron() to export the csv and send an email:

function MODULE_cron()
{
    //this is the function that creates the csv, you'll need to research how to use it properly.
    webform_results_download($node, $export_info);
    //send email
}

As far as sending email, you can use php mail or drupal_mail(), but phpMailer might be the easiest to use.


Member for - how Drupal 7 calculaties and formats duration?

$account->content['summary']['member_for'] = array(
  '#type' => 'user_profile_item',
  '#title' => t('Member for'),
  '#markup' => format_interval(REQUEST_TIME - $account->created),
);

It's in function user_user_view($account). And yes, of course you can use format_interval($interval) function in other places.


How do I modify default labels of the location module?

https://www.drupal.org/node/381458#comment-6699162 worked for me

/**
 * Implements hook_location_element_alter().
 */
function update_personal_info_location_element_alter(&$element) {
  $element['additional']['#title'] = "Address line 2";
}


No content but empty row outputted by view

You need to set a filter value on the image field.

Open your view, then edit as follows:

Enable 'Use Aggregation'.

Make sure that the image field is aggregating on 'Group Result together', using Group column 'Entity ID'. Sometimes views gives an error here, so just remove and re-add the image field with these settings.

Add a Filter criteria using 'field_image:fid', set its aggregation to COUNT, and choose the operator 'Is greater than' with value 0.

You might have to remove all of your sort criteria and re-add them as switching on aggregation mid stream can cause issues with sorting.

Basically, what you have done is to do a count on the image primary key (fid) for each node, and if the count is 0 to exclude the record from the result.

This should work for an image field that has either a single, or multiple values.

I you are uncomfortable working with aggregation, then have a look at the Field Count Formatter module. It adds a views field that simply count the number of values contained in a multi-value field. I would imagine it providing a filter in views as well.


Checking for string in variable fails in twig

Via kint and a bunch of trial and error I identified the right way to do this:

{% if 'Ball' in product.field_myproduct_type.0['#plain_text'] %} Order Ball {% endif %}
{% if 'Block' in product.field_myproduct_type.0['#plain_text'] %} Order Block {% endif %}

Thank you 100pic for your assistance.


Grouping Exposed Filters (using Better Exposed Filters)

First I'd recommend adding a taxonomy term 'Graduate Interdisciplinary Program' to match the 'Undergraduate Interdisciplinary Program'

Assuming you have these taxonomy terms 'weighted' to their respective parent terms 'Graduate' and 'Undergraduate' you can proceed to configure your view.

Configure the filter criteria as follows:

Settings
Content:Has Taxonomy Terms
Vocabulary: Graduate/Undergraduate Programs
Selection Type: Dropdown
Depth: 1

Configure Filter Criteria
Tick - Expose this filter to Visitors, to allow them to change it.
Tick - Grouped Filters
Widget Type - Select List
Label - 'Area of Study'

Finally configure the table as you have it in your screen-shot ... ideally without the overlap of the term 'Multidisciplinary Program' ...


You can use ETags - when the app receives an image, there will be an HTTP header that looks like:

ETag: "686897696a7c876b7e"

Whenever the app wants to check for a new image, perform a GET request with this header:

If-None-Match: "686897696a7c876b7e"

If the file is unchanged, your web server will respond with HTTP 304 Not Modified status.