How to resolve Integrity constraint violation: 1062 Duplicate entry on node_access?

For posterity, I did not figure out the line of code that were  causing this but the issue is that node_save was being called twice on a new node, which DID create a legitimate duplicate key, but then it would also delete the offending row. This drives the developer bonkers.

It has something to do with Workflow (probably), and I am not particularly proud of this but you can remedy by making one small change to node.module:

/* ADDED SPR */
$delete = true; //$op == 'update';
/* END ADDED SPR */

Top and bottom lines are for easy searching of code tweaks for upgrades.


Creating REST service to get complex node type

Views Datasource is very popular module to return json, xml or any other type of data.

    Views Datasource is a set of plugins for Drupal Views for rendering content in a number of shareable, reusable formats based on XML, JSON and XHTML.

Install the module. Create the view that return your node. then under format select data source as json. You can only select the field you want to render in field settings.


Can I use the Services module without coding skills?

Using migrate and services are for separate use cases IMO.

I'd use Migrate for a one-off or periodic import and use Services for RESTfully add/update/deleting one at a time.

The services module includes integration with the user module and you can pretty much administer/point and click to get an xmlrpc endpoint with the user resources added.

You'd have to write a bit of code on the first site though, you might use a user hook http://api.drupal.org/api/drupal/modules!user!user.api.php/function/hook_user_insert/7 (or update, delete etc) and then use the data to make a http request to your other site http://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_http_request/7


The error is complaining that it can't save the body field because you haven't specified the bundle of the object. But more importantly I think you want to look into the Entity API rather than creating a 'node_type'.

In drupal there are nodes and there are types of nodes called content types. To make it more abstract, nodes are entities of type 'node'.  Each content type is a 'bundle' of that entity type. Many things in drupal are entities, from users to comments to taxonomies.

If all you want to do is create a content type programatically, I think examples might have one. Otherwise just create the content type through configuration.


How hide from menu content type Basic Page and Landing page

SOLUTION:
I just removed for Content publisher or any other role

Create any content on assigned domains

I think this permission was added with the module Domain Access


Get path alias from NID (or node object)

To get the path for a node id use AliasManager::getAliasByPath:
Drupal 8
$alias = \Drupal::service('path.alias_manager')->getAliasByPath('/node/'.$nid);

As per the new change record in Drupal 8.8.0 and above path.alias_manager is deprecated and path_alias.manager is introduced.
New syntax is as follows :
$url_alias = \Drupal::service('path_alias.manager')->getAliasByPath('/node/'. $nid, $langcode);


unable to add,edit,delete content types in drupal 7?

Try following steps.

Make sure clean URLs working first. If you need any help for clean URL visit this link
Try clear cache and then disable all contributed modules. I see there is a problem due to commerce line items module. Disable all contributed modules. Don't disable core modules.
Clear cache and check.

Tell me in comments if you still face problem.


How to configure settings.php for Drupal site with Varnish and CDN?

If you don't know what you're doing (and to a certain extent even if you do) it's probably better to use modules to accomplish what you're trying to do:

Varnish
CDN

This is mainly due to the extra configuration and set-up help you get with the modules


Which cookie is this? All of Drupal 8's cookies are secure.

The exception is BigPipe's no-JS cookie, see https://www.drupal.org/node/2678628 — but there are no security consequences there.

If that's the one that is triggering this alert, then the problem is clear: your security testing tool is making blanket statements that don't make sense.


Providing "translations" based on region rather than language

The addressfield module does this.  You can check their code to see how you can implement such a feature in D7.


In your theme open file THEMENAME.theme, example in my case THEMENAME is bartik and file is bartik.theme add code below:

/**
 * Implements hook_preprocess_links().
 */
function bartik_preprocess_links(&$variables) {
  if (isset($variables['links']['node-readmore'])) {
    $variables['links']['node-readmore']['link']['#options']['attributes']['class'][] = 'css-readmore';
  }

  if (isset($variables['links']['comment-add'])) {
    $variables['links']['comment-add']['link']['#options']['attributes']['class'][] = 'css-comment';
  }

}

Update:

Code above will add css class to any readmore link, to add for article only you can add preprocess and check type is article.

/**
 * Implements hook_preprocess_HOOK() for node.html.twig.
 */
function bartik_preprocess_node(&$variables) {
  ...

  if ($variables['teaser'] && $variables['node']->getType() == 'article') {
    $node_type_is_article = &drupal_static('node_type_is_article');
    $node_type_is_article = TRUE;
  }
}

/**
 * Implements hook_preprocess_links().
 */
function bartik_preprocess_links(&$variables) {
  if ($node_type_is_article = &drupal_static('node_type_is_article')) {
    if (isset($variables['links']['node-readmore'])) {
      $variables['links']['node-readmore']['link']['#options']['attributes']['class'][] = 'css-readmore';
    }

    if (isset($variables['links']['comment-add'])) {
      $variables['links']['comment-add']['link']['#options']['attributes']['class'][] = 'css-comment';
    }
  }
}

Clear all cache and see result. Here is my result:


Check to ensure the content has full HTML input filter, it may be that even though the source includes the customised html inserted by TinyMCE upon save it is all being stripped out.


Limit taxonomy terms display on hierarchical select

Workbench Access module might be a great solution for your issue.

  Workbench Access creates editorial access controls based on hierarchies. It is an extensible system that supports structures created by other Drupal modules.

  The module supports Taxonomy and Menu modules for the management of access hierarchies.

Also, take a look at the current issue for Hierarchical Select module integration with Workbench Access module


The module Bulk Media Upload is the one that I have used in the past for that matter. From the module page:

  With Bulk Media Upload you can upload a bunch of files and a new node, taxonomy term, or other entity will be created for every file. The files are selected via a browser file upload dialog and can be stored in a file or image field.
  Also default values can be chosen for the other fields assigned to the new node.

I believe you will not have any difficulties, it is pretty straightforward. Also, if you come across some minor bugs, I have a couple of patches commited in its issue queue awaiting community review.

Alternatively, one can use the Feeds module to import nodes. That would be more helpful with existing files. It might require to list the files into a CSV file (for *nix systems copy/paste from terminal the output of ls /path/to/files).


what permissions are needed to give a role ability to access: admin/content list page

found it! its under this:

Access the content overview page
Get an overview of all content.


How can I save a file in specific folder?

In form submit action you can give the destination path.

function formname_form_submit($form, &$form_state) {
    $destination = $form_state['values']['foldername_name'];
    $validators = array();
    $file = file_save_upload('file', $validators, 'public://'.$destination);
}

More about file_save_upload get https://api.drupal.org/api/drupal/includes!file.inc/function/file_save_upload/7.x.

more related links
https://stackoverflow.com/questions/1253094/howto-drupal-file-upload-form


Currenty working on that. The code

# One month
 <filesMatch ".(css|jpg|jpeg|png|gif|js|ico)$">
  Header set Cache-Control "max-age=2628000, public"
 </filesMatch>

helped me to remove images from the list below https://developers.google.com/speed/


A relationship to the latest referencing entity in views

Make a view that lists nodes of Type B.
Sort this view based on date.
Add relationship based on the reference field which reference content type A.
Now list the fields you want from Content type A.
If you don't need fields from Content type B, hide them.


Strategies for approaching a client requirement to create quizzes

I am sure that the latest version of the quiz module has a full flow of functionality with Drupal 7 also. I have used the quiz module to develop a site in Drupal 7 and it worked fine. If you have any issue in working with the Quiz module, i am ready to help you out in solving your issue.


There is at least 1 issue queue item looking to add "reporting" to the Media module, such as show me where this file is used on the site.

If you're using Drush. Look at drush sql-cli and a query such as select fid, filename from file_managed where status = 1


What is the proper way to add third party script snippets to head tag?

Your issue seems to be related with hook_page_attachments() not called from mytheme.theme file. If you look to the answer, it's written -

  It appears that this function is only callable from a module, as it is
  listed in Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8
  module but not listed as a valid method in Adding stylesheets (CSS)
  and JavaScript (JS) to a Drupal 8 theme.

I verified with the current documentation & that's correct. You can use hook_page_attachments_alter, which has documented in above given document for Adding stylesheets and JS to a Drupal 8 theme.


If you are using Drupal latest version, boolean field is available by default in core.

Goto your content type => Manage field => Add new field => Select field type

In the manage field configuration, give 'on' value and 'off' value. Here I have given, Yes and No.

In the views filter, select the option you wish to filter. Thats it.


I don't find any module does that specific purpose of making top bar.
It is usually done by custom themeing. Basically, you add a new region to your theme.
For example, You define a new region called "topnav" in .info;  code the markup in template.php and .css files. Then go to block administration page, assign stuffs to the topnav region.


How do I Send a single mail with Rules and VBO?

Here is a blueprint to do what you're asking about:

Create a new variable, which you define as a "list of users" (so that you can use this list later on to "loop through this list").
Replace the "send an eMail" (within your existing Rule) by an action to  "Add an item to a list" (using the list you created via that new variable). When doing so, you make sure to set "ENFORCE UNIQUENESS" to true, so that you "only add the item to the list if it is not yet contained" (see where I'm going?).
In the end, the value of the new variable will contain a list of unique users. So just add another Rules loop (at the end?), to iterate over each of the users in that list. And guess what you can then do in this additional Rules loop ... indeed: send an email to each of those users. And since each user is only contained 1 time in that list, they will only receive 1 eMail.

Easy, no?


node_type_form() lives in modules/node/content_types.inc, which the system only includes when it needs to (to fulfil menu paths etc).

If you include it manually before your call to drupal_get_form() it should work...

module_load_include('inc', 'node', 'content_types');
$form = drupal_get_form("node_type_form");
// ...


Where are Commerce 2 hooks (or Events) in Commerce 2

as you've discovered, you can look in any module's src/Event/*Events.php file to find a list of their events. Using the order paid event is one way to react once you know that payment has been collected, but note that in scenarios where an order is placed with only a payment authorization (and not a capture), that event would not have been fired yet.
That may be fine in your case - if not, I'd recommend the commerce_order.place.pre_transition or commerce_order.place.post_transition events that are triggered when the order is placed. That event is coming from the state machine module and correlates to order workflow transitions. You can read more about it in the module's readme.
As for form alters, those exist in D8 as they did in D7.


Creation + Drag and drop of groups of fields with CCK

Take a look at field collection module.

You could create a field collection with a text field (Number of values: 1) and an image field (Number of values: Unlimited). Then you should set your field collection field also to unlimited values so you can add as many sets you want.

Nevertheless field collection is a little buggy, but give a try first.


How can I ensure that every page within my drupal 6 site loads a specific Javascript file?

Add the URL of the JavaScript file as scripts[] to the theme's info file.


How to change the name of uploaded file in my custom Entity?

Please refer the below articles it will be helpful for you..

How do I change the uploaded file name after the node has been saved?

Changing file name on upload


https://drupal.org/project/domain_access_bridge

This module creates a working interplay between the Domain Access suite, one {access control} module (e.g. Organic Groups, Content Access, Taxonomy Access) and eventually the Workflow module.


Need to insert a custom node edit link in the node template

In your node.tpl.php you have access to current node object $node and you can get the node id.
You can check permissions for current logged user with user_access function

So you can do the next thing in your node.tpl.php

<?php
      if (user_access('your_permission_here')){
       //create link for current node edit
       echo l(t('Edit this node'), 'node/' . $node->nid . '/edit');
      }
?>


How to remove images from body field in views?

Edit the Body Field Rewrite results in your Views and enable the option Strip HTML tags. Use Preserve certain tags if you have other elements within your text you want to show, enter them there.
This option is below the Trim this field to a maximum number of characters you're probably using, you'll probably want to also use the suboption Field can contain HTML.


RULES : How to redirect user to a page after login unless they're using the one-time-login-url?

1st method:

I believe there is a module called Login toboggan which will allow you to do exactly what you want.

From the module page:

  The LoginToboggan module offers several modifications of the Drupal
  login system in an external module by offering the following features
  and usability improvements:

  Allow users to login using either their username OR their e-mail
  address.

  Allow users to login immediately.

  Provide a login form on Access Denied pages for non-logged-in
  (anonymous) users.

  The other brings the user to a separate page, but returns the user to
  their original page upon login.

  Optionally redirect the user to a specific page when using the
  'immediate login' feature.

  Optionally redirect the user to a specific page upon validation of
  their e-mail address.

  Optionally display a user message indicating a successful login. ...

2nd method:
I believe when someone request a password, the format of the link will be similar to this one:

https://www.drupal.org/user/reset/...

If so, you can create a rule to redirect the user upon login to a specific page. However, add one condition which will be:

Data comparison: the link should not contain the word reset

Hope it helps,


Set to the language of admin pages to english despite the language of front pages?

Administration Language module lets the administrator see all administration pages in their preferred language.


Can't pass php variable to javascript in Drupal 7

Make sure you call for jquery setting inside Drupal behaviour, you can do like this:

(function ($) {
    Drupal.behaviors.example_name = {
        attach: function(context) {
            alert(Drupal.settings.my_var.orderid);
        }
    }
})(jQuery);

or you can call inside jQuery's .ready() event (less preferable than behaviours approach in Drupal world):

jQuery(document).ready(function($) {
   alert(Drupal.settings.my_var.orderid);
});

These both approaches ensure that jQuery is loaded before calling a variable.

P.S. I recommend using console.log instead of alert for quick debugging, like this:

console.log(Drupal.settings.my_var.orderid);

Then go to your developer console / firebug (depending on browser you use) and you'll see an output in console.


You can make use of Field Info API functions to get this information.

Since the 'required' setting is on the instance level, not the field level, you'll need to use either field_info_instances(), which will get the instance information for all fields attached to a given entity type and bundle:

$entity_type = 'node';
$bundle = 'article';

$info = field_info_instances($entity_type, $bundle);
foreach ($info as $field_instance) {
  $required = (bool)$field_instance['required'];
}

or alternatively, if you only want the info for a single field, the field_info_instance function:

$entity_type = 'node';
$bundle = 'article';
$field_name = 'field_my_field';

$info = field_info_instance($entity_type, $field_name, $bundle);
$required = (bool)$info['required'];


Perform action when new user verifies email link

I also updated the link your posted to.

If you're using the LoginToboggan module for e-mail validation and you don't wish to use the rules module you can simply mimic the module's validation response (exploiting a temporary logintoboggan_email_validated = TRUE account property that's pushed to hook_user_update) yourself in code:

 /**
 * Implement hook_user_update()
 *
 */
function yourcustommodule_user_update(&$edit, $account) {
  if (!empty($account->logintoboggan_email_validated) && !isset($account->your_custom_action)) {
        $account->your_custom_action = TRUE;

        // Do what you want here

  }
}

Since core and other modules will also invoke hook_user_update you'd want to implement something to avoid repeated actions. In this example I set another property on the $account once the action is initiated but you can impose finer control if necessary.


How can I moderate user's edits of user profile?

There is drupal module Profile2 Moderation to achieve this. It enables moderation on user profiles.

  A "quite hackish procedure"™ to enable moderation on user profiles but it works


Drupal Commerce Mirgrate product displays

When I added a product variation in code the product appeared in the list. It's required to have at least one variation to be linked for the product display to be considerd a product display.


Drupal Commerce does not provide a UI nor function for this actually. However, we can look at how the Node module does it and run the same function, just adjusted.

From node.pages.inc, there is a function to delete a specific Node revision.

But that is only for a specific revision ID. Here's an adjusted function that loads a products revisions and purges them.

/**
 * Deletes a node revision.
 *
 * @param $revision_id
 *   The revision ID to delete.
 *
 * @return bool
 *   True on success, false if not.
 */
function commerce_product_revision_delete($revision_id) {
  if ($revision = entity_load('commerce_product', NULL, array('revision_id' => $revision_id))) {
    $revision = reset($revision);
    // Prevent deleting the current revision.
    $commerce_product = commerce_product_load($revision->product_id);
    if ($revision_id == $commerce_product->revision_id) {
      return FALSE;
    }

    db_delete('commerce_product_revision')
      ->condition('product_id', $revision->product_id)
      ->condition('revision_id', $revision->revision_id)
      ->execute();
    field_attach_delete_revision('commerce_product', $revision);
    return TRUE;
  }
  return FALSE;
}

Basically the trick is ensuring you load the revision and then delete it's record and invoke field_attach_delete_revision so the old field data gets purged.

I created an issue in the queue for this: https://www.drupal.org/node/2660056


How to get statistics of (internal) referrers for landing pages?

To answer this question, there are basically 2 approaches possible, as further detailed below (you might want to combine them also ...).

Option 1: Use the Rules module

You can use the Rules module to trigger "some" Rules Actions, based on the actual value specified as your promoid. Use either of these modules to trigger Rules Events based on the 'current URL being viewed' (quotes are from their project pages):

Rules URL Argument:

  ... provides two rules conditions based on URL arguments:

  check if a URL argument is present
  compare the value of an URL argument

  It also provides an action that makes the value of an URL argument available as new variable to Rules.

Path Rules:

  ... implements Rules conditions for checking the URL against a given string for triggering actions.

What the actual Rules Actions should be, is up to your own imagination, but here are just a few possibilities (rather basic, but straight forward to implement using the Rules module):

Perform a redirect to some URL, specific to each promoid (and then you just count the hits for each of these URLs).
Send an eMail each time you have a hit, whereas the content of the eMail somehow reflects the value of your promoid, and/or you use a different eMail ID to send such eMail to, based on that value.
...

Option 2: Use a typical module about statistics

Below is a list of modules to pick from (quotes are from their project pages).

Statistics Advanced:

  Provides a few advanced options to the core Statistics module.

Visitors:

  Displays information about visitors, and integrates with the WhoIs Lookup module

Better Statistics:

  introduces a Statistics API, which allows for a way to collect, limit, and route custom access statistics and data.

Piwik Web Analytics:

  Adds the Piwik web statistics tracking system (free open source) to your website.

  Related module: Piwik Reports, which provides graphical reporting of your site's tracking data inside Drupal.

Chartbeat:

  ... to provide third party integration with Chartbeat, for real-time site monitoring statistics.

Stat Counter:

  ... provides an integration between Drupal and StatCounter web statistics.


Add percentage based fee/tax to specific product types on checkout

In the interest of anyone else who is looking for an answer to this, here is how I solved adding tax to only specific product types, based on comment #1 here: https://www.drupal.org/node/1251444

Add elements to the rule applying tax to the line item

Entity has field: Parameter: Entity: [commerce-line-item], Field: commerce_product
Data Comparison: Parameter: Data to compare: [commerce-line-item:commerce-product:type], Data value: YourProductType

Add OR/AND for more based on needs.

Hope this helps someone!


What I wanted was actually to theme the registration field directly from the module, by implementing zss_field__field_registration($variables).

So, if you have a similar problem, you need to proceed in 2 steps:

create a custom field formatter for your registration fields (described above). This will allow to display the form even when the current user has already registered.
theme the registration field from your module so as to display it according to the current user and available seats.


Auto-complete and form auto-populate from wikipedia

To create your own autocomplete callback, you can see Textfield that uses autocomplete which shows a custom autocomplete.

Since all the data is stored of site though, you can save some time and load by implementing it client, since the user must rely on javascript anyway.

Managing JavaScript in Drupal 7 shows how to add the javascript to your site.

I'm not aware of any module, or even php/js library, that does all the wikipedia integration. If you go with the PHP option, you'll probably be interested in Guzzle. When I tried last, it was complicated to integrate composer packages with Drupal 7 though, but it looks like the situation may have improved through Composer manager.


How to use glossary contextetual filter?

Solved by Adding a Attachment Display to views.


Is it possible to customize user profile URLs based on a custom profile field?

As Pathauto uses the tokens provided by the Token module, you could use the Token Profile module that implements tokens which return the value of user profile fields.


How do you add remote javascript script with custom parameters?

External javascript files can't be declared inside the theme.info file, unfortunately. Inside your template.php file, you'll have to add something like this:

<?php
  drupal_add_js('https://maps.googleapis.com/maps/api/js?key=XXX&sensor=false', 'external');


Sorry, only after I created the question it came to my mind that the UUID itself already may be present inside a config YAML. And indeed it is. Inside system.site.yml. So, I guess when it's OK to have it printed inside a config YAML – with the purpose to get version tracked – it's no problem to have it inside a text file as well.


How we can change the Select option into Autocomplete

While not a direct answer to your question, I would recommend trying the Chosen module, which integrates the jQuery Chosen plugin.  It will essentially convert most of your selects into something searchable / autocompletable, while keeping them as selects.  It works particularly well with multi-selects, and I have it working with some large vocabularies in Views exposed filters on a few sites.


There are many, many ways to do this in Drupal but I'll outline two basic approaches for D7.

First, you'll definitely have a much easier time working with .jpg than .ppt.  As Drupal is open source, it supports open file formats (jpg) much better than proprietary ones (ppt).

Warning: this is not a complete tutorial; writing one would have far too many steps and is out of scope for this site.

APPROACH 1

Views Slideshow:  This relies on the Views module.  If you're new to Drupal, you should definitely learn how to use Views first; Node One has an excellent tutorial on Views.  Using Views slideshow, you would roughly do the following:

Create a content type for your images.
Create a vocabulary Categories using the Taxonomy module and add each individual category as a term.
Create a node of content type image for each picture.
Configure Views Slideshow to show each gallery on its own page.

Why use this approach?  Each picture will be its own node.  This allows you to later add different fields to each picture such as a rating (with Fivestar) or the name of the photographer, etc.

APPROACH 2

Field Slideshow: This approach allows you to store all of the pictures for each gallery on a single node.  To do this:

Create a content type for galleries and add a field to hold the pictures.  Make sure it allows for multiple values.
Create a node of content type gallery for each category.
Configure Field Slideshow.

Why use this approach?  It is somewhat simpler to set up and requires less tinkering with Views.  However, it is less flexible.


I see two ways of doing that:

Change the "files-mode" to private via admin/settings/file-system (as googletorp stated) AND changing the filepath to somewhere outside of your webserved files.
Change the "files-mode" to private and set some rewrite rules inside your .htaccess (or elsewhere in your webserver config). this gives you more control which files you want served private and which public. Something like:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/sites/default/files/(private/.*)$
RewriteRule ^.*$ /system/files/%1 [L]

Now every request directly to the "private" files will be rewritten to the systempath which is controled by drupal. So no access without drupal is possible.


How to alter a form base on the users' request info?

You should definitely use hook_form_alter() for that - no need to go a different route, it'll just make things harder for no benefit. Doing things the standard way your code could be as simple as:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'foo_form' && isset($_GET['bar'])) {
    $form['baz']['#access'] = FALSE;
  }
}


How to make download file link to open form and mail the download link to email?

There is simple solution for this.

You need to create a form using custom module and link download file with that form. When user click on download file link, it will redirect user to form.

In the form submit, you can send mail to client with download link and admin also and can perform other task too.

If you want to expire download link after once download, you can save the counter of download in database. You need to create link for download in your custom module and in page callback of that link, you can check if its already downloaded or not.


How to set the path for the public directory?

You can maybe create a symlink of /var/www/sites/default/files to /var/www/drupal/sites/default/files. Assuming you're inside /var/www/drupal, the command to do that is:

ln -s ../sites/default/files sites/default/files

So with this in the File System configuration page, you can just use the default path "sites/default/files".

But you can also just transfer /var/www/sites/default/files into it's new and final location though just to make things cleaner and organized, if you want.

Updated

Since you have noted also that "../sites/default/files" almost worked maybe you just need to update the permissions of the folder to maybe 775 and try to clear caches.

Hope everything works for you.


How to get the URL of the entity reference node?

This is a very late answer, but hopefully it will help others looking to get the raw URLs for related content (especially if you're building a custom theme file for the view).

In the view:

Under "Relationships", add a Entity Reference: Referenced Entity relationship for the related field.
Under "Fields", add a Content: Path field
Set that field to use the relationship.
In the field settings, deselect label; under style settings, set the wrapper HTML to none.
Under "Rewrite Results", select "Rewrite the output of this field"
Use the replacement patterns to add just the [path] token. If you already have a separate Path field selected in the view, it may show up as [path_1] or a similar name.
Save & test the view.


How to make radio buttons required and have a possible default value

I'm not sure exactly why this happens; maybe FALSE is being cast to an integer in the validation, being evaluated as 0, and becoming an acceptable selection (your value for "No" being 0).

Fortunately you can use NULL instead:

'#default_value' => isset($attending) ? $attending : NULL


Change the way a node is themed based on an argument added to a URL

one solution is to use Views. Create views page, for path add node/%/argument, choose Content on Format Show and View mode you want. See Entity view mode module for ability to add more View modes per entity. Add one to Article named "Custom view" for example. Add next code in template.php (change THEME to your maschine theme name).

function THEME_preprocess_node(&$variables) {
  $variables['theme_hook_suggestions'][] = 'node__' . $variables['view_mode'];
}

Then copy node.tpl.php to node--custom-view.tpl.php in current the dir - if your already add new view mode with name "Custom view" and edit node view template as you want.

To have node--Content-Type--View-Mode.tpl.php like node--article--custom-view.tpl.php the above code must be

function THEME_preprocess_node(&$variables) {
  $variables['theme_hook_suggestions'][] = 'node__' . $variables['type'] . '__' . $variables['view_mode'];
}

EDIT:

Programmaticaly solution with code in custom module:

function HOOK_menu() {
   $items['node/%/argument'] = array(
    'page callback' => 'node_custom_view',
    'page arguments' => array(1, 2),
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );

  return $items;
}

function node_custom_view($arg1, $arg2) {
  $content = '';

  if (is_numeric($arg1) && $arg2 == 'argument') {
    $node = node_load($arg1, $vid = NULL, $reset = FALSE);
    $content = drupal_render(node_view($node, $view_mode = 'custom_view', $langcode = NULL));
  }

  return $content;
}

"custom_view" is our custom display for node created by Entity view mode module, then we enable this for content type from Manage display


How to specify the version for drush site-install

Usually I use drush dl drupal then cd into the drupal directory and then drush si [other parameters].

That means, when you download drupal core you need to specify the version at that time -- not during site installation (which is just running the files).

You can do that by appending the version onto your dl argument, for example:
drush dl drupal-6 or drush dl drupal-6.x


How I show theme selection page with thumbnails to everyone?

Go to permissions page sitename.com/admin/user/permissions

search for switch theme and apply for roles.

Switchtheme Also provides some Blocks see Block configuration page

Thats all.


How can I show a message to visitors of a blocked user account page in Panels?

You could try to use the Rules module for this, using an approach that is similar to my answer to the question "How to create a redirect to point to the user's id?", in which you use values for the_old_path and the_new_path that fit your needs here, i.e.:

Change all occurences of the_old_path to the path of the user profile.
Change all occurences of the_new_path to the path of your custom variant.
Add a Rules condition to check if the user account is blocked.
Fit the message being displayed to fit your needs. If you don't want such message to appear, then just delete the line containing drupal_message in the rule.


Have you checked the auto nodetitle module with the token Module. Then you can create the node Titles with tokens.
Check also the Automatic Entity Label i think its better for your Usecase


How to pull twitter feed in content type?

For this you have twitter block module in drupal 7 , but you want content type for this make node--twitterfeed.tpl.php  template  and put your api script like this

Tweets by @InstaSnapShop

also check https://www.drupal.org/project/twitter_block


Apply coupon from an affiliate link to ubercart

Try ECO (Extra Customization Options for Ubercart).

  ECO (Extra Customization Options for Ubercart) provides additional ("extra") options to customize Ubercart.

  Some of the functionality provided also includes a degree of integration with other contributed modules like Legal, Webform, and Ubercart Discount Coupons. Among the customization options are using URL parameters to auto-apply coupons in checkout, requiring new customers to choose a password, and integration with the Webform module to pre-populate address fields in checkout.


Something like this ought to do the trick:

$nload = node_load($requestid);
$field_collection_item = entity_create('field_collection_item', array('field_name' => 'field_request_collection'));
$field_collection_item->setHostEntity('node', $nload);
$field_collection_item->field_products[LANGUAGE_NONE][0]['target_id'] = intval($productid);
$field_collection_item->save();

$nload->field_request_collection[LANGUAGE_NONE][]['value'] = $field_collection_item->item_id;


Ubercart Marketplace vs Ubdercart Affiliate?

Ubercart Marketplace is where you want your "sellers to post their products" - more like eBay.

Whereas Ubercart Affiliate module is where "you sell your products" but affiliates help marketing those by spreading your site's links. This is much like the affiliate programs that are run by most hosting providers.

This is the primary difference. And they both plug to Ubercart. So they can leverage all UC features.

However it is possible that you use both in conjunction. Never tried that out. Would be interesting.


Display specific node type in different path

Use the pathauto module and configure it so this content type automatically gets the right path settings by default when creating a node.
https://www.drupal.org/project/pathauto


How to add a reference to a view block in a field?

Both Views and Entity Reference are now part of the Drupal 8 core.

Go to
1) structure >views and create a view of type page or block. In another   display select entity reference as display.
2) In format settings select the search fields for this view and select the fields you wish your view should display. Now save the view.
3) Go to structure > content types> Content type to which you want to add the reference field. Create and new field of type content, set the label you wish to and save and continue.
4) In type of item to reference select, "view". Save field settings.
5) In field settings, under reference type, select "Views: filter by an entity reference view". Under "View used to select the entities ", select your entity reference view and save.
6) In manage display of content type for this reference field you can select Link to entity or rendered entity. I had selected rendered entity and save the manage display settings.
7) Now create a content of your content type and in the entity reference field give the name of entity to which you want to refer to.


Fields created by a Feature generated module remains after disabling the module

Yes, this is normal. Some configuration items such as views can be implemented purely as code and some such as fields require database updates. Items in the former category will be removed when you disable a feature, those in the latter category will not. This is not necessarily a good thing but once you understand it, at least you know how to deal with it (manual removal of items).


How to use separate databases for Drupal tables?

In the settings.php file used for the site, you can specific a different prefix for each database table.

  $databases['default']['default'] = array(
    'driver' => 'mysql',
    'database' => 'databasename',
    'username' => 'username',
    'password' => 'password',
    'host' => 'localhost',
    'prefix' => array(
      'default'   => 'main_',
      'users'     => 'shared_',
      'sessions'  => 'shared_',
      'role'      => 'shared_',
      'authmap'   => 'shared_',
    ),
    'collation' => 'utf8_general_ci',
  );

You can also refer different databases, or schema, using code similar to the following one.

  $databases['default']['default'] = array(
    'driver' => 'mysql',
    'database' => 'databasename',
    'username' => 'username',
    'password' => 'password',
    'host' => 'localhost',
    'prefix' => array(
      'default'   => 'main.',
      'users'     => 'shared.',
      'sessions'  => 'shared.',
      'role'      => 'shared.',
      'authmap'   => 'shared.',
    ),
    'collation' => 'utf8_general_ci',
  );

The difference between the last snippet, and the previous one is that the last character used for the prefixes is the dot, not the underscore. That causes the database engine to select a different database/schema, instead of the currently set one.
To be clearer, in the code I shown the database engine is still MySQL running on localhost; what changes is that for the users table, Drupal will use the shared database instead of the databasename one.

As far as I know, this is valid for Drupal 7, or higher. The same trick is not reported in the comments present in the default.settings.php file that comes with Drupal 6.

Reference

The comments shown in the default.settings.php file.


administer MSSQL databases from Drupal 6

There is no support for MSSQL Server in Drupal 6, so it is higly unlikely that a module that can help you to administer your MSSQL databases exists.

You could maybe write your own, see MSSql or SQL Server Wrapper for custom module? for a possible way to connect to your database while still being able to rely on some API's provided by Drupal.


Defining the primary address of a CiviCRM contact

Webform-CiviCRM will always set the first address as "primary".

You don't need to expose the location-type field if you don't want to - you can set it on the backend form. This has the downside of forcing the location type of the primary address to change to whatever you've set the first address to.

Here is a solution that will solve your problem for both creating and updating contacts, and you don't need to resort to custom code and hooks:

Set the location-type field for both addresses to be exposed (user select)
Change both location-type webform fields to type "hidden"
Set the default value for the first one to be "home" and the other "work"

Now when the user updates their address, the location type will not be changed (your default values will be overwritten by the existing data). But when creating new addresses you'll be setting sensible defaults.


What you want to do, is to make views use your class instead of the the one solr module provides. Defining your own plugin wont help.

Instead you can use hook_views_plugins_query_alter to specify the plugin class.


Destination property uri not provided migrating uri

It turns out that the problem was that the source data from D6 doesn't have a uri field (it's filename and filepath), so just using a custom plugin to create the uri in the source row gets around it.


How to test for a boolean field in a twig template?

You want to look at the raw value, not the render array.

Example:

{% if node.field_foo is not empty %}

This checks if the field exists. The render array won't be useful beyond rendering values.

Don't look at content - that is simply the render array. Look at the fields in your entity object (node, paragraph, etc). You might want to install Twig XDebug to breakpoint your templates or inspect variables in mytheme.theme.

You should be able to look at {% if node.field_foo.value ... %} for equality checking.


Remove Administration Theme from user/%/edit

For Drupal 7 you can use Administration theme or hook_admin_paths_alter() in your custom module.

/**
 * Implements hook_admin_paths_alter().
 */
function my_module_admin_paths_alter(&$paths) {
  $paths['user/*/edit'] = FALSE;
}

For Drupal 8, see https://www.drupal.org/node/2224207.


Why does the EN version of the Main menu not appear on the EN version of my site?

I've been struggling with a similar issue in the past too. Below is how I resolved this for a multilingual site with menus in multiple languages. In this case for the "main menu", but you can do this for any menu.

Step 1

Use a single "main menu" that contains all menu items for all languages, so not 1 main menu for only EN menu items and another main menu for only FR menu items.

Step 2

Configure the multilingual options of the menu via the Menus administration page and follow the "edit menu" link to the menu in question. For the Main menu that would be admin/structure/menu/manage/main-menu/edit.

For "Translation Mode", use the option "Translate and Localize". So that
menu items with language will allow translations, and menu items without language will be localized.

Step 3

Add the links for any of your languages to the single menu, but make sure to specify for each of these links for which specific language you want the link to be shown. Or as an alternative, if you have menu items that should be shown for al languages, make sure such link is marked as "Language Neutral".

Summary

For any language the very only (single) "Main menu" is shown. However based on the selected language, only those menu items in it will be shown that match the selected language. Not sure if it is the best/most elegant way to make this work, but IMHO it works like a charm ...


Use computed fields as Apache solr facets

I think you need to store the computed field in database in order to make apache solr index it.
There is check box in computed field to save it to database: Store value in database

Just enable it and see if it works.


How to overcome error caused by non-existent service "entity.manager"?

As folks (Hudri, leymannx) alluded to in the comments, entity.manager was deprecated in Drupal 8 which means it was removed in Drupal 9. The project that has the code that's calling entity.manager is not ready for Drupal 9 (or at least the version you have installed is not ready for Drupal 9). You may want to look for alternative modules if the one your using isn't ready for Drupal 9.
This one particular error is relatively simple to fix though, you may just need to replace any references to entity.manager with references to entity_type.manager. This issue on d.o gives a good example of what you may have to do.
As @Jaypan noted in the comments, entity_type.manager may not always be the correct replacement. From the entity.manager documentation:

Use \Drupal::entityTypeManager() [i.e. entity_type.manager] instead in most cases. If the needed method is not on \Drupal\Core\Entity\EntityTypeManagerInterface, see the deprecated \Drupal\Core\Entity\EntityManager to find the correct interface or service.

Note: if this issue is being caused by a contributed package, e.g. a d.o module or theme or other package included by composer, you need to work within that project's issue queue to patch the project instead of updating the files directly in your codebase. At the very least, you'll want to create a local patch in your composer project and configure composer to apply the patch.


Use a class on a DIV on specific content with Omega

You don't mention if it's a particular node TYPE that you're after.  If it is, then please clarify that.  You also don't say what the .mask div actually contains, so I'm going to assume it contains nothing and the content is the background image.  If this is the case then you can just put

 anywhere.  The position: absolute should mean that it won't dislodge any other content anyway.

I'm also not sure why you need !important after width.  If this class is something you're declaring then it shouldn't get overriden unless YOU want it to.  If you're worried about it then I'd namespace the class instead (ie .mytheme-mask).

EDIT

Put it anywhere, but write it like this:

<?php if (!drupal_is_front_page() && !$teaser) { ?>

<?php };?>

This means that if the page is a content page (not the front page) and not a teaser then place your div in the node.


I made it by creating 'VIEWS' by selecting the facebook style micro publisher images as 'field' and filtered according to my requirement.


Include Full Taxonomy Term inside a Content Type?

The content type UI doesn't allow you to render a taxonomy term entity. So, you can solve this one of three ways.

Create all the fields in the taxonomy you need and add the term to the content type via a reference then use the custom code found here: https://stackoverflow.com/questions/12705389/displaying-content-of-term-reference-instead-of-link-drupal-7

$term = taxonomy_term_load('taxonomy_term', array($hotel["und"][0]["taxonomy_term"]->tid));
$view = taxonomy_term_view($term);
print render($view);

Note: In most cases, you will find that you actually do not need to run taxonomy_term_load since the values in the array ['taxonomy_term'] is exactly the same. Therefore you can use:

    $term = $hotel["und"][0]["taxonomy_term"];
    $view = taxonomy_term_view($term);
    print render($view);

Create a taxonomy view and use a contextual filter to limit the view to the nid from URL.
Don't use taxonomy for this. What you're trying to do is display content, not organize content. In Drupal, when you want to display content, you should use a content type. Once you have a content type, you can reference it with an entity reference and display it in a teaser format. You could then add a term reference to THAT content type to limit it by category.


How to insert checkbox value in MySQL database

'checkboxes' are array - serialize values on insert (and unserialize when get it), something as

'languages_known'=>serialize($form_state['values']['languages_known'])

edit:

full working code for example form

function mymodule_menu() {
  $items['test-form'] = array(
    'page callback' => 'drupal_get_form',
    'page arguments' => array('test_form'),
    'access callback' => TRUE,
  );

  return $items;
}

function test_form($form, &$form_state) {

  $languages_knows=array(
    'English' =>t('English'),
    'Hindi' => t('Hindi'),
    'Marathi' => t('Marathi')
  );

  $form['languages_known'] = array(
    '#title' => t('Language Spoken'),
    '#options' => $languages_knows,
    '#type' => 'checkboxes'
  );

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

  return $form;
}

function test_form_submit($form, &$form_state) {
  //Does something with successfully submited form fields.
  global $user;

  $user = db_insert('lawyer_details')
    ->fields(array(
      //'first_name' => $form_state['values']['first_name'],
      //'middle_name' => $form_state['values']['middle_name'],
      //'last_name' => $form_state['values']['last_name'],
      'languages_known'=>serialize($form_state['values']['languages_known']),
    ))->execute();
}

also you need to have install file, same as mymodule.install with table/field schema:

<?php

function mymodule_schema() {
  $schema['lawyer_details'] = array(
    'description' => 'Details comments here.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Some identifier.',
      ),
      'languages_known' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => 'Some description here.',
      ),
    ),
    'primary key' => array('id'),
  );

  return $schema;
}

then delete your table, uninstall module (uncheck, save, uninstall) and install again.

test

hint: see https://www.drupal.org/node/159605 for schema field definition


php code to load latest posts from a term

One way would be to use taxonomy_select_nodes() to build and run the query for you, it orders by n.sticky DESC, n.created DESC by default but you can change that to just n.created DESC if you need to by passing the 5th argument to the function.

It also limits the query to the number of records found in the default_nodes_main variable, which defaults to 10.

$tids = array(1); // 1 is the term id (tid)
$result = taxonomy_select_nodes($tids);

while ($row = db_fetch_object($result)) {
  $node = node_load($row->nid);

  $title = $node->title;
  // etc...
}


Using Backup and Restore to transfer drupal configurations but not actual data

For drupal 7 the best way to transfer Drupal configurations but not actual data is to use Features module.
You can create features from your staging env.
and then revert them in production.


Drupal View 3 / CiviCRM integration - block update depends on user authorization

I'm not sure if there's a way around this. Drupal will cache the output of Views to anonymous users, as it does for most pages. Drupal rarely caches content for authenticated users. On top of that, your host may be using a reverse-cache such as Varnish, since it greatly improves performance of Drupal sites for anonymous users.

A workaround could be to reduce the cache time of content. First try by changing the cache settings on the specific View, and if not, try the global setting in /admin/config/development/performance.

However, assuming that the list of contacts you are displaying is a sort of "randomly featured members" type of block, if your cache expires every 15 or 30 minutes, it's still usually pretty sufficient for that type of requirement, unless you have a really high traffic site and you must rotate faster.

If you do have a very high traffic site, I would probably load the block dynamically with Ajax to avoid killing the cache (and cache that block in a more efficient cache such as memcached, which a short expiration time of perhaps 5 minutes).


Require First and Last Name on Comments in Drupal 7

In Drupal 7, Comment fields are managed the same way Node fields are managed.

Go to structure->Content types-> edit link. If comment is enabled for selected content type, It will add a tab for "comment fields" on top besides manage fields tab.

For article content type url will be "admin/structure/types/manage/article/comment/fields" and tab looks like the image attached below.


Permission for translating menu items via the menu config screen

I found the answer. You have to have the following permissions set: translate interface  and administer menu items.


drush cron fails: Drush command terminated abnormally due to an unrecoverable error

Apparently Elysia Cron was installed and in that case you have to

drush elysia-cron

And drush cron is an alias of drush core-cron.


How to create a pie chart of user points and taxonomy terms?

There are a number of chart modules for drupal.
If you used the charts module, it has views integration, so assuming you are using the user points module, and that user points has view integration, you should be able to create a view with items grouped by term and display as a chart.
Update
Replicated your environment as above, updated the userpoints module to 7.x-1.x (dev), installed charts module (and included google charts module to test), constructed view of userpoints with contextual filter on user and the chart  works perfectly! Thanks for asking the question, I have suddenly thought of loads of places I could use similar graphic incentives.
Here is the exported view - in this example it uses taxonomy terms article, page and comments:
$view = new view();
$view->name = 'points_chart_userpoints';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'userpoints';
$view->human_name = 'points_chart_userpoints';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'userpoints table block';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'chart';
$handler->display->display_options['style_options']['library'] = '';
$handler->display->display_options['style_options']['label_field'] = 'tid';
$handler->display->display_options['style_options']['data_fields'] = array(
  'points' => 'points',
  'tid' => 'tid',
);
$handler->display->display_options['style_options']['field_colors'] = array(
  'points' => '#2f7ed8',
  'tid' => '#0d233a',
);
$handler->display->display_options['style_options']['width'] = '';
$handler->display->display_options['style_options']['height'] = '';
$handler->display->display_options['style_options']['xaxis_labels_rotation'] = '0';
$handler->display->display_options['style_options']['yaxis_labels_rotation'] = '0';
/* No results behavior: Global: Text area */
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['label'] = 'no points';
$handler->display->display_options['empty']['area']['empty'] = TRUE;
$handler->display->display_options['empty']['area']['content'] = 'no points found';
$handler->display->display_options['empty']['area']['format'] = 'filtered_html';
/* Relationship: Userpoints: User */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'userpoints';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
/* Field: Userpoints: Current points in category */
$handler->display->display_options['fields']['points']['id'] = 'points';
$handler->display->display_options['fields']['points']['table'] = 'userpoints';
$handler->display->display_options['fields']['points']['field'] = 'points';
/* Field: Userpoints: Points category */
$handler->display->display_options['fields']['tid']['id'] = 'tid';
$handler->display->display_options['fields']['tid']['table'] = 'userpoints';
$handler->display->display_options['fields']['tid']['field'] = 'tid';
/* Contextual filter: User: Uid */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'users';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['relationship'] = 'uid';
$handler->display->display_options['arguments']['uid']['default_action'] = 'default';
$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'user';
$handler->display->display_options['arguments']['uid']['default_argument_options']['user'] = FALSE;
$handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';

/* Display: Chart (block) */
$handler = $view->new_display('block', 'Chart (block)', 'block');

/* Display: Table (block) */
$handler = $view->new_display('block', 'Table (block)', 'block_1');
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
  'points' => 'points',
  'tid' => 'tid',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
  'points' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'tid' => array(
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
);
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['defaults']['row_options'] = FALSE;

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->display->display_options['path'] = 'userpoints/chart';


Form API: Persistent values across submits?

In the Form API, there are two separate value setters #default_value and #value where these two make different things happen when you using it
- #default_value set the value of your element when the form is created the first time, and if your form has an error for some reason, does not affect your element
- #value set element value every time the form is rendered, even when the form is created again because of some error

It is not correct to use #value for textfields and other input elements, use #default_value instead. #value is meant only for buttons, submits and other non input elements.
if you use $form['#value'] = 'Name' for input elements like textfield the value of that field always would be Name even if the user entered some other value for this field.

see Form API Reference


Ok, got this. As far as my field has nothing in $items, in order to print something I had to use this snippet:

function fblike_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) {
    foreach ($entities as $id => $entity) {
        if (empty($items[$id])) {
            $items[$id][0] = 'something';
        }
    }
}


$base_url and the mystery of broken feed images

Module Pathologic might help your problem, if you haven't tried that. Here is a quote about it (from the module's project page):

... is an input filter which can correct paths in links and images in your Drupal content in situations which would otherwise cause them to “break;” for example, if the URL of the site changes, or the content was moved to a different server. Pathologic can also solve the problem of missing images and broken links in your site’s RSS feeds.
Pathologic is designed to be a simple, set-it-and-forget-it utility. You don't need to enter any special “tags,” path prefixes, or other non-content noise into your content to trigger Pathologic to work; it finds paths it can manage in your content automatically.


Commerce: is there something in the basket?

This is what i use :)

function items_on_cart(){
  global $user;
  $cart = commerce_cart_order_load($user->uid);
  $line_items = count($cart->commerce_line_items) ? true : false;
  return $line_items;
}


Where are entities stored in MySQL by default?

There's no default as such; each entity type defines its base table and field data table via the *EntityType annotation. See Structure of an entity annotation for examples.

The Entity API and its power don't just live in the database, there's also plenty of code involved to prepare things sensibly for the system to use inside a request.

With that in mind, you might consider that using the built-in REST API is a more efficient way to communicate with Drupal than direct database manipulation, which won't give you the full picture of an entity without re-implementing at least some of the PHP logic in SQL


Trying to modify a menu with hook_menu_alter

Implement the hook_menu() in your custom module, then clear the cache and you will see the link in the User menu (you need place the block for the User menu in a region).

function YOUR_MODULE_NAME_menu() {
   $items = array();
   $items['/path'] = array(
   'type' => MENU_NORMAL_ITEM,
   'menu_name' => 'user-menu',
   'title' => t('Title'),
  );
  return $items;
}


How to display webform results under the webform with contextual filters?

1. create a views block display of your view

configure the view as you wish
but you have to add contextual filter by content:nid as shown below with setting: raw value from URL, path compoment 2

We have to specify validation criteria content: webform as shown below

2. add the views block in a block region

Now if you visit a webform will show under it the relevant submissions


REST API POST returning 400 Syntax error

You can use Postman to generate your code

Click here to change code language


How to call disclaimer page on all media files in Drupal?

Here is an example

bitcoin.pdf

SEE A DEMO HERE

In Drupal to use jQuery you need to wrap it in

(function ($) {

    //code goes here

})(jQuery);

so your code should look like this

(function ($) {
  $( document ).ready(function() {
    $('.test').click(function() {
        alert('your disclamer goes here');
    });
  });
})(jQuery);

PS: If your div class is outside the

bitcoin.pdf

then use it like this


How Do I improve the performance of my Drupal7 Site?

These are notes from my experiences and might vary from what others experience. I predominantly use LAMP stack and have considered the same in my suggestions.

Thumb rules for caching that I generally follow.

Process Once Use Multiple Times.
Live with stale data when possible
Clear Caches infrequently and keep it very specific.
When possible do the changes at the lowest level in the stack.
LAMP - DCCc : Linux,    Apache, Mysql, PHP, Drupal Core, Contrib and custom module.

Improve Performance of a Drupal Site (In the increasing order of complexity)

Keep the core updated, contrib module and themes updated. Yes it
matters.
Install APC on your server. (Moved to top based on suggestion from
Letharion)
Page Caching : admin/config/development/performance Difference between Minimum cache lifetime and Expiration of cached pages
Block Caching https://drupal.org/project/blockcache_alter Caching options for all the blocks.
Aggregate javascript and css files - Front End Improvements
https://www.drupal.org/project/advagg
Disable Unnecessary modules. Every module adds to the amount of code
that needs to be available for a page load. And it also increases
the number of lookups. Wherver possible use a generic module in
place of multiple module that does specific functionalities.
Cache Views content - Content aware caching for Views
https://www.drupal.org/project/views_content_cache
Disable DB logging - Use https://drupal.org/project/syslog_ng
Reduce 404 Errors -  http://www.brokenlinkcheck.com/
Fast 404 Responses  - https://drupal.org/project/fast_404 - Try
handling at server level.
Client Side Validations -
 https://www.drupal.org/project/clientside_validation
Compress Image - https://www.drupal.org/project/imageapi_optimize
Lazy Loading of Images - Don’t load unnecessary images -
https://www.drupal.org/project/lazyloader
Use Sprite Sheets - https://www.drupal.org/project/spritesheets
Set Minimum Cache Life Time Value to a higher number and use cache clearing modules to clear the caches for specific pages - Whenever I edit/update a node all the page caches for anonymous user are lost
Use Devel Module to watch queries.
Rewrite Views Queries /  avoid Views if its a overkill.
XHProf - https://www.drupal.org/project/XHProf
FPM, HHVM.
DB Profiling and Tuning - https://www.drupal.org/project/dbtuner
Use Boost, don't Bootstrap DB if not required.
 https://drupal.org/project/boost For most of the small to medium sites Boost is good enough and you may not need Reverse Proxies or so.
Use CDNs - https://www.drupal.org/project/cdn Its easy to set up.
If your cache tables are huge use Memcached - If you can install
 memcached and set up RAM for it, it is not as complex as it sounds.
Etags - Configure Etags properly.
https://developer.yahoo.com/blogs/ydnfiveblog/high-performance-sites-rule-13-configure-etags-7211.html
Use Reverse Proxy Server - Varnish(at-least for assets). Helps a lot if most of your users are anonymous.
Compressed transfer - Enable gzip compression
Keep Alive - Use Persistent Connections where possible.
Progressive JPEGS -
CACHING IN CODE - Eaton’s blog is awesome.
 http://www.lullabot.com/blog/article/beginners-guide-caching-data-drupal-7
Implement Cache Warming - https://www.drupal.org/project/cache_warmer - Cache Warm the pages before the end user hits them.
Master Slave DB Config - https://www.drupal.org/project/autoslave makes it easier for you to set up one.
Database Clusters - https://stackoverflow.com/questions/1163216/database-cluster-and-load-balancing
Load Balancers -http://en.wikipedia.org/wiki/Load_balancing_(computing)
Use heuristic Cache Warming - https://www.drupal.org/project/cache_graceful
Authenticated User Caching - https://www.drupal.org/project/authcache


Configuring drupal in a virtual directory

Running Drupal in a subdomain and changing the document root of Apache virtual server are two different things.

To change document root you would set new paths in two Apache configuration lines for the given website:

DocumentRoot /home/username/public_html
<Directory /home/username/public_html>

Change the above two records to whatever you like, for example to:

DocumentRoot /home/username/public_html/sub-directory/sub-sub-directory
<Directory /home/username/public_html/sub-directory/sub-sub-directory>

and it wouldn't matter for Drupal as long as the following directive stays same:

ServerName example.com

In other words, whatever document root you set for a website, it will be still accessible through its domain name typed in the browser's address bar, set as ServerName in Apache configuration file, and Drupal will behave accordingly.

However, if you want to just place Drupal in a sub-directory, then you do not have to meddle with Apache configuration at all.


How to add an HTML comment to the head of every page?

You're better off using a more Drupal-centric solution. If you're looking to place some static copyright info, you can create a block of HTML and place it in a footer region of your site's theme (under the block administration area).

If you're just looking to play around with the Drupal CMS & PHP coding in general (off topic for Drupal Answers), as long as you make your changes outside of the <?php ?> tags you should be fine to make changes to your template file.


Commerce- Is it possible to hide the radio button on payment select with only one payment type?

Here is a more elegant way:

function yourmodulename_form_commerce_checkout_form_review_alter(&$form, &$form_state, $form_id)
{
   $form['commerce_payment']['#access'] = FALSE;
}

I'm not confident if the payment selector might be put into another form in checkout settings. Then it might be part of the commerce_checkout_form_checkout_alter instead. Then do this:

function yourmodulename_form_commerce_checkout_form_checkout_alter(&$form, &$form_state, $form_id)
{
    $form['commerce_payment']['#access'] = FALSE;
}


Custom block doesn't work correctly when not logged in

You block is build on the first page request. The else flow is followed. Depending on you settings the page or block is cached. Logged in users don't have cached blocks.

That it worked now and then for anonymous was probably due to your cache clears.

You should create a callback using hook_menu() like

function innovista_donate_menu() {
  return array(
    'innovista/addtocart' => array(
      'title' => 'Innovisata add to cart',
      'page callback' => 'innovista_donate_add_to_cart',
      'access callback' => TRUE, // Accessible for everybody
      'type' => MENU_CALLBACK,
    ),
  );
}

function innovista_donate_add_to_cart() {
  if(isset($_GET['d'])){
    switch ($_GET['d']) {
      case 1:
        $product_id='6';
        break;
      case 2:
        $product_id='8';
        break;
    }
    commerce_cart_product_add_by_id($product_id, 1, TRUE);
    drupal_goto('checkout');
  }
}

Your block can now contain just the links. You can now disabled PHP input filter probably too.

(Note I changed your drupal_goto and removed tabs)


Are you talking about the spacing in the html itself? So the code looks visibly nested? Such as:

         something

If that's the case, you might want to try a WYSIWYG and add WYSIWYG CodeMagic


Is it safe to allow domain.com/username?

On a site that is not using a mechanism like the one implemented from the Two-factor Authentication (TFA) module, letting visitors know usernames of existing accounts is giving out half of the credentials. It doesn't mean it is easier to log in on somebody else's account, though.
Somebody who got my password for a site could probably try to use the same password for another site's account where I am using the same username. If I were using the same credentials for more sites, that could work, but somebody could argue it is my fault for using the same credentials on different sites.

On my experience on Drupal.org, the bigger issue was not the username being publicly available, but third-party software used on the server, which caused  unauthorized access to account information to emails, usernames, and hashed passwords.

That said, Drupal 8 core code is being changed to use the output of User::getDisplayName() every time links to user accounts are given in a page. User::getAccountName() should be used when displaying the name to administrator users, the user who owns the account, or for the username in the login context.
Using domain.com/username for the user account pages is going on the opposite direction. I would rather use the output of User::getDisplayName() to build the path alias of user accounts pages.

As you are asking for a Pathauto pattern, this would mean using the [user:display-name] token when creating the pattern on admin/config/search/path/patterns.

Instead of domain.com/username, I would rather use domain.com/users/username or domain.com/u/username to avoid conflict with existing routes, or other path aliases.

To make an example of what could happen, I created a test site on simplytest.me where the user #1 is set with admin as username. I installed the Pathauto module and its dependencies, and I created a pattern for user entities using [user:display-name]. The result is that the URL for the user #1 became (after I bulk-updated the path aliases) https://dqth.ply.st/admin-0. (See the -0 part added not to create conflicts between the registered route and the path alias).
This is happens when the route is already defined when the path alias is created. I cannot predict what would happen when a module using a route with a path that already exists as path alias is installed.

Also, if you look at the code of User::getDisplayName(), you will notice that by default it returns the username (the output of User::getAccountName()). It will return something different only if there is a module that implements hook_user_format_name_alter() and that module does alter the value of the $name parameter it gets.

$name = $this
  ->getAccountName() ?: \Drupal::config('user.settings')
  ->get('anonymous');
\Drupal::moduleHandler()
  ->alter('user_format_name', $name, $this);
return $name;

This means that you need to use the [user:display-name] token in the Pathauto pattern, but also install a module that implements hook_user_format_name_alter(). For example, you could use the Real Name module which adds a Real name field to user entities, containing the value Drupal 8 will use as display name. You can also implement a custom module for that.


How to send mails with mime module only for specific modules?

I installed the HTML Mail module and created a new setting with Mail >> Simplenews leaving the key blank, which works fine now!


How do I add custom order fields for users to fill out at checkout

I was able to solve this problem using Commerce Field Group.   What you do is:

create the fields you want.
create the field group.
put the new fields inside the field group.

Then

goto the Checkout Settings (admin/commerce/config/checkout) and add the group inside Review


Why doesn't "composer update drupal/drupal" work?

Edit: this is probably not helpful b/c I just re-read your statement and you didn't have the same case as mine where I was coming from an old Drupal 8 install but I will leave this up in case anyone else has this issue and try to see if I can find the specific issue you are having. Sorry.

I had this issue when dealing with a recent update and this was my issue but YMMV so if it doesn't work just let me know.

This may be a problem of that you composer file is set to the old repository listing on composer.org. Recently, Drupal setup their own composer endpoints, one for Drupal 7 and another for Drupal 8. You can read more about that change here: https://www.drupal.org/docs/develop/using-composer/using-composer-to-install-drupal-packages-through-drupalorg

This is the command that needs to be ran to swap the repository over the Drupal.org's.

$ composer config repositories.0
$ composer https://packages.drupal.org/8


Drupal 7 - Array to string conversion in DatabaseStatementBase

Webchick's Quick-and-dirty debugging is so useful in this type of situation that I've sometimes had a projects with it as a ready to apply patch.

Find drupal_set_message()

function drupal_set_message($message = NULL, $type = 'status') {

in bootstrap.inc, and add

// DEBUG: Go track down that stinkin' error...
if ($type == 'error') {
  $message .= '<pre>'. print_r(debug_backtrace(), 1) .'</pre>';
}
// END DEBUG

at the very top. This will give you a backtrace on the error, helping you to trace down it's source. It could be good to know that there are instances where this runs PHP out of memory, if you have a lot of errors, so you may need to add extra conditionals in there at times.


drupal 6: passing multiple arguments to a view using code

the array must be array in "execute" then this array in array - in "preview", e.g

$args = array($arg1, $arg2, $arg3);
$view2->execute('block_1', $args);
print  $view2->preview('block_1', array($args));


I used the query generated by the drupal page and generated JSON programmatically.


Autoload files by patterns instead of listing each file

You can potentially use hook_registry_files_alter along with the PHP directory functions.  Something like

function foo_registry_files_alter (&$files, $modules)
{
  $include_path = drupal_get_path('module', 'foo') . '/includes';

  if ($handle = opendir($include_path)) {
    while (($entry = readdir($handle)) !== FALSE) {
      if (preg_match('/\.php$/', $entry) === 1) {
        $files[$library_path . $entry] = array(
          'module' => 'foo',
          'weight' => 0,
        );
      }
    }
  }
}

This is untested, but the idea is to use scan an "include" directory for PHP files, and then tack them onto the array that the class registry uses for the autoloader.  This should work, but I can't remember exactly what readdir() returns, so you may need to adjust the paths a bit.


How to get Drush in my path in Windows 10?

The variable will be "Path". Just select that one and edit it then add new line.

You have to download the drush.phar file from here: https://github.com/drush-ops/drush-launcher/releases/tag/0.6.0

Then you have to change the file name from 'drush.phar' to just 'drush' and put that file somewhere and that location needs to be in your path. I put mine in both my system path and user path. Once that is done you shoud be able to call drush from your drupal directory if it was installed with composer.


Readme says

1) Assure that you are using Views 3.x. http://drupal.org/project/views

2) Upload/install the Libraries API module. http://drupal.org/project/libraries

3) Upload/install the ctools library. http://drupal.org/project/ctools

4) Create a sites/all/libraries directory on your server.

5) Create a directory within sites/all/libraries named jquery.cycle.

6) Locate/download the jQuery cycle plugin. http://malsup.com/jquery/cycle

7) Upload/install the jQuery cycle plugin: place it inside the jquery.cycle
   directory.
8) Enable the Views slideshow and Views Slideshow: Cycle modules

9) You should now see the new views style option called "Slideshow"

You need to install cycle plugin not cycle 2. Try installing using cycle plugin and follow above instructions.

There is a sandbox module available if you want to use Cycle 2 plugin.

You can download using git commands.

git clone --branch master http://git.drupal.org/sandbox/BenYoung/1832338.git views_slideshow__cycle2

cd views_slideshow__cycle2

Follow the installations instruction in project page for the same.


Understanding Drupal's session management and user authentication

Drupal supports external authentication. There are many alternatives authentication modules for Drupal, such as OpenID (included in core), OAuth Connector, or LDAP. Learn more about how Drupal authentication works; the best would be to look at the OpenID and OAuth modules, and to the core login form submit callback. But, AFAIK, they always start the normal Drupal session after a successful authentication.

For session management, Drupal plugs into PHP session handling and register it own handlers. The Drupal session backend is itself pluggable, you can set the session_inc variable to the path of a file providing alternative implementations of the functions found in includes/session.inc. The memcache module use this to store session in memcached.

For references, the OpenID module handle successful authentication in openid_authentication() which itself ceats and call the user login form submit handler (ie. user_login_submit()). This submit handler itself is simple, it loads the successfully authenticated user with user_load() into the global $user variable, it then call user_login_finalize() which handle session, login timestamp in the user table and invoke hook_user_login() implementations.

Another option is the use the user_external_login_register() function. The function will log an external user in. It also creates a local user if needed. If you need more control on local user creation, you can always use user_save(), user_set_authmaps(),  user_login_submit() and user_external_load() from you custom call, using user_external_login_register() as template of what needs to be done.


Update module with Drush + commit with Git

git add -A is the simple answer you are looking for.  It will add all of the files anywhere inside the current working directory, including any new files that were provided or removed pm-updatecode.  (Note: git add . behaves similarly to git add -A, except that it will not include removed files in the commit.)

There is one inconvenience with git add -A, though, and that is that if you have any stray files in the way, they will be added to the repository as well (obviously enough).  You can get around this problem by listing the files that should never be committed in a .gitignore file, or simply use git reset HEAD unwantedfile prior to git commit, as recommended by git status.

drush will manage this for you with the --version-control=svn option, but as you may surmise, this is only useful when you project is checked in to svn.  As of yet, no one has written --version-control=git.  This was discussed in http://drupal.org/node/797190, but closed "won't implement".  There are some other good git commands to try in that thread as well.


Migrate to commerce. ;)

I think you'll have to do this the old manual way.

Create your own entity with an image field to store the data.
Hook_form_alter the relevant form to insert your own widget.
Handle form submission, and push the data to it's relevant entity, then hand over form submission to the original handler.


How to change the page path being reported to Google Analytics as a pageview

In the Google Analytics configuration (admin/config/system/google-analytics) under the collapsed fieldset "Advanced" > "Custom JavaScript code" there is a field "Code snippet (before)" where you can add javascript (pure, no jQuery).

In this case I added the following:

if(window.location.pathname === '/pagename') {
  if(window.location.hash) {
    ga('set', 'page', '/pagename/' + window.location.hash.substr(1));
  }
}

Essentially any Google Analytics variable can be pre-set or changed before the pageview fires.


Not really, and there is no need for it

If you need form available from code, Form API forms are not that hard to write from scratch. Contrary to Views, you can only theme Webforms bu their node ID, and that would change from site to site, so Webform forms bundled with module will not be convenient.

If you want to bundle forms with your modules, and for any reason you can't use Form API, UUID Features Integration and Webform share provide ways to do it. It will not be a code in pure sense, but it should work.

It's relatively easy to use hook_form_alter to obtain Form API representation of particular webform. Of course, you won't be able to change it easily in future, but again, contrary to views, it is good. Module is not hurt if some data is not displayed. Data not provided, or provided in a way module does not expect, may break things. So if module needs a form, it should not be easy to edit. Edits to form would require edits to module's code anyway, so Form API code makes things easier, not harder in the long run, in such situations.


How to suppress print in only in front page via twig

You can have as many differen view modes as you want, both the frontpage and the term pages by default are views, so they are easy to customize.

So create a new one under Admin > Structure > Display modes, then enable it for that node type and configure the fields as you want. Then change one of the views to use that view mode.

Another option would be logic in process, but then you need to add the right cache context.

Or you just hide that field with CSS.


How to map Address field module sub fields (City, State, etc.) to specific (individual) fields in Salesforce?

We can resolve this by using typed_data module. https://www.drupal.org/project/typed_data
This is a required module for Salesforce Suite installation.

In the Field Type select Properties,Extended
then select the name of the field associated the Address field Module corresponding to the Salesforce field.


Use swipe to switch blocks for mobile screen

Work with a views - slideshow, like owl or slick, where you show these blocks using views_block_area.

Show this view by css-media-queries, in which you hide the normal content ..
like:

.my-view {display: block;}
.my-block {display: none;}
@media(min-width:34em){}
@media(min-width:48em){
  .my-view {display: none;}
  .my-block {display: block;}
}
@media(min-width:62em){}
@media(min-width:75em){}

more info on the web or here https://stackoverflow.com/questions/18424798/twitter-bootstrap-3-how-to-use-media-queries


What hook gets called at the formation of a form? (hook_form_alter called for adjusting a form)

There's this brilliant image on the Form API Internal Workflow in drupal.org, you can see the build process and structure. You've got callbacks such as #process and #after_build that could be useful for your use case.


How to set width to Media entity image in CKEditor

I found solution for my self.

Move to /admin/config/content/embed/button/manage/media_browser
Check to Thumbnail in Allowed Entity Embed Display plugins section.
In node editing select 'Display as Thumbnail' and you could select Image style.


Can I specify 'greater than' with db_delete()?

You can see document Conditional clauses for 7 (need update document) or you can see the documentation for QueryInterface, in particular for QueryInterface::condition().

  @param $operator  Possible values: - '=', '<>', '>', '>=', '<', '<=',

  'STARTS_WITH', 'CONTAINS',
  'ENDS_WITH': These operators expect $value to be a literal of the same type as the column.
  'IN', 'NOT IN': These operators expect $value to be an array of literals of the same type as the column.
  'BETWEEN': This operator expects $value to be an array of two literals  of the same type as the column.

. In your case you can use:

$salary = 45;
$num_deleted = db_delete('test_table')
  ->condition('salary', $salary, '>=')
  ->execute();


Try the Arrange Fields module.

  This module lets you drag-and-drop the fields of any CCK content type, Webform, or almost any other form in Drupal into the positions you would like for editing. This makes it super simple to have forms with inline fields, which you can change at any point.


How to generate iframe from Drupal 7 view (custom blog) with security token?

If you add ?entity_iframe to the url it will trigger the iframe theme. Entity iframe resize has examples of how to do cross domain communications (assuming sub-domains) securely and with less complexity then the provider / consumer handshake via the PostMessage capability built into browsers (http://caniuse.com/#search=postmessage)


how to create tabbed blocks for recent comment and recent content?

Use the quicktabs module:

http://drupal.org/project/quicktabs

Install it normally, and then 'add quicktabs instance'. In the interface, select the two views you have that you want to display and add them to each of the tabs. Your new block will show up in the block menu to be placed using the blocks menu or other layout solution.


Got something closely related to your case and I won't say this is not possible, you can have some workaround by following these threads:

Login to Drupal using LinkedIn

This feature is not available right now, to login into Linkedin while using its credential on your site. But it seems that, this thread is in knowledge of Linkedin Officials as well and there may be some work is going on to provide you create app feature just like Facebook.

Here is something to elaborate the same:

http://developer.linkedin.com/forum/how-create-linkedin-application-tripit-or-slideshare


Weird problem in calculating sum of two computed field values as another sum

I think this suggestion works

Go to the computed filed settings of G. Uncheck "Store value in the database" option might solves your problem. (If not necessary to store)


Module to suggest node revision to node author

check out revisioning. It seems more like it's set up for moderators to view revisions before approving content, but perhaps it can be used for what you need.


How to implement a reputation based system with badges in Drupal similar to StackExchange sites?

There's the User Points module and the User Badges module, though the 7.x version of User Badges is not suitable for production yet (as of June 4, 2012).

Thankfully, User Points integrates with the Rules module, which allows you to greatly customize the ways users gain (or possibly lose) points.

There's also a collection of contributed modules for userpoints of varying stability.  You can certainly set up some amazing stuff with these modules, but make sure to carefully test your implementation-- though the modules are well written and fairly stable, there's still a lot that can go wrong so make sure to verify everything works properly.


Different Feeds Tamper per destination in mapping

First thing this morning, I realized what Map to multiple fields using 'Blank source' in the documentation means.  I was able to have Task Code as my source for GUID, then Blank Source 1 as my source for Task Code.

In the tamper for Blank Source 1 I use Copy Source Value before doing my other transform:


Display message instead of redirecting to Access Denied page

1st attempt

Maybe the Disable Messages module can help here? Here is an excerpt from its project page:

  Gives a site owner options to disable specific messages shown to end users. The core drupal message system as offered by drupal_set_message is an excellent way for modules to send out messages to the end users. However not all drupal site owners are keen to show all the messages sent out by drupal core and all modules to their users. This module gives site administrators a reasonably powerful way to filter out messages shown to the end users.

Some of its features which might help in this specific case:

  Filter out messages that match a full text string exactly.
  Filter out messages that match a regular expression.
  Apply filtering only for specific paths.

2nd attempt

If the 1st attempt doesn't help, then you may want to try to expand the rule you already seem to have (as per your "I have set a rule for mailing purpose on the same event"). I.e by adding a rules action to flag the user (using the Flag module, with a flag you only use to indicate your scenario just happened to that user (let's say you label it "TimeOut").

Together with this, create an additional rule like so:

Rules Event: Drupal is initializing
Rules Conditions:

Current path matches your "no access" path (whatever that is in your case).
User is flagged with the "TimeOut"

Rules Actions:

Remove the "timeOut" flag (=unflag) for the current user.
Set your message.
Perform a redirect to a path that fits your needs.


Alter a form in a block only if it is in a certain region

use this code in hook_form_alter:

function cmfzen_form_alter(&$form, &$form_state, $form_id) {
    switch($form_id){
         case 'views_exposed_form':
         $region = 'NAME_OF_A_REGION';
         $blocks = block_list($region);
         kpr($blocks);
         //if the block is in the $blocks array do the changes.
         break;
    }
}

using block_list($region) you will get the blocks that are placed in a specific region, and it returns array of block objects (for more detail visit this page). Now check if the block you are looking for is in the $blocks array.


I have resolved the issue like adding a submit handler function when click on continue button click. Code is provided below

your-module_form_alter(&$form, $form_state, $form_id) {
   global $user;
   if(!$user->name){
      $form['account']['login']['mail']['#required'] = 0;
      $form['account']['login']['mail']['#prefix'] = '
';
      $form['account']['login']['mail']['#suffix'] = '
';
      array_unshift($form['buttons']['continue']['#validate'], 'your-module_submit_handler');
    }
}

your-module_submit_handler(&$form, &$form_state){
    $form_state['values']['account']['login']['mail'] = $form['customer_profile_shipping']['field_email']['und'][0]['value']['#value'];
}


Should I use Drush or Drupal Console with a new site?

You should use Drush.
Drush is about to be added to the drupal/recommended-project, see #3159647, while Drupal Console seems to be abandoned and currently is incompatible with Drupal 9 due to mismatched dependencies, see #4251.
Maybe Drupal Console finally accomplished its mission by triggering the modernisation of Drush. And there's no need for two CLIs. Now forces can be joined again.


You'll find the configuration files of the user picture field in the standard profile. You can export the complete config, add the yaml files of the field and reimport again.

Or if you want to import the field in UI, go to admin/config/development/configuration/single/import, select the configuration type Field storage and import the content of

core/profiles/standard/config/install/field.storage.user.user_picture.yml

The same for the configuration type Field and the content of

core/profiles/standard/config/install/field.field.user.user.user_picture.yml.


This should work for you:

    $replacements[$original] = url('user/login', array(
      'query' => array('edit' => array('name' => $account->mail)),
      'absolute' => TRUE,
    ));

Sidenote: you are naming the argument as name but you are passing the mail.


How to alter the "Request new password" form validation

Nothing special about this form, you can alter it just like any other:

function MYMODULE_form_user_pass_alter(&$form, &$form_state) {
  $form['#validate'][] = 'MYMODULE_user_pass_validate';
}

function MYMODULE_user_pass_validate(&$form, &$form_state) {
  // Your code here
}

Works perfectly fine.


The problem is in this:

  $page->arguments = array(
    // Array key must be unique.
    'node' => array(
      'id' => 1,
      'identifier' => 'Node: ID',
      'name' => 'entity_id:node',
      'settings' => array(),
    ),
  );

I found workoroud for this problem. Create custom load hook that will be the similar to node or some else you need. Like this:

/**
 * Duplicates node load callback because panels can't have two same entities arguments.
 */
function mymodule_custom_load($nid) {
  return node_load($nid);
}

So to solve tis, you need to use %mymodule_custom instead of %node.
Hope this will help somebody, because I search the answer for very long time.


A webform is simply a node so the rough process of doing this would be to node_load() your particular node, add your components array to the $node->components[] array and then execute a node_save(). There is some documentation here that fleshes out how to programmatically add a webform, your code would look something like this:

$node = node_load(YOUR NODE ID);
$components = $components = array(); #YOUR COMPONENTS ARRAY
$node->webform = array(
      'components' => $components,
);
node_save($node);


How to list all fields of a content type with views?

According to me the best way to configure a view is to use display modes ("Show: content" and select the display mode).
So that when I add a field to a content type I just have to configure the "Manage Display" sections (1 per view mode) of the content type.

Note that sometimes I need extra fields to render, to use as token for other settings (rewrite a field, header/footer text, more link,...) or to make grouping. To achieve this I switch the "Show" option to fields and add a "Content: Rendered Node" field (that comes with Entity API module). Then the "Show complete entity" display option of this field allows you to choose a display mode (Full content, teaser, list item or any other display mode) and render the nodes.


Button to selectively include content in an RSS feed

Well, you can just add a field to the content type(s) you are collecting with your view and use that to filter the rss feed. You could easily add a "include in rss" checkbox for example with whatever default value you like.


No, it will not serve for the purpose you have in mind. It checks the currently logged-in user has view access to the node, which means that if the currently logged-in user is the user #1, it will see every node, including the ones that aren't published, and independently from the content type.

As @Neograph734 says, you should not use that tag to filter out nodes basing on their content type. If you want to filter the result by content type, you should use a line like $query->condition('type', 'article'); to built the query.


How to create a "Link posting" system in Drupal 7

Basically, you need a couple of modules to do that. You already mentioned Views to create the list of links.

To set up your content type, you will need the Link module which provides a link field. You can configure it to display two fields, for link title ("My cool site") and link url ("http://www.example.com"). I think that new content types contain a body text field by default, but you can remove that.

I also recommend Automatic Nodetitles in your case. In Drupal, a node is required to have a title, but you probably do not want to expose a title field to the user because the link field already contains a link title. Automatic Nodetitles allows you to hide the title field and populate it with another value, for instance the link title, the link url or even a combination of those two.

I hope that helps - if not, please clarify your question.


You can try the following.

Add in your JS file:

$(document).ajaxStart(function(){
  $('#ajax_loading').show();
});

$(document).ajaxStop(function() {
  $('#ajax_loading').hide();
});

Add the HTML in your page:

<div id="ajax_loading" style="display:none">

Add in your CSS file:

#ajax_loading {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
}


Sidebar Menu like on Myspace (for each profile)

You might start with the Author Pane module:

  Author Pane is a block of information about a given user, like those
  typically found on a forum post, but can be used in other places as
  well. From core, it collects the user picture, name, join date, online
  status, contact link, and profile information. In addition, any module
  or theme can feed it more information via the preprocess system. All
  of this information is then gathered and displayed using a template
  file.


How to create a custom template for entities?

You don't need to add entity string to the template file name. These are theme hook suggestions for entity built with ECK (assuming your entity and bundle names):

section.tpl.php
section--masthead.tpl.php
section--masthead--full.tpl.php
section--[ID].tpl.php

As you can see there is a naming conflict because section is a drupal builtin template. It would be safer to use different name for your entity.