add new format to description fiield of taxonomy display modes

This is because the description field isn't a 'field'.
It's a term property like 'title' in node content type.
You should add your own 'description' field and you should be able to use custom_formatter module to add your format 'trimmed'.
===========================================================
Edit : Update your taxonomy term
This solution use the "View Bulk Operation" module for updating your terms.
[!]First of all, make a backup of your database !!! and put your website in maintenance [!]
After module installation, create a new View based on taxonomy term
Your results need to correspond at all terms you need to update.
Create a VBO field like the following screen :

Save your View and display it on your web site.
Go to the page where this View should appear and select all terms
In php script textarea enter this :
// Load a wrapper for the current term, access to value are easy now
$wTerm = entity_metadata_wrapper('taxonomy_term', $entity);
// Update your custom field (In example : field_mydescription) with description field
// use the format of description to keep same values (In example : filtred_html)
$wTerm->field_mydescription = array(
    'value'     => $wTerm->description->value(),
    'format'    => 'filtred_html'
);
// Save your modifications
$wTerm->save();

All your term should be updated.
Careful, if you have too many terms to update, this operation should run in background via
batch API.
Delete everything we have created for the update, put in offline minimum.
That's done !
You can achieve that operation in many different ways, this is quick fix.


Updating modules with drush without breaking SVN?

because running these commands does indeed get the newer version, but it destroys the SVN data folder in the process, leaving me with "! module/file.php"

I'm running Drush 4.4 and this does not appear to be the case for me. Running drush upc or drush up keeps your .svn directories intact. You can svn status to review the changes to the modules. New files are indicated by ? and removed files are indicated by !.

Test your site's functionality. Once you are satisfied that the modules are still working correctly, you can then svn add/remove with a snippet such as the following:

add:

svn status | grep '^\?' | cut -c8- | while read f; do svn add "$f"; done

remove:

svn status | grep '^\!' | cut -c8- | while read f; do svn rm "$f"; done


Sounds like you need to use Views with a contextual filter based on the logged in user and a relationship from the user to the coworkers


Site not responding while flushing cache

Using a MySQL frontend like phpMyAdmin run SHOW PROCESSLIST while your site is locked from the cache clear. That should show what is causing the issues for you. My guess is it will be a metadata lock. https://www.drupal.org/project/apdqc was built to prevent db locks in database caused by the cache.


How do you theme specific fields in on a content type?

You could use field.tpl.php

If your field is called field_series then you will need to create:

/mytheme/anyfolder(optional)/field--field-series.tpl.php

If you inspect the variable $element then it will contain everything you'll need (tid, name, see drupal_get_path_alias for the link)

Don't forget to clear the cache once the new template has been created.


How do I examine an entity's update SQL statement in order to write a unit test?

Just write a test that attempts to update a primary key, and assert that it fails to do so.

There's no need to test the SQL generation mechanism of the storage class.


Can I create a url alias for private files?

Interesting question.

In theory, every routed path should be able to have an alias because it runs through \Drupal\Core\PathProcessor\PathProcessorAlias::processInbound() before routing, which converts it back to the system path.

However, private files, and image styles are special and quite weird. Because the routing system does not really support having an argument with / and doesn't know how to properly map that to a single argument (Not sure if that is still true or if there would be a better way now with more recent symfony versions), we have a workaround.

That workaround for private files is \Drupal\system\PathProcessor\PathProcessorFiles::processInbound(), which converts the full private path to just "/system/files" with file as a query argument.

The problem is now that those two run on the same event, and PathProcessorFiles runs first, at that point, the path is still the alias and does not match system/files/$something.

I'd say this is a bug and the priority of the service definitions should be adjusted for this. That is path_processor.files (currently 200) and path_processor_alias ( currently 100). Setting the first to 99 and clearing caches makes it work for me.

I'd suggest you open a core issue for this, I suspect nobody tried this yet.


First thought that comes to mind:

I presume you have your view setup with an argument to create the different pages. Something like /productinformation/%

You could setup a second views display with an extended URL like /productinformation/%/senddetails

You can now make a couple of rules, whenever someone accesses /productinformation/%/senddetails you send the emails and redirect them back to /productinformation/%

When you send emails using rules you have access to tokens. This should give you access to things like the User Email or Page title. This is the part I'm not sure about, I don't know if you can get all the information you require through these tokens. Good luck!


The username field is a required field in the {users} table so it has to be there one way or another.

A way round it might be to remove the "Change own username" permission for authenticated users at http://mysite.com/admin/user/permissions. I can't remember if the field will still display on the user edit form but either way it won't be editable.


onClick attribute striped out in rendered html

Try this code:
$form['cancel'] = [
  '#markup' => '
' . t('Back') . '
',
];
$form['step2_submit'] = [
  '#type' => 'submit',
  '#value' => t('Next'),
  '#prefix' => '
',
  '#suffix' => '
',
  '#name' => 'step2',
  '#attributes' => ['class' => ['enabled-for-ajax']],
  '#ajax' => [
    'callback' => '::myajaxmethod',
  ],
];


How get Superfish to display on mobile device?

My bad, I discovered my .css for the page was HIDING Superfish. Removed the offending code and Superfish on mobile works fine.


Did you flush all caches under Performance settings? You can do it manually too. Go to phpmyadmin and clear all tables with "cache" preposition. If you use admin_menu module, it need to be rebuild from time to time.

Try to access manage_fields manually on path https://www.yourdomain.com/admin/structure/types/manage/page/fields

page is name of your content type

When I'm facing strange problem I always try to reproduce it on new Drupal installation. It tells me a lot when I'm "reverse-engineering" the problem.


Allow people to administer only on certain content type?

The menu callback for "admin/structure/types/manage/%node_type" is defined in node_menu() using the following array item:

  $items['admin/structure/types/manage/%node_type'] = array(
    'title' => 'Edit content type',
    'title callback' => 'node_type_page_title',
    'title arguments' => array(4),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('node_type_form', 4),
    'access arguments' => array('administer content types'),
    'file' => 'content_types.inc',
  );

There are other two menu items that follow it, but they depend from that menu item for the access callback.

  $items['admin/structure/types/manage/%node_type/edit'] = array(
    'title' => 'Edit',
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );
  $items['admin/structure/types/manage/%node_type/delete'] = array(
    'title' => 'Delete',
    'page arguments' => array('node_type_delete_confirm', 4),
    'access arguments' => array('administer content types'),
    'file' => 'content_types.inc',
  );

Once you change the access callback for the first menu item, the other two will use the same access callback.

The first step, for the custom module I would implement to achieve what you want is to implement hook_permission(). node_permission() is useful as guideline to write the code you need.

function mymodule_permission() {
  $perms = array();

  foreach (node_type_get_types() as $type => $info) {
    $perms["administer $type content type"] = array(
      'title' => t('%type_name: administer content type', array('%type_name' => $info->name)),
    );
  }

  return $perms;
}

The foreach() part could be rewritten as the following code:

  foreach (node_permissions_get_configured_types() as $type) {
    $info = node_type_get_type($type);

    $perms["administer $type content type"] = array(
      'title' => t('%type_name: administer content type', array('%type_name' => $info->name)),
    );
  }

The difference is that node_permissions_get_configured_types() is using some Drupal variables that are set in a settings page. The function is used also from the Node module when creating the list of the permissions associated to a node of a content type. The documentation for the function reports the following text:

  To exclude a specific node from getting permissions defined for it, set the "node_permissions_$type" variable to 0. Core does not provide an interface for doing so; however, contrib modules may exclude their own nodes in hook_install(). Alternatively, contrib modules may configure all node types at once, or decide to apply some other hook_node_access() implementation to some or all node types.

The second step is to alter the menu item already defined by the Node module.

function mymodule_menu_alter(&$items) {
  if (isset($items['admin/structure/types/manage/%node_type']) {
    $items['admin/structure/types/manage/%node_type']['access callback'] = '_mymodule_content_type_access';
    $items['admin/structure/types/manage/%node_type']['access arguments'] = array(4);
  }
}

_mymodule_content_type_access() should contain code similar to the following one:

function _mymodule_content_type_access($type) {
  return user_access("administer {$type->type} content type");
}


Go to Manage Display, on "CUSTOM DISPLAY SETTINGS" enable the checkbox "Token"


Alternative #markup in a block's build function

You can use #allowed_tags on the markup.

So put it like that:

  $content = "Something<canvas id='12' width='100' height='100'>
               </canvas>"
   return [
     '#markup' => $content,
     '#allowed_tags' => [
       'canvas',
       'span'
     ]
   ];

not exactly sure if you need to add the span tag.

But also note that following is suggested as Drupal Best Practice from https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21theme.api.php/group/theme_render/8.7.x:

  #markup: Specifies that the array provides HTML markup directly. Unless
  the markup is very simple, such as an explanation in a paragraph tag, it
  is normally preferable to use #theme or #type instead, so that the
  theme can customize the markup

And this is the explanation from Drupal regarding #markup and tags:

  Note that the value is passed through
  \Drupal\Component\Utility\Xss::filterAdmin(), which strips known XSS
  vectors while allowing a permissive list of HTML tags that are not XSS
  vectors. (For example,  and  are not allowed.) See
  \Drupal\Component\Utility\Xss::$adminTags for the list of allowed
  tags. If your markup needs any of the tags not in this whitelist, then
  you can implement a theme hook and/or an asset library. Alternatively,
  you can use the key #allowed_tags to alter which tags are filtered.


Need a list of terms from a vocabulary machine name

What you are doing is pretty much the same as Drupal core is doing for the term reference field, so doubt you can improve the code much.

/**
 * Returns the set of valid terms for a taxonomy field.
 *
 * @param $field
 *   The field definition.
 * @return
 *   The array of valid terms for this field, keyed by term id.
 */
function taxonomy_allowed_values($field) {
  $options = array();
  foreach ($field['settings']['allowed_values'] as $tree) {
    if ($vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary'])) {
      if ($terms = taxonomy_get_tree($vocabulary->vid, $tree['parent'])) {
        foreach ($terms as $term) {
          $options[$term->tid] = str_repeat('-', $term->depth) . $term->name;
        }
      }
    }
  }
  return $options;
}


Redirect for single page with htaccess file not working when url has spaces

In the end the issue was spaces in the url. Working with this:

# RewriteBase /

RewriteRule ^taxonomy\/term\/6\ 7\ 8\ 9$ /taxonomy/term/all [L,R=301]


Is there a performance hit to using persistant variables?

In Drupal 6 and 7, variables created with variable_set() are stored in the {variable} database table. They are not automatically cleared when the cache is cleared. They are only removed when variable_del() is called.

Whenever a page is loaded, all variables in the {variable} table are loaded into the global $conf array. So yes - if a site is automatically creating new variables at a constant rate without cleaning them up, it could in theory cause performance degradation.

You can see in the variable_get() function that it is simply loading the global $conf array and looking for the requested variable within that.

It sounds like the custom code should have been using a dedicated database table for the data it was storing, because then it would only load that information when it needed to. Variables are loaded on every pageload.


drush devel-reinstall does not rebuild tables

Apparently because the module can't be uninstalled because another one is dependent on it.


Auto rendered images from external links

CKeditor has the ability to add an image to a text field using its url:

  This module will allow Drupal to replace textarea fields with the
  CKEditor - a visual HTML editor, usually called a WYSIWYG editor. This
  HTML text editor brings many of the powerful WYSIWYG editing functions
  of known desktop editors like Word to the web. It's very fast and
  doesn't require any kind of installation on the client computer.


Programmatically manipulate content type select list

You need to use hook_form_alter to add AHAH/AJAX to your field. The hook should be placed in either a custom module or in your theme's settings.php file.

Drupal has many examples about this. Here's for Drupal 6 and here's for Drupal 7.

This specific example from the links above seems to be what you are looking for.


A better way to insert preformatted snippets into content/wysiwyg?

The perfect solution hasn't presented itself, but I settled on using specialized content types inside a parent content type, (via Entity & Entity Reference fields) and then using Better Formats, Wysiwyg with CKE, Fieldgroup, Conditional Fields to make a user interface that presents all the myriad options in a nice clean manner.

I'm kinda proud of the result, I expect I'll eventually reuse the system somewhere more public so I can show it off.


The problem was with the hierarchical menu module 7.x-3.0-alpha5. Although no error is created when trying to add a new item to a menu, an error is generated when adding new content with a menu link. This error allowed me to search for a solution.

I disabled the module and was able to add a new menu item to my new menu.


Is there a way to place the "Add new comment" link where I want?

You can use hide and render to hide/show individual fields.
http://tjegz.wordpress.com/2012/03/02/132/

This will allow you to place things in any order in the tpl file


Is there a way to make a keyboard shortcut for Save on the node edit page?

Keyboard Shortcut module might be the one you are looking for , Project page says

  The Keyboard Shortcut Utility module enables you to create keyboard
  shortcuts on your website. You can create a shortcut to go to a page
  (internal or external) or call a JavaScript function.


How to disable max length validation on an entity form?

You didn't give an explanation of your rules for your input, but for an example, imagine that the format of the required value is XXX-XXXXXXXXXX, where X is a numeral, and the hyphen is always at position 4.

Change the maxlength on the HTML input to allow more characters. Add your own validation handler to be run before the default validation handlers. Add your own submit handler to be run on submission.

use Drupal\Core\Form\FormStateInterface;

function HOOK_form_alter(array $form, FormStateInterface $form_state, $form_id) {
  if ($form_id == 'some_form_id') {
    if (isset($form['some_field'])) {
      // Change the HTML max length to 14.
      $form['some_field']['#maxlength'] = 14;

      // Insert a custom validation handler to be run BEFORE
      // the default handlers.
      array_unshift($form['#validate'], 'my_module_FORM_ID_validate');

      // Add your own submit handler to deal with the submitted values:
      $form['actions']['submit']['#submit'][] = 'my_module_FORM_ID_submit';
    }
  }
}

In the validation handler, parse the value in this handler, replacing the value in the field with the 10-character value, so it can pass validation. Store the other 4 characters in the $form_state

function my_module_FORM_ID_validate(array &$form, FormStateInterface $form_state) {
  if ($value = $form_state->getValue('some_field')) {
    // Check that the submitted value is in the right format, and
    // parse the value into $matches.
    if (preg_match('/(\d{3})-(\d{10})/', $value, $matches)) {
      // Store the 10-digit value in the field, to be passed through
      // default submit handlers.
      $form_state->setValueForElement('some_field', $matches[2));

      // Store the other three digits in the $form_state.
      $form_state->set('some_key', $matches[1]);
    }
    else {
      // The submitted value was not in the correct format.
      $form_state->setError($form['some_field'], t('Some Field must be in the format XXX-XXXXXXXXXX where the Xs are numeric'));
    }
  }

}
Use the values as necessary in the submit handler.

function my_module_FORM_ID_validate(array &$form, FormStateInterface $form_state) {
  $key1 = $form_state->get('some_key');
  $key2 = $form_state->getValue('some_field');
  // Do what you need with these values.
}


You don't need to worry as the entity API should take care of the specific structure and just set it via:

$entity->set('field_myfield', 'some value');
$entity->save();


Why Views Data relationship between custom entity type and node doesn't work?

I solved it by this way:

$data['stream']['table']['join'] = array(
  'node' => array(
    'left_field' => 'nid',
    'field' => 'nid',
    'handler' => 'views_join', // this is actually optional
    'left_table' => 'node'
  ),
);

$data['stream']['nid'] = array(
    'title' => t('Related node'),
    'help' => t('Node related to stream item.'),

    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),

    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
      'allow empty' => TRUE,
      'help' => 'Filter on a related node nid.',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_numeric',
      'numeric' => TRUE,
      'validate type' => 'nid',
      'help' => 'Argument on related node nid.',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
      'help' => 'Sort on related node nid field.',
    ),
    'relationship' => array(
      'title' => t('Stream node'),
      'help' => t('Relation to node related to current stream item'),
      'label' => t('Stream node'),
      'base' => 'node',
      'base field' => 'nid',
    ),
  );


How to fix 'Cannot redeclare ctools_content_process' problem after sql-sync?

In Drupal 7; this could be caused by corruption in the code registry. The code registry

  is an inventory of all classes and interfaces for all enabled modules
  and Drupal's core files. The registry stores the path to the file a
  given class or interface is defined in, and loads the file when
  necessary.

ref: Drupal Code Registry

The solution to this particular problem would be to force a rebuild of the registry; which you can do as per this post; Code Registry Rebuild.


You can get an entity type or bundle's field structure with field_info_instances(). e.g.

// Get metadata for all fields attached to the article content type.
$instances = field_info_instances('node', 'article');


How to create on mouse over dropdown menu in drupal 7?

You can use nice menu or super fish menu
nice menu will create two blocks called nice menu 1 and nice menu 2 you have to choose on of them as a block and in configuration you will choose a menu to display

also superfish module will create 4 blocks (it is a dynamic number form config menu) and give you more options to style your menu also option to choose which menu you want to display


function [themename]_form_webform_client_form_76_alter(&$form, &$form_state, $form_id) {
// code of altering
}


Any properly configured opcode cache should work. Notice that Drupal only currently checks for PHP Opcache in its requirements. Some people have got Drupal 8 working with XCache, for example.

APC is really not the way to go. It exists in a backwards-compatible way in PHP 5.5 and as a token-based data cache (still useful, but it isn't an opcode cache in that configuration).


Disable breadcrumb on View in Drupal Commerce Kickstart

Do you want to disable the breadcrumbs entirely? If so, with kickstart, you can do so at:

Appearance > Settings > Commerce Kickstart Theme > Toggle advanced elements

It looks like commerce kickstart 2 uses the crumbs module (https://drupal.org/project/crumbs) to handle breadcrumbs (that's what I see in a local install from late July).

I haven't worked with Crumbs, but the documentation is here: https://drupal.org/node/1004394


breadcrumb containing a link to a path that's deeper than the one of the page it's on

Is it possible that there is an old link to this page in your menu that is nested in the tree like.
home
-page
--MY-PAGE

Because breadcrumbs seem to use the menu tree to build the breadcrumb items.


Access callback return true, but still is: you are not authorized to this page

'access arguments' must be an array. Like 'access arguments' => array('access administration pages')


How to display the rendered entity of the "compact" display of the user account in the profile?

If I understand your question correctly, you want to change the view mode when a user's profile page is displayed. I recommend to put this kind of logic in a module, not in your theme. One way to do this, is by implementing the hook_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInterface $entity, $context):

function YOUR_MODULE_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInterface $entity, $context) {
  if ($entity->getEntityTypeId() == 'user') {
    $view_mode = 'compact';
  }
}


How to open external links in new window?

The External Links module does exactly that:

  External Links is a small module used to differentiate between internal and external links. Using jQuery, it will find all external links on a page and add an external icon indicating it will take you offsite or a mail icon for mailto: links.

  Configuration options:

  Apply icons to either mailto: or external links or both.
  Configure external links to open in a new window.
  A confirmation message when leaving the site.
  Regular expression inclusion and exclusion of links considered external.
  CSS selector inclusion and exclusion of elements for processing


I think User import module can help you with that


Adding WYSIWYG to webform email template field

HTML emails have a different standard than WYSIWYG editors. For example HTML emails use tables instead of divs, you can't use paddings etc.

So I don't think that HMLT email creating with WYSIWYG editor is a good idea...


Access to referencing entity field from referenced entity template in Drupal 8

When you are inside the children node, you don't see what is around you. The children node is build and cached on its own. The entity reference is a n:m relationship. There can be more than one parent. So from the data modelling there is no easy solution. Better look for a solution from parent to children, not backwards.


Check if a field group's subfields have values

You might want to try use the field_group_field_group_is_empty() function.

From the field_group module itself:

  // Example from field_group itself to unset empty elements.
  if ($display) {
    foreach (element_children($element) as $name) {
      if (in_array($name, $groups)) {
        if (field_group_field_group_is_empty($element[$name], $groups)) {
          unset($element[$name]);
        }
      }
    }
  }


Conditional display of CCK field for certain profiles values

for this you have to create a field on your content type called vat registered or not. Autofill that field from profile 2 field for the specific users. Then use conditional module. If that field is filled by default show some fields otherwise do not show that fields.


What preprocess function or theme function override are you putting dpm() inside of? If you are inside of hook_preprocess_views_view() then I would expect that you'd get the same results in on every page that the given view is on.


How can I display a paragraph field excerpt in a search result view?

If you add the specific fields within your paragraphs to search_api fields it will generate excerpts for them. If you just have 'Rendered HTML' of the entire page, it will not create excerpts of paragraph text.


Only show comments in view where the comment author has a specific role

I figured out how to do it.

Create a view displaying items of type Node.
Create a relationship Comment:User
Create a filter User: Roles and require Relationship with User (which was created in 2.
Specify the roles

You can style the view (and add fields) as you like.


how to use image for next previous link in pager in drupal 7

In template.php

function THEMENAME_pager($tags = array(), $limit = 10, $element = 0, $parameters = array()) {

}

http://api.drupal.org/api/drupal/includes!pager.inc/function/theme_pager/7

For api please check above link you can overridden.   also check below link.

In drupal 7, How to override theme_pager?


How to include the AddThis sharing buttons on the home page of a site?

Find the block that comes with the AddThis module and make it available (expose this block) only on the <front>.


Disabled AJAX paging with embedded views when used in Views template files

It looks like you are adding some chunks of code logic to your theme templates?  This is not usually recommended in a drupal instance.  Have you tried adding a context to include your loadcover view block on the view generating your grid, so that you do not need to print embed in the tpl?
https://www.drupal.org/project/context

Enable the module and go to /admin/structure/context/add  Set the name of this context, something like Book Grid Display.  We use a "Layout" tag group for things like this, but you could use "custom" or just about anything you want, it is optional.  Under the Conditions dropdown select Views, and on the list that appears to the right check the box in front of your Inside grid view.
Under Reactions select Block.  The theme regions will appear as well as the different groupings of blocks available on your system.  The last grouping is Views, select your Loadcover view and click the +Add on the theme region you are wanting (I assume Content since you were printing this in the content template).

The page content will have a weight of 0, and the drag-and-drop reorder likes to start at weight -10 so use the Show Row Weights to get it under the view grid if desired.  Or at least that is a quirk I have seen when using this method.

Another note, the views_field_view that was mentioned in a comment would allow you to add your Loadcover view as a field in your book grid view, so that you did not have to inject it with custom code from the theme logic layer.  If you were wanting to invoke LoadCover for each cell in your grid and I missed that part, then yes views_field_view would solve the problem for you instead of this context solution which will get you one instance of Loadcover.


In Views, when using a filter on a datetime field, what is the time zone of the offset?

For datetime fields, it uses the timezone for the user viewing the page. If no user timezone is set, it uses the default site timezone.
See the relevant comment from Drupal\datetime\Plugin\views\filter\Date.php:

Date-only fields do not have a time zone associated with them, so the filter input needs to use UTC for reference. Otherwise, use the time zone for the current user.

/**
 * Get the proper time zone to use in computations.
 *
 * Date-only fields do not have a time zone associated with them, so the
 * filter input needs to use UTC for reference. Otherwise, use the time zone
 * for the current user.
 *
 * @return string
 *   The time zone name.
 */
protected function getTimezone() {
  return $this->dateFormat === DateTimeItemInterface::DATE_STORAGE_FORMAT
    ? DateTimeItemInterface::STORAGE_TIMEZONE
    : date_default_timezone_get();
}


just an observation from looking at the module documentation:

there is a note under interaction with other dependencies on the Edit dependency page which says this:

When this dependent has more than one dependee, how should this condition be evaluated against the others?
Note that sets will be grouped this way: ANDs AND ORs AND XORs

with a selection for AND, OR and XOR

This would indicate that you

define your dependency of field C on A,
define your dependency of field C on B
and select OR as your interaction with other dependencies


How can I link css/js from main bootstrap theme to subtheme?

The fact that you've got the Drupal Bootstrap site logo means the theme was correctly enabled. However, this is a symptom of the browser not finding your CSS file.

And you don't actually use the Bootstrap CSS that comes with the parent theme. You actually have to import Bootstrap into your SASS/LESS. That's why you need to download Bootstrap to your subtheme (Step 4).

If you're using the SASS/LESS starterkit, you will actually need to compile your CSS (that's steps 4 and 5 of the Overview). Once you've got it compiling, you need to tell your subtheme the path of the compiled CSS by adding it to the info file (step 3 of the Overview).

stylesheets[all][] = path/to/compiled/styles.css


drush pm-update of 6.27 to 6.28 yields this error: Allowed memory size of 67108864 bytes

See this thread.

What you need to do basically is to increase the memory in your php.ini file. Start with 128M and if you are still getting that error, try with more.


form #type => checkboxes with zero / empty option value

I managed to prevent this problem by adding an '#element_validate' handler on the checkboxes element.

The code below is a simplified version of what I did, up to you to fine-tune.

$element['#element_validate'][] = '_MYMODULE_checkboxes_validate';

function _MYMODULE_checkboxes_validate(array &$element, array &$form_state) {

  // The form value already has the format $[$id] = $id, mostly.
  // However, if trim($id) === '', the array key will be an integer increment.
  $value = $element['#value'];

  // Make sure it has the expected format.
  if (!is_array($value) || [] === $value) {
    $ids = [];
  }
  else {
    // Get rid of integer keys for empty-ish string ids.
    $ids = array_combine($value, $value);
  }

  // Remove dangling * => 0 entries.
  form_set_value($element, $ids, $form_state);
}

Note: If you have the value_is module installed, empty-ish values will always be unset, thanks to _value_is_disabled_options_value_callback().


Two places that come to mind on the Permissions page (/admin/people/permissions) are:

Under Checkout, look for Access checkout
Under Order, look for View own orders of any type


Comment pagers in D7: They appear even when the page has only 1 comment!

After researching for quite some time, I´ve found this reply in the Omega issue queue that gave me the answer. Even when the answer has nothing to do with the theme layer.

In short: When this happens to you, it´s probably because the pager is conflicting with a views block with it´s own pager activated, all in the same page.

You actually fix this by giving the Views pager a different value than the default zero.

Posted it here just in case anyone encounters with this issue again!

Cheers,

Rosamunda


how to hide the facet api block if it has only one item?

Use the module facetapi_bonus and you will get an option to hide a facet if the view has only X item(s)

This setting can be accessed through 'facets > configure filters'


How to avoid admin account to be blocked for all ip's by failed attemps to login?

The answer can be found in this article

https://www.karelbemelmans.be/2015/04/reverse-proxy-configuration-for-drupal-7-sites/

Adding these lines to settings.php solves the issue:

$conf['reverse_proxy'] = TRUE;
$conf['reverse_proxy_addresses'] = array('127.0.0.1');
$conf['reverse_proxy_header'] = 'HTTP_X_FORWARDED_FOR';

Added these lines, in the flood table of the drupal site database, every failed login request is logged with the real ip the request came from.

The real problem, indeed, was not lying in the failed login attemps, but in linking all the attemps to the loopback address. Looking at the flood table in drupal database, I could see every request under the ip 127.0.0.1, which is wrong and causes any request from any user (and any ip) to be blocked if anyone from any ip tried to login with wrong passwords. Linking attemps to their right ip makes the drupal flood protection working as expected, that is blocking attemps only from the ip which tried to login with wrong password.


Distinct classes for each row in views-table

I have two ideas:

1) with :nth CSS selector you can reach every row you want with your style rules. For example the third row can be selected with the selector:

.table-class .tr:nth(3) td { background: red; }

2) with jQuery


Is there a way to set a session variable but not save them in the sessions table?

You should probably look first at either not storing this data but instead deferring its calculation, or at alternative storage methods, eg perhaps cache_set() and cache_get(). You could easily run into the same DB limitations there of course.

You probably don't need to store this data to the session at all, and as you've discovered it can be problematic to do so.

I've seen developers use  $_SESSION as a global variable to pass data around, and as temporary per-visitor storage. This is possible, but there are limitations and likely better ways - for which you might need to zoom out to the actual problem at hand. (Do you need to store a rendered collection of kitten profiles, or just a list of kitten IDs then render later?)

If you do actually need to store such large datasets to the session, you'd probably have to replace the default session management in Drupal or reconfigure your DB (which you've said you'd rather not do). In that case perhaps modules like Session Proxy or perhaps Memcache would help ... But try not to go there :)


How to get the name of the month in local language in Drupal?

Don't use the PHP date function, use the Drupal API: format_date. To add the comma, make it part of the pattern. To match your example 30 maart 2015, 11: 34, the pattern is j F Y, H: i:

$timestamp = strtotime('2015-03-30 11:34');
print format_date($timestamp, 'custom', 'j F Y, H: i', NULL, 'nl');

For this to work, you need to have the core locale module enabled and Dutch translations on your site should be up to date (check that the names of months are translated inthe translation UI).  The module Localization Update will help you with updating translations if you need to.

You can skip the last argument ('nl') if the default language of your site is dutch.


Sounds like it can't connect to the database any more if it's crashing on /query.inc

Some things to try:

Check your database daemon is running (sudo service mysql status or similar)
Check that your settings file has the correct db information and permissions
Check that your drupal user in mysql has right level of permissions (and that it exists)


How to create an add content link with views

You needn't use the PHP module, using PHP in the backend UI is usually a bad idea anyway.

First of all, the node creation link is simply a system link like /node/add/project which works only for users with the correct permissions.

There are ways to correctly route links through Drupal in Views (custom text—output as link), but as this is just for administrative reasons, you can probably simplay paste HTML like add Project in a custom text field / View header / View footer.
This displays the link for everyone with access to the View though.

If you want to display the link to specific users only, the easiest way is to simply create a block with the aforementioned link, display it on the same page as the View and show it only on specific user roles.

You could also set up a different view with different access privileges and attach it via an additional module, but I would deem this overkill.


Put your session and cache data in memcache or APC.
Use non-database log backend.

Don't store logs to long, if you have to keep them in DB.

If above fails, just change your hosting company or hosting plan, to get bigger limit. Database space is cheap nowadays.


I created a view of a page and a block, but cannot find either. Where are they?


Reg your trying override this on the span but the em tag has the style defined on it.

Should be...

.norm12 em {
//...
}


Issues with a trigger module ("beep"). Module is not updating or changing labels in the hook_action_Info() hook

The thing is that the system registers an action with the system name beep_beep_action and probably stores that in a cache. That way it's easier and faster to access the right function in your files. I've however not found that cache, nor a way to clear it.

There are three things you can do:

Accept that all others who install your module will see it right.
Rename beep_beep_action and beep_beep_action() to something else and you will register a fresh action.
Open the database and find and remove the stored action. (But only if you know what you are doing.)

I'd go for the second approach.


drupal_validate_form not validating more than one time on listing page

i just change the validated flag of every form in the foreach and after that it works fine


Not all custom theme styles shown in ckeditor window

Ok, the mistake was to use classes outside the iframe. This way it works:

body.cke_editable ul {
 list-style-type: disc;
}


Webform multi-page submit handler fires on every page

You can use $webform_submission->getState() to determine if the submission is completed. The EmailWebformHandler includes decent examples on how to the submission state. I recommend trying to use WebformHandler::postSave() instead of WebformHandler::formSubmit().


When using the #type => 'button' the submit callback is never executed, it already receives  a FALSE as default value.

Even if the submit callback is not executed, the validate callback is always executed (even on ajax posts). You can bypass this validation on a trigger element by using the #limit_validation_errors property.

In your case, you can set it on the body_words form element to only validate on this scope instead of the whole form.

$form['get_word_count'] = array(
    '#type' => 'button',
    '#value' => t('Update Count'),
    '#weight' => 5,
    '#limit_validation_errors' => array(
        array('body_words'),
    ),
    '#ajax' => array(
        'callback' => 'count_words',
    ),
);


Getting the value of a taxonomy term reference field

You get the first item out of ['#items] with a "0":

{{ content.field_rating['#items'].0 }}

To get a field from the taxonomy term, I would use the node object, because you don't know how the render array in content will change if you configure the view mode differently:

{{ node.field_rating.0.entity.term_field.value }}


How to query the Database logs and create summary reports and/or charts of them?

The Views Watchdog module might be useful.

  The Views Watchdog module extends the Views module and allows to
  create customized lists (pages, blocks, feeds) of watchdog entries.

Combine it with the Charts module and a bit of custom code and you should be able to get a wide array of reports.


You have to change the ID of one of the pagers. For the Views module is under Pager setting, Field pager ID.

The description for that field says:

  Unless you're experiencing problems with pagers related to this view, you should leave this at 0. If using multiple pagers on one page you may need to set this number to a higher value so as not to conflict within the ?page= array. Large values will add a lot of commas to your URLs, so avoid if possible.


Create user profile using content type or add additional fields to the default registration form

I think there are two more possibilities. One, use social media integration to get as much information as possible to pre-fill the profile. Two, use panels to create a form that will collect a minimal number of required fields from your user profile. Overall, reduce the number of required fields and let users fill out their profiles gradually, with a little nudge from your site. If you ask them to fill out a large number of fields just to get started you may end up with a high form abandonment rate.

I would avoid creating a new Volunteer content type. It may just be my opinion, but I like to follow Occam's razor and avoid the proliferation of entities.


Only one module implements hook_tokens()?

$hooks = module_implements('tokens');
print_r($hooks);

It returns the follwoing

  Array
      (
       [0] => token
       [1] => date
      [2] => domain
      [3] => entity_token
      [4] => facetapi
      [5] => logintoboggan
      [6] => name
      [7] => node
      [8] => scheduler
      [9] => system
      [10] => taxonomy
      [11] => token_custom
      [12] => user
      [13] => views
      [14] => field
      [15] => menu )

The only place which i see is it is cached, try clearing the cache or try the following

 module_implements('tokens', FALSE, TRUE)

The third params is reset to reset the cache.


How to use check box in select list for multiple selection in content type?

You can simply achieve that by following way.

Choose Field Widget Type 'Checkbox' instead of Select list.

If you want to make appear checkboxes field as multiple select list,Add the following line in your CSS file

   #field-id-name{ height: 100px; overflow: auto; width: 100px;  }

Note: replace field-id-name with id name of the field; change the width and height according to your requirement.

After applying CSS, the checkbox list field in content type appears as follows.

I hope this simple solution helps


How to remove spaces and beginning 0 from a contact number in Views PHP view?

You can do it using the PHP function str_replace

$number = $row->field_contact_number;
// Remove the spaces.
$number = str_replace(' ', '', $number);
// Grab the first number.
$first_number = substr($number, 0, 1);
if ($first_number == 0) {
  // Check if the first number is 0.
  // Get rid of the first number.
  $number = substr($number, 1, 999);
}
// Remove the + sign.
$number = str_replace('+', '', $number);
echo $number;

Although the question asked using Views PHP, it is not a good idea to enable the Views PHP and PHP Filter module. In Drupal 7, the alternative/preferred method would be to add the following code to the bottom of your template.php file (located in /sites/all/themes/yourtheme/ folder).

function themename_preprocess_views_view_fields($vars){
  if ($vars['view']->name == "view_name" && $vars['view']->current_display == "block_1") {
    $number = $vars['fields']['field_contact_number']->content;
    // Remove the spaces.
    $number = str_replace(' ', '', $number);
    // Grab the first number.
    $first_number = substr($number, 0, 1);
    if ($first_number == 0) {
      // Check if the first number is 0.
      // Get rid of the first number.
      $number = substr($number, 1, 999);
    }
    // Remove the + sign.
    $number = str_replace('+', '', $number);
    $vars['fields']['field_contact_number']->content = $number;
  }
}

Replace themename with your theme name
Replace view_name with your view name
Replace block_1 with your machine name

Remember to flush the cache to see the changes.


form_alter and #element_validate inside .module file

As per @Clive comment, it's probably because password_confirm isn't a single element, it gets converted into two separate fields in a process callback, and doesn't apply the #element_validate to either of those because it can't reconcile which one you were referring to.


Link menu item to an element ID on the same page

well I just figured that out, I can simply link it like: node/515#node-2 so it wont refresh the page and goes straight to the div.

node/515 (same page that my menu are in), but the thing is it doesnt work with url alias so better stick to the classic node url's


I found a sollution to overwrite the "theme_menu_local_tasks" function.

function MODULENAME_theme_registry_alter(&$theme_registry) {
    if (!empty($theme_registry['form_element'])) {
        // Menu local tasks
        $theme_registry['menu_local_tasks']['function'] = 'MODULENAME_menu_local_tasks';
    }
}


In node add, how to upload file using image from clipboard

You could try the FileField Sources module. It provides quite a few additional options to upload files.

  Re-use files by an auto-complete textfield
  Attach server-side files uploaded via FTP
  Transfer files from a remote server (cURL required)
  Paste a file directly from the clipboard (Drupal 7 only)
  Select existing files through the IMCE file browser


What css framework is better between 960gs and Blueprint?

I haven't used 960gs, but used to use Blueprint.  Blueprint worked fine if I was always making 960px width templates.  But, now I veer away from those CSS sizers.  They're too constricted in what you can accomplish.  Also, I always prefer to size the CSS with a min-width:960px and max-width:1200px.  So many of the screen res. are 15" and 17" now.  You can't really accomplish much beyond the scope of 960px with Blueprint and, I'm assuming, 960gs.


clearing cache to call hooks in .module file

Short
This is wrong use of tokens, it can never work.
Long
So what you are doing is incorrect usage of tokens. The idea with tokens, is that you have some data object, like a Node, a User etc and based on that you can output something from that object, like the label, uri etc.
Tokens aren't designed to load data from somewhere and display it. For Drupal 8 with all the new caches, it's even more tricky, but even for Drupal 7 this would not work. The reason is that the result of token replacement is cached, since the idea with tokens is that it will always be the same (as long as the data objects which are used for to make the tokens do not change.
To achieve this feature, you would need to load the current node and make it available in the texts where you want to use it as a token, and for Drupal 8 you would also need to add cache context of the url. If I knew what you are using this for, I might be able to give a more precise advise on what the best way would be to achieve this.


How can I upload 1000s of nodes per hour to a live drupal 7 site and avoid deadlocks?

I work for Stanford university and have been doing similar things. We constantly have to load over 100,000+ nodes on a regular basis. We have been working on our own custom loading code for 2 years now have been able to speed up the process quite a big using pcntl_fork. The only thing you have to remember is to close all socket connection before invoking the fork. For example you have to close you mysql connection, memcache connection and even mongo connection. Drupal will automatically create new connections when one doesn't exists. As far as the deadlock problem, we were able to fix that issue by putting innodb_locks_unsafe_for_binlog = 1.


How to allow users to login with a particular role they have selected?

Changing roles would probably require the permission "Administer permissions" so it could be hard. There's a module that does what you want, but it would probably require some modification: https://drupal.org/project/roleswitcher

There's also the Masquerade module (https://drupal.org/project/masquerade) which offers the ability to switch user account - which may be useful depending on your needs.


Is there any way to know if a string is not translated?

Install l10n_client then flush your cache.

If you switch to any other language you'll see a small box with blue bg in the bottom right. Click it and in the left it'll show all translated & untranslated strings. The green ones have been translated, while other ones you'll need to. Just select one and add the translation there itself.


Trouble theming Ubercart's cart page (Drupal 7) using hook_theme

uc_cart_view() is not a form builder; it is a page callback. As such, theme_uc_cart_view() is not automatically called for uc_cart_view(). It is the page callback that needs to call the necessary theme function, or refer it such as in the following code.

  if (empty($items)) {
    return array(
      '#theme' => 'uc_empty_cart',
    );
  }

What you can do is the following:

Implement hook_menu_alter() to alter the page callback invoked for http://example.com/cart.

function mymodule_menu_alter(&$items) {
  if (isset($items['cart'])) {
    $items['cart']['page callback'] = 'mymodule_cart_view';
  }
}

Implement the page callback to output the content as you want it to be.

I cannot suggest the code to write for mymodule_cart_view(). Looking at the code used from uc_cart_view(), I notice the main part is the following one.

  // Load the array of shopping cart items.
  $items = uc_cart_get_contents();

  // Display the empty cart page if there are no items in the cart.
  if (empty($items)) {
    return array(
      '#theme' => 'uc_empty_cart',
    );
  }

  $build = array();
  // Load through the cart panes...
  foreach (uc_cart_cart_pane_list($items) as $id => $pane) {
    // If the pane is enabled...
    if ($pane['enabled']) {
      // Add its output to the cart view.
      $build[$id] = $pane['body'];
    }
  }

What a page callback can return, in Drupal 7 is:

a string containing the markup to output
an array accepted from drupal_render(), such as the following ones

$build = array(
  '#theme' => 'node',
  '#node' => $node,
  '#view_mode' => $view_mode,
  '#language' => $langcode,
);

$block = array(
  '#markup' => '<em>' . t('There are no rows matching the selected criteria') . '</em>'.
);

$styles = array(
  '#type' => 'styles',
  '#items' => $css,
);

As side note, in your theme definition, the template filename cannot be "cart"; as the template file is for "uc_cart_view" you can report it to be "uc_cart_view" or "uc-cart-view." Any other filenames are not accepted, from Drupal.


How do I show an already hidden field of a custom content type to a specific authenticated user?

It's possible to hide/show an entity field when an entity is rendered, but a hidden field is automatically removed from the base class used to implement an entity view, the EntityDisplayBase class. Its constructor calls EntityDisplayBase::init(), which contains the following code.
// @todo Remove handling of 'type' in https://www.drupal.org/node/2799641.
if (!isset($options['region']) && !empty($options['type']) && $options['type'] === 'hidden') {
  $options['region'] = 'hidden';
  @trigger_error("Support for using 'type' => 'hidden' in a component is deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use 'region' => 'hidden' instead. See https://www.drupal.org/node/2801513", E_USER_DEPRECATED);
}
if (!empty($options['region']) && $options['region'] === 'hidden') {
  $this
    ->removeComponent($name);
}

Since that code is executed when the entity display class is build, every hook running before the entity is rendered would not get those hidden components (which are entity fields and extra fields).
Rather than setting an entity field as hidden by default, and then show it when some conditions are met (which would not be possible), you can set the field as visible by default, and hide it when some conditions are met. Which hook to use depends also from when that field needs to be hidden.
If the entity field needs to be hidden only when specific view modes (a.k.a. entity display modes) are used, then hook_entity_view_display_alter() can be implemented.
use \Drupal\Core\Entity\Display\EntityViewDisplayInterface;

function mymodule_entity_view_display_alter(EntityViewDisplayInterface $display, array $context) {
  // Leave field labels out of the search index.
  if ($context['entity_type'] == 'node' && $context['view_mode'] == 'the view module you are interested to') {
    $components = $display->getComponents();
    $name = 'The machine name of the field you want to hide.'
    if (isset($components[$name])) {
      $options = $components[$name];
      // Verify the conditions to hide the field are met.
      $options['region'] = 'hidden';
      $display->setComponent($name, $options);
      }
    }
  }
}

The code I shown assumes you are using at least Drupal 8.3; otherwise, it needs to be changed. (Instead of $options['region'], it needs set $options['type'] to 'hidden'`.)
If you need to hide the field independently from the view mode used to render the node, then the hook to implement is hook_entity_field_access().
use \Drupal\Core\Field\FieldDefinitionInterface;
use \Drupal\Core\Field\FieldItemListInterface;
use \Drupal\Core\Session\AccountInterface;

function mymodule_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {
  if ($field_definition->getName() == 'the field you are interested to' && $operation == 'view') {
    // Verify the conditions to hide the field are met.
    // Return AccessResult::forbidden() if the conditions are met.
    return AccessResult::forbidden();
  }
  // Otherwise, return AccessResult::neutral(), which lets Drupal core
  // or third-party modules decide.
  return AccessResult::neutral();
}

I used AccessResult::forbidden() just as example. You could also verify the account passed to the hook has a specific permission with AccessResult::allowedIfHasPermission($account, 'permission to check'), or verify the account has one or more permissions with AccessResult::allowedIfHasPermissions($account, ['list', 'of', 'permissions'], 'OR').
Keep in mind that, implementing hook_entity_field_access(), you would also avoid the field is indexed by the Search module. If you want the field to be indexed by the Search module, you need to implement hook_entity_view_display_alter() and leave the field visible when $context['view_mode'] is equal to 'search_index'.
As alternative, you could create a view mode that is similar to the view mode used to show the node, but where the hidden field is visible. Implementing hook_entity_view_mode_alter() you can alter the view mode to use the one you created.
use Drupal\Core\Entity\EntityInterface;

function mymodule_entity_view_mode_alter(&$view_mode, EntityInterface $entity, $context) {
  // For nodes, change the view mode when it is teaser.
  if ($entity->getEntityTypeId() == 'node' && ($view_mode == 'full' || $view_mode == 'teaser')) {
    // Verify the conditions are met.
    $view_mode = 'my_custom_view_mode';
  }
}


Is there a Drupal module to add a Creative Commons license to entities?

Yes, in addition the the Creative Commons licensing support that is integrated in the Media Gallery module, there exists a module for that does exactly that: the Creative Commons licenses module. From the project page:

  The Creative Commons module allows users to select and assign a Creative Commons license to a node and any attached content, or to the entire site. It also provides integration between CC and Drupal technology.

It was originally written for D6 and is still under development for D7 (up to alpha2 at the time of writing), but the core functionality is in place.

Somebody may ask:

  "Why would you need a module for that? Why can't you just add an Entity Reference field to link to whatever license the user chooses? What tasks should this module accomplish that a simple dropdown (or dropdown with link) cannot?"

The answer is that there is a lot more to Creative Commons licensing than just linking content to the CC license.

I think that reading the road map for the D7 port will shed some light on what is desirable, and why you need a module to accomplish it. To summarize: When licensing content under Creative Commons it is highly desireable that RDFa and ccREL metadata is properly presented, and you need more than a link for that. A CC search option should also be is available.

Looking at the issue queue for the Creative Commons module, it looks like development may have stalled when it comes to porting the more advanced features of the D6 version to D7, but I think it still is worth checking out.

There is also an experimental module named Attributions. It is not only for Creative Commons. It lets module and themes authors who use third party materials (e.g. fonts, photos and icons) that requires attribution register an attribution string in the project's .info-file. All the registered attribution strings from various projects can then be shown together on an attribution page or block.  Disclosure: I am one of the co-maintaners of Attributions.


How to count the total number of cores in apache solr 3.5?

You can find it in your server where solr is hosted in /admin, you will see every core or if you've access to the server you will find it in.

/var/lib/solr/cores/ each folder can be a core.


How to call one file functions in other files in custom module?

It's PHP, so you use require or include to include functions from other files.

Drupal's wrapper around those is module_load_include. Examples from the docs:

// Load node.admin.inc from the node module.
module_load_include('inc', 'node', 'node.admin');
// Load content_types.inc from the node module.
module_load_include('inc', 'node', 'content_types');

Only use this function inside another function, not in global scope. If you need to unconditionally depend on a separate file for a whole module, just use require_once or whatever makes most sense for your use case.


Export a sqlite database through drupal admin?

Not aware of an out of the box way to get it done in the admin area, but you shout be able to back the sql lite file up by downloading it in cpanel or ftp. There is a discussion about doing just that right here https://www.drupal.org/node/1156588


How to load sliders on subsequent pages in GD Infinite Scroll?

user gooddesignusa kindly showed me a solution:

scripts.js in the theme folder has to be like this (can also be created if no scripts.js is there):

(function ($, Drupal) {

  Drupal.behaviors.STARTER = {
    attach: function(context, settings) {
      // Get your Yeti started.
    }
  };

  //runs on document ready.
    $(function(){
    //checks for autopager function and checks if ID of view is on page
    if($.autopager && $('#gelaendespiele').length){
      //binds ajaxSuccess
      $(document).bind('ajaxSuccess.autopager',function(event, xhr, settings){
        //rerun function after ajax is done loading
        $(this).foundation('reflow');
      });
    }
  });

})(jQuery, Drupal);

Then I had to uncomment line 72 of my info file (make sure scripts.js is included)

Finally clear all caches.


'User Account' menu link does not show to anonymous users

That is a feature. An anonymous user doesn't have an account nor can he log out, why should there be links to these pages?

You might want to update your question to better explain what you actually want instead of explaining how it works right now :)

EDIT: To have a link to the Login page, just create a menu entry that points to /user/login. Just like /user/logout, this link will only be shown if you can log in (which means that you are not already logged in).


Copying field values from one EntityForm to another on submit

If you don't mind using query parameter for passing value. Prepopulate would be your choice.

Example code:

function extra_inschrijving_default_wp_submit($form, &$form_state){
  $values = &$form_state['values'];
  $prepopulates = array(
    'edit[title]' => $values['title'],
  );
  $form_state['redirect'] = array(
    'node/add/article',
    array(
      'query' => $prepopulates,
    ),
  );
}

$prepopulates is an array for query parameter which will pass the pre-filled values to the node add form. The array keys specify the fields prepopulate to. You can learn how to set the key from the handbook page.

At this moment, the latest stable version 2.1 has a known bug and it is discussing here. If you the module is not working on some field, you may need to add the patch in the thread. I don't recommend the older stable version because 2.1 has fixed an exploit.


Is there a way to add a persistent querystring across multiple pages?

The way I would go about this would be to dedicate an alias subdomain and perform the redirect before hitting the application.

For example, Apache can be configured via mod_rewrite to add any query parameter to the requested URL:

  # Add iframe=1 to query parameter if requested from iframe domain.
  RewriteCond %{HTTP_HOST} ^if.example.com [NC]
  RewriteCond %{QUERY_STRING} !iframe=1 [NC]
  RewriteRule ^(.*)$  http://if.example.com/$1?iframe=1 [L,R=301]

The only problem this causes is that D7.5 now forcing iframes to only originate from the same domain so you'll have to explicitly allow iframing from this different domain in your settings.php:

# Allow iframing on host requests to the iframe domain
if ($_SERVER['HTTP_HOST'] == 'if.example.com') {
  $conf['x_frame_options'] = '';
}


Adding Where clause in Views Query using a custom filter Handler

function query() {
        parent::ensure_my_table(); #$this->ensure_my_table();
        $alias = $this->table . '_' . $this->view->base_table;
        $operator = ($this->value['0']) ? 'IS NOT' : 'IS';
    $this->query->add_where(0, $alias . '.pid', NULL, $operator . ' NULL');
        #debug($this->query);
        parent::query();
    }


How do I programmatically get the content title field from a view?

Try with this out:
The following example with hook hook_preprocess_views_view

/**
 * Implements hook_preprocess_views_view().
 */
function myModule_preprocess_views_view(&$variables) {
  $view = $variables['view'];
  $result = $view->result;
  //- Titles Array
  $titles = [];
  for ($i = 0; $i < count($result); $i++) {
    $titles[]= $result[$i]->_entity->title->value;
  }
}


You may try using the module Block Group. You can group multiple blocks into a single block using this module.


In the official documentation

says the following:

  "#resizable": Controls whether the text area is resizable. Allowed values are "none", "vertical", "horizontal", or "both" (defaults to "vertical").

in this documentation we can see, that this property "#resizable" is applicable only to textarea.

Then, you can try:

function test_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form_id == 'node_page_edit_form' || $form_id == 'node_page_form') {
    $form['body']['widget']['0']['#resizable']='horizontal';

    //or
    //$form['body']['widget']['0']['#attributes']["style"]="resize:vertical";

  }
}

if you change the text format in "restricted HTML" you will see

if you want to use the "both" parameter

function test_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form_id == 'node_page_edit_form' || $form_id == 'node_page_form') {
      $form['body']['widget']['0']['#resizable']='both';

  }
}

if you change the text format in "restricted HTML" you will see:


Altering Webform email %value before sending email

In hook_form_alter, add a new submit function before the other submit handlers, like so:

pwe_webform_form_alter(&$form, &$form_state, $form_id) {
  switch($form_id) {
  case 'YOUR_WEBFORM':
       array_unshift($form['#submit'],'pwe_webform_form_submit');
       break;
  }
}

And then write your submit handler, something like this:

function pwe_webform_form_submit($form, &$form_state){
  $form_state['input']['submitted']['last_name'] = ucfirst($form_state['input']['submitted']['last_name']);
}

You can intercept the submit handler with dpm($form_state['values']) calls, to make sure you're using the right array keys, etc.


for show the subdirectory site in the root I followed this guide.
I hope it could be usefull for you too ^^


Jquery ticker in a drupal block isn't working

In your js file, you are depending on the $(document).ready(function () {} ); to initialize your jquery stuff, but your content is being added via ajax ( if I understand correctly ), so this code will never fire, as the document is already loaded at that point.

This is the reason behaviors have been implemented in drupal.

If you change this to initialize your code in a drupal attached behavior, like so:

(function ($, Drupal, window, document, undefined) {
    Drupal.behaviors.stockTicker = {
        attach: function( context, settings ) {
            page.trendDescriptions = {};
            loadTrendDescriptions();
        }
    }
})(jQuery, Drupal, this, this.document);

or something of the sort, that may fix your problem. You'll need to look into the once() function, to prevent the code from running every time any content is added to the page, but for now, try a behavior and see if you get js behavior


Allow users to edit just the vocabulary that belong to them?

The Taxonomy Delegate module (http://drupal.org/project/taxonomy_delegate) and the Vocabulary Permissions (http://drupal.org/project/vocabperms) let you delegate administration of a taxonomy to a role, but they do not do it for an individual user. You might be able to write a custom module from here, but what you're proposing goes a little against the role-based permission architecture. My search didn't seem to find one that does exactly what you want.


How to get a rendered output field from view object programatically

Use the following code.

foreach ($view->result as $row) {
  // Change the full view with your view mode.
  $render_array = $row->_entity->field_slider_banner->view('full');
  $field_slider_banner_markup = \Drupal::service('renderer')->renderRoot($render_array);
}

Alternatively, you can use the following code.

foreach ($view->result as $id => $row) {
  $my_field_value = $view->style_plugin->getFieldValue($id, 'field_name');
}


How to import external database table into Drupal database table?

You have at least 2 choices, none of which is easy in my opinion.

Import the non-drupal-users into drupal using a tool such as Migrate to actually map the new fields into drupal fields, you can use hook_schema_alter() and hook_entity_propery_info_alter() to tell Drupal about these new fields that Migrate is moving over.
If you dont merge these tables permenantly into 1 drupal "users" table you're kinda making more trouble for yourself. You could implement your own authentication method to do an SQL query against your (non-drupal) Users table and if the visitor is found there create a new Drupal user account for them. To do so you'd basically create your own login logic as loosely described here for an external source, Blog Tutorial


How to handle a Drupal core change that have an impact in the next release of a contrib module?

There is no need for a new branch in your module as long as your own API doesn't change IMHO. The version definition will prevent that users update too early.
There is also no need to continue providing versions compatible with old core versions, they are no longer supported.

If it's just about deprecated usages, there's no reason to hurry, you can easily wait a few month/next core minor before starting to use it to give your users time to update. All those deprecated functions will only be removed in the 9.x branch, so you have plenty of time to update. It's different if core broke something in your module and you're forced to update asap or if there is a completely new API that you'd want to use.

See also last paragraph on PHP 7.1 requirement for Doctrine packages: Their PHP version dependency is similar to your Drupal core dependency.


What are best practices for creating node relationships?

Your best bet for this kind relationship is going to be Taxonomy. You can create a free tagging vocabulary (exactly like the vocab that is initialized with the Article content type in a standard profile D7 install) and as these "Authors" come up with a need for a "Pseudonym" you just tag that node with it's term.

Views supports most every use case (if not all) you can imagine working with Taxonomy.

Because Taxonomy is core it's further developed and easier to use than alternative relationships (references, hierarchy, etc).

For the above example, you'd could configure the view to display all (full, teaser) or part (fields) of the "Author" content type based on being tagged with the relative "Pseudonym". Views are a little daunting at first but if you keep playing with them, you'll soon realize their immense capability.

Just comment if you need clarification on any of the above...


I ended up doing 12 rules as @nvahalik suggested. Here's an export of one of them. Doing the others is just a matter of cloning this rule and changing weight, territories and shipping price accordingly

{ "rules_dk_shipping_1_499g" : {
    "LABEL" : "DK shipping (1-499g)",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "Commerce Checkout", "Commerce Payment" ],
    "REQUIRES" : [
      "rules",
      "commerce_physical",
      "commerce_order",
      "commerce_line_item",
      "commerce_shipping"
    ],
    "ON" : { "commerce_shipping_calculate_rate" : [] },
    "IF" : [
      { "data_is" : { "data" : [ "commerce-line-item:type" ], "value" : "shipping" } },
      { "data_is" : {
          "data" : [ "commerce-line-item:commerce-shipping-service" ],
          "value" : "by_weight"
        }
      },
      { "entity_has_field" : {
          "entity" : [ "commerce-line-item:order" ],
          "field" : "commerce_customer_shipping"
        }
      },
      { "commerce_physical_rules_order_weight_comparison" : {
          "commerce_order" : [ "commerce-line-item:order" ],
          "operator" : "\u003E=",
          "value" : "1",
          "unit" : "g"
        }
      },
      { "commerce_physical_rules_order_weight_comparison" : {
          "commerce_order" : [ "commerce-line-item:order" ],
          "operator" : "\u003C",
          "value" : "500",
          "unit" : "g"
        }
      },
      { "commerce_order_compare_address" : {
          "commerce_order" : [ "commerce-line-item:order" ],
          "address_field" : "commerce_customer_shipping|commerce_customer_address",
          "address_component" : "country",
          "operator" : "is one of",
          "value" : "DK"
        }
      }
    ],
    "DO" : [
      { "commerce_line_item_unit_price_amount" : {
          "commerce_line_item" : [ "commerce_line_item" ],
          "amount" : "3300",
          "component_name" : "shipping",
          "round_mode" : "0"
        }
      }
    ]
  }
}


How can I put a time-delayed lock on a node?

http://drupal.org/project/user_alert is a good module combined with "Job scheduler" or a trigger module for timing should be Fine. but you may have to get creative with the setup. also try http://drupal.org/project/notifications


How to tell if you are on a view page in preprocess_page

That function will error because it does not exist in Drupal 8.

You can do this though:

$view_id = \Drupal::routeMatch()->getParameter('view_id');
$view = \Drupal\views\Views::getView($view_id);

Be sure to validate view_id first though, that it exists/length before calling the second line.


How to send an email with a download link?

The Functional Overview of the Webform Protected Downloads module seems to be like so (from its project page):

  This module provides protected downloads using webforms. When you create a webform you can select which of the attached files you want to protect. You need to specify the webform field used for the confirmation mail (this must be a mandatory email field) and how long the download should be accessible after the user has submitted the form.
  When a user submits a webform with protected files he will be sent an email with a link to the downloads page. The link contains an individual hash code that will be checked upon page load to verify the access. If verification fails access will be denied. If it succeeds the user will see the default private upload file listing with all protected files that are attached to the webform.

Pretty sure you can build something similar (or close) by using the Rules module instead, which integrates nicely with Webform via the Webform Rules module. By using the Rules module you can, for example:

Perfectly tune the entire content of your eMail to be sent. Have a look at these (working) samples of sending eMails using Rules.
Perform all sorts of redirects, based on the actual URL being used. Have a look at these (working) samples of performing redirects using Rules.

What else would you need?

Video tutorials

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


Remove content translation links from contact form

If you want to hide that button, you can use the CSS Injector module, create a CSS class to apply to that data, and set display:none !important. It's not necessary to use a Drupal hook.


How do I make a view block with picture of the currently logged-in user?

Create a new view /admin/structure/views.

Add  a contextual filter in view: User: User ID and configure.

Add picture field.
Save.
Show block where you need.


How to add a checkbox to a Content Type and act if box is set to true or yes

You can add a field in a number of ways:

Edit the content type and add a Boolean field through the UI
In your .install file as you already mentioned
Using hook_form_alter() to add a #checkbox.

If you used option 1 or 2 you can pick up whether the field is checked or not using hook_node_presave() or hook_node_update().

If you used option 3 you'll probably need to add a #submit value to the form which calls a custom function in your module.


Let user join an organic group during site registration

You must enable the module:

Organic groups register (Allow subscribing to groups during the user registration)


Do not include certain pages from Search

I haven't tried this in Drupal 7, but it doesn't seem to have changed much. There is an easy "hack" and a "better" way to do this:

The easy way is to override search-result.tpl.php. You can copy the default search-result.tpl.php file from the core search module into your theme. Then, inside the template you can use code like this to exclude results based on node ID:

 if ($result["node"]->nid != <excluded nid>) {
      // search result display code
 }

The only drawback with this approach is that you will have certain pages of search results that have less results than others (if you show 10 results per page and you don't display 3 on one page, then you will only have 7 results). You could also do similar hiding in template_preprocess_search_result with the same drawback.

The right/"better" way to do this is to actually exclude the list of nodes from ever being indexed. To do that you'll have to implement hook_query_alter. You can check out a post describing exactly how to do this over on Phase2's blog.

As you can see in the blog entry, you can also exclude by content type.

Note that the Drupal 6 way was to use hook_db_rewrite_sql. There is a post over at Lullabot on that.


Best Practices? Create dynamic links with static titles on node full view page

This is how I do mine if it's entity reference prepopulate:

<?php
        $l = l( t('Add Photo'), 'node/add/photo',   array('query' => array('field_album_reference' => $nid)  ));
        echo $l;
?>

But I usually use node reference widget when for example adding an album coming from venue content type. Code example:

<a href="<?php print url('node/add/venue-photo-album/' . $node->nid); ?>">Add Photo album


Putting additional functionality for Commerce Files/License

Here's what you need to get started.

You'll need to create a new license type and extend the CommerceLicenseBase class (or the file class). When your license class (whose parent class is CommerceLicenseBase) gets activated, the ->activate() method ends up calling ->save(). Your new class will implement ->save() and within that function you can:

Generate a PDF.
Generate or load a README.txt.
Create a Zip file.
Store that file and attach it to some entity, email it, etc.


References module doesn't specify/read a pager limit when field is using a view to generate potential references

I haven't found a neat general solution to this issue, but in terms of a specific solution you can use hook_query_alter. Basically in one of my bespoke modules I added the following:

/**
 * Implements hook_query_alter().
 */
function bespoke_module_query_alter(QueryAlterableInterface $query) {
  if ($query->hasTag('views_autocomplete_for_ref_files')) {
    $view = $query->getMetaData('view');
    if ( !empty($view) && $view->current_display == 'references_lead_image_by_default' ) {
      $query->range(0, 10);
    }
  }
}

  NOTE: Awkwardly there doesn't seem to be an ability of SelectQuery to get back the current range settings. The code could be more general if it could detect that no limit was set.

Out of the above views_autocomplete_for_ref_files is the machine name of the reference list view, and references_lead_image_by_default is the name of the display. I can focus on the default display because I have code elsewhere that switches the view in use depending on certain contexts. The default display is never actually used by the site, except when it is requested by the Views UI (because the widget hook below is not used for the Views UI display).

/**
 * Implements hook_field_widget_form_alter()
 *
 * Modifies the autocomplete path for autocomplete widgets
 */
function bespoke_module_field_widget_node_reference_autocomplete_form_alter (&$element,
    &$form_state, $context) {
  $instance = &$context['instance'];
  $field = &$context['field'];
  /// only step in if the field uses a view to populate
  if ( $field['settings']['view']['view_name'] == 'autocomplete_for_ref_files' ) {
    /// switch the view display depending on content type
    if ( (arg(0) == 'node') && ($node=node_load(arg(1))) && ($node->type) ) {
      $field['settings']['view']['display_name'] =
        'references_lead_image_for_' . $node->type;
    }
    /// hijack the current autocomplete path to point to our own callback
    $element['nid']['#autocomplete_path'] =
      $instance['widget']['settings']['autocomplete_path'] . '/' .
      $instance['entity_type'] . '/' . $instance['bundle'] . '/' . $field['field_name'];
    /// hijack the autocomplete validate function, to validate with our own criteria
    $element['nid']['#element_validate'] =
      array('bespoke_module_node_reference_autocomplete_validate');
  }
}

I'll keep looking to see if I can find a more general solution.


How to create a squeeze page for attached files under Drupal 7?

There are a number of modules out there and I assume you found them, your particular implementation will affect which suits you, but for D6 or D7 take a look at the Comparison of file download gateway and tracking modules.

I have found each of these to be too specific and limiting in some or other way and have resorted to using webform and some custom coding.


A deleted module is appearing in getEditable('core.extension')

There is many reasons for this and most likely the rename hapend before was completely uninstalled...
Here is a few examples of how to make sure its gone for good:

run the following somewhere
 \Drupal::service('module_installer')->uninstall(['wdocsApi']);

or Just

run drush cex to export the active config

Open up core.extension.yml  and delete the reference to  "wdocsApi"

run drush cim to import the config


How do I send an email from a module using an Easy Email module email template?

Sending an email from a custom module using an Easy Email template requires the following steps:

Create a new Easy Email template
Implement [MODULE].emails.yml
Tell the system to use the template from step 1 when sending the mail from your module
Send the mail from your module
(Optional) - Export and save configuration to your module

This example will show how to send an email to admins with the role site_admin when a group (using the Groups module) has applied for a review of some kind. The email requires the Group entity, to provide the group name and a link to the group.

1) Create a new Easy Email template

The email in this example will require a new template, with an entity reference field on the template for the Group entity that the email will refer to.

Navigate to Admin -> Structure -> Email Templates and click 'Add Email Template'.
Enter a name for the template, and make note of the machine name (the email template key). Save and proceed
In the template, set the following field values:

From Name: [site:name]
From Address: [site:mail]

Save.
Find the template you just created in the list, and under 'Operations', click 'manage fields'
Add an entity reference field to the Group entity and save
Back on the email templates listing page, edit the email. Group fields are available as tokens in the template body due to the entity reference to the group. The recipient of the mail is also available, and [easy_email:recipient_uid:0:entity:display-name] will provide the name of the recipient. Example email:

[easy_email:recipient_uid:0:entity:display-name],

The group [easy_email:field_group:entity:title] has submitted an application for something. Please review it.

&nbsp;

Thank you,

--&nbsp; [site:name] team

2. Implement [MODULE].emails.yml

Next, [MODULE].emails.yml needs to be implemented, so that the Easy Email module knows to override the email.

Note that this will require an arbitrary key for the email, that will be used to send the email from the module in step 4. In this example, the email key is group_something_application_received.

# This is the ID of the email override. I have keyed it by
# [ENTITY TYPE].[MAIL KEY].
group.something_application_received:
  # Re-use of the same ID above.
  id: 'group.something_application_received'
  # A label to be shown on the email override interface.
  label: 'Group: Custom domain application received'
  # This should be replaced with the machine name of the module.
  module: 'example'
  # The email key. This will be used by the module to send the email.
  key: 'group_something_application_received'
  # An array of parameters. At a minimum, account will be required for
  # the recipient of the email. In this example, Group is also required
  # to fill in the group values of the template.
  params:
    account:
      type: 'entity:user'
      label: 'Account'
    group:
      type: 'entity:group'
      label: 'Group'

3) Tell the system to use the template from step 1 when sending the mail from your module

The next thing is to link the email the module will send to the template created in step 1.

Navigate to Admin -> Structure -> Email templates
Click the 'Overrides' tab (note - requires the Easy Email Override module to be enabled)
Click 'Add Email Override'
Give it a label. Under 'Email to override', select the value entered for 'label' in `[MODULE].emails.yml'. Under 'Easy email template', select the template created in step 1. Save.

4) Send the mail from your module

Finally, emails can be sent using the system default email manager. The Easy Email manager will handle the rest of it. In this example, the email is being sent from the submission handler of a form that stored a Group object in the form state.

/**
 * {@inheritdoc}
 */
public function submitForm(array &$form, FormStateInterface $form_state) {
  $group = $form_state->get('group_entity');

  // Do some submission stuff (not shown).

  // Get the UIDs of all users with the site admin role.
  $uids = $this->entityTypeManager->getStorage('user')->getQuery()
    ->condition('status', 1)
    ->condition('roles', 'site_admin')
    ->execute();

  // Load the admins.
  $admins = User::loadMultiple($uids);
  // Loop through the admins, and send the email:
  foreach ($admins as $admin) {

    // Send an email to the admin using the mail manager.
    \Drupal::service('plugin.manager.mail')->mail(
      // The module machine name:
      'example',
      // The email machine name (use the same one declared in [MODULE].emails.yml)
      'group_something_application_received',
      $admin->getEmail(),
      $admin->getPreferredAdminLangcode(),
      // Populate the parameters declared in [MODULE].emails.yml:
      [
        'account' => $admin,
        'group' => $group,
      ]
    );
  }
}

5) (Optional) - Export and save configuration to your module

This step is optional insofar as the module will send mail after completing step 4. However, if the module is to be used in multiple systems, default configuration should be exported from the system and saved to the [MODULE]/config/install directory. The configuration exported should be:

Template configuration for the easy email template
Override configuration for the email override

Note that if you wanted your module to easy-email compatible, but not dependent, you can put the configuration in [MODULE]/config/optional, and do not declare the Easy Email module a dependency. This way your configuration will be used if the Easy Email module is already installed on the system, but will not require it. If you do take this path, you'll also need to implement hook_mail() in your module and react to the key group_something_application_received to create the email text that will be sent when the Easy Email module is not installed.


Views: Insert Profile2 information in a node

You need to have an entity reference field on the node type that allows you to reference a user as the creator of the necklace.
Then you want a node view that has a contextual filter of nid, that uses node id from the url as a default value when no contextual filter value is provided.
Then you can add a relationship to the user via the entity reference field you added.
Then add a relationship for the profile2 profile, so you can use the profile fields in your view.
Add a block view display.
Add the block to your node pages.


How to modify add to cart form in detail

I realise this answer may be a little late, but for those that end up here looking for a way to display the product variation fields (price, add to cart buttons, etc) separately, you can do it through the commerce-product.html.twig template using something like this:

<article{{ attributes }}>
  {{ product.title }}
  {{ product.body }}
  {{ product.variation_price }}
  {{ product.variations }} //show add to cart button
</article>


Why do i get a select dropdown when in mobile view from superfish

This is from a superfish plugin called sf-smallscreen.

You can either change it to kick in at a lower screen width, or you can disable it completely at /admin/structure/block/manage/superfish/1/configure -> Superfish Plugins -> SF-Smallscreen -> Disable


Updating a term reference programatically

You're one level off; this:

$node->computed_file_extension[$node->language][0] = $term->tid;

Needs to be this:

$node->computed_file_extension[$node->language][0]['tid'] = $term->tid;

Without specifying the field column (tid in this case), Drupal doesn't know which DB field the data should be stored in.


Custom commerce payment methods based on item

An administrator can add two payment transactions to an order using different payment methods from the admin > order > payment area.

However an end-user normally selects a single payment method from the radio button form during checkout.

To support multiple payment methods you may need to send the customer through the payment step of the checkout twice, each time with a different amount and a different payment method selected.

Payment method selection is controlled by Rules logic and can be configured there.
The order status controls whether it can be sent through checkout again so may need to be set to the relevant checkout status.
The order amount to be paid may need to be set in custom code during the payment step process.


If you add something like

reCAPTCHA

to your form, that should stop the spammers in their tracks.

If the form is auto-populated by a bot, it should prevent adding spam content in any of the form fields as they won't be able to submit the form without passing the challenge.


Pre-populate an Entity Reference when Adding a Node : Based on URL Alias

Your latest update mentions you're having trouble constructing the link, so I'll focus on answering that.

It seems that if you construct the link manually (simply type in the addressbar) everything is working correctly (this is to test that the Entityreference prepopulate module is working correctly on your side).

The problem then seems to be how to construct the link automatically for each of your game nodes, so that by clicking on the link, a Profile creation form is shown with the relevant entity reference prepopulated.

Add Prepopulate links to Views

In your Games views add a field Content: Nid and Exclude from display
After that field (it's important the Nid comes before this) add a new field Global: Custom text
In the Text textarea of that field enter:
Add new Profile referencing this Game

Check that the token really is [nid] under Replacement patterns.

Now you have a list of Games with links that when clicked open the Create profile page with the related Game pre-selected.

Add Prepopulate links to Node pages

If you need to display the link on the actual node page, you can se the same Views as above only create a Block with a Contextual filter.

This has to be done through Views block because the module you're using (Entityreference Prepopulate) doesn't have the URL widget feature implemented so you have to work around it.

Create a Block display View of Games
Add the same Fields as above (use the same Views)—the hidden Nid and Custom text with the link code.
Add a Contextual filter Content: Nid and configure it:
When the filter value is NOT available
Provide default value
Content ID from URL

This will limit the list to show the Prepopulate link for the current node only, otherwise it would show links for all games, like above.

This filter isn't responsible to the link contruction! Link is being constructed using the Fields!
Place your block in Content region or whereever you want the link to display, restrict the Block visibility to Game pages

Visit some Game pages and click on the links, see they are prepopulated with the nodes where you clicked the link.


Can I group fields by their Field Group in Views?

Field group doesn't actually do anything with regards to data storage or grouping, it only provides fieldsets and formatters for data entry and grouping fields together on display.

It seems to me that you'd find either Field Collection or Tablefield more useful for this use case.

With TableField, you can just output the field in Views, as it's already a table.

With regards to Field Collection, it's a little more work, but much more flexible. You should be able to add a relationship in Views to the the field collection entity that contains your fields, and then group by the entity ID of said field collection in views.

You will also probably have to use something like Views Field View to embed your grouped Field Collection fields into your original view if the other fields aren't to be laid out like tables..


There is no functionality for this in core in the UI. You could do a entity load + delete with drush ev/core-cli or console, but that's basically your only option.

File entity does offer a UI for this, but you possibly don't want to use it anymore.

That said, setting that setting to Never is IMHO the wrong solution, as it also doesn't delete files that were only uploaded but then for example removed again or never really submitted. See https://www.drupal.org/node/2801777 for more information and another solution for that.

That said, when using media_entity, it should be save to configure Drupal to delete unused files as the media entity itself will always count as a usage of the file, so it will only ever get deleted if you manually delete a media entity.


Detect page redirection and execute code

You may be able to use hook_drupal_goto_alter to achieve this. It'll get called during the processing of the redirection.


drupal_goto is not refreshing the webform on submit

If you redirect to a URL that does not return a page but instead returns some other type of resource (such as a PDF in this case), then the current page will not be refreshed, as you have observed, because the response to the form request is returning the PDF, not HTML.

If you want the page to be refreshed as well then a common technique is to return the HTML for the new page from the form, and then redirect again to return the PDF. Because you need the new page to load fully (so the browser renders it), you'll need to use JavaScript to provide the redirect to the PDF. You can have a link in the page as well, to say something like "If the file does not download automatically, click here".


You may define 'type' => 'serial' if you want to auto increment your primary key.


Changing an exposed filter to use check_plain() or filter_xss()

You can write a form alter in your custom module. ie :

function mymodule_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'views_exposed_form') {
        $view = $form_state['view'];
        if ($view->name == 'my_view_machine_name' && $view->current_display == 'display_name') {
            // alter your exposed form here
            $form['yourdata_item'] = check_plain(filter_xss($string));
        }
    }
}


I found out that the Drupal for Facebook module has User Management capabilities which allows me to automatically assign a temporary role to any users authenticated via Facebook. I added a role and changed the permissions to allow for the posting of my custom content type. Everything is working now! Hope this helps someone!!


Why cannot anonymous users vote, even though they have permission for it?

A possible explanation for this might be what is described in this issue on D.O: Fivestar Not Working for Anonymous Users with Cache Enabled.

A possible workaround for it is mentioned in Comment #9 of that issue, which states:

  ... When I set the author to anonymous on the field also set the field to allow users to vote on their own content, this appears to work as a crude work around.

Curious to hear if this somehow helps ...


No option to validate for email in drupal webforms validation

Currently it seems there is no such functionality, as it still sits in issue queue as a feature request. You can either:

Use plugin from feature request, it's already there in issue queue.
Use regex validator, with one of the rules you choose. Simplest "usually OK" would be \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b and you can find more at Regular-Expressions.info


Sending an email using phpmailer drupal 6

You should consider using drupal_mail for sending email from Drupal. That will make sure Drupal can control your mails. For example say, you are using some module like Re-Route Email or maillog.

  $params = array(
    'subject' => t('Client Requests Quote'),
    'body' => t("Body of the email goes here"),
  );

  drupal_mail("samplemail", "samplemail_html_mail", "me@site.com", language_default(), $params, "admin@site.com");

/*setting up our mail format, etc in hook mail*/
function hook_mail($key, &$message, $params)
{
    case 'samplemail_html_mail':
          /*
           * Emails with this key will be HTML emails,
           * we therefore cannot use drupal default headers, but set our own headers
           */
          /*
           * $vars required even if not used to get $language in there since t takes in: t($string, $args = array(), $langcode = NULL) */
          $message['subject'] = t($params['subject'], $var, $language->language);
          /* the email body is here, inside the $message array */
          $body = "

HTML Email with Drupal

              {$params['body']}
              ";
          $message['body'][] = $body;
          $message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
          break;
}

You would invoke this in your code somewhere. Or else you can use the rules module to send email as per some events or actions in the site.

If you still want to use PHP Mailer, you have module to do that here.

you can see a screencast on using rules to send email here.


Display views result from a certain entry on

As far as I can tell, you have no choice right now but to write a simple custom module which would use the current user name and output themed results of a corresponding query.

Though of course it would be nice to be able to use the Views UI in this, so I understand that perhaps this is not the best solution for you.


'process' is not recursive - you can't simply embed processing within another plugin in the general case (only iterator has that ability). Rather, plugins (generally) need to be executed in sequence:

field_subject_terms:
  # First step in the processing pipeline.
  -
    plugin: explode
    source: subject_terms
    delimiter: ','
  # Results of the first step are passed through to the second step.
  -
    plugin: entity_generate


I doubt that's possible, or at least not without messing with a lot of core code.

User 1 is synonymous with the root user in linux. It can be disabled, hardened, made virtually impossible to access, but not removed.

See Securing user #1 for more information.


How can I apply different templates based on taxonomy hierarchy?

What template exactly? taxonomy-term.html.twig, I guess?

You're looking for template suggestions. See Working with template suggestions on Drupal 8 for a similar question.

You can implement hook_template_suggestions_TEMPLATE() and then provide alternative file names for whatever condition you can think of.