Applying a condition/reaction context to all themes

You could do this through a very simple custom module. This way hiding the region will work with any theme, as long as it has the same name of the region you are trying to hide.

Here's the code that would go into your sample.info file:

name = Module name
description = Module description
package = Custom
core = 7.x
version = 7.x-1.0

Create sample.module file and add the following code:

function sample_page_alter(&$page) {
  // Fetch the node object.
  $node = menu_get_object();
  // Perform some checks to make sure this is the page we want to alter.
  if (
    // We are on node page.
    $node &&
    // Check if the node if of type you want to have 100% wide layout.
    $node->type == 'page' &&
    // This will exclude local node tasks, such as edit, delete and revision.
    !arg(2)
  ) {
    // Unset the region you want to hide.
    unset($page['sidebar_first']);
  }
}

Update

You asked for a wildcard that would work across multiple themes.

First off - the sidebar_first and sidebar_second are somewhat standard names for left/right sidebars in Drupal themes. Most of the themes will name sidebars the same way.

However, for the sake of answering the question, here's how you'd "scan" for all regions that contain for example the word "sidebar":

function sample_page_alter(&$page) {
  // Fetch the node object.
  $node = menu_get_object();
  // Perform some checks to make sure this is the page we want to alter.
  if (
    // We are on node page.
    $node &&
    // Check if the node if of type you want to have 100% wide layout.
    $node->type == 'page' &&
    // This will exclude local node tasks, such as edit, delete and revision.
    !arg(2)
  ) {
    // Unset the sidebar regions.
    //
    // We will loop through the elements and check if they are set and contain
    // the word "sidebar".
    foreach (element_children($page) as $region_name) {
      if (strpos($region_name, 'sidebar') !== FALSE && !empty($page[$region_name])) {
        unset($page[$region_name]);
      }
    }
  }
}

Notes

Do take into consideration that the above approach will just prevent the region from being printed on the screen. This means that if you have complex blocks, they will still be rendered and take server resources.
You can replace all instances of sample with whatever else you want to call your module.

For more information, check out the following:

hook_page_alter()
menu_get_object()
path_is_admin()
current_path()
element_children()

Hope this helps.


How to make a theme hook suggestion for blocks according to region?

You can get region if you get Block Entity.

.module or .theme file

use Drupal\block\Entity\Block;

function MODULE_theme_suggestions_block_alter(array &$suggestions, array $variables) {
  if (!empty($variables['elements']['#id'])) {
    $block = Block::load($variables['elements']['#id']);
    $suggestions[] = 'block__' . $block->getRegion() . '__' . $variables['elements']['#id'];
  }
  /* Use this 'else if' only if you are using page_manager module and want to know which region is the block */
  else if (isset($variables['elements']['#configuration']['region'])) {
    $suggestions[] = 'block__page_' . $variables['elements']['#configuration']['region'] . '__' . end(explode(':', $variables['elements']['#plugin_id']));
  }
  return $suggestions;
}

Edit 1: Cover page_manager module case.


Simplenews is not Activated Automatically for Users

If you're using the silent option for new accounts, this only automatically activates if you've disabled email verification for new account registration or an admin activates the account (if requiring administrative approval).


I have created the related feature request here.

  If this feature is not yet available in the location module, I could
  maybe use Views, create the indexed synonyms as taxonomy terms
  vocabulary and term reference field Content: Location Synonyms,
  modify the view's Global: combine filters filter setting Choose
  fields to combine for filtering as Location: City and Content:
  Location Synonyms? This would require tagging each node location
  synonyms manually or would require setting up a Rule (using Rules
  contrib module) that would add these synonyms automatically depending
  on the Location: City selected. The standard Drupal search would
  index these tags.

  It would be better to have it either inside the Location module or as
  an additional contributed helper module.

There is also a contributed module Location Taxonomize that might help in achieving this.


How do I show the contact form in panels?

Please use contact_block, because ctools use blocks please see module ctools_block in module ctools.


When I double-click on the publish content tab on a node, I end up on /user instead

It's because when you double click, most probable case is the second click will try to use an already used token.

Or it could also be due to the fact that the second click might be translated as trying to publish an already published node.


How can I set up Drupal so people can collaborate on content development prior to making it public

The near defacto-standard for this in Drupal 7 is the Workbench Moderation module, which is part of the broader Workbench suite.  From the module page:

  Workbench Moderation adds arbitrary moderation states to Drupal core's
  "unpublished" and "published" node states, and affects the behavior of
  node revisions when nodes are published. Moderation states are tracked
  per-revision; rather than moderating nodes, Workbench Moderation
  moderates revisions.

and about Workbench in general:

  Workbench is a suite of modules which provide easier content
  management for content administrators. Each of the "Workbench" modules
  has been tested to work with the main Workbench module, and with the
  other modules in the Workbench suite. The Workbench suite is modular,
  allowing site builders to build the workflow that best suits the
  content administrators on their site. The Workbench suite provides
  authors, editors, and publishers with a unified interface for managing
  content relevant to them. It allows people to focus on content, rather
  than on learning Drupal.

This is highly tailorable to your particular organization, and all organizations differ.  You didn't list out a lot of additional requirements, but typically you would create roles (Author, Editor, Publisher, Admin), and then define which role can do what (eg, Authors can only edit their own content, Editors can edit all, but only Publishers can make nodes public).  Additional controls can be implemented with Workbench Access.

I have deployed solutions based on this for many organizations, mostly with success.  I also like this solution, compared to others, as this module suite is "site-builder friendly".  This means, that I can get the basics going for a site, and then have non-developers on the team work with clients to tailor it for their needs.

When it doesn't work well, it is usually because the organization doesn't really want content workflows as opposed to needing them.

This solution is also providing the base for the Content Moderation initiative for Drupal 8.

That said, depending on your situtation Groups / Organic Groups may be a better fit (as described in another answer).  I would take both solutions for a test drive to see what works best for you.


Its too simple my friend. For these types of manipulations template_process_html(&$variables) comes handy. This is provided by theme.inc located in includes/ folder of your drupal directory.

You can put this function in your template.php file of your custom theme directory

/**
 *Implementing template_process_html()
 */

function custom_theme_process_html(&$variables) {
    $path = drupal_get_path('theme','custom_theme');
    $variables['scripts'] .= '<script src="' . $path . '/js/jquery.smoothState.js"></script>
<script src="' . $path . '/js/functions.js"></script>';
}

  This will append these new scripts to your scripts variables that is rendered to html.tpl.php as <script> tags while processing it. Provided that you put these scripts in the js folder located in your theme folder . So the file path should be like this - sites/all/custom/themes/custom_theme/js/functions.js.

Don't forget to clear the cache as its a new hook in your template.php file and drupal won't execute that hook until you do that.

Hope that helps.


What permissions are needed for omega tools to create subtheme

To work, the user that runs your web server needs to have write permissions to the target folder. Typically, you have a user that owns the files and then the web server runs as the group so permissions of 755 (ex. rwxr-xr-x) would work on most files except files/directory that drupal needs to write to (ex. files directory, or in this case, your themes folder).

What you need to do is either

change group ownership of the ygf folder above to the same user that runs your web server;
or - you can blow open the permissions to the folder (ex. chmod -R 777 ygf) temporarily and then switch it back after this operation.

Regardless, you're probably going want to remove the write permissions on this folder after omega tools has generated the sub theme. Omega Tools just needs this temporarily and it can be risky to have group-writable folders outside of the files directory.


Use computed field to calculate Field collection

I've got it! After a lot of tries I found a solution:
This works for a computed field outside the collection.

$sum = 0;
$wrapper = entity_metadata_wrapper($entity_type, $entity);
foreach($wrapper->field_values as $collection) {
   $sum += $collection->field_total->value();
}
$entity_field[0]['value'] = $sum;


login form generated by drupal_get_form('user_login_block') does not log in

You shouldn't need to render the form, and this may be causing your problems. The output of drupal_get_form() is a render array, so you can use that directly. Try changing this:

$user_login = drupal_get_form('user_login_block');
$out = drupal_render($user_login);
$block['content'] = $out;

To this:

$block['content'] = drupal_get_form('user_login_block');

Also, are you doing anything else to the block with preprocessing or processing? Is the system rendering the block normally, or are you rendering the block in some different manner, with a template or something?


How do I configure a view that gets a taxonomy on a node, and retrieves fields from the taxonomy?

Hi,

If you construct your view like the below and get the value from URL, you should be able to achieve.

EDIT: Allow me to guide you step by step:

You go to /admin/structure/views
You click on Add new view, and enter your view's name and description in the related fields in the next screen
Choose Content from the Show dropdown and your display format from the Display format dropdown and click Continue & edit.
Add Content: All taxonomy terms as a field, make your settings, and click Apply.
In the advanced section (to the right most section), add Nid as a Contextual Filter and click Apply (all displays).
Choose Provide default value and Content ID from URL, and click Apply (all displays

That's all there is to be done. You can test this by passing a node ID in the Preview with contextual filters field.


How to remove reference field value after delete its reference node

Try using Reference Delete module..

Project page says

  Deletes values in reference fields created with Entity Reference or
  References when the referenced entity is deleted.


Role to edit user profiels but not administer accounts

This looks like it should do the trick :

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

  This module allows site builders to set up fine-grained permissions for allowing "sub-admin" users to edit and delete other users — more specific than Drupal Core's all-or-nothing 'administer users' permission. It also provides and enforces a 'create users' permission.

The normal administer users permission is split out into create, edit and cancel users per role.


How can I make a read only field  form with node authors' mail address on node edit page?

see http://drupal.org/project/field_permissions,
from module description:

  The Field Permissions module allows site administrators to set field-level permissions to edit, view and create fields on any entity.


How to remove empty div created by routing.yml file by specified routes?

You can do this by overriding the page.html.twig for that page and stripping out the title.

To override the template for that specific page you should probably alter the hook suggestions:

/**
 * Implements hook_theme_suggestions_HOOK_alter().
 */
function THEME_NAME_theme_suggestions_page_alter(array &$suggestions, array $variables) {

  if ($node = \Drupal::routeMatch()->getRouteName() == 'games.two') {
    $suggestions[] = 'page__no_title';
  }
}

Now you can copy the page.html.twig template to  your theme folder, rename it to page--no-title.html.twig and strip out the title tag.

Hope this helps


How to create a "Make this Sticky" link or tab

Sure, you can simply add any field to your node type and use that. Let it be a simple checkbox for example. Hide that field from node display. It should just be displayed on the form display. Put it in a prominent position. Finally, via hook_form_alter add another submit handler that then checks the input of that checkbox and sets the node's sticky value accordingly.

I just released Toggle Sticky Toggler. Which adds a "Make Sticky / Unmake Sticky" tab next to the default "Edit" tab.


Does Drupal 8 core by default collect visitors data?

The answers and comments in the linked question for Drupal 7 are still valid, with one exception. Drupal 8 gets the client ip address from Symfony\Component\HttpFoundation::getClientIps(). This returns the client ip from the header REMOTE_ADDR, unless you set up a trusted proxy. In this case you would have to configure this proxy to obfuscate the visitor's data.

In all other cases it should be enough to overwrite part or all of the ip address in a Symfony middleware.


Limit a user to edit AND view only a specific content type?

If you have to control the list of content where they go to find content to edit, then you should use VIEWS & make list of only those content which they have permission to edit. Set a page for that list & navigate them there. It's pretty easy..

But if you want to restrict full content type for viewing then you can use Content Access module for that.


Why do certain fields not behave like fields?

Product title is an entity property instead of a field. See blog post by Wolfgang Ziegler for an explanation.

You should be able to add RDF definitions by using hook_rdf_mapping(). I looked into the Commerce module and it didn't use the hook. You might want to file an issue on the Commerce project page.

Luckily you can define the RDF mappings by yourself. Below is an example code which might work.

function your_module_rdf_mapping() {
  return array(
    array(
      'type' => 'commerce_product',
      'bundle' => RDF_DEFAULT_BUNDLE, // might be something else
      'mapping' => array(
        'rdftype' => array('sioc:Item', 'foaf:Document'),
        'title' => array(
          'predicates' => array('dc:title'),
        ),
      ),
    ),
  );
}

If you want to expose entity properties to the UI, you can use hook_field_extra_fields(). Node module is using that to expose the title property to the UI. Below is an example code of that.

/**
 * Implements hook_field_extra_fields().
 */
function node_field_extra_fields() {
  $extra = array();

  foreach (node_type_get_types() as $type) {
    if ($type->has_title) {
      $extra['node'][$type->type] = array(
        'form' => array(
          'title' => array(
            'label' => $type->title_label,
            'description' => t('Node module element'),
            'weight' => -5,
          ),
        ),
      );
    }
  }

  return $extra;
}


What D7 settings need changed to take advantage of bigger cloud server

Varnish, Memcache, & APC come to mind. PHP either has enough memory or it doesn't; giving it 512MB wont speed it up.


Setting a Drupal.settings JS variable from a form field

Adding the value of the new field wt_comments_share to $_SESSION['wt_comments'] is considered a good idea.

Because you're using session to pass values, you don't need to pass it to Drupal.settings unless if you want to add new JS file.

To add javascript code to node view you need to use hook_init or template_preprocess_node

function wt_comments_init() {
  // check if page is node and wt_comments is set
  if($node = menu_get_object() && isset($_SESSION['wt_comments'])) {
    // check users allowed to comment on this node
    if($node->comment) {
      // add javascript code
      drupal_add_js("jQuery(document).ready(function () {
            if ( Drupal.settings.wt_comments.wt_comments == 1 ) {
              // dance around! jQuery('body').css('background-color','green');
            }
          });",
       'inline'
      );

      // unset session wt_comments
      unset($_SESSION['wt_comments']);
    }
  }
}


Way for Admin to log in as an existing user without password for troubleshooting

Masquerade is what you need:

  The Masquerade module allows site administrators (or anyone with
  enough permissions) to switch users and surf the site as that user (no
  password required). That person can switch back to their own user
  account at any time.


SQLSTATE[42000]: Syntax error or access violation in drupal views query

Removing the fields and then adding them back resolved the issue, though I'm not sure how.


Drupal 8: Rendeirng node fields in another region

Easiest way to do this is create a View with a block display, and set the node ID as the contextual filter. The output of the View should be "Content" and a view mode - this view mode can be set with its own twig template in the theme. You can add a view mode at Admin > Structure > Display Modes > View Modes, then go to whatever content type you need it for and configure the display. On the view mode, you can pick and chose what fields should display and what formatters they use.

Here is a good write up detailing it, and a YouTube video walking through view modes and what they are.

Once the View is created, you can place the block in the block admin, and set its visibility settings to only show on your content type(s) that you configured.


add one condition that checks if the node has field_term_ref (term reference) equal to what term name you wish for it.

Choose the action "Set a data value".
Choose the taxonomy term reference field to set.
"Switch to the direct input mode" button to reveal the terms available in your taxonomy field.


Custom module .install does not create table in database

hook_schema alone is sufficient to create database tables. I assume you are just disabling and then enabling the module which will not help you to create tables in the database.
To get it working, admin/modules' locate your module and disable it. Then navigate to 'admin/modules/uninstall' and again locate your module and uninstall it.
After this, go toadmin/modules', and enable your module.
Now you can find the respective tables in your database.

You can also use drush for the same.
drush dis module_name, then
drush pm-uninstall module_name and finally
drush en module_name.

Also, as per @OPTASY Canada, do check your dblog for any warning or error.


JavaScript loading but not being applied in Drupal 8 theme

The dumbest of all possible mistakes was the answer. I had a <div> wrapping my insertion of the page block, like so:

{% if page.slideshow %}
{{ attach_library('themename/zaccordion') }}
    <div class="col-xs-12" id="slideshow">
        {{ page.slideshow }}
    </div>
{% endif %}

I thought if I put the attach_library line there it would load it 'closer' to the actual code needing it (don't try to understand what I was thinking). At any rate, I noticed that I have an id="slideshow" here as well. So I had TWO id="slideshow" - one on this <div> and another on the <ul> in the block...that was causing the slideshow not to work. So I just changed the id of this <div> to something else and it worked.


Execute a Backup and Migrate backup via PHP

Ok, as it happens, I figured this one out. Below is a sample function meant to be used as an admin form submission handler.

function _my_backup_handler() {
  $destination_hash = 'yourhash'; // See below.

  backup_migrate_include('profiles');
  $settings = _backup_migrate_profile_saved_default_profile();
  $settings->destination_id = $destination_hash;
  $settings->source_id = 'db'; // Your primary Drupal database. This is probably redundant.
  backup_migrate_perform_backup($settings);
}

As for what $destination_hash is, it turns out the "machine name" of a custom BM destination is a random hash. It can be found in the URL if you go to http://www.yoursite.com/admin/config/system/backup_migrate/destination and click the "edit" button for your destination; you'll end up at http://www.yoursite.com/admin/config/system/backup_migrate/destination/list/edit/[hash]. Just copy [hash] and plug it in as a string for the value of $settings->destination_id.


SEO-friendly Views: How do I make contextual filters work together with exposed filter criteria?

You're nearly there, but you need to replace your exposed filters with equivalent Views arguments (i.e. Country and City). Then if you change the view's 'page' display path from frontpage to frontpage/%/%, each percent will be mapped to the arguments in the order they appear.

Once the above is done you can still use exposed filters for other fields to control the view, but they will need to be other for fields. If you need to change the city/country arguments inside the %, look into making a 'Jump menu' view display to provide a drop-down to control the view, rather than an exposed filter. Also see the Jump module.

If you need more power, a related alternative is to re-create the page in Panels which will allow you to pass arguments to several views in different panes at the same time. Views should do the job on its own for you, though.


Assign different weights for different displays

Poking around in the Weight module, it seems they only allow you one weight per node.

However, you can just keep adding Sort Criteria to the View, based on fields you've added to the content type. So you could add a How Many Layers? numeric field and also sort by layers, in addition to weight and/or popularity and/or whatever.


Make my view the default for content type

Your main concern is you don't want the /node/123 link to be available publicly or in search results?  You could unpublish the node and then make a Boolean field in your content type and for your view choose to show the piece of content based on your new boolean field INSTEAD Of the stock published/unpublished checkbox.  So your view by default will only show "published" content but you can change that so that it shows "live" content (new boolean field you created for that content type)  or like that and ignores the published/unpublished field.  So node/123 won't show up for anonymous users or in search results but will still be processed by your view.  Assign the view to the path of your choice /contact-page or whatever and you're golden.


How to setup module install (sub-folder) paths from the *very beginning* (contrib, custom, features etc) - i.e. not move them after the install

Actually it seems like all you need to do is just create a folder called contrib in /sites/all/modules

when I issued drush dl views (at the docroot/install top level root of my site), drush put the views module in the contrib folder

as for features - you specify where you want the module to go when you (re)create the Feature (in the Feature section of the Drupal config)

as for custom - I'm hoping that Drupal will discover custom modules here - but is discovering, rather than a setting determining the path, a good thing?

Thought I'd still ask the question even after I'd found an answer, didn't want to waste the effort in making the question - hope someone else finds it useful.

Please provide your own answer or comment to enhance what I found.


Trying to override Drupal core 'find content' with a view and VBO

Views doesn't really know how to override paths. It always breaks menus.
You need the Admin Views module that provides some extra code for overriding to work.


How to let a user change their own username?

Changing a username inside a hosted site is completely up to the OpenAtrium Drupal installation.
Aegir does not usually interact with this.

I just verified that it works OK on a clean Aegir 3 install with a standard Drupal site.

So @Bisonbleu's comment seems correct:

  That's done in permissions. In Drupal 7, go to admin/people/permissions and look under User: Change own username.


In order to theme the unordered list, you need to call theme_menu_tree(). You can edit your template.php in order to call this.

function THEMENAME_menu_tree__MENUNAME($variables){
  return '
' . $variables['tree'] . '
';
}

Then, if you want to theme your links, call theme_menu_link().

function THEMENAME_menu_link__MENUNAME($variables) {
  $element = $variables['element'];
  $sub_menu = '';

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '
' . $output . $sub_menu . "
\n";
}

Now, the problem with Drupal 7 is that there is a major bug when it comes to displaying the active trail of custom menus.

See issue
Issue #520106 - No way to dynamically set active trail
Issue #942782 - Custom menus never receive an active trail

You are basically out of luck if you want some true custom menus. These issues are very long standing in the drupal community so I am not sure if they will be fixed anytime soon. I don't know if there is some PHP that can help with it. You can turn to some alternative modules in order to help ease functionaltiy, like Menu Attributes and Menu Block. They both can help get around the cruddy menu system in Drupal 7.


Clean URL/.htaccess problems with multiple subdirectories

It seems that your .htaccess is custom made, first of all you should have a look at the one Drupal provides as you're missing some criticals rules like

<FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$">
  Order allow,deny
</FilesMatch>

Regarding your problem, I think you should change the RewriteBase condition like this:

RewriteBase /siteB_D6

for each of you subsite (make it matches the subdirectory where it's located).


Installing Drupal patches in Ubuntu terminal

As far as I know there is nothing in specific about applying patches for drupal in ubuntu.

If you are already using git for managing your project code then you can apply a patch to a project's repository by using following code:

git apply -v path/file.patch

If you are not using git, or if the repo isn't a local checkout of the project you wish to patch:

patch -p1 < path/file.patch

For more information, check https://www.drupal.org/patch/apply

Live example for patching in Drupal 8:

Download the .patch file (in this case: Add_rtl_support.patch)
Copy it into the particular module's directory (since the patch is relative to the module directory).
Change the destination directory in the Ubuntu terminal to the module's folder - In this case it should be cd modules/admin_toolbar.
Apply the patch using 2nd method patch -p1 < Add_rtl_support.patch


views.view.unformated.html.twig taxonomy conditional if/else

The code doesn't match the template, it's more likely from a views-view-fields.html.twig template. Then you could configure a separate field in Views UI to produce the output you want. Views fields are not a 1:1 match of entity fields, you can rewrite the entity content to whatever you want. Most times it's a better idea to put Twig in Views UI and not in Views templates.
If you really want to access raw field values, don't use the output of Views field plugins. Access field values directly through the node object:
{{ row._entity.field_ref.target_id }}

More info Access row value in template_preprocess_views_view_fields(&$variables)


How to get user.field value in node.twig

You can try using variable node

Get user.name

{{ node.uid.entity.name.value }}


Job Scheduler
Provides an API to schedule jobs. Where you can programmatically unpublish product variation in worker callback.
Simple example:

// Declare scheduler.

  function example_cron_job_scheduler_info() {
    $schedulers = [];
    $schedulers['example_unpublish'] = [
      'worker callback' => 'example_unpublish_nodes',
    ];
    return $schedulers;
  }

// Add a job.

  $job = [
    'name' => 'example_unpublish',
    'type' => 'story',
    'id' => 12, // must be unique
    'crontab' => * 3 * * 0, // Every Sunday at 3 AM
    'periodic' => TRUE, // set to false if you want to just run once.
  ];
  $service = \Drupal::service('job_scheduler.manager');
  $service->set($job);

// Work off a job.

  function example_update_users_total(\Drupal\job_scheduler\Entity\JobSchedule $job) {
    // Do stuff.
  }

There is more examples & info in the READ.ME, so read it.

Ultimate Cron
Provides a UI where you can schedule all the cron jobs. You can implement your own hook_cron and then schedule it using Ultimate Cron.


Probably better to ask the Hostgator support if/how they support that.

One alternative is setting up and running those commands locally, that will download the necessary files and you can then upload them.


How to hide the text format field set using css?

Your code is correct. Just add it to a custom module, and it will work. Most likely it doesn't work because the admin theme is not the same as your front end theme.

Your module would take as little as this:

YOUR_MODULE.info:

name = Your module.
description = Description.
package = Custom
core = 7.x
version = 7.x-1.0

YOUR_MODULE.module:

function YOUR_MODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'ID_OF_THE_FORM_YOU_WANT_TO_ALTER') {
    drupal_add_css('
      #edit-conditions-format {
          display: none;
      } ',
    array('group' => CSS_THEME, 'type' => 'inline'));
  }
}

That's it. You can fetch the empty boilerplate here or if you want to do it properly, have a main custom module where you do all the extra customizations. You can have a look at mine here.

Or you could create a child theme of the admin theme, but that will likely take as much effort as creating a custom module.


Is there some way to compress CSS and Javascript only for certain users?

You're looking for AdvAgg. If the user has the correct permissons you can add ?advagg=-1 to the URL and all CSS/JS files are un-aggregated for that page request. You can also set a cookie on the admin/config/development/performance/advagg/operations page so you no longer need to add that to every URL.


By default, the apachesolr Drupal module is set to do an AND search.  However, you can change that in one of two ways:

Implement a custom module that alters the queries sent to apachesolr.  All you'd need is to implement the apachesolr_query_alter hook.

 <?php
 function HOOK_apachesolr_query_alter($query) {
   // Force an OR keyword search.
   $params['mm'] = '100%';
 }
 ?>

More details can be found on this drupal.org documentation page: http://drupal.org/node/1159424

The second thing you can do is modify the deafaultOperator from "AND" to "OR" in apachesolr's schema.xml file.  You should be able to find that in your modules/apachesolr/solr-conf folder.  That setting should be towards the end of the file

<!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
<solrQueryParser defaultOperator="AND"/>   // change to OR here

With this second one, just be careful.  You don't want to make this change to your schema file and then forget and have it replaced later when you update your module or something like that.  Just by searching now, I can see there is this rather unstable module that exposes some of the configuration options of the schema file in the User Interface: http://drupal.org/project/apachesolr_confgen, but I'm not sure I'd choose to use that...

Hope one of these helps!


Create users to post unplublished nodes so admin could approve

There are multiple ways.  (Edit:The workbench module is very popular, but is for Drupal 7 only). I have achieved good results using the revisioning module, which has a release for Drupal 6.


500 Internal Server Error after logging in

From my research there are basically four things that could cause the '500 internal server error' with drupal :

Misconfgured server (you will have to dig into your server configs)
Misconfigured .htaccess file (replace your existing .htaccess with the drupal default)
Misconfigured file permissions
Low php memory_limit setting

In my case, the culprit was the memory_limit setting. After doubling the same, my site is flying right now.


How to rename installation profile name in existing website in D8

Ok here is the way to do it:

Edit this line in core.extentions.yml in your config directory to your new name

my_custom_profile: 1000

Rename your profile directory and clear the cache


Use the WYSIWYG module...  TinyMCE allows for media to be added such as Flash, so you can use that plugin.

For files/images you can use the Insert module OR IMCE (along with IMCE Wysiwyg API Bridge) to add the images/files to the content.

Remember Google can be a wonderful thing ;)


The RTL css file is not working for a menu

you mistake is here     dir:rtl; :(, and correct code will be below "dadash"

#header-menu ul.menu li {
float:right;
direction:rtl;
text-align:right;
}


Frontpage module redirecting to /user/uid not correct url on login

You can create a rule for this. when user logged in site then it will redirect on node/1 site.


How to track field changes in custom (ECK) entities

You can try ECK Revision module. Also check related drupal.org issue: Support Revisions in ECK.


This is a permission issue. Simply enable the permission "View user profiles" for anonymous users.


How to alter the fields available for commerce backoffice Quick Edit?

i am not sure if this might help, but recently i've written a custom hook to enable stock quantity field on commerce product quick edit form.

It should theoretically be possible yes to write a similar hook on commerce order.
Here's my custom module copy pasted :

<?php
/**
 * Implements hook_form_FORM_ID_alter().
 */
function commerce_stock_quickedit_form_commerce_backoffice_product_quick_edit_form_alter(&$form, &$form_state, &$product){
  $product = $form_state['product'];
  $product_wrapper = entity_metadata_wrapper('commerce_product', $product);
  $form['stock'] = array(
    '#type' => 'textfield',
    '#title' => t('Stock'),
    '#title_display' => 'before',
    '#default_value' => !empty($product->commerce_stock) ? $product_wrapper->commerce_stock->value() : 0,
    '#size' => 5,
  );
  $form['price']['#title_display'] = 'before';
  $form['#validate'][] = 'commerce_stock_quickedit_commerce_backoffice_product_quick_edit_form_validate';
  $form['#submit'][] = 'commerce_stock_quickedit_commerce_backoffice_product_quick_edit_form_submit';
}
/**
 * Validation callback to make sure stock is numeric.
 */
function commerce_stock_quickedit_commerce_backoffice_product_quick_edit_form_validate($form, &$form_state) {
  if (!empty($form_state['values']['stock'])) {
    if (!is_numeric($form_state['values']['stock'])) {
      form_set_error('stock', t('Please enter a numeric stock value'));
    }
  }
}
/**
 * Submit callback to update the product stock.
 */
function commerce_stock_quickedit_commerce_backoffice_product_quick_edit_form_submit($form, $form_state) {
  $product = $form_state['product'];
  if (!empty($product) && !empty($form_state['values']['stock'])) {
    $product_wrapper = entity_metadata_wrapper('commerce_product', $product);
    $product_wrapper->commerce_stock->set($form_state['values']['stock']);
    commerce_product_save($product);
  }
}


I found the solution for this.

The reason for error was that the ThemeKey module was not overriding and admin pages, by default.
Hence pages like user/uid/edit which are admin by nature are not overriden in their theme and pick the admin appearance theme always.

To bypass this I enabled the THEMEKEY COMPATABILITY Module (Part of Themekey module for D7). Open the following settings page:

http://localhost/admin/config/user-interface/themekey/settings/compat

Section Modules>> Integrate Modules in Theme Switching Rule Chain>>

Then check the option "System (Administration theme)".

Now all admin pages like user/uid/edit also come under theme switching rule and pick the theme as defined.


You are mixing up the globally installed Drush with a locally installed Drush. To run the local Drush from your project, run vendor/drush/drush/drush --version from inside your project. This will give you 8.0.0 which is a bit old. Better get the latest Drush 8 release with composer require drush/drush:^8. Currently this is Drush 8.4.8.
Next, you can consider to either update the globally installed Drush (not recommended) composer global require drush/drush:^8 or alternatively (recommended) install the Drush Launcher instead. The Drush Launcher is just a wrapper command to always pick up the project-local Drush. So you can easily run Composer-based D7 and D8/D8+ projects on the same machine in parallel and calling drush --version in a project will adjust accordingly.
If your project is D8 or D9 install Drush 10 instead composer require drush/drush.


Views Jump menu with taxonomy url and custom url


In Views, how can I display an edit link if a node relationship exists, otherwise display an add link?

I have had a similar situation and I did the following which is probably not the best thing to do - I will use your terms:

When an assignment node is created a work node for each student is created with the field field_submitted set to false
On the view, the field field_submitted is included but excluded from display
I have a php field with this code which displays edit or submit, both are actually sending to the same node but they will give the student some insight about what he should do next:

if(!empty($data->field_field_submitted[0]['raw']['value']))
   echo l(t('edit')/*, ... */);
else
   echo l(t('submit')/*, ... */);


Executing a method of a custom entity after all instances have been built

You can use an event for this, a RESPONSE event with a low priority or a TERMINATE event. See for example UserRequestSubscriber::onKernelTerminate:

/**
   * Updates the current user's last access time.
   *
   * @param \Symfony\Component\HttpKernel\Event\PostResponseEvent $event
   *   The event to process.
   */
  public function onKernelTerminate(PostResponseEvent $event) {
    if ($this->account->isAuthenticated() && REQUEST_TIME - $this->account->getLastAccessedTime() > Settings::get('session_write_interval', 180)) {
      // Do that no more than once per 180 seconds.
      /** @var \Drupal\user\UserStorageInterface $storage */
      $storage = $this->entityManager->getStorage('user');
      $storage->updateLastAccessTimestamp($this->account, REQUEST_TIME);
    }
  }


Just use DRUPAL_CACHE_GLOBAL. On multilingual sites the users language is part of the (cid), i.e. the key used when storing/fetching entries to/from the block cache.

The function responsible for this behavior is drupal_render_cid_parts which is called from _block_get_cache_id.

You can embed the following fragment into a custom PHP block in order to verify the mechanism:

$fakeblock = (object) array(
  'module' => 'some-module',
  'delta' => 'some-delta',
  'cache' => DRUPAL_CACHE_GLOBAL,
);
print _block_get_cache_id($fakeblock);

On a multilingual site, the fragment should print something like:

  some-module:some-delta:bartik:en


How to use LESS (CSS) in a Zen sub-theme?

I can't comment directly about using LESS with Zen, but I have used it with Omega 3.

With this, you have to specify the proper filenames in the theme.info file.  The stylesheets need to be named like "styles.css.less", and specified like:

stylesheets[all][] = styles.css.less

in the .info file.  Includes with variables and mixins get named like "mixins.less".

Assuming files are named this way, the module will do its thing, and compile the sheets and rewrite the paths to reflect the compiled versions.

That said, we stopped using LESS a while ago, and have moved on to Sass/Compass.


Create a custom form from Custom Content Type & Save it

node_form will give you a form for your content-type, just pass a node.object having your content-type ($node->type) and maybe something more .., plus the content-type needs to be registred already i guess

saving is handled automagically ...


How to add autocomplete filter to a views based on webform results?

I did this in my custom module :

function hook_form_alter( &$form, &$form_state,$form_id ) {

  if($form_id == 'views_exposed_form') {
    $view = $form_state['view'];
    if($view->name == 'your_view_name') {
     $form['data']['#autocomplete_path'] = 'example/autocomplete';
   }
  }
}

'#autocomplete_path' => 'example/autocomplete' defines an autocomplete callback for our textfield.

When user types something into our textfield, Drupal sends a request via this url to send data you input and to receive suggestions via json if there are any.

To make Drupal aware of this path, let’s add it to the menu system(hook_menu):

$items['example/autocomplete'] = array(
  'page callback' => '_module_name_autocomplete',
  'access arguments' => array('access content'),
  'type' => MENU_CALLBACK
);

Now we need to create a _module_name_autocomplete function which will look for a suggestion and return it to the user.

function _module_name_autocomplete($string) {

  $matches = array();
  // Some fantasy DB table which holds cities
  $return = db_select('webform_submitted_data', 'w')
  ->fields('w')
  ->condition('w.cid', 'your_component_id', '=')
  ->condition('w.data', '%' . db_like($string) . '%', 'LIKE')
  ->execute();

  // add matches to $matches
  foreach ($return as $row) {
   $matches[$row->data] = check_plain($row->data);
  }

 // return for JS
 drupal_json_output($matches);
}


Two ways to approach this.

One way is to use the Webform module. If this is just a simple contact form, you can get this done with Webform in five minutes.

The second way is create a custom module that implements a route, Form class and related methods. Wouldn't take an intermediate long, but a beginner should try Webform first.

You cannot simply paste form HTML into a twig file and expect it do anything. Drupal is ignorant to its existence and therefore no hooks will work, as you already saw.

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


For Drupal 7, the best thing I've seen/used for this is ImageAPIOptimize.

To use it properly you can either use an external toolkit like Yahoo SmushIT! or different options on your server like optipng as you mention above, among others.  See screenshot for partial config screen.  I've run tests with GD, ImageMagick and this module and it produces the best results (in my testing).

Config screen from admin/config/media/image-toolkit:


Custom error for user registration page in D7 not working

The reason why it's not displayed are:

Since the field is required, Drupal handles that already so your user-defined validation wouldn't run since Drupal make's sure the field passes "required" validation and when it reaches your trapping, it's never empty.

  First ensures required fields are completed, #maxlength is not exceeded, and selected options were in the list of options given to the user. Then calls user-defined validations.

Reference: function _form_validate

Here is an example that your functions are right.

if ($form_state['values']['name'] == 'asdasd'){
    form_set_error('name', t('username is asdasd!'));
}

That will trigger your validation since it passes the "required" validation and checked the username for something aside from being empty which conforms to the description of the _form_validate.


It sounds like you're looking for Field Permissions.

  The Field Permissions module allows site administrators to set field-level permissions to edit, view and create fields on any entity.


Disable an parent link for dropdown menu but keep css

Adding

  e.preventDefault();

under

 $('.topmenu').click(function(e){

will disable link redirection.


Wrong text being shown in a template file

You need to set the encoding of new files to utf-8 in your text-editor. The image below is on Notepad++. There should be a similar setting in your text editor.

To test if you got it right, create an HTML/PHP file with the Hebrew text outside of Drupal first.

For Notepad, Save As and select UTF-8 as the Encoding.

Also, make sure you have the following line in the <head> tag of your HTML:

<meta charset="utf-8">


if anyone else is experiencing this issue, notice that it can also be caused by your configuration in yoursite/admin/config/regional/language/configure, even if you are not using Admin Language Module.

Menus are part of your interface, not of content. So, for example, if you set your interface language detection to default (only use site default language), because you want your interface to be only in english, you are not going to see your translated menu blocks when you navigate to yoursite/anotherlanguage!

Hope this helps someone!


Is the latest Drupal 7 core, 7.59, fully PHP 7 ready?

For the most part, Drupal 7 core is compatible with PHP 7, however in some cases you might run into issues, depending on your specific website's configuration.

There is a meta issue on drupal.org that you can follow at https://www.drupal.org/project/drupal/issues/2656548

In addition, although most of the widely used modules are, not all contributed modules are compatible yet.
The issue you linked is for a contributed module, not Drupal core.

Your best bet is to test your site and its particular modules on a development PHP 7 environment and then resolve any issues you find. Once you're happy that the site is functioning as it should, update your PHP version on your production server.

In my personal experience, with at least a dozen Drupal 7 sites of varying sizes, I have had no issues with Drupal 7 on PHP 7.0 or 7.1 but I have had a few issues with 7.2 when it was new (which may have been resolved by now).

In some cases I have had to apply patches that were already available in issue queues, but generally I've only had to update modules to the latest versions.


How to switch view before render current view?

Answer

You can't switch view during render process but current display id.


How to add multistep registration form in default user registration

You can try Field group

  Fieldgroup will, as the name implies, group fields together. All
  fieldable entities will have the possibility to add groups to wrap
  their fields together. Fieldgroup comes with default HTML wrappers
  like vertical tabs, horizontal tabs, accordions, fieldsets or div
  wrappers.

Available group types

Fieldsets
Horizontal tabs
Vertical tabs
Accordions
Divs
Multipage steps: Note: This is only client side.

The idea is to use Multipage steps to make the form steps.


Confirmation email for newsletter signups drupal 7

This is absolutely possible.

Go to admin/content/webform
Click Edit for the webform you want to modify.
Click on the Webform tab
Click on the E-mails sub-tab
Add a new one.

Once in there you can set all of the options you need to send an email to the person signing up.


The Drupal for Facebook module gives you integration on a number of levels, including (with some extra work) automatic push to a Facebook page you have access to.

However, you might get better results by letting visitors to your website post references to their own timeline using something like ShareThis. This will use your audience as multipliers of your message, not just on Facebook but on other social media sites as well.


Remove clearfix from section class in custom theme

For Drupal 8, the best approach for this is to just copy the bootstrap/block/block.html.twig template from the bootstrap theme into your custom themes folder, and just remove the 'clearfix' class from the twig classes block.


Menus - hard coded primary nav with per-page sub nav

I am not sure which part you need hardcoded, but if it is everything but the a tag, then then l() helper function comes to the rescue:

    <?php print l("Foo", "original/path/to/foo") ?>

Now, if you access "/original/path/to/foo" or (on of its) alias(es), the l() helper will automatically add a class "active" to the a tag, generated by l().

If, for some reason you need the l() outside of the a, or if you want to customize the a itself (e.g. by adding markup to it), you can use the code seen in the l() to determine activeness  of the current item. Place this as helper in template.php of your theme:

function _my_theme_is_active($path) {
  $active = FALSE;
  if (($path == $_GET['q'] || ($path == '<front>' && drupal_is_front_page())) &&
      (empty($options['language']) || $options['language']->language == $language->language)) {
    $active = TRUE;
  }
  return $active;
}

Obviously my_theme is the name of your theme.

Then in the tpl.php files, or anywhere in the scope of your theme, you can use the function:

  <a href="<?php print url("original/path/to/foo") ?>" <?php print (_my_theme_is_active("original/path/to/foo") ? 'class="active"' : ' ') ?> id="foo-1">
    Foo

Beware that you use url() to catch aliasing for the oringial path, but that you /do/ pass in the original (system) path into the _my_theme_is_active helper.


How do plugins store their configuration/field data?

Sounds like the answer is "the data is probably the config table... but it could also be anywhere else depending on the implementation." In the commerce_license example I noted, instances of LicenseTypes on Product variants get their own entry in commerce_product_variation__license_type, where the data for that instance is stored in the license_type_target_plugin_configration column. Just like data stored in the config table, this is a hex blob which, when decoded, is the config field data as a serialized array.


For this situation overwriting the image_style theme function seems a bit heavy-handed, and as best I can tell your overwritten version omits some logic that it probably should not (see the core theme_image_style()). This could explain why things "break".

You would probably be better off implementing a preprocessing function that simply alters that 'attributes' variable that your site's exiting image_style theme function uses, something like:

function mytheme_preprocess_image_style(&$vars) {
  if ($vars['style_name'] == 'front_page_recent_blogs' || $vars['style_name'] == 'blog_page_view') {
    $vars['attributes']['class'][] = 'img-responsive';
    // etc... add other var adjustments as needed
  }
}

You may also be able to avoid custom theme changes altogether if you have enough flexibly in your CSS. It sounds like you need to add some CSS rules only to images in specific fields within specific views, so CSS like this may work too:

.view-id-my_view_name .views-field-field-my-field img {
  // Add your CSS for .img-responsive here
}

Of course this may require duplicating the CSS for .img-responsive if it's used all over the place already (probably likely), which may only be realistic if you are using a CSS preprocessor. I assume you ruled this out already for good reason, but I figured I'd mention it anyway.


I got a solution as follows:

(function($){
    $(document).ready(function(){

    var lMap = Drupal.settings.leaflet[0].lMap;
    lMap.on('click', function(e) {
            marker = new L.marker(e.latlng).addTo(lMap);
    });

    });
})(jQuery);


Drupal Commerce: Number of a sales per product

With this view I solved: https://www.drupal.org/node/1292104#comment-8524109
Just import it and play around for get what you want.


Meaning of "Query results" and "Rendered output" in Views cache?

“Query results” are raw data from DB. After fetching data you often do some additional work (modifications, templates) with data and then render it to HTML in some way — so you get a “Rendered output”. For more flexibility you have two levels for caching here.

As I think (I can be wrong!) here is no sense to set “Query results cache” time less than “Rendered output cache”.

Your use case, as I can see, to flush View cache immediately after new content added. You can solve it with additional staff Cache Actions, which requires Rules.
For example, you can create a rule with event "After saving new content" or "After updating existing content", condition "Content is published" and one of the Cache actions.

Cache will be flushed regardless of cache settings in your view.


Ajax Callback Function in Submit Button Doesnt Work

It is because you are changing the id attribute of the button.
The ajax in Drupal automatically attaches the javascript event listener to the submit, but it expects the button the have the automatically generated id.
Adding or changing the class attribute should not affect it though.

All the suggestions TerryCB made in the comments are also valid.


How to solve Mysql PDOException: SQLSTATE[42S02]: Base table or view not found:

Remove the 'drup_' prefix from your db_query call. Since you define a prefix in settings.php, using {Detailstable} will automatically add the prefix on lookup.


Show list of users based on taxonomy term (D7)

You're right Mohammed, I should be using views.
Use a view with a filter on the department field and then create a link to the view page in my main menu.
I was overthinking this way too much.


Run PHP when node and/or profile is updated?

Theming functions are the wrong place for something like that. To run some PHP code after an node or profile (thus entity) is updated you should use the Rules module or use the following hooks, hook_entity_insert, hook_entity_update


Prevent certain user roles from showing up in results

For A.

Set up another filter in your view for "User: Roles". Choose the Operator "Is none of" and then, choose in the options the role you dont want seen. You can use the roles filter after the exposed one.

Attached is a pic of the user:roles filter section. The options are cutoff to the right (taken from a working site..want to leave the role names private)

You can also expose the role filter and, limit it to the selections you choose in the options pane.


How do I hide /sites/default/files from URLs?

File Aliases module allows you to use token customizable aliases for your uploaded files, giving you the ability to keep your file system organized as per usual while providing clean looking paths (i.e., no more '/sites/default/files/').

  Customizable File Alias field using Node tokens.
  Support for:

  Drupal core Upload module.
  FileField module.
  ImageField module.
  Image module.
  Comment Upload module.

  Support for Private and Public file systems.
  Support for Views output (Fields and Nodes).
  Support for FileField Paths Retroactive and Active Updating.


Ajax drop down list problem with callback

The values will be passed to the callback function reload instead of the original form function, therefore you should rebuild the form in your callback function - reload and pass back the element:

function reload($form, &$form_state) {
  $form_state['rebuild'] = TRUE;
  $form = drupal_rebuild_form('mymodule_form', $form_state, $form);
  return $form['select_str'];
}


How do I add validation in the node processor before creating a node?

You can add this functionality in a custom module. But you'll have to add the logic that you have in your node's validation here.

/*
 * Implements hook_feeds_prevalidate()
 */
function mymodule_feeds_prevalidate($source, &$entity, &$item, $entity_id) {
  // the $item contains your csv files column values
  if ($entity->feeds_item->id == 'import_name') { // check the feed import ID
    if ($item['some column'] != 'something') { // validate column value
      $entity->feeds_item->skip = TRUE; // skips this row from importing
    }
  }
}

Important: I think you'll need 7.x-2.x-dev in order for this hook to work, I'm using it. This is a new hook and I think it has not been added to 7.x-2.0-beta4 yet.


As reported in the documentation, hook_theme_registry_alter() is invoked from Drupal to allow third-party modules to alter the theme registry information returned from hook_theme().

The value returned from the implementations of hook_theme() is an array containing information about the different theme functions implemented by the modules (or themes).

function node_theme() {
  return array(
    'node' => array(
      'arguments' => array('node' => NULL, 'teaser' => FALSE, 'page' => FALSE),
      'template' => 'node',
    ),
    'node_list' => array(
      'arguments' => array('items' => NULL, 'title' => NULL),
    ),
    'node_search_admin' => array(
      'arguments' => array('form' => NULL),
    ),
    'node_filter_form' => array(
      'arguments' => array('form' => NULL),
      'file' => 'node.admin.inc',
    ),
    'node_filters' => array(
      'arguments' => array('form' => NULL),
      'file' => 'node.admin.inc',
    ),
    'node_admin_nodes' => array(
      'arguments' => array('form' => NULL),
      'file' => 'node.admin.inc',
    ),
    'node_add_list' => array(
      'arguments' => array('content' => NULL),
      'file' => 'node.pages.inc',
    ),
    'node_form' => array(
      'arguments' => array('form' => NULL),
      'file' => 'node.pages.inc',
    ),
    'node_preview' => array(
      'arguments' => array('node' => NULL),
      'file' => 'node.pages.inc',
    ),
    'node_log_message' => array(
      'arguments' => array('log' => NULL),
    ),
    'node_submitted' => array(
      'arguments' => array('node' => NULL),
    ),
  );
}

The returned array used what in my previous comment I called theme ID, and it is the same value that is passed to theme().
node_theme() doesn't use it, but the documentation for hook_theme() reports that the array can use the function index to report which function needs to be called as theme function.

A module implementing hook_theme_registry_alter() should use the following code to change the function that is invoked when theme('image') is called.

function mymodule_theme_registry_alter(&$theme_registry) {
  if (isset($theme_registry['image'])) {
    $theme_registry['image']['function'] = 'theme_mymodule_image_output';
  }
}

When a module alters the theme registry using that code, any call to theme('image', ...) will not invoke theme_image() anymore, but it will invoke the function defined from that module.
To notice that it is not necessary to name the function theme_mymodule_image_output(); the code would work the same if the function is renamed mymodule_image_output() and the code of mymodule_theme_registry_alter() is accordingly changed. I usually use the prefix theme_ to make clear the function is a theme function.


The Token module is a start, but it alone won't allow you to pre-fill the content.  By default it will provide a token for the value of every field defined in the user profile.


I assume you're aware that Drupal 6 has been announced to be end of life as of Feb 24, 2016, as detailed in Drupal 6 end-of-life announcement. That mean that D6 will soon be considered as "old" also, right?
So looking at your question in this D6-context , I think "a" practise that may fit for D6 ("when upgrading isn't an option", as in your question) is to Buy Drupal 6 Long-Term Support (LTS) from one of the “official” vendors (up to you to decide if it is a 'good' or 'best' practise of course).
Moreover, as a variation of that "Drupal LTS project" that you mentioned, there now seems to be the D6LTS project.
For more details, refer to "What to do about Drupal 6 End of Life?". Some more details (from this link):

What, specifically, will happen after February 24th?

All D6 modules will be marked as “unsupported” on Drupal.org - which will mean the ‘update’ module will start telling you that ALL your modules are out-of-date.
Also, the status information that the ‘update’ module uses could go away at any time - so, you’ll no longer be able to rely on that in general.
The Drupal security team will no longer be making Security Advisories (or coordinating security releases)
In general, most module maintainers will no longer pay attention to Drupal 6 issues and will stop making new releases.

What should people with Drupal 6 sites do?

Archive the site, or
Plan upgrade.
Buy Drupal 6 Long-Term Support (LTS) from one of the “official” vendors.

What makes the “official” vendors special (vs. any other vendor)?

Get confidential information from Drupal security team.
Agree to follow security team processes and release all security patches publicly.
Vetted by the Drupal security team.

How will the Drupal 6 LTS work?

Same process as security team - but work done by vendors rather than security team.
Will publish patches on the D6LTS project.
Likely, but not 100% decided:

Announce new patches on the D6LTS issue queue.
Make new Pressflow 6 releases with the Drupal core patches.

Can the community get this without working with a vendor?

Yes!
But each vendor only supporting those modules their customers depend on
Question: And what about security issues that hackers find first?


How to define ranges for integer/decimal/float fields in D7?

I needed the same functionality for a project I am working on.

I have created a sandbox project http://drupal.org/sandbox/thepearson/1842424 which I'll be working on hopefully releasing as contrib. I still need to do some more testing, tidy up and documentation.

Obviously it's in sandbox so, use at your own risk. Currently supports int and float. Supports defining min and max limits on both start and end values along with prefix, suffix and range indicator. ie:

[prefix] [min] [indicator] [max] [suffix]
[$ ]     [123] [<----->]   [157] [per person]

alnum type is there but limit validation seems a bit buggy. I would recommend not using alnum until more testing is done.

It's also supports some hook_info/hook_info_alter functions for you to either define your own range datatypes, or change the existing ones. Look at the sub-module range_integer to see how it's done.

If you find any bugs please raise bug reports at drupal.org.


After installation of Drupal commons-7.x-3.13 in windows. I got this type of error?

You need to allocate more memory. There is not enough for mysql to run. There is an entire handbook page dedicated to this common issue. See https://drupal.org/node/259580


I imagine $data->node_data_field_story_text_html_field_one_value is not being set.

Try running dpm($data) if you have the devel module enabled which will show you all the object members set.

Also you should check your php error logs and Drupal watchdog for any errors to see if they provide a clue as to why it doesn't work


How to alter image style based on product custom attribute?

You could use ImageCache Actions module
and write your PHP field condition right on the generation of the image.

Custom Actions effect is what you need.


How to display multiple products under each category in a views grid?

In you view page, click Settings under Format section next to Grid or whatever display type you use.
For Grouping field Nr.1 select Content: Category
Under Fields section, click on the field Content: Category
Check Exclude from display
Save. That's it.


Adding autocomplete to title field of node form

Avoid a custom implementation and use the Unique Field Module. Once this module is enabled, it adds a 'Unique field settings' section to each content type's administration page for specifying which fields (Including node title) for that content type must be unique.The administrator may choose whether the fields must be unique among all other nodes, among nodes of the same content type, or of the same language. You can also set it to display the nodes that match the title.


How can I change the style of a specific CCK field?

you can review the style in the source code, detecting the 'id' of the specific field.

for example add this rule (according the specific id):

#edit-field-color-value {
color:#00FF00;
}


The easiest answer to your problem might be the taxonomy image module:

  "The taxonomy_image module allows site administrators to associate
  images with taxonomy terms. With the association created, an admin can
  then make a call to 'taxonomy_image_display()' from their theme or
  other PHP code to display the appropriate image."

but since you already have a field associated with your taxonomy term, you just want to suppress the output of the tags in your node template and replace it with code that loads the term field and then renders it, ex. roughly:

/* load your term object */
$term= taxonomy_term_load($node->field_tags['und'][0]['tid']);

/* load the entity object (your field names will vary)
$result=field_view_field('taxonomy_term',$term,'field_image','image');

/* display the rendered result, this can be set in manage display for your field to use image styles, etc. */
print render($result);


hook_form_node_type_form_alter does not work

You have a syntax error on the last line, it should start with an apostrophe, and your constant is mispelled.  So it probably isn't compiling properly.  If drupal was picking up the hook you would probably get a white screen of death.

So this means:

You need to make sure the beginning of the function name is exactly the same as your module name - did you use a capital A when naming the module?  PHP is case sensitive.

Lastly, make sure you clear the cache so that Drupal picks up the new hook.  Install drush if you haven't already, go to the /install_directory/sites/mysite directory and run

drush cc all

(assuming you're on linux with command line access)


Preventing a field from rendering on a page

Go to  Display management of your content type  in admin/structure/types/manage/{yourcontenttypename}/display  and  set Formatter as Hidden.

Also you can  hide it with hide function  before render it in node template.

  hide($content['field_home_slider']);
  print render($content);


How to add a column to DB with weight by using hook_update_N?

db_add_field doesn't support AFTER, which you would need to create your desired query.

You'll need to build an appropriate SQL string and run it through db_query() instead.


Which of the following is better in terms of performance and speed?

db_select would give quicker results as it doesn't invoke the entire Views API to get that database result set. However, Views will give you the benefit of a highly configurable user interface to adjust your query which may save on development time.


Visit your checkout page (add product to cart, visit cart, then click Checkout), each fieldset (as in image) is a pane. It's not the same as for "panels" pane.


how to install commerce_kickstart on an environment with PHP memory_limit less than 128M?

Try the methods listed here to increase the PHP memory_limit value

If none of those work, you may need a new host for that application.


View output that goes from list to three-column grid?

I am thinking to create two views. And add them one above the other in a panel. The first view has 10 items in an unformatted list then the next ten would have a grid display of the same content but with an offset of 10.


load a node content into a lightbox2 (without headers and footer and other blocks)

There are many ways to do this, and this gets asked a lot, please have a look at my answer in this question.

Look at this doc page from the Lightbox2 documentation.

Right now though I highly recommend using the Modal Frame API and Automodal for things like this.

** Drupal 7 update

The colorbox module doesn't offer out of the box support for nodes yet (they are working on a patch for this), but in the meantime you can use this approach. You can also use the Shadowbox module, have a look at this and this issue.


Provide the roles to user to make any content and after save the content it will show with restriction.
Or
you can make custom module for that.


How to use function like 'rtrim' in drupal?

Use the Drupal file API to do this; file_move() will take care of renaming.

  $file = file_load($fid);
  $new_file_uri = preg_replace('/\\.([a-zA-Z]+)$/', '', $file->uri); //Remove .whatever from the file name
  file_move($file, $new_file_uri);


Changing to date field based on from date using javascript

If I understand you right it should be as simple as dropping something like this into a JS file included in the page:

(function($) {
  Drupal.behaviors.myModule = {
    attach: function(context, settings) {
      $('#edit-from-date', context).change(function() {
        $('#edit-to-date', context).val($(this).val());
      });
    }
  }
})(jQuery);

Disabling certain dates is a bit more complicated but there's an example here that should point you in the right direction.


How to set a content type tile base on taxonomy field that user select?

Do it with rules and the title module:

{ "rules_title_taxonomy_token" : {
    "LABEL" : "title taxonomy token",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : {
      "node_insert--package" : { "bundle" : "package" },
      "node_update--package" : { "bundle" : "package" }
    },
    "DO" : [
      { "data_set" : {
          "data" : [ "node:title-field" ],
          "value" : [ "node:field-my-taxonomy-field:0:name" ]
        }
      }
    ]
  }
}

Be sure to change "package" to the name of your content type and be sure to use the proper field name for your taxonomy instead of field-my-taxonomy-field.

As far as I know, the above only works with the Title module and the Title Field UI.


How can I do an OR operation on the values of a solr field?

Can't say for sure if this is in 1.6 but if you configure the country facet block you'll get the option to use AND or OR inside the facet.


How can I set a response URL to use https?

The best way to handle this is when the user requests the JSON over HTTP, redirect it to HTTPS, and then the response will come back as HTTPS.

The Secure Pages module does just this.  It will let you create regex patterns on paths, so you can have portions of your site use HTTPS, but not others.  You would just need to add the paths for your JSON.

Note that the Drupal 7 version requires two patches against core, but I have clients who have these patches on live sites.


I have WYSIWYG and CKEditor 3.6.6.1 and want to install the latest CKEditor 4.6.1

As far as I know, you need to use the dev version of the WYSIWYG module in order to use CKEditor 4.x. You also need to grab the 'full build' of CKEditor and not a stripped down one. You do not need the CKEditor module if you are using the WYSIWYG module. WYSIWYG looks for editors in the given paths (usually libraries) - you have to go get it from ckeditor.com.

The second thing you are describing is adding custom or non-core plugins to CKEditor, which is not as straightforward. "Paste from Word" should be available though once you get WYSWIYG and CKEditor 4.x setup in Drupal 7.

I wrote a plugin integration once for CKEditor 4.x under WYSIWYG. I do not recall needing any module other than WYSIWYG and the full CKEditor library for getting WYSIWYG to show up. You shouldn't need any other CKEditor modules. But if you are looking to add other plugins on ckeditor.com - you need to get comfortable with the WYSIWYG API in order to properly integrate it if someone else hasn't done so already.

The reason your CKEditor may not be showing on the edit page is likely due to a JS error - I am going to guess either because you are not using WYSIWYG dev branch, or CKEditor is not the right version, or CKEditor is not installed in the correct path. Please add the error from the browser console to the original question along with any watchdog errors.


Large var_dump when looking at $variables

Yes, it is normal as Drupal pass enormous amount of data trough functions and hooks using array. But for better answer you should provide more information.


How to properly use a JS library that inserts content into existing DIV?

You can likely use drupalgap_add_js() at the beginning of your pageshow implementation to add the Chart.js library:

function qleva_start_auth() {
  drupalgap_add_js('Chart.js');
  // ...
}


Drush 9 can't find installed module, yields CommandNotFoundException

I looks like I simply had forgotten to enable (i.e install) the module in /admin/modules. I had just ran "composer require", but not actually enabled it.


Uploading images in a node with WYSIWYG and TinyMCE 3.4.3

Check your Input Filters field-set while editing your node, in case of filtered html your image would not be presented. Try with full html.


Using Profile2 and Views - How to display the separate profile data on a single row

I am not sure how you have created the view. But this would be the method to go about it

Create a view of the user.
Create two relationship of the type User : Profile One for the Main Profile and the other for the Membership
Add the required fields choose The corresponding  relationship for each of the fields, that is choose the one we created for Main Profile for the fields with in Main Profile and Membership for the ones in the membership.

That should bring it all in one line.

You might not be able to have the Profile and PID like in the first out put but I guess you dont want that .


The first hook, hook_token_info(), is used to declare any custom tokens.

    /**
 * Implements hook_token_info().
 */
function module_name_token_info() {
  $info = array();
  // Define a new token type.
  $info['types']['my_custom_tokens'] = array(
    'name' => t('My custom tokens'),
    'description' => t('A token type for my custom tokens.'),
  );
  // Define any new tokens.
  $info['tokens']['my_custom_tokens']['my_cool_token'] = array(
    'name' => t('My cool token'),
    'description' => t('A token I use to show that I am cool.'),
  );
  return $info;
}

We are creating our own custom token type here too but if you just want to put your token in an already existing type, you can get a list of the existing tokens and types by calling token_get_info().

Now that our new token is good and defined, we just need to give it some content with hook_tokens().

     /**
     * Implements hook_tokens().
     */
    function module_name_tokens($type, $tokens, array $data = array(), array $options = array()) {
      $replacements = array();

      if ($type == 'my_custom_tokens') {
        // Loop through the available tokens.
        foreach ($tokens as $name => $original) {
          // Find our custom tokens by name.
          switch ($name) {
            case 'my_cool_token':
              // Work out the value of our token.
              $value = 'Whatever we want the token to be';
              // Give our token it's value!
              $replacements[$original] = $value;
              break;
          }
        }
      }
   return $replacements;

}

That's it! Our token should now be available and appear in the list of tokens wherever tokens are available.


Adding a class to a menu item where the class name is set in the node

How comfortable are you with code?

This sounds like a job for hook_preprecess() inside template.php to get the value of drop down field and store it to something like $var['my_class_to_insert']=. Then inside of whatever.tpl.php used for this situation, have
Content goes here
. See https://stackoverflow.com/questions/8124089/ for how to get the value of a field in the template.php file.

The drawbacks to this second approach is that you are coupling functionality to the theme layer and adding to "Drupal's Div Soup."

Or I'd look at two other modules before you open up a code editor. You could try to use logic in the Context Module

  Context allows you to manage contextual conditions and reactions for
  different portions of your site. You can think of each context as
  representing a "section" of your site. For each context, you can
  choose the conditions that trigger this context to be active and
  choose different aspects of Drupal that should react to this active
  context.

And Rules may help out...

  The Rules module allows site administrators to define conditionally
  executed actions based on occurring events (known as reactive or ECA
  rules). It's a replacement with more features for the trigger module
  in core and the successor of the Drupal 5 workflow-ng module.

Rules and Context also have a world of other modules that add additional pieces of functionality.


I need to add title of specific nodes in a select box

Depending on your requirements could try drupalising your webforms a little so that you could use all the lovely field based modules.

If you elected to use entity form, instead of webform, then you should be able to use a normal entity reference field or a views derived field (eg entity reference view widget) on your form.


Yes, it is acceptable for child menu items to not contain any of the parent item's path.


For Drupal 8 you can use the Content Synchronization module.  From the project page:

  The content synchronization module provides a mechanism to export single content items, or all content items, from an environment, and move them to another, effortlessly.


Listing all entity properties identifying unique entity instance?

I have always assumed that when you do

$entity_info = entity_get_info('foo');
$table = $entity_info['base table'];
$schema = drupal_get_schema($table);

and then examine $schema['primary key'] and $schema['unique keys'] you get a tuple to represent uniqueness.

I would also assume that you can do

$entity_info = entity_get_info('foo');
$keys = $entity_info['entity keys'];

and this would represent a tuple to uniquely identify an entity.  However, this gets a little confusing.  For example, if you have UUID installed, then there is a uuid and revision uuid in the results.  These are not needed within one system, but will guarantee uniqueness between systems.


How to use user_external_login_register() with user authenticated by token?

It seems a couple of mistakes in your above code.

Your $cs_user array below line should be populated with name instead of lastname

'name' => $user_info['data']['user']['lastname'] . "_psr",

Also, It seems 2nd line of your function function chapterspot_signon_user_external_login_register($name, $module) is not needed. Because if you Initialize your $account variable with $name then your condition if (!$account) { never comes true and the code written into that if condition will never executed.

You can try two approaches it will work for you:

1) Call Built-in function user_external_login_register($name, $module)  from your custom module.

Example:

user_external_login_register("addweb-solution", "your-custom-module-name");
drupal_goto('/members');

2) You can write your own function as below in your custom module:

function test_user_external_login_register($name, $module){
        $account = user_load_by_name($name);
        // $account = $name;
        if (!$account) {
            $userinfo = array('name' => $name,
              'pass' => user_password(),
              'init' => $name,
              'status' => 1,
              'access' => REQUEST_TIME,
            );
            // Register this new user.
            $account = user_save(drupal_anonymous_user(), $userinfo);
            // Terminate if an error occurred during user_save().
            if (!$account) {
              drupal_set_message(t("Error saving user account."), 'error');
              return;
            }
            user_set_authmaps($account, array(
              "authname_{$module}" => $name,
            ));
        }
        // Log user in.
        $form_state['uid'] = $account->uid;
        user_login_submit(array(), $form_state);
        drupal_goto('/members');

}

Hope this will helps you.

Thanks!


Export block that exists in two or more regions

The short answer is no.

The simplest way to get what you need is to create two unique blocks and simply export both YAML files. This method will make adding any styling or configuration differences down the line much easier anyway.

Per question #9677 there were some problems with doing this in Drupal 7 but thankfully the block system is pretty robust in Drupal 8.


Drupal 7 form, query DB and results display

This is what you need. Take a look into the Examples for Developers module. And Views of course. No need for handcrafted SQL.


How to avoid Exif data rotating images automatically during approval selection?

Once you've set up ImageMagick you can start using it in a file hook to process your images on upload.

Some good hooks to look at would be:

https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_file_presave/7

https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_file_insert/7

Watch for an image being uploaded, read exif data with imagemagick, adjust accordingly.


How to delete uninstalled modules via drush?

Drush is a tool for performing Drupal operations in the shell. If you've already uninstalled the module then there's nothing left in Drush's purview to do, just perform a rm on each module you need removed. pm-list has --pipe option that will spit out the module short name. You can use that output to find the correct directory and remove it. Something like...

drush pm-list --type=Module --pipe --no-core --status="Not installed" | while read -r module; do  find sites/all/modules -type d  -name "$module"; done

The remaining work here is more of question about bash (or your shell of choice) than Drush so I'll leave it to the reader to find his own solution.

It should also be mentioned scripting module folder deletion could be fraught with dangers (e.g. not every module is going to be at the same folder, you shouldn't be deleting submodules, etc.); you're better off manually inspecting a list of uninstalled modules (you shouldn't have that many) and removing them judiciously.


2 Drupal Multisites, Separate Databases, Changing 1 Also Changes the Other

You've been doing Multisites for awhile now, so this seems like an obvious question -- but did you clear the drupal cache?

... and after doing so, restart Apache.  Many of my "unexplainable" errors have come down to that.


Drupal installation in nginx subdirectory

I had a similar scenario, but in my case I didn't need to define again the root folder for the Drupal installation as you do on location /admin.

In my case I only needed to add the nginx directives for the Drupal path:

location /admin {
    try_files $uri $uri/ @rewrite;
}

location @rewrite {
    rewrite ^ /admin/index.php;
}


Defining a varibale Node Expire date by custom PHP code in Rules module

Thanks to @undersound, the code below worked!

$duration = [node:field-duration:field-value];
$node->expire = date('Y-m-d', strtotime("+" . $duration . " days"));
return array("node" => $node);


It appears that the issue was at the infrastructure level. The error resolved when I restarted Apache.


How do I use theme('links') with nested arrays?

You need to add the sub items to a 'children' key of the array. Here is an example:

$list = array(
  'item1' => t('Item 1'),
  'item2' => array(
    'data' => t('Item 2'),
    'children' => array(
      t('Item 3'),
    ),
  ),
  'item4' => t('Item 4'),
);

return theme('item_list', array('items' =>  $list));


My solution is simply manually typing out relevant labels for each line.
I just use "Custom body"

For example:

Name: [webform_submission:values:navn:value]

Email: [webform_submission:values:email:value]

Date: [current-date:html_date]

Unless you change your form often i find that to be the easiest way to format it exactly as you want it.


How to show view for submitted result of a webform by a user

I have done that in drupal 7 but not in drupal 6. In drupal 7, go to View.

Create a relationship "Webform Submissions: User" and require it
Create the contextual filter "User: uid"
Select the relationship which you created in step 2 and select "provide Default Value" under "When the value is NOT in the URL" and select "User ID from logged in User".

I hope this will help you out.


I am looking for suggestions on how to implement banner ads utilizing google type ads (or someone else)

The most common ad network is Adsense. You will have to sign up for an account and then you can install the Adsense module which will manage your ads for you.

Beware however, this isn't a get rich quick type situation. Making money of Adsense requires a high volume of traffic.


You need use hook_page_attachments_alter

function mytheme_page_attachments_alter(&$attachments){
  $attachments['#attached']['html_head'][] = [
    // The data.
    [
      '#type' => 'html_tag',
      // The HTML tag to add, in this case a  tag.
      '#tag' => 'script',
      // set attributes like src to load a file
      '#attributes' => array('src' => '/themes/mytheme/assests/js/particles.json'),

    ]
  ];

}


How do I change the delta values using a hook?

You can specify the validation criteria with PHP code in your contextual filter settings:

When the filter value IS in the URL or a default is provided

Specify validation criteria -> PHP Code

if($handler->argument){
  $view->display['default']->handler->options['pager']['options'] = array(
    'offset' => 0,
    'items_per_page' => $handler->argument
  );
  return true;
}
else {
  return false;
}

That's it. Now, for every request the delta will be equal with the argument from the URL.
$handler->argument It's the argument which has been provided by your contextual filter.


User 1 becomes anonymous on node/add, access denied messages

Those who come and find this question unsolved can use the solution at d.o which is

  Solved it!! It had to do with the .htaccess file! I needed to comment
  the following with regard to SSL Certificates.

# SSL Certificates
#  RewriteCond %{HTTPS} !=on
#  RewriteRule (user|admin) https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
#  RewriteCond %{HTTPS} !=off
#  RewriteRule (node/*/edit|node/add/*) http://%{SERVER_NAME}%{REQUEST_URI} [L,R]

  I am not entirely clear on why it suddenly worked, but obviously it
  has something to do with these rewrite rules.


SQL left join query using Drupal DB Layer

I've seen this before, I can't remember why it's this way but you can fix it by swapping out which types of quote you use.

Changing your code to this will fix the problem:

$query = db_select( 'node', 'n' )
  ->fields( 'n', array('created', 'title', 'type'));

// Change wrapping quotes to "" and internal to '' for 3rd arg here
$query->leftJoin( 'url_alias', 'ua', "ua.source = CONCAT('node/', n.nid)");

$query->addField('ua', 'alias');
$results = $query->execute();

It's either a Drupal or PDO issue, as either type of quote works fine when executing directly against the MySQL server.


How to add a preview image to a content type?

No, this functionality is not in Drupal core.

It could (at least in principle) be added through a contributed module, but AFAIK, there is currently no contributed module offering this.

It may not be trivial to add this feature in a meaningful way.  It is not unusual for Drupal sites to have content types that uses the same visual layout - but different workflows and access rules - for different use cases.  A "preview image" would not distinguish them from each other in such cases.

While the idea of different content types for different purposes is at the core of the "Drupal way" of building a site, I've noted that many ordinary users, editors and even admins struggle with this particular idea.  The problem you mention: "the editor who doesn't know which content type to choose for his content" is a real one.

I've not found a really good solution to this.  In the real world helpful content type descriptions are often not read by users/editors/admins.

My solution so far is to offer a very restricted number of content types to end users, and use very descriptive names for the types they're exposed to (e.g. "Personal blog post", "Embedded video").


I'm not sure but maybe the Computed Field can be used, you can even use it to fill another field.

If you are ready for some custom code (although Computed Field will probably require some code too), you can implement hook_nodeapi() when $op == 'prepare'(or hook_prepare() in Drupal 7). There you can pre-fill new Invoice node (when $node->nid is not set, the node is being created).


How to add custom email to account user emails?

This form is defined in core user module, user.admin.inc file:

/**
 * Form builder; Configure user settings for this site.
 *
 * @ingroup forms
 * @see system_settings_form()
 */
function user_admin_settings() {

Particularly, line 444 starts email template section:

$form['email'] = array(
    '#type' => 'vertical_tabs',
  );
  // These email tokens are shared for all settings, so just define
  // the list once to help ensure they stay in sync.
  $email_token_help = t('Available variables are: [site:name], [site:url], [user:name], [user:mail], [site:login-url], [site:url-brief], [user:edit-url], [user:one-time-login-url], [user:cancel-url].');

  $form['email_admin_created'] = array(
    '#type' => 'fieldset',
    '#title' => t('Welcome (new user created by administrator)'),
    '#collapsible' => TRUE,
    '#collapsed' => (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) != USER_REGISTER_ADMINISTRATORS_ONLY),
    '#description' => t('Edit the welcome e-mail messages sent to new member accounts created by an administrator.') . ' ' . $email_token_help,
    '#group' => 'email',
  );
  $form['email_admin_created']['user_mail_register_admin_created_subject'] = array(
    '#type' => 'textfield',
    '#title' => t('Subject'),
    '#default_value' => _user_mail_text('register_admin_created_subject', NULL, array(), FALSE),
    '#maxlength' => 180,
  );

As you can see, there is no foreach, no external hook call, nothing. Just raw fields hardcoded. The only way is to add your fields using hook_form_alter(). Make sure you also add your validators and submit handler to take care of your new fields, because user module will not do it for you.


Why I not get value from $form_state['values']['field_form_name']

The code you are showing is wrong for two reasons:

hook_form_alter() is invoked for every form Drupal is showing; this includes Drupal core forms, as well as forms implemented by third-party modules. It is not invoked for the forms of your own module. So, you first need to check for which form the hook is being invoked, then you can access the form fields the form of your module is using.
hook_form_alter() is not invoked when the form is submitted, but before the form is rendered. So you cannot use $masothue = $form_state['values']['ma_so_thue']; there. You need to add a new submission handler from hook_form_alter(), and in that submission handler you can get the submitted values, but then you cannot alter the default value for a form field in a submission handler.


After a few more hours learning twig filters I can calculate the retail price in each line item with this:

{% for adjustment in totals.adjustments %}
{% set disc_percent_remainder = 1 - adjustment.percentage %}
{% set disc_unit_price_raw_2 = order_item.getUnitPrice|commerce_price_format %}
{% set disc_unit_price_raw_1 = disc_unit_price_raw_2|trim(' USD', 'right') %}
{% set disc_unit_price_raw = disc_unit_price_raw_1|trim('$', 'left') %}
{% set disc_unit_price = (disc_unit_price_raw * 100) / disc_percent_remainder %}
${{ (disc_unit_price / 100)|round(2, 'ceil') }}
{% endfor %}

This is a horrible work-around I'm sure, ruins any chance of multiple currencies and Im sure can be cleaned up a lot with nesting some of this. But, it comes up with the correct retail pice.


ERR_TOO_MANY_REDIRECTS on images after switch to HTTPS

Try this out -

# ensure www.
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [L,R=301]

# ensure https
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]


How can I generate thumbnails for PDF files?

For similar purpose i was using Media Entity in Drupal 8, so on this way you can use reference field to upload document and get preview like thumbnail.


Need Separator image for views ticker content?

If you wants the separator between two content you have to write css for that.This is a css query.Please check the css.Have a great day.


Contextual filter by taxonomy term not using language

Temporary solution for was to create patch file to override views module functionality a little bit. Patch can be found under issue on drupal.org
https://www.drupal.org/node/2466001#comment-9795191.


Taxonomy reference of the content type must be set to 1. New tokens will become availible and differect ways to create a url like the above become possible


How to retrieve data from custom table in database?

The fields method takes a table name/alias as its first arg, and an array of field names as its second:

$result = db_select('mymodule', 'mm')
   ->fields('mm', ['field_one'])
   ->execute()
   ->fetchAll();


There is a hook in webform called hook_webform_select_options_info, that allows you to build a dynamic list of $items[] (return $items), which will be used as the list of options for your component.  What you put into this list can obviously be anything - i.e. how you decide what to put in is up to you.

I used it recently to create a multi-route dynamic web form where the path through the webforms is determined by a decision tree.  Ever option on every question is loaded from a JSON file, and depending on the answer, the next question (which could be any one) is shown.


How to add custom class on the menu block using twig?

You can do this by creating template file called "menu--main.html" in your theme's template folder.

Then in place below code in that file:

{% import _self as menus %}
{{ menus.menu_links(items, attributes, 0) }}
{% macro menu_links(items, attributes, menu_level) %}
  {% import _self as menus %}
  {% if items %}
    {% if menu_level == 0 %}

    {% else %}

    {% endif %}
    {% for item in items %}
      {% if menu_level == 0 and item.is_expanded %}

    {{ item.title }}

      {% else %}

        {{ link(item.title, item.url) }}
      {% endif %}
      {% if item.below %}
        {{ menus.menu_links(item.below, attributes.removeClass('nav', 'navbar-nav'), menu_level + 1) }}
      {% endif %}

{% endfor %}

  {% endif %}
{% endmacro %}

This will add the class "ul"


It should be:

module_load_include('inc', 'calc', 'form');

(The 'inc' in the first argument automagically appends as the extension)


Missing my custom ajax field values by image field in node form alter

In your form an AJAX call is made when your car_brand element is changed but also when upload image button is clicked. Your problem is the AJAX call that is made when upload button is clicked. In that call car_info_form_car_info_node_form_alter() is called, and probably is modifying the allowed options array for the model select element in a wrong way.

In your form altering function check for the element that fired the AJAX call  modifying the select element options only when your first select (brands). You can check for that element in the $form_state['triggering_element'].


There are many things to comment here: Why are you installing Drush 8 and why the specific (outdated) version 8.1.3?

What happens is that your global Drush looks for a site local Drush, finds something ("C:\xampp\htdocs\drupal-project\drush") and tries to execute it.

The recommended approach - at least if you have a site local Drush, which you have if you installed Drupal using Composer and "drupal-composer/drupal-project" - is to use Drush Launcher (instead of a global Drush). NB! Read this issue so it works smoothly on Windows.

After you have fixed the path so Drush Launcher is used instead of the global Drush, try drush status again. I expect it to find the correct site local Drush. You migh also want to try drush --versionto verify which version of the launcher and Drush itself that is used.

You can test that the setup is correct by running Drush inside the directory containing Drupal:

1) If you have installed Drush Launcher correct, you should get the following output:

# drush --version
Drush Launcher Version: 0.6.0
Drush Commandline Tool 9.2.3

2) If you however have installed a global Drush 9 (using Compser) in stead of Drush Launcher, you get the following output:

# drush --version
'PATH_TO_DRUPAL_PROJECT/vendor/drush/drush/drush' is not recognized as an internal
or external command, operable program or batch file.