How can I implement this floating sidebar block?

You can achieve it with HotBlocks module, Check out the screencast

Add, remove, and reorder nodes or blocks to a page without leaving or
reloading the page or using editors
Content added to hotblocks can be constrained to individual pages or
be made global to display on all pages that contain the hotblock
Can display multiple instances of the same block or node in multiple
regions
Can give end users the ability to add and remove blocks to pages
without exposing the administer blocks permission
Provides a means to filter which of those blocks are available to the
user for adding so every block in the system is not exposed
See an overview and administer all of your assigned hotblock content
grouped by region, url, or taxonomy on a single page
Allow users to add and remove content to a page without giving them
permission to edit that content
Advanced permissioning possible - allows you to control which roles
can assign/remove/reorder each type of content to every hotblock
individually if necessary
You can use your own custom icon set for the UI controls to customize
look and feel
If you don't like the term "hotblock" you can customize the
terminology exposed to the user to suit your purposes

and for floating use Floating block module.


Users and Forum Transfer from a live site to a staging site

Use Features for all need of these kind. Module page explains -

  Features provides a UI and API for taking different site building
  components from modules with exportables and bundling them together in
  a single feature module. A feature module is like any other Drupal
  module except that it declares its components (e.g. views, contexts,
  CCK fields, etc.) in its .info file so that it can be checked,
  updated, or reverted programmatically.

So you can make feature of your users setting as well as forum and you can always track the changes at your staging site and if it's overridden then you can make it again and apply the changes at live site by replacing the created feature and enabling it..


Disable cache during development: Templates are not discovered

try add this in .htaccess  (drupal root)

    <IfModule mod_headers.c>
       //ADD THIS
        Header set Cache-Control "no-cache, no-store, must-revalidate"
        Header set Pragma "no-cache"
        Header set Expires 0
    </IfModule>


How can I access the virtual machine filesystem from within Windows?

Create shared folders from Virtual Box Manager. For each drive you will have to create a shared folder. These shared folder will appear in guest OS as network file-systems.

As Ubuntu (Linux) is underlying in QuickStart.

Mounting temporarily need to fire this command from terminal:

sudo mount.vboxsf [share_name] [directory - mount point e.g. /mnt/share/]

OR

sudo mount -t vboxsf [share_name] [directory - mount point e.g. /mnt/share/]

Mounting permanently using fstab (/etc/fstab)
Make sure to install samba first (in ubuntu it should be already installed or do it sudo apt-get install samba, it needs internet connection)

Now edit your fstab file and add an entry in the last

\\vboxsvr\[share_name] [directory - mount point e.g. /mnt/share/] vboxsf rw,gid=100,uid=1000,auto 0 0


How to reset form page after it has been successfully submitted?

That happens because you are using $form_state['rebuild'] = TRUE; which is telling Drupal to rebuild the same form, which also mean the form will be repopulated with the last values the users entered. When you then set $form_state['rebuild'] to TRUE, $form_state['redirect'] is ignored, since the user is already redirected to the page containing the form.

The code I would use is the following one.

function answers_custom_form_answer_node_form_alter(&$form, &$form_state) {
  if (arg(0) == 'node' && is_numeric(arg(1))) {
    // See https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_get_object/7.
    $node = menu_get_object();

    if ($node->type == "question") {
      $form['#submit'][] = "answers_custom_destination";
    }
  }
}

function answers_custom_destination($form, &$form_state) {
  // Since the form submission handler is added only when the user is seeing node/%node,
  // there is no need to verify that again.
  $form_state['redirect'] = FALSE;
}

As side note, since the form alter hooks and the form submission handlers share $form_state, which is passed by reference, if something needs to be shared between those functions, it can be added to $form_state. As long as the added array index doesn't conflict with an array index used by Drupal or third-party modules, all is fine.

For example, this code would use $form_state to share a value between the hook altering the form, and the form submission handler.

function answers_custom_form_answer_node_form_alter(&$form, &$form_state) {
  if (arg(0) == 'node' && is_numeric(arg(1))) {
    // See https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_get_object/7.
    $node = menu_get_object();

    if ($node->type == "question") {
      $form_state['answers_custom_question'] = $node;
      $form['#submit'][] = "answers_custom_destination";
    }
  }
}

function answers_custom_destination($form, &$form_state) {
  // Since the form submission handler is added only when the user is seeing node/%node,
  // there is no need to verify that again.
  $form_state['redirect'] = drupal_get_path_alias('node/' . $form_state['answers_custom_question']->nid);
}

Reference

drupal_build_form()
drupal_redirect_form()


get the content moderation value on node update

Getting the version of the entity meant getting the last revision and allow to get the correct value

function my_hook_entity_update(Drupal\Core\Entity\EntityInterface $entity) {
  if ($entity->getEntityTypeId() !== 'node') {
    return;
  }

 $current_entity_lang = $entity->get('langcode')->value;
 $translated_entity = $entity->getTranslation($current_entity_lang);
 $mod = $translated_entity->get('moderation_state')->getValue());
}


modules_install hook causes constraint violation: 1048 Column 'module' cannot be null: INSERT INTO {role_permission} (rid, permission, module)

Seems like a hook_install() in the .install file for the feature will work if called with

drupal_flush_all_caches();

I am not sure if this is the best solution, but it seems to work for me


Take a look at the Colorbox node module. you could show any node or view in a colorbox.


drush status not showing correct setting from alias file

This is not supported by Drush, as explained in this issue: https://drupal.org/node/1335626

In brief, the database information stored in an alias file is only used for Drush commands such as sql-sync, sql-cli and so on; a Drush alias will never affect the way that Drupal is bootstrapped.  Therefore, Drush core-status will always show you the database info from settings.php, which is where Drupal reads it from.

If you want to force a different database configuration for a given alias, it would be best to use Drupal's multisite feature, and make another settings.php in a sites/test folder.  Then, just specify 'test' as the uri for your alternate alias.  Should work like a charm.  I always prefer to give my local test installations a completely separate copy of the Drupal + contrib code base too, though, in case I want to fiddle with the code on test without interfering with my other local copy's behavior.  Using the multisite feature is fine if this is not a concern for you, though.


Is it possible to change the "view type" from a "content view" to a "search view"?

You can use Display Suite search module to use search view like content view. Display Suite module have a submodule namely search that extend the search results for Drupal core or Apache Solr.

Steps:

Install Display Suite Search Module after downloading from above
link.
Go to content type's manage display and check the search result option that you find under custom display settings on vertical tab after that save it.

Now Go to Search result display mode local tab link and configure your display of fields as you want and save it.

For Manage Core search result :

Go to admin/structure/ds/list/search and choose option 'search result' in view mode and save it.

Go to admin/config/search/settings and chose option Display Suite
Search for ACTIVE SEARCH MODULES and Default search module.

Now search using core search form. This will display differently as core search result.

Now Manage Search api Search result :

Go to view of desired search index views.
Choose Format show as Rendered entity

Go to Format show setting option and choose option 'Search result'

Now save this views.

After that you can see search api result is as you configure previously on manage display.


How to override registration form message

You can check this message in hook_init it's working for me please try this code.

function custom_init() {
 if (!empty($_SESSION['messages']['status'])) {
  $message_text_to_remove = "Registration successful. You are now logged in.";
  $key = array_search($message_text_to_remove, $_SESSION['messages']['status']);
   if ($key !== FALSE) {
      $_SESSION['messages']['status'][$key] = t('Greta Now your message changed');
    }
  }
 }

Thankyou


How to post the node link in social networking if node is published?

For Facebook and Twitter you should be able to get this to work using the Rules module, though for Google+ this sounds like a business opportunity (read: no known solution as of today). Read on for more details about each of them ...

Facebook

The Facebook Rules module can be used to post to user's wall, via the Rules module. Some more details about Facebook Rules (from its project page):

  Facebook rules module extends FBOauth permissions and integrates with Rules module.

  Once the user's Drupal Account is connected to his/her FaceBook Account, FaceBook Rules can be used to set up actions based on particular events or triggers.

  It provides following rules:

  Events:

  User logged in using Facebook connect.
  User connected existing own account to Facebook.
  User registered using Facebook connect.
  User registered using Facebook connect, requires admin approval.

  Condition: User's Drupal account is connected to Facebook account.
  Action: Post to user's wall.

Twitter

After you enable the Twitter module, and its sub-module Twitter Actions, you can use the Rules module to create an action that will post a tweet to a specific Twitter account.

Have a look at Post Automated Tweets Using Rules and Twitter Actions for more details about it.

Google+

For Google+ I'm not aware of any working solution. Yes there is the Google+ module (which only has a dev version for D7 ...). And yes Google+ does have an API, but this module doesn't implement it.

Therefor I think the best you can find (to start from) is what is described in How to post in google plus wall?. Starting from there, you may get that to work also if you'd write your own (custom) Rules (Event(s), Condition(s) or Action(s)), similar to what is described in the answer to the question about "How to login-redirect users to their profile page on specific days only?".

PS: Using the Rules module to make something happen when something gets "published" should be a no-brainer (that's like Rules lesson 101, which I assume does not need any more explanation).


How do you retrieve the node IDs of the nodes using a a taxonomy term?

EntityFieldQuery to the rescue:

$query = new EntityFieldQuery;
$query->entityCondition('entity_type', 'node')
  ->fieldCondition('field_name_of_term_reference_field', 'tid', $term_id);

$result = $query->execute();
if ($result) {
  $nids = array_keys($result['node']);
}


FileField Permissions- How can I allow users to upload a file without giving them the ability to remove files that have been uploaded?

Try to add a second file field via the field UI; to set the permissions for a single field you could use hook_field_access().


Drush Make and the Windows maximum path length

The Drush temporary directory can be set manually in the environment variable TEMP. So something like:

mkdir -p /c/drushtmp
TEMP=/c/drushtmp drush make [...]

can neatly solve the MAX_PATH problem for the temporary directory.


How to allow anonymous users to view page?

I think it is hard to achieve.
However, using Access Unpublished module, maximum you can do is you can provide the specific URL to anonymous user(which includes all), so they can see the unpublished node with that specific URL(So, this way you are hide content from all other users, as they have not that URL), however they can not edit. For Editing option you have to set the separate user role, hence it ends up with login.


Capturing return value from remote post hander

There is no built in solution for this, you have extend the Remote post handler and write some custom code.

Please open a ticket in the Webform issue queue. Ideally, the remote post handler would be able to populate some meta data that could be exposed via a token.


Permission to edit own unpublished content (only)?

hook_node_access() to the rescue!  You need to create a new module to do this.  In the new module's .module file you'll need to put this:

function YOUR_MODULE_node_access($node, $op, $account) {
  // Deny updating the content if it's a published poll
  if ($node->type == 'poll' && $node->status && $op == 'update') {
    drupal_set_message('This poll has been published, you may not make changes to it.','error');
    return NODE_ACCESS_DENY;
  }
}


How can I redirect users on login based on their chosen language?

May be this can help you.

function custom_module_user_login(&$edit, $account){
  $base_url;
  if($account->language) {
          $redirection = $base_url.'/'.$account->language;
  } else{
      $redirection = $base_url;
  }

  // Unless there is already a redirection going, or the user is trying to reset his password, we redirect to $redirection.

  if (!is_null($redirection) && (!isset($_POST['form_id']) || $_POST['form_id'] != 'user_pass_reset')){
    $_GET['destination'] = $redirection; // Should we use $edit['redirect'] instead..?
    $GLOBALS['destination'] = $redirection; // Should we use $edit['redirect'] instead..?
  }


Return inserted serial from drupal_write_record

drupal_write_record() populates the serial field of an object you pass to it automatically. So assuming you have a serial field in your table called id, if you run code like the following:

$record = new stdClass;
$record->title = 'Title';
$record->some_other_field = 'Something';

drupal_write_record('table_name', $record);

the $record object will be auto-populated with a member representing the serial column when the function returns. In this example you can access it with $record->id.


How to redirect all URLs of all terms in a specific vocabulary to custom URLs

The Rules module is your friend to implement such redirects ...

Here is the rule you'd need for it (in Rules export format, just use copy/paste it to import it in your own setup via the Rules UI):

{ "rules_redirect_an_old_path_to_a_new_path" : {
    "LABEL" : "Redirect an old path to a new path",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "init" : [] },
    "IF" : [
      { "text_matches" : {
          "text" : [ "site:current-page:url" ],
          "match" : "the_old_path",
          "operation" : "starts"
        }
      }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "Sorry, the old path (= /the_old_path) is no longer in use, you will be redirected automatically to its corresponding path (= /the_new_path)" } },
      { "redirect" : { "url" : "the_new_path" } }
    ]
  }
}

A few more tweaks to make it fit your exact scenario:

change all occurences of the_old_path to your old path corresponding to [term:vocabulary]/[term:name].
change all occurences of the_new_path to your new path corresponding to CUSTOM_WORDS/CUSTOM_WORDS/[term:name].

Attention (1): when applying those 2 changes above, you want to do so using the Views UI. So that you are sure that you'll use the exact Rules syntax, e.g. using "tokens" that the Rules module makes available. But also know that sometimes it's a bit tough and/or tricky to get that right.

Attention (2): it could well be that the Rules condition (with that text_matches) has to be replaced by something using a "regular expression" (instead of that starts in my sample).

Whenever such redirect actually happens, the user will also receive an informational message like so:

  Sorry, the old path (= /the_old_path) is no longer in use, you will be redirected automatically to its corresponding path (= /the_new_path)

If you don't want such message to appear, then just delete the line containing drupal_message in the exported rule above.


How can I use a Twig if statement in a View rewrite

You don't need to strip HTML tags. This works for me:
{% if field_tags == "green" %}
   GREEN
{% else %}
   NOT GREEN
{% endif %}

where field_tags is a taxonomy reference field with "Link label to the referenced entity" disabled.


Getting a better handle on APC Cache Bins / code for settings.php

"APC has been running for 3 min 54 sec. Currently caching 0 entries (0
  bytes)."

This message suggests that your APC is running for each php request separately ultimately not caching anything at all.

I had a similar issue and it required to set up PHP once again but in a different mode.

APC works fine for multiple processes with apache/2 + php 5.3.x + php-fpm + fcgi in FPM/FastCGI mode.

PHP 5.3.x is configured with following options --enable-force-cgi-redirect --enable-fastcgi --enable-fpm

In APC section of my php info I can see:

APC Support = enabled
Serialization Support = php
MMAP File Mask = /tmp/apc.something  | where something is a random 6-character string

Please check your phpinfo

In PHP Configure Command you should have:
'--enable-fastcgi'
and
'--enable-fpm'

In Server API :
 FPM/FastCGI

Check if you have cgi-fcgi section and if you can find
php-fpm set to "active"

NOTE: There might be another solution if you use php 5.2.x or older.


Garland sub-theme color functionality is not working

From Example: Creating a Garland Subtheme That Utilizes the Color Module

  That said, even if you do not have a style.css file in your subtheme
  directory, you still must add it to your .info file with
  stylesheets[all][] = style.css


In my opinion that is the case for a View. You should prepare a view with the fields you want to display from referenced nodes.

Then install Entity Reference View Widget module. With that module you will be able to use your view to select the node references.


Contextual Filter with Title and Language

Multiple contextual filters are fine & dandy.
The issue seems to be that the url prefix being used in a translated/localized content is a bit different from the actual machine code for the language. French is not 'fr-fr' but simply 'fr' in Drupal's views. French Canadian would be 'fr-ca'.

here is a list of defined languages I use on my site along with their codes. These should be what you're looking to filter on. No issues with multiple filters.


Print title of block group to allow for collapsible group

I'm about to do something similar, but I imagine you could do a preprocess and populate the variable yourself.

-- EDIT --

As a matter of fact, I am sure of it. Just did it myself.

In template.php write a hook_preprocess_region() function.

function mytheme_preprocess_region(&$variables) {
  if ($variables['region'] == 'blockgroup_regionname') {
    $variables['title'] = 'Title';
  }
}

Then just in your template.

<?php if ($title): ?>

<?php print $title; ?>

<?php endif; ?>

Which in turn should make the variable available to whatever else you are trying to do. SHOULD anyway. Good luck!


Get whole tree of a taxonomy term from node into seperate php variables

It appears from your printout that taxonomy_term is an object, not an array. So your code would look like this:

$country = $node->field_location_term['und'][0]['taxonomy_term']->name;

You might not be able to do the object->['array']->object->['key'] thing. It might need to be broken into:

$foo = $node->field_location_term['und'][0]['taxonomy_term'];
$country = $foo->name;


How can I add additional query parameters to a view title linked to a node?

You can do this in Views.

Add a new field to the View "Content: Path".
Check Exclude from display.
Click on Rewrite Results and the check "Use absolute link".
Click Apply button to Save.
Rearrange your fields so "Content: Path" is above "Content: Title".
Click on the "Content: Title" field.
Uncheck "Link this field to the original piece of content".
Click on Rewrite Results and check "Output this field as a link".
In the Link path textbox enter "[path]?return_view=myview".  (You can use the path replacement pattern because it is above the title field in the field order)
Click Apply.


Theme user pictures in comments in drupal 7

To help you understand the syntax, have a look at the comment.tpl.php documentation, here you will find the different variables and a link to template_preprocess_comment() where they are defined:

$variables['picture']   = theme_get_setting('toggle_comment_user_picture') ?
                          theme('user_picture', array('account' => $comment)) : '';

So there's a theme function to render this picture: theme_user_picture() which state you should have a look a the template file: user-picture.tpl.php which finally send you to template_preprocess_user_picture().

There you can override this function copying and pasting the original code and changing the bits and parts you want to suit your needs (put this code in your template.php file):

function YOURTHEME_preprocess_user_picture(&$variables) {
  //change only the relevant part and leave the rest of the code
  //For Drupal 7 imagecache is in core so I put the correct syntax
  $variables['user_picture'] = theme('image_style', array('style_name' => 'size32x32', 'path' => $filepath, 'alt' => $alt, 'title' => $alt));

  //...
}

Have a look at the $variables to find a way to target comments or add a class there and use CSS as dkiscool mentionned.

NB: if you don't like browsing all the API documentation, there's a faster way, use theme developer (see this answer).


Add this to the YOUR_THEME.theme file:

function YOUR_THEME_preprocess_page(&$variables) {
  $variables['site_name'] = \Drupal::config('system.site')->get('name');
}

And then this in your page--front.html.twig template:

{{ site_name }}


function hook_views_post_execute(&$view) {
  // If there are more than 100 results, show a message that encourages the user
  // to change the filter settings.
  // (This action could be performed later in the execution process, but not
  // earlier.)
  if ($view->total_rows > 100) {
    drupal_set_message(t('You have more than 100 hits. Use the filter settings to narrow down your list.'));
  }
}


Multililingual views displaying wrong content

To make the view results correspond to the language switcher, add a filter for Content  Translation: User's Current Language, which is the language that an authenticated user has set in the user settings (it is NOT the same as the current browser language or the site language).

If no option for the 'User's Current Language' is available in the filter criteria form, then verify your configuration at Configuration -> Languages -> detection and selection: the order should be 'URL, Default, User', and not something like 'Default, URL, User' (as mentioned also in https://www.drupal.org/node/1701854#comment-6279474).

Note: filtering Views results in a multi language site can sometimes be challenging, as illustrated also in discussions such as in https://groups.drupal.org/node/47478 ...


How to add an external image to node with a module?

File field references are made on the fid column in the file_managed table -  you haven't saved the file object so it doesn't have a fid, and thus nothing to relate the field data to.

Just add a call to file_save after you've prepared the file object, but before you add it to the field on the node object:

file_save($file);


Create separate .tpl for content types and then put the code to print taxonomy term

<?php if($node->field_category): ?>
<div class = "top_tag">
  <?php print $node->field_category['und'][0]['taxonomy_term']->name;?>
</div>
<?php endif;?>

put this code in template.tpl.php

function mytheme_preprocess_page(&$vars) { // replace mytheme with your theme name
  if (isset($vars['node']->type)) {
    $vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
  }
}

hope it helps you!


Do we have Node Reference : Representative node similar to the Taxonomy term: Representative node

The References module doesn't seem to provide a Views relationship like that. Here is one way to achieve the required functionality in your case:

Add a reverse Node Reference relationship to get teacher nodes referencing the college. This will get you all teachers for each college.
Implement hook_views_query_alter() and add the extra condition utilizing a subquery:

function mymodule_views_query_alter(&$view, &$query) {
  switch ($view->name) {
    case 'college_teachers':
      $expression = '
        field_college_node.nid = (
          SELECT n.nid
          FROM {field_data_field_college} fdfc
          INNER JOIN {node} n ON n.nid = fdfc.entity_id
          WHERE fdfc.entity_type = "node" AND fdfc.field_college_nid = node.nid AND n.type = "teacher" AND n.status = 1
          ORDER BY n.created DESC
          LIMIT 1)'
      $query->add_where_expression(0, $expression);
      break;
  }
}

(The Views-generated field_college_node alias is a bit misleading because in fact, it will reference the teacher node, not the college one.)


Implementation of hook_file_default_displays() {media module} makes it impossible to export image display settings via features

The problems comes from the heart of Media module which programatically add default overrides.

I have managed to solve the problem in 2 steps:
(1) Sunk the Media Icon to the bottom

apply a patch to Media module:

--- sites/all/modules/contributed/media/media.module
+++ sites/all/modules/contributed/media/media.module
@@ -1082,7 +1082,7 @@
   $file_display = new stdClass();
   $file_display->api_version = 1;
   $file_display->name = 'video__preview__file_field_media_large_icon';
-  $file_display->weight = 0;
+  $file_display->weight = 50;
   $file_display->status = TRUE;
   $file_display->settings = '';
   $file_displays['video__preview__file_field_media_large_icon'] = $file_display;
@@ -1093,7 +1093,7 @@
   $file_display = new stdClass();
   $file_display->api_version = 1;
   $file_display->name = 'audio__preview__file_field_media_large_icon';
-  $file_display->weight = 0;
+  $file_display->weight = 50;
   $file_display->status = TRUE;
   $file_display->settings = '';
   $file_displays['audio__preview__file_field_media_large_icon'] = $file_display;
@@ -1104,7 +1104,7 @@
   $file_display = new stdClass();
   $file_display->api_version = 1;
   $file_display->name = 'document__preview__file_field_media_large_icon';
-  $file_display->weight = 0;
+  $file_display->weight = 50;
   $file_display->status = TRUE;
   $file_display->settings = '';
   $file_displays['document__preview__file_field_media_large_icon'] = $file_display;

(2) I exported my feature but manually edited the File Display like this:

YOURFEATURE.features.field.inc

For Default the order is

Vimeo
Vimeo Preview
Youtube
Youtube Preview

For Preview the order is

Vimeo Preview
Vimeo
Youtube Preview
Youtube


Pathauto deactivate when I use node_save($node)

You'll need to set:

$node->path = array('alias' => $path, 'pathauto' => FALSE);


Adding a value using that code won't actually work since you've only defined one textfield, and thus, only one value will be stored. All the new fields returned will have the same id/name as the first one so only one form value will be sent back to the server when the form is submitted.

You need to add an extra layer to the form structure to make each field instance unique, say by including an instance number in each id/name.
Something like $form['checkboxes_fieldset'][$i]['number'] where $i is increased by one for each field instance. That goes for all the elements inside the fieldset. You generate these fields in a loop, but before that you check how many instances of the field are already present in the form state so you know how many iterations are needed in the loop. For each iteration, you also check if the form was submitted and if the current field instance matches the name of the button used to submit the form. If so, you skip adding that field instance to the form (don't increment the instance counter this iteration to keep the total count synced).

The submit handlers for adding/removing fields simply set the 'rebuild' flag in the form state and return the fieldset to be updated (all instances get re-rendered each time).
Adding/deleting field instances then become an indirect action of rebuilding the form with the correct number of field instances.

The examples module on drupal.org has an "add more" AJAX example which is fairly similar to what you want, except that it always removes the last field instance.


How to delete events from Full Calendar?

if you want to be able to delete nodes directly from the calendar, here is how:

make sure you have the tokens module installed/enabled.

in your fullcalendar view, add the Content:Nid field.
add a global:custom text field that is under the nid field you just added, and input the following as the text:

node/[nid]/delete
click on the fullcalendar settings (under the format heading) and click "customize fields" click the "use a custom redirect URL" checkbox, then in the dropdown, select your custom text field you created in step 2.
save the view.

now when you click on the event, it will ask you to confirm or cancel the deletion of the node.


How to copy data from one node reference to another node reference in same content type

As far as I know VBO is rather not for this kind of job, I also don't know any other module to help you with this except the migrate module but I also think that it won't be of any help for you. What you are describing is called "migration", transferring and storing data from one place to an other, even if it is just one field or an entire website. Most migration tasks require at some point, if not at all points, code writing, code to  manage the data during the migration. Fortunately, to your case is just a field, so you'll need to write a small script by taking advantage of the Drupal's node API, to transfer the data from one field to another, and that's it.

Rough idea on how to do it:

$query = new EntityFieldQuery();

$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'events')
  ->propertyCondition('status', NODE_PUBLISHED)
  ->addMetaData('account', user_load(1)); // Run the query as user 1.

$result = $query->execute();

if (isset($result['node'])) {
  $nids = array_keys($result['node']);
  $nodes = entity_load('node', $nids);
}

foreach ($nodes as $node) {
  $value = $node->field_organization[LANGUAGE_NONE][0]['value'];
  $node->field_affiliation[LANGUAGE_NONE][0]['value'] = $value;
  field_attach_update('node' ,$node);
}

Use drush to run your script by using this command :

drush php-script site/all/scripts/script_name
I know, this is too much for someone who has not much experience with Drupal yet but if you are really serious in getting involved with it you should start learning and use those things as much as possible.

Lastly, if you still insist to do it without writing a single line of code, do it manually, but you will soon discover that that way has a major disadvantage if your nodes are more than one or two hundred.


Specifying the root resolved this for me. Having used composer to install drupal through drupal-composer/drupal-project the site is put in a "web" folder so the following worked.

drupal --root=/var/www/html/web list

I had also run the init command beforehand

drupal --root=/var/www/html/web init


Which newsletter module will fit my requirements?

Try the Newsletter module. The features portrayed in the project page:

  Multiple newsletters lists configurable on existing terms.
  Plain text or HTML out of the box.
  Multiple schedules Each newsletter can have more than one schedule, e.g. Daily, Monthly, Weekly, manually or even custom, eg after 10 new
  posts for this term.
  Centralized administration and configuration on a single page.
  Users can customize the terms in the list they subscribe to.
  Custom template per list.
  Statistics (CTR and Open-Rate).

It allows using HTML for the email (uses regular Drupal filters).


Personally I deal with situations like this in a custom module by registering a path with a callback function that prints the needed content:

function mymodule_menu() {
  $items['somepage/%'] = array(
    'title' => 'Somepage',
    'page callback' => 'mymodule_ajax_callback',
    'page arguments' => array(1),
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

function mymodule_ajax_callback($nid) {
  if ($node = node_load($nid)) {
    $view = node_view($node, 'full');
    print drupal_render($view);
  }
}

This would get you the view of node 12 without any external markup on 'somepage/12' for example. Note that when you use return instead of print you get the page with additional markup added (just for future reference).

If you want to go with the template approach you could create 2 templates: 'html--blank.tpl.php' and 'page--blank.tpl.php'. The first one should contain only <?php print $page; ?> and the second <?php print render($page['content']); ?>. In your template.php file add:

function mytheme_preprocess_html(&$variables) {
  if (isset($variables['page']['content']['system_main']['nodes'])) {
    $nodes = $variables['page']['content']['system_main']['nodes'];
    $key = key($nodes);
    if (count($nodes) == 2 && $nodes[$key]['#node']->type == 'my_content_type') {
      $variables['theme_hook_suggestions'] = array('html__blank');
    }
  }
}

function mytheme_preprocess_page(&$variables) {
  if (isset($variables['node']) && $variables['node']->type == 'my_content_type') {
    $variables['theme_hook_suggestions'] = array('page__blank');
  }
}

These solutions will give you a slightly different result, but either should get the job done (just remember to modify them to fit your needs and clear the caches).


Why drupal includes *.profile file on every page?

This is a new feature of Drupal 7: install profiles behave like modules.

See #509398 : Install profiles should be modules with full access to the Drupal API and all it entails

Code that you don't want loaded during run-time should be moved to hook_install().

Edit - Xio asked about uninstalling a profile.
variable_set('profile', 'standard');
might work.


How to make textfield with ['#ajax']['keypressed'] = TRUE trigger only on click and not on blur?

Maybe too late but for the others :

['#ajax']['event'] = 'none'


How can I assign a block to a panel or mini-panel?

Mini panels are blocks and you can add Mini Panels to Panels. You can't add blocks themselves to Panels, but usually most of the content that you can display in a block, you can actually display in Panels, content such as Activities, Menus, Mini panels themselves, Miscellaneous, Pages elements, Views, Widgets, Nodes, Custom content and more.

See Drupal - Blocks vs Context vs Panels.


You can user template_preprocess_views_view function to do it

function mymodule_preprocess_views_view(&$variables) {
  if ($variables['view']->name == 'my_view') {
    if ($variables['view']->current_display == 'my_display' && !empty($variables['rows'])) {
      $variables['header'] = '';
      $variables['footer'] = '';
    }
  }
}


How can I resend the commerce email from the admin orders screen?

Since I was using the commerce email module, it was a pretty easy setup to use a rules component and then add it to my /admin/commerce/orders vbo view.

{ "rules_resend_order_email_to_customer" : {
    "LABEL" : "Resend order email to customer",
    "PLUGIN" : "action set",
    "REQUIRES" : [ "variable_email" ],
    "USES VARIABLES" : { "commerce_order" : { "label" : "Commerce Order", "type" : "commerce_order" } },
    "ACTION SET" : [
      { "variable_email_mail" : {
          "to" : [ "commerce-order:mail" ],
          "variable" : "commerce_email_order_[mail_part]",
          "language" : "default"
        }
      }
    ]
  }
}


A tutorial with more detail can be found here tutorial. But in short what you want to do is the following:

Find the correct .tpl file and copy it into your theme. Edit the .tpl in your theme and remove the wrappers.
Don't forget to flush caches after inserting a new template. All the template files are in the sites/all/modules/views/theme folder (depending on where exactly you installed views). There are quite a lot of them and the view templating is quite complex, luckily views helps you with a list to find the right one.

You can find the list of template names you can use in the views interface (where you edit your view) under the advanced tab.
Look for the Theme: information item. Clicking it will give you the list of all the .tpl files this view would use if able (ordered from most general to most specific and highlights the current one).

Note

Be as specific as possible to prevent accidentally breaking other views (rename the template file if to match the name in the list).
more about the view templates


I got a notice every time I upload an image

The issue is already fix. The hosting provider had changed some permissions of my shared account.


Path alias creates redirect loop or redirects to the front page

Edit your page and go to URL redirects. Find the redirect path with the most number of count and delete it. Click save then view the page.

Let me know if that fixed your problem


How can I programatically enable a block by default for a theme?

There isn't a way to perform programatic actions during the enabling of a theme. You can, however, have your custom blocks module add an entry to the database for the placement of the block into a theme's region, before that theme is enabled.

To do that, you would implement a database insert query, perhaps in your module's install function, that creates an entry in the blocks table for the block(s) in certain regions in any theme. You can create these entries whether the theme(s) are enabled or not.

The result will be that the block appears to be enabled when the theme is installed.

Here is a d.o forum post on the subject, with some helpful examples


Webform submission edit - redirect after edit

try using rules module, it has a full featured of triggering actions with conditions like content type, user roles, ... etc.

Take a look at the documentation if needed.


Pasting the code made me think about the problem in more detail.

It's a question of which gets sent first: 403 (Access Denied) or 404 (Page Not Found).

If it's a legal URL ("library" or "library/valid-category") but the user doesn't have access, they get a 403 and redirected.

If it's not a legal URL ("library/invalid-category") it gets reported as a 404 ... even though they don't have access anyway.

Makes sense.


I can't get my drupal_http_request to go to the correct function

The path that you are passing in drupal_http_request is incorrect. It should be $create_website_applicant_path = 'http://' . $website_url . '/api/applicant/';


How to change/set/assign parameter's value for an entity query?

There are some nice examples in the comments on the api documention page for Entity queries https://api.drupal.org/api/drupal/core!lib!Drupal.php/function/Drupal%3A%3AentityQuery/8.2.x

One example assigns a value to a variable, then uses the variable in the query:

$value = 'some value';
$query = \Drupal::entityQuery('entity_type');
$query->condition('field', $value);
$entity_ids = $query->execute();

In your loop you could re-assign the value as needed before executing the query.

Another example sets up some functions, so that might be an option and then your loop could call the function.

function someFunction($value) {

  $query = \Drupal::entityQuery('entity_type');
  $query->condition('field', $value);
  $entity_ids = $query->execute();

}

Or you could clone the part that stays the same in your loop and alter the rest.  Using your code as an example...

$base_query = \Drupal::entityQuery('taxonomy_term');
$base_query->condition('vid', 'some_vocabulary');

for ($i = 1; $i <= 10; $i++) {
  $query = clone $base_query;
  $query->condition('tid', $tids[$i]);
  $query->execute();
  //...
}


Serial is used for auto-increment column of the table(so here auto increment is implicit), e.g. for node table nid has a serial data type and int can be any number based on size provided.

  'type': The generic datatype: 'varchar', 'char', 'int', 'serial',
  'float', 'numeric', 'text', 'blob' or 'datetime'. The types map to the
  underlying database engine specific datatypes. Use 'serial' for auto
  incrementing fields.

Reference: https://www.drupal.org/docs/7/api/schema-api/schema-reference


One of the features and APIs of the Webform module for Drupal 8 that I personally enjoy using is support for inline messages using the WebformMessage element

The WebformMessage element supports dismissal messages and #states API.

Here is the YAML version of a Message element

message:
  '#type': webform_message
  '#message_type': warning
  '#message_close': true,
  '#message_storage': user,
  '#message_message': 'This message can be dismissed by a user'

Here is the PHP syntax, which can be used in your custom code.

$build['message'] = [
  '#type' => 'webform_message',
  '#message_id' => 'custom_message_id',
  '#message_type' => 'warning',
  '#message_close' => TRUE,
  '#message_storage' => WebformMessage::STORAGE_USER,
  '#message_message' => $this->t('This message can be dismissed by a user'),
];


I have 2 commerce feeds imports, one must run before the other

There are multiple solutions to this problem:

Cron manager
One is indeed to use a cron manager module. I think you would need Feeds Ultimate Cron for this. This solution would require you though to guess when the first import is completed.

Rules
Using the Rules action 'Execute feeds importer' (requires latest dev of Feeds 7.x-2.x or the patch from https://www.drupal.org/node/2446307). In this case you would create a Rules component of type 'Action set' and then add two times the action for executing a feeds importer (one for each importer). Perhaps it possible with Rules Scheduler to run this action set on a regular basis? Note that you should configure the importers to not run in background, else both imports may still run simultaneously. Also note that Feeds would try in this case to perform the whole import in one go, so it could perhaps cause max runtime issues.

Drush
Feeds has a drush command called feeds-import with which you can perform an import in one go. So you could create a shell script that runs both imports after eachother and then run that script on a regular basis. For details about this command, see https://drushcommands.com/drush-7x/feeds/feeds-import/

Implement hook_feeds_after_import()
Feeds has a hook called hook_feeds_after_import() that you could use to initiate an other import programmatically:

/**
 * Implements hook_feeds_after_import().
 */
function mymodule_feeds_after_import(FeedsSource $source) {
  // Run product display importer after product importer.
  if ($source->importer->id == 'product_importer') {
    $product_display_source = feeds_source('product_display_importer');
    $product_display_source->existing()->startImport();

    // Execute batch, if there is any. Set 'progressive' to false to prevent
    // batch from triggering a drupal_goto().
    // (note: this code is not needed when using the 'process in background' option.)
    $batch =& batch_get();
    if (!empty($batch)) {
      $batch['progressive'] = FALSE;
      batch_process();
    }
  }
}


Change role of users after deleting referred content via rules

I think i resolved it by using "fetch entity by property" and looking for the entity reference field that is equal to the current removed book.
Doing that create a list that you can iterate with the loop and inside this use actions to revoke roles.


Internal links no longer working. Getting MAMP virtual host info instead

Since turning off Clean URLs seems to at least be a work around for your issue, it sounds that you have not correctly configured Clean URLs. To correctly enable/configure Clean URLs, refer to Configure Clean URLs in the installation guide.

If you're not familiar with Clean URLs yet, I suggest to review that documentation (for the version of Drupal that you're using) and make sure your server is correctly configured before proceeding.

Here is a summary of common steps/issues:

With Apache HTTPD as web-server, you have to enable mod_rewrite and configure the necessary rewrite rules in the .htaccess file.
Usually, theses rules are applied automatically, when mod_rewrite is enabled. But in some cases, the AllowOverride directive is too restrictive to allow this.


Can you print single view fields in a block template file?

The first thing do not use that tpl file(views-view--block.tpl.php), this will alter all views of your current system. you can use views-view--news-overview.tpl.php this will alter your current views view only, there is many suggestions in views->advanced->theme:information. you can use appropriate tpl file.


How to use the data from a deleted Field Collection item in a Rule?

Instead of trying to get access to the deleted value with Rules, it's easier to store the sum in a new hidden field, called "Sum". In that way, the 'old value' will always be available in any Rule. Just make sure that you update "Sum" when a new Field Collection item is saved or an existing item is deleted. That can easily be achieved with another Rule.


Wrapping javascript code conditionally using a cookie

This StackOverflow question should contain enough information to solve your issue.

I would go with the one that suggests using setcookie(). $_SESSION information is cleared when the user's session ends, generally at the close of the browser. Here is a recent example of me using cookies to remember an anonymous user's submission of a Webform and redirect them to the completion page if they tried to visit the Webform again:

    <?php
    define('REQUEST_TIME', $_SERVER['REQUEST_TIME']);

    function _mymodule_manage_cookie($nid, $type = 'my_cookie_type') {
      $matches = (bool) $nid == variable_get("mymodule_{$type}_webform_nid", FALSE);
      if (empty($_COOKIE["Drupal_visitor_mymodule_{$type}_submitted"]) && $matches) {
        mymodule_cookie_save(array("mymodule_{$type}_submitted" => TRUE));
      }
    }

    /**
     * Drupal 7 yoink!
     */
    function mymodule_cookie_save(array $values) {
      foreach ($values as $field => $value) {
        // Set cookie for 365 days.
        setrawcookie('Drupal.visitor.' . $field, rawurlencode($value), REQUEST_TIME + 31536000, '/');
      }
    }

    function mymodule_cookie_delete($cookie_name) {
      setrawcookie('Drupal.visitor.' . $cookie_name, '', REQUEST_TIME - 3600, '/');
    }
    ?>

You need to put this in a module or in template.php in your theme. You can conditionally include the code in a manner similar to the following:

template.php

    <?php
    function THEMENAME_preprocess_page(&$variables) {
      // THEMENAME_get_first_visit_cookie() would refer to a function
      // you have to write that retrieves if the cookie
      // is set. You could alternatively try just using
      // $_COOKIE['my_cookie_type'].
      if (THEMENAME_get_first_visit_cookie()) {
        $variables['first_visit'] = TRUE;
      }
    }
    ?>

page.tpl.php

    (skip to wherever you want to embed the code)
    <?php if ($first_viist): ?>
      // Paste your code here
    <?php endif; ?>

Now, one more point. The way I just showed you isn't the best way. You should add your Javascript properly using drupal_add_js() in a module or by adding a separate Javascript file in the theme that reacts to a class on the <body> tag and displays your first visit message (or whatever you're doing). You would still need the $first_visit variable to determine whether to add the class or not.


Switching file system from private to public makes all inline image paths broken

There's no miracle for that, you've to replace all path in the database. Fortunately MySQL has a replace function that will be useful for you.

First, you've to find every table/field that can contain inline image, if you're using Drupal 6, you'll look at node and node_revision for Drupal 7 it's more something like field_data_body and field_revision_body.

And finally you have to apply this query (for Drupal 7)

UPDATE field_data_body SET body_value = REPLACE(body_value, 'system/files/', 'files/');

Perhaps you should customize a query a little, but the main idea is there.


Scanner module triggers call to node.admin.inc (require_once(), trying wrong path)

Turns out to be a conflict with Administration Views (7.x-1.0-alpha1).

Disable admin views & functionality is restored. Not sure where the blame is yet because I haven't pinpointed the conflict. But it does make sense at face value because admin views replaces the /admin/content and scanner is located at admin/content/scanner


Uploading my Drupal Comerce Files to My Web Host

You can use File Transfer tools like WinSCP, FileZilla to transfer you files in your webhost. Then you need to export your database in your local then import in your webhost database. If you have some special configuration like path you may need to update that in your webhost.

Create a database creds in your webhost.

Export you local database and import it on webhost.

Upload your Drupal files

Update your settings.php to change the database information.
....


How can I create a View utilizing the Access Log hits (Hits in last 4 weeks)

Maybe the visitors module might be a valid alternative to consider? Refer to its community docu for some more details.

Be aware: I'm the new maintainer of this module, it was unsupported until recently ...


Help with JQuery Toggle Div, Start in Hidden State

Try this - In your loop, where you are iterating over each element to attach a click event handler, add this line:

$(this).hide();

That should hide each element. But don't add it to your click event handler. You can also initially hide the element using CSS if you want. Either method should work.

Please consider properly formatting code samples you post so that the community can read and understand it easier.

Good Luck!


Locked myself out after enabling misconfigured Google Authenticator

I post this as an answer, because someone might be as stupid as I am :)
I browsed various old backups and found the settings.php line that grants admin permissions to anonymous user, and it worked.
If you add:
$config['user.role.anonymous']['is_admin'] = 'true';

in your settings.php, every anonymous user is admin. That way I could get back into admin panel and uninstall TFA and Google Authenticator. Deleted the line, logged back in as user1 and installed both modules again.
Handy way to do it, if you don't have drush. But not recommended for production sites obviously.


I'm not familiar with the One-Click Upload module, but you might want to check the file_usage table after adding an image to see if it's recording a usage. If it's not recording a usage, it's being deleted because on cron run, Drupal automatically deletes files from file_managed that don't have a usage recorded in file_usage.

Drupal does not detect linking from entities other than the one(s) on which a usage was originally recorded. For example, if you added a link to an image in the markup of node 5, but the image was uploaded as an attachment on node 3, the image will disappear when node 3 is deleted, and node 5 will show a broken link.

If this is your problem, you could solve it by using the File Lock module to add file usages so they aren't deleted, or you could switch to the Media module, and apply this patch that has been committed to the latest dev (and that I personally wrote some tests for) to ensure that a usage is being recorded for files uploaded via WYSIWYG.


How do I create a configuration sync folder?

To generate a new config folder do the following:

In settings.php add the following line:

$config_directories['sync'] = 'dest/to/config-sync';

This is relative to your docroot or index.php file.  My permission were set in a way that drupal could create this directory but you may have to create your own.  Next you will want to populate your sync directory with active config. Run

drush cex -y

Now your active config can be version controlled and deployed to your other environments. Remember to make a database backup first before importing config.


How to make view to group by only one field?

I had the same problem.
Try to implement the group by in hook_views_pre_execute, it's work for me.

function MYMODULE_views_pre_execute(&$view){
  if ($view->name == 'YOUR_VIEWS' &&  $view->current_display == 'SOME_DISPLAY') {
    $view->build_info['query']->groupBy('node.nid');
  }
}

If you are using a pager, updating $view->build_info['count_query'] with the same changes should keep the pager consistent with the query results.


How to determine if the current Drupal page is a contact page?

Have you tried

\Drupal::routeMatch()->getParameter('contact_form');

This returns an object of type ContactForm when the user is on a contact page. A simple detection you can do with getRouteName():

if ('entity.contact_form.canonical' === \Drupal::routeMatch()->getRouteName()) {
  // huhu, a contact form
}

You can have a look at ./core/modules/contact/contact.routing.yml. There are all routes available.


Use Subdomains as variable with Domain Access

I did this by installing Domain Access module. When skimming Domain Access module's documentation before, it seemed extremely complicated. However, the documentation is geared towards you learning all about how it works. The actual steps to install are more than a regular module, but not too complicated.

It allows me to restrict content to a specific domain and to have different site names for each domain.


If you are using Omega theme version 7.x-3.1, you can go to the templates folder and edit region--content.tpl.php. In line 12 you will find the following:

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

You can comment this line out, or delete it.


During insertion of the field in the drupal view, there is image contained text but text is displaying not in image

It might be field settings issue.. Make sure your field has "full_html" format also,

Make sure formatter is default in view field settings..

Make sure Rewriting results has not been enabled..


How to attach a library to a specific block

It sure looks like you are on the right track to me. I've used the same approach myself. See: https://github.com/vegantriathlete/presentation/blob/master/templates/node--slide--full.html.twig

Have you cleared the cache? Maybe the theme registry needs to be updated to reflect the template you are using.

Have you viewed the page source of the page when that block is visible to see if the javascript is being included? Maybe the javascript is being attached and you've got a bug in your main.js. You aren't following the pattern of how to attach javascript. see: https://www.drupal.org/docs/8/api/javascript-api/javascript-api-overview


How to use Views Excel Export or Views data export to export a filtered table?

I just used Views Data Export module for a Drupal 7 project.

Create a view with the configuration you require (exposed filters, etc.).
Add a new display to your view of the type "data export". (As you duplicate your display the filters should inherit, but otherwise, you just want the "main" view and the "data export" view configured the same.)
In the "Page Settings" of the "data export" view display, give it a unique path (This is true even for tabbed items like admin views linked in admin menus).
In the "Page Settings" of the "main" view display, attach the "data export" display (This will provide a little CSV link at the bottom of your view).
Under the "Format" settings for your view, make sure you select CSV. Then edit settings and check the box for "download as file" or whatever it is.

Now, clicking on that CSV icon that appears at the bottom of your view page/block will export a CSV file that will inherit the filtered table. Just ensure the exposed filters match in each display.


alter the 26 (A-Z) parent links so that just the menu link text is displayed without its associated hyperlink

special menu items:

Special menu items is a Drupal module that provides placeholder and separator menu items.

A placeholder is a menu item which is not a link. It is useful with dynamic drop down menus where we want to have a parent menu item which is not linking to a page but just acting as a parent grouping some menu items below it.

https://drupal.org/project/special_menu_items


Can a drupal admin user get FTP rights to a godaddy server

I don't use Drush. But using the install module function at admin/modules/install I have installed modules before when live on a GoDaddy server.

I don't know what is causing the problem, I would maybe contact their support. But certainly it's doable, and I've done it in the past.

However depending on the module I would stay clear of installing on a live server, particularly if you are on shared hosting environment with GoDaddy (contrary to a lot of people I actually find them okay and the best solution at that price for hosting a site).

However whilst you'll find installing modules okay you may find you run into problems enabling them with PHP memory limits, or other server issues. Generally doing dev on a local machine if you have hosting like GoDaddy is going to be faster, more flexible, and generally easier.


How to get the row added by ajax in the right place?

I finally made it work this way:
  public function ajaxAddRow(array &$form, FormStateInterface $form_state)
  {
    $myKey = $form_state->getTriggeringElement()['#name'];
    $formBis = [];
    foreach ($form as $key => $value) {
      switch ($key) {
        case 'subscriptions':
          foreach ($form['subscriptions'] as $key2 => $value2) {
            $formBis['subscriptions'][$key2] = $form['subscriptions'][$key2];
            if (is_numeric($key2)) {
              if ($key2 == $myKey) {           << Here is the row to be copied
                $keyfornewrow = $key2 + 5;
                $formBis['subscriptions'][$keyfornewrow] = $form['subscriptions'][$key2];
                foreach ($formBis['subscriptions'][$keyfornewrow] as $key3 => $value3) {
                    << some code here to initialize content of copied row >>
                }
              }
            }
          }
          break;
        default:
          $formBis[$key] = $form[$key];
      }
    }
    return $formBis;
  }


Multiple image sizes from one uploaded image?

This is the function that I was looking for:

image_style_url($style_name, $path)

More info here.

(Should have done a little more digging via Google before I asked!)


ctools_get_plugins() isn't a function defined in a module file, but in the includes/plugin.inc file in the directory containing the Chaos tools module.
It's not the module that isn't loaded. It's the module that is calling the function that should first load the file containing that function, for example adding the following line before the function call.
ctools_include('plugins');

This is the solution used, for example, in ctools_get_plugins() is called without including plugins.inc.
What you can do is checking the issue queue for the module that is causing that error, and see if the issue has been already reported and fixed. If it's so, you should update the module and use that release.
For what I can see, the CourseObject::access() method of the Course module does include the file before the function, and so do other methods in that file, which is the only file using ctools_get_plugins() in the Course module. (I did check with git grep --fixed-strings 'ctools_get_plugins' in the directory containing a copy of the 7.x-2.x branch.)
Probably the module causing the issue is another one.


I believe this is due to the issue reported here: https://www.drupal.org/project/drupal/issues/2010132. See the patch in comment #107 for a patch.

I've confirmed that the patch applies to the current Drupal 8.4 branch, the tests pass, and the aliases get generated as expected.


You use different theme hooks page and menu.

If you want to use the variable in

menu--main.html.twig

use

function mytheme_preprocess_menu(&$variables) {


Hide the actual location of a node on Views with GMap Module

Resolved the issue by adding a marker in a circle format, setting maxzoom and clearing all cache.


User page tab with node edit, file upload image widget not working

Ok i found solution:

If your node form has a file upload widget, you should add this code to hook_menu.

'file path' => drupal_get_path('module', 'node'),
'file' => 'node.pages.inc',


There's no concept of a "sub-queue", it's just queues, items in the queue, and workers of a queue (on items). Without knowing more about your use case I'd say you should may want to have a queue per account. Or create a queue item containing the account its for and working that way. So, you can either have many queues with some items in each or one queue with a whole bunch of items.


Error in validation of managed_file field with Form API

There's a bug in the way system_settings_form() handles managed_file types. It's to do with the upload/remove buttons and parent elements (if you read the whole issue you hould get a good take on what's going on).

I don't know if it's the same error as I was having, but adding code like the following to the top of the form's submit handler fixed it for me:

foreach($form_state['buttons'] as $delta => &$button) {
  if (preg_match('/module_top_content_equipe_image_(upload|remove)_button/i', $button['#name'])) {
      $button['#parents'] = array();
    }
  }

Not ideal by any means, but it does work.

On another note, the #process property attached to the managed_file item is unnecessary. That code should be run in the form's submit handler, and since your submit handler is named in the right convention it will be run when the form is submitted, which is when you need it to.

Try removing the #process line altogether and see what happens.


Views Conditional Fields According to Devices

As of now, I don't think views supports this. But you can use the Mobile Detect  module to achieve this. Note: you need to download the mobile detect library as well and place it in the module folder as specified in ReadMe.txt
Then you can use either of the below preprocess functions to detect the device and then return your output to the views template.

template_preprocess_views_view
template_preprocess_views_view_fields

Hope this helps.


Its not done simple, by default quicktabs ordered by wieght,
Quicktabs has quickly become one of my favorite Drupal modules of all time. To think that I was actually wasting time creating tabs by using jQuery plugins, and writing custom AJAX. Creating tabbed content is one of the most popular techniques used on the web today, and with Quicktabs it has never been easier to add tabs to your Drupal site - even with AJAX!

First you'll want to install Quicktabs

Once you have Quicktabs installed, there are a couple of ways to generate tabs. You can do it through the Drupal interface, or you can do it programmatically, but first, make sure you have some content that you want to show in tabs! Quicktabs works with your existing content. You can tab between views, blocks, nodes, or a mixture of these.

For this demo, we'll use Views and set up 2 displays filtered by a certain taxonomy term. We will then create a tab that displays nodes of each taxonomy term respectively. Make sure you have some taxonomy terms to choose from for each post. Then you'll want to create a view called "my_listing", or whatever makes sense for you.

Once you have created your View, create a couple of different "page" displays. Name each display according to your taxonomy term, so if you want to tab between say "Development" and "Theming" nodes, each page display will be named respectively.

Since you're creating page views, you'll have to specify a URL for each under the Page Settings section. You can use something like "list/development" and "list/theming" respectively. This is required by page displays, but it is also good if a user for some reason does not have javascript enabled, they will still be able to see the listings, just not through AJAX.

Also, for simplicity, make "Row style" node, so we don't have to play with fields.

Under "Filters" filter on each display for that specific taxonomy term, so that each display is only displaying nodes of whichever taxonomy you choose. Save the view.

Now that you have some content to play with it's time to create some tabs. Browse to admin/build/quicktabs and click on the "New QT block tab".

By default, Quicktabs creates a block for you which you can then place anywhere in the site like a regular block, but there is also a way to output your quicktabs in code, which i'll show you further down.

In the Block Title field, give your block a meaningful title. Next is the style dropdown, where you can select between various styles of tabs. You can also select "no style" so you can theme them your own way

The next field allows you to select whether or not you want your tabs to be AJAX. In most cases you will want to use AJAX so that you only load the second view when the user requests it.

The "Hide empty tabs" will only work if you do NOT use AJAX, which is kind of unfortunate. But, an easy way to deal with this is to use the "empty text" area in your views to give the user a friendly "There is no content here" message.

The next section is where you will start creating your tabs

Let's say the view you created with the 2 page displays are for a taxonomy term "Development" and one for "Theming". Give each tab their respective title. For the Tab type, select "view". In the tab content section, select the view you created (my_listing). Then select the display you want to show. For the Development tab, show the display that filters on Development. For the Theming tab, show the display that filters on Theming. You can also pass arguments into your Quicktabs to use with Views that accept arguments which is really cool, but I won't be covering that here.

Click save. You now have a block available for you to place anywhere on your site, that will tab between nodes of each taxonomy term! Very cool! But, what if you dont' want to use a block...what if you want a bit more control to place these tabs wherever you want? It's easy.

On your tabs listing page (admin/build/quicktabs) hover over the 'edit' link and take note of your quicktabs ID in the url. (quicktabs/1/edit). If this is your first quicktab, the ID will be 1.

Now to print out your quicktabs, all you need to do is call this function and run it through theme("quicktabs"); like this:

$tabs = quicktabs_load(1); // where 1 is your quicktabs id
$mytabs = theme("quicktabs", $tabs);

return theme("my_custom_template", $mytabs);

Then in your custom template, just print out the mytabs variable and you should see your quicktabs!


CTools modal return incorrectly return html instead of ajax commands

Turns out the offending part is not the logic, but the function name. The my_module_user_login_form function happens to be a invoke hook form, which interferes with the modal.

Changing the function name solved the problems.


What is the best way to put comments section to user profile

If you use Profile2, this creates profiles as node type entities so you can turn comments on as each profile will have settings similar to that when you create content types.


Slow page loads - unable to determine the cause

If a 304 is taking 5+ seconds that means you webserver (most likely Apache) is being very slow. The ONLY other thing that could be causing this is if you have Far-Future enabled with the CDN module (and that's a stretch). Aggregating should help, as this will reduce the # of requests hitting Apache.

What web server are you using? Also noticed that Clean-URLs is disabled so I would bet that the webserver needs to be configured.


How to apply theme to Drupal view or block

Go to your view display and look at the bottom of the "advanced" column. You'll see something like "Theme : Information". Try to locate your template name and click on it to get it's base code.


Adding an external image to a views output

I've come to the conclusion that I believe the best/easiest way to do this is by adding another field to my content type, and inserting the associated image in that field. Even though I've created a field in that content type that is only required for one piece of content.


Modify price components from Commerce Shipping without altering the module itself

If I get you correctly, you want to alter the order in where this components are displayed in the checkout process.

What I've done for minor tweaks on this area is using a preprocess of the components theme function, for example:

function mymodule_preprocess_commerce_price_formatted_components(&$variables) {
}

There you've got $variables and all the components, including the shipping ones so you can tweak some things of the display.


May be you are looking for language_negotiation_get_switch_links

  Return the language switch links for the given language.

$path = drupal_is_front_page() ? '<front>' : $_GET['q'];
$links = language_negotiation_get_switch_links($type, $path);


Faceted search show tid instead of taxonomy name

You need to check "Translate entity label" option to see the name.

By editing Tag facet block you can see that option.

If you have still same issue.

You need to install Core Views Facets module.
Then select Facet source.

View Search content, display Page

Added One example o/p screenshot.


Can't access global user object after drupal_bootstrap

The solution was a one line fix:

define('DRUPAL_ROOT', '../../../../../');
$base_url = 'http://' . $_SERVER['HTTP_HOST'];
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

Note the addition of $base_url


Theme a Panelized Content Type Not Working

I figured out what I was doing wrong.

In my content type, under Panelizer > Full Page Override > Content I had to add "Rendered Node" to the main content area. This allowed me to use the node--my-typename.tpl.php file to theme this panelized content type.


Can I clear cache only for particular domain / URL?

With just core this is not possible. If you where to write your own cache backend then what you're asking for could be done. An example of a custom cache backend is http://drupal.org/project/adbc


Fill filter between (min, max) field programmatically drupal

If the comments starting from the publication of the node are valid, you do not need a start date.  You only need to make sure you load all comments for that single node and an end date.

Since your view lists comments, I suggest you start by adding a contextual filter for the Comment: nid. This limits all the comments to those on that specific node only. For this to work in your use case, you need to update views_embed_view to also send the node id along (all parameters after the second parameter are sent as arguments (contextual filters)):

views_embed_view('contest_winners_one', 'block', $nid);

Now the results are limited to those on this node only, you need to compare the post date. If the To date is formatted properly (Drupal supports multiple date formats and out of my head I do not know the right one, but my guess is that the date needs to be stored as a timestamp), you can do a field comparison.

For this you have to add the fields to compare to the Fields section of the View (if there is no option to add fields, you can force enable in the dialog you get when clicking settings behind Format. These are the Comment: creation date and the Content: To date fields. Display format does not matter and you can select Exclude from display.

Then in the Filter section add the Field comparison filter. Then make sure the comment date is smaller or equal to the to date.

If you fail to get the contextual filter working, you can also use this approach for the content creation date and the comment creation date, but without node filtering, comments would get mixed up if two contests run at the same time.

Additionally you can probably use Rules and the Rules scheduler sub-module to disable comments on the node once the to date is reached. Refer to How do I create a rule that closes comments on node after 30 days? for reference on how to achieve this. If the comments are closed on the correct date, you can safely show all comments as they could only have been created in the defined period. (You wouldn't need any filtering)


there is no edit option on certain views of drupal site

There is a "Hide contextual links" setting in views to turn contextual links on and off.

Set "Hide contextual links" to "No" as per this screenshot:


How to change the Front page for the Commerce Kickstart distribution?

It looks like this preprocess function needs to be changed in the parent theme.

In this case it can be found in the /profiles/commerce_kickstart/themes/omega_kickstart/preprocess folder.


How to add a subtitle field to a block view?

The easiest solution is to add a Global: Text area in the HEADER and type your Subtitle there.

You can use FULL HTML and wrap it in a div class or ID so you can do some CSS work on it.

  Can i add additional fields just like with custom blocks?

You can add fields to your view

or attach another view that contains fields in the FOOTER, but fields in views and fields in custom blocks are totally different.


The easiest way is to use $argument = arg(2) but more formal and much better way will be to create new menu item based on node/%node:

function yourModule_menu() {
  $items['node/%node/%'] = array(
    'page arguments' = array(1, 2), // Here you can specify which parts of url are page callback arguments (starting with 0)
    'page callback' = 'yourModule_node_with_option',
    'access arguments' => array('content access'), // Try to avoid access callback = TRUE
    'type' => MENU_CALLBACK,
  );
  return $items;
}

function yourModule_node_with_option($node, $option) {
  // build your new page here.

  // $option is your extra parameter.
  $output = $node->nid . ' ' . check_plain($option);

  // This will show you node id and value of parameter
  return $output;
}


You would be better off using jQuery:

(function($) {
  $(function() {
    // Grab the element with both group_left and article_left class and set an ID attribute.
    $('.group_left.article_left').attr('id', 'pad_id');
  });
})(jQuery);

It's worth checking that the element with both of those classes is unique on the page, if the same ID is added to more than one element then the document will become invalid and you might have problems with other javascript.


If you don't mind my saying you're doing this the hard way. Drupal has a managed_file element type that handles most of this logic for you:

function mymodule_custom_content_block_form($form, &$form_state) {
  $form['custom_content_block_image'] = array(
    '#type' => 'managed_file',
    '#name' => 'custom_content_block_image',
    '#title' => t('Block image'),
    '#size' => 40,
    '#description' => t("Image should be less than 400 pixels wide and in JPG format."),
    '#upload_location' => 'public://'
  );

  return $form;
}

function mymodule_custom_content_block_form_submit($form, &$form_state) {
  if (isset($form_state['values']['custom_content_block_image'])) {
    $file = file_load($form_state['values']['custom_content_block_image']);

    $file->status = FILE_STATUS_PERMANENT;

    file_save($file);
  }
}


You can use a #pre_render function on that field to unset the values and add an empty option on the 3 select boxes.

$form['start_date'] = array(
    '#type' => 'date',
    '#title' => t('Date'),
    '#description' => t('Your field description ...'),
    '#required' => true,
    '#pre_render' => array('_YOUR_MODULE_form_pre_render_date'),
);

function _YOUR_MODULE_form_pre_render_date(&$element)
{
    // Don't put empty values if a date has already been set
    if (date('Ynj') !== implode('', array_values($element['#default_value']))) {
        return $element;
    }

    // Loop through each field, add empty option and unset value
    foreach (array('year', 'month', 'day') as $field) {
        if (!isset($element[$field])) {
            continue;
        }

        unset($element[$field]['#value']);
        $element[$field]['#default_value'] = '0';
        $element[$field]['#options'] = array(
            '0' => '',
        ) + $element[$field]['#options'];
    }

    return $element;
}


You probably need the module https://www.drupal.org/project/allowed_formats.

  Limit which text formats are available for each field instance.


When I click a radio button its value should display in textfield

You should use drupal ajax form
 try this code

function test_radio_form($form, &$form_submit){

/* the options to display in our form radio buttons */
$options = array(
  'one' => t('One'),
   'two' => t('Two'),
);

$form['count'] = array(
  '#title' => t('Count'),
  '#type' => 'radios',
  '#options' => $options,
  '#ajax' => array(
            'callback' => 'myid_print_all_submitted_id_callback',
            'wrapper' => 'myid_print_search_idnumber_wrapper',
  ),

);

$form['display'] = array(
'#title' => t('Display'),
'#type' => 'textfield',
'#value' => isset($form_state['values']['count']) ? $form_state['values']['count'] : '',
'#prefix' => '
',
'#suffix' => '
',
  );

$form['submit'] = array(
'#value' => t('PROCEED'),
'#type' => 'submit',
  );

return $form;
}
function myid_print_all_submitted_id_callback($form, $form_state)
{
      return $form['display'];
}


Assuming you have your web server (Apache, etc) pointing both sites correctly to your docroot, then Drupal will automatically route requests to the correct folder (and settings file) for each domain.

If you want to have it ignore the default folder and its settings.php file, you can delete the existing "default/" folder and create a symbolic link to one of your other two sites. For example:

ln -s alumni.something.edu default

and all requests to your docroot that don't match a domain in your multisites folder will be sent to alumni.something.edu (or whatever you prefer).


How to create path for taxonomy term pages with parent terms if they exist

You can use pathauto token like this.

 [term:vocabulary]/[term:parents:join-path]/[term:name]


Multi-value form widget in a system settings form

You won't be able to use the multi-value functionality used in the Field API in your custom forms.

However, with the Form API and Ajax you should be able to create dynamic form fields. See Ajax Example in the Examples for Developers project. What you want to achieve here is relatively similar to Generate textfields and Generate checkboxes examples, where fields are being added to the form on-the-fly.

<?php
/**
 * Form manipulation through AJAX.
 */
function ajax_example_autocheckboxes($form, &$form_state) {

  // Since the form builder is called after every AJAX request, we rebuild
  // the form based on $form_state.
  $num_checkboxes = !empty($form_state['values']['howmany_select']) ? $form_state['values']['howmany_select'] : 1;

  $form['howmany_select'] = array(
    '#title' => t('How many checkboxes do you want?'),
    '#type' => 'select',
    '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4),
    '#default_value' => $num_checkboxes,
    '#ajax' => array(
      'callback' => 'ajax_example_autocheckboxes_callback',
      'wrapper' => 'checkboxes-div',
      'effect' => 'slide',
    ),
  );

  ...

  for ($i = 1; $i <= $num_checkboxes; $i++) {
    $form['checkboxes_fieldset']["checkbox$i"] = array(
      '#type' => 'checkbox',
      '#title' => "Checkbox $i",
    );
  }

  ...

  return $form;
}

/**
 * Callback for autocheckboxes.
 *
 * @return array
 *   Renderable array (the checkboxes fieldset)
 */
function ajax_example_autocheckboxes_callback($form, $form_state) {
  return $form['checkboxes_fieldset'];
}

Another, quick solution that may work (or not) for your case is using an entity (e.g. a single node of a new content type) to store that configuration.


list all used & unused views in site or panels, as a site audit

I think this module might help you.

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

Module provides administrative page with detailed information about each display use cases and its status for each enabled view. It helps you to detect unused and broken displays to modify them or completely remove from your site.

Regards,

Oleg


What's the best way to create a content type with multiple fields that link to an external URL?

I usually set the fields to "hidden" under the "manage display" tab, and then print the fields however you like with a block view.

Just place that block view to appear on that content type only, and with a contextual filter to get content ID from URL.

You can also use the Title module to replace the title from the content type, which you can then hide and display in the same block view.


How do I reference an image inside my custom module directory?

The \Drupal class has many useful static functions such as moduleHandler. I recommend (for future issues) to first search there, then in the core.services.yml & system.services.yml files for a service or a method that could help.

\Drupal::moduleHandler()->getModule('foo')->getPath()


How to use multiple styles for Nice Menus?

Each Nice Menu can be addressed in CSS using its name. For example I have a Nice Menu called "Product Menu" and by looking at the html of my page I can see that my menu has the following classes

nice-menu
nice-menu-right
nice-menu-menu-product-menu
etc..

You can use the nice-menu class for all Nice Menus, the nice-menu-right class is the type of menu it is set as (Right, Left, etc.). You can also customize each menu individually by addressing it in CSS using the nice-menu-menu-MENU-NAME


You will need to add the following configuration in your settings.php file

$databases = array();
$databases['default']['default'] = array(
  // Drupal's default credentials here.
);
$databases['my_other_db']['default'] = array(
  // Your secondary database's credentials here.
);

Refer to settings.php for the array options.

Now if you are using a custom module you can use the following in  your module to switch between the 2 db's

// Use the database we set up earlier
db_set_active('my_other_db');

and if you want to move back to the default db

// Go back to the default database,
// Remember to go back to the drupal default version or drupal will not be able to access its data
db_set_active();

Also refer to https://drupal.org/node/18429 for more information.

There is one more of doing it if you do not want to do the db_set_Active() all the time.

So you define the connection in your settings.php like in the first step. Then in the module you can directly do the following

$query = Database::getConnection('default', 'my_other_db')
           ->select('source_table', 'st')
...


Add additional element to exposed view form?

Well then... apparently it's a weird lopsided solution that is necessary.  See comment #10 here http://drupal.org/node/893392.


Your code still shows radio instead of radios for '#type' attribute.

$form['paymentMethodSelect'] = array(
    '#type' => 'radios',
    '#title' => $this->t('How would you like to make payment?'),
    '#default_value' => 'eft',
    '#options' => [
        'eft' => 'EFT (Electronic Funds Transfer)',
        'cc' => 'Credit Card',
    ],
);

Otherwise there is no other problem I see in your code.
Sample code from D.O

$form['settings']['active'] = array(
  '#type' => 'radios',
  '#title' => $this->t('Poll status'),
  '#default_value' => 1,
  '#options' => array(0 => $this->t('Closed'), 1 => $this->t('Active')),
);


How to implement this event tracking to google analytics module

The GA Event Tracking module is designed to react to a number of different binded JS events. You're limited by what DOM events that jQuery can bind to. As such, there is no settimeout event.

One solution that comes to mind is adding some custom JS to the standard GA module. Go to configuration page under the Custom Javascript Code in the Advanced Settings fieldset. There you can add what custom JS needed to trigger your setTimeout GA event.


Updated an empty field collection in Drupal7

I believe you need to load and save the node to which the field collection is attached.

This question: Modifying a field collection programmatically missing hostEntity fields is slightly different but the examples are accomplishing the same thing.


Drupal 7 webform Version: 7.x-4.5 not sending email

If you want to make token [current-page:node:author:mail] working, you need to apply this Token module patch.

Source.


How to email individual content to email field?

If you're looking for existing module to base a solution on. The Print module has a Send by email submodule that supplies a form (/printmail/node/NID) that you can tweak for sending out emails and capturing the supplied emails.

/**
 * Implements hook_form_print_mail_form_alter().
 */
function MYMODULE_form_print_mail_form_alter(&$form, &$form_state, $form_id) {
  // Add a custom submission handler for your functionality.
  $form['#submit'][] = 'MYMODULE_form_print_mail_form_submit';
}

function MYMODULE_form_print_mail_form_submit($form, &$form_state) {
  // @TODO: process $form_state['values']['txt_to']['addrs'] for email addresses to store.
  // Use $form_state['values']['path'] to the load relevant node & save data to its fields.
}


As for this issue commited on November '11, you should be able to close any CTools modal window with a link that has the class "ctools-close-modal"

For example, in my modal I've got this for element to cancel and close:

  $form['actions']['cancel'] = array(
    '#markup' => l(t('Cancel'), '#',
       array(
         'attributes' => array(
           'class' => 'ctools-close-modal'
          ),
         'external' => TRUE
       )
     )
  );


hook_library() is thought only for Javascript and CSS files; for PHP libraries, you should consider the Library API module.

  This module introduces a common repository for libraries in sites/all/libraries resp. sites//libraries for contributed modules.

  External libraries

  Denotes libraries ("plugins") that are neither shipped nor packaged with a project on drupal.org. We do not want to host third-party libraries on drupal.org for a multitude of reasons, starting with licensing, proceeding to different release cycles, and not necessarily ending with fatal errors due to conflicts of having the same library installed in multiple versions.
  Drupal 7 only has built-in support for non-external libraries via hook_library(). But it is only suitable for drupal.org projects that bundle their own library; i.e., the module author is the creator and vendor of the library. Libraries API should be used for externally developed and distributed libraries. A simple example would be a third-party jQuery plugin.

The Library API module implements an API that can be used from third-party modules to load libraries installed on a Drupal site; the pro of using Library API is that it handles dependencies between libraries, and versioning.


You can use EVA module. With that it is possible to have a views block as a field in DS.


It is a permissions problem. You will be able to install the module by downloading it and putting it into your sites/all/modules folder


Rendering a region fo a theme programmatically

Using the block.repository service you can get an instance of the BlockRepository class.
You can then call the getVisibleBlocksPerRegion method on it which will return an associative array BlockInterface[][] (first key is the region name, second key is the block ID).

You will probably need to change the active context if some of these blocks only appear certain conditions.


Well, I could not find a way to make the grouped filter work for me. The solution I found was to use the Better Exposed Filters module. It is quite easy to configure. It worked smoothly for me.


For Drupal 6, these are the only two options I know of, either use content_profile and use aditional nodes or stick with what profile.module can do.

In Drupal 7 however, users are fieldable, which means that you can attach any field that you can attach to nodes too. Additionally, there is the http://drupal.org/project/profile2 project, which provides something similar to content_profile. However, profiles are in that case not nodes but a custom entity.


Add additional fields to the postal address

I'm pretty sure there is a configuration in the field settings. If not in there I'd look at the module's config screen.


Complex View Involving Separate Entities / Taxonomy Vocabulary / Content - Distinct

You can cheat a little and use Views Limit Grouping to help do this.

I created a view of smart phones with the path being smart-phones/%/colors. The only argument I need is for the OS. Add a contextual filter for the mobile OS using "Content: Has taxonomy term ID", filter by the term name. Under your fields to be shown, just select the color.

Using the Group Field (with Limit) formatter, we'll group by the color and show 0 items. Now if there are smart phones that have a color selected, it should show up in this list. In my screenshot you can see that I am only showing Blue and Orange, but in my taxonomy I actually have Blue, Green, Orange, and Red available - but I have no phones that are Red or Green.

From here, all you need to do is rewrite the color url to go to whatever other view you would like, such as smart-phones/%OS/%Color


Enabling a block to inherit the settings of a sub theme

You can style a block however you like - since it is going in the header, it sounds like a css issue for the header region. I would start by comparing the css for the content and/or footer regions with that of the header.  If all else fails, you can theme individual blocks - here is some info.


Moving site from one environment to another

Check your settings.local.php (or settings.php if you don't have one) for 'install_profile' and make sure this is set and matches your staging environment:

https://github.com/drupal/drupal/blob/2e8b29651cfb08309098c239ce9d03e724d747b3/sites/default/default.settings.php#L279

If that doesn't work you can take a look at https://www.drupal.org/node/2870028 as @jaypan said


how to show views for particular language

Have you tried to use filters? When you create your view, you add a new filter and select "Node translation" from the "Groupes" list and the check "Node translation: Language" and click "Add". Then you can chose language(s) on which you want the view to show


What determines which fields are available in the relationship options?

One thing that affects the choice of the fields that are available is the show box when you first create the view this allows the developer to refine the criteria that is being chosen.


Vertical tabs of form fieldsets taking a long time to load

I'm almost 100% certain this problem is related to slow-loading javascript; As Mołot mentioned in his comment on the question, you should investigate whether something is holding up the JS from loading and/or processing when the page loads, using browser tools.

There might be some other JS that's being added on the page that's blocking the vertical tabs JS from loading/running. Do you have any 3rd-party (Facebook, Google, Twitter, analytics, etc.) libraries loaded on the page? There are some good tips for getting these things to not block the rest of the page load here: Non-Blocking Loading Of 3rd Party Scripts In Drupal.

Otherwise, do you have a module enabled or some custom code that's hindering/slowing the progress of the page load on that form? This is less likely, but sometimes if a module does something that requires a lot of CPU time (like looping through an entire taxonomy tree to build a form element or do something fancy to it) either with PHP or JS, that can cause the page load to take a really long time.

Vertical tab rendering (as well as fieldset collapsibility rendering) is usually one of the last things to load when a page loads. Something is blocking the page load/render progress, and if you can figure out what that is, you'll find the source of the problem. Good luck!


Editing order confirmation email in Drupal 7 Commerce

I the end, I had to install the Mime Mail module. My site uses gmail for the site's email, so I had to use Mime Mail together with SMTP module.

The emails render html tags and tokens as needed.

For someone who might experience the similar issue, here is how I configured the Mime Mail witih SMTP:

In admin/config/system/mailsystem scroll down to the "New Class" fieldset. Create a new class using MimeMailSystem for format() and SmtpMailSystem for mail(). Use that newly created class for the "Site-wide default MailSystemInterface class.

I'm still not completely satisfied with this solution as I was hoping to make Commerce Message to work. If someone ever gets to respond to this I would be thankful for the answer.


Yes, on the linked page you would find Node::load() to get a pre-existing node:

$node    = \Drupal\node\Entity\Node::load($nid);
$content = \Drupal::service('entity.form_builder')->getForm($node);

return $content;


Your entity query works fine (without aggregate). dpm() doesn't work in D8 for content entities, try kint() instead, but that will also be misleading.

Your last attempt was almost correct: ->value is a property (a magic property, actually), not a method. So this should work fine:

$holidayType->field_activityid->value

As referenced already in a few questions, have a look at http://wizzlern.nl/drupal/drupal-8-entity-cheat-sheet; it's a bit old but it's still a great overview of the Content Entity (Field) API.

If you do want to use dpm()/kint(), then always run it on $entity->toArray(). That will give you an array structure of the fields, you can translate that 1:1 to object properties and it will work fine. For deltas, use $holidayType->field_activityid[1]->value; not providing it defaults to delta 0.

And, no, you definitely don't want an aggregate query. You need that if you want to COUNT() or SUM() some values of your entities.


how do i create a new link in node.tpl.php by preprocess function in drupal?

This line will always return true, since you are assigning a value with the '=' operator:

if($variables['type']="product"){

This should be a comparison, so use '==':

if($variables['type']=="product"){


How to display number of posts in author pane?

it appears you need another module that will feed this info to author pane. This module is User stats.

Apparently though User stats has only a development release for D7 and reading through this issue, I would be reluctant to implement it on a production site. Will keep you updated if I find a better way to deal with this.

Edit: I've tested the 'post count' functionality of the 7.x-1.x-dev version of User stats and it seems to be working fine.


Views relatonship with multi value field - and views distinct

use group-by class so it will show you unique class name with teachers for the class


You need to right click and inspect the elements and find the div class or id that belongs to those blocks or fields.

Then with CSS you can center them. See CENTERING THINGS. So just add the css to your theme's style.css file, located in /sites/all/themes/yourtheme/ folder.

Then remember to flush the cache to see the changes.

If you want to do it within Views using REWRITE RESULTS

put <center>[title]</center>


How to change the pagination of related entities displayed on a taxonomy term page?

The taxonomy module uses the default_nodes_main variable to decide how many to show per page (this happens around line 55 of taxonomy.pages.inc in case you're interested).

Usually you would implement a custom module and provide a form to override that variable for your users. But you don't have to do that, if you just want to set the variable once and be done with it use one of the following methods instead:

Use Drush (drush vset default_nodes_main 20)
Add a PHP snippet somewhere that will be run in your site (you only need to do it once)

variable_set('default_nodes_main', 20);

Use the Devel variable editor


Looks like a classic "off-by-one" error. You should make sure that you are storing all date stamps in the UTC format.

Read the section on "Converting to and from UTC" here:
https://www.drupal.org/node/291799

If the date/time field is storing the German time (UTC+1h) then it will end up adding another +1h when it localizes the time, and you'll end up one hour ahead.

"There are two hard things in computer science: cache invalidation, naming things, and off-by-one errors."

UPDATE: As you say in your comment below, you can get the desired result by simply subtracting 1h from each datestamp in order to convert from Berlin time to UTC.

However, this approach will only work if you are certain that the time field in the import file will always contain UTC+1 times.

If you ever need to import files that could be in different time zones, you'll need to follow the API.

To convert a local date back to UTC to store it in the database, do:

$date = // local date value
$local_zone = // the name of the local timezone, e.g., 'Europe/Berlin'
$type = // the type of date value, DATE_DATETIME, DATE_ISO, or DATE_UNIX

$date = date_make_date($date, $local_zone, $type);
date_timezone_set($date, timezone_open('UTC'));

// $date now contains the UTC value of the date.
// Output it like:

print date_format_date($date, 'custom', 'm/d/Y H:i');

In order to generalize your database import, you would also need to include a field for the $local_zone for each timestamp.

It sounds like you will always be importing Berlin timestamps, but I just wanted to make sure that you understood the drawbacks to simply subtracting 1h from each timestamp rather than following the API.

Even if simply subtracting 1h works for you in this case, there is value to doing this the right way, in case you ever need to import a file from another timezone, or one with mixed timezones -- either in your current project, or a future one.