How to display nodes on front page with Search API?

I have very good experience in search api and the easiest way to display the search results is use module search_api_views (included into search_api).

Just create view for your search api index and select there required view mode and filtering criterias. Put this view on your front page and it will work.


Mobile navigation works on desktop resize but not on mobile devices

There is a jQuery error happening on your webpage.

You need to fix that either by trying var $ = jQuery.noconflit();
OR
Update the version of jQuery to 1.7, don't upgrade to version higher than 1.7 since jQuery 'on' function will not work.

Thank,
Vineeth


Difference between content type and content entity

Content Types are one of the main building blocks within a Drupal site; as the name suggests, content types hold content. However, different content types can hold different kinds of content; an event can hold information that is specific to a time, where a discussion can be used for people to talk. Most sites have multiple different content types, and the name of a content type will ideally give information about how it is used.

An Entity is a piece of data within a Drupal site. Nodes, users, comments, and taxonomy are all entities; additionally, with custom code, you can create new entity types if/when needed. You can also add fields to entities, which allows for things like detailed user profiles, or more sophisticated comment forms.


Your site will most likely work, but with some bad luck the files could cause errors. The reason is either a file permission issue or, less likely, that you had the files open and that they were locked for that reason.

To be on the safe side you should manually update the affected modules, i.e. delete the directory and replace it with a downloaded copy. Then run the update script.

Do this for the affected ones:

http://drupal.org/project/ckeditor
http://drupal.org/project/imce
http://drupal.org/project/menu_token
http://drupal.org/project/recaptcha


Form fields getting cleared off of user inputs after validation errors

I reckon using the ternary conditional operator to check if there is anything in $form_state['values'] would get there, i.e. something like:

$default_value = 'Test Default Value';

$form['test'] = array(
  '#type' => 'textfield',
  '#default_value' => !empty($form_state['values']['test'])?$form_state['values']['test']:$default_value,
);


How can I parse php code from another file during nodeapi function?

As i get you, you need to implement hook_theme and use it, instead parsing php code.

Please, see anwser here: https://stackoverflow.com/questions/12985689/how-to-implement-hook-theme-in-drupal-7


Please confirm you got any value from arg(2) which is equivalent to term id(tid) .

Try this code

$result = db_select('taxonomy_index', 't')
  ->fields('t')
  ->condition('tid', arg(2), '=')
  ->execute()
  ->fetchAssoc();

$node = node_load($result->nid);

print_r($node);


How to expose a persistent variable as a field for use in view

Your instincts are correct (and you're right about the lack of examples too).

In order to add a custom replacement pattern / token, you'll need to extend a Views field handler class and override the document_self_tokens() and add_self_tokens() methods.  You can then instruct a field to use your custom field handler via hook_views_data_alter() (thanks to Daniel Wehner for this info, and very likely the hook itself).

You can see example code from my need for adding a Views field replacement pattern / token.

If you need help adapting it for your need above provide the field or fields you'd like the replacement token to appear for and maybe more on how you'd like to construct it, but if you look at my example and remember to list in your .info the file with your field handler extending class so that Drupal registers it, you'll probably be all set.

(In giving the same answer over here, i also commiserated about the confusing naming of Views rewrite field replacement pattern "tokens" versus Drupal's Token API tokens.)


Maybe try this:

// Example: Assume we have a node with nid 1 which contains a single
// language-neutral date field named field_date.
$node = node_load(1);
$date = $node->field_date[LANGUAGE_NONE][0];

// Create a date object.
$date_object = new DateObject($date['value'], new DateTimeZone($date['timezone_db']));
// Convert from the database time zone to the user's time zone.
$date_object->setTimezone(new DateTimeZone($date['timezone']));

// Example: Print a formatted date.
print date_format_date($date_object, 'custom', 'Y m d');

Source: Convert a date field to the correct time zone


Why is doing KernelTests Code Coverage so slow?

A kernel tests actually installs Drupal (in-memory only, but still), that means it runs thounsands and thousands of lines of code.

You can't really do anything to change that, xdebug (I guess you use that) would actually have to support a native whitelist to keep the overhead minimal, but that would in turn also result in overhead.


Why is drupal_json_output only returning page HTML?

You have an error in your Javascript, you're trying to use PHP syntax to concatenate the URL (the . symbol). As it is you JS shouldn't be running at all which is why the callback isn't being called. Your module code looks fine. Just change your JS to this:

jQuery(function($) {
  $.ajax({
    url: 'fetch/explore/' + category, // + instead of .
    success: function(data) {
        console.log(data);
    }
  });
});

Just to clarify, if the ajax call is going through despite the syntax problem the HTML response you're getting might be a 404/403/500 error page caused by the wrong URL being called.


drupal 7 profile 2 how to create field profile url as NAME

Worked it out finally.

You need to add fields in correct order to then use replacement which is [url]

for link to profile name.


You need to use the file resource to upload the file first; that will provide you with a fid (file ID), which gets attached to the field on the node. The payload for that request might look something like:

{
    "filename": "foo.jpg",
    "target_uri": "bar/foo.jpg",
    "filemime": "image/jpeg",
    "file": "iVBORw0KGgoAAAANSUhEUgAAAKQAAAFzBAMAAABC179RAAAAD",
    "filesize": "12345"
}

And then to attach it the field your existing code will change to something like:

"field_image":{
  "und": [{
    "fid": [FILE ID RECEIVED FROM FILE SERVICE HERE]
   }],
}


How can I generate commerce file audio preview automatically?

This sounds like an awesome companion module that could be created and would be popular. From a bit of Googling, you can use SOX or FFMPEG-PHP and the exec() command to actually trim the audio file. From there, it's just a matter of saving this audio file to a new field. I would not use rules unless you need to expose it in the interface for some reason. You could easily achieve the programmatic saving of an audio field (probably a specialized file field) using any of a number of examples out there on the web.

Found an example here: https://stackoverflow.com/questions/7884960/ffmpeg-php-code-example-to-trim-mp3-file

<?php
exec('$ sox input.wav output.wav trim 0 10');
?>


Query to get termID, term name and number of posts that has that term

See the example for Views Group By -- "List top 10 most frequent terms applied to a specific node type and the number of nodes for each term."


How to edit markup on existing pages using version 4 of the CKeditor library in Drupal 6?

CKEditor Version 4.x is known to have 'some' issues, at least when used in DRupal. The issue you described in the question here is probably one of them. And it doesn't matter if you use the CKEditor 'module', or the WYSIWYG 'module' (in combination with the CKEditor 'JS library'). Because for both modules these issues exist.

In my experience, going back to CKEditor 3.6.x version (or never upgrading from 3.x to 4.x) has always been the best "compromise", since in the 3.x versions these issues seem to not exist.


How to replace usage of static Entity::load method calls for better testability?

My workaround is (without changing legacy code):

   $entityManager = $this->getMockBuilder('\Drupal\Core\Entity\EntityManager')
      ->disableOriginalConstructor()
      ->getMock();

    $entityManager->expects($this->any())
      ->method('getEntityTypeFromClass')
      ->will($this->returnCallback(function ($class_name) {
        return $class_name == 'Drupal\taxonomy\Entity\Term' ? 'taxonomy_term' : '';
      }));

    $term = $this->getMockBuilder('Drupal\taxonomy\Entity\Term')
      ->disableOriginalConstructor()
      ->getMock();

    $termStorage = $this->getMockBuilder('\Drupal\taxonomy\TermStorage')
      ->disableOriginalConstructor()
      ->getMock();

    $termStorage->expects($this->any())
      ->method('load')
      ->willReturn($term);

    $this->termStorage = $termStorage;

    $entityManager->expects($this->any())
      ->method('getStorage')
      ->will($this->returnCallback(function ($type) {
        return $type == 'taxonomy_term' ? $this->termStorage : NULL;
      }));

    $this->container = new ContainerBuilder();
    $this->container->set('entity.manager', $entityManager);
    \Drupal::setContainer($this->container);


To extend @Pierre.Vriens answer , you could then add a rewrite rule to make the urls a bit nicer

assumptions

you've got public files set up
you've got a url 'normalisation' (either symlinks in files directory or 301s)

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /sites/%{HTTP_HOST}/files/$1 [L]

in your host will take

http://www.example.com/filename.pdf

and rewrite it to

http://www.example.com/sites/www.example.com/files/filename.pdf

what do i mean by url normalisation ?
well, if you can get example.com - then you'll get a 404 - as the folder in the sites directory is www.example.com

an easy solution is to use symlinks in the sites directory, or to use 301 redirects

to use symlinks, assume you have

sites/www.example.com

you could then create a symlink to it as follows

ln -s www.example.com example.com

this would create a symbolic link from

sites/example.com

to the www.example.com folder. this means that both www.example.com, and example.com would be found when the rewrite rule runs


There might be other more convenient solutions but this is a quick one, in some cases it wont work or suit at all (it will work on pages with clean urls), but you can perform current path validation by this code:

$destination = drupal_get_destination();
$destination = $destination['destination'];

// validate if path contains "?" from exposed filter

if (preg_match("/\?/", $destination)) {
return FALSE;
}
else {
return TRUE;
}


You have done everything I would have done.

Try a different path to ckeditor library. Install the libraries module and put the ckeditor library under libraries/ckeditor/ckeditor.js.

Try uninstalling the Drupal CKEditor module and go with the WYSIWYG module and see if that helps.

Also, try with different versions of jQuery. Sometimes the newer versions (1.9+) conflict with a lot of modules, though 1.7 which you are using is the sweet spot I have found.

And lastly try with an older version of CKEditor plugin.


Charging UserPoints for flagging a node with Rules in PHP

When you simply want to grant 10 userpoints to a user after flagging a node, you're making things way to complicated! This can be done without custom coding at all. Here's what you have to do:

Create a new rule.
Add an event "A node has been flagged, under YOUR_FLAG".
Add an action "Grant points to a user" and give it an amount of 10.
Done!


how to display all content for the people table

There is no table {people} in the database.  However, the way I understand this question, you want to display everything that is recorded about all user entities (i.e. you want the list of user entities that is shown under People in the admin interface expanded to include all the fields attached to such entities).

In that case, you can install the Views project and enable the Views and Views UI modules (both part of the Views project). The recipe below assumes you're using Views 3 on Drupal 7. Older versions are different.

Navigate to Home » Administration » Structure » Views and click Add a new view. Give the view the name "Users", and select "Users" from the Show pull down menu.  Click Save & Exit.  This will give you a page view showing all users, but no fields.

Now, return to Home » Administration » Structure » Views, locate the view named "Users", and click Edit.

Next, locate the "Fields" widget, and click Add.  Filter on "User".  This will show all fields defined for the user entity (except pass), with a checkbox for each.  Check all boxes and click Apply (all displays).  Now you've get to configure how to show each of the fields.  You can of course do a lot of fine tuning here, but I find it better to do that later, after the view is fully populated with fields. So just click Apply (all displays) to each of these.  AFAIK, this gives you access to all the fields in the user entity except pass (which holds the user's hashed password, and is excluded for security purposes).

After you've added all, there will be a preview at the bottom of the page.  At this stage, the listing will not be pretty, but you can fine-tune how this appears later, by editing the format of the view.

When done editing, remember to click Save (near top of screen) to save the view.

If your objective is to export this data, there are deveral modules let you export lists produced by Views. One of these is Views Data Export.


Two Blocks for sort filter Views -- Drupal 7

I dun really get what you mean. I presume you are trying let admin or user to able to do sorting.

I have two ideas

Under format change from unformatted list to table. At this case you are able to do sorting by click table header.

Another one is under sort criteria, add any content you want to sort and select expose.

If I wrong, can show me any example??


Did you rename all the functions in the template.php file as well? These need to start with your theme name ;-)


How to manage a views term filter at run-time?

Is it necessary to use a "Filter"? If you can use a "Contextual filter" instead, then this should work without you needing to specify which terms are allowed.

Another, much more complicated option, would be to implement hook_entity_insert and update the Views configuration on new terms.


The function decode_entities works as you expect.  It converts the HTML entity (&#039;) into a single quote and returns the decoded string.

However, that single quote will be expanded into an entity again at some point downstream, when the page is rendered.  This is what inserts (provided you spell "description" correct) the following into your page's <head>:

<meta name="description" content="We&#039;re in this together" />

I would not worry about this.  The above is a perfectly valid HTML meta-tag and will be interpreted correctly for SEO purposes, etc.


Display children of taxonomy term in parent taxonomy page

Create a view of taxonomy terms
Create a block display for the view
Add a contextual filter for vocabulary ID
Make the block show up on all vocabulary pages in the block settings.


how can I change digits from latin to persian digits

You can use persiantools module, it change digits from latina to persian and some another features.....

persiantools


How to read a Drupal 7 node as a css file?

If you know that Drupal isn't meant to be used this way, then why would you do it? Are you trying to allow the end user to edit the CSS through the UI? There are better tools for that! (eg. Live CSS, Sweaver, Live Themer...)

If you update your question and tell us which problem you're trying to solve, we can help you much better.


How to use hook_form_alter to change the cancel link

I think you're just missing an ampersand (&) in front of $form in the first line of your code.


You can make a custom template taking views-view-rss.tpl.php as starting point.
See the template under modules and views/theme/views-view-rss.tpl.php


Views to Recognize my Custom Entity's One-to-Many Reference

That's currently a gap in the automatic entity views data integration, it can only do multi-value configurable fields.

Work is going on to improve this, not sure if it will make it into 8.1 now, probably it will have to wait for 8.2, but you could already use the patch: https://www.drupal.org/node/2477899


Is there a risk of having xmlrpc.php on my site?

You are save. At least to what we know now.

The first linked article is wordpress related. This is totally different code. Not drupal related at all!

  Drupal had a known security flaw in versions lower than 6.38 / 7.43 /
  8.04

So your version 7.56 is patched. Always make sure to update to the latest version and you're good.


Navigate to next page / previous page based on entity reference field instead of Book module

I can code a little but I'm not very good so I'm having trouble
  finding an approach to implement this.

I started 7 years ago from zero, I only knew HTML and CSS. I learned and mastered Rules & Views. But like 4 or 5 years ago, I ran into scenarios like this one where the existing modules didn't quite do what I needed or felt I had to do overkill/bulky-overhead workarounds with existing modules. So I learned PHP from online resources and I learned how to create custom modules for Drupal.

I highly suggest you improve your backend/coding game. Specially since Rules in D8 is barebones compared to D7.

  I tried to build this in Views. The problem I encountered was that it
  is very difficult to iterate through the subdivision entity reference
  field and filter out the previous and next links.

While it's possible to programmatically solve it with Views, it feels overkill/unnecessary to do this in Views just for prev and next links. A better approach is to create prev_url and next_url variables for Twig. Using a preprocess function we can create and pass those variables to the appropriate template file, node.html.twig in this case.

I've put lots of comments, so you can follow and hopefully learn a thing or two.

In mytheme.theme (since this particular hook can also be used in theme, rather than creating a custom module).

/**
 * Implements hook_preprocess_HOOK() for node.html.twig.
 */
function mytheme_preprocess_node(&$variables) {
  $node = $variables['elements']['#node']; // obtain current page node object
  if ($node->getType() == 'page') { // check it's a "page" content type
    $page_nid = $node->id(); // get the current page node id
    // get Chapter nids using Entity Field Query
    $query = \Drupal::entityQuery('node')
      ->condition('type', 'chapter')
      ->condition('field_reference', $page_nid); // check if current page NID is set on any Chapter's reference field
    $chapter_nids = $query->execute(); // returns array of Chapter nids
    if (!empty($chapter_nids)) { // check we have a result
      $chapter_nid = reset($chapter_nids); // Extracts the first array value, since we assume current page can only belong to one Chapter.
      $chapter_node = Drupal\node\Entity\Node::load($chapter_nid); // load chapter node
      $referenced_page_nodes = $chapter_node->field_reference; // get referenced nodes
      foreach ($referenced_page_nodes as $key => $referenced_item) { // loop though referenced nodes
        if ($referenced_item->entity) {
          if ($node->id() == $referenced_item->entity->id()) { // check if current page nid equals referenced nid
            $prev_key = $key - 1; // we'll use these keys to access prev/next array values
            $next_key = $key + 1;
            if (!empty($referenced_page_nodes[$prev_key])) { // check if previous key exists
              $prev_url = $referenced_page_nodes[$prev_key]->entity->toUrl()->toString(); // get prev URL
              $variables['prev_url'] = $prev_url; // creates prev_url variable in node.html.twig
            }
            if (!empty($referenced_page_nodes[$next_key])) { // check if next key exists
              $next_url = $referenced_page_nodes[$next_key]->entity->toUrl()->toString(); // get next URL
              $variables['next_url'] = $next_url; // creates next_url variable in node.html.twig
            }
            break; // since we found it, exit from loop as no point in continuing to loop through.
          }
        }
      }
    }
  }
}

Note: Rename field_reference (2 places) to the machine name of your actual reference field in Chapter content type.

In mytheme/templates/node.html.twig, you can place them after the {{ content }} part

{% if prev_url is not empty %}
  {{ 'Previous page'|t }}
{% endif %}
{% if next_url is not empty %}
  {{ 'Next page'|t }}
{% endif %}


Solved by Clive. I had memcached running. It had stored chunks of the code from my original site and tried to run them on the new version. Clearing or restarting memcached solved the problem.

Edit:

An overly simplified explanation of memcached for anyone who's unsure what I'm talking about.

Memcached caches chunks of code. It's best illustrated by a contrast. Varnish caches a static picture of a page and sends that to people when it's requested. It will bypass PHP processing completely.

Memcached won't stop the processing for the page happening each time, but it will remember chunks of the processing and deliver the result straight from the cache.

When I wiped my server and reverted to a backup I forgot to restart memcached. This means that memcached had still remembered chunks of my PHP code. This code didn't fit in with the older revert of my website so I got a horrible error. Restarting memcached or flushing the memcached cache will solve this.


A View for Referenced and Referencing Nodes


An illegal choice has been detected. after leaving form page

You change the options after the form is built:

 $select_form['expeditions']['#options'][$value->{'expedition'}->{'expeditionId'}] = $this->t($value->{'expedition'}->{'expeditionTitle'});

The Form API doesn't know about this. On submit the Form API checks if the submitted option is in the original option list. If not, it rejects the submit with the error "An illegal choice has been detected. Please contact the site administrator."


How do you get template preprocess functions to fire on hook theme suggestions?

You need to do this before you can do that...

/*
 * Implements hook_preprocess_field().
 */
function YOURTHEME_preprocess_field(&$vars) {
    if ($vars['SOME_FIELD']) {
        $function = 'YOURTHEME_preprocess_field__'.$vars['SOME_FIELD'];
        if (function_exists($function)) {
            $function($vars);
        }
    }
}


Browscap doesn't seem to hide blocks on google chrome for android

Using Browsecap (AKA 'user agent sniffing') will always be error prone, because there are so many different browsers, all with different user agents.

Instead, consider implementing a responsive design, using CSS3 media queries, to hide certain elements based on screen width.


Limited permissions for users logged in with facebook and twitter

You could use Rules to automatically assign them specific roles, then limit permissions based on those roles.

A few ideas about how to work with rules and auto-assigning roles.


How to modify module output via another module - whois module?

You can change the output through preprocessing, for example in your theme's template.php file, or in your custom module (see also: https://api.drupal.org/api/drupal/modules!system!theme.api.php/function/hook_preprocess_HOOK/7).

The $variables['content'] variable contains the content of the block to be displayed. The individual elements come from $variables['elements']. If you add:

debug(array_keys($variables['elements']));

to the script, you get the following output:

array (
  0 => 'whois_form',
  1 => 'whois_lookup_data',
  2 => '#block',
  3 => '#weight',
  4 => '#theme_wrappers',
  5 => '#children',
)

When looking at these in detail, you see that $variables['elements']['#children'] is comprised of $variables['elements']['whois_form']['#children'] and  $variables['elements']['whois_lookup_data']['#children'].

Ultimately, $variable['content'] is comprised of $variable['elements']['#children'] (see also https://api.drupal.org/api/drupal/modules!block!block.module/function/template_preprocess_block/7)

So, there are two options:

Alter $variables['elements']['whois_lookup_data']['#children'], and
recreate $variable['elements']['#children']
Alter $variable['elements']['#children'] directly.

I chose the second option below.

To use the hook_preprocess_block hook, as shown below, the core module "Block" needs to be enabled.

If used in a module, in yourmodule.info:

name = Whois Alter Module
description = A module to change the output of whois.
core = 7.x
package = Drupal 7 Misc
files[] = whois_alter.module
dependencies[] = block
dependencies[] = whois

In whois_alter.module:

<?php
// $Id$
/**
* @file
* A module to demonstrate hook_preprocess_block to alter the output of another module
*
* This module alters the output of the whois module
*/

/**
* Implements hook_help().
*/
function whois_alter_help($path, $arg) {
  if ($path == 'admin/help#whois_alter') {
    return t('A module to alter whois output.');
  }
}

/**
* Implements hook_preprocess_block().
*/

function whois_alter_preprocess_block(&$variables, $hook){

  if (isset($variables['elements']['whois_lookup_data'])) {
     $whois_modified = whois_alter_modify_whois($variables['elements']['#children']);
     $variables['elements']['#children'] = $whois_modified;
     $variables['content'] = $variables['elements']['#children'];
  }
}

function whois_alter_modify_whois($content) {
   // do what you want to do to modify the output
   return $altered_content;
}

For Theme preprocessing, just use the functional part of the module in template.php:

function yourtheme_preprocess_block(&$variables, $hook){

  if (isset($variables['elements']['whois_lookup_data'])) {
     $whois_modified = yourtheme_modify_whois($variables['elements']['#children']);
     $variables['elements']['#children'] = $whois_modified;
     $variables['content'] = $variables['elements']['#children'];
  }
}

function yourtheme_modify_whois($content) {
   // do what you want to do to modify the output
   return $altered_content;
}


Providing menu route parameter values from url

It may not be the best solution, but you could add an additional route and link to that in the menu, this route would link to something like /admin/ej_profile. Then via the controller get the current user information and redirect immediately to the correct profile form.


Severe health issues are found on your site

There's nothing in your robots.txt file that is out of the ordinary and for the most part you probably want to keep all of those exclusions, checks, etc. to save on bandwidth and for security. The health message you're seeing is likely due to another issue within the site or maybe just a temporary Google hiccup that will resolve itself shortly. Are there any other messages within the Google Webmasters page that indicate other issues, ex. permission problems?

Another possibility is to submit an XML Sitemap to Google directly to tell it exactly what you are expecting it to index:

http://drupal.org/project/xmlsitemap

I've found that this resolves some Google crawl issues in the past.


Block taxonomy list count with filter by search term?

Contextual Filter Wont do here. Please follow these steps:

Add another field "Taxonomy:term name".
Under the advanced settings tab, turn on SQL Aggregation.
Edit the sql aggregation settings against the newly added field "taxonomy term" to make it "COUNT". Not "COUNT DISTINCT" remember.
If there is any sort option, please remove it for this to work. Let the filter remain as it is.
Now you will have taxonomy tags, with the number of nodes against each.


You can change this under the field settings for your date field.  If you edit your date field, you should see a "More Settings and Values" section:

You'll just have to set the default end date to "No default value"


You need to make a custom drupal module then implement a form alter to add a #field_prefix to the form element.

In this case specifically, it would be like this:

/**
 * Implements hook_form_alter().
 */
function MODULE_NAME_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'FORM_ID') {
    $form['FIELD_NAME']['#field_prefix'] = t('PREFIX_TEXT');
  }
}

You will need to change the following in that code sample to suit your form:
MODULE_NAME: The name of your custom drupal module.
FORM_ID: The form id of the form you want to alter. In this case the forward form.
FIELD_NAME: The machine name of the field you want to add a prefix to.
PREFIX_TEXT: The text you want to put in front of the field.

To work out the form id of the form you want to alter, install the devel module, and just inside your form alter function add the following line:

dpm($form_id);

Now whenever you load a page you will see the form ids for all the forms on the current page, so go to the page with the forward form and you will see the form id.

To get the field machine name of the field you want to add the prefix to you use the same method.

So after you have added the form id to the code sample, then just inside that if statement add:

dpm($form);

Then when you go to the page with the form on it you will get a display of the form, which you can click to expand.
Expand it and you will see a list of the form elements in the form, the keys are the machine names of the elements.

When you are done you can remove the dpm() calls and uninstall the devel module.


Reuse/sync view mode display settings across entity bundles?

Multiple solutions, pick what works best for you..

View modes

If you really want to work with view modes, there might be ways to copy the settings around between bundles. This still leaves you with lots of redundancy. So maybe not the preferable solution.

Views fields

If you work with Views, you can use views fields instead of view modes. These have their own advantages and drawbacks. You cannot use a layout (afaik). And now you cannot reuse the fields configuration across views.

So..

views fields: reuse across entity bundles, but not across views.
view modes: reuse across views, but not across entity bundles.

Ctools content panes / panels

Panels configurations can be reused in different places.

I personally do not use them as much, so I am sure someone else could write more about it.

Entity display plugin / Renderkit.

You can use EntDisP, to configure an entity display from multiple components. (This is using components from Renderkit.)

The module gives you a views row plugin, and a views field handler. So you can create an "entity display" for the entire row, or you can combine it with views fields.

It also gives you field formatters for entityreference, taxonomy term reference, paragraphs, and field collection.

You can configure the entity display in the place where you use it, so it will be stored as part of the view, field formatter, etc.

Or you can configure it as a "preset" with CFR Preset, so it will be stored independently and can be reused in different places. Such presets can be exported as features.

You can embed view modes in entity displays.

You can also embed entity displays in view modes using EntdispFieldUI.


Maybe you're looking for the Domain 301 Redirect module. Here is a quote about it (from the module's project page):

  ... allows sites to 301 redirect to a domain that is marked as the main domain. This means you can have all subdomains and other domains pointing to the site 301 redirect to a domain that you choose as the main domain. This provides great SEO benefit.


If you only want to change the title of an menu item, you should be able to do this through the administration. Go to admin/structure/menu and edit the correct item in your secondary menu.

To use hook_menu_alter() you must add it in a custom module not inside your template file. Remember to clear you cache in order for the changes to take effect. To clear the cache you can goto admin/config/development/performance.


Having Problem editing product displays created by Commerce Feeds to add product flag link

As pointed out in the comments, this was resolved by using commerce reference flag and adjusting my flag and displays.


There are many similar questions on Drupal Answers.

$subquery = db_select('cap_boat_to_pas', 'cp')
  ->fields('cp', array('pas_uid'));

$query = db_select('cap_pas', 'cp')
  ->fields('cp')
  ->condition('cp.pas_uid', $subquery, 'NOT IN');

results = $query->execute()->fetchAll();

Note: to write this in a single query (by using joins), take a look at leftJoin().


How to handle multiple stores and multiple store admin users

I am currently working on a similar project and I am using commerce marketplace. Had faced some issues, but overall it was a smooth journey using marketplace. Also, it is not difficult to implement.


Load custom form into contents of a specific content type

You can output form as block, then output this block in region and set block's visibility options to show only on specific content types:

/**
 * Implements hook_block_info().
 */
function mymodule_block_info() {
  $blocks = array();
  $blocks['my_block'] = array(
    'info' => t('Block with form'),
  );
  return $blocks;
}
/**
 * Implements hook_block_view().
 */
function mymodule_block_view($delta = '') {
  $block = array();
  switch($delta) {
    case 'my_block' :
      $block['content'] = drupal_get_form('mymodule_custom_form');
      break;
  }
  return $block;
}
/**
 * Form example.
 */
function mymodule_custom_form($form, &$form_state) {
  $form = array();
  $form['text'] = array(
    '#type' => 'textfield',
    '#title' => t('Place your form fields here'),
  );
  return $form;
}

Clear cache, go to blocks page (/admin/structure/block), assign your block to region. Go to your block configuration page and define Visibility settings on Content types tab.


How to add 1000 nodes of the same content type in just one step?

Feeds module will also allow you to import content/create nodes via CSV.


You can use DownloadFile module. This module provides display formatter, for images, file etc, that uses downloadable links(of type: /download/file/fid/[fid]) and should be compatible with older browsers.

Note:

If you are doing custom coding, you can use file id (fid) to create your download link.
You must upload the image, so that it can be assigned a file id.


How do you find out which module is causing a redirect?

If we're talking Drupal redirects (i.e. drupal_goto calls), the Devel module could help out here. In its settings it has a Display redirection page option that halts redirection for inspection.

You can use this in conjunction with a hook_drupal_goto_alter() invocation to dump a stack trace on the redirection halt page to find the origin of the drupal_goto call.

function MYMODULE_drupal_goto_alter(&$path, &$options, &$http_response_code) {
  ddebug_backtrace();
}


How do I add an Organic group to my main menu?

I love the new screeencast for OG, it explains it really well.

When you install OG it creates a few "views" that you can use. "OG list" view shows you a list of all the groups (you might have to enable the view if it's disabled).

Then create your menu item "groups" and use "group-list" as the path.

You can add specific "group nodes" to a sub-menu by editing the nodes and using the "provide menu link" feature. I believe not every theme uses submenus, for example Bartik doesn't by default.


Displaying associative array data in twig

Sollution:

Associative array:

array_push($mealsArray, ["meal" =>
  [
    'strMeal' => $mealTitle,
    'strMealThumb' => $mealImage,
    'mealUrl' => $mealTitleUrl
  ]
]);

Twig:

{% for meal in meals %}
      {% for fields in meal %}

{{ fields.strMeal }}

        {% endfor %}
    {% endfor %}

The return statement remains unchanged.


I believe hook_node_presave() along with user_load() is your answer

something like this:

function hook_node_presave($node) {
if($node->type == 'webform') {

$uid = user_load($node->FIELDOFUID);

$uid->mail;

// do your mail send here with $uid->mail;

}

}


Token replacement pattern for triggered rules on node creation

This should be possible with the the above modules.

You do not need to get data from the form/form_state.

I'm assuming the data you want is from a cck field because you're sending the email when a new node is created.

Rules has the "Replacement patterns for saved content" field set for pattens.

In there there's going to be cck specific token replacements. You can use those cck tokens to get the data you want.

These replacement tokens will look like [node:field_name_of_your_field-formatted]

Also make sure you're using the "After saving new content" event.


MimeMail is not MIME encoding url images in email

That's correct. Mime Mail is still in alpha and that feature isn't working correctly yet. If this feature is important to you please participate in the issue queue at https://www.drupal.org/project/mimemail
Images are usually only delivered as attachments if they are not publicly accessible on the server. A complete link to an external image should work just fine in any email client.
But let me also note that there is something going on that you didn't mention - the Mime Mail module will NEVER use 7-bit encoding, and will NEVER use quoted-printable encoding. So it's quite possible that you're doing something that breaks the behaviour of Mime Mail.


How to make Dynamic Term Link based on content type?

The easiest way to achieve this is by using Views.

The links rendered in Taxonomy fields (Entity reference fields) are set to go to Taxonomy term pages. The links are constructed with Taxonomy term ID in the URL: taxonomy/term/[TID].

Taxonomy term pages are created using Views, so you can easily Edit the relevant Views to adjust it to your needs. The modification you're after is adding a Contextual filter that filters out only one content type.

With that modification you could type, for example, taxonomy/term/10/article in the browser address bar, and the usual Term page for term 10 would list only results of the Article Content Type.

The other part of your question is how to make the Taxonomy reference link on the node View be sensitive to the Content type it's on, so when it's clicked it goes to the filtered list, and not the general term page that shows all results.

The easiest way to do that is to hide that field from displaying and replace it with a Views Block that would output a similar link, only Contextually sensitive to the term, and to the Content type.

Here are the steps on how to achieve this:

Make term pages sensitive to Content types

Duplicate the Taxonomy term View (it's better to keep the default ones as they are, so you don't mess up the original features and it makes updates more straightforward). Rename it to make sense (Taxonomy term-Content type)
Add a new Contextual Filter Content type from the Content Category (keep the one sensitive to the taxonomy term that is already there, we need it) and configure it with these options:
When the filter value is NOT in the URL
Display all results for the specified field
When the filter value IS in the URL or a default is provided
Override title
Content tagged with {{ arguments.tid }} of type {{ arguments.type }}
Specify validation criteria
Validator Content type
Validate user has access to the Content type
More
Transform spaces to dashes in URL
Edit the Path to add another % to react to the Contextual filter we just added, so you end up with the Path: taxonomy/term/%/%
Go to the other Display in the same View called Feed and edit the Path there to read taxonomy/term/%/%/feed
Save the View. You can test it by entering the relevant arguments into Preview inside Views (for example 10/article) or by typing the URL into your browser addressbar (example.com/taxonomy/term/10/article).
Optional but good UX: add No results behavior Text area No content of type {{ arguments.type }} tagged with {{ arguments.tid }} has been found. on your Page display and override for that Display only This page (override).

Create taxonomy links on Nodes sensitive to CT

To create links sensitive to the context we need Views Display Block of type Content. We can add it to the Views we created above (because that View is of type Content), or create a completely new View for this. Since this Block Views will be sufficiently different it's better to create a new View for this. Here are the steps for adding a new  Views to accomplish this:

Create a new Views of type Content showing Fields, add a Block Display to the View, change its name to something meaningful you can recognize later on Blocks page: Taxonomy term link sensitive to CT
Add a Filter to limit to your desired Content types (event, course, video)
Under Format option Show settings choose to Hide empty fields
Add a new Field City (or whatever your field is called), Exclude from display, and don't tick Link label to the referenced entity
Add a new Field Content type, Exclude from display and set Formatter to Entity ID (so you get CT machine name so the contextual filter later works correctly)
Add a new Relationship Taxonomy term referenced from field_city and Require this relationship
Add a new Field Term ID (it will use the Relationship from previous step), Exclude from display and set Formatter to Unformatted
Add a new Field Custom text from Global Category and configure it:
Create a label just tomake it easier to build, enter Taxonomy link sensitive to CT
In Text area enter {{ field_city }} (type { type }})
Rewrite results
Output this field as a custom link
Link path: taxonomy/term/{{ tid }}/{{ type }}
Replace spaces with dashes
No results behavior
Hide if empty
Add a new Contextual filter ID from Content Category and configure:
When the filter value is NOT available
Provide default value
Content ID from URL
When the filter value IS available or a default is provided
Specify validation criteria
Content
[your CTs video course event]

Now when you enter a node ID into Preview it will show the link to taxonomy term page that has content type argument added to it at the end.
Set Pager to Display a specified number of items to 1 item
Remove the Title field so you end up with only the Custom text visible and Save the View
Place the Block in Content region, don't Display title, set Content ID to Node from URL, limit which Content type to show the Block on
Edit your Content types (all three) Manage Display to hide the City Taxonomy Field (drag to Disabled)

And now you have the relavant Taxonomy term link that has the added Content type at the end to call on Views term page that will filter out only that content type.


Is there any harm is manually modifying file_managed status?

No there's no harm in modifying the table manually, as long as you know what you're doing.

If there are no references to the file in the file_usage table, and you don't need the file any more, it's perfectly safe to simply delete the line from the file_managed table. Alternatively you could set the status for that file to zero in the table, and let it be deleted automatically on Drupal's cron run.

The advantage of doing it that way is that the physical file is also deleted automatically so you don't have to clean up yourself.


I used something else in the end as I couldn't get the module to work, so used cookieassistant.com in the end. As for the speed, thanks for that, I think it's down to good hosting to be honest. – pixelshrink


What payment gateway should be used for invoice payment?

Yes - just create a new (custom, standard) payment method named Invoice, and user's then can select that.
On the payment method edit form you can add more details, and even could limit the availability of the method.
Rules are not actively supported as in D7: https://www.drupal.org/node/1535554
But I do not see a need using rules with your use-case.
You need to configure your invoice type to send emails, there should be a checkbox: Email the customer a confirmation when an invoice is generated - see https://www.drupal.org/project/commerce_invoice/issues/3089861
The invoice is attached by default and you can remove the attachment with hook_mail_alter, it's using the id invoice_confirmation. See https://git.drupalcode.org/project/commerce_invoice/-/blob/8.x-2.x/src/Mail/InvoiceConfirmationMail.php (UPDATE: The invoice types seem to create invoices for all payment methods and is not (yet) configurable to limit them)
See also the commerce-invoice-confirmation.html.twig to change the email.
Not attaching the PDF makes the emails smaller, and maybe passes more SPAM filters .. But users need to take action and press a link .. I would discuss that with the customer or maybe try both and gain experience with them. (Like what method is really paid more, and which one is faster)
UPDATE:
If you only want to send the invoice for one payment method you need to alter the commerce receipt email (id: order_receipt) and attach the invoice there. You'll find the order entity in the body's theme render array (first entry using #theme commerce_order_receipt)


Disable the default username in the registration form

To disable a field in a form you must use hook_form_alter() like

MYMODULE_form_alter($form, $form_state, $form_id) {
  if ($form_id == 'user_register_form' ) { // id of registration form
    $form['account']['name']['#access'] = FALSE;
  }
}

  #access

  Used by: All elements and forms

  Description: Whether the element is accessible or not; when FALSE, the
  element is not rendered and the user submitted value is not taken into
  consideration.

I would also like to mention for other people reading this that this can also be accomplished with the email_registration module


How do I switch a node's view mode for AJAX calls?

If you have a custom handler for your ajax request, I suggest you to manually render the node using node_view api function. It has a view_mode parameter which you should set to 'ajax'.


How to determine block module given block delta

No, it's not possible without having the module name.

Block deltas only need to be unique per module, so any two modules could implement a block with exactly the same delta, and you'd have no way to determine which was which without the module name.

The simplest proof of this in the code is the block_load() function, which has this signature:

function block_load($module, $delta) {

As you can see, even Drupal can't load the details of a block without knowing the module name unfortunately.


translate interface search exact keyword

No, there isn't any way to do that through admin interface.
The string search is based on the LIKE condition which includes hardcoded placeholders (%) to search for all strings containing your provided string.

Only way for you is to directly tamper with the database or go through all 19 result pages.
Alternatively, you could change the code temporary. For that you have to open locale.inc and go to function _locale_translate_seek() in line 1833. Depending on your search (all, untranslated, translated) you have to look for

->condition('s.source', '%' . db_like($query['string']) . '%', 'LIKE');

and change it to

->condition('s.source', db_like($query['string']), 'LIKE');.

Your search should then only result in exact strings.


Make Facebook comments on Facebook page show up on my Drupal site

You can have a look at this Facebook Comments Social Plugin Module

  Implement Facebook commenting with settings on the level of both
  content type and node. This module comes with a Facebook Comments
  block so you can have comments anywhere on your site.

There are another modules which support your functionalities -> FB Comments Box

  This module gives your site the ability of using Facebook's Comments
  Box social plugin, i.e. comments on your site powered by Facebook. It
  provides an easy way to configure Facebook Comments parameters (like
  theme, administrators, number of posts, node types to attach to) and
  then exposes the generated code as a block for you to insert into a
  region of your choice. This module is intended for anyone who wants to
  put Facebook Comments on their Drupal site in addition to or instead
  of Drupal comments from core.


place own block from module to the left of the screen

You have to edit your theme's template to create a new region.

You will need to add something like:

<?php print render($page['your_region']); ?>

Without this nothing in that region will ever get rendered.

You will also need to add it to your themes .info file.

For more information see: How do I create custom regions in a theme?


What are Ctools plugin (content type, access, etc), and how does one create them?

Every now and then when working with Ctools Page manager, and Panels, it is useful to add custom Ctools plugins.

Ctools plugins comes in a large number of forms, and other modules, such as Feeds, Addressfield and Openlayers all make use of Ctools to provide plugins extensible by other modules. The most common forms of plugin though, are probably "content type", and "access". The first must not be confused with the entity "content" and its bundles, also called content types.

First, the boilerplate:

For any module to provide ctools plugins, they should first tell Ctools where to look for them. The hook below, says that we provide plugins for ctools, of the types "content_types", and "access". The function could be made simpler, but this way we ensure that only the right module gets told about the plugins, as well as only having it scan the disk for files when we actually provide the type of plugin being asked for.

function HOOK_ctools_plugin_directory($owner, $plugin_type) {
  // We'll be nice and limit scandir() calls.
  if ($owner == 'ctools' && ($plugin_type == 'content_types' || $plugin_type == 'access')) {
    return 'plugins/' . $plugin_type;
  }
}

Below is an example directory structure for a module providing two plugins. One content type and one access plugin.

module/
module/module.info
module/module.module
module/plugins/
module/plugins/content_types/
module/plugins/content_types/two_views_in_one.inc
module/plugins/access/
module/plugins/access/term_depth.inc

Content type plugin

A content type in the Ctools vocabulary, is more often known as a "Pane", as provided by for example Views. In this question: Is there a way to intercept a list of NID's created by a view and use them as a filter for another view?, the author asks about programmatically feeding arguments to a view. While that in it self it not very hard, the follow up question quickly becomes, "How do I display the results?".

One answer, will be to create a new "content type".

Now, the actual content type plugin, again using the Views question from above, could look like this:

$plugin = array(
  'title' => t('Render a View with arguments from another'),
  'single' => TRUE,
  'category' => array(t('My custom category'), -9),
  // Despite having no "settings" we need this function to pass back a form, or we'll loose the context and title settings.
  'edit form' => 'module_content_type_edit_form',
  'render callback' => 'module_content_type_render',
);

function module_content_type_render($subtype, $conf, $args, $context = NULL) {
  $block = new stdClass;
  $block->title = 'My View';

  $view = views_get_view('get_nids');
  $view->preview('display_machine_name', array($arg1, $arg2));

  $nids = '';
  foreach($view->result as $node) {
    $nids += $node->nid . ',';
  }
  $nids = rtrim($nids, ',');
  $view = views_get_view('get_related');
  $view->execute_display('display_machine_name', array($nids));
  $block->content = $view->render();

  return $block;
}

/**
 * 'Edit form' callback for the content type.
 */
function module_content_type_edit_form($form, &$form_state) {
  // No settings beyond context, which has already been handled.
  return $form;
}

With this module enabled, there should now be a new category in Panels, 'My custom category', where in one should find a single pane, rendering the code from above.

Access plugin

The access plugin below will provide the ability to filer out variants and/or panes based on the depth of a term as measured from the root of the vocabulary.

<?php
/**
 * @file
 * Plugin to provide access control based upon a parent term.
 */

/**
 * Plugins are described by creating a $plugin array which will be used
 * by the system that includes this file.
 */
$plugin = array(
  'title' => t("Taxonomy: term depth"),
  'description' => t('Control access by the depth of a term.'),
  'callback' => 'term_depth_term_depth_ctools_access_check',
  'default' => array('vid' => array(), 'depth' => 0),
  'settings form' => 'term_depth_term_depth_ctools_access_settings',
  'settings form validation' => 'term_depth_term_depth_ctools_access_settings_validate',
  'settings form submit' => 'term_depth_term_depth_ctools_access_settings_submit',
  'summary' => 'term_depth_term_depth_ctools_access_summary',
  'required context' => new ctools_context_required(t('Term'), array('taxonomy_term', 'terms')),
);

/**
 * Settings form for the 'term depth' access plugin.
 */
function term_depth_term_depth_ctools_access_settings($form, &$form_state, $conf) {
  // If no configuration was saved before, set some defaults.
  if (empty($conf)) {
    $conf = array(
      'vid' => 0,
    );
  }
  if (!isset($conf['vid'])) {
    $conf['vid'] = 0;
  }

  // Loop over each of the configured vocabularies.
  foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) {
    $options[$vid] = $vocabulary->name;
  }

  $form['settings']['vid'] = array(
    '#title' => t('Vocabulary'),
    '#type' => 'select',
    '#options' => $options,
    '#description' => t('Select the vocabulary for this form. If there exists a parent term in that vocabulary, this access check will succeed.'),
    '#id' => 'ctools-select-vid',
    '#default_value' => $conf['vid'],
    '#required' => TRUE,
  );

  $form['settings']['depth'] = array(
    '#title' => t('Depth'),
    '#type' => 'textfield',
    '#description' => t('Set the required depth of the term. If the term exists at the right depth, this access check will succeed.'),
    '#default_value' => $conf['depth'],
    '#required' => TRUE,
  );

  return $form;
}

/**
 * Submit function for the access plugins settings.
 *
 * We cast all settings to numbers to ensure they can be safely handled.
 */
function term_depth_term_depth_ctools_access_settings_submit($form, $form_state) {
  foreach (array('depth', 'vid') as $key) {
    $form_state['conf'][$key] = (integer) $form_state['values']['settings'][$key];
  }
}

/**
 * Check for access.
 */
function term_depth_term_depth_ctools_access_check($conf, $context) {
  // As far as I know there should always be a context at this point, but this
  // is safe.
  if (empty($context) || empty($context->data) || empty($context->data->vid) || empty($context->data->tid)) {
    return FALSE;
  }

  // Get the $vid.
  if (!isset($conf['vid'])) {
    return FALSE;
  }
  $depth = _term_depth($context->data->tid);

  return ($depth == $conf['depth']);
}

/**
 * Provide a summary description based upon the checked terms.
 */
function term_depth_term_depth_ctools_access_summary($conf, $context) {
  $vocab = taxonomy_vocabulary_load($conf['vid']);

  return t('"@term" has parent in vocabulary "@vocab" at @depth', array(
    '@term' => $context->identifier,
    '@vocab' => $vocab->name,
    '@depth' => $conf['depth'],
  ));
}

/**
 * Find the depth of a term.
 */
function _term_depth($tid) {
  static $depths = array();

  if (!isset($depths[$tid])) {
    $parent = db_select('taxonomy_term_hierarchy', 'th')
      ->fields('th', array('parent'))
      ->condition('tid', $tid)
      ->execute()->fetchField();

    if ($parent == 0) {
      $depths[$tid] = 1;
    }
    else {
      $depths[$tid] = 1 + _term_depth($parent);
    }
  }

  return $depths[$tid];
}


You could modify http://drupal.org/project/jcarousel to do this. Since the link you provided already provides a guide (http://valums.com/scroll-menu-jquery/) to implement this why don't you put the code in a drupal block and display it.


How can I list all the IP address and referrers of visitors of a specific node?

Have a look at the Visitors module. It comes with various reports, such as reports about pages that have recently been visited, or that have been hit frequently, or about pages count per month, day of month, day of week, hour. And it also includes a Referrers report (for referrer type either internal, external, or both).

One of the included reports is the Recent hits report, a table with columns Date of visit, Title, Path and User ID of the visitor. If you follow any of the "details" links in that report, you'll get something that looks as in this example:

The demo site contains some sample reports (charts) available to anonymous users also.

You may also want to look at the visitors_schema to get an idea of the data that actually get logged (recorded) by this module.

In case the delivered reports are not a perfect fit, it's probably a very good starting point for some custom reporting. Either via a custom module that would simply have to query the data maintained by the Visitors module. Or via a straight forward custom report created with the Forena module.

Disclosure: I'm the maintainer of the Visitors module,
and co-maintainer of the Forena module.


Personal Contact Form granular permissions

I would do this using hook_form_alter.

Set up your roles,  then create a function using hook_form_alter that checks if it's building the contact form or not.   If building the contact form,  check the current user's role,  and either redirect to a 403 or allow it to go through.


I'm working on something similar. I think you can do this using a validation rule.

/**
 * Implements hook_form_alter().
 * We replace the local login validation handler with our own.
 */
 function beneficiaire_form_alter(&$form, &$form_state, $form_id) {
    // In this simple example we authenticate on username to see whether starts with dave
    if ($form_id == 'user_login' || $form_id == 'user_login_block') {
        $form['#validate'][] = 'beneficiaire_user_form_validate';
    }
 }

/**
 * Perform validation rules and set error states
 */
function beneficiaire_user_form_validate($form, &$form_state) {
    if (!beneficiaire_authenticate($form_state)) {
        form_set_error('name', t('You are not on our super-secret list.'));
    }
}

/**
 * Custom user authentication function
 */
 function beneficiaire_authenticate(&$form_state) {
     // Check the webservice here and return false if user not found.
 }


In your $form FAPI usage you called the file key file, a child element of the parent container background_audio_file. In your _submit() function you are not looking for file.

Do a Devel dpm($form_state['values']) or a print_r($form_state['values']) and you will see the key file with your content. Besides that your code looks ok.


How do I get when an entity was last updated?

If the entity uses the EntityChangedTrait (Drupal\Core\Entity\EntityChangedTrait), then you can use getChangedTime().


How to upload static files to a remote server in Drupal 7 instead of local filesystem?

You should look into the CDN project.
I am think of implementing it myself, but have no practical experience to impart.


If you serve your menus as blocks then you can use Authcache Block sub module. On the block admin page you will find an Authcache personalization setting.


Thanks for editing @Krishna Mohan.

I have changed module from MuchoMenu to "TB Mega Menu". TB Mega Menu allows us to create block into drop down menu.

And, I think "to display custom menu" need to print block into that region.

So, Define region into .info file
and print that block into page.tpl.php file.

So, in page.tpl.php replace code with this:

             <?php print render($page['top_menu']); ?>

I am new to drupal, so I might be wrong.

Thanks!


How to use Composer to install third party libraries

It is not recommended to installing JavaScript libraries using composer.json, but it is possible.

Note: This repository type has a few limitations and should be avoided whenever possible:
Composer will not update the package unless you change the versionfield.Composer will not update the commit references, so if you use master as reference you will have to delete the package to force an update, and will have to deal with an unstable lock file.

(Composer docs)
If your package is available for download at an external source, e.g. as an archive, you could add it as custom package with type drupal-library to the repositories section of your Drupal project's composer.json, and then require this package accordingly:
"repositories": {
  "drupal": {
    "type": "composer",
    "url": "https://packages.drupal.org/8"
  },
  "mypackage": {
    "type": "package",
    "package": {
      "name": "myvendor/mypackage",
      "version": "1.0.0",
      "type": "drupal-library",
      "dist": {
        "url": "https://example.com/mypackage.zip",
        "type": "zip"
      }
    }
  }
},
"require": {
  ...
  "composer/installers": "^1.2",
  "myvendor/mypackage": "1.0.0"
},
"extra": {
  "installer-paths": {
    "public/core": ["type:drupal-core"],
    "public/libraries/{$name}": ["type:drupal-library"],
    "public/modules/contrib/{$name}": ["type:drupal-module"],
    "public/profiles/contrib/{$name}": ["type:drupal-profile"],
    "public/themes/contrib/{$name}": ["type:drupal-theme"],
    "drush/contrib/{$name}": ["type:drupal-drush"]
  },
  ...
}

Check the Repositories documentation for Composer for more details or other source types.


Add field to node without new content type

A field of the Field API is meant to be used in an entity. Nodes are specific types of entities, such as users are. Fields are attached to specific bundles of an entity. Content types for nodes are the bundles of the nodes entities. If an entity type does not support bundles, such as users, then fields are bound to the entity regardless. For more on the subject see Drupal.org: An introduction to Entities.

As such, a field is not designed to belong to a particular entity but rather to an entity type/bundle (briefly, not designed to belong, meaning that the database design and programming logic as is would not support something like that).

So to sum up, it would require some considerable coding effort to achieve something like this and it would be advised to reconsider your design to take into account those factors.


Can I invoke a template for print media?

You cannot tell in drupal, if your page is going to be printed.

CSS and media queries is browser based. You deliver the same content (html) and the browser will generate different output for display and print.

If you want to do deliver a special print version, you have to provide a different url for this and link it on your page, for example a print button. You can then check in the twig for the special url and change the html.


On the theme "busy" how to remove the "0 comments" at the bottom?

Try disabling the comments module, or set the comments to be hidden in the content type settings.


How to link menu item to a page in Drupal7, that can display database content?

There are 3 broad ways of doing this i) create a widget ii) ajax/json iii) create a block.

The widget method is suitable if you are trying to create an element in the form that is more sophisticated than the form elements provided. You present it in a node--contenttype.tpl.php template. Replace 'contenttype' with the name of the content type you created.

If you want to print out just parts of the data captured in the form then you can use hide($content['fieldname') to get rid of any fields that you don't want rendered. That is the 'streamlined' way. See the 'field example' module in the examples project.

Assuming the module is called ognotify you will need to implement:

ognotify_field_info() to declare the field
ognotify_field_widget_info to define the widget and
ognotify_field_formatter_info() to define the available formats.

These 3 things define the 'edit content type form' in the administration area of drupal.

To process the output you also need to implement

ognotify_field_is_empty($item, $field)
ognotify_field_widget_form(&$form, &$form_state, $field, $instance,
$langcode, $items, $delta, $element) to define the form elements

and some validation routines. You can add this 'widget' to any content type.

It sounds as though you are trying to render something more specific. If by dynamic you mean via ajax then one way is to create an ajax block and callback response from the block (module is called bookreview this time).

Define the block as per:

function bookreview_block_display($delta, $args) {
...

This calls a form element of ajax type.

function _bookreview_publish_review_link($args) {
  $block = array();
  if (empty($args['nid']) || empty($args['status'])) {
    return $block;
  }

  $block['content'] = array(
    '#type' => 'link',
    '#title' => 'Publish review',
    '#href' => 'bookreview/publish/' . $args['nid'],
    '#prefix' => '
',
    '#suffix' => '
',
    '#ajax' => array(
    'effect' => 'fade',
    ),
 );

 ...
  return $block;
}

Render this on a page. You can do this by mapping blocks, or in code in a template:

$block = module_invoke('bookreview', 'block_display', 'bookreview_publish_review_link', $args);
print render($block['content']

The callback in this example is 'bookreview/publish'. This is the 'access content from a menu' solution. Implement the menu:

function bookreview_menu() {
  $items = array();
  $items[BOOKREVIEW_MODULE_NAME . '/publish/%node'] = array(
    'title' => 'Publish a Book Review',
    'page callback' => 'bookreview_publish_review',
    'page arguments' => array(2),
    'access callback' => 'bookreview_access_callback_check',
    'access arguments' => array(array(BOOKREVIEW_ADMIN_PERMISSION_NAME)),
    'type' => MENU_CALLBACK,
    'file' => 'includes/BookReviewEvents.php',
  );
  return $items;
}

Now we have mapped a menu item (uri) to a function that prints out the content.

function bookreview_publish_review($node) {
  if (!isset($node)) {
    return;
  }

This takes a node argument, %node in the menu definition which automatically gets converted from a node number to a node loaded from the database. The address publish/123 will result in node 123 being passed to your function. You can create a callback for each of the fields in the content type as per /bookreview/menu-name-field/%node. Then create a function to either directly print out the ajax json response:

...
// How you want to get the data from the node. Best to use Netbeans/php debugger
// or dpm() if you don't have it.
$menu_name_field_data = $this->node->{$this->_findMenuFieldName()}[LANGUAGE_NONE][$delta]['value'];
$data_to_print[] = $menu_name_field_data;
ajax_deliver(array('#type' => 'ajax', '#commands' => $data_to_print));
...

The 3rd way is similar to creating the ajax response, except that you define a block that allows you to render the html content. As per the ajax defining a menu item and declaring a block. You print out the content there instead of defining an ajax form.

The widget answer is the most reusable, the ajax answer is the most dynamic and flexible and the block method presents HTML instead of ajax responses. Regarding 'dynamic' the ajax solution best meets your description in the question, although I thought it necessary to present the breadth of the possibilities so that you can make choices regarding the tradeoff between reuse and dynamic.


Image styles not working, uploads to to files directory

It's because you do not have the correct folder owner/group.

You need to cd into your /sites folder. Once there:

If you're using Ubuntu do:

sudo chown www-data:www-data -R default

For CentOS it's:

sudo chown apache:apache -R default and disable SELinux

PS: Never give your files folders permission of 777, set it to 775


Determine the row number of an unformatted row in views

Views already wraps each row in all sorts of CSS classes, like views-row, views-row-#, views-row-first, views-row-last, etc, so if all you want to do is STYLE things differently, you can use these classes.  Now, if you want to re-arrange the CONTENT of your node, that's a whole 'nother story...


Creating/registering a user (of a custom profile type) when a certain webform is submitted?

First you can add your code and add inside sites\all\modules\webform\includes\webform.submissions.inc in functions named "webform_submission_insert" , and check if it works or not , also as per below image in $submission variable you will get all webform submitted values .

Also , if you want to Get Webfrom submitted data by userid wise use below code anywhere.

module_load_include('inc', 'webform', 'includes/webform.submissions');
$values = webform_get_submissions($nid, null, $user->uid, 1);

if you want to Get Webfrom submitted data by node id , as below code 105 is node id.

module_load_include('inc', 'webform', 'includes/webform.submissions');
$submissions = webform_get_submissions(105);


Can't access template page--node--1.tpl.php by its path

If you're getting a 404 for the path "node/1" then that node doesn't exist, so the template will not be run for it. A template file will only be applied to a path that actually exists.

You just need to get the nid of an existing node and replace the id in the template file name with that, e.g.

page--node--2.tpl.php

where a node with a nid of 2 actually exists in the database.

Don't forget to clear Drupal's caches anytime you add/remove a template file so the theme registry gets updated.


{{ directory }} in Twig template in base theme breaks subtheme

You can also use this:
{{ source('@parent/../images/svg/resources.svg') }}

where @parent is the name of the parent theme. @parent references to the templates folder, so @parent/../ was added to go to the root directory of your theme.


Core Drupal8 JS necessary for Drupal theme to function

In your .info.yml file specify:

libraries-override:
  core/drupal.active-link: false

You may have to remove more libraries, but this one is specifically for the files you mentioned.


How can I display the of result count of a view in its header?

Do you not mean these predefined value(s) in the Header area ?

Return a view's total_rows in Drupal 7 without php filter?

You could count the number of rows using PHP in views_pre_render() ... but I bet this is what the above is doing already ....


Mailchimp Newsletter block position in registration page in Drupal

Ok, you'll need to do this with a custom module and use hook_form_alter and set the weight of the mailchimp list properly.

function MODULE_form_alter(&$form, &$form_state, $form_id)
{
    if ($form_id == "user_register_form")
    {
        //print_r($form);
        //first name field - use proper name
        $form["first_name"]["#weight"]      = 1;
        //last name field - use proper name
        $form["last_name"]["#weight"]       = 2;
        //email field - use proper name
        $form["email"]["#weight"]           = 3;

        $form["mailchimp_lists"]["#weight"] = 4;
    }
}

You should use print_r($form); or drupal_set_message(print_r($form,true)); to inspect the structure of your $form array and get out the proper names of your fields to use in the hook.


Addressing objects and arrays nested in an object?

This is the correct way to use it (see the usage of the square brackets in the string):

print $field->handler->last_tokens['[title]'];


Include third party library in custom module without composer

It's quite common that production sites are unable to run composer. Even if command line access is available the site code is read-only, so composer would be unable to make any changes.  Either developers have to use composer locally and upload all modules and vendor files to the production environment, or a build system takes care of that task.

Your Drupal site will only have one vendors folder and autoloader, which is used by Drupal and all modules; modules don't have to include the autoloader themselves.

I'm assuming you haven't used composer to set up the site initially, and have only downloaded the Drupal zip file and added your modules.  Composer is unable to automatically determine dependencies from modules when using the zip file, but you can still add the dependencies yourself.  From the root directory of your site (not the module with the dependency), add any required packages as a dependency to the project:

composer require ryanwinchester/hubspot-php

This will add the third-party package as a dependency of your site, install its files to the vendor directory, and also make it available to any modules.

Updating Drupal core with this setup is trickier however.  You'll need to replace the composer.json file with the updated version to make sure that you get the correct dependencies for Drupal core, and then re-add any of your additional dependencies.

You can read the documentation on using Composer to manage an entire site:
https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies

Using drupal-composer/drupal-project instead of the Drupal core zip file will allow you to add Drupal modules with composer, as well as automatically resolve and include any dependencies of those modules.


Sounds like you'd really want to supply a hook_block, whose $content will call a custom PHP function that will construct your array of links to other organic groups, based on your criteria.


use Change Label Length limit module.

it lets users change the maximum limit of label fields.


Views contextual filters summary display nodes id instead of title

I have found how to do it. Firstly, I added the relation between customers and groups in the "relation" section. After this, instead of adding the relation field as contextual filter, I added the title field as contextual filter, but I checked the relation I have created. Then, when the argument is not present, It shows a list of groups (with their names) and the count of record.


If your question is not what your title says consider this:
Module you need is views module.

Create a view of article type and keep the display of  your view type as page,this view will list all nodes of article content type.Give page path as "articles" or whatever.
Create another view to show taxonomy terms of type all/vocab, this view will also be page display type.Give page path as "show-taxonomies" or whatever.
Create a menu block with two menu items "articles" and "others" link them respectively to the views page path you have set.
Now put this menu block in main content region with path specified for block display as "opinions".


How to change default content type machine name in commerce kickstart?

You can only set the machine name when you create the content-type. After that, it is not editable anymore. That's why you have to think twice when you create a new content-type. Your only solution is to delete this content-type and recreate one with the right machine name.

If it is only the appearance of the URL that doesn't suit you, you can also use URL aliases modules like https://www.drupal.org/project/pathauto and replace the word 'hats' by the word 'products' for example (in the module configuration).


User click on log in when user already logged in so should throw message.

You can check value of field uid of global variable $user:

global $user;
Contains preferences and other account information for logged-in users. When a user is not logged-in, the $user->uid property is set to 0.

http://api.drupal.org/api/drupal/developer!globals.php/global/user


Deploying Drupal 7 with read-only DocumentRoot, especially concerning image handling

When an generated image is not available, the page callback is image_style_deliver(). This callback first generate the image (after some access and concurrency checks) and then stream the file as response (through the file_transfer() function).

Using hook_menu_alter(), you can override the image generation callback to redirect to the static domain once the image has been generated. Ensuring the generated files are always served from the static domain. On the static server, you can add a rewrite rule to redirect request for a not yet generated image to the non-static domain. Ensuring the files are generated, even when requested from the static domain. Because of the redirections, Varnish should be able to cache the files as soon as they have been generated.

Edit: Not creating the image derivatives as files on disk does not seems to be an option. Drupal uses its Image Toolkits wrapper API (GD and ImageMagik are usually used a backend) to generate the image and this API does not seems to offer a way to generate images in memory. If you really want/need to remove the generated files, you can do it in a cron job using image_style_flush() via hook_cron().


Drupal requires that one theme must always be set as default. Further, you cannot disable a theme that is currently set as default.

Best bet would be for you to enable another theme, set it as default, then disable the one you don't want.


How do you allow a role to assign other users roles - but only specific roles?

I think Role Delegation is what you're looking for.

  For each role, Role Delegation provides a new assign ROLE role
  permission to allow the assignment of that role.


Is it possible to add second horizontal Menu below Main Menu?

Go to /admin/structure/menu/add and add a new menu
Go to /admin/structure/block and place the new menu block in the region of your choosing.


Here is Internationalization pack for building multilingual sites in Drupal: i18n.
To translate field labels you need “Field translation” module from this pack. After you enable it new tab “Translate” appears on field edit page.

Update

That's strange that you can see your field labels on admin/config/regional/translate/translate page, so I started an issue #1672694. I think it's a bug.

Update 2

Fixed since Drupal 7.22


Cache error on file upload with media, multiform, and plupload

There is a bug in multiform that was introduced by recent changes to Drupal Core. The bug has been reported in the module's issue queue and a patch has been provided: https://drupal.org/node/2247527

The patch fixed the issue for me, and hopefully will be included in the next release of the module.


You can do this by using Flag Friend module

  Flag Friend aims to be a lightweight friending module utilizing the
  excellent Flag module's API.

Or

Flag Follow

  This is a simple module which allows a user to view Heartbeat
  activities of his favorites/followed users. A user can add another
  user to his favorites list by just click on a 'Follow' button. It
  requires no approval to add a user to your favorites list.

or

You can do this by using Follow module.

  Follow adds sitewide and per user links that link to various social
  networking sites. The links reside in two blocks. The Follow Site
  block lists all the links for the site itself, and by default is
  visible on all pages. The Follow User block lists all the follow links
  for the user and is visible only on user profile pages.


Code working normally in a fresh HTML file but not in a Drupal block

Inputing PHP or Javascript through the UI is almost always a bad idea, and can happen to be impossible in some cases, for security reasons.

I recommend another approach, for example creating a block in a custom module with the various block hooks.

This way, you won't bypass Drupal security and you'll have a much more versatile and robust solution.


A view I wrote has bugged handlers so I want to alter the query manually. How do I get the current view display?

If you already know the machine name of the view then you can wrap your code in an if statement.

function hook_views_query_alter(&$view, &$query){
    if($view->name == 'name_of_view_to_alter'){
        //do stuff to the query
    }
}

hook_views_query_alter takes two arguments &$view and &$query. If you don't already know the machine name, of course install devel and use dsm($view) to find what you need. Also very helpful calling that on the $query variable as well. I just did something very similar.


how to create two or more view with in a single view

What you need is a views attachment to the main parent view. Fist you create a new Views Display, say a block. then on the parent view, attach that view to it. Now turn on inherit contextual filters so you can pass the arguments over to the other view. If you want finer control with the output and fields you can try: http://drupal.org/project/views_php


After Creating A new User inside RULES, I can not access to UID

Use the action to save the entity. The user only gets the UID when saved, not when created.


I try to customize my block id and it doesn't work

You can set your block to a 'system block' from within the Panels pane management interface. It should then pick up on the system level block template files.

This also may be a duplicate of How to use a custom block template when the block is embedded in a panel pane?, but there wasn't a definite 'good' answer there either it seems.


You can use a custom User Provider in Symonfy and then use the Service Module from Drupal to login via a REST interface


Which is the preferred way to change field content before rendered?

hook_entity_view_alter() is for altering the render array of an entity, that is coming out of a view mode. It is not for a single field and changes in this hook would have no effect, when using the field alone, for example in a view. Using this hook would be the answer to the question Which is the preferred way to change the display (view mode) of an entity, before it is rendered?

(When using this hook, don't digg to deep, you can only change the render elements in the top level. Not the referenced objects, they are only to get information, not to change the rendering)

But the question is to change the rendering of a field, you asked "everywhere throughout all contents" For this the right solution is a field formatter, this can be used everywhere in drupal, whenever a field is rendered, no matter if you define a display mode (aka view mode) of an entity or use the field in Views.

To make the picture complete, you can change a field twice while displaying content, first in a field formatter and the second time, when the whole content is build and this build array can be altered in hook_entity_view_alter()

In drupal 8 field formatters are no longer hooks, they are now plugins.

https://api.drupal.org/api/drupal/core!modules!field!field.api.php/group/field_formatter/8

The documentation does not help to setup this plugin. I would copy an example from core and put my own code in it, for example:

core\modules\datetime\src\Plugin\Field\FieldFormatter


Render a field from an entity reference in twig template?

After some more thought and research, I think the best approach to this problem is to use a theme pre-processor function to manually prepare the entity reference field.

The main issue is that the referenced entity has a formatted text field that I need to output. That means it needs to run through the formatter before it's considered safe for output.

Manually accessing the value through the entity object in Twig is not a good solution because it will just print the raw value from the database, which twig will by default escape. Tacking on |raw makes it unsafe because it still hasn't run through the text processor.

Here's a preprocessor snippet that does what I need:

/**
 * Implements hook_preprocess_node().
 */
function MY_THEME_preprocess_node(array &$variables) {
  $node = $variables['node'];
  if ($node->bundle() == 'news') {
    // Extract the caption from the cover image media entity and prepare it manually. We do this because in our template, we render the caption separately from the image.
    if (!$node->field_news_cover_image->isEmpty()) {
      $image_media_entity = $node->field_news_cover_image->entity;
      $caption_field = $image_media_entity->field_media_caption;
      // Caption is formatted text, so we must output a render array that will
      // process the text with the appropriate filter.
      $variables['cover_photo_caption'] = [
        '#type' => 'processed_text',
        '#text' => $caption_field->value,
        '#format' => $caption_field->format,
        '#langcode' => $caption_field->getLangcode(),
      ];
    }
  }
}

This allows me to simply print {{ cover_photo_caption }} in the twig template.


drupal contextual filter (URL argument) OR operator

Can different content types share a common field?

In drupal 7 (maybe also in drupal 6) yes you can.
When you add a new field to your content type, you've the possibility to add a field that already exist: "Add existing field".

Then filtering on the field should work for any content type using it.

Basically, I would add to the three content types Books, Photos and Article the same field "field_issue_number".

I think that will make your life easier :)


How to call a module in a block or give a module a block or put module form into a block?

You can do this with the $form_id and the function drupal_get_form();

You need to create a module and use hook_block():

function mysecondmodule_block($op = 'list', $delta = 0, $edit = array()) {
  switch($op) {
    case 'list':
      return array(array('info' => 'mymodule add block'));
    break;
    case 'view':
      if($delta == 0) {
        return array(
         'subject' => 'Mymodule Add',
         'content' => drupal_get_form('form-id');
        );
      }
    break;
  }
}


this can be done with a bit of code in a tpl file or in a preprocess function.

Views has a function views_embed_view that you could use to embed the block into your field output.

print views_embed_view('views_name', 'display_id', $fieldvalue);

https://www.drupal.org/node/1336844


According to the documentation of comment.tpl.php, you should have access to $comment, so the following should work:

<?php print $comment->subject; ?>


How to reorder vertical tabs by weight in Drupal 7?

If you are calling the hook function through your module it can happen that other modules are calling the same hook function after your hook. This would make the changes you made overwritten by the other module.

So if you want to make sure your hook is called last, either call the function in the themes template.php file or change the weight of your module to something higher so that it gets executed last. The second option would require you to edit the system table in the database.


Limit amount of content creation per anonymous user

You could do it custom with hook_node_access and the Flood API.

e.g:

/**
 * Implements hook_node_access
 */
function MY_MODULE_node_access($node, $op, $account) {

    // Get node type, can be string or node object
    $type = is_string($node) ? $node : $node->type;
    if ($type == 'type_of_interest') {
      // Check flood limit for anon users node creation
      if ($op == 'create' && user_is_anonymous()) {
        // Ensure checked only once per page request, node/add path only
        $access_checked = &drupal_static(__FUNCTION__);
        if(empty($access_checked) && arg(0) == 'node' && arg(1) == 'add') {
          // Record the access check for drupal_static
          $access_checked = TRUE;
          // Check create_node limit of 2 per 12 hours
          // Note, you could make the threshold and window config variables.
          if(!flood_is_allowed('create_node', 2, 43200)){
            drupal_set_message(t('There is a node creation limit of 2 nodes per 12 hours. Please try again later.'), 'error');
            return NODE_ACCESS_DENY;
          }else{
            // Register the node create event to test against for 48 hours
            // Note, you could move this somewhere else to ensure the node is actually saved, e.g hook_node_insert
            flood_register_event('create_node', 172800);
          }
        }
      }
    }

  return NODE_ACCESS_IGNORE;

}


How to output unlimited value Field Collection with dates into a Views table format with no duplicates?

Revisiting this two years later after asking if I'd solved it. In short, yes, I did. :)

Here's a screenshot of the final product, still live:

Here's a screenshot of the view as of this morning:

Basically, I created two fields of the Field Collection item: Date, which I was able to access by creating a relationship to the Field Collection. I then changed the formatting of those Field Collections to be what I wanted them to be.

In the Table's settings, I used Grouping field Nr.1 to group them by Content: Category, using the rendered output to group rows. I also enabled sticky table headers so that the headers will follow the table down.

For the class date, I set the formatter to Date Range, and set the format to "F j" for single date, single date all day, single day date range. For Date format for single month date range, I set it to F j – {j}, for single year date range I set it to F j – {F} {j}. For multiple years date range, I set it to F j, Y – {F} {j}, Y

No aggregation or distinct functionality was used in the view, as all of the trainings can only be part of a single category, so I didn't get duplicates. You may need to factor that in. I've always had great results from the Views Distinct module when running into that problem.

The items are sorted first by the taxonomy term weight, and then by item. I also integrated DraggableViews so the editor can re-arrange them as they saw fit rather than alphabetically if they want. (I actually should remove the sort by start date bit, as that doesn't do anything.)

Hope that helps.


Drupal 7 Can a custom textarea render html without a rich texteditor enabled?

I didn't find the answer I wanted to find, but after careful examination of the form api, I discovered markup and it led me down the path of fooling the end user into thinking it looked like a field with some css manipulation. This is working for me

$form['Venue Agreement'] = array (
 ['0']['#default_value'],
  '#weight' => '10',
  '#markup' => $form['field_venue_agreement']['und'['0']['#default_value'],
  '#prefix' => '
',
  '#suffix'=> '
',
);


How to join the `field_data_field_*` tables with `node` table using SQL?

Yes, you are right :)

In general, for each table from field_data_field_* family, if its entity_type is equal to  the "node" value, then it can be associated with the n.nid from the node table and if the entity_type is equal to the "user" then the entity_id value is associated with the uid value from the users table.

I hope it will help somebody.


How do i change the button text "subscribe", from the "simplenews" module, in drupal 8?

I figured it out due to 4k4's comment

Basically you can translate it english-to-english under /admin/config/people/simplenews/settings/subscriber/fields/
It's a part of the configuration translation module.

If you get the error message "The configuration objects have different language codes so they cannot be translated:" look at this thread for the solution for that: How to change default language for configuration entities


How can I send HTML mail when a new content is created with attachments using these modules?

First you need to create a Rule to send a HTML email via Mimemail:

Once you've configured the rule correctly and have entered your HTML email content, you need to ensure the correct mail system class is being used by Drupal to send your emails:

If you don't select the MimeMail class within these settings, the default Drupal mail system will be uses and your HTML emails will be sent in plain text.


How to get field data for Panels style plugin? (ctools context?)

I had to add a Relationship to the File from the Context section of the panel variant (e.g. File from Node (on Node: Image [field_featured_image])). Now you will be able to use %file:url in the image field. Basically, the token you use needs to be listed in the summary of contexts.


Content region not visible in blocks setup page in Sky Adaptive Theme

Which version of Sky theme are you using? In 7.x-2.3, I can see the "Main content" region in the drop down list. If you have made custom changes to theme, try clearing the cache.


What are costs/benefits of integrating Phing, Jenkins together with Drupal?

Ok, as for being a fan myself of continuous integration, I can assure you virtualisation is very handy to control the testing environment. I have built myself a CI setup, forking off from a wonderful package called quickstart. This package depends on Virtual-Box or other VM software, it is basically a Ubuntu made for Drupal with a pre-set up lamp architecture, pre-configured debugging and editors, profilers, etc.

I have installed Jenkins and phing  on top of quickstart, and can assure you it is quite low cost($0), quite low hassle. Any one can co-opt in with me on most any project quite easily, the whole dev environnement is reproduced and it comes with quite a few tools by default, and quite a few I have myself upgraded.

Now, the way we use jenkins is most certainly not pure CI, it just run the tests when we commit, then we shut down the thing and forget about it.  It could be used for notifications and documentation generation, and on some projects I do generate some code metrics but the main thing I also cared about in my setup was testing. One clear advantage when using a vm software for testing  is it can easily be reproduced used  to run the tests elsewhere or even on different systems and configurations, you always have control over the environnement (memory, processor usage, peripheral ressources, etc..)

In most projects I contributed on, testing is done before staging I guess this may be different depending on the project managers.

PS: Another thing to consider, in a true testing environnment you would tend to try and reproduce your server setup and load as much as possible. Our projects are hosted on Cent-OS and obviously we don`t quite follow up to the rules on this aspect either, quickastart is Ubuntu based. So far have not had any problems,  and  as a bonus has many other features pre-configured for rapid Drupal application prototyping and developpment.

Happy CI'ing!


When you run drush up, you are actually updating Drupal core along with contrib modules and themes. Try:
drush up recaptcha -y
This will update the recaptcha module only, with no confirmation needed.


I found there is a patch that works for exactly what we need. Support enclosure field in Views RssFields row plugin


Drupal isn't picking up my custom action

It's my understanding that, by convention, an action function should start with modulename_ (to prevent namespace collisions) followed by a short description of what it does, eg publish, but in order to be found at all, it needs to end in _action.

So try naming all of your functions:

publicatie_omgeving _ SOMETHING _ action

and see what happens.


Should I use different content types or tags?

I'd go for content types. That way you can easilly filter the content for the specific types when needed later.

It's easier to display all different content types at once, then to hide specific ones by their tags.


Use a different theme when your site is being embedded in an iframe

Create a custom module and put this lines there:

/** Implementation of hook_init **/
function yourmodule_init(&$vars) {

  //here put any condition to you want, for example a domain
  $url = url("<front>", array('absolute' => TRUE));
  if( $url == "http://mydomainiframe.com") {
    global $custom_theme;
    $custom_theme = 'new-theme'; //setting a new theme for this domain.
    init_theme();
  }
}

Also you can avoid create a whole new theme creating only a new page.tpl.php and using it.

/** preprocess_page **/
function your_module_preprocess_page(&$vars) {

  //here put any condition to you want, for example a domain
  $url = url("<front>", array('absolute' => TRUE));
  if( $url == "http://mydomainiframe.com") {
    $vars['template_file'] = 'page-iframe'; //setting a new page template
  }
}

And the page-iframe.tpl.php will be used instead of the page.tpl.php of your theme, in this way you can reuse things to you have in your actual theme.


Drupal sending SPAM, can't log in anymore

I've managed to log in programmatically using a theme function, explained in this post.

How do I programmatically log in a user?


Is there a possible/safe way to do a sub-request

I do this as following:

// We mimic menu_execute_active_handler().
$router_item = menu_get_item($href);
if ($router_item['access']) {
  if ($router_item['include_file']) {
    require_once DRUPAL_ROOT . '/' . $router_item['include_file'];
  }
  $page_callback_result = call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
}
else {
  // Access denied.
  $page_callback_result = MENU_ACCESS_DENIED;
}

if (is_array($page_callback_result)) {
  // Render array.
  $output .= drupal_render($page_callback_result);
}
elseif (is_string($page_callback_result)) {
  // Render string.
  $output .= $page_callback_result;
}


Why do I get "Theme hook ... not found" after renaming?

function questionList_theme(...)

must have the name of the module, like :

function survey_theme($existing, $type, $theme, $path)
{
    $variables = array(
        'questionList' => array(
            'variables' => array(
                'questions'    => NULL,
            ),
        ),
    );
    return $variables;
}

will work.


AJAx HTTP ERROR, can't add views to Drupal 7 site, same behavior on 2 different sites

It was a problem with the hosting company....but they were great and changed to PHP 5.4(native) right away, fixed it.

Great job namecheap.com hosting, as usual, they are actually really good


Views: Show only "Grouping Field" headings

Since you want to display all the terms  possible, and not only those assigned to nodes, it doesn't make sense to build it through a Node View.

You can create a new View of type Taxonomy terms, create a block displaying Taxonomy terms, then place the Block in the Content region on your Views page (or any other region).

Alternatively you could also use a module to create the block listing Taxonomy terms: Taxonomy menu and again place the Block in a region and restrict it to show only on your node View page.


Overriding user edit page with Panels loses the user edit form

I think it's fair to say the pane could have had a better name, but here it is.