Drupal has only a very course access control structure for viewing content.  For the authenticated user role, you can set permission to 'view published content' (Drupal 7), but that's about it.   With that permission set the user will be able to view all the published nodes created in the site till date, without it, no content except own content will be visible.

Since the core's built-in support for node access control is rather course,  to control access to view a node, you must use some sort of node access control module.  There is a page at Drupal.org listing all node access modules, with a capsule review of each.  I suggest you take a look at that page to see if you can find a suitable module to control access.

One particular module, named Flexi access, allows you to create access control lists that explicitly contols the published nodes viewable by each logged in user.  This gives you fine grained node access control, but it may also be cumbersome to maintain such lists with a large number of users and nodes.

If you can live with a less fine grained resolution (role) there is the Content Access module.  While still only in beta for Drupal 7, I regard it as stable for role based node access control.  However do not use it for lower resolution (user based) access control, as this mode is not yet stable.

Finally, for more complex access control relationships, there is Organic Groups.  This is large. powerful and fairly complex project, but well suited for complex and entangled access control.

Disclosure: I am the maintainer of Flexi access.


The problem is, that the cache tag block_content:[id] does not bubble up and the tag is missing in the cache entry. Without this cache tag the cache entry can't be invalidated when saving a modified custom block.

Here are two workarounds:

Twig template (Workaround 1)

If you theme a block template and you render single fields

{{ content.field_field1 }}
{{ content.field_field2 }}

then you also need to render the rest of content:

{{ content|without('field_field1', 'field_field2') }}

That's because content contains the cache tag of the block content entity, which otherwise won't bubble up.

Preprocess (Workaround 2)

As an alternative option for rendering {{ content }} you can add the cache tag at the top of variables in preprocess.

mytheme.theme

function mytheme_preprocess_block(&$variables) {
  if ($variables['base_plugin_id'] == 'block_content') {
    $renderer = \Drupal::service('renderer');
    $renderer->addCacheableDependency($variables, $variables['content']['#block_content']);
  }
}

Then you no longer depend on the twig template to render all of content.

You'll find in Drupal\block\BlockViewBuilder::preRender() more workarounds for issues with bubbling up data from the content render array. You could use this code, which there is only applied in special circumstances, for all cache data from block content to bubble up to the top level:

use Drupal\Core\Cache\CacheableMetadata;

function mytheme_preprocess_block(&$variables) {
  $content = $variables['content'];
  CacheableMetadata::createFromRenderArray($variables)
          ->merge(CacheableMetadata::createFromRenderArray($content))
          ->applyTo($variables);
}

But I don't know which side effects that would have in other places. If it would be that easy the block view builder would do this already. So it's better to tackle only that specific problem with the one missing tag and use the first version of the preprocess function.


D6 - Rule to simply redirect path to login

One easy option is to set the 403 Access Denied page at:

admin/config/system/site-information

to:

user

That way, if the user is not authenticated, they can login and view the node/add page.

I think the reason your Rule isn't working is because /node/add isn't an "alias" per se, but a system path.

Another option is something like

/**
 * Implements hook_init
 */
function MODULENAME_init(){
  if($_GET['q'] == 'node/add' && !user_is_logged_in()){
    drupal_goto('user/login');
  }
}


Are you operating on the user account object?

If so, it should be:

$variables['account']['user']->created;

Which would be used at the template_preprocess function level. From the actual template itself, unless you have intimate knowledge of what was passed to $variables, you will sit there and guess all day long and not get far. Even I am guessing. The only way to know exactly what you have to work with is by using a real debugger.

The best option is implementing a debugger like xdebug so you can get a better idea of whats going on.

Atom has a package: https://atom.io/packages/php-debug
PHPStorm is
simple to setup: https://www.youtube.com/watch?v=jkv0dzW3IM4

It will save a lot of time if you leverage it over devel. You can then set a breakpoint in your template_preprocess function in template.php, inspect all the variables being passed to that appropriate template, and print or modify as you need.


Is it possible to style a Views 'group by' field that's excluded from display?

Under the advanced tab you can see what templates you need to override the views template. Copy the templates mentioned from the modules/views/themes folder to you own theme/templates folder, rename them as the view suggests under advanced and style your output.

note: if you display a teaser or full node, but forced it to use fields, the styling (making it h3) won't work.

The h3 is coded in views-view-unformatted-list.tpl.php. The $title there is output of the field you grouped by. There you can set it to h2.

UPDATE:
This is the default views template for outputting lists (the container which contains all rows as a group). This one is named views-view-unformatted.tpl.php, you need to rename it to match with your view.

 <?php

/**
 * @file
 * Default simple view template to display a list of rows.
 *
 * @ingroup views_templates
 */
?>
<?php if (!empty($title)): ?>

<?php print $title; ?>
 // THIS IS THE GROUPNAME
<?php endif; ?>
<?php foreach ($rows as $id => $row): ?> // THESE ARE THE ROWS INSIDE THE GROUP
  <div<?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"';  } ?>>
    <?php print $row; ?>

<?php endforeach; ?>

If you want to put style on ALL the rows inside the group then you can use the view-ui itself, or use the template called views-view-fields.tpl.php to override all rows.

If you want to style ONE specific row use views-view-field.tpl.php (note there is no 's' behind field).


How to add behavior-based onclick to ajax-enabled Form API button?

Form API #ajax effectively disables behaviors on elements. I can't see this documented, but that's how it works, consistently. So the solution was to change the line:

$('#edit-categories-update', context).on('click', function(){

and make it

$('#edit-categories-update').ajaxSuccess(function() {

That way code was not executed on click, but after processing of AJAX triggered by the button succeeded. It's not useful if you want to perform JavaScript before AJAX call, but if you need it to happen after, or if you don't care, it is a sufficient solution. If you need things to happen before AJAX call, use this instead:

$('#edit-categories-update').ajaxStart(function() {


My website's http header has weird information

It means you have no additional caching mechanism and the default Drupal caching will be used, several of my sites also return this header without any problem.

On other sites I use different mechanisms to control the caches, Memcache or Redis in addition with Authcache gives you quite a lot of additional control over the caches, but you'll need access to additional resources on the server.

Another aspect I've heard about is Varnish but I have no knowledge of using this myself.


Writing a news ticker module. It works, but it's sloppy as hell. Is there a better way to do this query?

Two things jump out at me, both related to the use of {url_alias}:

I don't see why you need to do the string shenanigans in the WHERE.  You should be able to to use node.type to limit yourself to the subset of nodes you want, especially if you are primarily using Pathauto settings.
I don't see why you explicitly need to return url_alias.dst in the result set. If you have the nid, then you can just use $path = url('node/' . $nid); to build up paths (or use l()).

I think this means that you should be able to eliminate the JOIN on the {url_alias} altogether, which should make the query much faster.


Redirect if nothing is select in the View's jump menu

Using hook_form_alter you override the default $options value used in ctools_jump_menu for the array key _none to whatever site url you want to redirect to.


How to move drupal site from remote server to localhost?

I am not sure your site has SSH access and you can access it, but certainly you have FTP access to your site.
Suppose your drupal directory is /public_html/mydrupalsite/; with FTP managers like FileZilla or CuteFtp access your site. Download all the files that are in the mydrupalsite directory, then  go to phpmyadmin on your site, and select your database; open the export tab, and export your database without changing any setting.
Install PHP, Apache, and MySQL server on your computer, copy the files to the directory that can run in your local host, create a new database, import the  database, and change the parameters in the settings.php file.


How to add link to Comment Author's User Profile page

Comment module does add a link to comment author name on comments view. The link is conditionally visible to user's i.e. If user has permission to "View user profiles" or administrative permission then he will be able to see author name as link, else plain text. See screenshots below (tested with Anonymous user with and without permission "View User Profiles"):

Permissions:

Comment preview with permission:

Comment preview without permission:

You can still add a link to author name by your own, by implementing template_preprocess_comment() function in your theme's template.php or .module file. This might lead to access denied page:

/**
 * Process variables for comment.tpl.php.
 *
 * @see comment.tpl.php
 */
function [THEME_NAME]_preprocess_comment(&$variables) {
  if (!empty($variables['elements']['#comment']->uid)) {
    $variables['comment_author'] = l($variables['elements']['#comment']->name, 'user/1/' . $variables['elements']['#comment']->uid);
  }
  else {
    $variables['comment_author'] = t('Anonymous');
  }
}

And then printing "$comment_author" variable in comment.tpl.php file, see below.

<p class="commenter-name">
  <?php print $comment_author; ?>
</p>


Create a view of the first entityreferenced child item from a multifield for a list of parent nodes

We usually name the referencing nodes Children, and referenced nodes Parents (Children reference Parents), so I'll assume it applies here that you want to show the first Parent in a multivalue ER field.
You need to create a list of type A nodes in a Block Display, add the ER field and select to show only the one, first value under Multivalue settings for the field.
This will give you a list of A-type nodes that shows only the first B reference.
Now we need to filter out only the A node that we're currently viewing. This can be done through the ID Contextual filter (under Advanced View settings), configure it:
When the filter value is NOT available
Provide default value
Content ID from URL
When the filter value IS in the URL or a default is provided
Specify validation criteria
Validator: Content
Content type A
Set the option for the case when the argument doesn't validate, and all the other options, to something that makes sense to you.
When you add the Contextual filter, depending on what option you chose for when the argument doesn't validate, you may see no results any more. To bypass the Contextual filter enter all into the Preview field (unless you change that default).
You can test the Contextual filter with Views Preview. Enter the node ID of the A node into the Preview field. You should see only the one result in Views, the result relating to the A node with the ID you entered.
If you're seeing expected results save the Views and place the Block into a theme region, but don't forget to set the Context option on Block configuration too.


If I delete enabled module files will items be stuck in the database forever?

In order to get rid of module's database tables and other contents, you must first disable the module, and then uninstall it.  Deleting a module without disabling it is "against the rules", as module_exists('foo') will still return 'true' for these enabled-but-removed modules.  Since Drupal tends to call modules only via code that uses the php function function_exists to determine if hooks are available, you usually won't experience any obvious problems if you do this.  However, things could get weird if you had a situation where module B uses module_exists() on one of these modules that you removed.  The code in question could make assumptions that are only true when the hooks you deleted are executed, which could cause unpredictable behavior.  So, in short, don't do that -- always disable and uninstall your modules if you no longer need them.


How to save content created by selected roles in an external database?

Yes you can do that.

There are two method for configuring external database.

Inside settings.php
Inside Module directly.

1. Inside settings.php

$databases = array();
$databases['default']['default'] = array(
  // Drupal's default credentials here.
  // This is where the Drupal core will store its data.
);
$databases['my_other_db']['default'] = array(
  // Your secondary database's credentials here.
  // You will be able to explicitly connect to this database from your modules.
);

In your module:

// Use the secondary database we set up earlier
db_set_active('my_other_db');

// Run some queries, process some data
// ...

// Go back to the default database,
db_set_active();

2. Inside Module directly.

If your module will be alone in using the secondary database you can define the connection directly in your module:

  $other_database = array(
      'database' => 'databasename',
      'username' => 'username', // assuming this is necessary
      'password' => 'password', // assuming this is necessary
      'host' => 'localhost', // assumes localhost
      'driver' => 'mysql', // replace with your database driver
  );
  // replace 'YourDatabaseKey' with something that's unique to your module
  Database::addConnectionInfo('YourDatabaseKey', 'default', $other_database);
  db_set_active('YourDatabaseKey');

  // execute queries here

  db_set_active(); // without the paramater means set back to the default for the site
  drupal_set_message(t('The queries have been made.'));

Refer https://www.drupal.org/docs/7/creating-custom-modules/howtos/how-to-connect-to-multiple-databases-within-drupal


Permissions deselected, but user can still edit content

You need disabled option "view, edit, delete any content". If this option is checked, next options not used.


Disable delete button on a view under certain conditions

You need hook form alter: https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_form_alter/7

You first have to inspect element of the form and get the Form ID. Then use the following to unset the submit button. You will have to print_r() or use devel to output the $form array to find the submit button to unset.

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

if ($form_id == 'myformid') {
  unset($form[submit button])
}

}


How can i render webform on custom url with custom html in drupal 8

This should work if you return $webform; without rendering. Or use the webform render element, then you don't need to load the form:

return [
  'test1' => ['#markup' => '

test1

'],
  'form' => [
    '#type' => 'webform',
    '#webform' => 'webform_id',
  ],
  'test2' => ['#markup' => '

test2

'],
];


What we ended up using was an existing module that we have already installed (Context) along with a custom block.

We created a new context for hidden sections of our site using the condition of the request path and the user role anonymous. From there our two reactions were to hide all sections within our theme except ones for help messages to our users, and to add a custom block to that help section.

Works like a charm and is fairly straightforward to change and keep track of in config.


URLs with trailing slash say site in maintainence mode, others don't, site isn't in maintenance mode

Have you already cleared the cache? Maybe it's just that
Try putting this code $conf['site_offline'] = 0; into settings.php to see what happens :)


Different currency per-product in Ubercart

There isn't really a good way of dealing with this. One thing you need to figure out is what to do if you have multiple currency in the cart, since ubercart, payment methods etc can't handle this.

If you want an alternative currency for some products, one way of doing that would be to add some options CCK fields which holds the price and currency. Then you could hook_currency_handler_alter and hook_currency_handler_format to handle how the price should be displayed.

This is no easy task and you need to alter a lot of things to make sure the proper context is available to be able to load the node and figure out how the price should be displayed.

In other words, it's a real pain in ubercart and there isn't a good way of doing this really. The above is probably the best solution though.


Have you tried using taxonomy_get_children()?

  Finds all children of a term ID.


Drupal Commerce: Add content nodes to checkout steps

It is! With the module commerce_extra_panes you can add nodes (content) to the checkout.


How to display a view without using a page template - drupal 7

You can create a block view and display it anywhere in the code.

If your text format allow you to use PHP code you can insert a views anywhere in your website by adding something like this.

  <?php
    $block1 = "Name_Of_The_View";
    print views_embed_view($block1);
  ?>

And this will print a view inside of a node without using a page template. The beauty about this is that you can add HTML around this without using the block module.

For more information I will recommend you to read this documentation page Placing the contents of a block in any location


Hook_view_pre_render(&$view) to alter field_title link locations

You don't specify what type of changes you want to make, but in general, yes, hook_views_pre_render is a good place to change the way the View looks when actually rendered.

You will find the hits from views in $view->results, and that is where you will want to make changes.

Note though that you may not even need the hook, you can use replacement patterns, as in this answer to accomplish many simple, and some advanced, changes to fields.


As anschauung mentioned you can use Boost to create a static page cache. Boost will copy the entire HTML of a page and store that HTML as a static file on the disk in a specific directory. A set of rewrite rules will cause the webserver to first look for a static HTML file for each request and serve that file if it's found. If it isn't, a normal Drupal request occurs via PHP. Requests served through the static file will be really fast, but PHP and the database are completely bypassed.

Boost is not a replacement for the cache backend and that Drupal will still use the cache tables in the database when a miss occurs on the static HTML files created by Boost. If you want to completely replace the cache backend, you could look into memcache, which stores serialized objects in memory. Memcached runs as a daemon on the server and can be connected to via TCP. This can be both a good and bad thing, depending on number of servers in the environment and

Note that it is possible to have the database keep the cache tables in memory as well (at least with MySQL), although I'm not sure about the specifics of doing so.

You could all use the APC module if you're running Drupal 7. The APC modules integrates with the APC opcode cache and uses it as Drupal's cache backend. APC can be faster than memcached in certain scenarios because there is no TCP connection overhead. Each APC cache is tied to a specific server, while memcached and the database can be shared by multiple front end servers (again, this can be good or bad).


Turned off overlay module. Problem has fixed.


Pass data to hook_preprocess_html from custom module

D7's html.tpl.php doesn't contain menu in $vars, as it's supposed to represent the template that contains the high-level HTML document. This data is in page.tpl.php via $main_menu / $secondary_menu vars.

If you need menu data in hook_preprocess_html() you can do something like call menu_tree_all_data('main-menu') in your code which will retrieve the menu data for main-menu.


Display Field Collection items as select list in other content type

This is a partial answer, looking for further guidance!

After a lot of exploration, I still couldn't find exact solution to my question.

While searching I found this topic titled: Entity Reference view to populate select list for reference field => only one result when using a contextual filter, might help others. This is a long node addressing similar problem.

But my problem was not solved by above mentioned link. So I used hook_form_alter,

function module_form_alter(&$form, &$form_state, $form_id){
    if($form_id == 'your_form_id'){
        $url_arg=arg(); //get arguments from URL
        $node_id=$url_arg[1];
        $node=node_load($node_id); //load appropriate node of Content type A
        $info = field_info_field('field_testing_code'); //load field from Content Type B's form
        $values = &$info['settings']['allowed_values']; //get list of allowed values
        $values= array(); //remove all existing values
        $i=0;
        while($node->field_consignment_text_field[und][$i][value]){
            $values[$node->field_consignment_text_field[und][$i][value]] = $node->field_consignment_text_field[und][$i][value];
            $i++;
        }
    field_update_field($info);
  }
}

As I mentioned, each B content type is a sub part of A content type. And URL contains id of A. When I open content type B's creation form one at a time, it works fine. When I open more that one forms having different A parent, form_alter shuffles data e.g Field data of tab 1 gets assigned to tab 2.This is the issue now.
Looking for some solution for this.


You could use a presave hook and rename the file before it gets saved: https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_file_presave/7


Drupal 7 I need to style the title attribute

It doesn't work because in test file you are using 'HTML5' doctype, and on other page (in Drupal) doctype is 'XHTML + RDFa' and you can't use data attribute.

Why don't you ignore data tags and use only CSS? There is an example:

a {
  color: #900;
  text-decoration: none;
}

a:hover {
  color: red;
  position: relative;
}

a[title]:hover:after {
  content: attr(title);
  padding: 4px 8px;
  color: #333;
  position: absolute;
  left: 0;
  top: 100%;
  white-space: nowrap;
  z-index: 9;
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
  border-radius: 5px;
  -moz-box-shadow: 0px 0px 4px #222;
  -webkit-box-shadow: 0px 0px 4px #222;
  box-shadow: 0px 0px 4px #222;
  background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
  background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #eeeeee),color-stop(1, #cccccc));
  background-image: -webkit-linear-gradient(top, #eeeeee, #cccccc);
  background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
  background-image: -ms-linear-gradient(top, #eeeeee, #cccccc);
  background-image: -o-linear-gradient(top, #eeeeee, #cccccc);
}

You can play around with this CSS and stylize your tooltip as you like.

Also, you can use CSS to stylize title tooltip form an anchor tag, but it won't work on img tag title.

This is how provided example looks like on your site (of course you can set 'width' for tooltip and it will look exactly like yours at test page):

I hope that this is helpful.


Is there an existing D7 UI solution to control the content of emails sent by the system?

Try out the Mail Editor and see if that's what you are looking for


Editing entity property (title) with ECK and editablefields

I think you can use Title module to replace the default title field.


How do I allow users to rearrange the fields order during content creation?

If you want per-node changing of field display order I recommend looking at Panelizer module. It takes over view modes at the level of entity bundles (content types) and additionally individual entities.

It is not an exact fit of what you describe in that:

It works on an interface separate from content creation.
It is view
mode specific. So rearranging one view mode (teaser) will not change
the full view mode. That might be good or bad depending on what you
want.


Is that possible to single sign-on with completely different domains?

Have you tried the Domain module? I've looked into it a bit, and seems to do what you need (though I myself have not set up my site yet with it, so I'm not positive). According to the documentation:

  The module allows you to share users, content, and configurations across a group of sites such as:

  example.com
  one.example.com
  two.example.com
  my.example.com
  thisexample.com <-- can use any domain string
  example.com:3000 <-- treats non-standard ports as unique

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


Those tables are generated dynamically by the field API, and as such don't have a pre-built DDL. This is essentially because fields can be added through the UI/programmatically after installation. Rather than keeping a monolithic registry of those fields and values, the architectural decision was made to split them out into dynamically-created tables with a conventional structure.

If you have corrupt field tables it's a bit...awkward. Drupal will already think the field exists because it'll still be listed in field_config and field_config_instance, so trying to add it again with the API/UI isn't going to work unless you also prune those records.

Those records may also be referenced elsewhere (possibly in serialised PHP strings, no less), and there's no referential integrity of any sort here anyway, so you'd have to be able to work out what types of referenced record you could have, be able to identify them all, and nuke them. Not exactly easy.

The easiest approach will probably be a bit of a hack job; get the DDL of another field table, and twist it to match the table you've lost:

mysqldump -d -uroot -p <dbname> field_data_body

Give us

DROP TABLE IF EXISTS `field_data_body`;
CREATE TABLE `field_data_body` (
  `entity_type` varchar(128) NOT NULL DEFAULT '' COMMENT 'The entity type this data is attached to',
  `bundle` varchar(128) NOT NULL DEFAULT '' COMMENT 'The field instance bundle to which this row belongs, used when deleting a field instance',
  `deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'A boolean indicating whether this data item has been deleted',
  `entity_id` int(10) unsigned NOT NULL COMMENT 'The entity id this data is attached to',
  `revision_id` int(10) unsigned DEFAULT NULL COMMENT 'The entity revision id this data is attached to, or NULL if the entity type is not versioned',
  `language` varchar(32) NOT NULL DEFAULT '' COMMENT 'The language for this data item.',
  `delta` int(10) unsigned NOT NULL COMMENT 'The sequence number for this data item, used for multi-value fields',
  `body_value` longtext DEFAULT NULL,
  `body_summary` longtext DEFAULT NULL,
  `body_format` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`entity_type`,`entity_id`,`deleted`,`delta`,`language`),
  KEY `entity_type` (`entity_type`),
  KEY `bundle` (`bundle`),
  KEY `deleted` (`deleted`),
  KEY `entity_id` (`entity_id`),
  KEY `revision_id` (`revision_id`),
  KEY `language` (`language`),
  KEY `body_format` (`body_format`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Data storage for field 7 (body)';

Replace the table name and comment. Remove body_value, body_summary, and body_format columns, and the body_format index. These are specific to the body field type, the rest is boilerplate and common to all field types.

It seems likely your field type was a file reference, so you need to find the columns for that field type's schema. These are in file_field_schema(); mix these into your edited DDL:

`field_files_fid` INT(10) unsigned NOT NULL,
`field_files_display` TINYINT(3) unsigned NOT NULL DEFAULT 1,
`field_files_description` TEXT DEFAULT NULL

(add comments if you wish)

And an index for the file ID:

KEY `field_files_fid` (`field_files_fid`)

Repeat for the revision table (using field_revision_body as a starting point), and you should have your table structure back in place. At this point it would be a good idea to restore the data to these tables from a backup, as they reference entities in the file_managed table (and can have references elsewhere throughout the system).


Sounds like something to put in the field or form validation.

$form['#validate'][] = 'form_validate';

or

$form['your_field']['#element_validate'] => array('_field_callback_validate'),


Drupal itself does not depend on titles or labels to identify entities, and there is no expectation within the core system that they would be unique. You could in theory have a completely functional site with ten thousand nodes all sharing the same title, tagged with ten thousand terms sharing the same name, linked by ten thousand menu items sharing the same label.

Drupal is full of locally unique, automatically generated IDs: each node has an nid, each term has a tid, each menu has an mlid, and so on (though for identifiers unique across the system, one must use UUID or something similar). Provided your custom code, theme output, Views filters, and so on can be written to reference these machine IDs, I would expect few problems.

It is not always possible to rely on those machine IDs; they are content, and so are subject to editing, deletion, and replacement. You might want a banner to appear on your About Us page, but depending on the season the About Us page may be node/25 or node/29, for example.

Thus it is possible, even unconsciously, to build parts of the site that do depend on labels. Many themes insert a class on the <body> based on title, or on the alias/context (which pathauto will by default set to the title); you may have CSS rules applying to the wrong pages. You may have an editorial policy that all nodes pertaining to a particular product include its product code in the title, and set up Views to filter them. But only takes one typo for a node to go missing, or one forgotten edit to the title of a cloned node to have extras appearing.


A little bit tricky

function your_form(){
  $form = array();
  ...
  $record_ids = array();

  foreach($record_set as $record){
      $record_ids[$record['id']] = ''; // Collect ids of your record as index
      $form['column1'][$record['id']] = array('#value' => $record['field1']);
      $form['column2'][$record['id']] = array('#value' => $record['field2']);
      $form['column3'][$record['id']] = array('#value' => $record['field3']);
  }

  $form['select'] = array(
      '#type' => 'checkboxes',
      '#options' => $item_ids,
  );

  $form['#theme'] = 'render_your_form'; // Theme registry function to render this form
}

Define theme_registry

function your_module_theme(){
   ...
   $theme['render_your_form'] = array(
       'arguments' => array('form' => array()),
   );
   return $theme;
}

Now write your theme handler

function theme_render_your_form($form=array()){
   $head = array('Select', 'Title Col 1', 'Title Col 2','Title Col 3');
   $rows = array();
   foreach(element_children($form['select']) as $id){
       $fields = array();
       $fields[] = drupal_render($form['select'][$id]); //This will render a checkbox, omit if not required
       $fields[] = drupal_render($form['column1'][$id]);
       $fields[] = drupal_render($form['column2'][$id]);
       $fields[] = drupal_render($form['column3'][$id]);
       $rows[] = $fields;
   }
   $output = theme('table', $head, $rows); // Theme as table output
   $output .= drupal_render($form); // Render rest of form components. (For D6)
   $output .= drupal_render_children($form); // Render rest of form components (For D7)
   return $output;
}


Implement hook_form_alter() and check $form_id == 'user_register_form'


Below are the two ways. I hope help you to solve your issue.

1.
Your files via FTP into the image_import directory aren't being given the correct permissions. You have to provide the permission i.e. chmod 660 * on them in the image_import directory the files were recognized correctly and the import worked.

OR

2.
In /includes/image.inc, change line 117 from:

  if (!is_file($file)) {

to:

if (!is_file($file) && !is_uploaded_file($file)) {

Then check is your issue is solved or not. If not then try once updating below with second way :

On the admin/settings/file-system, try changing C:\WINDOWS\Temp to sites/default/files/temp (also made sure it was writeable by the web server).


Don't allow users to create nodes until they have at least one comment

You can do this is with the Rules module.

Remove the permission to create nodes from authenticated users.
Create a new role (e.g., one_comment) and give this role the permission to create nodes.
Create a rule that is triggered when a comment is posted and gives the user who posted the comment the one_comment role.


Is it possible to create a Nodequeue of Nodequeues?

Nodequeue supports Smartqueues.

  Smartqueue API

  Nodequeue provides a robust API that allows other modules to define
  smartqueues, which are associated with external data. For example, the
  included taxonomy smartqueue creates subqueues for a given queue for
  every term in the chosen vocabulary. Nodes are then only eligible for
  subqueues whose term matches the nodes terms. This makes it very easy
  to have queues for each category without cluttering the management
  page.

If the default smartqueue's dont meet your needs you could leverage the API to write your own smartqueue that uses the queue's you've made for your users.

EDIT:

Perhaps see Smartqueue for Content Types.

  This module provides a smartqueues based on avaliable content types.
  It adds a subqueue per node of selected content type to hold an
  ordered queue for nodes of another types. Any of these types can be
  used for smartqueues as well to hold additional levels of nodes
  grouping. So you can build very complex informational structures
  powered by handy Nodequeue's features and integration.


Within a node, how can I reference the value of a field of a node associated to the current user through a node-reference?

You should be able to do this through Views arguments, with the nid of the customer node as the argument. Then that node's fields should be available to you from there.


Import images from Joomla com_exposé to Drupal 7

If all the page layouts has the same or similar kind of tags associated with them i would suggest you to write a custom scrapper and save the images locally.
If you are gonna use these images in you Drupal site, i am sure i can help you with a clear cut piece of code and implementation.


Take 2 fields in a content type with php

Let assume that you are using Drupal 7

You need to know nid of node "Mondovi".

Then you can use following code:

$node = node_view(node_load(NID_OF_NODE));

// print value of body field without field label
print render($node['body'][0]);

// or print body value with field label and all div wrappers
print render($node['body']);

// print value of field_data without field label
// if field can have multiple values - use cycle to dipslay all of them
print render($node['field_data'][0]);


Add 150 grams to each order for calculating shipping

I guess you're using commerce_shipping module, if so, you can add a commerce_flat_rate service to every order.

Otherwise I would suggest you start using these modules ;)


If it was me, I'd probably use a Region reference on the City so that you only need a single-value field, but this should be quickly accomplished in Views either way.

Assuming a City reference on the Region:

Create a View of Content entities of type City with a Block Display.
Add a Node ID Contextual Filter with Default Actions set to Provide Default Value > Content ID from URL.
Add a required Relationship to Region/Content using your reference field.
Add your reference Field to the display using the Relationship and uncheck/disable Multiple Field Settings > Display all values in the same row.
Add a Contextual Filter for your reference field using the Relationship with Default Actions set to Provide Default Value > Content ID from URL. Then check/enable the More > Exclude option.

Now just place the block in a theme region on your site so that it shows up on the City page. #1-4 should get a View showing all Cities that share a Region with the current one. #5 should remove the current one from the results.


As say in Search interface the search system already indexes all visible output of a node; i.e., everything displayed normally by hook_view() and hook_node_view().

You can activate and configure in the display settings of your content type the custom display "Search index" than will be used for indexing.

If this doesn't works in you case, you can implement hook_node_update_index to add any information you want on the node before is indexed.


How to use Output as a link and replacement patterns to get friendly URLs

If I understand your problem correctly, it sounds like you're trying to redo the aliasing work PathAuto does in Views.

If that's the case, you can add a Content: Path field to your view (using the Exclude from display option if you don't want it visible) and use [path] in your link output to link it to your pathauto alias.


Associate a Taxonomy term to user who creates it

Taxonomy doesnt contain this kind of data.
A possible workaround would be-
Creation of a custom module that writes data into a custom table.
You can use hooks to intercept the addition of the item.


Just add two entries in the "Sort criteria" section, left column, bottom. The more important sorting criteria should be on top.

Add button can be used as a drop-down, to show Rearrange button, if needed.


What is the D7 equivalent of CCK "content_instance_tablename" in db_query?

Both functions in your code (content_field_tablename() and content_instance_tablename()) just return a string based on the version number of the CCK module.

The Drupal 7 equivalents would be the field_config and field_config_instance tables respectively, as defined in field_schema.

Remember fields can be attached to any entity in Drupal 7 (not just nodes) so you'll need to change your code accordingly.

If you're using this query to get information about the field metadata you might want to use one of the Field Info API functions instead, e.g.

$all_field_instance_data = field_info_instances();

or

$single_field_instance_data = field_info_instance('node', 'field_some_field', 'article');


"No query was run" when Contextual Filter is added. Was working before

I had already flushed caches and reloaded the page twice (yes, I'm positive, and yes, I swear) when I originally asked this question, but at some point my view magically started working again. So I guess I should have just flushed caches and reloaded the page harder.


Get the user ID for a newly created user account

You don't have access to an id property. You need to use the id() method instead, e.g. $userEntity->id(). See the documentation for User.
For example:
echo "User " . $userEntity->id() . " saved!\n\n";


Redirect the users to the page they were watching before logging in or registering an account

I hope you want to keep users on the currently visited page after logging in or out. If it is so, then download and install the Login Destination module. It is also possible to keep users on the currently visited page after logging in or out.


The SystemMenuBlock of core is invalidated when its menu changes because this method:

public function getCacheTags() {
  // Even when the menu block renders to the empty string for a user, we want
  // the cache tag for this menu to be set: whenever the menu is changed, this
  // menu block must also be re-rendered for that user, because maybe a menu
  // link that is accessible for that user has been added.
  $cache_tags = parent::getCacheTags();
  $cache_tags[] = 'config:system.menu.' . $this->getDerivativeId();
  return $cache_tags;
}

I think you can solve your problem in the same way.


Modify default rendering of a custom content type defined in a module

This is the way that I solved this problem:

/**
 * Implements hook_theme().
 */
function docbook_theme($existing, $type, $theme, $path) {
  return array (
    'node__docbook' => array(
      'template' => 'node--docbook',
    ),
    'node__docbook_section' => array(
      'template' => 'node--docbook-section' ,
    ),
    'field__field_dbw_author' => array(
    ),
  );
}

/**
 * Implements hook_preprocess_HOOK().
 */
function docbook_preprocess_node(&$variables) {
  //krumo($variables);  //debug

  if ($variables['type'] == 'docbook') {
    $variables['variable1'] = 'hello1';
  }

  if ($variables['type'] == 'docbook_section') {
    $variables['variable2'] = 'hello2';
  }
}

/**
 * Implementing theme function theme_HOOK().
 */
function theme_field__field_dbw_author($variables) {
  //krumo($variables);  //debug

  $output = '';

  . . . . . . . . . . . . . . .

  return $output;
}

See more details on these commits:

https://github.com/dashohoxha/DocBookWiki/commit/0e15266fdfa9000bd32d2ddabce036b21fa55930
https://github.com/dashohoxha/DocBookWiki/commit/0fee64d261f66878166c215559234e01e185e6f1
https://github.com/dashohoxha/DocBookWiki/commit/0fb4ac1ca7da38067c647f362c22d167c62f5ae6
https://github.com/dashohoxha/DocBookWiki/commit/db15d8af013bfc91143029c84e7cd0134400af85
https://github.com/dashohoxha/DocBookWiki/commit/c9250ba89094fc2c8fa83945ffbee0be25d42d84

I would expect these solutions to work as well:

function docbook_preprocess(&$variables, $hook) {
  if ($hook == 'node__docbook') {
    $variables['my_new_variable'] = 'hello';
  }
}

function docbook_preprocess_node__docbook(&$variables) {
  $variables['my_new_variable'] = 'hello';
}

function template_preprocess_node__docbook(&$variables) {
  $variables['my_new_variable'] = 'hello';
}

But somehow they don't work. Either my understanding and expectations are wrong, or there is something wrong on the implementation of Drupal.


How to display nodes based on the taxonomy terms of the current logged in user, with multiple vocabularies?

Did you try this using fields instead of taxonomy? I personally prefer using fields over taxonomy since fields are more flexible with views. In your case, if your site is still under development I suggest you to use fields and try out the same.


node_load_multiple does not respect node access grants

You can do it like this. First, query the NIDs, with a query that is tagged for node access, then load the nodes with the found NIDs.

$nids = db_select('node_field_data', 'n')
  ->fields('n', ['nid'])
  ->condition('title', $my_title)
  // The node_access tag will check access rights.
  ->addTag('node_access')
  ->execute()
  ->fetchCol();

$nodes = Node::loadMultiple($nids);

Untested in D8, but it should work.


All you have to do is to Enable your proper language (using locale module) and then use translate interface (site building -> translate interface) , and you can translate your string.

after that whenever t('hello world') is called , drupal checks for proper language , then checks if there is a translation for 'hello world' in that language , if true , then it will print translated string.


How to access current langcode in theme?

Here's how to do the same in Drupal 8:

$language = \Drupal::languageManager()->getCurrentLanguage();
// Will return "en".
$shortcode = $language->getId());
// Will return "English".
$language_name = $language->getName();

Read more here.


Where are the watchdog logs located or how do I view the errors created?

Both Drupal 6 and Drupal 7 put the viewable version of watchdog logs at /admin/reports/dblog. The core database logging module needs to be enabled, and users who want to view them need the access site reports permission. The actual database table is watchdog.


How to programmatically handle files (CSV import)

Drupal's naming convention for the automagic association of validation and submit handlers for a given form is:

name_of_form() (builder)
name_of_form_validate() (validation handler)
name_of_form_submit() (submit handler)

In your case, if you wanted to name your form vts_departs_conf_form(), you'd want to either rename your validation handler to vts_departs_conf_form_validate() and your submit handler to vts_departs_conf_form_submit(), or use the #validate and #submit form attributes to associate functions that don't follow the naming conventions.

In your example, changing the builder name to vts_departs_conf() made the form work as expected.


Embedding content in a panel ctools plugin- any other options

I definitely understand your problem with a ctools pane feeling verbose.

Unfortunately I don't have a great fix. I tend to copy an old content type to a new one and edit names and such.

What you make not know is that the normal single => TRUE property of a content type can be switched to FALSE allowing the code to create multiple panes in a single content type. (Actually I think FALSE is the default, so you don't even need to).

This allows you to share a lot more code between several panes that act similarly.

Another, simpler but more limited option is Fieldable panels panes, which basically allows you to take an entity, put fields on it, and stick it directly into a variant. If your needs are simply to display simple content, that could be enough, but this isn't enough when more complex logic is needed.

Actually a pane that requires a EntityFieldQuery context as an argument and then basically just themes it would be very interesting. There's probably use for at least a sandbox that provided the context and content type for that. :)

I'll try to write up more details if necessary, but look at plugins/content_types/custom/custom.inc for an example of a content type that does the above.

Someone may also have taken the time to write a drush command to generate a content type from a template. Haven't looked around for one though.


Any advantage to using Profile2 module vs. custom user account fields?

The Profile2 module is only good if you need more then 1 type of profiles.
For example:
         - a student profile, with certain fields.
         - a teacher profile, with different fields.

If you don't need different types, just stick with the custom user account fields.

Hope this helps!


Errors to Display: None - Settings won't save

Found it!

This is my first Drupal site I'm pushing to production. I still had the following lines of code in my settings.php as suggested on this site: http://drupal.org/node/1056468

error_reporting(-1);
$conf['error_level'] = 2;
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

Those lines were forcing it to ignore the value in the database and always set it to Show All Errors. I commented those lines out and it's respecting the form value I choose now.


Sounds like the function of Field Permissions module.

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


Manually including Webform in a single node

A discussion on Drupal has resulted in a patch that allows you to display a webform in a block (and then you can display that block only on your node tpl page).

EDIT: The patch has been included in the latest version of webform.

Additionally, you could try using this PHP code:

<?php
    $node = node_load($nid);
    print node_view($node);
?>


Invoice module to run with commerce module?

The most up2date list of Drupal Commerce invoicing modules can be found at
http://drupal.org/node/1535498


Remove "Password reset instructions" hint on reset you password page?

You want to use hook form alter like this:

function mymodule_form_alter($form_id, &$form) {

  if ($form_id == 'user_edit') {
    $form['fieldname'] = '';
  }
}

If you install devel and kint, then you kan kint($form), to see what the fieldname is.


Trigger a Drupal behavior from another module in Javascript?

Hitting the route with Drupal.ajax results in
  'context.querySelectorAll is not a function.

This happens when Drupal.attachBehaviors() is passed a jQuery object. It expects an HTML string. So if you are doing this:

var element = $(".some_element");
Drupal.attachBehaviors(element);

You change it to:

$(".some_element").each(function () {
  Drupal.attachBehaviors($(this).eq(0));
});


How to add extra option to the existing drush command?

This is done with drush_help_alter rather than drush_command_alter. See the example Drush policy file, reproduced in part below:

function policy_drush_help_alter(&$command) {
  if ($command['command'] == 'updatedb') {
    $command['options']['token'] = 'Per site policy, you must specify a token in the --token option for all commands.';
  }
}


How to install a local module file with drush?

If you already have the module / feature that you want to install on your local disk, simply copy the files to DRUPAL_ROOT/sites/all/modules.  Some folks also like to create "contrib", "custom" and "features" directories inside of "modules" to better organize their files.

Once you have your files in place, run drush en featurename to turn it on.


Ok, I answer myself as I realized what I was doing wrong. Just make sure that the facets you are selecting are the indexed facets, so this way they match with the indexed fields you want to filter by.

It works really nice now!


Show Block when Listing one Content type

Please follow these instructions carefully:

1) Go to /admin/structure/block and click on "Pleace block" button in the region you want to add your view block, for example "Content" region.

2) Now you will see at least three tabs:"Content types", "Pages", "Roles"

3) In tab "Content types" select "DEF" type content

4) Be sure on tab "Pages" is selected the radio button option "Show for the listed pages", leave empty the text area on this tab.

5) Save block.

Hope this help.


The important points, which I can't seem to find stated clearly anywhere:

Each Search API search index you create becomes an option in the "Show [content]" dropdown at the top when you first create a new view. Unlike regular search views (where you could just take any old view and add a "Search" contextual filter), to use search API in views, you have to create a special type of view, choosing and fixing the search index to use at the point of creating the view, by choosing it in this dropdown.
You'll need to pipe the actual search terms in somehow. A common way is to use the "Search fulltext" contextual filter, which interprets an argument in the URL as the search terms to use. There's also (depending on search server, I believe) the popular "Search More like this" option, which uses the content of the entity loaded via the contextual filter as the search terms (so if it's a block on a node page set to use the node's nid, it gives you results as if you searched using that node's content). Another way is using an exposed filter then getting the search terms from the input or exposed filter part of the URL query string.
For reasons I don't quite understand (probably something to to do with how entity API module does views integration for entity views, which has some limitations, more info at http://drupal.org/node/1378656), some elements of a Search API view are different to how they would be normally. For example, where in a node view, the path would be [path], in a Search API index view on a search index set to search nodes, it's [url]. It's no big deal, mostly the differences are fairly easy to figure out, but it's something to watch out for. Some things e.g. some relationships don't work for similar reasons - test complex views thoroughly and look at both Search API and Entity API issue queues if you find problems.

There is, technically, a documentation page that touches on some of this, which might be of some use to someone.


hook_menu() doesn't work as expected. How can I fix that?

It was very simple problem-

I just added following line to my .module file-

function store_id_to_arg($args){
if(empty($args)){ drupal_goto('<front>'); }
return $args;
}

Thanks for your help.


(Assuming you are on Drupal 6, as it seems) you also need to copy the default node.tpl.php (e.g. the one from your base theme) in the same theme directory you are putting the override file (node-product.tpl.php) in order for the theme engine to pick it up:

  If you are implementing a suggestion, rename the file to the
  suggestion name it should have. Note that some suggestion files will
  not be recognized unless their base file is also present -- for
  instance, if you want to make a node content type suggestion file for
  your content type, you need to have node.tpl.php present in your theme
  directory order for your node-my_content_type.tpl.php file to be
  recognized.  (Beginners guide to overriding themable output)


Ship to multiple addresses on single order

This is one of those tasks that take a lot more time on Drupal 7 than Drupal 8, since the Drupal 7 version of Shipping doesn't have native support for multiple shipments.

Your best bet is investigating the Commerce Shipment and Commerce Fulfillment modules, choosing one of them, and then coding the rest.


Why can i not add a new link to the main menu?

Go to Modules list /admin/modules and make sure the Path module is enabled.


How to Add Taxonomy Vocabulary in Rules when User Registers

I have checked the rules and I couldn't find a Data Selector for user name. But if you are fine with achieving the same using custom code then you can use the following code.

function YOURMODULENAME_user_insert(&$edit, $account, $category){
   $vocabulary = new stdClass();
   $vocabulary->name = $account->name;
   $vocabulary->machine_name = "tutor_".$account->uid;
   $vocabulary->hierarchy = 0;
   taxonomy_vocabulary_save($vocabulary);
}


Seems like something perfecly suited to Panels.

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

Just create a panel page with the content you want displayed in a list, and then make this panel page your front page.
There are loads of tutorials/help on the project documentation page if you've never used it before.


Why is config for my view going to config/local?

As is usually the case, 30 min after posting I figure it out.
My issue was caused by the "Include dependent configuration" option being enabled for the split configuration.


Drupal changes language after clicking html link

I unchecked all the options on admin/config/regional/language/configure except the url
option.
Now my links link seems to work.
Credits to drupalist:
thanks


How do I print the SQL query of a view in front end?

You can enable on "Show the SQL query" and "Show other queries run during render during live preview" on "www.example.com/admin/structure/views/settings"

Hope it will help you.


How to add UniqueField constraint on integer field?

This seems to be an open bug in core. I have filed a bug report containing a makeshift solution on Drupal.org: https://www.drupal.org/node/2784015/

Edit the file 'core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php' to let the errorElement function return $element[0]['value'] instead of $element['value']. So far, I don't understand why it is happening.


You can dump $content['field_primary_section_link'] using var_dump() or if you have devel module installed in your project you can use dpm() and you'll see a bunch of arrays there and check the raw url that you need.


OK I found out that that error in particular is due to not having a large enough allowed packet size in your mysql configuration. Here is a bit more info on that:

http://is.gd/pV7c2M

If you're running LAMP, here is how you can create a configuration file and increase your max packet size limit:

http://is.gd/mI3B82


Custom login block that redirects to password protected page that is not published otherwise

Giving users permission to view unpublished content could potentially be a security risk, and it's not (easily) possible to restrict it to just viewing a particular content type.

Why not publish the node, but only allow users with a certain role be able to view them using the Content Access module.

Then create a few accounts with this role, setting the usernames and passwords yourself.

Then just use the standard Drupal login form but then alter the redirect once logged in with hook_user_login:

function hook_user_login(&$edit, $account) {
    if (in_array('your_role', $account->roles)) {
        $edit['redirect'] = 'node/123';
    }
}

By creating the accounts this way it means you can use the main Drupal authentication system so reducing the amount of work that you need to do...


This is because you're rendering the full item when all you want is the url as a string, if you add this line of code in the template you will be able to see where the url is held in the $items array.

<?php var_dump($items); ?>

then you can find the part of the array where the url string is so your final markup would be something like this.

<a href="<?php echo $items['url']; ?>">


I had to do something similar to this in the past, where the website client wanted users to be able to mark items as favorites, and then email that list of favorites to the client for pricing and further information. Rather than building a whole e-commerce setup, I used webform and webform view.

Here is the basic setup:

Create 'food item' content type or whatever will be most appropriate for each of your food items
Create a view that displays the food item nodes.
Create a webform that collects user information (such as contact information when submitting an order
Embed your food item view in that webform using the webform view module.

When people then fill out the form, they can select which 'food item' nodes they, want, the quantity, or any other custommizations that you can create using the webform (special requests, delivery method, anything you'd like). They will also enter in any relevant contact information and send it to you as a standard webform.

Webform view has great documentation. It can be a little confusing the first time you try to use it though, so I suggest you follow exactly the documentation in webform view to get an idea for how this module works, and then modify it accordingly for your food item view.

I liked this method too as then the food items are their own content type, so if you do want to do something with e-commerce for real in the future, you should be able to migrate those nodes to products for something like drupal commerce.


automatically fill the field info based on user selected

Please make a try by using Entity reference autofill and Entityreference prepopulate Modules.

Add an entity reference field.
The entity reference autofill will automatically fill reference value into field.
Entityreference prepopulate will prepopulate the values. (you have to add existing fields for that.)

For more details please refer project page.

Another approach using ajax. Try the following code in a custom module.

function your_module_form_alter(&$form, &$form_state, $form_id){
  if($form_id =='your_node_form_id') {
     $form['your-email-field']['#prefix'] = '
';
     $form['your-email-field']['#suffix'] = '
';
}
$form['your-user-field']['und'][0]['#ajax'] = array('callback' => 'your_module_callback', 'wrapper' => 'field-email-replace','method' => 'replace',);
}

function your_module_callback($form, $form_state){
  $uid = $form_state['values']['your-user-field']['und'][0]['value'];
  $user = user_load($uid);
  $form['your-email-field']['und'][0]['value'] = $user->email;

  $commands = array();
  $commands[] = ajax_command_replace("#field-email-replace",  render($form['your-email-field'])); // use render if you want to render field.

 return array('#type' => 'ajax', '#commands' => $commands);
}

Hope this will help you.


How to disable persistent database connections for Drupal 7 / PostgreSQL

Drupal does not use persistent connections.  See https://drupal.org/node/1079892.  You may need to lower the number of web server processes (e.g. Apache MaxClients).


How to add 'not equal' condition in form #states

This code should work:

':input[name="B"]' => array('!value' => 'all')


Prioritize Row within View based on Taxonomy Term

On your view, for Sort Criteria remove whatever you're current using (post date is usually the default) and add Taxonomy term: Weight

Then go to admin/structure/taxonomy go to list terms and click on show row weight link (far right) and give them different weight numbers, or use the four arrows icon to drag them and arrearage them in the order you want them to show in.


Render the User creation form on another page

You could use the Form Block module and place it before/above your view.

  Enables the presentation of user registration, site wide contact, or
  node creation forms in blocks. This is particularly useful for
  including forms on panels.

  Do I just inspect element the form and grab the form id again and
  replace it with the UserLoginForm section?

You just need the ID user-register-form which means your form ID is user_register_form

I see now that you're talking about the admin form, I believe you just have to modify the formblock.module file and comment out or remove this part

 // Don't display the form to logged in users or if registration is disabled
  if (!$user->uid && variable_get('user_register', 1)) {
    $block['content']['form'] = drupal_get_form('user_register_form');
    $block['subject'] = t('Create new account');
    return $block;
  }

So try:

$parameter = 'new';
$form = \Drupal::formBuilder()->getForm('user_register_form', $parameter);


Can I setup the Security Kit module via Drush?

You could update the Security Kit settings via the config-set command:

drush config-set seckit.settings seckit_xss.csp.img-src "'self' 'unsafe-inline'"

You can find the available configuration keys by looking at Security Kit's  default configuration file, config/install/seckit.settings.yml, or you can view your site's current settings through the config export page.


Create two nodes from webform submission

I would recommend Rules.

Here's a link. Using webform rules to create node after webform submission

Hope that helps.


How to lock a piece of content form being edited by specific roles?

I've not used it, but the Content Lock module might fit your needs!

EDIT AFTER COMMENT

What you could do then is utilise Taxonomy Access Control using the following method:

1) Add a Taxonomy vocabulary called "Locked" (or something like that)

2) Add two terms to that vocabulary - Locked and Unlocked

3) Set the permissions for authenticated users to be able to add/edit the content, but do not allow them to set the taxonomy terms.

4) Set the permissions using TAC so that if a node has the term of Unlocked, it is still editable, but as soon as that term gets changed to Locked, then authenticated users cannot edit that node.

5) Once the content has been submitted and approved, the user with the Editor or Admin role sets the term on the node to Locked.   This will prevent the user from being able to access the edit page for the node.

It sounds much more complicated than it really is.  You'll see what I mean when you get to the settings page for TAC.


How to query for null in nested db_or conditional

You can use isNull() in the db_and() condition, it'll work just fine:

$query->condition(db_or()
  ->condition(db_and()
    ->isNull('join_alias1.field_date_unassigned_value')
    ->condition('join_alias2.field_date_assigned_value', $end_date, '<=')
  )
  ->condition(db_and()
    ->condition('join_alias1.field_date_unassigned_value', $start_date, '>=')
    ->condition('join_alias2.field_date_assigned_or_submitted_value', $end_date, '<=')
  )
);


Google Maps Module custom markers and routeplanner

Have you already tried https://drupal.org/project/routeplanner ? It's a very simple and lightweight Module to create a route from any address to a fixed point of interest.


PHP has an extension for XML-RPC, but it's not enabled by default. If your PHP installation doesn't have the extension, you can use one of the PHP libraries that handle XML-RPC requests, such as XML-RPC for PHP, and The Incutio XML-RPC Library for PHP; if you have downloaded the Zend Framework, you can use its XML-RPC classes.


$media_id = \Drupal::request()->get('media'); // get value of media query param

$media = Drupal\media\Entity\Media::load($media_id); // load the Media entity

$media_name = $media->getName(); // get the media item name

$media_field = $media->get('field_media_image')->first()->getValue(); // get media field

$file_id = $media_field['target_id']; // get the File ID

$file =  Drupal\file\Entity\File::load($file_id); // load File entity

$image_url = $file->url(); // get image url

You could take this shortcut instead of writing the last 4 lines.

$image_url = $media->get('field_media_image')->entity->url();


It's not a good Idea to change manually the jQuery lib of drupal , because It can cause lot of bugs , instead of this use jquery update module


Trouble hooking blocks with theme templates

There is a easier way to do this using Block theme. But in case you do not want to use it, you can create block template files in the following order.

block--module--delta.tpl.php

block--module.tpl.php

block--region.tpl.php

More information can be found here.


Can I redirect the user to some other page if the result of a view is empty?

In your views No results behavior Choose ' Global: Text area ' choose php filter and add the following code.

<?php
 drupal_goto('node/1'); //path to redirect
?>


Webfrom : Having two textfield boxes inline .

You can easily accomplish this using the Webform Layout module.

This module allows you to arrange fields into rows or columns.


How to get a list of all the selected values for a field programmatically?

Because fields can have multiple values both of the methods you describe will return an array. Each of those array items will itself be an array, of all the possible columns for the field. In the case of text fields the only column you really need to worry about is the value column.

Assuming your particular field does not accept multiple values, or it does and you only want the first value, the following should work:

$items = field_get_items('node', $node, 'field_countries', $node->language);
$item = array_shift($items);
$value = $item['value'];

or

$value = $node->field_countries[$node->language][0]['value'];


You actually need to add the edit button in a node. well, first you need to get the node ID, create template.php and add this function :

function YOUR-THEME_preprocess_node(&$variables)
{
    if (isset($variables['node']))
    {
         $variables['id'] = $variables['node']->nid;
    }
}

in this way the node id will be saved in the $id variable inside the node template file. if you want to use the default node.tpl.php copy this file from modules/system/node.tpl.php. now add this code where ever you want in the new copied node.tpl.php

<?php
    global $base_url;
?>
<a href="<?php print $base_url;?>/node/<?php print $id;?>/edit">Edit the Content! </a>

if you suggest any theme hook (theme the node page) no difference does it make, use the above code, the link always will be

"<?php print $base_url;?>/node/<?php print $id;?>/edit"

Good luck


Email webform results - only filled fields

You could alter the webform email template to check for submission results before outputting them.

The documentation for utilizing the template is here:

http://drupal.org/node/1337488

Look under the Heading 'Using a webform email template'.


In the file back_to_top/js/back_to_top.js you'll find the following on line 23:

$('html,body').animate({ scrollTop: 0 }, 1200, 'easeOutQuart', function() {

The 1200 is the animation duration in milliseconds. Lower it and the animation will go faster. Optionally you could raise a feature request in the module issue queue to make this a configurable setting.


Something like this should work:

Set the Views to cache data.
Implement hook_cron(), and delete the cached data from the cache_views and cache_views_data tables.
Programmatically request the URL which contains the expensive Views to rebuild them (this could be done via CURL, file_get_contents(), etc.)


How to get Webform Field data for a custom module?

Provided Token is installed, you can use token_replace to access Webform submission values by field name.

$email = token_replace('[submission:values:email]', array('webform-submission' => $submission));

Note: The Devel module can be useful for exploring object properties and tokens (among other things).


Looking at file_create_url() I think it should be possible to pass in an absolute path, starting with /files... and then prefix the return value with your domain, protocol, whatever you need.

To handle that at a single location in code you can also use hook_file_url_alter().

Is it possible that you're looking for the CDN module?


You created your link by concatenating width=500&amp;height=500&amp;iframe=true with an ? instead with another &amp;
So the working link would be:

open in Colorbox (iframe)


Acquia has to have the full site, core, modules, themes, libraries, et.al. checked into their git repo in the format like:

git root
  docroot
    core
    modules
    themes
    etc.
    (includes index.php and other root files)

As Clive said, there is a pay for it CI process.  However, for the normal sites, you need to manage the site as a whole entity.  They do have Deployment hooks, but that is generally for clearing cache and the like.

FYI - I use composer on all my sites.  You run it locally and check in the composer files to the repo (e.g. the composer.lock, etc.).  Things like js libraries are added by manually adding repo's to the composer.json file if they are not composer friendly. E.g., here's how the jquery chosen plugin gets added:

"harvesthq.chosen": {
  "type" : "package",
  "package" : {
    "name" : "harvesthq/chosen",
    "version" : "1.8.7",
    "type" : "drupal-library",
    "dist" : {
      "url" : "https://github.com/harvesthq/chosen/releases/download/v1.8.7/chosen_v1.8.7.zip",
      "type" : "zip"
    },
    "require" : {
      "composer/installers" : "^1.2.0"
    }
  }
},

It's also best to have the Drupal friendly paths defined in your composer file.  E.g.:

"extra" : {
    "installer-paths" : {
        "docroot/core" : [
            "type:drupal-core"
        ],
        "docroot/libraries/{$name}" : [
            "type:drupal-library"
        ],
        "docroot/modules/contrib/{$name}" : [
            "type:drupal-module"
        ],
        "docroot/themes/contrib/{$name}" : [
            "type:drupal-theme"
        ]

These make sure things get placed properly by composer.


I don't think (I haven't seen your view) you need to enable aggregation to group by year. This is a solution:

If you need to display the date field value add the field twice. You will use one for the display of the date and the other for the grouping by year. If you are not going to display the date, you still need the date field to be able to group by year.
On the date field you are going to use to group by year you need a custom format that will only show you the year and if you are collecting both start and end date set it to you only the start date or the end date, but not both.
To create a custom date format go to admin/config/regional/date-time in Drupal 7 or to admin/settings/date-time in Drupal 6. There you will create a date format that will only show the year and then create a date format type that will show that date format.
Back to the date field you want to use to group by year change its format to the newly create format that only show you the date and set you show only one date and click apply. Also if you don't want the year value to show on the view check the option to exclude it.
Depending on the view format you have chosen (Table, Unformatted list, HTML list, etc) you will click the setting of the format and you are going to set the date field with the newly date format as the grouping field. Click apply and you are done.
You might also want to visit the "sort" section of your view to set the sort order of the dates.


How to intercept the loading of a field?

Ok, i figured it out.  I put this code into my template.php of my theme:

function johncustom_field__field_price(&$variables) {
        if($variables['element'][0] == '$0.00') return 'Free';
        else return $variables['element'][0];
}

I also had to clear the cache several times before this function would fire.


Right way to add a field to be used as a filter in Views with ranges?

This module might help: Views Contextual Range Filter

Module Page Description:

  Views Contextual Range Filter is a simple plugin for Views that adds
  the option to contextually filter not just by a single value, but also
  by range. Numeric, alphabetical (string) and list ranges are all
  supported. Node ids, user ids and even taxonomy term ids are all
  special cases of numbers so will work also. Range-filtering on the
  "created" (posted) and "updated" (last modified) node properties is
  also supported, provided you use the correct format as dictated by
  Views. So, YYYYMMDD for full dates or one of the shorter formats, i.e.
  year+month, year-only, month-only, week-only or day-only. You may use
  the OR operator (i.e. +) and the negate operator. You negate by
  ticking the "Exclude" box on the Views Contextual filter configuration
  panel, in the "More" section.


SFTP Can't upload module despite using owner's credentials

Using ssh you can log in to the system to check about directory permissions using the same credentials you use with sftp.

try..

ssh user@host

to login and then use a number of commands to check permissions

ls -l                      //Lists files with permissions for user, group and other
chmod 755 dir/file         //Change file/directory permission
chown user:group dir/file  //Change the user/group ownership of file(s)

scp command can also upload file from local (*nix) machine to server.

scp path/to/local/file user@host:/path/on/server


Any ways to create count column like mysql "COUNT(*) as counted" Column with d7's db_select()?

This error simply means that column does not exist in your database which means u have to write addExpression() method for solving these problem as follows and even you have not joined the table properly use your query as below

$query = db_select('users','u');
$query = $query->extend('PagerDefault')->extend('TableSort');
$query->leftJoin('mycustom_report','r','r.uid=u.uid');
$query->fields('r');
$query->fields('u');
$query->addExpression('COUNT(uid)', 'uid_count');
$result = $query->execute()->fetchAll();

this will surely removes your error the main issue with your query is that you are combining the db_query syntax with db_select


how to get a list of all the boolean fields of a node?

You can get a list of an entity's field definitions with EntityFieldManager::getFieldDefinitions(). You should then have a list of fields defined on that entity and should be able to determine which are the boolean fields.

You can access this via a service like:

$product_field_definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', 'product');


Showing child taxonomy terms if the parent is selected

Views doesn't have any built in way of creating an exposed filter like you explain, which means that you either need to create this functionality yourself for Views - which is very hard unless you have messed with Views APIs. The other option is to create this functionality in a custom module which a lot easier but also quite time consuming, so you will have to code it all in a custom module.

As a side note you should update your views install, currently up to date version is 3.3, This is quite important as 3.1 or 3.2 had a security fix, meaning you site has a known security vulnerability.


How do I programmatically get the link for a webform submission?

Webform submissions are content entities, you can use any method defined in \Drupal\Core\Entity\EntityInterface including…

$submission->toUrl();
$submission->toLink();


Create an e-mail reminder depending on a date field in a custom content type

I followed the following instructions to achieve what I wanted to do.

  Create a Rules component of type 'Action Set' and call it 'Send Notification'. Add a Variable of 'Entity: Node', give it a label
  and machine name of 'node'.

  Add an action to the loop (note: add it to the loop and not the
  component) of 'System: Send Mail'.

  Add a new rule and call it 'On new event', to react on 'Node: After
  saving new content'. Restrict it to the custom content type.

  Add an action to this rule, 'Rules schduler: schedule component
  evaluation', and select the 'send notification' component you created
  earlier.

  Set the evaluation date to node:field-event-date.

  Add an offset: -1 days (optional)

  Add an identifier of 'node-[node:nid]-event' and note its pattern as
  you will be using it to delete events.

  Select the Node as 'node'

Source: Send reminder to referenced users day before event date in cck date field


Add class to Menu Block UL unique to each Menu Block instance?

Unless your theme changes the usual behavior then each of your menu blocks will have its own unique ID so you can use CSS like this (note the ID/class I used here might not be the ones you have to use, they're just an example):

#block-menu-block-2 ul.menu

This way you don't have to worry about overriding the markup of the menu to add classes in.


you should create a view which display only the nodes related to the current term. You'll have to play a bit with contextual arguments but it works. The simple way is to add a contextual argument to the term field.


how to modify print--mail--node--node-type.tpl.php drupal 7x

I think that you can do this by changing display of content type. Just go to the Manage display page of the content type you print; at the bottom, expand Custom display settings and select Print. After saving, you'll see the Print tab (next to tabs like Default and Teaser).

Now you can change the page display settings. You can also change the page style using CSS.


One solution I did recently in a similar situation was just create a views xml feed of the content I want to feed to my subsites. From there my subsites would have the feed_import module and have to fetch the articles every 10 minutes. Once fetched it will be unpublished but can only be viewed by certain roles for screening.

Now as for the left over imported nodes I would use node_purge to delete nodes that are X days old. Obviously this solution wouldn't be ideal for sites with sensitive data as the xml feed is exposed.


Drupal 7 db_query how to return regular array from varchar field

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

$arr2 = db_query('SELECT stats FROM {my_db} WHERE uid = :uid AND nid = :nid', array(':uid' => $usid, ':nid' => $noid))->fetchCol();

print_r($arr2[0]);


How do I add a child to an HTML Tag render element?

Please see the drupal API page on this.

A simple example could be:

// Shows how #prefix and #suffix can add markup into an array.
t('Using #prefix and #suffix') => array(
  '#markup' => '

',
  '#prefix' => '
',
  '#suffix' => '
',
),

or you could use children

t('using children demonstration') => array(
  '#markup' => '',
  'child1' => array('#markup' => '

'),
  'child2' => array('#markup' => '

'),
  '#prefix' => '
',
  '#suffix' => '
',
),


As when it comes to theming stuff, you should always ask your self: Can I do this with CSS? The answer in this case is yes.

label { float: left padding-right: 3px; }

Example

OR (probably best to go with)

label { display: inline }
input { display: inline }

Example 2

You will need to add the css code to your administration theme .css file.


Create custom signup block with mailchimp module?

In the end, this is what I did:

Installed the mailchimp module and connected drupal to a list in mailchimp using normal instructions and an API key that mailchimp provides.
Created a new custom module that creates and displays blocks using standard hook_block_info and hook_block_view code.
Created a very simple form with hook_form, with a companion submit function, hook_form_submit, and add this form to the block(s) created above.
In hook_form_submit, I open a connection to the mailchimp api with:

$q = mailchimp_get_api_object();

Then subscribe the user with:

$success = $q->listSubscribe($list_id, $email, $merge_vars, 'html', TRUE, TRUE);

The above functions are documented in the mailchimp api.

So, in the end, I'm not really using the Drupal mailchimp module for anything other than providing access to mailchimp api over a secure connection (the drupal site is running https). The main advantage of this approach is complete control over the look and feel of the forms that appear in the blocks, and the actions taken when a user submits.

Another advantage: Because I'm using hook_form_submit to control processing once the form is submitted, I can add the form location (using request_path()) to the merge variables that are passed back to mailchimp. That way, the form is the same on every page that it appears, but the location is passed back to mailchimp as part of the sign-up process.


How to remove inner div from create block in drupal 7

The markup you require removing comes from one or more template files. While i have no idea what theme you are using, ill assume its one that hasn't overidden the default template files..

If you go and get the file modules/system/region.tpl.php and copy it to your theme folder you can remove the markup you do not require. e.g. delete <div class="region region-footer-bottom-right">

To get rid of the rest of the markup you will have to override the block template in the same fashion, to only remove the markup from 1 specific block you can use naming suggestions here https://www.drupal.org/node/1089656

note: Flush the caches for the theme to pick up the presence of any new template files.


This is not an issue with the module.

The most likely cause of the problem is that your local system is missing gzip, so the backup and migrate module is unable to turn the tar-file into a gzipped tar file.

The command to do that is not tar -cvzf (which you've tried), but gzip. I.e.:

gzip 127.0.1.1-2015-01-12T17-23-50.sitearchive.tar

This should produce a valid 127.0.1.1-2015-01-12T17-23-50.sitearchive.tar.gz, but if you try this on the local system, it will probably fail telling you that it can't locate gzip.

The best fix would be to install gzip on the local system.

Alternatively, you may export the file to some system that has gzip, and do the gizipping there.


How to show dynamic text on node/add form with Panels (using AJAX)?

you do not need to use panels, just add an ajax callback on that form select field, where you add a node's body in the postfix of the field.


Nodes created on 1st date of the month are not showing up on Calendar

It's not clear if you are A> using a "date contextual filter" and "page by date" or B> you are simply showing content in a calendar.

If it's B>, check your date filter and make sure you have "greater than or equal to" set to ensure the first day gets included.


Get path parameter in views-view-fields--portfolio.tpl.php file

borrowed from here

// field_video_image is the name of the image field

// using field_get_items() you can get the field values (respecting multilingual setup)

 $field_video_image = field_get_items('node', $node, 'field_video_image');

// after you have the values, you can get the image URL (you can use foreach here)

 $image_url = file_create_url($field_video_image[0]['uri']);


What's the best way to add an entity (of a specific type) selector to a form?

If you're operating on an entity, you can just use an Entityreference field which will do it for you.

If not, then yes, write it yourself and use EntityFieldQuery. Just watch out, entityCondition('bundle') is broken for comments and taxonomy terms, and entity access is non-existent (so it will show all users instead of the non-blocked ones, etc).
Entityreference implements workarounds for this (until it gets fixed in core), so you can take a look and borrow that code if needed.


Do multi-level multi-value relationships work in a view?

Am I asking this view to do something views can't do, by having
  multi-value references 2 levels deep?

Yes, to my knowledge there is no way to go 2 levels deep for this scenario.

One possible solution, to work around this constraint, would be to use Views Field View and...

1) Create a team member view that uses the project nid as a contextual filter.

2) Add the project nid (content id) as field to your original view so you can pass it to the views field view.

3) In original view, add a views field, select the team member view you created in Step 1 and pass it the project nid (content id).


Disabling a custom module has fixed this.


When viewing a user, display their content profile

function MYMODULE_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'view':
      profile_load_profile($account);
      // Now $account will contains all profile data;
      // some code
      break;
    }
  }
}


Filter date from current date to upcoming 7 days?

In Views filters find your date field.
Now, in filter settings select "is between".
Choose "Enter a relative date" and enter "Now" in the first one and "+7 days" in the second field.


Install the Multilingual modules in admin/modules

Go to admin/config/regional/language and add the new language

Go to edit your View and click in Translate

Then click in edit

And go to edit the title


How do I place the registration form in the front page?

The user register form id is user_register_form. Please try it like:

$form = drupal_get_form('user_register_form');
print render($form);


You need to implement hook_cron() in your module and execute these tasks there.

Then, drupal will automatically execute these tasks during the default cron handling.

You probably have used drupal_set_message() only as an example but note that using that function in a hook_cron() implementation makes no sense because there is no user to read these messages. As an alternative, you could log messages with watchdog().


It's fairly simple:

Create a menu at http://mysite.com/admin/structure/menu/add
Add some links to it
Go to http://mysite.com/admin/structure/block and assign the automatically generated block for your new menu to your theme's footer region.

If your theme doesn't have a footer region you can add one by adding a line like the following to the theme's .info file:

regions[footer] = Footer

And then edit page.tpl.php to add the new region wherever it sits best in your HTML:

<?php echo render($page['footer']); ?>


You can used Rules, and/or Views Rules.

Here is the rule that you need to created:

Event: When a node from a content have been delete or updated.
Condition: based on role.
Action: message display if a node from an specific content type have been remove or updated


Problem in Recurring payment using money scirpts

If you set it to 'Persistent' in scope, then it will remain discounted for all payments in the series. 'Initial' is what you want, where only the first payment is discounted, sort of like a Trial amount.


How to remove ul li formatting from list of attributes in Ubercart order email template?

Not exactly what I was asking for, but I did find a workaround that works for the most part. I copied the uc-order--customer.tpl.php  file into my theme dir and added css for the ul to the head in that file. (display: inline-block and a few padding, margin, and list-style styles). The only issue now is the emailed order invoice. The CSS doesn't follow along into the email, so it's a bit of a mess. Open to any suggestions on how to handle that, or a better way overall.

EDITED TO ADD: I ended up copying the product line items from the uc-order--admin.tpl.php file. The attributes therein are not styled as a list, so it was a breeze to use that code.


How to modify the display of custom line items in the ADD To Cart Form?

You can add additional fields directly to the 'add to cart' form on a per item basis with the help of the Commerce Customizable Products module. This allows you to create additional custom line item types. When you create the field there is a checkbox under ADD TO CART FORM SETTINGS that will add these fields to the add to cart display.


Edit your product.
Go to features.
From the Add a new feature, Add both recurring fee and role assignment for your product.

Hope this helps.


Can I configure Send by Email to use CC instead of BCC?

You could try the hook_mail_alter() which lets you intercept emails used by drupal_mail(), but that's problematic since, as you mentioned, each email gets sent out individually.

There's a hook_print_mail_alter() invocation before the email is sent, but this is problematic too since $params doesn't have the email recipients.

The route I would take is to alter the email form submission handler with your own custom submission based off the print module's implementation:

/**
 * Implements hook_form_alter().
 */
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'print_mail_form') {
    $form['#submit'] = array(
      'MYMODULE_print_mail_form_submit'
    );
  }
}

/**
 * Submission Handler.
 */
function MYMODULE_print_mail_form_submit($form, &$form_state) {
  //@TODO: Implement your own email code.

  //print_mail_form_submit($form, $form_state);
}


Ok, I came up with some sort of solution, thanks to @clive.

function hook_preprocess_comment(&$vars){
    if (isset($vars['view'])) {
        $view = $vars['view'];

            if ($view->name == "my_view_name"){
            $vars['theme_hook_suggestion'] = 'comment__' . str_replace('-', '_', $view->name);
    }
  }
}

I tried to do $vars['theme_hook_suggestions'][] but those templates were never picked up.  Is it ok to directly set theme_hook_suggestion.

Really hope this helps someone else out there..


Painless way to import content from old custom CMS

"Painless" data migration? You're kidding, right? :)

There are numerous answers suggesting the Migrate module. It is certainliy an option, but one I've never liked. I've done dozens of projects with migrations of content from external systems into Drupal (sometimes from multiple external sources simulteneously), including projects with millions of pieces of content, and I'll argue 'til my death that a Batch API implementation in a custom module is the way to go.

No two migrations are the same. Each individual migration will involve 'proprietary' cleanup, data sanitization/changes, etc. The only way to have total control is with an entirely custom script. Don't settle for an easy "80% of the way there" via a generic tool and then struggle for weeks as you bash yourself against that 20% that the tool doesn't handle.

Do it custom, use Entity Metadata Wrappers, and track legacy <--> new content ids in a separate db table.

It may also be an option to simply 'dump' the existing content, markup and all, into a 'legacy' content type and call it a day without moving things into fields and complicating your life. You should sit down with the client and figure out exactly what they want/need, and what they're willing to settle for. Sometimes a simple solution that is just "okay" is a heck of a lot better than the multi-month project that's "awesome."


View of taxonomies connected to view of each taxonomy

With this solution yo can get the result with some struggle, but I have a better solution for you.
Create a list that show all product in categories. (If you do not need this,  skip this step.)

Create a view of product type
Add a relation to category (taxonomy you used in product display)
Add a taxonomy field (also images)
Group the result by category

Create a view with  path something like product/* and pass the category ID to it.

then add contextual filter on your category field,and get default value from the URL.

for getting better involve with views contextual filter read this article.
if you need more details tell me to provide it.


Site redirects to old URLs after moving to a new server

Maybe you can use this module:

Path Redirect (Drupal 6)

Redirect (Drupal 7)


How to create a panel for a argument path

I'm not sure what you are after. You just want the URL to look right, then all you need is Pathauto.

What you are asking however, is essentially how to tell Page manager to load content based on the title of the content. That could make sense, if it wasn't because you already load it by the ID, so loading it again would just be redundant.

If that's really what you want though, here goes:

Page manager doesn't know how to load nodes by title, so you will need to explain to it.

This is a called a Context.

See What are Ctools plugin (content type, access, etc), and how does one create them? for the basics of how to implement a ctools plugin. Look at the existing contexts in the ctools examples directory, and creating the context shouldn't be to hard.


Upload zip & unzip to multiple image field

I think your main goal is upload multiple image on a single upload and this goal you can achive via a module name 'Multiupload Imagefield Widget' https://drupal.org/project/multiupload_imagefield_widget.

This module provide a widget to select multiple images . For more info go through the module instructions.


Remove field attributes using hook_form_alter()

Insert the following into your custom module:

function YOUR_MODULE_form_alter(&$form, &$form_state, $form_id){
  switch($form_id){
    case 'YOUR_FORM_ID':
      $form['title']['#required'] => FALSE;
      break;
  }
  return $form;
}

That makes the title field optional. You can check the different form element types and the properties that go with them here: https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7

And you can read more about hook_form_alter here: https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_form_alter/7


SQL injection Drupal Core - Highly Critical - Public Service announcement - PSA-2014-003 issue

Yes, your site is vulnerable. If your network is stopping people accessing the Drupal site without prior authentication then you're (potentially) safe from those outside the network, but still vulnerable to those inside it.

As with all security issues, upgrade as soon as physically possible.


How to allow user to manually change language when using "Browser" Detection as a detection option?

The Selected language option comes with this description:

Changing the selected language here (and leaving this option as the last among the detection and selection options) is the easiest way to change the fallback language for the website, if you need to change how your site works by default (e.g., when using an empty path prefix or using the default domain). Changing the site's default language itself might have other undesired side effects.

This option is meant to be the last on the list and used only as a fallback.
If you give Browser option advantage on the list by placing it above the URL option the language will always be chosen by the browser criteria.
I'm guessing that there are cases where browser language might be not available in which case the URL option will kick in, but in most cases the URL option will not be used because Browser option will set the language and no options that come after it will even be evaluated.
It seems you need the Session option before the Browser option. This option should work with the Language switcher to add the parameter in the URL that will set the chosen language, but before the user selects something from the dropdown the Browser option will set the language.
Turn the URL option off completely if you don't need the language prefix to avoid confusion when the parameter is present. Having too many options turned on complicates the system unnecessarily and makes it more difficult to figure out what the causes are if there are bugs present.
I haven't tested this configuration. Language configuration can be tricky and you may need to do more adjustments and testing to get to where you want to be.


How can I get the submission ID in a custom submit handler?

To get the webform submission ID in a custom form handler, I used the following code.
function MODULE_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form_id== 'webform_submission_add_form') {
    $form['actions']['submit']['#submit'][] = 'MODULE_custom_submit_handler';
  }
}

function MODULE_custom_submit_handler(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $webform_submission_id = $form_state->getFormObject()->getEntity()->id();
 }


How to ensure emails are sent only once to users in a Views Block Operations (VBO) list?

You can adapt my answer with a "trick filed" on your content type in this (last) answer. Update "trick field" when your mail is sent the first time.
Why is my rule that reacts on event "After updating an existing user account" firing twice?
Then hide "trick field" modifying your "form-id" and field name with this solution (2nd answer) Is there a way to prevent a user from seeing a field on their user profile page?


How to remove suggestions for a input field?

Take a look at hook_form_alter. Also refer to the drupal FAPI, there are many form controls are available which you can use in a form.

For your case, below example will be helpful.

function example_form_alter(&$form, &$form_state, $form_id) {
  if($form_id === 'your_form_id'){
     $form['your_field']['#attributes'] = array('autocomplete' => 'Off');
  }
}

Other option is with JS.

Drupal.behaviors.exampleModule = {
  attach: function (context, settings) {
    $('input[type="text"]').each(function (i, input) {
      $(input).attr('autocomplete', 'off);
    });
  }
};