How to check that cron is reindex the complete site?

Go to admin/config/search/settings or Configuration > Search and the top of the page will tell you how much of the site has been indexed.

The button "re-index" will let you re-index the site and the status above it will still tell you how far along the indexing process is. By default, Drupal indexes the website during cron runs and the option below the "re-index" button lets you select how many nodes are indexed per cron run.


EventSubscriber called on specific node type or path

I managed to do it but I feel it could be done much better.

class eSubscriber implements EventSubscriberInterface {

  public static function getSubscribedEvents() {
    $events[KernelEvents::TERMINATE][] = ['onRespond',27];
    return $events;
  }

  public function onRespond(PostResponseEvent $event) {
    $node = \Drupal::routeMatch()->getParameter('node');
    $user = \Drupal::currentUser();
    $name = $user->getUsername();

    $output = [];
    if (isset($node) && isset($name)) {

      $nodeType = $node->getType();
      $soap_response = new classThatHandleRequests();
      $output = $soap_response -> get_clients_fv($name);
      echo('<script>var JSONarray = ' . print_r($output,1) . ';</script>');
    }
  }
}


How to include a juery ui file in drupal 7?

It should be drupal_add_library('system', 'ui.draggable');


Open Atrium: How to add an action button on a view node

I found the solution. First, some terminology: the links in the dropdown menu on the bottom right are called Contextual Tabs. Second, the buttons with an icon are called Extracted Tabs. These settings are found in two different locations.

First, make your menu item a regular context tab. Go to admin/openatrium/setting and open the Contextual Tabs fieldset. Fill in the link to your page/menu item:

Next, extract the Contextual Tab as a button. Go to admin/config/user-interface/contextual-tabs and fill in the link and/or the label to your page/menu item in the Tabs to extract textarea:

Your link will now be displayed as a button with an icon of your liking.


How to remove the webform title field on add/edit form?

If you don't mind installing another module:

Install Automatic Nodetitles
Go to admin/structure/types/manage/webform/auto_label
Select a default title and check "Automatically generate the label and hide the label field"
Profit!


Master Detail webform or connecting/linking two webforms

For those who come along with a similar issue - my solution here was to use the entityform and fieldcollection modues.  the fieldcollection module allow you to attached a group of sub fields to the entityfield, then you can add more of the subfields as needed.  Querying and views were also fairly easy to set up.


When should "'target' => 'slave'" be used in a query?

SELECT (read) queries can go to the slave, other such as UPDATE and DELETE (write) queries should go to master then propagate across to the slave database.

  Also, looking at Drupal core code, why is array('target' => 'slave') sometimes used, and sometimes no?

That's probably just historical / legacy reasons due to the nature of how the Drupal code base is gradually committed. Potentially any SELECT queries could target the slave database.


How to load a menu item and its children menu items?

Try these:

// Select the parent menu link with 49 id.
$menu_link_content_id = 49;
// Use the 'menu_link_content' entity storage.
$menu_content_storage = \Drupal::entityTypeManager()->getStorage('menu_link_content');
/** @var \Drupal\menu_link_content\MenuLinkContentInterface $menu_link_content */
// Fetch an entity with parent menu link.
$menu_link_content = current($menu_content_storage->loadByProperties(['id' => $menu_link_content_id]));
// Build a specific value for a parent property.
$parent_prop = "menu_link_content:{$menu_link_content->uuid()}";
// Load child menu items by 'parent' property.
$menu_link_content_childs = $menu_content_storage->loadByProperties(['parent' => $parent_prop]);


When entities are created, I had to do this to create them in the node table:

$manager = \Drupal::entityDefinitionUpdateManager();

if ($is_new) {
      // create the field definition for the node
      $storage_definition = BaseFieldDefinition::create('boolean')
        ->setLabel(t('!label', ['!label' => $label]))
        ->setDescription(t('!description', ['!description' => $description]))
        ->setRevisionable(TRUE)
        ->setTranslatable(TRUE)
        ->setDefaultValue(0)
        ->setDisplayConfigurable('form', TRUE);

      $manager->installFieldStorageDefinition($id, 'node', 'custom_pub', $storage_definition);
    } else {
      $storage_definition = $manager->getFieldStorageDefinition($id, 'node');

      if (isset($storage_definition)) {
        // update the label and description on the definition
        $storage_definition
          ->setLabel(t('!label', ['!label' => $label]))
          ->setDescription(t('!description', ['!description' => $description]));

        $manager->updateFieldStorageDefinition($storage_definition);
      }
    }


After doing some more research i've found an answer to my problem. The main reason for not finding a solution was, they don't want you to do this in Drupal 8.

From their documentation:

https://www.drupal.org/developing/api/8/assets#dynamic-css-js

  If the dynamic CSS/JS is built for each request, then you enter the truly advanced territory. This is hard, and for a good reason: per-request dynamic assets have to be built on every single request and therefore slow Drupal down. We want to make it hard to make Drupal slow down, so this is why we don't offer a nice API for this — since we don't want you to do it.

This makes sense and there is a short description how to get it to work anyway but its lacking of an example. This is what i've done to get it to work:

function my_module_page_attachments_alter(array &$page) {
  $background_color = '#000';
  $page['#attached']['html_head'][] = [
    [
      '#tag' => 'style',
      '#value' => '.my-custom-class { background: ' . $background_color . '; }',
    ],
    'my-custom-module'
  ];
}


In drupal 7 how to group fields of a view?

What about  making two separate versions of the view: 1 page view with title fields and an attachement with author fields, or 1 page with titles, and the other a block with authors?
So you first create a page view with a fields display. When adding fields, you select titles *and you make sure you set the field for "This page only".

Afterwards, on the top of the view, you select "add attachment".
You will have an attachment versin of the view. In this, you add the "title" field.
Again, make sure it's "for this attachment only". Now, go to "Attachment settings and select attach to page.


Delay in logging Drupal user through Services

This looks unrelated to drupal itself but it's more likely to be a glitch / misconfiguration in the web server/LAMPP settings or a DNS lookup issue.

Can you please let us know more about your LAMPP stack and OS?

Also consider trying the following:

Setting the ServerName property in httpd.conf ( ServerName
  127.0.0.1:80 )
If the above doesn't work, in your httpd.conf be sure to set the setting HostnameLookups Off
Enable slow query log in MySQL.
Have a look at this post https://serverfault.com/questions/66347/why-is-the-response-on-localhost-so-slow


What hook to alter the result of a view?

1- Firstly you need to add a relationship to the Person entity to have the fields available.

2- then use hook_views_query_alter() to change the fields values.


Routing custom module with alphabetic pagination

As I alluded to in my comment, you are close, I believe. Here are some changes to get you in the right direction which begins by extending ControllerBase:

class ZiektesController extends ControllerBase
{

  // set any scope/variables here

  public function __construct($args...) {
    // set your injected dependencies to local variables
  }

  public static function create($args...) {
    // here you inject dependencies you need
  }

  public function ziekte($letter) {
    return array(
     '#theme' => 'mytheme_ziektes',
     '#items' => $this->queryNodes($letter),
     '#path'  => $path,
     '#url'   => $current_path,
    );
  }

  protected function queryNodes($letter) {
    // the following code can be refactored
    $letter_path = 'B';
    $path = base_path();
    $current_url = Url::fromRoute('<current>');
    $current_path = $current_url->toString();

    // Query for newest articles and return max 3 results.
    $query = \Drupal::entityQuery('node');
    $nodes = $query->condition('type', 'ziekte')
      ->condition('status', 1)
      ->condition('title', $letter_path, 'STARTS_WITH' )
      ->sort('created', 'ASC')
      ->execute();

    return count($nodes) ? $this->entityTypeManager->getStorage('node')->loadMultiple($nids) : array();
  }
}

ControllerBase should inject everything you need already, like entityTypeManager. That can be used to load nodes, as shown above. You don't need to call Node, and you likely don't have to do the same for Url either.

You can bring in your query as a helper method and you can inject entityQuery into your controller, see this comment on how to do that. That way, you're not using the global static container (\Drupal::). Then your code becomes:

    // Query for newest articles and return max 3 results.
    $query = $this->entityQuery->get('node');
    $nodes = $query->condition('type', 'ziekte')
      ->condition('status', 1)
      ->condition('title', $letter_path, 'STARTS_WITH' )
      ->sort('created', 'ASC')
      ->execute();

I am not sure why you need path and url though - every filter link will be routed to '/ziektes/{letter}'.


How to play a video via drupal video ftp?

You just need a player frontend for the CCK field in question to display the video. This is actually quite easy.

You'll first need a video player frontend of some sort. I would recommend the VideoJS module ,personally, but I'm sure there are others worth looking into as well.

On your video content type, go over to Display, and change the display widget of that cck field to a video player frontend of your choice after enabling the video module.


How to join another table via altering view query as exposed filter

Add a filter from the Global group as a combined filter. Then assure the View has both the title and body fields avaiable in the View (they can be hidden from the View if you want).

Then set the combined filter to use the title and body fields when a search is done.

Then your single exposed filter will show results from your query criteria from either of the fields.


How secure are variable_get and variable_set?

I suggest not storing this information with a variable_set or system_settings_form which will put it in the variable store (which is the database by default, and can be cached wherever caching is happening such as memcache).

Instead, I suggest using the $conf array in settings.php for the information. The benefit is that settings.php is a file you are already using to store credentials for the database and already protecting from prying eyes.

The beauty of this system is you can still use variable_get to load the value from $conf which is easy, handy, etc.

For more details read the settings.php file itself which has a lot of commented out code examples and documentation.


Adding a cache tag to an entity view display doesn't do anything?

For that to work, core would have to use getCacheTags() from that config entity, which it doesn't do.

I'm not sure if that should be changed, core currently does not add the cache tags of that entity on purpose, instead it it invalidates the generic {$entity_type}_ cache tag on saving such an entity in \Drupal\Core\Entity\Entity\EntityViewDisplay::postSave(). Consdering that this changes only very infrequently once a site is live, this is more performant as there are fewer cache tags to check on each request.


Save a new value with entity_metadata_wrapper to an entity field which is an array

When dealing with multi-value fields, the associated entity metadata wrapper object is an instance of EntityListWrapper (It may be a good idea to browse the API to look at the available methods. Also note this class implements the ArrayAccess interface)

So the simplest way to add new values to an EntityListWrapper is by using the "[]" operator:

$wrapper->field_example[] = $new_value;

This creates a new entry and assigns it the value. With this methods, the delta (the offset within the list of value) is created automatically. You can also set the offset yourself if you wish. Any of the three following methods are equivalent:

$wrapper->field_example[$delta] = $new_value;
$wrapper->field_example->offsetSet($delta, $new_value);
$wrapper->field_example->get($delta)->set($new_value);

In all three cases this will overwrite values if the delta already exists, and create a new entry if not.

You could also directly set an array of value on the field itself. Both of the methods are equivalent:

$value = array
  0 => array('property_example' => 'hello'),
  1 => array('property_example' => 'world')
);
$wrapper->field_example = $value;
$wrapper->field_example->set($value);

However this requires you to know the internal structure of the field you're assigning to as you're not using the field's metadata wrapper.

Finally you can empty a multi value field by setting it to an empty value. All three methods are equivalent :

$wrapper->field_example->set();
$wrapper->field_example = array();
$wrapper->field_example = NULL;


Grouping the nodes based on the taxonomy terms

Create a view add two fields:

Node title
Taxonomy Term

Follow these steps :

Taxonomy Term" field to "Exclude from display
Set format = unformatted list in Format section
Set group Field as taxonomy term


How exactly does a View Preview differ from what is rendered on a page/block?

If aggregation is enabled and query settings distinct and/or pure distinct as well with flags relationships, I experienced differences in what the preview was showing and what showed in the actual block/page version. The solution for me was disabling the distinct option.


How can I display a "loading" icon while a slow page loads?

There is Page Throbber module which suits your requirement.

  Page Throbber is a simple utility module which lets the site developer
  display a spinning "throbber" and a custom message to display when
  loading up pages which they know will be slow to load.


Boost not updating without www site after clearing cache

You need to clear the Boost cached pages, i.e. the static pages. You can do that on the Boost settings page at the bottom under Clear Boost's Database & File Cache. If you only have changed one page you can just clear this page by enabling the boost block Boost: Pages cache configuration.

Edit: After a bit more thinking I am not sure clearing the Boost cache will fix your issue. However, do yourself a favor and change your .htaccess rules to redirect users to either with www or without www. I would suggest with as that is working for you. Having both counts as duplicated content in search engines and you risk to loose ranking.

To fix this, uncomment the following part in your .htaccess file (around line 81), or add it if it's missing:

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


For anyone with a similar issue, here is how I solved it.

The problem: using openid signin with a site that shows a splash login page for all anonymous users. You cannot use any splash page configuration that uses redirects, because it interferes with the openid redirect.

Solution: I removed the require login module and enabled the front page module. Then I configured the front page to use an alias with the login page for unauthenticated users, NOT the redirect option. When new users sign in, it automatically uses the company domain to create an openid and then stores it in Drupal.

Sidenote: New users cannot already have an existing account in the Drupal site, even if there is no openid yet assigned. The account is created the first time they sign in . They will not be able to do so if there is already an account attached to their email.


Translation not working for custom user roles

You need to grant translation related permissions for the two roles you have created. For changing the permissions, go to /admin/people/permissions, then set the translation related permissions for the two roles.
If you want the two roles to translate content, then you need to grant Translate content permission for the roles.


Programmatically set the block visibility

I have found the solution, set the visibility configuration by the following function using $menuLinkItem->uuid().

  function setVisibilityConfig($instance_id, array $configuration)

$block->setVisibilityConfig('_menu_position', array('id' => '_menu_position',
        '_menu_position'=> [
              'main:menu_link_content:'.$menuLinkItem->uuid() => 'main:menu_link_content:'.$menuLinkItem->uuid()
            ],
        'negate' => null,
        )
    );

Thanks, @SumitMadan for helping out to understand the visibility concept.


You can get code from Comment Permissions and Comment Access modules.

something like

function comment_perm_form_alter(&$form, $form_state, $form_id) {
  #comment_node_merci_reservation_form
  if ($form['#id'] == 'comment-form' and arg(0) == 'comment') {
    $types = variable_get('comment_perm_node_types', array());
    $form_id_types = array();
    if (is_array($types)) {
      foreach ($types as $type) {
        if ($form_id == 'comment_node_' . $type . '_form') {

          $nid = $form['nid']['#value'];
          if (! comment_perm_access($nid)) {
            // for comment reply pages, redirect back to the node
            if (arg(0) == 'comment' && arg(1) == 'reply' && is_numeric(arg(2))) {
              drupal_set_message(_comment_perm_access_denied_message($nid), 'error');
              drupal_goto('node/' . arg(2));
    }
  }

          if (arg(0) == 'comment' && arg(2) == 'edit' && is_numeric(arg(1))) {
            if (! comment_perm_edit_access($nid)) {
              drupal_set_message(_comment_perm_access_denied_message($nid), 'error');
              drupal_goto('node/' . $nid);
            }
          }
      }
  }
    }
  }

}

then you can add you own condition.

You can also use above module ,if it is fulfilling your requirement.


What query string is used to display products in commerce kickstart?

You can use the function commerce_product_load which is documented here. I am sorry if you are saying Drupal is not loaded and you have to use a straight php query.


To prevent synchronization issues, you should mount the files directory as a shared folder over NFS between the drupal webservers, so that each Drupal instance has a symlink to the same file share

e.g:

/var/www/drupal-site-mysite/sites/default/files -> /var/lib/sitedata/drupal-site-mysite/files

where /var/lib/sitedata/drupal-site-mysite/files is a NFS mount/share.


What are you trying to do, and why are you trying to do this? To be honest, it makes no sense. First off, schema numbers should start at 7000 (in Drupal 7), and you should never be resetting them, particularly within hook_update_N(), as you're just going to cause the same code to be run every time the update process is run.


How can I hide fields by user role when viewing a node?

OK, this code seems to be the solution:

/**
 * Implements hook_entity_field_access().
 */
function MYMODULE_entity_field_access($operation, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, \Drupal\Core\Session\AccountInterface $account, \Drupal\Core\Field\FieldItemListInterface $items = NULL) {
  if ($field_definition->getName() == 'NAME_OF_THE_FIELD' && $operation == 'view') {
    return \Drupal\Core\Access\AccessResult::forbidden();
  }
  else {
    return \Drupal\Core\Access\AccessResult::neutral();
  }
}


The best (IMHO) way is to implement hook_block_list_alter() in a custom module and unset specific blocks when you need to. Advantages are:

No PHP code in your database, so your alterations can be managed in a version control system
No hacking in the theme layer, so the alterations will remain when you switch themes
Better performance because the block is removed from the list before it is rendered

Drupal core also uses this hook to hide blocks: block.module itself implements hook_block_list_alter to apply the default block visibility settings.


How could I allow content editors to send email to a selected bunch of users?

If your content editors need to be able to select the group they are contacting  you can use Views Send. You can also use Rules (and probably Views Rules to ease the process of writing the rule some) particullarly if the editors are not going to be editing the message (if they are sending a notice about content updates or something similar).


Check size of files folder, heavy images may increase site loading time.


How to split node fields into view blocks


Renaming the field label from "author" to "created by"

To rename the label of a field add the preprocess function template_preprocess_node to your template.php file:

function *YOUR THEME*_preprocess_node(&$vars){
  //Supposing that your content type name is "group"
  if($vars['type'] == 'group'){
    //Supposing that your field name is "field_txt_group"
    $vars['content']['field_txt_author']['#title'] = 'created by';
  }
}


How do I display a field that's set to "Hidden" by the content type in the template?

$node->content will be a string containing the generated HTML output of the node's fields that will be displayed.

In hook_nodeapi() the $node->content is already generated, but you can append the hidden field's value to it if needed, with something like this:

function mymodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
    switch($op) {
        case 'view':
            if($node->type == "mytype") {
                $node->content .= "<div>".$node->field_myfield[0]['value']."</div>";
            }
        break;
    }
}


Function for showing thumbnails for nodes with imce

You can change style output in display fields settings of your content type. This will affect you render.

Also you can use theme_image_style function to set your image style

Url of image you can find in $content['field_image']['und'][0]['uri']


Check out this list of order printing and order invoicing modules.

I think Commerce Billy looks promising, but I haven't tried it out.

Commerce Order2Pdf is another promising module, but I'm not sure how customizable it is.

I am currently building a custom module to handle my own packing slip requirement.  I'm building to a template, and have found FPDF to be quite useful for this.

If you're comfortable with custom module development, I'd think that FPDF is the way to go, but you'll just need to write a lot of PHP to build a template, and then use Drupal Commerce API and/or custom database queries to load in the order data.  If you don't like the sound of that check out the aforementioned modules.

Let us know what you end up using! I'm curious about those modules but in this case I am going the custom route.


I'm not sure why you need this and you want a similar module of PHP filter which adds a new text format.

If you are familiar with custom moduling and hooks, I would give you a straightforward solution.
You could implement this using hook_block_view_alter by defining custom patterns (tokens).

<?php
function mymodule_block_view_alter(&$data, $block) {
    $patterns       = array('[add button]'); # more replacement patterns here
    $replacements   = array('<button type="button">Button</button>');
    if(isset($data['content'])){
        $content = $data['content'];
        if(is_string($content)) {
            $data['content'] = str_replace($patterns, $replacements, $content);
        }
        elseif(is_array($content)) {
        }
    }
}

Here is the result.

You may expand the code as you like such as defining more tokens, adding criteria for certain blocks, user roles, etc. You can even create an administration page at admin/config to define token replacements from UI.


How to limit the number of comment a user can post?

You could add a validate handler to the comment form

e.g, something like:

/**
 * hook_form_FORM_ID_alter
 */
function MODULE_form_comment_form_alter(&$form, &$form_state, &$form_id) {
  $form['#validate'][] = 'MODULE_comment_form_validate';
}

/**
 * Validate comment form submission
 */
function MODULE_comment_form_validate($form, &$form_state){
  $node = node_load($form_state['values']['nid']);
  if(isset($node->type) && $node->type = 'targetted_type'){
    $account = user_load_by_name($form_state['values']['name']);
    if(!empty($account->uid)){
      // Get comment count for this node type
      $query = db_select('comment', 'c');
      $query->join('node', 'n', 'n.nid = c.nid');
      $query->condition('c.uid', $account->uid);
      $query->condition('n.type', 'targetted_type');
      $query->countQuery();
      $comments = $query->execute()->fetchField();
      if($comments > variable_get('max_comments_targetted_type', 3)){
        form_set_error('name',
          t('You are only allowed to post %max comments on this type of content.', array('%max' => variable_get('max_comments_targetted_type', 3))));
      }
    }
  }
}


How can I create some specific content with a cron job

You got it!  Implement hook_cron and inside that function create a node using the node_save().

Each time you run cron by going to /cron.php or each time it is called from your cron job, your hook will automatically be called.

Here's some sample code, partly borrowed from http://drupal.org/node/1111514

So your .module file should at least have the following,

// Implementation of hook_cron
mymodule_cron {

  // add node properties
  $newNode = (object) NULL;
  $newNode->type = '{NODE_TYPE}';
  $newNode->title = '{NODE_TITLE}'
  $newNode->uid = {USER_ID};
  $newNode->created = strtotime("now");
  $newNode->changed = strtotime("now");
  $newNode->status = 1;
  $newNode->comment = 0;
  $newNode->promote = 0;
  $newNode->moderate = 0;
  $newNode->sticky = 0;

  // add fields
  $newNode->field_{YOUR_CUSTOM_FIELD_1}[0]['value'] = '{DATA_1}';
  $newNode->field_{YOUR_CUSTOM_FIELD_2}[0]['value'] = '{DATA_2}';

  // save node
  node_save($newNode);
  }

After you enable your new module, just run cron by hand (go to /cron.php) and test it out to see if your node was created!


You can use the module String Overrides which allow you to do what you asked for.

(As my low reputation I need to put here some more useless details :-) )

Copied From the module page:

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

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


So this is what I found entityform module does. If preview is enabled it set $form['review']. All of my forms will have that preview set so what I did is simply:

//check if form is in preview mode and if it is then it adds my custom handler.
if(isset($form['review'])) {
    $form['actions']['submit']['#submit'][] ='custom_submit'
}


Images are refering wrong path on node import

The wrong path belongs to an image derived from image cache. It's the default "large" image style defined in admin/config/media/image-styles. You can try to rebuild the image cache, but success depends a bit on your "paste code method" which i'm unfamiliar with...


Can't Review Order, button loops back to checkout form '/cart/checkout'

Thanks to David's response, I was inspired to investigate my upgrade from uc 2.8 -> 2.9 and ran the update.php script. It seems it was not run at the time of the upgrade, so now that it has the problem is solved.


Can I create a block that shows custom node types but in a specific order?

You can use Node Queue module, it may solve your problem.

  The Nodequeue module allows users to collect nodes in an arbitrarily ordered list. The order in the list can be used for a any purpose, such as:

  A block listing teasers for the five top news stories on a site
  A user’s favorite music albums
  A group of favorite from which one is randomly displayed

  Nodequeue provides a simple drag-and-drop interface to manually order any queue. Additionally, it allows nodes to be added and removed from queues without needing edit permissions to the node. Nodes can be added to queues either from a queue management tab or by links on the node teaser.


How do I create and delete a forum via POST to taxonomy_term?

Part one: How to delete a forum.

curl -i -X DELETE \
  -H Cookie:SESSe6abeefcafe=ovQpO6ahoQYUUREX23bre_2Q1onya55i9fbmzq7TWEE \
  -H X-CSRF-Token:v6j7r9Rbase62tokenHere-m9YYZA \
  -H Accept:application/json \
  http://myserver/rest/taxonomy_term/7

Some notes:

to construct the URL, you need to use the Term ID of the particular forum you would like to delete
You need to use the Cookie obtained from the prior call to /user/login
You need to use the CSRF token obtained from that same call

Where does the term ID come from?

The term id in my case, is something I retrieved from a combination of two other calls: one to retrieve the taxonomy id for the forums, then another to retrieve the terms under  that taxonomy. Like this:

curl -i -X GET \
  -H Cookie:SESSe6abeefcafe=ovQpO6ahoQYUUREX23bre_2Q1onya55i9fbmzq7TWEE \
 'http://myserver/rest/taxonomy_vocabulary?parameters\[machine_name\]=forums'

The response is like this:

[{
  "vid": "1",
  "name": "Forums",
  "machine_name": "forums",
  "description": "Forum navigation vocabulary",
  "hierarchy": "0",
  "module": "forum",
  "weight": "-10",
  "uri": "http://myserver/rest/taxonomy_vocabulary/1"
}]

And then, with the taxonomy ID returned there, I can retrieve the terms, which correspond to actual forums, like this:

curl -i -X GET \
 -H Cookie:SESSe6abeefcafe=ovQpO6ahoQYUUREX23bre_2Q1onya55i9fbmzq7TWEE \
 -H Accept:application/json \
 'http://myserver/rest/taxonomy_term?parameters\[vid\]=1'

The response is an array of JSON items, each of which has a term id.  You can then choose one of those term id's to delete, as above.

Part two: How to create a forum.

To create a forum, do the converse; add a new term in the same "forums" vocabulary. like this.

curl -i -X POST \
  -H Cookie:SESSe6abeefcafe=ovQpO6ahoQYUUREX23bre_2Q1onya55i9fbmzq7TWEE \
  -H X-CSRF-Token:v6j7r9Rbase62tokenHere-m9YYZA \
  -H Accept:application/json \
  -H content-type:application/json \
  http://myserver/rest/taxonomy_term \
  -d '{
    "vid": "1",
    "name": "Another Forum on the site",
    "description": "",
    "format": null,
    "weight": "10"
  }'

The vid property needs to be the "vocabulary id" of the forums
vocabulary. The uuid and the tid of the newly-created term will
be generated for you. Unfortunately, the tid will not be returned
for you to reference. You need to query again to find it.

curl -i -X GET \
  -H Cookie:SESSe6abeefcafe=ovQpO6ahoQYUUREX23bre_2Q1onya55i9fbmzq7TWEE \
  -H Accept:application/json \
  'http://myserver/rest/taxonomy_term?parameters\[name\]=Another+Forum+on+the+site'

Response:

[{
  "tid": "36",
  "vid": "1",
  "name": "Another Forum on the site",
  "description": "",
  "format": null,
  "weight": "10",
  "uuid": "dcbe0118-c160-4556-b0b6-1813241bb851",
  "uri": "http://myserver/rest/taxonomy_term/36"
}]

Therefore, make sure you use unique names for these "terms".


This looks like a ownership / permissions problem on a Linux server. Make sure to set the ownership of the drupal root folder and underlying files to the webserver's user (like 'apache', for example).

Also, make sure that the "temporary" and the "private" folders are setup correctly and with the right permissions (if in doubt, just test with 777 - don't forget to lower them to your requirements afterwards).


Flickr-like responsive photo gallery for Drupal 8

Drupal 8 has built-in Picture module with support of responsive images.
So you need to create new content type "Photo" with image field.
Add some photos of new content type.
Create new view of type "Grid List" and add Photo image field to display.
Or create new view of type "Unformatted", add Photo image field to display, then remove default field formatting, modify CSS.


Since you are using Views, can't you use the delta value of the field? It should give you the amount of fields-a & fields-b per node. If you have 2 value's in field a. field a:delta = 2. From there you should be able to aggregate over several nodes.

It won't give you the value's of the selected fields though.


Check out the Photowall project to see if it matches your requirements out of the box.

From the project page:

  Provides a Photowall (like Google) format for displaying images, using the JQuery Photowall plugin.

There is a nice demo showing what it does at the  JQuery Photowall link.

If it is not advanced enough for your tastes, I have another idea:

Since most of the power of the YooTheme Widgetkit for Joomla and Wordpress is provided by Javascript that runs in the browser and that should work just as well when it is launched from Drupal instead of Joomla/Wordpress, it should not be too hard to adapt the Drupal module Photowall to make use of the YooTheme Widgetkit Javascript plugin, instead of the JQuery Photowall Javascript plugin (but it will obviously require some custom development).


How to compare Profile2 field with PCP percentage in drupal 7 while creating Rule?

See Rules Integration for D7 version issue in Profile Complete Percent issue queue. Only condition they implemented is, it seems, "User profile is completed".

Maybe there are additional conditions now. Open this window and see. If condition you want is lacking, you will need to either file a feature request for PCP, or write own custom module, clone "User profile is completed" in it, changing name and switching from =100% (or how they actually implemented it) to <60%.


Customised user registration / sign-up forms in Drupal 7

When you need different set of fields for different users you should have a look at the profiles 2 module. There's a good chance that you can acomplish your requirements without any coding.

BTW: This kind of question has been asked many times here. The search functionality will give you a lot of information about this topic.


Filter and display all commerce product sales by date in a block?

You need to do some advanced Views building to make this happen, so if you've never used Views aggregation (formerly I think it was called "group by"), then I'd recommend looking into video tutorials on the topic.

Basically, if you start with a View of Orders and turn on aggregation (under advanced settings), then you can add two fields to the View:

Your custom date select field using "Group results together" as the aggregation type.
The Order ID using "Count" as the aggregation type.

Fiddle with it from there to get it to look like you want, probably using an unsorted list display format with the fields set the show up on the same line.

Here's a quick working export of a View that groups orders by user and shows the number of orders per each user (courtesy of joshmiller): http://pastebin.com/j7NTrkp9


Get field from another content type in Views

I cannot give you a very detailed answer, mainly because it has been too long since I built new things with Drupal 6, but also because I don't know which Views version you are using.

But anyway, the key to your answer is "relationships". Views allows you to define a relationship from one item to another (for instance: node -> author (user)) and then query properties of the related item (node -> author[name]). You can even chain relationships, so you can query a property of a related item of a related item. This seems to be what you need: node -> author -> node[field].

For more info I recommend that you find some video's or tutorials about views relationships, like these ones:

http://gotdrupal.com/videos/drupal-views-relationships
http://drupaleasy.com/blogs/ultimike/2009/07/using-views-relationships-arguments-attachments


Content Aware Caching for Commerce Related Views

The list of products uses Views, so in theory the module should work for views in admin/structure/views/view/commerce_products


Single webform on multi-language site with different url aliases

You can achieve that using administration interface.

Firs, Go to admin/config/search/path and click "Add alias".

On "Add alias" page:

Select language.
Fill the field "Existing system path" with your webform node/{nid_number}
Fill the field "Path alias" with desired alias for that language.


Choose theme depending on the USER_AGENT

I would suggest you to use browsecap module to detect what browser users use and switchtheme module to switch to correct theme depending on the browser they use.


How to create a menu block which is created by the active trail

Menu Block does cover your use case.

Go to /admin/config/user-interface/menu-block

You will see

  If a block is configured to use "the menu selected by the page", the block will be generated from the first "available" menu that contains a link to the page.

That screen is for administering which menus are available when the menu block is supposed to simply rely on the active trail to determine which menu to show.


How to format views table using open outreach theme

You could transform the tabular display by using the DataTables module, which uses the datatables plugin.
In doing so, you get all the typical dataTables widgets available, such as sorting for appropriate columns, but also a search box, pagination, etc.
Here is an excerpt from the module's project page:

... integrates the jQuery plugin DataTables into Drupal as a views style and a callable theme function. DataTables lets you add dynamic features to tables, including:

Variable length pagination
On-the-fly filtering
Sorting with data type detection
Smart handling of column widths
... (1)

(1) = there are more features (i.e. "Themeable by CSS"), but that requires "fooling with php and CSS" ...
PS: Works great for both D6 and D7 ...
Update (related to that issue you ran into as mentioned in your comment):
Consider reviewing/testing if that patch in comment nr 1 might work for you. The patch looks like so:
diff --git a/datatables.module b/datatables.module
index 193c892..3b66932 100644
--- a/datatables.module
+++ b/datatables.module
@@ -244,11 +244,8 @@ function theme_datatable($variables) {
 function template_preprocess_datatables_view(&$vars) {
   // Run views table preprocess function to handle putting rows in columns,
   // classes, etc.
-  template_preprocess_views_view_table($vars);
-
-  // No need to add anything if there are no rows.
-  if (!$vars['rows']) {
-    return;
+  if(!empty($vars['rows'])) {
+    template_preprocess_views_view_table($vars);
   }

   $view     = $vars['view'];

The most elegant / straight forward way to "apply" that patch is to use GIT. However, this seems like only a few lines in 1 module are changed by the fix. You could also "apply" that fix by simply editing that module to be patched, by reading what the patch content is, and then editing the module with your favorite editor, to achieve the same result. Here are the steps involved:

navigate to the folder in your site that contains file datatables.module.
make a backup copy, eg to something like datatables.module.backup.
open datatables.module in your favorite editor, and scroll to the line around line 244. If you can, turn line numbers on.
You should then see a few lines of code identical to the lines near the top of the patch (not preceeded by '-' or '+' signs.
around line 247, there should be a line like template_preprocess_views_view_table($vars);, but without that '-' sign as in the patch
DELETE that exact line, and then next 4 lines entirely (which is indicated in the patch with the '-' sign at the start of each line).
then INSERT those 2 lines preceeded by a "+" in the patch (but make sure to replace the "+" signs at the start of those 2 lines with a blank).
save your (module) file, and rerun your test to see what effect/result you now get.
after you finished testing it, decide what you want to do with this edited version of the module. Continue to use it? If not rename the edited file to something like datatables.module.edited, and then rename the datatables.module.backup file back to datatables.module. That will have restored the original version.


Check the Rewrite the value of this field-option of the body field,
Fill out the following token in the text area: [body-summary]

Now it will only display text from the summary, and nothing when that very summary is empty. So it won't use the trimmed text of the full content either. Perfect.


How to set files public directory programmatically?

You can set that variable like so:

variable_set('file_public_path', 'sites/domain/files');

Hopefully someone else will be able to tell you why this problem is happening, I have no such issue in any of my multisite installations.


You can install Backup and Migrate

Back up and restore your Drupal MySQL database, code, and files or migrate a site between environments. Backup and Migrate supports gzip, bzip and zip compression as well as automatic scheduled backups.
With Backup and Migrate you can dump some or all of your database tables to a file download or save to a file on the server or offsite, and to restore from an uploaded or previously saved database dump. You can choose which tables and what data to backup and cache data is excluded by default.


How do I mock the "file_system" service?

You shouldn't call file_system with \Drupal::service('file_system') use dependency injection instead:

So try something like the following in your service:

Add arguments to your *.services.yml file.

services:
  yourModule.yourService:
    class: Drupal\yourModule\yourServiceClass
    arguments: ['@file_system']

Inject the file_system service in your Class:

  use Drupal\Core\File\FileSystemInterface;

  /**
   * The file system service.
   * @var \Drupal\Core\File\FileSystemInterface
   */
  protected $fileSystem;
  /**
  * Class constructor.
  * @param \Drupal\Core\File\FileSystemInterface $file_system
  */
  public function __construct(FileSystemInterface $file_system) {;
    $this->fileSystem = $file_system;
  }

Change setBasePath method to be like.

  /**
   * @inheritdoc
   */
  public function setBasePath($path = Null) {

    if ($path !== Null) {
      $this->directories['base'] = $path;
    } else{
     $this->directories['base'] = $this->fileSystem->realpath(file_default_scheme() . "://");
    }
  }


How can I reduce the initial load of page?

There isn't much you can do with the browser debugging tools in this case. You need to debug this on the server:

https://docs.acquia.com/articles/using-xhprof-evaluate-code-performance


How to remove unused tables in the database in Drupal 7

I think Schema will tell you that.
If a module leaves tables after uninstall, that's a bug, and you should open an issue.


How to work with .install files and hook_enable etc... when developing a module?

Yes You can write in your hook_update_N() like this in your mymodule.install file:

function mymodule_update_7001() {
 db_add_field('table_name', 'field_name', array(
  'description' => 'The total amount to be paid for the order.',
  'type' => 'numeric',
  'precision' => 16,
  'scale' => 5,
  'not null' => TRUE,
  'default' => 0.0,
 ));
}

After writing this you can simply run your update.php file


Searching for a general approach for passing custom lists of node IDs as an argument to Views 3.x

What you really want is a an "argument default plugin".
There are some availible in views itself, one is the php one, which you use already.

It's really not that hard to write. You need the following hooks for it:

hook_views_api
hook_views_plugins

After this you have to create the plugin and most important write a function called get_argument() which returns the arguments.


How to get relationship id in views drupal 7?

If you want to output a link in views which leads to the page where the user's account can be deleted you can use the field "User: Cancel link". That field should be present in your view since you have the user as a relationship.

If you still want the user's uid and link to some page on your own you need to add the field called "User: uid" and then rewrite the output of the field.

Add the field called User: uid, then under the settings for the field expand Rewrite results and click Rewrite the output of this field, enter the text that should be displayed. Then click output this field as a link and use the [uid] placeholder in the link. The [uid] will be replaced with the user's uid when the View is rendered. You can see an example of the settings in the image below.


Module for username suggestions on registration

There is no module that does that. The closest you will find is the one that just checks if the username is available while registering. An example of such module is username check. To achieve the username suggestion bit, you may have to write a custom module for that.

  This very simple module allows visitors to check username originality
  quickly using AJAX request during registration (completing
  registration form). This makes registration process more convenient as
  you don't need to submit your registration form to find out whether
  this username is already taken or not. This module is sensible to
  standard Drupal username validation as well as Access Rules
  validation.

or friendly register

  Friendly Register module allows users to see if a username or email
  address has already been used during registration before they submit
  the form. This module checks the database and returns an error if the
  username is already in use. In addition to checking the username the
  module checks if there is already an account using that email address,
  if there is, a message is displayed with links to the login or reset
  password pages.


How to display a default value for minute field of Time fieldtype

As the time component says in its description field, it "accepts a time in any GNU Date Input Format. Strings such as now, +2 hours, and 10:30pm are all valid."

If you want to set the default minute, you can used a formatted string like "1972-09-24T20:02:00,000000-0500" or "10:30pm" in the Default value field.


The http://drupal.org/project/jplayer module allows for playlists and so forth, but unless you are up for some obfuscated javascript and a whole bunch of other coding (that in the end is nevertheless subvertible [sp?]) the mp3s will still be downloadable by most advanced users.  (Or perhaps investigate the private file serving methods drupal offers, but then you have to balance the overhead there)


Setup multiple solr core's and then use settings.php to define for each environment as poster above said.

If you are using ApacheSolr its like:

$conf['apachesolr_environments']['my_env_id']['url'] = 'http://localhost:8983';

Just make sure your settings.php is not moved from server to server, if it is then use environment variable in apache:

SetEnv ENVIRONMENT development
SetEnv ENVIRONMENT staging
SetEnv ENVIRONMENT production

And use something like this in settings.php

<?php
switch ($_SERVER['ENVIRONMENT']) {
  case 'development':
    $conf['apachesolr_environments']['my_env_id']['url'] = 'http://localhost:8983';
    break;
  case 'production':
    $conf['apachesolr_environments']['my_env_id']['url'] = 'http://www.domain.com:8983';
    break;
}
?>


It all depends on what that word is.  For example, if 'practice' is a taxonomy term name, you would choose that and Views would filter on nodes tagged with taxonomy term 'practice.'  If, however, the word was the title of a node, you would filter on node title and Views would filter on node titles equal to 'practice.'

ADDITION:

If you want to ignore the word when it comes to filtering, just use the Global Null field and it will be ignored by any queries, but will still be available as arg(#) in any script called.

ADDITION 2:

Let's say you are looking at a Views Page Display, with a path something like:

www.user1015214.com/all/the/best

that returns pictures of all the best stuff a website has to offer.  Views would have that with a path of all/the/best.  Now, let's say we wanted filter this by something, we'd change that path to all/the/best/% and then enter an argument (D6) or contextual filter (D7).  Let's say it's a taxonomy term for this example.  So now we could have something like this:

www.user1015214.com/all/the/best/views

and it would return all the best stuff the website has to offer that is tagged with the term views.  Now, let's say you want to have an easter egg feature, where if you have polite users, they get something special, so in Views, you can add another argument to the path, eg, all/the/best/%/% and in this second argument you give tell Views it is a Global Null Value.  Now, what this does is let Views know to look for an argument there, but not to use it in any of the sql it builds.  Like a placeholder.  So, now you could do something like:

www.user1015214.com/all/the/best/views/please

And Views would create the same sql statements as before, returning all the best views, but you could then access that additional argument for any custom purpose you wanted anywhere within the drupal system.  The easiest is to use the system arg(#) function:

$foo=arg(0); // all
$bar=arg(2); // best
$baz=arg(4); // please

and in your example, within the your node template file, you could do something like:

$baz=arg(4);
if ($baz=='please') {
   print '
Thank\'s for being polite! Here\'s a link to something special: ';
   print l('Pee Wee\'s Playhouse', 'http://www.peeweesplayhouse.com') . '
';
}

and then whenever someone asked nicely that additional  would be displayed along with your node.  Pretty nonsensical I realize, but I hope it explains arg()s :)


I'm probably completely over thinking this

Have a look at Entity forms https://www.drupal.org/project/entityform rather than webform then the user can create an entity that can be converted to your event style content type. Some form of workflow will clearly be involved. Rules may help you avoid coding.


How to add class in li element (for page where I am) in menu for drupal 8

To add active class to
 need to add the following code in your .theme file and menu.html.twig

In .theme file add this

function themename_preprocess_menu(&$variables, $hook) {
  if ($hook == 'menu__main') { // If it is not working replace "main__menu" with "menu"

    // Get the current path.
    $current_path = \Drupal::request()->getRequestUri();
    $items = $variables['items'];
    foreach ($items as $key => $item) {
      // If path is current_path, set active to li.
      if ($item['url']->toString() == $current_path) {
      // Add active link.
      $variables['items'][$key]['attributes']['class'] = 'active';
      }
    }
  }
}

In menu.html.twig replace your
 with below line.

replace this line

{{ link(item.title, item.url) }}

by

 {{ item.title }}


How do I get a field count from an executed query?

Drupal uses PDO, whose equivalent function is PDOStatement::columnCount():

  Returns the number of columns in the result set represented by the PDOStatement object. If there is no result set, PDOStatement::columnCount() returns 0.

So what you're looking for isn't totally possible these days. I can't see a Drupal equivalent of columnCount(), but you can always grab the PDO connection object with Database::getConnection(), and work with that directly if it'll help you get part of the way there.

To take a different approach, and assuming you've used the schema API to describe your table to Drupal, you can query that instead:

$table = drupal_get_schema_unprocessed('MYMODULE', 'table_name');
$fields = $table['fields'];


I think the easiest option is leave everything as you have it in terms of configuration and your taxonomy term values for main terms. The default Workbench (Moderation) logic isn't nested enough for you. So use it's supported hooks to extend the functionality to meet your needs.

Look at hook_workbench_moderation_access_filter()

/**
 * Allows modules to alter moderation access.
 *
 * @param &$access
 *   A boolean access declaration. Passed by reference.
 * @param $op
 *   The operation being performed. May be 'view', 'update', 'delete',
 *   'view revisions' or 'moderate'.
 * @param $node
 *   The node being acted upon.
 */
function hook_workbench_moderation_access_alter(&$access, $op, $node) {
  global $user;
  // If the node is marked private, only let its owner moderate it.
  if (empty($node->private) || $op != 'moderate') {
    return;
  }
  if ($user->uid != $node->uid) {
    $access = FALSE;
  }
}

By implementing this hook for the node access check, you can define the nested taxonomy check you're wishing Workbench_Moderation did for you. In order to find if some node has a value of a certain parent term you may find the Taxonomy Edge API module useful. Then again you might not need Taxonomy Edge.

I believe the Views workbench uses will also support this runtime check.


What extensions are used in a module, and what do they mean?

The extensions that are specific for Drupal, or that have a specific meaning in Drupal, are the following ones:

The .api.php extension is used for the file describing the hooks used by a module, such as system.api.php.
The .install extension is used for the file that is used when a module is installed, such as system.install. It is also loaded when Drupal is verifying the requirements needed from a module.
The .inc extension is used for any secondary file that contains code that is loaded only when necessary. If the code is used in specific cases, such as when a specific menu callback is being invoked, then the code is moved in a separated .inc file. Often, you will find modules using a file with the .admin.inc extension (e.g. node.admin.inc) that includes all the code necessary to run the administrative interface, and a file with .pages.inc extension (e.g. node.pages.inc) that contains the code executed for other menu callbacks. If a module implements tokens, in Drupal 7 you will find files using .tokens.inc as extension (e.g. user.token.inc); those are the files where the implementations of hook_token_info(), and hook_tokens() are looked for (see system_hook_info()).
The .info extension is used for the file describing the module, or the theme, such as system.info. It contains metadata, such as the required Drupal version, the minimum PHP version with which the module/theme is compatible, and other information specific for the module, or the theme.
The .module extension is used for the main file of a module, such as system.module.
The .test extension is used for the files containing the testing code (e.g. system.test), which is actually running on the SimpleTest framework.
The .theme extension was used from themes not using PHPTemplate template engine. In Drupal 6 (and before) the extension was used from the chameleon.theme file; in Drupal 7, there aren't themes using that extension.
The .tpl.php extension is used for the template files used from theme functions, such as node.tpl.php.

Third-party modules can use specific extensions, such as the following ones:

The .views_default.inc extension is used for files (e.g. node.views_default.inc) containing the code to implement the default views used from a module that integrates with the Views module.
The .views_template.inc extension is used for files (e.g. node.views_template.inc) containing the code for views templates.
The .rules.inc extension is used for files containing code for integrating with the Rule module.


Here is description of all parameters that you can pass to theme_table() function http://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7

To add classes for table tag use this code:

$build['table'] = array(
  '#theme' => 'table',
  '#header' => $header,
  '#rows' => $rows,
  '#attributes' => array (
    'class' => array('class name goes here'),
  ),
);


You have to use hook_form_alter or hook_form_FORM_ID_alter
Add your submit handler to $form['#submit'] like this $form['#submit'][]='my_submit'
And write your code:

function my_submit($form, &$form_state) {
  // your code
}


How can I hide the primary menu block to certain pages using PHP?

You can do it from the block configuration

go to admin/build/block
search for the block and click "configure"
in the "Page specific visibility settings" click on "Show on only the listed pages"
write the page that you want this block to be visible on E.g "news" this will make that block visible on http://www.examble.com/news

Is that what you mean?

UPDATE:

if you want to control tha appearance programatically do the following

1- Disable the primary links block from "admin/build/block"

2- enable the primary links menu from your theme configuration (now i suppose you see the menu in all the pages and you want to specify the pages that you want this menu to appear in)

3- open page.tpl.php file

4- go to line 24 you will find something like this

<?php if (isset($primary_links)) { ?><?php print theme('links', $primary_links, array('class' => 'links', 'id' => 'navlist')) ?><?php } ?>

we will edit the following condition if (isset($primary_links))

now you should know something if you have url like this
http://yoursite.com/media/pictures

then the function arg(0) will return media and arg(1) will return pictures

another example

http://yoursite.com/admin

then the function arg(0) will return the first argument in your url which is admin

now lets back to the condition if (isset($primary_links))

we will edit it ... we wanna say to drupal if the first argument is equal to something then appear the menu else disable the menu

suppose that you want the menu to appeare in the page user

then you will edit the if (isset($primary_links)) to be

if (isset($primary_links) && (arg(0) == 'user')  )

suppose that you want this menu to appeare in page user and page admin

if (isset($primary_links) && (arg(0) == 'user' || arg(0) == 'admin')  )

one more advanced example... if you want the menu to appeare only in
user/1 page and admin  page

if (isset($primary_links) && ( (arg(0) == 'user' && arg(1) == '1') || arg(0) == 'admin')  )

hope that will help you


How to limit the products from the compare in drupal?

You may solve this through Rules module.

Event: After udpdating an already existing line item

Conditions:
1/ data comparison: commerce-line-item:type = product
2/ data comparison: commerce-line-item:commerce-product:type = Your given product type
3/ data comparison: commerce-line-item:quantity is greater than 1

Action:
- set data value: commerce-line-item:quantity 1
- display custom message


For aggregate queries, you need to use the separate method, from https://www.drupal.org/node/1918702:

$query = Drupal::entityQueryAggregate('node');

$result = $query
  ->groupBy('type')
  ->aggregate('nid', 'COUNT')
  ->execute();

groupBY() alone doesn't do anything. The normal entity query returns entity ID's. Always. It makes no sense to group by a field or anything else. Only in combination with aggregate.


How to add multiple forums for a single site in Drupal

The Drupal forum module allows creation of multiple forums.  The module allows you to create 'forum containers' (groups of forums) and forums.

If combined with 'Advanced Forum' and 'Forum Access' modules it should be able to provide you with the facility to create multiple forums and control access by role to specific forums or containers.

The forum containers are actually taxonomy terms so you can customize the URLs for each container by editing the taxonomy term, eg /forum1 /forum2 etc.

To make the URL structure consistent between containers and forum topics, you may also require 'PathAuto' module, and to look at the URL alias patterns.

For default pattern for forum topics - I use is:

forum/[node:taxonomy-forums:parents:join:/]/[node:taxonomy-forums:name]/[node:nid]

You might find this works better for you if you wish to customize the taxonomy term URLs.

[node:taxonomy-forums:url:path]/[node:nid]

Pattern for forums and forum containers:

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

or perhaps for consistency with custom URLs

[term:parent:url:path]/[term:name]


It is not necessary to hide the 'no' option from checkbox - just go the the field settings and make it a single on/off checkbox, that way you will not have to deal with this at all.

Then, go to the field settings and set the Default value to off (see screenshot).


How to store multiple values in a profile field (specific to each users)?

You might be best installing content profile as this will allow you to use cck, when creating the profile field amount you can set it to unlimited which would allow you to store multiple values in an array for a single field.

The total would be another dynamic field which is calculated by adding the values from the amount array each time they are changed via a hook

To add the field to a content profile, follow the below steps:

Edit the profile content type
Go to manage fields
Add a new "text field
Fill in field details
On this page you will see a "number of values" option, choose "unlimited"

You can update content profile fields as below, just put it in a custom module or something:

//load current user
global $user;
//find the users content profile
$uid = $user->uid;
$node = content_profile_load(profile,$uid);
$pid = $node->nid;
$node = node_load($pid);
//update the field AMOUNT
$node->field_AMOUNT[0]['value'] = $var1;
$node->field_AMOUNT[1]['value'] = $var2;
//do the same for the TOTAL with calculations
$node->field_TOTAL[0]['value'] = $var1 + $var2;
//save the content profile node
node_save($node);


Print taxonomy information based on the link that is clicked

If you just want a custom pattern for the URL then you are better of with Pathauto module

Once you enable the module if you go to Admin -> URL Alias you will get a new TAB Pattern. In that you can define the pattern that you want to give to the taxonomy page. By default it would be [term:vocabulary]/[term:name]

So if your vocabulary name is fruits and your term name is apples then the url will automatically be turned into fruits/apples

After you enable the module you might have to do Bulk Update from URL aliases for the urls to take effect.

If the requirement is to add more information regarding the taxonomy terms or nodes with in the taxonomy term then you should use the views module

If you are simply trying to learn the how things work with in drupal then you should check the examples module it has got all sorts of modules to get you started with.


How to count date difference excluding weekend and holidays in Computed Field

why would you try something like this,

create a variable array that contain all the Hollidays

$currentyear=the current year;
$holiday['01-01-'.$currentyear,other holiday,other holiday];

$result=$start_date->difference($end_date, 'days');
for(ctr=0;ctr=sizeof(holiday);ctr++;)
{
    if(holiday[ctr]>=start_date && holiday[ctr]<=end_date)
    temp++;

}
$result -= temp;


How to get notified by eMail after someone edited his own webform submission?

Using Webform Rules (and Rules of course), it's a peace of cake to send an eMail using Rules Event "After a webform submission is updated". To actually do so, refer to the answer from CodeNext. However, the real challenge in this question here, is to address this part of the question: "someone edited his own submits". Read on for more details on how to implement that part of it.

Assumptions:

It should also work for "someone edited 'her' own submits".
The question is NOT about anonymous users (for that you might need things like IP address, session API, etc ... be my guest to also get that to work ...).

With these assumptions in mind, you'll need to have something in your webform available to store, as part of the submitted webform, the uid of the user who actually submitted the webform. I've not found (yet) any such data that is available as a token to Rules (you'll need it in Rules to get this challenge to work). So therefor I'd use an approach like adding an extra (hidden?) webform field that is automatically set (eg using Rules) when the webform is first submitted, let's say using a field with machine name field_webform_submitter_uid.

After all the above is in place and agreed about, you're in good shape to address the challenge "someone edited 'his/her' own submits": all you'd have to do is to further enhance the rule detailed in the prior answer, by adding an appropriate Rules Condition, to check if the uid of the currently logged in user matches field_webform_submitter_uid.

But, there is 1 more challenge to implement that extra Rules Condition: how should the Rules token look like for the value of field_webform_submitter_uid? To find the answer to this, refer to the README.txt of Webform Rules: based on what's documented there, the token to be used in that extra Rules Condition should be [data:field_webform_submitter_uid-value].

Voilà ...

Note (about the token for the uid of the user who submitted the webform): each submission has data like "submitted by" and "submitted on", however from all uid-variations I've experimented with, none of them contain the value that always matches the "submitted by" (not to be confused by tokens like node:author:uid, those are for sure not what matches the "submitted by"). To convince yourself, try a scenario where the user who submitted the webform is different from the one who edits that submission ...


Importing content to a content type with images and associated data

In Drupal content is store in Databases (SQL) this your text and any link that you inside your content. Images are files that can be call from your content, module or theme.

Tooltips is mainly a front-end work, this is part of the theme or a module. So you do not necessary import from the content from your another framework (or website). You added a module or a theme that support Tooltips.

Here are few modules for Tooltips:

qTip
BeautyTips
Field Tooltips
Tipsy

You should pick one of these module and you should be good to go.


How can I add "data-target" additional attribute in mega menu?

You can use below code to set attributes. This will add an attribute to all links in the page. But make sure to add the condition check for your URL.

/**
 * Implements template_preprocess_menu().
 */
function THEME_preprocess_menu(&$variables) {
  foreach ($variables['items'] as $item) {
    $item['attributes']->setAttribute('data-target', 'YOUR TARGET NAME');
  }
}


Question about D7 Organic Groups, Memberships, and Views

That sounds more like an issue with the SQL query, called a Cartesian join.  It's where you join every row of one table to every row in another table, or to itself, resulting in lots of duplicated rows. Dump the SQL that the View is creating and run it by itself in the database client to see if that's the source of the problem.


You can add the jquery date picker in for that page as dependency.

your_theme.libraries.yml

date-picker:
  js:
    script/site-datepicker.js : {}
  dependencies:
    - core/jquery
    - core/jquery.ui.datepicker

site-datepicker.js

Drupal.behaviors.customDatepicker = {
  attach: function (context, settings) {
    jQuery(function () {
      jQuery("#datepicker").datepicker({
        dateFormat: "dd-mm-yy",
        altField: "input[data-drupal-selector=edit-created]",
        altFormat: "yy/mm/dd 23:59:59"
      });
    });
  }
};

views-exposed-form--views-block-name.html.twig

{% if q is not empty %}
  {#
    This ensures that, if clean URLs are off, the 'q' is added first,
    as a hidden form element, so that it shows up first in the POST URL.
  #}
  {{ q }}
{% endif %}

<input id="datepicker" type="text">
<input data-drupal-selector="edit-created" data-msg-maxlength="This field field has a maximum length of 128." name="created" size="30" maxlength="128" aria-invalid="false" type="hidden">
{{ form|without('created') }}

There is also the Date Popup module, for Drupal 8. You can use that module and implement this functionality.


Create a "title" function in your controller and declare it in your route, like here ( _title_callback):

entity.node_type.edit_form:
  path: '/admin/structure/types/manage/{node_type}'
  defaults:
    _entity_form: 'node_type.edit'
    _title_callback: '\Drupal\Core\Entity\Controller\EntityController::title'
  requirements:
    _permission: 'administer content types'


Get field_collection values in field template

This is the solution I came up with. The first line is a bit of a hack and I think is not very robust.

Also, I think i'm not using the entity_metadata "way" of accessing the contact fields - but it works for now.

Would welcome suggested improvements.

$candidate_node = node_load($row->node_node_nid);
$survey_node = node_load($row->{$field->field_alias});

$candidate_wrapper = entity_metadata_wrapper('node', $candidate_node);
$survey_wrapper = entity_metadata_wrapper('node', $survey_node);

foreach ($candidate_wrapper->field_contact->value() as $contact) {
    if (array_key_exists('und', $contact->field_type)) {
            $key = $contact->field_type['und'][0]['value'];
            $value = $contact->field_contact_url['und'][0]['safe_value'];
            print sprintf($format[$key], $key, $value, ucfirst($key), $score);
    }
}


Add placeholder in registration form and removing labels

This could be easily done my hook_form_alter in your custom module. See example below:

Suppose you have a form with id as 'your_form_id' and are looking at overwriting title and placeholder text for a field named 'yourfield', you can create a custom module and add this code to your custom module.
You will need to replace 'yourmodule' with the name of your module. Same with 'your_form_id' and 'yourfield'.

     /**
     * Implements hook_form_alter().
     */
     function yourmodule_form_alter(&$form, $form_state, $form_id) {
       switch($form_id) {
         case 'your_form_id':
           $form['yourfield']['#title'] = t(''); // Remove title from yourfield.
           $form['yourfield']['#attributes']['placeholder']= t('Your placeholder text'); // Set placeholder text for yourfield.
           break;
       }
     }

The t() method is used for internationalisation.

Let me know how you go...


Error when I try to make a local translate.

It's happening because you have <div> tags in your translation text.

locale_string_is_safe(), the function used to make sure the string provided for translation is safe, has this to say about the allowed tags:

  The allowed tag list is like filter_xss_admin(), but omitting div and img as not needed for translation and likely to cause layout issues (div) or a possible attack vector (img).

So basically you need to remove the <div> tags and your translation will work just fine.

If you're interested in the chain of functions called so you can check the logic for yourself, it's as follows:

l10n_client_save_string()
_locale_import_one_string_db()
locale_string_is_safe()

Since locale_string_is_safe() does allow <span> tags you might consider using those instead. If you need the element to be block level then you can just use CSS to do that.


You can use EditableFields instead, which will let you use Unformatted list instead of table.

  This module allows CCK fields to be edited on a node's display (e.g.
  at node/123), not just on the node edit pages (e.g. node/123/edit). It
  also works within views etc. Anywhere a 'formatter' can be selected,
  you can select editable (or click to edit).

Here is a video tutorial on how to use it.

Then you can use CSS to get the view to look how you want it.

.field-title { float: left; }
.field-feedback { float: left; }

Also, you will probably need to resize the edit button.

Else, if you do not want to use CSS then the following may possibly work:

1) Hide all your fields from display

2) In FIELDS, add a Global: Custom field

3) Use the replacement patterns on your custom field.

Ex:

[title], [author]

[field_description]

[field_feedback] | [field_rating]


How to delete file using drupal_form_submit?

You can use this code in your form submit function

$file ='public://not_imported_longanswer.csv';
$path = $base_url . '/sites/default/files/not_imported_longanswer.csv';
if (file_exists($file)) {
    file_delete($path);
}


In Drupal 8, how do you add attributes to a link generated by the core Link field? (or, generally a render array with #type set to "link")

Answering my own question: the original suggestion was actually a valid solution; the way I had my theme configured meant that the hook wasn't loading. Stupid mistakes!


How can I add pagination to the comments of advanced forum in drupal 7?

I think that this can help you.

Let me know if this is working.


If you are referring to drush dl, then by default Drush downloads from drupal.org, if you don't tell Drush to use another URL.
For example, if you use drush dl views --source="updates.modules.org/history", Drush would probably download the Views module from modules.org, instead of drupal.org. From where the module would be downloaded depends from what updates.modules.org/history/views/7.x (for Drupal 7) or updates.modules.org/history/views/8.x (for Drupal 8) returns.

If you look at what https://updates.drupal.org/release-history/views/7.x retuns, you will notice a line like <download_link>https://ftp.drupal.org/files/projects/views-7.x-3.14.tar.gz</download_link>, which is telling to Drush to download the Views module version 7.x-3.14 from https://ftp.drupal.org/files/projects/views-7.x-3.14.tar.gz.


The field template prints all the fields as a row. If you want to output the row of fields manually you need to remove the foreach iteration of the fields.

See views-view-fields.tpl.php for more info.


How to return drupal's articles image upload

Go to Structure » Content types » Article >> Manage fileds

Add new field. Here is the sample screenshot


Is there a hook when a relation is created, updated or deleted?

Relations are themselves entities, so you can use the entity hooks:

hook_entity_insert()
hook_entity_update()
hook_entity_presave()

and so on, checking the $type parameter to react only for the appropriate entity type(s).

There's a full list of available entity hooks in the system.api.php file.


Clone nodes and change fields with Rules and VBO

I solved using custom PHP code in my component instead of the node clone action, so I'd like to share this with you:

// load the original node
$node = node_load($node_parameter->nid);
$node->nid = null;
$node->vid = null;
// park the new node
node_object_prepare($node);
// reset fields
$node->uid = 1;
$node->status = 1;
$node->path = null;
$node->created = 1432072800;
$node->title = $site->current_date;
$node->field_one['und'][0]['target_id']= 11530;
$node->field_two['und'][0]['value']= 'my text';
unset($node->field_three);
// save the new node
node_save($node);
// flush
unset($node);

Probably the key is that when you use the action "node clone", Rules alone can't determine the cloned node type and access to its fields directly, even if you are cloning a node already verified by the condition at the beginning of the component. Probably it could if putting another condition after the clone action, but I don't know how to.

So another solution I tried is to create a component that just clones the VBO passed node. And then create a separated rule that reacts on event "after cloning a node" and put in there the condition "content is type of" and all the "set data value" actions I needed.

And it works.

Anyway I prefer the first solution, so I can keep all I need in just one place and avoid using Node Clone module. I was worried about performance executing PHP and node_load() in Rules, but in just few minutes I successfully cloned and updated 2260 nodes.

Thanx all


How to create new markers into a Google map with click?

This is working example at my side please check here Demo

function initCentraDistrictmap()
{
var mapOptions = {
zoom: 12,
center: new google.maps.LatLng(1.3050618171691895, 103.8240737915039),
mapTypeId: 'roadmap'
 };
    map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);

google.maps.event.addListener(map, "click", function (event) {

var myLatLng = new google.maps.LatLng(event.latLng.lat(),event.latLng.lng());
var image = 'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2246%22%20height%3D%2244%22%3E%0A%3Ccircle%20cx%3D%2223%22%20cy%3D%2222%22%20r%3D%2220%22%20stroke%3D%22%23000%22%20stroke-width%3D%222%22%20fill%3D%22%23ff3019%22/%3E%0A%3Ctext%20transform%3D%22translate%2823%2025%29%22%20fill%3D%22%23fff%22%20style%3D%22font-family%3A%20Arial%2C%20sans-serif%3Bfont-weight%3Abold%3Btext-align%3Acenter%3B%22%20font-size%3D%2212%22%20text-anchor%3D%22middle%22%3ETesting%3C/text%3E%0A%3C/svg%3E';
var marker = new google.maps.Marker({
      position: myLatLng,
      map: map,
      icon: image// baseURL + 'assets/drawsvg.svg'
  });
});
}
 $(document).ready(function(){
  initCentraDistrictmap();
 })


Well you can use the forum module that comes with Drupal core or you can integrate a phpBB installation. Check this module: phpBBforum Integration module. phpBB 3 is the best open source bulletin board. It is fast, secure and has a lot of features and extensions (mods). All the features that you need above are supported by phpBB 3.


You would use:

dpm($form['#node']->uid);

As you rightly say the #node variable is an object, and object properties in PHP are accessed using the -> operator.

Have a peek at the PHP Objects documentation for a few more details.


Edit the Reaction Rule "Collect rates: Flat Rate" and add conditions if you wish, so that it only applies to certain Product Types, or to an Order whose total is over a certain amount, for example. (Note that because you are using Conditional Rules you could also put such logic in the Action of your shipping pricing rule [see below])
Create a Shipping Service for your Flat Rate Shipping Method. For example, "My Basic Shipping." Give it a base rate - can be $0, or whatever.
Create a shipping pricing Rule that applies shipping charges to Products through the Service you just created. You can use conditionals in the Rule to apply the shipping based on SKU, Product Type, price, or whatever. You can use extra modules to base it on size and weight, day of the month, whatever.

Here's an example of a Price Calculation Rule. My Shipping Service is called 'swag shipping' and the Rule adds to the shipping cost based on the country:

{ "rules_ship_s_store_shipping_surcharge_by_country" : {
"LABEL" : "Ship\u0027s Store: Shipping Surcharge by Country",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "Commerce Checkout" ],
"REQUIRES" : [
  "rules",
  "commerce_order",
  "rules_conditional",
  "commerce_line_item",
  "commerce_shipping"
],
"ON" : { "commerce_shipping_calculate_rate" : [  ] },
"IF" : [
  { "data_is" : { "data" : [ "commerce-line-item:type" ], "value" : "shipping" } },
  { "data_is" : {
      "data" : [ "commerce-line-item:commerce-shipping-service" ],
      "value" : "swag_shipping"
    }
  },
  { "entity_has_field" : {
      "entity" : [ "commerce-line-item:order" ],
      "field" : "commerce_customer_shipping"
    }
  },
  { "NOT commerce_order_compare_address" : {
      "commerce_order" : [ "commerce-line-item:order" ],
      "address_field" : "commerce_customer_shipping|commerce_customer_address",
      "address_component" : "country",
      "value" : "US"
    }
  }
],
"DO" : [
  { "CONDITIONAL" : [
      {
        "IF" : { "commerce_order_compare_address" : {
            "commerce_order" : [ "commerce-line-item:order" ],
            "address_field" : "commerce_customer_shipping|commerce_customer_address",
            "address_component" : "country",
            "operator" : "is one of",
            "value" : "CA\u000D\u000AMX"
          }
        },
        "DO" : [
          { "commerce_line_item_unit_price_amount" : {
              "commerce_line_item" : [ "commerce_line_item" ],
              "amount" : "1000",
              "component_name" : "flat_rate_swag_shipping",
              "round_mode" : "1"
            }
          }
        ]
      },
      { "ELSE" : [
          { "commerce_line_item_unit_price_amount" : {
              "commerce_line_item" : [ "commerce_line_item" ],
              "amount" : "1500",
              "component_name" : "flat_rate_swag_shipping",
              "round_mode" : "1"
            }
          }
        ]
      }
    ]
  }
]

}
}

IMPORTANT NOTE: You may have trouble after you get your shipping working, to display your shipping line items in your Order display, for example in the Order acknowledgment e-mail that comes by default with Commerce. You need to make some rather complicated configuration changes to get this to work. Please see the article How to display all Drupal Commerce line items using a token if you get that far.


how to Add new Role employer also display in url like user/employer?

You can do this by using any of below module :

Registration role module. After register your self by user can directly assign the role.

  Registration role lets an administrator select a role to automatically
  assign to new users. The selected role will be assigned to new
  registrants.

Webform Rules module.

  This module adds rules integration on webforms. Webform Rules makes it
  possible to catch webform submissions by rules and do whatever you'd
  like to do with it.

Auto Assign Role - This module definitely solve your both the issues i.e assigning role after registration & passing role on URL.

  The Auto Assign Role serves three primary purposes :

  Provide an automatic assignment of roles when a new account is
  created.
  Allow the end user the option of choosing
  their own role or roles when they create their account.
  Provide paths that will trigger a specific role when an account is
  created.

For the user/employer url you also do this by using Path Auto module.

  The Pathauto module automatically generates URL/path aliases for
  various kinds of content (nodes, taxonomy terms, users) without
  requiring the user to manually specify the path alias. This allows you
  to have URL aliases like /category/my-node-title instead of /node/123.
  The aliases are based upon a "pattern" system that uses tokens which
  the administrator can change.

Multiforms module.

  The Multiforms module is designed for the collection of data from
  users. It can be used to easily author multi-page forms which are
  published as nodes. The data collected by the forms can then be
  exported. It was originally designed to handle contest.


How can I adjust the position of a cancel button added with hook_form_alter()?

Use the following code.
$form['actions']['cancel'] = array(
 '#type' => 'markup',
 '#markup' => $link,
);

If it doesn't work, check with print_r() where the submission buttons are added in the form array. Usually, it's $form['actions'], but sometimes can be a different array index.


Conditional rewrite on views according to singular / plural

Drupal views provides a singular/plural option, if the field value is an integer type. In your case, if its not available in Field settings try using views_php contrib module.

This module will allow you to add a field in views with php code that will executed on the fly. You can get existing values of row data inside php from $data variable. Now you can get your output based on the singular/plural in php.

But it is suggested to check the field settings properly if same option is available.


What is the right way of loading a service?

The standard way to inject services in other services is passing dependencies directly through the constructor:

mymodule.services.yml:

services:
  mymodule.foo_service:
    class: Drupal\mymodule\FooService
    arguments: ['@current_user']

While you can define a factory method in *.services.yml, see
https://symfony.com/doc/current/service_container/factories.html,
in Drupal the most common places for this are Controllers and Plugins which implement ContainerInjectionInterface::create or ContainerFactoryPluginInterface::create. See How do I use dependency injection on \Drupal::moduleHandler() to a Controller?
\Drupal::service... is largely used from procedural code when not in an OOP context, like hooks or static callbacks. See the comment from @Kevin.


How to use the Rules module for assigning a role during user registration based on a select field option?

You need to add a Rules Condition (after the one you already have) to check the value of field_selector.

With that your Rules Action should work. Though you also may want to add the Conditional Rules module to implement the "otherwise" part of your question.


How to migrate D6 node reference to D7 organic group membership?

I ended up using the advanced method as described in the semi-official documentation (https://drupal.org/node/2023273).  It all came down to modifying the query to get the nid and new group nid.

class MemberCompanyMembershipMigration extends DrupalMigration {
    /**
     * Construct a migration.
     *
     * @param array $args
     *   Constructor arguments passed at migration-registration time.
     */
    public function __construct($args) {

        parent::__construct($args);

        // Set the fields we want; document in the UI.

        $this->sourceFields += array(
                'nid' => t('Group node ID.'),
                'is_active' => t('User status in the group.'),
                'is_admin' => t('Group admin or not.'),
                'uid' => t('User ID.'),
        );
        $this->sourceOptions['map_joinable'] = FALSE;
        // Set the query as the migration source.
        $this->source = new MigrateSourceSQL(
                $this->query(), $this->sourceFields, NULL, $this->sourceOptions
        );
        // Map source rows to destination rows with uid+gid.
        $this->map = new MigrateSQLMap($this->machineName,
                array(
                        'field_contact_member_company_nid' => array(
                                'type' => 'int',
                                'not null' => TRUE,
                                'description' => 'ID of the group.',
                        ),
                        'uid' => array(
                                'type' => 'int',
                                'not null' => TRUE,
                                'description' => 'ID of the user.',
                        ),
                ),
                MigrateDestinationOGMembership::getKeySchema()
        );
        // Destination is group membership.
        $this->destination = new MigrateDestinationOGMembership();
        // Field mappings.
        $this->addFieldMapping('group_type')
        ->defaultValue('node');
        $this->addFieldMapping('entity_type')
        ->defaultValue('user');
        // Let the user migration map the uids.
        $this->addFieldMapping('etid', 'uid')
        ->sourceMigration('ClickUser');
        $this->addFieldMapping('state', 'is_active');
        $this->addFieldMapping('is_admin', 'is_admin');
        // Group migration maps the gid via the OG Node migration.
        $this->addFieldMapping('gid', 'field_contact_member_company_nid')
        ->sourceMigration('MemberCompany');
        // Minimal source config means we just set a default
        // instead of looking for roles to map.
        $this->addFieldMapping('group_roles')
        ->defaultValue(array(OG_ADMINISTRATOR_ROLE));
        // Accept defaults for these destination fields.
        $no_input = array(
                'created',
        );
        $this->addUnmigratedDestinations($no_input, t('Do Not Migrate'));
    }
    /**
     * Query for the source group data.
     *
     * @return QueryConditionInterface
     *   Provides a connection and query for getting OGMembership records.
     */
    protected function query() {
        $query = Database::getConnection('click2', $this->sourceConnection)
        ->select('content_type_contact_content','p')
        ->fields('p', array('field_contact_member_company_nid'));
        $query->join('node','n','n.vid = p.vid');
        $query->addField('n', 'uid');
        $query->isNotNull('field_contact_member_company_nid');
        return $query;
    }
    public function prepareRow($row) {
        if (parent::prepareRow($row) === FALSE) {
            return FALSE;
        }
    }
}


Is there a way to selectively export specific relevant configuration into custom modules?

I would use the awesome features module as a base to export complex configurations that contain multiple dependencies as a base of my new module and then start building my custom functionality. All major distributions are using features module as it saves a lot of time and it is very reliable.


Added menu link not showed in menu configuration

There are a couple possibilities for why your menu link isnt showing.

Have you checked that the menu being rendered is the same as the one you added the link? Typically, menus are rendered via Drupal's block layout settings. (Admin > structure > block layout) You can check that the menu rendered on your site is the same as the one you are adding the links to.
If using the Menu Block module, check that your menu block settings aren't set to display a fixed level of the menu or fixed trail.
Is the link you've added to a page or view on the site that has permission restrictions? This sometimes happens when trying to add custom admin routes.

If the settings above are correct, try flushing the drupal caches when updating menu links before checking on the front end.

In the case none of the above works, and you are on a development instance of the site, try switching to a standard theme (like Bartik) to quickly determine if somethingin your theme is preventing the links from rendering.


i18n + views, getting localized version of node

Add this to your Filter Criteria: "Content: Language (= Current user's language)."


Attaching a view with exposed filters block to user profile in D7

Having exposed filters in a block is really only meant for page views.

There is a work around for creating a block view that will work with an exposed filters block at https://drupal.stackexchange.com/a/38994/10729 - Note also the comment below the answer, which talks about creating a custom module for the block, which is much better than using the PHP input filter if you don't mind making modules.

Then you can assign the block to show on the profile page.

A potential downside is that you cannot reorder the view via the profile fields display admin area like you can with EVA. This may or may not be an issue depending on wheere exactly you are positioning the view.

You could also instead print the block manually in your theme on that page exactly where you want it, or you could even put the views_embed_view() line directly in your theme and not worry about the block at all.


mysqldump should just come bundled with MySQL. Have you tried running it from the command line? If you don't have/can't find mysqldump you should be able to use phpmyadmin to do export/import.


Custom URL using Taxonomy and Custom User information (Real Name)

You will be able to do quite simply with two modules Pathauto and Token I guess. Token will propose you any field as token and you can use it into pathauto config to generate your urls.


After logging off, a user is able to see the pages by pressing back button of the browser

This is a result of the browser caching the page, there's not a lot you can do about it really.

Some browsers might respond to setting cache control headers like the following:

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past

which might force the browser to re-load the page regardless of it's local cache.

There are apparently some options available to control this in Safari specifically, but I haven't been able to find anything for other browsers. I imagine the same would work for Chrome (being Webkit based), but I can't comment on the the other major browsers.


I thinks, you must twig ckeditor config file, and set config.allowedContent = true. Please, see docs http://docs.ckeditor.com/#!/guide/dev_allowed_content_rules

This links below can help you.

https://stackoverflow.com/questions/15659390/ckeditor-automatically-strips-classes-from-div

CKEDitor removes class names, even with the exception in config


Can't delete entities using entity_delete_multiple()

entity_delete_multiple() is implemented by the Entity API module, which is not part of Drupal.

In order to be able to delete entities with entity_delete_multiple() you need to do one of two things.

Define a deletion callback for your entity
Use a controller class that implements EntityAPIControllerInterface

In fact, this is the code used by entity_delete_multiple().

function entity_delete_multiple($entity_type, $ids) {
  $info = entity_get_info($entity_type);
  if (isset($info['deletion callback'])) {
    foreach ($ids as $id) {
      $info['deletion callback']($id);
    }
  }
  elseif (in_array('EntityAPIControllerInterface', class_implements($info['controller class']))) {
    entity_get_controller($entity_type)->delete($ids);
  }
  else {
    return FALSE;
  }
}

In the first case, you simply define a function similar to the following.

function basic_delete_entity($id) {
  // Delete the entity whose ID is $id.
}

You can use any name for the delete callback, as long as you refer it in your hook_entity_info().

In the second case, you normally sub class EntityAPIController. EntityAPIController::delete() should normally be sufficient.


Does the LDAP module encrypt directory queries?

As configured in your screenshot -- yes your queries are running in plaintext over the wire. This is similar to running MySQL on the default port and not running MySQL connections under SSL (which is also possible by sharing certs).

Securing network connections between Drupal and LDAP is dependant on your LDAP vendor. For instance your LDAP vendor may support ldaps:// (ldap using SSL) connection strings to connect to your server and a secure port (such as 636) and not require Start-TLS.

For some gritty details see details from the Open LDAP FAQ:
http://www.openldap.org/faq/data/cache/605.html

  The StartTLS extended operation [RFC 2830] is LDAPv3's standard
  mechanism for enabling TLS (SSL) data confidentiality protection. The
  mechanism uses an LDAPv3 extended operation to establish an encrypted
  SSL/TLS connection within an already established LDAP connection.
  While the mechanism is designed for use with TLSv1, most
  implementations will fallback to SSLv3 (and SSLv2) if necessary.

  ldaps:// is a mechanism for establishing an encrypted SSL/TLS
  connection for LDAP. It requires use of separate port, commonly 636.
  Though originally designed for use with LDAPv2 and SSLv2, many
  implementations support its use with LDAPv3 and TLSv1. Although there
  is no technical specification for ldaps:// it is widely used.

  ldaps:// is deprecated in favor of Start TLS [RFC2830]. OpenLDAP 2.0
  supports both.

  For security reasons the server should be configured
  not to accept SSLv2.

For example at my job they say to use ldaps:// and a secure port when connecting to our LDAP server. They say not to use start-tls. The configuration depends on your LDAP vendor and the version of LDAP you're using.


How can I use a content type field on the body of the e-mail message template on the Webform module?

After looking more the examples, I found this token:

[webform_submission:node:field_name_of_the_field]

I needed only to replace field_name_of_the_field with the field I want to use.


How to use hook_prepare to modify a field of a node before it is edited

The code that is provided by the page that you linked to is wrong. While this hook exists in D7 and while it is possible that during early D8 core development, in alpha or beta, it existed at one point. In D8 there is no such thing as hook_prepare.

As per the list of all D8 core hooks, it looks to me that hook got replaced with a newcomer hook called hook_ENTITY_TYPE_prepare_form

/*
 * Implements hook_ENTITY_TYPE_prepare_form
 */
function mymodule_node_prepare_form(\Drupal\node\NodeInterface $node, $operation, \Drupal\Core\Form\FormStateInterface $form_state) {
  if ($node->getType() == 'article') {
    // your code goes here
  }
}

and as always, anytime you implement a new hook, for the first time, clear the cache so it gets picked up by Drupal.


Render a view in a given language in a custom command

You should call:

Drupal::service("entity_field.manager")->clearCachedFieldDefinitions();

after language changes.


How do I solve this memory usage limited problem?

Currently migrate module does not support batch query for to get value of nodes. You need to apply one patch which work for you.


I've run into the same topics and found a solution, check it here: Autocomplete field - fill the selected id into another form element (eg. hidden field)


Detect the taxonomy term(s) of a node from within a template file

As alluded to in the first answer, you should use a preprocess function, but probably for the node template.

For the node.tpl.php template (and all derivatives) the function is defined as

MYTHEME_preprocess_node(&$vars) {
}

and should appear your theme's template.php file.

You must clear the Drupal cache in order to reset the theme registry such that Drupal recognizes and executes this function.

The $vars argument of the function is an array that contains all the template variables which subsequently appear in the tpl file ($vars['foo'] will be leveraged as <?php print $foo; ?> in the tpl file).

This also includes the native $node object, which will allow you to inspect $node->taxonomy, and create any subsequent variables accordingly. You can leverage these in the tpl file.

The best way to inspect and discover the components of $vars is to use the Devel module's dpm() function, which nicely prints any variable to the theme's messages box.

So, enable devel, create the following in template.php, clear cache, refresh viewing a node, and work from there.

MYTHEME_preprocess_node(&$vars) {
  dpm($vars);
}

You may also be interested in my session on Drupal preprocess functions from Drupalcon Copenhagen or the Drupal handbook page.