Programmatically assign permisions to role

You don't need to re-install the whole website just to make a change to your .install file...you can just implement hook_update_N() instead.

/**
 * Description of the update.
 */
function MYMODULE_update_7100() {
  // Perform some tasks. From the comments it looks like you have the logic you need.

  return t('Tasks completed');
}

After adding that code visit update.php and follow the instructions (or run drush updatedb) to update the database.

The changes will then be applied, without having to reinstall your modules.

This hook is the best place for your code in this situation (in my opinion) as it will only need to be run once. The update system will make sure of that on your behalf, and if you need to make further changes you can just add another update function.

Please make sure you read through the docs fully before giving it a go, there are some caveats that you really should know. Basic stuff but quite important


Why multilingual site url is not working in production site?

Just a beginner's suggestion... when you migrate your site, did you turn off clean URLs, clear cache and put into maintenance mode before migrating?  If not, I suggest you try that then turn back on clean URLs, and take out of maintenance mode.


How can I customize the node/add form for a content type?

On the content type edit/creation page there is a field labeled Explanation or submission guidelines with a help text of:

  This text will be displayed at the top of the page when creating or
  editing content of this type.

Simply put your instructions for the content type form in that field and save your changes.

Example:


How can I find specific block name in structure->blocks in drupal-7?

You could enable the contextual links module and hover over the block and click the small gear icon to edit the block.
you could figure out what region the block is in using firebug or similar which will narrow it down in the block administration page assuming the block is set that way.

If the block is still not visible, the specific user/role may not have the permissions to see whatever content you are trying to view.  Check the permissions for the role at /admin/people/permissions


You can have a look at the Entity popup module, it allows you to define a separate view mode for the popup content and includes an example on how to integrate with colorbox.


Comments in Drupal 7 are tied to Nodes. You could try the Reply module but it is still a dev project.

Usually though in situation like this though if a project needs some functionality that is built into Nodes in Drupal core I think it might be case where Nodes should really be used.


I'll post my comment here as an answer also so this question can be closed.

If you want a taxonomy vocabulary and it's terms to be represented in a menu you can use the module Taxonomy menu. It synchronizes changes in your taxonomy tree to a menu of your choice.

  Transforms your taxonomy vocabularies into menus with ease!


How do I allow modules to provide their own view?

Views are config, so:

Create a View
Export the config for it as a single item using the UI or drush (removing the uuid if applicable).
Include it in your module’s ./config/install folder
Install the module on a different site; the View will be created automatically


Not able to show node comments on a view -content pane

I have been playing around with comments in views for a while. It seems there is a kind of bug as checking "Display comments" on the Full content settings doesn't seem to work. You can solve this, using display suite as the format used by views, which comes with the option "Comments -load comments for every node to display" which does work as expected.

I hope it can help to someone else in the future. :-)


If you want to get rid of the /sites/default/files/ part and change it to something shorter then just go to the admin menu and follow Configuration > Media > File System

( Or just follow the url : /admin/config/media/file-system )

There set your Public file system path and Private file system path to what ever you want.

---- EDIT ----
Actually the above is valid for Drupal 7.
For Drupal 8 you will have to change the value of $settings['file_public_path'] in the settings.php file, as mentioned by 4k4.
In D8 the Configuration > Media > File System page displays these two parameters but no longer allows editing them.
----END EDIT----

So you could change your sites/default/files to something like resources for example.

And then your files will have   urls like this : example.com/resources/the_file.pdf
instead of what you had : example.com/sites/default/files/the_file.pdf

Also make sure that :
  - your resources directory exists, and
  - is located at your web document root directory, and
  - is writable by your apache user (or whatever webserver you use).

Of course, this will be fine for a fresh setup, but if you already have a lot of contributed stuff then changing these settings may impact on your existing node contents.


If you need to decide whenever a page should be cached from Drupal, you need to create a service that implements the \Drupal\Core\PageCache\ResponsePolicyInterface interface and it's tagged page_cache_response_policy, as described in Flexible page cache policy.

That page shows code that can be used as example. You can also use code that Drupal core actually implements, as example, like the code for the node.page_cache_response_policy.deny_node_preview service.

The code implementing the service is quite simple. It becomes more complex basing on the logic you need to apply to decide when a page should be cached.

class DenyNodePreview implements ResponsePolicyInterface {

  /**
   * The current route match.
   *
   * @var \Drupal\Core\Routing\RouteMatchInterface
   */
  protected $routeMatch;

  /**
   * Constructs a deny node preview page cache policy.
   *
   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
   *   The current route match.
   */
  public function __construct(RouteMatchInterface $route_match) {
    $this->routeMatch = $route_match;
  }

  /**
   * {@inheritdoc}
   */
  public function check(Response $response, Request $request) {
    if ($this->routeMatch
      ->getRouteName() === 'entity.node.preview') {
      return static::DENY;
    }
  }

}


Drupal 7 - Advice needed to accomplish the idea of embedding a view in a view

Where did you read that Views is resource heavy?  While there is some overhead to running Views, it is generally not significant unless you are getting enormous amounts of traffic.  Your system sounds like it will be used internally, so I highly doubt that you will run into performance issues.

Views is a visual SQL query builder.  It is also the most popular module for Drupal and one of the best supported modules.  The alternative to Views is to write the SQL queries yourself, but unless you're a SQL expert this is error-prone and time consuming.  You can always do everything in Views first and then re-write some of the queries manually if you run into performance problems.


Messed Up Drupal Site, truncated all cache, menu_router, registry_file and now I can't access site

Best thing is to restore it from a backup to make it work.

If you want to fix it, replicate the site from a back up (db and files).
Then truncate tables one by one to see which one is causing the problem (It should be menu_router).

Truncate first all cache table and check
Truncate menu_router and check
Truncate registry_file and check.

About the code you did, try to remove registry_rebuild from your code.
Create a file fix.php and paste this code

<?php
error_reporting(E_ALL);
define('DRUPAL_ROOT', getcwd());
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

menu_rebuild();

save it into your drupal root and visit mysite.com/fix.php .


You set incorrect semicolon at the end, remove it: while($data = $result->fetchAssoc());

And next manner looks more clear, instead using while:

foreach($result as $data) {
    $rows[] = array(
        $data->user_company_uid,
        $data->user_company_nid,
        $data->user_company_sub_number,
        $data->user_company_date,
    );
}


Use a module that allows you to route email through a real SMTP server.

What is probably happening is that Drupal is sending the mail, but it's being blocked as a spammy looking email message.

edit: you can Alphabet for "drupal smtp module", but this is one I've used https://www.drupal.org/project/smtp


Altering strings

To change the text of a single string, the simplest method is to use the String Overrides module. That would allow you to replace the string:

  "!name field is required."

with (for example):

  "The field '!name' is required."

Altering form fields

If you want to make a field not required, use a normal hook_form_alter() implementation:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function mymodule_form_node_form_alter(&$form, &$form_state) {
  $node = $form['#node'];
  if ($node->type == 'my_custom_type') {
    $form['title']['#required'] = FALSE;
  }
}

Changing the way a form is validated

Forms have validation functions specified in the $form['#validate'] array. And form elements have functions specified in $form['element_key']['#element_validate'].

You can specify your own like this:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function mymodule_form_node_form_alter(&$form, &$form_state) {
  $form['title']['#element_validate'][] = 'mymodule_validate_node_title';
}

/**
 * Validate the node title to prevent ALL CAPS.
 */
function mymodule_validate_node_title($element, &$form_state, $form) {
  if (preg_match('/^[A-Z]+$/', $element['#value'])) {
    form_error($element, t('You may not enter titles in ALL CAPS.'));
  }
}


Unresolved dependency Invite (Version 3.x required)

Sorry i just found solution . I have have disabled User Relationships Invites using db from system table and it works .


Can composer-dependent PHP libraries be used with the Libraries API?

This is not really a direct answer to your question, but as an alternative to using the Libraries API (which I too have struggled with in this context), check out the Composer Manager module. It works nicely for PHP libraries installed via Composer, and takes care of the autoload seamlessly.


Does Drupal have some kind of Structure system?

If you're new to Drupal, you might have a hard time getting your head around the (amazing) Panels module, and things like "context", etc. But it sounds that's part of what you're looking for. Watch the videos about Learn Page manager for more details. After you reviewed these videos, you should understand various features that come with the Panels module ... but also its challenges.

As an alternative, you may want to give it a try to see how far you can get with any (or all?) of these modules:

Display Suite (a typical alternative for using Panels).
DataTables used in combination with Views (especially because of its client side search facilities).
You might want to check also to what extend the features provided by Organic Groups module might help in your case.

Fairly sure that at some point you should also look at the Rules and Flag module.

Video tutorials

For anybody not familiar (enough/yet) with Rules, checkout the 32 (!!!) great (+ free) video tutorials Learn the Rules framework, organized in 7 chapters.
Possibly also the similar set of 8 video tutorials about the Flag module, often considered as a natural complement to the Rules module.
The amazing set of videos to Learn Organic Groups might help to better understand what Organic Groups is all about.
While you're there, why not also review the set of 30 video tutorials about the Views module.


Fast method to locate occurrences of SQL queries via code?

Try CTRL+F-ing for these:

db_query
->query(
\Drupal\Core\Database\Connection::query()
\Drupal\Core\Database\Connection::defaultOptions()


Changed my theme name without disabling it. Can't re-enable, please help

You probably forgot to change folder name where theme is located.

Also see if you have changed all occurances of theme name in .info file.

It would be good also if you change name occurances in template files of that theme (template.php)


Updating view content (in block) based on field data from page it's displayed on

To avoid the article you're on :

Click on the "advanced" tab.
Click on add under "contextual filters".
Choose Content:nid.
Under "when the filter variable is not available, choose "provide default value".
From the drop down menu select "content id from url".
Scroll all the way down to the bottom of the window and click on the "More" link.
Click "Exclude"

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

The second problem can be done by adding 2 Sort Criterias.   The first will be on 'field_related_articles'  - and then by date.  I find displaying the SQL output in admin really helps to see what is happening backend.


How to get a patch for the Views module reviewed and committed to the project?

A pitty that nobody has reviewed your patch so far. I think you should consider posting a question in one of the Drupal.org forums, with some kind of friendly reminder about it. Something like "can anybody help me on this specific issue to get it in status  Reviewed & Tested by the Community (RTBC) please?".

By the way: RTBC is not to be considered as a synonym of "Patch to be ported". Though as a maintainer of a few Drupal modules, I often treat an issue in such status as "Ready To Be Committed".

RTBC is, in my opinion, the next status that your issue should be changed to (assuming your patch is tested by somebody else, and confirm to indeed solve the issue).

After the issue receives RTBC status, it's up to any of the (co-) maintainers of that project to actually apply the submitted patch to the most current dev version (make sure your patch was created as compared to that, if not there is a risk the patch needs to be re-rolled, which in turn will cause more delays until that gets done). It is perceived as a good practice in Drupal to also "give credit" to the submitter of the patch, by indicating your drupal userid as part of the commit message.

And from then on, it's a matter of waiting for a new release that includes the corresponding commit of course.

A great illustration of this workflow can be found in the issue at https://www.drupal.org/node/1947876 ... Even though that specific issue has taken really long (over 2 years ...) before it made it to the finish, i.e. status fixed and closed. What I find so amazing about this issue is that it is a perfect illustration of "the community at work", where each of the players did their part of the work ...

FYI: I'm a (co-) maintainer of a few Drupal modules (refer to my SE profile for details), sometimes it's hard to find sufficient time to process such RTBC-patches (waiting to be committed). But whenever I have time, I always give those RTBC-issues the highest priority, out of respect for the contributors of such patches (and the people who reviewed them) ...

PS: even if your patch doesn't get committed as fast as you'd like it to be, you should still continue submitting patches. Because that way you have them available for any sites where you believe this patch is required. This may require however that occasionally you need to update / rework your patches.


Alter default value for field settings (allowed_formats)

Thanks to @Berdir and @4k4 who helped me out several times - I just followed their ideas, tested and wrote up the answers.

This first hook alters the field settings.  I've included a second example for image settings.

/**
 * Implements hook_ENTITY_TYPE_create() for 'field_config'.
 */
function MYMODULE_field_config_create(FieldConfigInterface $field) {
  if ($field->isSyncing()) return;

  switch ($field->getType()) {
    case 'image':
      $field->setSettings(['file_directory' => 'images', 'max_resolution' => '1080x1080']);
      break;

    case 'text_with_summary':
    case 'text_long':
      $field->setThirdPartySetting('allowed_formats', 'basic_html', 'basic_html');
      break;
  }
}

This second hook alters the form display settings.  The array_diff_key command is used to determine which fields are new.

/**
 * Implements hook_ENTITY_TYPE_presave().
 *
 * Override field form display defaults used when a field is added to a content type.
 */
function MYMODULE_entity_form_display_presave(EntityFormDisplay $display) {
  $fields = $display->getComponents();
  $origFields = (isset($display->original)) ? $display->original->getComponents() : [];
  foreach (array_diff_key($fields, $origFields) as $newField => $settings) {
    switch ($settings['type']) {
      case 'text_textarea_with_summary':
      case 'text_textarea':
        $settings['third_party_settings']['allowed_formats'] = ['hide_help' => '1', 'hide_guidelines' => '1'];
        $display->setComponent($newField, $settings);
        break;
    }
  }
}


Javascript link in theme.info not working Drupal 7

Clear your cache. I think it may work for you.


It should be in "admin/structure/views", click the little arrow next to "edit" link under Operations column. If your view has changed from what's exported in code, it should display "revert" option there.


You can add the global view result counter field to the view, whose description in the Add fields dialog box is the following.

Displays the actual position of the view result.


You can create an internal url system that redirects to the partner sites. Depending on what you need to do, you could create a node (content) with info about the partner site where you stored the link to it. Then instead of displaying the link directly on the site you could instead display the url: redirect/[nid]. The url would be known by your module, and you could store info that you were sending some one over to the partner site before loading the node to find the url to send them over to.

You would have to create a custom module for this, but the above method could be a way of doing this.

You could also use tools like Google Analytics to track outgoing links instead. It depends where you want the data and what you need to do with it.


Sharing only one content type between 2 websites

If you are trying to share content between sites, you may want to look at the deploy module....

  The Deploy module is designed to allow users to easily stage content
  from one Drupal site to another. Deploy automatically manages
  dependencies between entities (like node references). It is designed
  to have a rich API which can be easily extended to be used in a
  variety of content staging situations.

To share a Content Type between sites, look into features:

  The features module enables the capture and management of features in
  Drupal. A feature is a collection of Drupal entities which taken
  together satisfy a certain use-case.

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

Alternatively if you're only trying to share a list of things, what about using RSS feeds from Website 1 and using the Feeds Module to pull it into Website 2?

  Import or aggregate data as nodes, users, taxonomy terms or simple database records.

  One-off imports and periodic aggregation of content Import or
  aggregate RSS/Atom feeds Import or aggregate CSV files Import or
  aggregate OPML files PubSubHubbub support Create nodes, users,
  taxonomy terms or simple database records from import Extensible to
  import any other kind of content Granular mapping of input elements to
  Drupal content elements Exportable configurations Batched import for
  large files

Also as mentioned in the comments the Migrate Module is worth a look.

  The migrate module provides a flexible framework for migrating content
  into Drupal from other sources (e.g., when converting a web site from
  another CMS to Drupal). Out-of-the-box, support for creating core
  Drupal objects such as nodes, users, files, terms, and comments are
  included - it can easily be extended for migrating other kinds of
  content. Content is imported and rolled back using a bundled web
  interface (Migrate UI module) or included Drush commands (strongly
  recommended).


If all you want to do is display that in/on your website, include it in an iframe, eg, create a block that just has:

<iframe src="http://www.addyosmani.com/resources/shinetime/"></iframe>

in it.

Now, if you are wanting to create a View, eg http://drupal.org/project/views, then you need to give some more specifics of what you are wanting to do.


How to put page-title inside of my content's first panel?

Given the theme's use of Panels, I would suggest looking into the default panels it uses and whether or not the title field can be manipulated in that way, so that the title could be placed in any given section you want.

EDIT from OP

"Just so. For future readers: I accessed Panopoly > Pages under the admin menu to alter the default page templates. Then for the generic Content Page, set "Title type" to "No title" and edit the settings for the content panel to "Override title" as "%node:title", "h1"."


Send e-mail when a field has a specific value

I don't know when you need to compare the field data,But you can probably do a form alter or modify the Workbench moderation module function.

Then create a component instead of rules and use a parameter if needed for field id or data.In action add send email.

Then you can invoke that component in the function you are using like this:-

rules_invoke_component('rules_save_review_field', 'paramval1', 'paramval2', ....);


Here is a very simple way to get the nid of the node currently being viewed:

$path = current_path();
list($entity_type, $entity_id) = explode('/', $path);

After this, you will have the entity id (the nid in the case of nodes) in the variable $entity_id.


Adding to that list of display options that includes "Default" and "Teaser"

You can either use the Entity View Mode module (which lets you define new view modes through the UI) or you can use hook_entity_info_alter() in a custom module to create them through code:

function MYMODULE_entity_info_alter(&$info) {
  $info['node']['view modes']['some_view_mode'] = array(
    'label' => t('Some View Mode'),
    'custom settings' => TRUE,
  );
}

The 'custom settings' bit is defined like this in the hook_entity_info() docs:

  A boolean specifying whether the view mode should by default use its own custom field display settings. If FALSE, entities displayed in this view mode will reuse the 'default' display settings by default (e.g. right after the module exposing the view mode is enabled), but administrators can later use the Field UI to apply custom display settings specific to the view mode.

Basically you want to set the to TRUE to have the view mode show up on the manage fields page.

Using either of those methods you should see your new view mode(s) pop up everywhere (the manage display form for nodes, in views, etc.)


Instead of using the admin blocks interface, if you really want to manually render blocks, you can render:

Directly in a template:

if ($block = module_invoke('module_name', 'block_view', 'block_delta')) {
  print render($block['content']);
}

Via code, with drupal_add_region_content

if ($block = module_invoke('module_name', 'block_view', 'block_delta')) {
  drupal_add_region_content('left',  $block['content']);
}


Checkbox left hand navigation drill down

Just to help others out here! This is called Faceted Search. After looking around and around online, I found it. There are a lot of posts about it. Drupal 7 uses Facet API to do this. However, it is still not extremely straight fwd...


For Drupal 7, use the Entity and Entity Reference modules. This is just a simple view. You don't need to create any relationship. Just add course type in Fields.


How to alter the name of downloadable excel sheet of webform

The only way to do this is to change the $node->title on the loaded object for the webform.  That filename uses that title, so I am assuming you have a webform title of "Localhost Worklog".

The problem with that is you only want to change the node title, when you are downloading the webform (or atleast running through that process).

You have two options (I think).  You could implement a hook_entity_load() function and then check if the URL is

node/%webform_menu/webform-results/download
or

node/%webform_menu/webform-results/download-file

function MYMODULE_entity_load($entities, $type) {
  if (arg(2) == 'webform-results' && (arg(3) == 'download' || arg(3) == 'download-file')) {
    foreach ($entities as $entity) {
      $entity->title = $entity->title .'_'. now();
    }
  }
}

Docs

The other way I can think of is altering the page callback with a hook_menu_alter(), changing the title there and then calling their function to return the form or download file with the updated node object to include the time appended to the title.

EDIT

From reviewing your update, it seems it's changing the title too soon on that page.  So I think you will need a combo approach.  Using hook_entity_load and hook_form_alter.  The point is changing that title in the $node object that is passed around for download.  So try this.

/*
 * Implements hook_entity_load().
 */
function MYMODULE_entity_load($entities, $type) {
  // Change the node title to include the time when downloading.
  if (arg(2) == 'webform-results' && arg(3) == 'download-file') {
    foreach ($entities as $entity) {
      $entity->title = $entity->title .'_'. now();
    }
  }
}

/*
 *  Implements hook_form_alter().
 */
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == WEBFORM_DOWNLOAD_FORM_ID) {
    // Change the node title that is passed around for download.
    // @TODO: Check to make sure this is correct.
    $form['node']['#value']->title = $form['node']['#value']->title . '_'. now();
  }
}


Multigroup (CCK3) / FlexiField-like solution for compound fields?

For the moment, I'm implementing this via Field collection. Granted, that is still very early development.

If somebody could provide a list of solutions in the "group content fields together and allow an infinite number of these groups via the 'add another' button", I'll accept that as my answer. I may have to upgrade my FlexiField project to D7 at some point and there's currently no clear upgrade path with that module.


How to create groups and assign users to them?

This sounds like a clear use case for the Organic Groups module. Organic Groups is great if you have a need to create a container for content and then associate users with that container.

However, if you don't have a need for any content-oriented aspects of OG (such as access control), then maybe all you need to do is make the associations visible, rather than a part of the site's information architecture. In that case, it sounds like you might want to use the Content Profile so you can leverage CCK Node Reference fields, which can be one:many arrangements, and using the bundled content_permissions module or Field Permissions, restricted to roles with specific permissions for editing the field.


I like adding the redirect to sites/default/settings.php instead of .htaccess (just because Pantheon ignores .htaccess redirects and a lot of my sites are hosted on Pantheon). I'm also just more comfortable with the syntax.

The first example will redirect just /suggestions to example.com/suggestions. The second example redirects any path beneath /suggestions (e.g., /suggestions/submit or /suggestions/submit/thankyou) to that same path on the main domain (example.com).

In terms of wild-carding this solution for scenarios similar to 'suggestions', I don't think that would work. I mean you don't want to redirect everything so you have to check for a specific REQUEST_URI.

But you could use this solution as a template for the other redirects you need. If you have a very large number of these (or anticipate a large number in the future), you might consider switching to the Domain Access module instead as it would handle this scenario without any redirects or custom coding.

You'll need to update 'example.com' to match your main domain and you may need to change 'http' to 'https' is you're using TLS.

// 301 Redirect from /suggestions to example.com/suggestions
if ($_SERVER['HTTP_HOST'] != 'example.com' &&
  $_SERVER['REQUEST_URI'] == 'suggestions' &&
  (php_sapi_name() != "cli")) {
    header('HTTP/1.0 301 Moved Permanently');
    header('Location: http://example.com/suggestions');
    exit();
  }

// 301 Redirect from /suggestions/* to example.com/suggestions/*
if ($_SERVER['HTTP_HOST'] != 'example.com' &&
    $_SERVER['REQUEST_URI'] == 'suggestions' &&
    (php_sapi_name() != "cli")) {
      $url = $_SERVER['REQUEST_URI'];
      $url = substr($url, 13); // stripping '/suggestions/' which is 13 chars
      header('HTTP/1.0 301 Moved Permanently');
      header('Location: http://example.com/suggestions/'. $url);
      exit();
  }


Did yout try simply add new filters?

For example, user:

Add Filter Criteria
Chose Filter - User
Search for "name" field
Select "User: Name"
Check "Expose this filter to visitors, to allow them to change"
Click "Apply"

That's all you need to do. I should notice that for amount and date you can expose operator for your own needs.

In the same way you can add SORT CRITERIAS


I had a experience about that, when using Ajax each short time each user and all of open each pages has requested to server ( if you look at firebug console you see what I mean ), another method is Long Polling method that also it is not the best way ( although it is better than Ajax method if very quick response time is not important for you), In Both cause heavy load on server (especially memory exhausted).ajax and polling is old method to interactive real time applications like chat
I strongly recommend you using Nodejs method, Nodejs is very good for realtime chat system

So use  Drupalchat nodejs integration solution

  f you use node.js as backend in this module, then it will be highly
  scalable. There are two ways to use this backend:

 First way is to setup your own node.js server and install Nodejs Integration module. This is currently under development.
If you don't want to or can't setup your own node.js server, then you can checkout our ready to use node.js server. If you opt for this

  method, then there is no need to install any additional
  software/package on your web server. To do so, please visit us at
  https://iflychat.com.

another solution is using nodejs_chat drupal module ( in both solution you require nodejs on yourserver).


If these are different content types, you could create a separate node-[type].tpl.php file for each, leaving out the title in one of them.

http://drupal.org/node/1089642


Users already have a personal contact form if you enable the contact form for users.
This way, you can place the link to the user's personal contact form, and then the email will automatically be sent to the author.


How do I remove the page title only from the front page?

The Title is a Block now in Drupal 8. You can edit the Page Title Block and set it to show on all paths except for <front> to hide it from the front page.


How to use AJAX form on custom maintenance page

When you put your site to offline mode, the menu router system (which is called first when a request is received to serve a page).

By default, Ajax forms are handled from the path system/ajax, which is not allowed when the site is in offline mode. This is not an issue with Drupal itself, it's just that when a site is in offline mode, there is no guarantee that any system is in working condition.

Ajax forms require the form to be cached, and that cache storage is the database unless you alter otherwise. When the database connection is failed, Drupal returns the same maintenance-mode page. Now, if you embed an Ajax form, imagine how there will be a recursion.

If you still need an Ajax form, you need to implement hook_menu_site_status_alter() to alter the site status for a specific path. Then, in your form, your will need to turn off caching ($form_state['no_cache'] = FALSE), and add your own #ajax properties with especially ['#ajax']['path'] set to your custom path that bypasses site status check (from the hook_menu_site_status_alter() hook).

I didn't bother to write an example since your question indicates you already have the Ajax form setup. Disable its cache, add a custom path to handle the submitted data, and make that path accessible with a hook_menu_site_status_alter() hook.


You need to create a view page, and in the FILTER CRITERIA you can add "for example" : content datasource:title and add the title of this specific page if it will not change
But the best is to use : ID = nid that you will find in your database in the
node_field_data table
Search for the title and you will find your ID and use it to filter in your views and that's it !


Define states that target only element in multi-value fieldset

See the first comment on my question, the Webform module (super-duper) maintainer @jrockowitz committed a change to the module's composite element example which explains how to do this in Drupal 8.

So this is my solution based on the question code:

use Drupal\Component\Utility\Html;
use Drupal\webform\Element\WebformCompositeBase;

class MembershipItem extends WebformCompositeBase {

  public static function getCompositeElements() {
    $elements = [];

    // Generate an unique ID that can be used by #states.
    $html_id = Html::getUniqueId('webform_membership_item');

    $elements['address_same'] = [
      '#type' => 'checkbox',
      '#title' => t('They live at the same address'),
      '#attributes' => [
        'data-webform-composite-id' => $html_id . '--address_same'
      ],
    ];

    $elements['address_postal'] = [
      '#type' => 'textfield',
      '#title' => t('Postal address'),
      '#states' => [
        'visible' => [
          '[data-webform-composite-id="' . $html_id . '--address_same"]' =>['checked' => FALSE],
        ]
      ]
    ];

    return $elements;
  }
}


In my Simplenews twig template how do I get the URL of the page I am emailing?

This is better!

      You can view this news article in your web browser


Go ahead and download this https://drupal.org/node/1209450 module in zip. there are two zips you can download any one. here is the code can you use now

function modulename_message_alter(&$message) {

    if(isset($message->messages['error'])){
       foreach($message->messages['error'] as &$val) {
        if(preg_match('@The entered date must be \w+/\w+/\w+ or \w+.@',$val)){
            $val='This is not correct date';
        }
       }
    }
}


I don't have the write permissions for the directory /admin/config/media/file-system. So, I got to change the write permissions to files directory that appears in /sites/default path
- change permissions from dwrx-rx-x to dwrx-wrx-wrx

If every thing goes well, you will no longer see the warning. Now, you are ready to install the new modules/themes.


Creating Nodes and Referenced Nodes at Same Time

For a couple different sites now, I've done this using a ctools modal, and here's the basic outline of how I've implemented it (very simply):

Create a custom page callback in your module's hook_menu() that displays a basic node form for the node you want to reference (for a 'student' node, just have a name field and maybe a graduating year field). On that form, in your submit callback, save the node using node_save(), and store the node ID (which should be at $node->nid after you pass a new node object to node_save()) in the form's $form_state['storage']['student_id'].
Alter the master/Class node form using hook_form_alter(). You need to do a few things here:

First, you need to add in the ctools modal javascript and
    functionality so ctools knows what to do with your special link:

// Add in ctools modal js and functionality.
ctools_include('modal');
ctools_modal_add_js();

Second, you need to add a link to the page callback you created in step 1 in hook menu, and with that link, add the class 'ctools-use-modal'. So, for example:

// Add link to custom student form callback with ctools modal.
$form['add_student_link'] = array(
  '#markup' => l(t('Add Student'), 'mymodule/add-student', array('attributes' => array('class' => array('ctools-use-modal')))
);

In your custom page callback, you need to do a few things to make it work with or without JavaScript, and with ctools' form functions.

Here's an example callback:

<?php
function mymodule_student_form_callback($js = FALSE) {
  // Make sure $js (set by ctools) is TRUE/loaded.
  if ($js) {
    // Add in ctools modal form stuff.
    ctools_include('modal');
    ctools_include('ajax');
    $form_state = array(
      'ajax' => TRUE,
      'title' => t('Create a Student'),
    );

    $output = ctools_modal_form_wrapper('mymodule_create_student_form', $form_state);
  }
  else {
    return 'Javascript must be enabled for this feature to work.';
    // Or, if we wanted to load the form normally...
    // return drupal_get_form('mymodule_create_student_form');
  }

  // If the form is executed, dismiss the form and reload the page.
  if ($form_state['executed']) {
    $commands = array();

    // Close the frame.
    $commands[] = ctools_modal_command_dismiss();

    // Use one of the ajax framework commands to place the returned
    // student node nid into the proper form value, placholder div, etc.
    // See: http://api.drupal.org/api/drupal/includes%21ajax.inc/group/ajax_commands/7
    $commands[] = ajax_command_append('#student-id-placeholder', $form_state['storage']['student_id']);

    $output = $commands;
  }

  // Render the output.
  print ajax_render($output);
  exit();
}
?>

In mymodule_create_student_form($form, $form_state), build your form like you normally would, and then in the mymodule_create_student_form_submit(form, &$form_state) (submit) function, set the value of the NID of the newly created student node in $form_state['storage']['student_id']. This is how you'll get ctools/AJAX to pass back the new nid to your original Class form.
In my situation, I was using the modal to spit back some markup to the original page, so I passed the markup into a placeholder div using ajax_command_append(), then I had some jQuery on the original page monitoring the placeholder div, and when it found content in it, it would move the HTML into the proper place elsewhere on the node form. In your case, you'll need to populate a single or multi-value node reference field, which may be a little more complex. I haven't needed to do that yet... so I don't have more advice to offer for that part of the equation.


How to integrate messaging into a custom module?

Have a look at the Message Stack, these are the basic components and dependencies of it:

Some more details about the Message-related modules (=quotes are from the module's project page):

Message:

The Message module is the core of the message stack. It enables logging and displaying system events in a number of different use cases. Events that are recorded over time are sometimes call activity streams. Exportable messages subtypes can be created for different use cases with custom fields and display (view) modes.

Message Notify.

This module provides a method for sending a message via a notifier plugin. Message Notify comes with plugins for email and SMS and may be extended to other transport mechanisms as required.

Message Subscribe.

With this module, users who subscribe to content will be notified when events occur that involve that content. The module leverages the Flag module, which provides a subscribe functionality to users.

Quite a few popular Drupal distributions already adopted to this Message Stack, Open Atrium is one of them.
If you'd rather look at an existing module as an example, then checkout the 7.x-4.x version of the Answers module (disclosure: I'm a co-maintainer) and its Answers Notification sub-module. This sub-module allows logged in users to subscribe to selected questions, so that they receive notifications (using the Message Stack) when Questions receive Answers.


Theme function overrides and preprocess functions - for the non-programmer

Well, the theme layer is PHP, so you will need a minimal understanding of some programming concepts (e.g. what a function is). Especially since you will have to write some basic PHP within them. So the following might not be perfectly suited for a non programmer initally, but I tried to link everything so you can read more about it. Also, add comments if something is not clear.

The theme layer builds upon naming conventions on how to name your functions to have them called automatically. Similar to the so called hooks. At least preprocess functions are a special variant of hooks. I'll come back to that later.

Any module can register theme functions (or templates) by using hook_theme() (You don't need to understand how that works right now). ) For example,  it can basically tell Drupal that it has a theme function called mymodule_fancything. This module is then also responsible for providing the default theme function, which is prefixed with theme_. In the previous example, that module needs to define the function theme_mymodule_fancything.

Later on, that, or any other, module can call that theme function with the function theme() like this: theme('mymodule_fancything', $arg1, $arg2); (D6) or theme('mymodule_fancything, array('arg1' => $arg1, 'arg2' => $arg2));` (D7).

Then, that function will figure out which function to call. First, it will check if there is a theme override for the active theme. That means, a function that is prefixed with themename_ instead of theme_. So in our example, themename_mymodule_fancything. If it finds that function it will call that and if not, it falls back to theme_mymodule_fancything.

As you've seen in the example code, you usually pass a number of arguments to a theme function or a template which contains the data that should be displayed. Sometimes you want to further process/change that information before it's passed to the theme function or the template. Or a module wants to change something of another module. Also because theme functions/templates should not contain any complex PHP processing. Unlike with the mentioned hooks (which can be implemented by all modules and all are called), a theme function can only by overridden once.

That is where preprocess functions come into play. They are invoked by the theme() and receive all arguments passed to that theme function (only in D7) or template. Then they can be altered/extended in any way. There is a large number of rules what preprocess functions are called when but basically, you usually only use one that is specific for a given theme function/template. That looks like this: name_preprocess_hook(&$vars). name can be the name of a module or theme and hook is the name of the template/theme function. There are tons of examples for preprocess functions in core, search for preprocess.

Remember to rebuild theme registry (e.g. with devel.module or by re-saving the theme configuration form).


Profile fields shown during registration

The field permissions module should help with this.  You can set individual permissions on fields of user and node entities.  If you set a field permission to be visible to only authenticated users, then it won't show on the sign up page.

Here is an example with screenshots:

These are the fields I have in Profile 2

When editing the field for "Will not be visible" I scroll to Field visiblity and permissions and select custom.  Then check the types of users that can see/edit values for themselves and others.  By default everything is only checked for admin.

Then when going to create an account you can see the "Will not be visible" field is not visible.


Website saves separate sessions for "www.domain.com" and "domain.com"

For usability (this problem) and SEO reasons you should redirect all visitors to a single version of the site. Look in the .htaccess file and you should see instructions on how to do a 301 redirect to send people to either the www or the non-www version of the site.

If you really really do want to make the site work on both versions, open your settings.php and find the line for $cookie_domain. Set it to be the "example.com" version and it should work.


Responsive Layout of multi-page website in Adaptive Theme

The more recent methods concerning responsive design is "mobile first". It's more time consuming to theme a desktop site and then bring it down it pieces to a mobile version, but some of this goes into the initial architecting as well. But, this is another topic.

You should keep your CSS as generic as possible at first, then drill down to specific items when you need to. Something you might want to look into is using a CSS preprocessor like LESS or SASS. On our projects (generally using LESS), we make CSS files for different regions of the site. Header, content, sidebar, footer, mobile, etc. and then compile them all into a few CSS files. In this screenshot, you can see the different sections broken up and they're all compiled into the global.css (the others are direct).


Puilling Information From Referenced Entities to Display/Use In A Custom Content Type?

Two suggestions

First, the most common solution:

Create a View
Add a "relationship" from Release to Stars
Add whatever fields you want to display, in this case, "Name", and make they "Use relationship Stars".

Second, what I would have done:

Create a suitable Panels Page for Releases
Create a mini-panel for Stars
Add the Stars reference field to the releases page with "Panels reference formatter", choose the mini-panel as the formatter.

Intro to Views.

Intro to Page manager and Panels.


Image styles not generated with Drupal 7 on IIS 6

Ok, I figured it out.

The problem was that there were two .htaccess files. One in the top level, that contains most of the configuration and one in sites/default/files, which is security related (avoid execution of php files and similar) and contains just this:

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks

Now the difference seems to be that in Apache, both files seem to be combined (the one in sites/default/files inherits everything from the top-level one). This does not happen with the ISAPI_Rewrite module that seems to handle the Apache/IIS .htaccess compatibily.

I fixed this by copying the content of the top-level directly into the file in sites/default/files, below the existing content. Additionally, I had to change the RewriteBase so that it included the index.php file in the correct directory.

The header of the changed .htaccess file now looks like this:

# From the original .htaccess file, do not remove.

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks

#
# Apache/PHP/Drupal settings:
# (copied from /.htaccess)
#

Content of the top level .htaccess file here comes here...

And the part that I changed now looks like this:

# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
RewriteBase /YOURFOLDERHERE

So when Drupal is installed in a sub directory, insert your folder name. If not, you can leave this part commented out.

I found this thanks to the (unecessarly long) blog post at http://www.caspianit.co.uk/imagecache-wrong-path/

Note: Simply deleting the .htaccess file in sites/default/files did work too, however, that removes the security relevant SetHandler setting. I however doubt this has any effect in IIS anyway...


db_insert in Drupal 7 without field names

You can not do this with db_insert().  You could probably dig into the InsertQuery class and get it done, but that's no different than what you're already doing IMO.

I have never seen INSERT without specifying column names, for good reason, although apparently you can (mysql api).  If you do this, it makes it more difficult for someone else to understand what you've done, and impossible to alter the table structure without causing headaches.

You can look at the waydrupal_write_record() uses drupal_get_schema() to create the fields if you'd like to automate the process (although it would probably take just as long to write the $fields array one time).


CPN: Replacing tokens in physical css/js files

Both drupal_add_js and drupal_add_css have an option to add code "inline".  You can try his in a template_preprocess_node:

function mytheme_proprocess_node (&$variables)
{
  drupal_add_js($variables['cpn']['js'], 'inline');
  drupal_add_css($variables['cpn']['css'], 'inline');
}

If you do this in a theme, then the CPN hook should have already been fired.  If you do it from a module, you may need to play with the module weights to get yours to follow.


How to print text (formatted, long) in twig without raw filter?

With the excellent Twig Tweak module you can do this:

{{ node.FIELD_NAME.value | check_markup(node.FIELD_NAME.format) }}

This feature (and more) is well documented on the module's cheat sheet.


Create a view on a entity using criteria on another entity

A view of entity one in relation with entity 2 referenced field may work, but maybe you can try the other way around:

Create a view of Entity 2 (Listing Premium Settings) with field titles or nid that you exclude from display (and maybe remove at the end)
Create your filters at your convenience of time
Define your relationship: content referencing the first entity
Then add the fields of entity one you wish to display in your view, using the relationship in these fields.

In that sense it might give you more control on the filters which are attached to entity 2.
In the other sense (entity 1 relationship to entity 2) it gives you more control on the fields of entity 1 to display in case of multi-value field for example.


How to Save a Node Object reached from another Server?

Are you working on a multilingual site?
Trying to save a node that have different language than expected, for example "it" instead of "und" fails, event if the node is cloned from another site in which is working well.

You could also try to
unset($node->nid)
unset($node->vid)

they are not required in order to create a new node.


Drupal, Crawlers, and Migrating from a Query string based site to a Clean URLs site

You need to handle this in your httpd.conf or .htaccess before Drupal handles it.

Your best bet is to come up with some rewrite rules and 410 Gone them.  Something like this

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} page=(\w+)&stuff=(\w+)
RewriteRule ^(.*)$ - [G,L]

should be a start.  You need to play with the query string to match the inbound requests.


In your own custom module implement hook_views_pre_render and alter the view's result in the following manner:

function MYMODULE_views_pre_render(&$view) {
  if ($view->name == 'my_view') {
    // for example reverse the result
    $view->result = array_reverse($view->result);
  }
}

Use devel module and namely the dpm function to test your code before and after. It is very handy.
Hope this helps.


Show name of the taxonomy filtered by in views block title

Yes, you can get the taxonomy term name and use it in the view title.
It's possible with the contextual filter settings. You can achieve your goal in two ways:

  Option #1 ( Using "%1" for the first argument, "%2" for the second, etc. )

When the filter value IS available or a default is provided:

Override title -> More %1 articles

Specify validation criteria -> Taxonomy term

Filter value type -> Term ID

Action to take if filter value does not validate -> Hide view

  Option #2 ( using PHP code )

When the filter value IS available or a default is provided:

Override title -> check this option, but leave text field empty.

Specify validation criteria -> PHP Code

Enter the code:

$tid = $handler->argument;
$term = taxonomy_term_load($tid);
if ($term){
  $name = $term->name;
  $handler->options['title'] = "More $name articles";
  return true;
}
else{
  return false;
}

Action to take if filter value does not validate -> Hide view


Is there a way to import Paragraphs with Feeds module (no code)?

The Drupal 8 version of Paragraphs does support some basic Feeds integration with a "Target" (see the source code)

Alternatively you could write a Processor plugin that manually creates and associates the paragraphs contained within a node.


So I decided to create a module to extend twig and get the file url from its fid.

get_url_from_fid git project

Source of src/GetUrlFromFid.php

<?php
namespace Drupal\get_url_from_fid;

class GetUrlFromFid extends \Twig_Extension{

  /**
   * {@inheritdoc}
   * This function must return the name of the extension. It must be unique.
   */
  public function getName(){
    return 'get_url_from_fid';
  }

  /**
   * In this function we can declare the extension function
   */
  public function getFunctions(){
    return array(
      new \Twig_SimpleFunction('get_url_from_fid',
        array($this, 'get_url_from_fid'),
        array('is_safe' => array('html'))
      )
    );
  }

  public function get_url_from_fid($fid){
    $file = \Drupal\file\Entity\File::load($fid);
    if(!is_null($file)){
      $uri = $file->getFileUri();
      return file_create_url($uri);
    }else{
      return false;
    }
  }
}


Creating a new menu item that links to /user

To move an existing menu item to a different menu in code, you can implement hook_menu_alter() and change menu_name and weight for $items['user'].


Is it possible to provide logins based on purchases?

YOu don't need a real login, just an access to a certain node. For this, you can use the Node autorize link module:

  Generates link for view, edit, or delete content without login

So, when someone pruchases something you must create a node tieh the data tue user can view. Add the view authorize link to the purchase email notification and the customer will have access to the node with data just following the emailed link.


Use contextual filter on no results behavior

If you have the PHP input format enabled you can use arg(1) in the empty text for the view.


In editing content, can I show source formatted HTML

Syntax highlighting is your keywords.  I uncovered this for you.
http://code.google.com/p/ckeditor-syntaxhighlight/wiki/Installation

There is most likely more plugins available but you will need to add a plugin to achieve what you are looking for.


Internal Server Error? Why is this happening?

Q. Why is this happening?

This can happen if the .htaccess files in your Drupal directory use settings or trigger actions which are not supported by your Apache server config. If you're not running the server yourself, but are registered with a webhost, you can either ask your webhost to enable the options in question, or just comment them out in the htaccess files.

The options which are known to cause an Error 500 are:

Options -Indexes
It may also occur when setting very permissive file permissions (777) and your hoster added some security checks to avoid this. Try to lower permissions.
Another problem can occur if you're using .htaccess files using UTF-8 codification with Byte-Order Mark (BOM). Reencode your .htaccess files properly without BOM to solve this.
This error can also manifests itself as a PHP error. Try adding the code below to one of your PHP files such as local.php, then checking the error log file it generates.

ini_set('log_errors', 1);
ini_set('error_log', 'errorlog.txt');

Read:

HTTP Error 500 Internal server error

List of HTTP status codes


You can suggest a new template file with the following code.

use Drupal\taxonomy\Entity\Term;

function THEME_NAME_theme_suggestions_page_alter(&$suggestions, &$vars) {
  if (\Drupal::routeMatch()->getRouteName() == 'entity.taxonomy_term.canonical' && $tid = \Drupal::routeMatch()->getRawParameter('taxonomy_term')) {
    $term = Term::load($tid);
    $suggestions[] = 'page__taxonomy__' . $term->getVocabularyId();
  }
}

Then create the file: page--taxonomy--VOCABULARYNAME.html.twig and customise it as you wish.


How to access fields from node template without render

You can do it like this:

$lang = field_language('node', $node, 'field_name'); // gets field language

print $node->field_name[$lang][0]['value']; // prints field


Drupal 7 Ajax GET - Error 400 (Hook_menu)

The % symbol is type of placeholder in hook_menu item. You can read more about it here: https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_menu/7#sec_path_wildcards.

For you example I suggest to use the following:

function my_db_module_menu() {
  $items['callback'] = array(
    'title' => 'My callback',
    'description' => 'Desc',
    'page callback' => 'mymodule_getinfo',
    'type' => MENU_CALLBACK,
    'access arguments' => array('access content'),
  );

  return $items;
}

Simple path  - callback.

And use the following AJAX:

$.ajax({
  url: '/callback',
  type: 'POST',
  dataType: 'json',
  data: {data: post},
  ...

By this way, you can access the data in your webhook more simply:

/**
 * My callback
 */
function mymodule_getinfo() {
  $data = !empty($_POST['data']) ? $_POST['data'] : array();

  // do what you want...
}


If you're executing the VBO operation while in the Views configuration page, you're likely to run into this error. Save your view and go to the URL for that view and then run the operation.

A 200 return code actually indicates success, but the presence of the AJAX debugging screen interferes with the completion of the operation.

I know because I just ran into a nearly identical issue. :-)


How to save autocomplete and date type fields while adding node programmatically?

I think

$node->field_user['und'][]['target_id']

and

$node->field_time['und'][]['value']

is the good way


hook_node_load for currently viewed node?

It depends on when and where you trying to modify the $node. hook_node_load runs every time a node is loaded,whereas  hook_node_view runs only when a node is about to be rendered on the page.

The reason you might not be having the node id in question in you hook_node_load may be because the context in which you are calling hook_node_load might be wrong.
In order to test you can create a dummy callback and call the node_load() in it with you nid in question. You can see that once you call the node_load() api, it will invoke a call to hook_node_load.

Cheers


Restrict a menu item only for a particular accessible after loggin and optionally for a role

If you actually just want to check if the user is logged in and don't want to set up permissions, you can set the access callback to 'user_is_logged_in':

$items['start'] = array(
  'title' => 'Take A Test',
  'page callback' => 'qe_start',
  'access callback' => 'user_is_logged_in',
  'expanded' => TRUE,
);


Answer 1:-template.php file will runs first.you can check it by using die() on top of all files.

answer2 :-For changing some variable's value for page.tpl.php/html.tpl.php use function function XXX_preprocess_page().

html.tpl.php -> Handles meta info, body classes

page.tpl.php -> Handles content body display

node.tpl.php -> Handles content display

field.tpl.php ->Handles per field display

Template.php provide display alteration  for all these files.


Node template only on specific page (Drupal 7)

add template.php:

function THEMENAME_preprocess_node(&$vars) {
  if (request_path() == 'specific/page') {
    $vars['theme_hook_suggestions'][] = 'node__specific';
  }
}

and create file node--specific.tpl.php in theme dir


Views contextual filter to a number of product variations

You could try like. First include sku in your view and exclude it from display. Then write this code it would give u desired results.

function modulename_views_query_alter(&$view, &$query)
    {
    if($view->name=='yourname'){
        preg_match('/.*[^\d+]/',drupal_get_path_alias(),$match);
        $query->add_where(1,'commerce_product.sku','%'.$match[0].'%','LIKE');
    }
}


You'll need to write a custom module that calls an AJAX function after each field of the Webform has been changed that fires the same function that the Save draft button does.

Shouldn't be too complicated, there is a starting point at Use AJAX to auto save a draft which should hopefully push you in the right direction, plus Webform Ajax might also help


Drupal 6 failing to login user in IE7 but forwarding to user account page

I would try the following in order:

Ask the user to clear their browser cache.
Rebuild permissions - admin/content/node-settings/rebuild
Create a test account with the same roles.
Manually verify the roles and permissions haven't changed.


Hide body on node edit if user can't access input format

Not really an answer, but there is AFAIK no way to change this without hacking core.

The check for this is directly in node_access() and can't be altered.

What you are trying to do is btw how it works in Drupal 7, see the corresponding issue.


Store the result into a session like below

function get_all_products() {
  $prod = get_products();
}

function get_products($reset = FALSE) {
  $res = $_SESSION['products'];
  if(empty($res) || $reset) {
    $key=array();
    $flowervalue=array();
    for($i=2;$i<=150; $i++) {
            $url="http://testurl.com/test/node/".$i.".jsonp";
            $timeout=0;
            $ch = curl_init();
            curl_setopt($ch,CURLOPT_URL,$url);
            curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
            curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
            $data = curl_exec($ch);
            $jdata=json_decode($data);

                if($jdata->type=='product') {
                    $key[]=$jdata->nid;
                    $flowervalue[]=$jdata->title." ".$jdata->field_petals_code[0]->value;

                }

    }
    $res=array_combine($key, $flowervalue);
    $_SESSION['products'] = $res;
  }
  return $res;
}

Else if you want cache the  $url="http://testurl.com/test/node/".$i.".jsonp" enable the page caching in drupal.


8 How do I display "Showing content between date1 and date2" on the current pager item?

There is an other way for "Showing content between date1 and date2" use the Exposed filters  fields for the "Start date" and "End date" with Is between Operator. According to field created in the content type, From this You can easily filter the content according your filled date and set displayed items in pager.
Hope its helpful to you!


Create custom action for Views Bulk Operations

I believe your type should not be entity but the actual entity type you want to use, like node. Then it should show up on nodes.

Also VBO requires no triggers to be defined, unless you want the action to be triggered via the action module as well. For just VBO this can be an empty array.
I have no idea what behavior is, never used it.

See an example of VBO with a form here: Add multiple friends at once with user relationships


How To Rescue Content from a Corrupt Database

The database isn't likely to be corrupt - unless you're coming up against a ridiculously unlikely scenario, it wouldn't work for any users at all if it was corrupt.

If the data was corrupt, you wouldn't be able to restore the backup, it would fail.

What you need to do is look into the server logs; you're currently seeing a WSOD (White Screen of Death), which is common in PHP applications.

Your server logs will contain details of the exact error your site is encountering, and you can use that information to decide on how to debug and fix it.


Change template of Drag & Drop module on node add form

You can do this by updating css into that module.

Or once try to use HTML5 Drag & Drop File module. Hope this module provided that you want.

  HTML5 drag & drop + HTML5 file upload with XHR2. Allows the user to
  drag & drop files into a Image/File Field and uploads it immediately
  behind the scenes. In theory it should work for as many files as the
  field allows.


custom block's BLOCK_VISIBILITY_LISTED not working on profile installation hook_install()?

I had to do this in a module that gets installed after all other modules installation in the profile using

  hook_install_tasks()

and in the the new task's callback i enable the module with module_enable


How can you automatically add CSS classes to  tags in the post body?

I have found how to resolve this specifically if using the Tailwind framework, which I am.

You can use the @apply function of the framework to add classes based on common Drupal class names, or ones you specify in your custom html.twig files.

Documentation here: https://tailwindcss.com/docs/functions-and-directives/#apply
I am using the Tailwind Starter theme which also uses this function https://www.drupal.org/project/tailwindcss

For example, to apply the text-xl utility class to node paragraph tags, I can use the following code in my stylesheet

.node-content p {
  @apply text-xl
}


You can use the inline_template to solve the problem:

// Delete the other button.
unset($form);
$form['submit'] = [
  '#type' => 'inline_template',
  '#template' => '<button type="button" class="btn btn-success" disabled="disabled">Product unavailable</button>',
];


How to add a menu item to main menu: hook_menu() or menu_link_save()?

After a hard time I figured out what hampered the execution of the above code: clearing caches isn't enough to see the results. I had to use devels menu reset (/devel/menu/reset). Using drush's drush eval 'menu_rebuild();' as mentioned at How do I call the menu_rebuild function in Drupal 7? somehow does not work. I do not know why.


Should I use all these template files or will theme hooks do the job?

The module that defines a template defines if it is a template or a theme functions, that's not something you have any influence over.

And yes, theme functions are faster, but they're also deprecated and will be removed completely in Drupal 9 (Because twig is far easier to write than PHP). With render caching and so on, the performance difference is no longer as relevant as it used to be.

The performance difference is between having a template or not. There's anyway a template, just not a custom one, and the only performance difference then is the additioal complexity that your template adds and what you are doing sounds trivial.

There might be reason to do what you're doing differently, you could use preprocess, but you'd need to at least share your templates/code (you should always do this when asking questiosn) so you can get a specific code example. But not because of performance, a more valid reason would be code/template management, it will be more work to make further changes if you have 10 different templates or just one.


Yes, that API doesn't support passing in the language.

I would recommend you use a view mode for what you are doing. You can click that together in the UI, configure the fields you want to see there and then just call $node->view('your_view_mode'). That should just work.

You could also use the Entity View block provided by ctools module, then you can place your sidebar as a block in a region and don't need any custom code at all.


The Expanding & Folding of the information related to a checkbox isn't working in drupal 7.34

I had a similar issue back in August. It was the jQuery update module that was the problem.  The configuration at this link finally worked for me: https://www.drupal.org/node/1810656#comment-8677587


How to render node content according to site theme after hook_node_insert/update?

So first as the hook_node_update doc says:

  Note that when this hook is invoked, the changes have not yet been
  written to the database, because a database transaction is still in
  progress. The transaction is not finalized until the save operation is
  entirely completed and node_save() goes out of scope. You should not
  rely on data in the database at this time as it is not updated yet.
  You should also note that any write/update database queries executed
  from this hook are also not committed immediately. Check node_save()
  and db_transaction() for more info.

Solutions:

There's a module for that: hook_post_action

There's also a short article about drupal_register_shutdown_function


Trouble extracting year from date field for computed field

Function array dereferencing was added in PHP 5.4, you must be using an older version.

To fix:

$parts = explode("-", $date);
$year = $parts[0];


Which hook for code after a node has been deleted from the DB?

There isn't one. If you look at node_delete_multiple(), which node_delete is a wrapper function for, you can see that the only hook invocations (the above hooks) are triggered before the DB delete statements.

If your Drupal site only allows deleting through the node/$nid/delete form, one alternative to a post-delete hook is appending a submission handler to the node deletion confirmation form:

function MYMODULE_form_node_delete_confirm_alter(&$form, &$form_state, $form_id) {
  $form['#submit'][] = 'MYMODULE_node_delete_confirm_submit';
}

function MYMODULE_node_delete_confirm_submit($form, &$form_state) {
  //@TODO: Post-node-delete code here
}


How do you programmatically modify a programmatically created content type?

http://api.drupal.org/api/drupal/modules--field--field.crud.inc/function/field_update_field/7
http://api.drupal.org/api/drupal/modules--field--field.crud.inc/function/field_update_instance/7

Open WWWROOT/profiles/standard/standard.install (starting from line 199)
Profile install creates basic content types (like Article and Basic page)


Why am I getting "Access Denied" on /user/login?

Probably your IP has been blocked as a potential source of flooding/DoS attack. This may happen if there were a lot of requests from the same IP.

That happened to my company's site once when we rearranged our LAN structure so all intranet users could only access the site through proxy server, and proxy server IP was blocked by Drupal automatically.

You need to check flood table - there must be a record with your IP. Just delete that record or all records (DELETE from `flood`).


You can create a view of taxonomy terms with a contextual filter of the type Taxonomy vocabulary: Machine name

Add relationship called Taxonomy term: Content with term and use that relationship to add the contents.


Although EFQ is a good tool, it starts with the assumption that you are querying about a field value.  It does not do the join because it is more efficient to get what you want the way it does it.  For you legacy nodes, I think you should do a legacy Dynamic Query.  This way you can specify a Left Join to get a result set that includes nodes with NULL/absent entries in the field table.

$query = db_select('node', 'n');
$query->leftJoin('field_data_field_myfield', 'f', 'n.nid = f.entity_id');
$query->condition('f.value', array('myvalue', NULL), 'IN')
  ->condition('n.type', 'my_content_type');

Joins in the dynamic query method.


Rendering drupal login form in a modal window

Modal forms module might help you.

Modal forms make use of the modal feature in the ctools module to open some common forms in a modal window.
Supported forms:

Log in (modal_forms/nojs/login) Request new password
(modal_forms/nojs/password) Create new account
(modal_forms/nojs/register) Contact (modal_forms/nojs/contact)
Comment (modal_forms/%ctools_js/comment/reply/%node) Webform
(modal_forms/%ctools_js/webform/%node)


You can create grids inside the main container or others.

You can look at these 2 modules for views and grids:

Views Responsive Grids

Views Column Class

Then you only need to create your own grid for that view. And of course you can select n columns with nth-child

For example: A view with Views Responsive Grids of 3 columns and N rows

  .your-view-class {
  $zen-column-count:  3;
  @include zen-grid-container();
  div:nth-child(n+1) {
    .views-column-1 { @include zen-clear(); @include zen-grid-item(1, 1);}
    .views-column-2 { @include zen-grid-item(1, 2);}
    .views-column-3 { @include zen-grid-item(1, 3);}
  }

}


How to log all outgoing links generated in a view?

You could use jQuery to attach a click event to each link that triggers an ajax request to record the click.

The problem with this is that the page may redirect before the ajax request has had a chance to fire so you will have to prevent the default action of the click, and then perform an ajax request with async=false, and then provide a call back function to redirect to the links destination.

Not exactly lightweight...

Another option is to define an outbound link function in PHP that will accept the final destination as a argument. So the link would look like /outbound?dest=http%3A%2F%2Fwww.google.com.

Then in that function you can record the click, and then redirect them on to the destination passed in...


Are there any advantages or issues with using a Google Analytics CDN app with the GA module?

CloudFlare acts as a reverse proxy and a CDN. So it can change the HTML output of your Drupal site. If your site has no Analytics script, it can add the code for you. That's for the convenience only. You are still using same Google Analytics.

For Performance

I would avoid GA module if there is a custom module that already has a hook_page_build or hook_page_alter hook. I'm more of a developer so I feel like the GA is an unnecessary load when I could include it in a custom module.

For Easy integration with precise tracking

With GA module, you can expose custom variables to GA, have per-path, per-role, and other contextual tracking, and also cache the snippet (This is actually a bad step IMHO because ga.js snippet is usually cached in the browser from your site or from some other site that uses GA).

If you don't have access to edit the modules, or would prefer to use the contrib, GA module would be better.

For the easiest integration with blind tracking

Use CloudFlare. They are a really good service (I took part in a CloudFlare guide ebook too), and responded quickly to the recent core SQL injection vulnerability. If you don't care about precising tracking, I would use CloudFlare.


How to add rel="author" attribute to Drupal 7?

The rel=author property is now supported by the Drupal 7 Metatags module dev version.

After installing the metatags module (http://drupal.org/project/metatag), go to admin/config/search/metatags, and edit the front-page or one of the node pages. Under 'Advanced' you will see the author and publisher fields where you can input your google+ page URL. On the following screenshot, I've marked the places you need to change the configuration in pink.

Metatags frontpage configuration page:


How to expose the user's email on the user's detail page?

By default the mail field is not configurable in view modes.

You can change this in a custom module. Place this hook in mymodule.module

function mymodule_entity_base_field_info_alter(&$fields, $entity_type) {
  if ($entity_type->id() == 'user') {
    if (isset($fields['mail'])) {
      $fields['mail']->setDisplayConfigurable('view', TRUE);
    }
  }
}

and you'll find the mail field in the Manage Display page.


Create a relationship between the current content type, and users.

Select Content: Author and click on Add and configure relationships. Leave the settings as they are and click on Apply (all displays).

Filtering the view

Now you need to filter the view to display only content authored by the current user.

Use the filter "User: Current".


url redirections not working for anonymous users

This is probably because of the page cache for anonymous users. The cache is implemented as middleware and runs before any event subscriber, even if you set a  high priority.

If your site serves dynamically generated responses and redirects for every single request, then you don't need this cache and you can uninstall the module Internal Page Cache.

If you want to disable the page cache in code:

\Drupal::service('page_cache_kill_switch')->trigger();

This will deny any page caching on the current request.


Record video clip from webcam in Drupal 7 custom module

There is Media: Webcam

  This project (still under active development) will add a Webcam
  capture tool for video and images to FileField. Video requires a Red5
  or Flash Media server to also be available; documentation for this
  coming soon enough.

Browse the SOURCE to get some inspiration.


dd a class="" to anchor on the "read more" links of a node

Add template.php file to your theme directory if it doesn't exist. Then, add template_preprocess_node() to it like so, replacing template with your theme name.

function template_preprocess_node(&$variables) {

  $variables['links']['node']['#links']['node-readmore']['attributes']['class'][] = 'btn-default';
}


Is it possible to translate image Title and Alt fields and sync images between tranlations?

Assuming you're talking about images uploaded to the site by users and administrators (and not static images that are integrated into the site as parts of a theme or a module), and you're talking about Drupal's core locale framework for translation and the built-in extensions available through the i18n module, the answer is "no".

Like everything else, it is of course possible to create a custom module to manage translation of image title fields (preferably as a submodule of some popular image management module), but I am not aware of anything like that already exists.


/**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&$form, &$form_state, $form_id) {
  switch($form_id) {
    case "user_register_form" :
      //Your Logic
    break;
  }
}

But for performance issue use hook_form_FORM_ID_alter()


Content restrictions for logged in user with specific role

This looks like a perfect use-case for hook_node_access with $op='view'. You check if the user is 'special' and apply your logic to approve/deny the view.
You could have a new role for this, or a new field on the product nodes, or some other idea. It very much depends on what your logic is there.


Views block showing empty content on front end

Turns out it was my theme's block.tpl.php file. It was displaying content like so, $block->content.

I changed it to match the block.tpl.php file in modules/block:

<?php print $content ?>


How to show only published node in Drupal Facets (Facet API + Search API)?

You need to click the "Filters" tab in your search API index, then check the  "Exclude unpublished nodes" option.


Module invoke webform redirecting validation

Go to admin/block and edit your webform block and check "Show all webform pages in block" and all errors display in block not in node.

This should resolved the problem, however you can check more about this problem here: https://www.drupal.org/node/1308806


Putting together an answer based on the comments/discussion there so this can be accepted/closed.

General instructions on how to theme a mail can be found in this existing answer: How can I theme the outgoing contact mail?
You might want to watch https://www.drupal.org/node/2680731, once resolved, you can rely on that instead of your own custom code to send the mail as HTML.
To use a custom template for the inner parts of the mail, you can set a custom template in hook_contact_message_view(). Or use field templates for specific fields.
To check for a specific contact form, you can use the bundle() method of the contact message entity, which you can find in $message['params]['contact_message'] in hook_mail_alter(). Make sure you combine this with a check that it is there and an entity object, otherwise you could have fatal errors for other mails.


The following module is missing from the file system: (Theme name)

This is probably due to the modules changing locations since they where installed.  One way to fix this is to just edit the system table.  You can do this via Drush like this:

drush sql-cli

> select * from system where name = 'bootstrap_barrio';

Verify that the path column is not correct.

> update system set path='correct path here' where name = 'bootstrap_barrio';

If the path is correct, then it might be a directory rights issue.  E.g. either the module or a parent can't be read by the webserver.


Contextual Filter is used to filter ,output of the view by URL arguments, also u can pass the arguments manually in this format:

<?php print views_embed_view($name,$display_id,$arg1,$arg2,$arg3); ?>

where "$name" is the name of your view (ex. 'example_view') and '$display_id' is the display type of your view (ex. 'default') and "$arg1,$arg2,$arg3" are arguments just like in URL.

URL arguments has the following structure:

http://example.com/arg_1/arg_2/arg_3 (arg_2 has the path component 2 (in view setting page)).

When the filter value is not availabe:

it means drupal can't find any filter.

Provide default value:

when the filter value is not available you can use this option to to creat a filter for views output, this filter can be PHP code (if PHP filter module enabled) or it can get it's value from the URL arguments--> (Raw value from url).
The Exception textbox allows you to cheat the value and display all results.

When the filter value is available

in this case you do a validation as your needs and some other options, when drupal can find the filter value.


Accessing the uri within the template_preprocess_image_formatter

i've sorted it

you can do it like this

$variables['url']->getUri()


Specification of an Image field attached to forum topic node type?

have you created one image field that is shared between all of your content types, or a different image field for each content type? if it is the latter, this sounds like it is likely a permissions problem where one of the image fields is restricted to admin users only.

i'm not sure about D7, but there's a module in D6 called "content permissions" that seems like you should enable it but you really should avoid it if you can. There's probably an equivalent in D7 - the module denies access to all new fields for all user roles by default, and you have to explicitly give permissions back.

alternatively, it could be a caching issue. Drupal caching is much less aggressive for admins than for anonymous users so if you've made a few changes to your views that admins can see but anonymous can't, try clearing your site's cache.


When using the Real Name module, how can I show the original (raw) username in a view?

You're right in using the field User: Name as there is no explicit Raw name field (only a token). Now in the field settings you must uncheck Link this field to its user and More > Use formatted username.

If you still want to have a link to the user's profile, do some field rewriting: add User: uid, move it above User: Name, check Rewrite results > Output this field as a link with the path user/[uid] or user/[uid]/edit.


Commerce orders view for user and his subusers

Orders are entities. Views 3 on Drupal 7 fully supports entities.

Sub Users are entities as well, with the Relation module connecting the users.

The relationships that exist are deep and abstract to Views and, while it may be possible to do this with SQL, the resulting view would be very complex and inelegant.

So your question is more about how to construct a view with the right series of relationships so that you are given a complete list of orders out of a set of users. The most straightforward way to do this is to create a view of orders (so the base table is the order table) and then to use the contextual filters to provide a list of owner user_id's based on the currently logged in user using PHP.

Hint: You could use the following (UNTESTED) php snippet that makes use of a subuser function to provide an array of user ids:

// Updated with a tested bit of code:

<?php
// never use the global $user variable directly.
$account = $GLOBALS['user'];
// the subusers module abstracts this relationship easily for us
$subusers_children = subuser_load_all($account);
// views requires a return statement.
// the subuser_load_all() returns full objects, we just need the uids
$allusers = array_keys($subusers_children);
$allusers[] = $account->uid;
return implode(',',$allusers);

Here's an export of a view that works (sort of). The user permissions for this would have to be reworked to make it secure. Works with user 1 if user 1 has subusers and those subusers have orders.

// Edit 2: Did some more testing, found the view wasn't working and after some debugging, it started working correctly, limiting the users to our sub users group. Sorry about the weird problems initially introduced.

<?php
$view = new view();
$view->name = 'user_orders_with_subusers';
$view->description = 'Display a list of completed orders for a user.';
$view->tag = 'commerce';
$view->base_table = 'commerce_order';
$view->human_name = 'User orders with subusers';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Defaults */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->display->display_options['title'] = 'All orders';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = 25;
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
'order_number' => 'order_number',
'created' => 'created',
'changed' => 'changed',
'commerce_order_total' => 'commerce_order_total',
'status' => 'status',
);
$handler->display->display_options['style_options']['default'] = 'order_number';
$handler->display->display_options['style_options']['info'] = array(
'order_number' => array(
'sortable' => 1,
'default_sort_order' => 'desc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'created' => array(
'sortable' => 1,
'default_sort_order' => 'desc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'changed' => array(
'sortable' => 1,
'default_sort_order' => 'desc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'commerce_order_total' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'status' => array(
'sortable' => 1,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
);
/* No results behavior: Global: Text area */
$handler->display->display_options['empty']['text']['id'] = 'text';
$handler->display->display_options['empty']['text']['table'] = 'views';
$handler->display->display_options['empty']['text']['field'] = 'area';
$handler->display->display_options['empty']['text']['content'] = 'You have not placed any orders with us yet.';
$handler->display->display_options['empty']['text']['format'] = 'plain_text';
/* Field: Commerce Order: Uid */
$handler->display->display_options['fields']['uid']['id'] = 'uid';
$handler->display->display_options['fields']['uid']['table'] = 'commerce_order';
$handler->display->display_options['fields']['uid']['field'] = 'uid';
/* Field: Commerce Order: Order number */
$handler->display->display_options['fields']['order_number']['id'] = 'order_number';
$handler->display->display_options['fields']['order_number']['table'] = 'commerce_order';
$handler->display->display_options['fields']['order_number']['field'] = 'order_number';
$handler->display->display_options['fields']['order_number']['link_to_order'] = 'customer';
/* Field: Commerce Order: Line items */
$handler->display->display_options['fields']['commerce_line_items']['id'] = 'commerce_line_items';
$handler->display->display_options['fields']['commerce_line_items']['table'] = 'field_data_commerce_line_items';
$handler->display->display_options['fields']['commerce_line_items']['field'] = 'commerce_line_items';
$handler->display->display_options['fields']['commerce_line_items']['settings'] = array(
'view' => 'commerce_line_item_table|default',
);
$handler->display->display_options['fields']['commerce_line_items']['delta_offset'] = '0';
/* Field: Commerce Order: Created date */
$handler->display->display_options['fields']['created']['id'] = 'created';
$handler->display->display_options['fields']['created']['table'] = 'commerce_order';
$handler->display->display_options['fields']['created']['field'] = 'created';
$handler->display->display_options['fields']['created']['label'] = 'Created';
/* Field: Commerce Order: Updated date */
$handler->display->display_options['fields']['changed']['id'] = 'changed';
$handler->display->display_options['fields']['changed']['table'] = 'commerce_order';
$handler->display->display_options['fields']['changed']['field'] = 'changed';
/* Field: Commerce Order: Order total */
$handler->display->display_options['fields']['commerce_order_total']['id'] = 'commerce_order_total';
$handler->display->display_options['fields']['commerce_order_total']['table'] = 'field_data_commerce_order_total';
$handler->display->display_options['fields']['commerce_order_total']['field'] = 'commerce_order_total';
$handler->display->display_options['fields']['commerce_order_total']['label'] = 'Total';
$handler->display->display_options['fields']['commerce_order_total']['click_sort_column'] = 'amount';
$handler->display->display_options['fields']['commerce_order_total']['settings'] = array(
'calculation' => FALSE,
);
/* Field: Commerce Order: Order status */
$handler->display->display_options['fields']['status']['id'] = 'status';
$handler->display->display_options['fields']['status']['table'] = 'commerce_order';
$handler->display->display_options['fields']['status']['field'] = 'status';
/* Contextual filter: Commerce Order: Uid */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'commerce_order';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['default_action'] = 'default';
$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'php';
$handler->display->display_options['arguments']['uid']['default_argument_options']['code'] = '$account = $GLOBALS[\'user\'];
$subusers_children = subuser_load_all($account);
$allusers = array_keys($subusers_children);
$allusers[] = $account->uid;
return implode(\',\',$allusers);';
$handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['uid']['break_phrase'] = TRUE;
/* Filter criterion: Commerce Order: Order state */
$handler->display->display_options['filters']['state']['id'] = 'state';
$handler->display->display_options['filters']['state']['table'] = 'commerce_order';
$handler->display->display_options['filters']['state']['field'] = 'state';
$handler->display->display_options['filters']['state']['operator'] = 'not in';
$handler->display->display_options['filters']['state']['value'] = array(
'cart' => 'cart',
'checkout' => 'checkout',
);

/* Display: User Orders */
$handler = $view->new_display('page', 'User Orders', 'order_page');
$handler->display->display_options['path'] = 'orders-subusers';
$handler->display->display_options['menu']['title'] = 'All Orders';
$handler->display->display_options['menu']['weight'] = '15';
$handler->display->display_options['menu']['context'] = 0;
$handler->display->display_options['menu']['context_only_inline'] = 0;
$handler->display->display_options['tab_options']['type'] = 'normal';
$handler->display->display_options['tab_options']['title'] = 'Orders';
$handler->display->display_options['tab_options']['description'] = 'User orders in the store.';
$handler->display->display_options['tab_options']['weight'] = '';
$handler->display->display_options['tab_options']['name'] = 'user-menu';


Drupal Commerce: Allow anonymous users to choose their username on checkout

Theres a sandbox project here that you will need to download with git that looks like a complete sign up form.

Theres also Commerce User Profile Pane that allows you to choose the fields in the pane. Ive not used it before, but looks like a good place to start.


I think it may be revisions or taxonomy revisions issue
module documentation  says
This module enables revisions for the taxonomy terms.

The users will have an option to create new revision for a taxonomy term as for
nodes. This means when a taxonomy term is edited in the default form, a new
checkbox is displayed for revision creation. If clicked a textarea will appear
to fill a revision log message.

Also on the taxonomy term edit page a new menu tab appears after the module
installation which will list all of the taxonomy term's revisions and provides


Need to count field specific value in Views

You first create  a views to show the list of  open or closed task.

create a views with content type  "project" remove all field  then add a relation on task referenced field ,add title field with consider that you select relation field for it (because we want load task title instead of project title) then add  filter   "task_status" equal to close,then enable exaggeration and on title.and finally for better result you can get the title(or nid ) of project with contextual filter . it help you you can get only the list of tasks form specified  project.( and finally create another page in that views with only one change,  status=open ).


How do i post/donate a module in drupal.org?


with BEF collapse expand items under their parent

I fixed this issue and here is the solution for any one want to do the same, based on this conversion Collapse and Expand according to Hierarchy

add this code to your theme and you can use this module to add Javascript or CSS through the views page or block Code per Views Display

This code will add a + button beside the every parent, which will expand the checkboxes when clicked

(function ($) {
Drupal.behaviors.betterExposedFiltersExpandCollapseNested = {
attach:function (context, settings) {
  if (!('$befSetupDone' in window)) {
    $('ul.bef-tree-child.bef-tree-depth-1').css('display', 'none');
    var $expander = $('+');
    $('ul.bef-tree-child > li:has(ul) > div.form-item').prepend($expander);
    $('.expander')
      .click(function() {
        $ul = $(this).parents('li:first').find('ul');
        $ul.toggle('fast');
     })
    $befSetupDone = 1;
  }
 }
 }
 }) (jQuery);

and another code which will expand when the parent checkbox checked

(function ($) {
Drupal.behaviors.betterExposedFiltersExpandCollapseNested = {
attach:function (context, settings) {
  // first collapse the children
  $('ul.bef-tree-child.bef-tree-depth-1').css('display', 'none');
  $('.form-checkboxes.bef-select-all-none li').has('ul').once('bef-tree', function () {
    $(this)
      .find('input.form-checkboxes:first')
      .click(function() {
        $ul = $(this).parents('li:first').find('ul');
        if($(this).attr('checked')) {
          $ul.slideDown('fast');
        }
        else {
          $ul.slideUp('fast');
        }
      })
   });
  }
 }
}) (jQuery);

Note: You will have to choose (Nested Checkboxex/Radio Buttons) and check this option in better exposed filter

  Add select all/none links


How to conditionally update and import nodes using Migrate?

OK, at least now I know, that splitting migration into two with filtered rows works just fine. prepareRow function looks like this:

public function prepareRow($row) {
  // If node exists on destination
  if ($node = node_load($row->nid)) {
    // Use the metatdata wrapper to pull values
    $node_wrapper = entity_metadata_wrapper('node', $node);
    // If destination title is the same as source title
    if ($node_wrapper->label() == $row->title) {
      return TRUE;
    }
    else {
      return FALSE;
    }
  }
  else {
    return FALSE;
  }
}


I found @Sohail to be almost right. I did:

chmod 777 drupal/sites/example.com/files/styles

and the error went away and my drupal 7 new image-style worked. I did not have a styles or even a files folder in druapal/sites/all/files


How to programmatically set a node field as empty?

To remove the value from you field you should do like this before saving it:

$this_node->body[$this_node->language] = array();


everything is ok, just try to clear cache and don't forget never, after any change in hook_menu clear cache


How can I insert block content between page fields?

Using Template files
You can create a template file .html.twig for your content type or specific node.
Download and enable Twig tweak module:

Twig Tweak module provides a Twig extension with some useful functions
and filters that can improve developer experience.

And then on your twig template put:
{{ content.field_refhero }}

{{ drupal_view('view_name', 'block_1') }}

{{ drupal_block('block_id') }}

{{ content.field_refquotes }}

Alternatively, you could use the following modules
Display Suite

Display Suite allows you to take full control over how your content is
displayed using a drag and drop interface. Arrange your nodes, views,
comments, user data etc. the way you want without having to work your
way through dozens of template files.

Panels

The Panels module allows a site administrator to create customized
layouts for multiple uses. At its core it is a drag and drop content
manager that lets you visually design a layout and place content
within that layout. Integration with other systems allows you to
create nodes that use this, landing pages that use this, and even
override system pages such as taxonomy and the node page so that you
can customize the layout of your site with very fine grained
permissions.