I believe devel generate uses a pattern like [FIELD_NAME]_devel_generate() when deciding who/what to ask for generated data, and then devel implements those functions itself for the core fields.

Unfortunately I don't really see a way to alter this behaviour as there is no Factory pattern or similar that one could use to instantiate derivative/overridden functionality.

What my team usually does is creating content more to our liking in the install profile. This allows us to gradually build in some basic content that the client will want anyway into the development process, and we use a variable to tag nids that won't be useful one we go live, so that we can easily remove the junk content.

If we stick with using devel, here's what I would do:

Hack the module. The code you are looking for is in devel/devel_generate, and then split up into many files, mostly one for each type of content it creates.
Make the functionality generally useful.
Post a patch in the issue queue saying. "I wanted to use devel like this instead, is there a way to incorporate this into Devel?".


Reject Form Submissions with URL in them

It is possible to create contact forms using either the Webform module, or the Entityforms module.

The beauty of the latter is the ability to attach fields, and to validate those fields with the Field Validation module, which offers a wide range of validation options.

There is a Webform Validation module for use with Webforms, but I think you will find Entityforms with Field validation to be a little more flexible and, perhaps, easier to use.

Either one should let you scan text for say "<a href=" or any other undesireable word or phrase (blacklist matching) or constructs using regular expressions, if you are so inclined.


Adding dynamic and multiple fields for user profile using profile2 module in Drupal 7

Old question, but I have to say that Ankit's comment was on the right track. Install and enable Field Collection, because you will use this to group each instance of your education details fields.

Depending on whether or not you use Profile 2, create a Field Collection-type field at /admin/config/people/accounts/fields or /admin/structure/profiles/manage/<profile_type>/fields. The number of values for the field collection field should be greater than one or unlimited. Finally, create your education details fields at /admin/structure/field-collections/<field_collection>/fields.


How do I configure Content Security Policy for base64 images?

Based on this Stack Overflow answer, you need to add data: to Additional Sources:
data: https://www.google-analytics.com https://ssl.gstatic.com https://www.gstatic.com https://www.googletagmanager.com


How do I get the field label from a node object?

Your first guess was very close, but both are protected properties, so are accessed by getters - functions with the prefix get:

$field_label = $node->field_name->getFieldDefinition()->getLabel();

For reference:

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Field%21FieldItemInterface.php/interface/FieldItemInterface/8.2.x

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Field%21FieldDefinitionInterface.php/interface/FieldDefinitionInterface/8.2.x

Edit:

Btw, in twig you don't need the prefix get, because if you tell twig to get something with the name label, it  tests all possibilities on the object, first it tries to access the property label, then the method label() and finally the getter getLabel().

{{ node.field_name.fielddefinition.label }}


IMHO the best way is to add the taxonomy's name to the index.  This may not be shown as an option in D7 if you have not asked for the fields to be extended to the referenced entities.

Note: expanding the field list in D7 can make the field list take Minutes to load and you may get a few script running long warnings.  Be patient and let the script keep running.  The list will come up eventually.

Once you have the text in the index, you can use this in either the search view filter or use it in a facet.

An alternative would be to add a relationship between your term id search field to the actual term data.  Then you should have the term name available for use.

Note that this method will add a lot more overhead to your search than just having the term names in the index.


How can I rearrange taxonomy weights for terms with two-deep hierarchies?

For such small taxonomies (large and frequently changing ones will be a pain) you may create special custom field for flat sorting order, since weights are meant to be used on a certain hierarchy level:

Then you just add some sort criteria to your views:

Considering this terms structure:

you will get this output:

Good thing: this requires no code hacking at all, yet supports all Views features like caching.

Bad thing: you will go mad with setting this field values for large vocabularies.


I found I can add an action handler that uses the select list to populate the Webform Permissions by Term element like I was thinking.

With a select list called Institution, using keys that match term keys in a taxonomy, the Update data with YAML section of the action handler can use this:

wf_permissions_by_term_element: '[webform_submission:values:institution:raw]'

The element gets updated on form completion and update, and individual result access is still limited by the Permissions by Term module.


You can create such tables with the Views module.

  You need Views if:

  You like the default front page view, but you find you want to sort it differently.
  You like the default taxonomy/term view, but you find you want to sort it differently; for example, alphabetically.
  You use /tracker, but you want to restrict it to posts of a certain type.
  You like the idea of the 'article' module, but it doesn't display articles the way you - like.
  You want a way to display a block with the 5 most recent posts of some particular type.
  You want to provide 'unread forum posts'.
  You want a monthly archive similar to the typical Movable Type/Wordpress archives that displays a link to the in the form of "Month, YYYY (X)" where X is the number of posts that month, and displays them in a block. The links lead to a simple list of posts for that month.


How can I programmatically delete a user?

This is not that hard, for D6 it would look like this:

Delete record from Drupal database users table;

user_delete(array(), $uid);

Change author on any content created by deleted user to Anonymous;

handled by the node module.
Send an email to our internal support address letting them know that the user should be removed from other non-connected systems

drupal_mail(...);

See hook_mail for details.


How to create basic Organic Groups functionality with flags and references?

1. Users can create groups:

To create groups you just create a new content type "groups" and with permissions for users to create new content. I also added an image field to allow uploading a group logo.

2. Users can join groups (and leave them) without approvals or permissions

The Flag module turned out to be an excellent way to allow users to join (and leave) groups. Create a new flag called "groups" and make sure the "global flag" is unchecked and then select your "groups" as "flaggable content". You can also customize the flag links to say "join this group", etc.
Btw, just changing the default link text is hard in OG.

3. Users can add other nodes to show up as group content

To assign other nodes to the "groups" content type I used node references from the references module. I also looked at (and used before) entity references and DA members seem to prefer entity references.

Node references however has more installs and comes with a nifty "References" feature that allowed me to filter the "available groups" on a node add/edit page to only the groups that have been flagged by the user.

To allow my photo nodes to be assigned to the groups type I add a "group_content" field to the photo type and select "node reference" as the field type. You can specify the widget type (autocomplete, checkbox, select list), I picked checkbox and 5 as the "number of values".
For "content that can be referenced" you simply select your "groups" content type.

With this setting you can create a new photo node and assign it to ANY of the groups that have been created so far. To limit it to a user's groups you create a view for "content of type = group" and then add relationship "Flags: Node flag" with the setting "include only flagged content" checked. Select your "group flag" and select "current user".

Now your view only shows groups flagged by the current user. Click "Add" below "Displays" and select "References", then save.

Now edit your photo content type again and edit the "group_content" field. At the bottom you there is an option for "The list of nodes that can be referenced can be provided by a view" and you should see your new view as an option. Select that and save.

You can create similar references from other nodes by using "add existing field" in "manage fields" of the content type.

4. Use views to display group content and group membership

Now all that is left is creating some views. For example, I want to show a list of users and a list of group content on a group page.

In OG these views are complex, see an example of group content view and users of a group.

With Flags and Node References they are very simple:

List of groups with number of users in each group":

content type = group
add relationship "flags: node counter" with "groups" selected and "include flagged content" not selected
add field "Flags: Flag counter", that shows the number of users
display in a table and enable default sort by title or number of users. Done

List of members that belong to a group:

create a view of users
add relationship "Flags: User's flagged content" with "include only users who have flagged content" checked and "group" as "flagged"
add contextual filter for "Flags: content id" and provide a default value of "content ID from URL"
create a block view to show the first 5 users with a more link to show all users on a page. Select that block to show up for your "group" content type

Show list of nodes that are assigned to a group:

create a view with content type = photo for example
add contextual filter "Content: Groups (field_group_content) - that's the node reference field we created above. Select "content from URL" as the default value and now you'll only see photos assigned to the current group.
create a block to show the most recent 5 with a "more" link to a page showing all. Then enable the block to show for type "group".

That's it. As an additional benefit I could import my legacy group membership and group content with a couple of basic SQL INSERT statements.


Trying to use these modules may help you (quotes included are from their project pages):

Responsive Images:

  ... integrates the Responsive Images library created by Filament Group.

  The purpose of this library is to load images in different sizes based upon
  the resolution of the browser loading the page. This allows for mobile-optimized images.

  ... provides a "Responsive Images" image field formatter for which you can select
  both a small (mobile-optimized) image style as well as a large (for normal screens) image style. The image style configuration options are provided by Drupal core.

Responsive images and styles:

  ... solves the problems with images and responsive themes, it allows you to define multiple image style suffixes and their corresponding maximum width.


Allow users to choose from multiple avatars while registration in drupal 7

Have you tried Avatar Selection for custom images ?
Also you can try the Gravatar module to use with this service.


Views filter criteria multiple content types (Drupal 7)

This can be done by modifying the Views filter criteria.


Taxonomy images display in different view rows

Received answer from @Lendude on drupal forums here:

  Yeah, adding relationships will add rows, that is the way of SQL
  queries.

  If you enable aggregation and then group the results on the right
  column, that works in some use cases (make sure to set/save the column
  for your image field or you will run into this #2815881: Switching on
  aggregation on generates fatal "Column not found: 1054 Unknown
  column" SQL error when using multi-column Fields) Using the 'rendered
  entity' field with a specific view mode can work. This would possibly
  allow you to remove the relationship from the View itself.


List all fields with the feature they are defined in

Some useful functions /snippets below

field_info_instances();

$features_map = features_get_component_map();

$features_map['field_base'];
$features_map['field_instance'];
return;
foreach (field_info_fields() as $key => $field) {
  $base = isset($features_map['field_base'][$key]) ? join(',',$features_map['field_base'][$key]) : 'NOT IN A FEATURE!';
  $instance = 'todo';
  $rows[] = array($key, $base, $instance);
}
print theme('table', array('header' => array('machine_name', 'base', 'instance'), 'rows' => $rows));
return;

$components = features_get_components();
$field_base_component = $components['field_base'];
features_include_defaults($field_base_component);
$field_instance_components = $components['field_instance'];


Can I display video from youtube and file system in the same field?

Video Embed Field Module:

You need to use Video Embed Field module. This is enabled in filed type in MANAGE FILEDS.If you select a filed to Video Embed and select a widget to Video.
as WELL as MANAGE DISPLAY that  select  format to Video Player. and you add a youtube url to content type that display video format.


You can set #theme_wrappers of the element to empty array so the element will not have any wrapper at all.

$form['email']['#theme_wrappers'] = array();


If you want to access the file uri in the node you have to iterate over the field in the node:

{% for image in node.field_image %}
  {% if loop.first %}

  {% else %}

  {% endif %}
{% endfor %}


CSS not updating with aggregation turned off

Your CSS file may still be being cached, even if not aggregated.
You can refresh the ?oegwy2 querystring with drush

drush cc css-js

Which refreshes the config variable: css_js_query_string

You could also add the following to your dev env settings.php to disable that querystring var:

$conf['css_js_query_string'] = '';

Then you should be able to just use hard reload (e.g Shift+Refresh) to refresh the CSS.


The simplest solution would be to set the cron to run more frequent: every 3 minutes is not unheard of.

However, many modules, including core, do not have a timecheck: they run their code regardless of how long it was since they last ran it. Other modules (also many core) have some "run only every X" implemented.

You will see an impact, but depending on your specific situation, that may, or may not be a problem.

Once that is done, you can implement hook_cron():

function yourmodule_cron() {
  $last_run = variable_get('mymodule_cron_last_run', REQUEST_TIME);

  if ($last_run <= (now() - 180)) {//180 seconds is three minutes.
    # DO SOMETHING EPIC!
    variable_set('mymodule_cron_last_run', REQUEST_TIME);
  }
}

If, however, you cannot run cron this often, you may want to write a cron bypass. In Drupal 6, the route would be, to create a menu-item, with a "secret" token in it (to avoid external folks from hitting that URL by accident/to overlad your server). In Drupal 7 there are (not well documented, AFAIK) methods to create thin requests: my code below will bootstrap an entire Drupal, while you may need only a very simple database-query to be ran without accessing any Drupal resources or APIs.

/**
 * Implementation of hook_menu().
 */
function mymodule_menu() {
  $items = array();

  $items['yourmodule/cron/s0mes3cr3tkey'] = array(
    'title'            => 'not used',
    'description'      => 'not used',
    'page callback'    => 'yourmodule_do_epic_stuff',
    'type'             => MENU_CALLBACK,
  );

  return $items;
}

/**
 * Menu Callback that does epic stuff.
 */
function _mymodule_do_epic_stuff() {
  # Do Epic Stuff.
}

You can then add an additional crontab to call only that url.

It is a very bad idea to run such code in the request of a user:

You don't know if users are visiting every 3 minutes. Even if you have 1000visitors per minute, there are potential situations where no user visits for, say 10 minutes.
You don't want your users to be bothered with maintainance code you run in their request.
You don't want your users to experience faults or errors in your cron-tasks. These tasks can, e.g. check whether some external API is up or down and throw errors on network trouble and such.


How do I show only 3 of the latest posts for each term in a view?

If you need only one node you can use “Representative node” relationship. But if you need three nodes per each term, use something like Views Field View.

1) Create "child" view for content. Something like this:

Add taxonomy term argument, pager limits, sorting and etc:

Now you can attach this view to another one.

2)  Create taxonomy view:

Add hidden term ID field and then add “Global: View” field:

Don't forget to configure caching. From Views Field View page:

  It's highly recommended to use this module in conjunction with views caching.
  Views Content cache and Cache Actions are good ways of caching views.


Hitting the back button after a batch process cause a nasty error

Here's a possible solution, however you'll need to alter the menu callback for patch and wrap the default page callback.

Create your hook_menu_alter() and change batch to be your own page callback function, and update the file attribute (unset if in your .module)

  // Default page for batch operations.
    $items['batch'] = array(
      'page callback' => 'system_batch_page',
      'file' => 'system.admin.inc',
    );

Basically your callback can mimic around the default system_batch_page() page callback. From there you can adjust what happens when someone hits an inactive or stale batch.


Should the plain text filter convert line breaks into p and div elements?

The answer to your question is no, it should not.

But I always want it to and so do my users. For textareas that do not require "fancy" formatting, we have still always wanted line breaks to carry over into the display.

I use this in my theme's template.php to add them to plain_text textarea fields:

/**
 * Implements template_preprocess_field().
 */
function THEMENAME_preprocess_field(&$vars, $hook) {
  // Add line breaks to plain text textareas.
  if (
    // Make sure this is a text_long field type.
    $vars['element']['#field_type'] == 'text_long'
    // Check that the field's format is set to null, which equates to plain_text.
    && $vars['element']['#items'][0]['format'] == null
  ) {
    $vars['items'][0]['#markup'] = nl2br($vars['items'][0]['#markup']);
  }
}


You can either use Profile2, or you can add your fields in /admin/config/people/accounts/fields.

From Profile2 project page:

  Designed to be the successor of the core profile module, which is
  deprecated for Drupal 7. In
  contrast to the deprecated module this module provides a new,
  fieldable 'profile' entity - leverage the power of fields!

You can find out how to create profiles in Profile2 documentation


Theming User Profile Edit Form not Rendering results.... Help?

Add a hook_theme() implementation

function YOURTHEME_theme($existing, $type, $theme, $path){
  return array(
    'user_profile_form' => array(
      'render_element' => 'form',
      'template' => 'user-profile-form',
      'path' => drupal_get_path('theme', 'YOURTHEME') . '/templates',
      //add '/templates' only if you store template files in an additional folder
    ),

  );
}

This tells the Drupal theming system that there's a template file waiting for it in YOURTHEME/templates.
Next we'll define some variables to pass into that template in a hook_preprocess_HOOK function. We can find the structured array of the form in $variables['form'] and assign the form elements to the variables we'd like to throw around our tpl.php file.

function YOURTHEME_preprocess_user_profile_form(&$variables) {
  $variables['rendered'] = drupal_render($variables['form']['account']);
  $variables['rendered'] = drupal_render($variables['form']['picture']);
}

This example will put the general account info fields and the user picture upload field (if pictures are enabled) into a variable called "rendered."
Now that we have defined a variable, we can output it in a template file. Create a template file named user-profile-form.tpl.php in 'YOURTHEME/templates'. This is a demo example:

<div id="new-form">
  <?php echo $rendered; ?>
</div>

When you visit your user edit page, you should now see only some general account info fields and the picture fields. Create different variables in the preprocess function to separate out form elements and place them wherever you wish in the user-profile-form.tpl.php file, adding whatever markup you like.

Taken from HERE


drupal 7: hook intercept url file requests located within the "Public File System Path"

Not as standard, no.

Drupal's .htaccess file has these conditions in it for the main index.php rewrite:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

Which basically means requests for physical, existing files are passed through without Drupal's involvement.

To change that behaviour you'd need to override those conditions, either in the root .htaccess or one underneath the files folder itself. For nginx you'd be doing basically the same thing, except the vhost's config file would be the place for the rewrite logic.

Then you'd need to implement a menu callback at the path files which dealt with all incoming requests for files. That callback would invoke a custom hook, which your module(s) would consume to make decisions about whether or not that particular file should be downloadable. If so, you'd invoke a file pass through, if not a 403.

Long story short, it's not a good idea - you'll put a large amount more strain on your server with all those extra bootstraps (every CSS file, every image, every everything). What you're describing is the private file system, it would be much more palatable to use that.

The public file system is designed to be just that - public.


How to show the distance relative to the user's location?

You need to install the Geolocation Field module and the example submodule that comes with it.

In the examples you will find a view that made exactly what you need, and you only will need to clone and edit the view.

  Geolocation Field provides a field type to store geographical
  locations as pairs of latitude and longitude (lan,lng). The Drupal 8
  version also provides a views proximity search plugin. Geolocation
  Field can be used with all fieldable entities like nodes, users,
  comments, taxonomy terms, etc.


Display field collection items by using twig

That is not a good idea to use kint() to collect the values somewhere in #markupkeys or other render elements. You can get the values from the field object, which is in a field collection an entity which then refers to the children fields. But if you use field collection, you should try first to use the theming, that is provided by this module. That is configure the format of the field collection in ui and then look in twig debug for the templates that are used by doing this and modify them.


How do I display a fixed size Views grid regardless of the number of results?

You can take a look at Views responsive grid.  I'd suggest using it over the built in views grid because it splits up your rows/columns in a more manageable way.

The functionality you're looking for is built into views, under pager.  You would need to set it to use a pager as well as display 6 results.

The section under Advanced -> No results behavior is what you are looking for.


How can I set a message on the page I am `drupal-goto`ing towards?

You are setting a NULL message in drupal_set_message, the correct syntax would be:

if ($userNeedsToBeRedirected) {
  drupal_set_message("You've been redirected because ...");
  drupal_goto('destination');
}

The second drupal_set_message $type parameter is for the message type:

'status'
'warning'
'error'


Trouble enabling view modes for content types

Late answer, but for anyone else looking, to get your view mode to display try either visiting the module page or disabling then re-enabling your module. Afterwards clear the cache.


$.cookie is not a function from form.js with block cache

This happens sometimes as $.cookie function is not supported. In those case you can try following approach.
Place this code in your JavaScript file
function setCookie(cname, cvalue, exdays) {
  var d = new Date();
  d.setTime(d.getTime() + (exdays*24*60*60*1000));
  var expires = "expires="+ d.toUTCString();
  document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

function getCookie(cname) {
  var name = cname + "=";
  var decodedCookie = decodeURIComponent(document.cookie);
  var ca = decodedCookie.split(';');
  for (var i = 0; i var c = ca[i];
  while (c.charAt(0) == ' ') {
    c = c.substring(1);
  }
  if (c.indexOf(name) == 0) {
    return c.substring(name.length, c.length);
  }
}
return "";
}

Then you can use, setCookie(cname, cvalue, exdays) and getCookie(cname) to use set and get cookie functionalities instead of $.cookie.
Hope this works.


Adding Information to Maintenance mode message

If you just wanted to add some text I'd say go into the admin settings of /admin/config/development/maintenance and update the text but if you want to add dynamic code like a facebook Iframe like button you're probably better off adding the code to a custom maintenance-page.tpl.php in your theme. Grab the code from Facebook and twitter and paste.

Just add it below the line that reads

<?php print $content; ?>

Drupal api reference - https://api.drupal.org/api/drupal/modules!system!maintenance-page.tpl.php/7


I might be wrong but I believe (most) dates in Drupal are simply stored as 11 digit integers. The format you refer to is only whats displayed on the page. Your migration probably just needs to be moving the integer date data by simply moving the data from your source csv column into your new profile2 Drupal Field:

$this->addFieldMapping('csv_birthday_column', 'new_profile2_birthday_field');

Then you just use a Profile2 Manage Display under the Field UI to setup how you want it to look on the page such as d/m/Y.

EDIT:

If your CSV has for example "04/15/2013" as a date for a piece of content you could use PHP strtotime() in a Migration class prepareRow() function to get an integer value to save in Drupal.


How to create a user with custom fields?

You are close to the right solution. You have to add 'field_organization' => 'some_value' to your $user_data array.

They keys in the $user_data array is the field names. The field name is what comes after user__ in the table name. You can also see the field name in the UI where you add the fields (it’s also called machine name).


When creating a view, choose for Show: Taxonomy Terms instead of the default selected Content.
Than you can define the Type of you terms and using a contextual filter (it is for Drupal 6, but the idea is the same) only show the terms that are a child of term page your on.


hook_preprocess_views_view not loading view when records are empty

I found out the solution to add files to specific 'View Pages'. Need to use hook_preprocess_page in template.php and check the view_name. Here is the code that worked for me.

function mytheme_preprocess_page(&$variables){
if($variables['page']['#views_contextual_links_info']['views_ui']['view_name'] == 'my_view_name'){
    drupal_add_css(drupal_get_path('theme', 'mytheme') .'/css/sample.css', array());
    drupal_add_js(drupal_get_path('theme', 'mytheme') .'/js/sample.js');}


Can I aggregate all stylesheets core, contrib and custom into one single stylesheet?

Enable aggregation of css by going to admin/config/development/performance

This is the best Drupal 7 can do without the need for any contrib module

You can also try Advanced CSS/JS Aggregation which gives some more advanced aggregation.


How to programmatically determine if the cron is running

In Drupal 7:

To determine if the current page request is a request for cron:
in other words, "is my code being called during cron"?

If you're running cron through cron.php, this is probably sufficient:

return strpos($_SERVER['REQUEST_URI'], 'cron.php') !== 0;

A more reliable way to determine a cron would be through introspection (e.g. debug_backtrace()), but that would entail a much greater degree of overhead.

To determine if any cron request is still running, across all Drupal threads and pageloads: in other words, "is any process running cron anywhere?" * Note that this method will fail if cron is stuck.

Drupal will programmatically set a variable called cron_semaphore while the cron is running. This variable is deleted once cron has completed. You can check for the presence of this variable to determine whether cron is currently active or not:

if (variable_get('cron_semaphore', FALSE)) {
  // cron is running
}

You can see the specific use of cron_semaphore in the documentation of drupal_cron_run().

The 'tasks being ran' will be implementations of hook_cron, which you can find using:

foreach (module_implements('cron') as $module) {
  $function = $module . '_cron';

  drupal_set_message($function . '() is being ran');
}


How to set a default value for Simple hierarchical select?

Hmm, That's a challenge to set default with Simple hierarchical select using form alter.

As they are handling options to taxonomy in js.

But we have another way to set default value for the field. Passing in URL.
Like : http://localhost/drupal/demo-view?field_test_tid=1

Hope this will help.
Just trying other way.


How do you properly use "Fetch entity by id" in Rules in order to access its fields?

I got to this question whilst searching for a different solution to my own problem, but I think I know what's wrong anyway, even if it's 2 years old, it might help someone in the future :P

I think you have to add a condition to determine the type of Entity you are looking at, either by using 'Entity has field' or 'Data comparison' to determine what content type you are looking at. The reason you only see the 'normal properties' by which I assume you mean NID, Author, Title etc, is because it cannot guarantee it has the fields you want, until you determine what content type it is


This seems to be a bug in the Views module. If you have an OR filter group, Views will incorrectly use INNER JOIN instead of LEFT JOIN in the query.

One solution is to patch Views - more info & patch: https://www.drupal.org/node/1766338

Another solution that is using hook_views_query_alter that changes the join type by modifying the query object: Changing an inner join to a left join in views 3.3?

A third solution (see comment below) is to check the "Reduce duplicates" checkbox for the filters in the OR group.


What is the correct way to exclude certain CSS files for anonymous, but include for authenticated users?

You should use hook_library_info_alter.

In which, you check is the user is logged in, or the logged in user roles, then simply unset the CSS files you don't want.


How do I send out an email every Monday at 8:00am?

For finer grained control over scheduled jobs, you sould have a look at the Elysia cron module. Drupal out of the box is not capable of that degree of scheduling control.


Custom template file to use themes html/page.tpl

If you want your content to be inserted in the content section of the page you just need to return it (as HTML, or render array) from your page callback function. Then you can override the template of any (html/page/node) level for this page by standard theme hook suggestion and customize it.


How do I stop View/Edit tabs appearing on Taxonomy driven Pages when I am not logged in?

This was due to someone not surrounding this code with a permissions checker, eg:

 if (!user_access('administer nodes')) {
    return;
  }


Node titles are erased when I update a field with entity_metadata_wrapper

I tried calling resetCache but the problem persisted. In the end I created a page for each language and used the PHP filter to add the script to the page. By switching to each language, setting the value of propertyCondition('language','') to the loaded language and loading the corresponding page, I was able to import the metroIDs and update the pages, one language at a time, without deleting the titles.


Adding price field on Drupal Commerce that affect Order Price

There is a contrib module developed espacially for shipping - Commerce Flat Rate

  This module allows you to define any number of flat rate shipping
  services via the user interface in conjunction with Commerce Shipping
  2.x. When you define a new flat rate service, you specify the base rate for it in the add / edit form. You can further modify the base
  rate (enabling things like weight or quantity based shipping) using
  rate calculation rules.

  This is functionally equivalent to using product pricing rules to add
  discounts or fees to base product prices before adding them to the
  cart.

There are few old but still actual video casts from rfay about Commerce Shipping. Watch it for a basic understanding:

Introduction to Commerce Shipping
Free Shipping Based on Order
Value or User Role
Shipping Discount for Item in Cart using
Calculation Rules


Drupal 6: Feeds mapping node taxonomy term

before importing nodes from a site that contains taxonomy terms , try first to import all taxonomy terms ( you can use taxonomy manager ).

Feeds will add a term with a new tid if It not exist , not the same as tid of the site from where you export


passing argument from one view to another view

You do not need two separate views for that.

Step 1: Install Address Field Module

Step 2: "Create a content type let say "Pharma Shops" , add adress field to this content type.

Step 3: Add some nodes to this content type, so you can see the results filtering with your views.

Step 4: Create view of type content for "Pharma Shops", add fields you want to show for the nodes in the display and search to find views setting for exposed filters,where again you will be exposing address field to all users to filter down the results.

As a Note: Consider view as ui to make database queries.


How to print token in webform-confirmation.html.twig?

First, talking about your twig extension:

{{ webform_token(....) }}
{{ drupal_token(....) }}

I've never seen drupal_token twig ext so let it out of here. or you guys can comment to help me update this answer.
For webform_token function, the real back end function of it you can check from this file: webform/src/Twig/WebformTwigExtension.php line 102. (v5.23.0). And it said that
public function webformToken($token, EntityInterface $entity = NULL....) {
  // Allow the webform_token function to be tested during validation without
  // a valid entity.
  if (!$entity) {
    return $token;
  }
  ...bla...bla
}

Mean that, if your code not given entity, it will return a string that you inputed. and the result will be like what you did.

Back to your case
If you look into webform/templates/webform-confirmation.html.twig template file, you can see the Available variables:

progress: Progress bar.
message: Confirmation message.
back_url: URL to the previous webform submission.

And the others Available variables can found at template_preprocess_webform_confirmation() of this file: webform/includes/webform.theme.template.inc. And they are

webform,
webform_submission,
source_entity.

So, it mean that you can use {{ webform_submission.data.field_name }} in webform-confirmation.html.twig template file; instead of using token like the way you did above.
*Note: Try to avoid using twig extension in twig template would make you easier in debugging and maintenance.


How do I print logic field on page--node.html.twig?

With simple logic, you could try using

{{ node.field_some_logic.value ? 'YES' : 'NO' }}

See ternary operator on https://twig.sensiolabs.org/doc/2.x/templates.html


Ensure registered users can publish nodes only after paying some money

The pre-existing solutions ( Commerce Node Checkout,   UC Node Checkout, Pay-per-node) for this problem haven't been ported into D8.

If one of the pre-existing solutions covers your use case well, you could help port it to D8 (Commerce 2.x is likely to have a stable release this year). Otherwise, you're looking at some sort of custom solution involving involving modifying the node form workflow and PayPal integration.


Why does The special menu items module break the bootstrap dropdown?

It's because bootstrap is expecting an anchor tag and by default Special Menu Items provides a span tag.

Go to admin/config/system/special_menu_items and specify an anchor tag as shown below:


Bulk update for unchecked "Generate automatic URL alias"

Have you tried using Views Bulk Operation. All you will need to do is create a view that will list all the nodes that will meet your criteria and then assign an action 'Generate Url alias' (I haven't tried it though.)


How to change user field value after node form is submitted?

As @Clive says, form submit handler is a bit too late. Do it in hook_node_presave or hook_entity_presave. If you do it in hook_node_presave:

Check the node type first: if ($node->bundle() === 'article')
Get the current user:
$user = User::load(\Drupal::currentUser()->id());
Then set the field value: $value = (int) $user->get('field_reputation')->getString() + 10; $user->set('field_reputation', $value); (I'm not 100% sure on this code, but I'm sure there are better ways to do it when you have more than 5 minutes :D. Feels dirty to use getString() and then type-cast it into int)
Save the user entity with $user->save();

If you use hook_entity_presave then you just need to check for the entity type additionally: $entity->getEntityType->Id() === 'node'


How does the private files folder need to be configured exactly?


How do I create a cache context in Drupal 8 that varies on user/node field data?

A cache key is not the right solution as dynamic_page_cache won't vary on the right things.

What you do is:

You create a custom cache context (see core.services.yml for many examples), which itself is dependent on the [route] and [user] cache context (as it needs to check the node).

e.g. cookies:[cookie_name] is a good example. (https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Cache%21Context%21CookiesCacheContext.php/class/CookiesCacheContext/8.1.x)

In that way you can have indeed a:

caneditnode:[entity_id]

Whenever this cache context is used, your handler is checked and needs to return the right information based on the given Context.

If caneditnode is given as cache context without context it could just throw an Exception or fallback to ['user', 'route'] as that is what it depends on.

In getCacheableMetadata you would just return the node cacheable metadata and the user.roles.

See https://api.drupal.org/api/drupal/core%21core.services.yml/service/cache_context.user.permissions/8.1.x for an example of a cache context, which itself depends on other data, which can be invalidated.


Form API Ajax - how to disable also form elements that will be changed, not only triggering element?

You can disable/enable some elements during ajax using this jQuery script:

// Disable filters on ajax call.
  $(document)
    .ajaxStart(function() {
      // Place here all elements that must be disabled during ajax.
      $("#path-to-the-element").attr("disabled", "disabled");
  })
    .ajaxComplete(function() {
      // Place here all elements that must be enablec after ajax.
      $("#path-to-the-element").removeAttr("disabled");
  });

Update. Some helper suggestions:

You can loop all inputs in wrapper element and disable each of them
using jQuery.each
You can see what is the class or id attribute of your generated
element html. Also you can add some special CSS class disable-on-ajax
to all your elements or wrappers that must be disabled on ajax. Then you will be able to handle them with one line of jQuery code.

Update 2

I can suggest one more solution.
E.g. you have added class for your target elements 'disable-on-ajax'.
Then you can write function that will be triggered on blur, select change, click etc.(You'll need to implements all target triggger checks).
In this function you'll check if element has class "disable-on-ajax". And add second class "ajax-disabled". Then on ajaxStart you'll handle only element with class "ajax-disabled"

You can populate form ajax-triggering elements, add property like ajax_wrapper="wrapper", ajax_event="event type" and then in behavior attach events


One reasons that a database can grow w/o bound is when you don't have cron setup to run.  Check your "Recent Log messages" at /admin/reports/dblog  and filter for cron, and make sure it is running (nightly is a good start).

On of the things cron does is prune the cache, watchdog, and sessions tables.  These can fill up quickly with data that isn't critical to Drupal running.

Occasionally, clearing these out can take too long for a cron run.  If this is the case, running a manual query, such as

DELETE FROM watchdog;

may be needed.  As mentioned above, you can run this on the cache and tables beginning with cache_, watchdog, and sessions.  It is always best to take a backup first, before running DELETE queries.


Click on NO RESULTS BEHAVIOR on the right side.

Add a Global: Text area

Enjoy...


For simple forms ...

... you can theme a form template by using {{ element }} instead of {{ children }}, see How to Create twig template files in drupal 8 for customizing user login,profile edit and forget password forms?.

But this is not always the best approach, because it's difficult to include all form elements and metadata the form needs to operate.

For complex forms ...

... it might be easier to add an additional template level, which only has to render the inner form elements, not the complete form:

/**
 * Implements hook_form_FORM_ID_alter() for \Drupal\user\RegisterForm.
 */
function mytheme_form_user_register_form_alter(&$form, FormStateInterface $form_state) {
  $form['#theme'] = 'user_register_form';
}

The custom template needs to be registered in hook_theme. See How to render specific form elements from the *.theme file for a step-by-step example.


How do I attach a single-use block through a field?

The block_field module is designed to reference block plugins rather than block content. I think what you want here is an entity reference field with an inline entity form or entity browser.
It's likely block field has never been tested with layout_builder enabled (where the InlineBlock plugin comes from) so that's where this confusion is coming from!


I could solve the problem myself, based on this solution for Drupal 7.

Instead calling the form directly in the router, I define a page callback in my_module.routing.yml.

my_module.form:
  path: '/my-module-form'
  defaults:
    _title: 'My module form'
    _controller: '\Drupal\my_module\Controller\MyModuleController::searchForm'

In MyModuleController, I load my form via the builder.

public function searchForm() {

  $form_state = new FormState();
  $form_state->setMethod('get');
  $form_state->setAlwaysProcess(TRUE);
  $form_state->setRebuild();

  $form = \Drupal::formBuilder()->buildForm('Drupal\my_module\Form\MyModuleSearchForm', $form_state);
  unset($form['form_build_id']);
  unset($form['form_id']);

  return $form;
}

The code of form then is like in the question above.


Feeds is not importing images into subfolders

My solution to a similar problem was installing FileField module and in the content type design, put the attached files (as images in the example) in a structured folder by tokens.

This way, when feeds grab the image and attach to node, file_fields module gets the task and put the image into a folder as you mention by design.

It's also helpful when you add single content, not bulk import operations.Everything organized just as you plan.


Commerce Order Total Tax line via EntityMetadataWrapper

the most thorough insight on getting access to the tax line and individual subtotals. found via: https://gist.github.com/BBGuy/3e1f624eaee2088d8eee

// order total object
$order_total_obj = $order_wrapper->commerce_order_total->value();
// Order total (cents).
$order_total = $order_total_obj['amount'];
// order currency code
$currency_code = $order_wrapper->commerce_order_total->currency_code->value();
// subtotal without vat
$total_ex_vat = commerce_price_component_total($order_total , 'base_price');
// total tax (in this case vat 20%)
$total_vat = commerce_price_component_total($order_total , 'tax|vat_20');
// subtotal with vat
$sub_total = $total_ex_vat['amount'] + $total_vat['amount'];
// formatted price string with currency sign
$sub_total = commerce_currency_format($sub_total, $currency_code);


how to save taxonomy terms in a custom user registration form in D7?

The column name for a taxonomy term reference is 'tid' rather than 'value', if you just change that your code should work:

$edit = array(
  'field_firstname' => array(LANGUAGE_NONE => array(array('value' => $form_state['values']['first']['field_firstname']))),
  'education' => array(LANGUAGE_NONE => array(array('tid' => $form_state['values']['second']['education']))),
);

user_save(drupal_anonymous_user(), $edit);


How to define settings from an install profile

I can't find a hook called hook_profile_final on drupal.org. I also can't see where you found it on the link you're using (https://www.drupal.org/node/1022020). You are using an outdated version of the tutorial (https://www.drupal.org/node/67921).

You need to implement hook_install_tasks_alter https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_install_tasks_alter/7 and change a task, or do a form alter of the config page.


What you will want to do is add a preprocess hook to the theme for the user page, and inject some new variables to the template.

Example:

In template.php:

$variables['address_form'] = drupal_get_form('form_id', $arg1, $arg2, $arg3...);

In your template tpl:

<?php print render($address_form); ?>

You will need to know the form id of the forms you want to call. The optional second argument to drupal_get_form will pass those arguments to the form, like say, user object, or user id. Each form will have their own requirements; some don't need any additional arguments at all.


The simplest solution is to add a html file somewhere in your drupal folder. Apache or whatever web server you use will serve it as is.


How do I add a pager for the following code?

I think you are trying to do a custom pager, not based on db query something like this, but it is D6 code.
For D7, check Extenders and what the Database Abstraction Layer page describes is

  Most Drupal database SELECT queries are performed by a call to
  db_query() or db_query_range(). Module authors should also consider
  using the PagerDefault Extender for queries that return results that
  need to be presented on multiple pages

You may also need to check theme_pager which displays the pager result.
When calling theme('pager') outside a pager query, it's necessary to initialize the pager first with a call to pager_default_initialize.


How to get a week range as a Views filter - Thursday to Wednesday

I guess that date filter with is between option filter could be a possibility if you alter the query used by your View, using a custom php builded by you to calculate values (to use and send inside query) according the current day. see this article http://www.appnovation.com/using-hook-views-query-alter about how to use query_alter hook to alter the queries used by your view.


Add restriction to content on the basis of various User

Creat role and assign role to the different user. Based on role set permissions of view content under people permission page.

If A role user can see A type of content so you can allow permission to view that content type page.


Check out Entity Connect Module

  Entity Connect now expands both Entity reference and References
  (node_reference and user_reference) fields by adding "add new content"
  and "edit current content" buttons.

Exactly what you need.


Port of Ubercart "Dependant Atributes" or "Chained Attributes" modules

This answer may be slightly late judging by your ask date but I figured I would post it anyway.

This module performs similar to the above.

https://drupal.org/node/1192892


To show a usage list for a particular FID (file ID) you can visit the following url on your site:

/file/FID/usage

Just replace FID with the file id you want to check the usage for.

You can see an overview of all file usage at /admin/content/file. You can access this page from the admin toolbar at Content > Files.

Here is an example of what the file usage table looks like on that page:

This shows the name of the entity where the file is in use, the entity type and the usage count.


The VCL you have linked to and your example in the question show you only using one backend. In this case using the probe to do a health check serves no purpose. As per drifteaur's answer disabling probe resolves many 503 issues and as you have no need for it, problem is solved.

However, if you are testing working towards rolling out on multiple backends then it still needs to be fixed(understood).

Looking at the VCL you linked (https://github.com/mattiasgeniar/varnish-4.0-configuration-templates/blob/master/default.vcl) it uses many sections which have been taken from https://www.varnish-software.com/ so we can presume (hopefully) that they are correct.

Currently, your probe is checking the response from "/ping" at your host and port, 127.0.0.1:8080, so that is 127.0.0.1:8080/ping .

If your set-up is multiple virtualhosts on one server with varnish sitting infront then using probe like this will not get a response(as this full url has most probably not been configured) and in turn this will lead to the backend being marked as "sick / unhealthy" and a 503 will be produced as Varnish will not even attempt to access the backend.

To confirm that it is your server setup add the following to your probe

backend default {
    .host = "127.0.0.1";
    .port = "8080";
    .probe = {
              .request =
              "HEAD / HTTP/1.1"
              "Host: www.EXAMPLE.com"
              "Connection: close";
              }
}

You will need to change www.EXAMPLE.com to a real domain you are using on the server.

If this gives you 200s rather than 503s than it is safe to confirm that using probe as you were with your server set-up was incompatible.

Probes info: https://www.varnish-cache.org/docs/trunk/reference/vcl.html#reference-vcl-probes


D8 generate double URL for commerce product

In your hook_entity_update() do like below

    function mymodule_entity_update(Drupal\Core\Entity\EntityInterface $entity) {
      if($entity->getEntityTypeId() == 'commerce_product'){
        $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
        $aliasStorage = \Drupal::service('path.alias_storage');
        $source = '/product/' . $entity->id();
        if ($aliasStorage->aliasExists($source, $langcode)) {
          // alias already exist. So save your second alias here.
          $aliasStorage->save('/product/' . $entity->id(), YOURNEWALIAS, $language);

        }
        else {
           $aliasStorage->save('/product/' . $entity->id(), YOURNEWALIAS_1, $language);
           $aliasStorage->save('/product/' . $entity->id(), YOURNEWALIAS_2, $language);
        }
        }
    }


How to create node in hook_node_insert without triggering it recursively

Why not add a second submit handler using hook_form_alter to the node add form and put your functionality in there as opposed to using hook_node_insert?

That way the code will run everytime the node add form is submitted, but you won't get into the endless loop scenario...


How to code multiple values field in Views PHP?

Structurally, your code looks fine, it's probably because

$row->view =

5

 basically the 5 has HTML tags around it.

so

5

 does not equal 5

You can use the PHP strip_tags() function to get rid off the tags.

if (strip_tags($row->view) >= 5 AND strip_tags($row->view_1) >= 5 AND strip_tags($row->view_2) >= 80) {

So try this:

<?php

$a = strip_tags($row->view);
$b = strip_tags($row->view_1);
$c = strip_tags($row->view_2);

if ($a >= 5 AND $b >= 5 AND $c >= 80) {
    echo "Amazing person";
}
elseif ($a >= 3 AND $b >= 3 AND $c >= 70) {
    echo "Good person";
}
elseif ($a >= 1 AND $c >= 60) {
    echo "Interesting person";
}
else {
    echo "Content needed";
}
?>

PS: no need to have anything for value code return $data;.


What's the alternative to using the Conditional Rules module?

For any custom rule where you are tempted to use the Conditional Rules module, you can always create corresponding Rules Components, with similar Rules Actions to be performed, but also with additional Rules Conditions equivalent to any Rules Conditions you'd want to include by using the Conditional Rules module. And then perform that Rules Component inside your Rules Actions of your original rule.

Consider this prototype-example (just assume it's a simplified version of a more complicated rule with preceding Rules Actions like "Fetch entity by ID", "Set a variable", etc):

{ "rules_show_a_message_using_conditional_rules" : {
    "LABEL" : "Show a message using Conditional Rules",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules_conditional", "rules" ],
    "ON" : { "node_delete--page" : { "bundle" : "page" } },
    "DO" : [
      { "CONDITIONAL" : [
          {
            "IF" : { "NOT data_is" : { "data" : [ "node:promote" ], "value" : "1" } },
            "DO" : [
              { "drupal_message" : { "message" : "Bingo ... using \u0022Conditional Rules\u0022 ..." } }
            ]
          }
        ]
      }
    ]
  }
}

Here is its equivalent using Rules Components:

{ "rules_show_a_message_using_a_rules_component" : {
    "LABEL" : "Show a message using a Rules Component",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_delete--page" : { "bundle" : "page" } },
    "DO" : [ { "component_rules_say_bingo" : { "current_node" : [ "node" ] } } ]
  }
}

And the related Rules Component looks like so:

{ "rules_say_bingo" : {
    "LABEL" : "Say bingo",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "current_node" : { "label" : "Current node", "type" : "node" } },
    "IF" : [
      { "NOT data_is" : { "data" : [ "current-node:promote" ], "value" : "1" } }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "Bingo ... using a Rules Component instead of \u0022Conditional Rules\u0022 ..." } }
    ]
  }
}

Some details about the alternative using a Rules Component:

The Rules Condition within the Conditional Rules construct, has become a Rules Condition of the Rules Component.
The actual Rules Action to be performed, was moved to a Rules Action of the Rules Component.
The original rule simply calls the Rules Component, thereby passing the node to be processed as a parameter of the Rules Component.
The Rules Event in the original rule is unchanged, and if there would have been any additional Rules Conditions in the original rule, those would have remained unchanged also.

Note: the above is just a "concept", to illustrate the key-part of the solution. Because this prototype did not require any previous "Fetch entity by ID" (or "Set a variable", or "load current user points") as a previous action.


hook_menu shows in menu but not show page

It's just a typo. Remove the underscore from page_callback.


Convert a date with format (2017-05-27) to save in node created field

The node created field is a Timestamp Field. Use the php function strtotime() to convert the string to a Unix timestamp:

$timestamp = strtotime('2017-05-27');

and store the value in the created field:

$node->created->value = $timestamp;

You can also use the method setCreatedTime():

$node->setCreatedTime($timestamp);


Database log messages (auto cleaning) with keeping exceptions

Under Database log messages to keep, there is an All option to keep all logs.  However, there is no option to selectively delete logs automatically in core.
There are two things you could try instead:
First, the Recent log messages screen is a view.  So, if you have the Views UI module enabled, you can edit the log messages view to create a new view mode (for example, a separate page) and then customize the configuration on that page to only list the types of log messages you want to automatically delete.  You can then trigger this manually at whatever interval you want.
Another option would be to use the Logging and Alerts module to store the logs you want to keep forever by copying them to email, SMS, or some other server.


After some research (How to POST an "entity reference" field to a node ? , REST views entity reference  issue

I found the solution, we should pass nid as target_id, final asnwer is

postData.field_course_ref = [{'target_id': formValues.nid }];

it's work correctly, I answer my question maybe be helpful for another guy later.


drush up fails to update, though it says it deos

"Backups were restored successfully" means that Drush failed at some step, and restored your old version of Drupal over the recently updated version.  Try setting file ownership &/or permissions; run with --debug, and perhaps you will see more information about why the upgrade is failing.


If it's an entity then you can remove the required property from manage fields option in comment.

$form['field_rating_comment']['und']['0']['rating']['#required'] = FALSE;


Contextual filter on Views Block file not found

I think you are just a bit confused about the structure of the page drupal creates so hopefully this might help to clarify it all.

When you create a page display in Views with a contextual filter, you basically are creating a menu item / path on your website. In this case, it's probably something along the lines of my-index/%, with the % being the contextual filter.

You then define that filter to be a tax term.  So, you can then type in  www.yourhost.com/my-index/foo and www.yourhost.com/my-index/bar and www.yourhost.com/my-index/baz and get the $content of those pages filled with the fields of the view you created filtered by foo, bar, or baz.

Or any other term a user puts in in place of the %.

This way you aren't creating umpteen individual views, eg, you don't have to create my-index/foo, my-index/bar, my-index/baz, etc etc page displays for each and every possible tax term.

Plus if you say show me everything if the contextual filter is missing, then you can also go to www.yourhost.com/my-index and get a list of everything.

Now to blocks.  These aren't the main $content of your page, but rather little boxes of additional information off to the side.  They can be placed pretty much on any page you want through the block admin pages, you just go in there and tell it what region you want and pages and off you go.

So, in this case, let's say you created a page display called my-index/% like the above.  In this example, let's also say that this view lists the content on your system sorted by Title.  So, in the main content area of this page you'd have that listing of your content tagged with that tax term sorted by title.

But let's say you wanted a block off to the side listing the very latest content tagged with that same tax term.

Here, you would create a block display of content sorted by creation date in descending order and limited to 1 item.  Here you would also add a contextual filter, but in the supply the default argument, you would tell it to take it from the url and specify where it is, in this case the 2nd argument.

Then you'd save everything and go to the block admin page and down in the list of blocks available you'd see this View Block.  Assign it to a region in your theme and then in the pages, restrict it to my-index/* and then it will show up on that page along with your main content.


How can I display a page element based upon security?

If you want to make a button only available to users who are admins, put this property in the form element:

'#access' => \Drupal::currentUser()->hasPermission('access administration pages'),


How do I load a Media entity from a File entity?

Example - if your File entity is loaded in a variable named $file, and the field name on the Media entity is field_media_image:

$media_entities = \Drupal::entityTypeManager()->getStorage('media')->loadByProperties([
  'field_media_image' => $file->id(),
]);

$media_entity = is_array($media_entities) ? array_pop($media_entities) : NULL;

Note1 : If the File object belongs to more than a single Media entity, you will need to loop through $media_entities to find the one you want.

Note 2: $media_entity will either contain the Media entity the File entity belongs to, or be NULL if the File entity doesn't belong to a Media entity.


Can I remove the experimental module warning from /admin/reports/status?

There is an experimental module that it's not shown on the screenshot given in the question: the Place Blocks module. Its .info.yml file is the following one, on Drupal 8.7.x.

name: Place Blocks
type: module
description: 'Allow administrators to place blocks from any Drupal page'
package: Core (Experimental)
version: VERSION
core: 8.x
hidden: true
dependencies:
  - drupal:block

Since it contains the hidden: true line, it isn't shown in the list of available/installed modules, in the same way modules used for the tests aren't shown.

You could ask now how it is possible to install a module that isn't shown in the list of the modules. The answer is that on Drupal 8.3.x, the module was not hidden.

name: Place Blocks
type: module
description: 'Allow administrators to place blocks from any Drupal page'
package: Core (Experimental)
version: VERSION
core: 8.x
dependencies:
  - block

Drupal 8.4.x was the first Drupal 8 branch to hide it.

As for uninstalling it, you need to edit the core/modules/block_place/block_place.info.yml file, remove the hidden: true line, or change it to hidden: false, clear the cache, visit the Extend page, and uninstall it. Be careful of not changing the line indentation for that file, as a wrong indentation can cause issues.
Since it requires to edit a module file, it could be tricky to make Drupal notice the change. I normally visit the Extend page after I edited a module file as in this case, install a core module I don't need, uninstall it, visit another page, and go back to the Extend page. At this point, I am sure Drupal caught the change I done to the module file.


Custom template for displaying inner blog contents

Declare your template using 'theme_suggestion` in your page preprocess function. like the following:

function THEMENAME_preprocess_page(&$vars){
  // Page template suggestion based on node type
  if (!empty($vars['node'])) {
    $node_type = $vars['node']->type;
    $vars['theme_hook_suggestions'][] = 'page__node__' . $node_type;
  }
}

if your node type is blog then your template will page--node--blog.tpl.php
Don't forget to clear cache after adding this code and your tpl file


I use in every of my projects the Taxonomy Manager module, among its features you can find:

mass adding of new terms
dynamic treeview
mass deleting
moving of terms in hierarchies


While adding vocabulary, you need to select third option for translate your     vocabulary and its terms. Ref. attached image.

After adding the terms and its translation, and configured term reference as a "select list", you can see there are both translated terms shows into select list while adding a content.

Hope it will be helpful.


How to keep showing Administration menu when changing user?

There is the Masquerade module for seeing how a page looks like for another user https://drupal.org/project/masquerade.

Another way is to duplicate your tab in incoqnito tab or in another browser and become another user there.

Third way is to make sure (if possible) your browser remembers user names and passwords on login forms. Then logging in as administrator is as easy as typing the first letter to the username field and pressing enter. This is less cool of course...


Where is Pathauto's "Strings to Remove" stored in MySQL?

It's stored in the variable named pathauto_ignore_words, you can get it directly like this:

SELECT value FROM variable WHERE name = 'pathauto_ignore_words'

or using the Drupal API like this:

$ignore_words = variable_get('pathauto_ignore_words', '');


filedownloading is making the file to view instead of download in drupal7

Read Force Files to Download Instead of Showing Up in the Browser as the page suggests you can achieve this by adding these lines to  .htaccess file

<FilesMatch "\.(?i:doc|odf|pdf|rtf|txt)$">
  Header set Content-Disposition attachment
</FilesMatch>

Or alter mime type


If you want to show your node in a modal, a simpler approach would be to use the Colorbox and the Colorbox node modules (the last one has Views integration).

So after installing both modules, go to your View; in your Fields, when you click on any of them, you will see that the option "Link this field to the original piece of content" now has another one that says "Display the content inside of a colorbox". Check it, and it will make your nodes open in a modal window (colorbox).


How to model players and rosters in a team sport site

I would say yes, player is a content type in this case. Every player node would represent something (the player) that still has a meaning when you would take it out of its context (the team). Setting it up as a distinct content type will allow for more flexibility in the future, for instance showing player biographies, or transferring a player from one team to another.

If you want to hide the player nodes from regular visitors, you can use the Rabbit Hole module.

To make references between nodes, there are several options. Entity Reference is good and pretty straight forward. It allows you to add a field on the 'team' node type in which you can reference nodes of the 'player' type.

The Relation module is more complex but it can do a lot more. Relation doesn't store the references in the node itself, but it creates a new relation entity for each relation. Those relations can be 1-to-1 or 1-to-many and they can be bi-directional or one-directional. Since relations are entities, you can even add fields to them. For instance, if you define a relation that stores which players play for team X, a field on that relation could store the year/season when that happened. As you can see this offers a lot of possibilities, but it might introduce more complexity than you need.

How you can create the roster depends on the way you build your team-player relations. If you use Entity Reference to create a players field on the tem node, then the roster could simply be a display of the team node. When Drupal displays the team node, Entity Reference can fetch all related player nodes and render them in a view mode of your choice (eg. it can use the teaser view mode of the player node). If you use Relation,  you should use the Views module. The Relation module has pretty good Views support (though I haven't used that feature a lot myself) as you can see in this video tutorial.


How do I make an FTP connection from a module?

The information about the classes that extends FileTransfer() are returned from hook_filetransfer_info(), and altered by hook_filetransfer_info_alter(). There isn't any service to use.
As such, the code that uses that class should be similar to the following one.

$info = drupal_get_filetransfer_info();

if (!empty($info['ftp']) && $class = $info['ftp']['class']) {
  $ftp = $class::factory($jail, $settings);
}

Notice that when the patch in Convert hook_filetransfer_info() to plugin system will be applied to Drupal 8.x.3, the code I wrote will probably need to be changed, if the change is not going to be backward-compatible.


You can't add fields to the content type in regular old Drupal.

Also, the thing is that the view itself is pulling fields from the actual entities you're trying to list, so even if you manage to somehow add tags/fields that relate to the content type (through a custom or contrib module), your views wouldn't be able to just access those special fields by default.  After all, your views are actually pulling entities themselves and accessing their fields.  You know?

The simplest way to do this, I think, is to hard-code which content types you want listed in your views as filters:

In your views' 'Filter Criteria' section, simply add the filter 'Content: Type' and select all the content types to include.  So, if you wanted a view that applies to 'news' category types, just filter to include all those content types (news, image news, etc).  Of course, if you ever add a new content type or want to change your categorization, you'd have to edit your views by hand to match the new way of doing things...

The above is better, in my opinion, then adding a 'content category' vocabulary that is included in each of your content types as a field.  Even if a 'category' vocabulary has a default, which allows content editors to create nodes and not have to set a category, the problem is that tagging each node (versus filtering by the content types as above), would make 'switching' your categories or removing/adding categories to your content types harder.  If you decide to change them later, what do you do about all the nodes you've created in the meantime that have been tagged a certain way already?  :-)


Create a rule to send confirmation email message after anonymous/authenticated user has created content

Rules works with the token module. If you haven't installed it, do so now.
In your "apply" content type ("application" would be a better name), ensure that your email field is required, and set the default to use token [current-user:mail] so that it fills with the current user's details if they're logged in.
"Conditions" is the "if" part of your rule. You use it to narrow down when the rule fires and by whom. Given that you're not needing auth, you can leave this empty. You could test for various node / field properties here e.g. node is published / field has value etc. Because you specified a content type in your "Event", the fields from that content type will become available to the subsequent "Conditions" and "Actions".
"Actions" are what happens when you trigger your rule. This is where you specify the email action. Click "Add an action", and from the supplied dropdown, choose "System > Send mail" or "Send HTML email".
In the "to" field, you can now add a token referencing the user email - probably something like [node:field_email_address]. Click the "Replacement patterns" accordion to see available tokens for each mail param.
It you're wanting to templatize & theme your HTML emails, that's possible through other modules (mimemail + mailsystem) but requires a separate discussion.


How to add a div tag after a specific field?

You can simply rewrite result of poster field (it's in poster field settings), but you need to display fields, not content. Just add there poster token and div

Upd: ong, what am I about. If you display fields in your view, you can add custom Global text field. And write there custom html, remember to use php filter(works 100%, mb one another works too).


Use MenulinkTree::load in page_preprocess

It is because you don't use a second (mandatory) parameter. Look at this example:

$menu_name = 'main';
$menu_tree_service = \Drupal::service('menu.link_tree');
$menu_parameters = new \Drupal\Core\Menu\MenuTreeParameters();
$menu_parameters->setMaxDepth(1);
$tree = $menu_tree_service->load($menu_name, $menu_parameters);

You could also set a root menu item like this:

$menu_parameters->setRoot($root_menu_item->getPluginId());

To get the menu link title and url:

foreach ($tree as $item) {
  $title = $item->link->getTitle();
  $url = $item->link->getUrlObject()->toString();
}


How would we limit the drop down for the Date's Timzone field?

The Date module's field elements are supplied by the Date API module. The timezone component is supplied by its process callback date_timezone_element_process().

It triggers hook_date_timezone_process_alter() which can be evoked by a custom module to alter the options within $element['timezone']['#options'].

For example:

/**
 * Implements hook_date_timezone_process_alter().
 */
function MYMODULE_date_timezone_process_alter(&$element, &$form_state, &$context) {

  if (isset($element['timezone']['#options'])) {
    // @TODO: Supply an array filter function that filters
    // IANA TZ names that don't correspond to
    // UTC - PST/PDT - MST/MDT - EST/EDT - GMT

    // Example: Filter TZ's that are only in the Americas
    $element['timezone']['#options'] = array_filter($element['timezone']['#options'], function($key) {
      return strpos($key, 'America/') !== FALSE;
    }, ARRAY_FILTER_USE_KEY);

  }
}


Redirect to webform from controller and back to custom form

What is the purpose of that redirect() method if it doesn't redirect?

You find this method in both, controller and form:
ControllerBase::redirect()
FormBase::redirect()
It creates a redirect response and you return it if a certain condition is met:
if (...) {
   return $this->redirect($route_name);
}

Example: https://drupal.stackexchange.com/a/277596/47547


You can use Features without additional modules. In fact, the module page is quite clear about it. Quote:

Features also provides faux-exportable functionality for the
following Drupal core and contrib components:
- CCK fields
- CCK fieldgroups
- Content types
- Input filters
- User roles/permissions
- Custom menus and menu links *
- Taxonomy vocabularies *

  * Currently in development.

In other words, these things can be exported using features out-of-the-box. That said, I recommend installing Strongarm right away, because some of the things above are lined to variables that you will want to export as well. For instance, if you export a content type, you probably want to export its comment settings too.


The easiest method would be to implement a hook_form_alter inside a custom module that overrides the title

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21form.api.php/function/hook_form_alter/8.2.x

Some information how to create custom module.

https://www.drupal.org/docs/8/creating-custom-modules


Covert link field as link field text format?

If you need to change the HTML you can Rewrite the output using tokens, see more info here: Raw Field Value in Views and in this question and answer: Add link for each column

Then you can emphasize a word in the output to make it italic, or wrap it with some HTML element with a class and italicize it with CSS in your theme.

If you want to make the whole link text italic you can add a class to that field and style it with CSS.

If you just want to reword the link text you can use the Rewrite results as mentioned.


In a view, how can I link a field to the node?

as @Daphna mentioned and you can see here: drupal.org/node/1234862 you can use Content: Path field value as a token for the field you want to be linked to the content:

add Content: Path field and in the configure field modal box check Exclude from display to hide this field from being displayed and rearrange fields so this field is above the field you want to be linked to the content.
click the field you want to be linked to the content to open configure field modal box and in the Rewrite results section check Rewrite the output of this field.
in the opened textarea under Rewrite results write this: [field_name]. you should replace field name with proper token of the field you want to be linked. you can find all the fields token in the Replacement patterns section under Rewrite results.


Favicon settings missing on subtheme config

Try setting:
settings:
    features:
        favicon: true
    favicon:
        use_default: false


Discard views filter on field from referenced taxonomy term when relationship isn't present

Yes, you want to use Grouped Filters in Views. In the View UI, there's an Add/Or, Rearrange option next to the Filter Criteria section.

This allows you to create a complex grouping of filters. To use an example that matches your conditions, here's a setup using Drupal's Standard installation with Basic Page/Article nodes and Tags taxonomy that's exclusive to Article:


How to delete sites showing up in backend of Aquia Dev Desktop

Found the solution, at the bottom left of the window there is a + and - sign, they look like sorting icons,but actually they are to delete. Clicking on minus does it.


Maybe I am missing something about your question, but it seems that one of three basic techniques should work for you.

If you just need information from a block in the footer, place the block in the footer region and style it with css so that it is positioned where you need it to be.
If you need to adjust the information in a block (e.g. to place a block on a page twice), use a render hook.  c.f. The Scary Render Array.
If you just want to put some custom content + php in your template after the footer, you can just plop it down there.  If you have code in your block function that needs to be called in two locations, factor it into its own function, and call it from the template and from the block function.

It feels wrong to call the block api from a template file when one of the above more conventional techniques should work just as well.


Drupal 7 Form API - AJAX updates for multiple file uploads

The AJAX updates I wanted was to provide some progress updates which I found out I can achieve form api #ajax['progress']. I guess if I had mentioned that in the original question it would have made life a bit simpler :) :

first create a url for the ajax progress update to call:

function awsImage_menu() {
  $items = [];

  $items['path/to/page'] = [
    'title' => t('Import progress'),
    'page callback' => 'import_progress',
    'access callback' => 'user_access',
    'access arguments' => ['access awsImage'],
    'type' => MENU_CALLBACK,
  ];

  return $items;
}

then update the form to use the progress path created in the hook_menu - note the type MUST be 'bar' and the url MUST have the starting forward slash

function awsImage_form($form, &$form_state) {
.....

  $form['submit'] = [
    '#type' => 'submit',
    '#value' => t('Upload'),
    '#ajax' => [
      'callback' => 'awsImage_form_callback',
      'wrapper' => 'results',
      'method' => 'append',
      'progress' => [
        'type' => 'bar',
        'url' => '/path/to/page',
        'interval' => 1000,
      ],
    ],
  ];
....

}

then create your progress function. In my original awsImage_form_callback function I created and updated a session variable: $_SESSION['awsImage']['import_status']

function import_progress() {
  // set up default progress status message
  $progress = [
    'message' => t('Starting import...'),
    'percentage' => -1,
  ];

  // check if there is any status data

    $completed = (isset($_SESSION['awsImage']['import_status'])) ? $_SESSION['awsImage']['import_status'] : false; // calculate progress percentage here

    if ($completed) {
      // there is status data, so build the status message
      $completed = unserialize($completed);
      $total_files = $completed['total'];
      $current_file = $completed['current'];
      $current_file_name = $completed['current_filename'];
      $completed_percentage = ($current_file / $total_files) * 100;

      $progress['message'] = t('Processing:' . $current_file_name);
      $progress['percentage'] = (int) $completed_percentage;
    }

  drupal_json_output($progress);
}

Now when I upload & process multiple files, I get an update every second on which file I am uploading and how much there is left to go... Most of the time, sometimes the progress bar does not do any updates then just shows 100% and completes... but that may be down to local files uploading to a local server and there is not enough time!


Try hook_form_alter() like this;

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'commerce_form':
      ...
    break;
}


Start with multiple entity reference items

Try  Unlimited fields settings module may help you.


How can I make the "field_media_document_display field be filled with a 1?

In media-migration-step1.yml.twig I see:

So should be:
field_media_document/display: TRUE
field_media_document/target_id:
    plugin: media_file_copy
    move: FALSE
    reuse: TRUE
    path: 'public://grants/'

If still not, try:
field_media_document/display:
    plugin: default_value
    default_value: TRUE
field_media_document/target_id:
    plugin: media_file_copy
    move: FALSE
    reuse: TRUE
    path: 'public://grants/'


Is there a one-click solution that builds a private organic group (OG) and invites another specified user to that group?

I would use Page Manager (part of ctools).

You can add an action or a tab to just about any page so you could have your view of users with a tab or link at the top (depending on your theme/styling) that requests a new organic group.

The URL would be based on the user view.  For instance if your user view was at /people/users you could add a path at /people/users/addgroup which redirects to the OG group creation page.

Alternatively you can create whatever URL you want like /request/new/org/id and give people the link for it... then use that URL to redirect to the OG group creation page.

In order to hide the user being added to the form you should be able to use a parameter in the URL like request/%tutor, then pick up the argument in Page Manager and auto-populate the user as a member.

As for automatically filling out the form?  Well, Automatic Nodetitles has worked well for me, you can build titles out of available tokens which is pretty neat.  And you could probably run some javascript to click the submit button on page load but that's a kludge.

If you don't want them to see the node creation screen then yes, the API is the way to go.  I haven't used OG so I'm not familiar with it, but most contrib modules have a .api file which gives an explanation of the available hooks.  But you probably want to use one of their functions, just look through the code until you find one called og_create_group or something like that, figure out what to send it as parameters and you're off!


PDOException: SQLSTATE[42S02] - Base table not found

Chechout the link at https://www.drupal.org/node/2144205#comment-9288889 which suggests this:

  If your cache_field table is corrupt, you should be able to clear it by running update.php or cc all from drush. If you want to empty the table contents without deleting and rebuilding the schema, you can delete from cache_table or truncate cache_table.

Another suggestion is in the same link, located at https://www.drupal.org/node/2144205#comment-8368871 ...

If neither of those links help (or don't work), then investigate which module creates that table as part of it's install/enable process. Then uninstall and re-install that module ...


You could drop the #action, then add some curl() code to your #submit callback function for the final step.

Trickier, sure, but it'll work without messing up the form caching for Drupal.


Perhaps, your question in bold needs to be reworded to Is there any simple method to port D7 modules to D8? Which is what you're really after.

If you are referring to CUSTOM modules (not drupal.org contrib  modules) then the fastest / most simple way is to use Drupal Module Upgrader which you mentioned in your question. In module page they show you a video with all the steps.

There is no reason to be afraid of Drush. As a Drupal newbie, Drush can seem scary/daunting, I used to avoid it too, but once you learn Drush, which is not hard, you will discover that is super useful and a time saver. You will wish you learned it earlier.

It is important to note that while the Drupal Module Upgrader will port/rewrite some of the code, some of the code may not (depends on how complex your module is) and you will have to manually modify/rewrite certain parts by hand.

Other than using Drupal Module Upgrader, there is no other choice, but to manually re-write your entire module.

If you are referring to Drupal.org Contrib Modules then you will need to download the D8 version, if there is one.


Views Slideshow does not come with the views module. Therefore you will not see it by default.  You have to download and enable the views_slideshow module to see this option.

There is alot of other contrib slideshow modules as well

Related modules

Views Slideshow Menu
Views Slideshow Slider
Views Slideshow Imageflow
Views Slideshow Dynamic Display Block  (My Favourite of this list)
Views Slideshow Galleria
Views Slideshow JCarousel Thumbs
Views Slideshow Xtra

Most of these module does not have a supported Drupal 7 version,  however most of their Drupal 7 dev version will be stable enough to use.  I know I have used views_slideshow_ddblock without any troubles.


Why can my view not access the data of a new node when using Rules event After saving new content?

IMO your "issue" (about "It seems like the data it's still not on Drupal database, so the view results empty") is because of the event (= "after saving new content") you are using, which might simply not be the right event.

Moreover, have a look at issue # 430274, about an event which is a variation of your event here, and somehow explains that "after saving something" actually happens ... "before saving something" (which is not a bug, simply how the Rules module  works ...).

A possible compromise to avoid these kind of issues, is to transform what's you're trying to do into a Rules Component, so that your original Rule "schedules the execution" (using the Rules Scheduler submodule) of that Rules Component (eg X secs or mins "after saving that new user account" ... if your cron job runs frequent enough, if not it'll be next time cron runs). This compromise will ensure that at the time the Rules Component is executed, the content is for sure saved ... (so that can't be the reason anymore then why it would still be empty ...).


Contextual filter with hierarchical taxonomy terms

I remember working on the same type of issue while ago.

The point here is Drupal will store only the deepest taxonomy item you selected and not the whole taxonomy path.

I solved that by hooking the node_save to save the whole path of taxonomy, but I'm not sure that's the best approach.

The other approach would be to find a way with views to make a join with the higher hierarchy level, by using relationships.

Another load could be to look at better_exposed_filter or hierarchical_select

I hope it helps.

Cheers


Are there modules for managing inline images?

After days of searching, I believe the closest there is is the Media module. It goes in the right direction on all counts, but seems to be a long way off "complete".

I haven't found any other modules that even remotely approximate what I'm after.


I can see the changes I made (as an administrator) but as an anonymous user, I can't

OK, I found the problem.

In my routing file, I was missing:

  options:
    no_cache: TRUE

That fixed it.


You can chain a concat process plugin to your destination property so that it contains the result of concatenated source & constant values:

field_paper_working_paper:
  plugin: file_import
  source: doc_format_url
  destination:
    plugin: concat
    source:
      - constants/destination
      - '/'
      - source_field_value
      - '/'
      - source_field_value
  uid: 1
  rename: TRUE


How to fetch fields in a view in the overrided twig file?

You can do it like this:

{{ fields.[machine_name].content }}

The machine name is shown in your content type manage fields.

So it would be:

{{ fields.title.content }}
{{ fields.field_designation.content }}

Also, your template name needs to be: views-view-fields--employee-details--block-1.html.twig

Make sure you clear/flush the cache to see the changes.


duplicate terms added by taxonomy_term_save

It's perfectly ok to have terms with the same name in the same vocabulary, the name column is not unique in the taxonomy_term_data table, and taxonomy_term_save() doesn't contain any logic to check.

This is by design as it would be very restrictive otherwise. Imagine you had a hierarchical vocab with many different levels...what happens if two terms happen to have the same name but live under different parents?

If you need your term names to be unique for whatever reason you can check if the term exists before saving it by using taxonomy_get_term_by_name()


You need to install the php5-ftp package and reload your webserver to load this extension.


How to save datetime field value in config?

There is no schema for data type called datetime.

Easiest solution is to store the date as the timestamp string.

Converting a drupal datetime into a timestamp:
The datetime form element holds an array value that contains three keys: date, time, object.
The object holds an instance of the [\Drupal\Component\Datetime\DateTimePlus][1] class. It has a _toString method which means it can be converted to string via normal casting (i.e. (string) $value).

Setting a default value on a datetime field:
Too do that you will need to create a new [\Drupal\Component\Datetime\DateTimePlus][1] object and set it as the value of $element['#default_value']


Leave Page Alert "warning " Unless Submit Button Clicked

You can use the dirty forms module.

Currently there is only a drupal 6 version on the project page, however in this issue there is a drupal 7 version that apparently has been well tested and works.

With this module you can configure it to target your form using css seletors like classes and ids.


IMCE 6.27 Missing Buttons to Upload to Editor

The issue in this instance laid with Google Analytics and it's Event Tracking. A quick test is to turn on the Google Analytics Module, then try to use the IMCE upload buttons again. If they return, do the following:

Re-enable Google Analytics Modules you'd previously turned off to test.
Goto /admin/settings/googleanalytics
Open the collapsible menu option "Page Specific Tracking Settings"
Add imce to that list Click Save
Configuration and test again.

Your IMCE should be working again without issue should the Google Analytics have caused your issue in the first place.


Get custom fields from users table in global user object

You can implement the hook_user_load() for this purpose

I have altered the user table with field "fname" , Now you can load this in user object with the help of hook_user_load() func.

function testing_custom_user_load($users) {
  foreach ($users as $record) {
     foreach ($users as $record) {

        $result = db_query("SELECT fname FROM {users} WHERE uid IN ($record->uid)")->fetchAssoc();

        $users[$record->uid]->extra =$result['fname'];
     }
  }

}

Just put this code snippet in any of your custom module file.


I'm sure this can be done more elegantly , but I was able to do this with a #icon_variable from the form[] to change the input suggestion. I just added side that I want the icon on the button and an extra option to ...-icon-class.html.twig etc.

1) Add a suggestion to the input

function MODULE_theme_suggestions_input_alter(array &$suggestions, array $variables, $hook) {

   if (isset($variables['element']['#icon']) || isset($variables['element']['#icon-left']) || isset($variables['element']['#icon-right'])) {
         $suggestions[] = 'input__submit_icon';
         if (isset($variables['element']['#icon'])) {
           $suggestions[] = 'input__submit_icon_' . $variables['element']['#icon'];
         }
      }
   }

Then I can add/alter this on the form:

   $form['actions']['submit']['#icon-left'] = 'icon-class';

With a template like input__submit_icon.html.twig :

<button {{ attributes }} >
    {% if element['#icon-left'] %}

    {% endif %}
    {{ attributes.value }}
    {% if element['#icon-right'] %}

    {% endif %}
</button>


Is there way to export block layout settings?

This question is about D8, for which you can use an approach as suggested in the comment from Ivan Jaros, i.e.:

  ... enable config core module and export the blocks (they are basically just instances of blocks) via admin/config/development/configuration/single/export and put them into your theme's config/install directory.

What not everybody may know, is that this kind of block related facilities that are new in D8, is actually because of the Bean module which has been included with Drupal 8 core (refer to this issue for more information).

This implies that a similar question for D7 can be resolved also by using the Bean module. Here is a quote about its project page:

  Think of a Bean as a method to provide new types (compared to node this would be a content type) which then provides an add content interface to create as many blocks as you require (see screenshot below). The bean content can then be placed around the site just like any other block.

This module also works great in combination with the UUID and UUID Features Integration modules. And after you become familiar with the Bean module, you might find other cases in your site where you also want to use this module (which somehow compensates the fact that you need to add another module).

The video tutorial Drupal Bean module tutorial - using Bean Admin UI provides a great introduction to really understand the power of this module, and the kind of things you can do with it (by only using site building techniques, no custom coding involved). It also shows how the Bean module transforms Drupal blocks into fieldable entities.

This module only started as of D7 (because of the "entities" of course that were only introduced in D7), and already has over 22K reported installs. Those who don't use it yet (in D7) should definitely start looking at it in preparation of some day upgrading to D8.


Programmatically created content type module title not working

Ok, I BELIEVE that this is a drupal core issue:

I thought I can create a module with another name as the node bundle I made.

/**
* Implements hook_node_info()
*/
function mycontent_node_info() {
  return array(
    'mycontent' => array(
      'name' => t('My content'),
      'base' => 'mycontent',
      'description' => t('You can define your objects here'),
      'has_title' => TRUE,
      'title_label' => t('Object title')
     )
  );
 }

 /**
  * Implement hook_form()
 */
   function mycontent_form($node, $form_state) {
     return node_content_form($node, $form_state);
   }

This is correct! But my module and hence my hook_node_info function had another name than my bundle.

So admin/strucure/types didn't show the bundle and the module title didn't recognize the bundle property.

So this is solved!


Access the row level field of a image field with multiple values

I'm the author of the Starter module you reference. I've made a change to the get_image_path() twig extension, in order to support images in passed by these means.

In order for this to work as required, you need to change your view - under Multiple Field Settings for your field, tick 'Display all values in the same row'. This will ensure that the fields aren't output as a multiple of the total number.

Then, in your view fields template, use:

{% for item in row._entity.field_header_images %}
  {{ get_image_path(item.getValue()) }}
{% endfor %}

Hope this helps.


How to show fontawesome icons in admin page inside Ckeditor?

A CKEditor plugin for fontawesome exists. If you're using the WYSIWYG module there are a number of hooks that allows you to modify your WYSIWYG editor. In fact, someone has done a write up on how to manually add CKEditor plugins using Drupal.


How to choose between Bean, Boxes and Fieldable Panels Panes?

It's perfectly possible to make a D7 site without blocks if you can live without dashboard.
Our new - content driven - site is being built on panels with workbench as a suitable (for us) alternative to dashboard. Arjan appears to already understand this.

On to the alternatives.
Read Your site should be full of beans.
The problem with boxes is the danger regarding overwriting existing content when using features. But read Fabian Franz's comment in the same article. Beans has many options. I'm not comfortable regarding management, scalability and performance. Hardcore developers that are fluent with panels use Fieldable Panels Panes. Fieldable Panels Panes lack documentation and examples.
What should get everyones focus and effort for D8 is the wscci-initiative. It allows for REST-calls, including for example DELETE. This could permanently tackle the problem of overwriting site builder configuration on code rollouts.


Is it possible to disable the Node module?

In Drupal 7 the answer is no, it's a piece of functionality built into the system more than required by anything else. I've heard rumors long ago maybe in Drupal 8 it would not need to be enabled by default -- but I'm not sure of that status now.

It's needed for example because it provides paths to content on the site at node/NID by non-developers -- yes Entities can do that. Drupal caters to a wide range of audiences, not just those that understand what a Node is and what an Entity is. In Drupal 8 there may be an install profile which is super minimal to even not include any content types, I'm not sure what happened regarding that ... ah in Drupal 8 they still require the Node module in the Minimal profile installer:
https://github.com/drupal/drupal/blob/8.0.x/core/profiles/minimal/minimal.info.yml

If you want to use entities then use a module like Rabbit Hole to hide any node content and do not use default nodes at all.


What is the purpose of _field_sql_storage_columnname()?

I think it's clear what the function is doing, the question was more why a function is required for that.

My guess is that the function was there from very first day field API existed where it might have made sense to change it. Nowadays, it's not going to be as easy as "just" changing that function, because it will obviously completely break all existing field tables.

I think the function is still useful for consistency reasons as there is one for the table name as well and I think it's also easier to read because it implies the string is the column name, which might not be that obvious if you e.g have a line like this:

$sql_field = "$table_alias." . _field_sql_storage_columnname($field['field_name'], $specifier['column']);
// vs.
$sql_field = "$table_alias." . $field['field_name'] . '_' . $specifier['column'];