1) run query
ALTER DATABASE DB_NAME DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
on your data base

2) change line

  'collation' => 'latin1_general_ci'

in settings.php to

  'collation' => 'utf8_general_ci'

and line

  PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES latin1"

to

  PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"


How to save a checkbox config_object in the schema files?

You are creating your checkbox options as an associative array of node type (bundle) IDs as keys and their labels as values.

When this form is submitted, checked checkboxes submit as key => key. So the stored information (I suppose 'rss_url' in your question is intended to being 'mymodule_enabled_content_types') is similar to:

mymodule_enabled_content_types:
  article: article
  page: page
  custom: custom

As the keys of the submitted values are unknown before submission, and the values clearly are strings, this is a sequence of strings (compare https://www.drupal.org/docs/8/api/configuration-api/configuration-schemametadata#properties). The correct schema definition is:

mymodule.settings:
  type: config_object
  label: 'My Module settings'
  mapping:
    mymodule_enabled_content_types:
      type: sequence
      label: 'Enabled Content types'
      sequence:
        type: string

After changing your schema definition and rebuilding your caches, your form submit handler should work just fine and the configuration being saved using its correct data types.


Code for group programatically fields on edit form similar to Flexifield

Have you tried the first link on that page? To the dev version of CCK? I just had to do this very thing this morning. The dev version of CCK has an additional module included with it called multigroup. You create a new field of the multigroup type, then add all the fields you want to include in it. Set the number of repeats on the multigroup to unlimited, and you (or your users) can then add as many groups as necessary.


Views: Only show 3 largest values and their sum per user

If you don't want to build a custom module I would think Rules is your best bet. Also install Conditional Rules as what you will be doing will requires logic a bit difficult to accomplish with Rules alone.

I will create a Result content type that will hold the aggregated result for the day per angler, as well as entity references to the fish content type. Then, after the angler uploaded a new entry, the rule will cycle through the related fish types and do the Maths and store the result in the result field.


How do I install the commerceguys libraries?

Download composer_manager into your modules directory.

From the Drupal root directory, initialize composer_manager, and run it for the first time:

php modules/composer_manager/scripts/init.php

composer drupal-update

composer dump-autoload

This will download the required libraries into the root vendor/ directory.

Enable modules now.


If your database connection on settings.php looks like

$databases = array(
  'default' =>
  array(
    'default' =>
    array(
      'database' => 'mydatabase1',
      'username' => 'root',
      'password' => 'root',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
  'test' =>
  array(
    'default' =>
    array(
      'database' => 'mydatabase2',
      'username' => 'root',
      'password' => 'root',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

The following command will back up both the data bases;

drush sql-dump --database=default --result-file=default.sql; drush sql-dump --database=test --result-file=test.sql


Load a block contents dynamically / via AJAX?

You can get the cookie from the request, see Can't find cookie for validation in EventSubscriber. Set the context and trigger the kill switch like in the code example and it should work. But this is not good for performance. So I would deliver an empty block container, attach a js library to the block, get the cookie value client side and then initiate an ajax request to get the block content.

See the code of the module Ajax Block as example how to lazy load a block client side: https://git.drupalcode.org/project/block_ajax


Debugging a custom module with XDebug and PHPUnit

xdebug must be added in the PHP env. Acquia Dev Desktop, DrupalVM, Vlad and other VMs come with it out of the box. As for setting the connection up, IDEs like PHPStorm, Atom and VSCode have walkthroughs on how to do that.

For PHPUnit in Drupal 7, it is doable, but not easy. There are a few articles out there that can show you how, but they may be dated. There are two paths, using SimpleTest, and using PHPUnit on it's own.

See:

https://www.lullabot.com/articles/write-unit-tests-for-your-drupal-7-code-part-1
https://www.drupal.org/node/811254
https://tlattimore.com/blog/using-phpunit-with-drupal-7/
https://www.previousnext.com.au/blog/drupal-8-now-phpunit-tests-drupal-7
http://patshaughnessy.net/2008/12/12/writing-your-first-phpunit-test-in-drupal
https://devblog.more-onion.com/content/writing-unit-tests-drupal-7
DrupalUnitTestCase

To be honest, I got going with the articles from 2008 and 2012 respectively. It requires a bootstrap file (that requires and bootstraps Drupal) that you can require in your unit test classes - this allows you to use PHPUnit bare metal.

However, you should really evaluate the tests you are doing. If they truly are unit tests and you're familiar and comfortable with PHPUnit, go for it. But if you can achieve it via SimpleTest, that may be an easier road in Drupal 7. DrupalUnitTestCase is meant for that.


Using computed field to format phone numbers?

Try Masked Input module. It allows you to create a text field with mask that you can setup custom (e.g. 999.999.9999). When user enters info into the field with masked input, the information entered is formatted automatically and stored into database with that exact format. So the output of formatted information becomes that much easier.

One drawback of this module is that it provides formatting only if user has JS enabled in the browser. If JS is disabled, you will rely on user to enter info in the desirable format. You can also ask the user to provide info in specific format by entering field description as a fallback (e.g. "Enter your phone number as follows - xxx.xxx.xxxx).
I've used this module on websites with big user base, and I can tell that users very rarely have JS disabled when they fill up forms.


Specify the reason for the refusal of publication node

Looks like you were looking for the editablefields module (and some scripts to attache a link). Here is an excerpt from its project page:

  ... allows CCK fields to be edited on a node's display (e.g. at node/123), not just on the node edit pages (e.g. node/123/edit). It also works within views etc. Anywhere a 'formatter' can be selected, you can select editable (or click to edit).


How to limit the terms of the view to the terms used?

If doing it manually is acceptable you can do it on the Exposed Filter Settings by ticking the Limit list to selected items and then selecting only the 10 tags from the list above (hold Ctrl key to add to the selection). This works if you'll always or for long periods of time need only those 10 tags.

If you want Views to filter automatically and only show what's within the results without you having to choose the tags manually you have to use the Contextual filter instead of the Exposed regular Filter. Contextual filters are under Advanced options.
Add the Contextual filter for the same field "Tags" and configure it:
When the filter value is NOT available
Display a summary
Format List
Base path (you must enter the Page path if this isn't the first Page Display in your Views)
Display record count with link
More
Transform spaces to dashes in URL
Adjust the options for when the value is not available to your needs (Tags Taxonomy term etc.).
This way you get a list of term IDs that link through to a list of nodes tagged with those terms. That is because the Tags field only stores the TID information, not the term name. When you first load the page you only see the Summary, no results, you have to click through to see the results. But if you create the Summary as Attachment on a Page Display you can get it both ways, the Summary and the Results at the same time (keep the path the same).
But you probably want the term name to be displayed instead of the term ID. In that case remove that Contextual filter, and add the one for Taxonomy term Name, but you need a Relationship first for that information to become available.
Add a Relationship Taxonomy term referenced from field_tags (or whatever the field is called in your case), require it becasue you don't want summary results without tags!
Then add a Contextual filter Name from Taxonomy term Category, it will use the Relationship we created, and configure it like the above Contextual settings.

Alternatively you can use an additional module, this one did it in D7 but not yet ported to D8: Views Selective Filters.
Facets module provides an easy filtering interface from what's in the results.


What causes the error "Call-time pass-by-reference has been deprecated?"

The cause of the "Call-time pass-by-reference has been deprecated in
 _registry_check_code()" is a file that holds a class being loaded that contains a variable that is passed by reference that is not in a function definition.

Drupal 7 requires PHP 5.2 or higher and PHP 5 always passes objects into functions by reference

This was a difficult bug to find because enabling a feature of the Date Views module is what triggered it. However, the problem was in the Workbench Moderation module. What I did was set the breakpoint in the debugger on function drupal_set_message() then worked back through the call stack till I found the offending variable.

Problem was not exactly in the Date module but was nonetheless triggered by the Date module in line 53 of date_views_fields.inc.

// If we don't have a filter handler, we don't need to do anything more.
if (!$handler = views_get_handler($table_name, $field_name, 'filter')) {
  continue;
}

This would iterate through all the view's handlers including workbench_moderatioin_handler_filter_user_can_moderate which passed a variable by reference not in a function definition,     parent::options_form(&$form, &$form_state);. Simply the Workbench moderation module needs to be patched to reflect changes in code in PHP 5.3


How do I get Drupal to load a node instead of looking for the index.php outside of drupal in a subfolder

You'll need to remove the original file, or make it unreadable by your webserver. Drupal is basically a big 404-handler; if the file exists it will get loaded before the webserver looks for the default index.php which then bootstraps Drupal.

That, or check to make sure you don't have APC or similar opcode cache installed.


How to hide the "Add comment" link in the teaser?

You can accomplish this with a custom module, as I found here https://drupal.org/node/1257788

Here is the code you'll need:

function MODULE_node_view_alter(&$build) {
  if ($build['#view_mode'] == 'teaser') {
    // remove "add comment" link from node teaser mode display
    unset($build['links']['comment']['#links']['comment-add']);
    // and if logged out this will cause another list item to appear, so let's get rid of that
    unset($build['links']['comment']['#links']['comment_forbidden']);
  }
}


Add JS to specific pages AFTER all other JS

Using the following in my template.php file for my theme, I achieved what I wanted to do.

function MY_THEME_preprocess_page(&$vars) {
  if (isset($vars['node']) && $vars['node']->type == 'venue') {
    drupal_add_js(drupal_get_path('theme', 'MY_THEME') . '/js/mapstyle.js',
    array('weight' => 15));
  }
}

I couldn't add the JS to my .info file as it would add to all pages, so I used the drupal_add_js fallback in template.php, and the now the error no longer shows on a page that doesn't have a GMAP on it.


Try Webform Conditional module, this has some extended conditional rule on radio button and other form elements:

  Webform already has support for conditional fields on multi-page forms. For example Field C on Page 2 can be dependent on Field A on Page 1. This module adds the ability to have conditional fields on the same page. This module adds the ability to have Field B on page 1 be dependent on Field A also on Page 1.


Is it possible to create a graph out of collected information stored in a Drupal database?

You can use Charts & Graphs, Charts or View Charts module. Through this you can show information in the form of graph.


I manage to install Drupal 8 with Drush after creating the project with Composer from drupal-composer/drupal-project. Steps I take are as follows:

Create project with dev dependencies:

composer create-project drupal-composer/drupal-project:8.x-dev directory-name --stability dev --no-interaction

Create site-database for the project.
Run inside web folder:

../vendor/bin/drush site:install standard --account-name=admin --account-pass=admin --db-url=mysql://username:password@localhost/site-database -y


There is a hook for that...

hook_mail_alter()

For an example see webform_mail_alter()


If the referenced field is a taxonomy term, you need to specify what property to show (usually the name). So your solution should be like

{{ node.field_field_data_provider_ref.entity.buisness_property_type.name.value }}

or, as NoSssweat said, with correct spelling (check your fieldnames)

{{ node.field_field_data_provider_ref.entity.business_property_type.name.value }}

also, I assume your machine name is field_business_property_type, so its

{{ node.field_field_data_provider_ref.entity.field_business_property_type.name.value }}

also, your field field_field_data_provider_ref is named field_data_provider_ref, then it's

{{ node.field_data_provider_ref.entity.field_business_property_type.name.value }}

Check your field names!


User register and login functions are called from hook_form_alter, but user isn't logged in

If a redirect is happening after print('x') then it will be lost. dmp() should show up however I prefer using Devel Debug Log in these instances so you know if then code is running then it will output to the log.

You can use the function ddl('log message') or ddl($array) and then check the report of what has been output once your code has run.

I realise this isn't actually answering your question but may make debugging easier...


Link product variations to its own pages (e.g. blue hat to blue hat variation, etc.)

I solved it by using the following rewrite results: [path]?id=[product_id].


What happens to the return array of hook_views_default_views after the function finishes?

ADDITION/CORRECTION:

For Views in Drupal7, the cache is built up by Ctools and its _ctools_export_get_defaults() function that is defined in .../ctools/includes/export.inc.  It is called many ways down the line from views_get_all_views():

function views_get_all_views($reset = FALSE) {
  ctools_include('export');
  return ctools_export_crud_load_all('views_view', $reset);
}

where ctools_export_crud_load_all() eventually calls it.  The kicker for grep'ing around to find this is that it uses $function = $module . '_' . $export['default hook']; to cycle through all the modules that implement the hook, and that is defined in views.install:

'default hook' => 'views_default_views',

so it certainly took a bit to find but it is a nice api way to allow all sorts of modules to export objects in a defined fashion.  I won't include the code here as it's a bit more verbose than the D6 version below but do let me know if you need any other help on this.

MY BAD:  The following for D6....D7 answer above but I'll keep this in here if anyone in D6land ever needs an answer:

If what you are asking is where does Views build up its cache of default views, it does this via the _views_discover_default_views() function found in .../views/includes/cache.inc:

/**
 * Scan all modules for default views and rebuild the default views cache.
 *
 * @return An associative array of all known default views.
 */
function _views_discover_default_views($reset = FALSE) {
  static $cache = NULL;

  if (!isset($cache) || $reset) {
    $index = views_cache_get('views_default_views_index', TRUE);

    // Retrieve each cached default view
    if (!$reset && isset($index->data) && is_array($index->data)) {
      $cache = array();
      foreach ($index->data as $view_name) {
        $data = views_cache_get('views_default:' . $view_name, TRUE);
        if (isset($data->data) && is_object($data->data)) {
          $cache[$view_name] = $data->data;
        }
      }
    }
    // If missing index, rebuild the cache
    else {
      views_include_default_views();
      $cache = array();

      foreach (module_implements('views_default_views') as $module) {
        $results = call_user_func($module . "_views_default_views");
        if (!empty($results) && is_array($results)) {
          foreach($results as $name => $view) {
            // Only views with a sufficiently high api version are eligible.
            if (!empty($view->api_version) && $view->api_version >= 2) {
              // Do not cache dead handlers.
              $view->destroy();
              if (!isset($cache[$name])) {
                $cache[$name] = $view;
              }
              else {
                watchdog('view', "View name '@name' is already taken", array('@name' => $name), WATCHDOG_ERROR);
              }
            }
          }
        }
      }

      // Allow modules to modify default views before they are cached.
      drupal_alter('views_default_views', $cache);

      // Cache the index
      $index = array_keys($cache);
      views_cache_set('views_default_views_index', $index, TRUE);

      // Cache each view
      foreach ($cache as $name => $view) {
        views_cache_set('views_default:' . $name, $view, TRUE);
      }
    }
  }

  return $cache;
}


You cannot call user_load_by_mail function in hook_boot because this hook is called before the theme, modules, or most include files are loaded into memory. It happens while Drupal is still in bootstrap mode.

To get this function work you need to add this code before calling user_load_by_mail function:

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);


A quick look at the code shows that this is being created via:

function theme_fbconnect_login_button($text, $attr) {
  return '<fb:login-button ' . drupal_attributes($attr) . '>' . $text . '</fb:login-button>';
}

which shows that Facebook is creating the button, and thus suggesting you are stuck with what you got.  Now, there may be some hidden attribute incantation to change the button, but given how brand conscious Facebook is, I doubt they will allow you to change it up using their SDK.


Trying to create a new prebuilt list in webform

When you are building option list in code, don't use human-readable syntax. Use machine-readable one. So instead of this:

$options[] = "1|city2 - Address1 - Floor - Building Name";

you should use this:

$options[1] = "city2 - Address1 - Floor - Building Name";

Second very bad thing you did is:

?>

<?php

It is highly discouraged to ever close php block. Everywhere except template files you should have <?php as the very first 5 bytes, and no ?> at all. What you apparently did was outputting few empty lines to the user's screen where nothing expected them.


How to give access to inactive user profile?

The View Profiles Permissions module will work for that purpose: https://www.drupal.org/project/view_profiles_perms.

In order for this to work, you will also need to give your blocked users a Role.

It is not the primary function of the View Profiles Permissions module, but there is more information about this specific issue here: https://www.drupal.org/node/2490934

Additionally, You can use the Rules module to automatically assign a role to users when they become blocked.

Steps:

Install and Enable the View Profiles Permissions module
Create a role called "Blocked"
Give permissions to anonymous users to "Access to Blocked profiles"
Assign the "Blocked" role to all users who are blocked (aka Inactive, Old, Disabled)
Extra Credit: Install/Enable the Rules module and a new Rule that automatically assigns the Blocked" role to users when they become blocked.


features for same content type but different structure collide in multi site

Diana,

Why not move the features into their specific site directories?
Then they dont 'see' each other in the other sites.

For example:

Feature 1 is located in sites/site1/modules/feature1

Feature 2 is located in sites/site2/modules/feature2

Then they are "unaware" of each other.

Would this work?


How do you theme a content type's create/edit form?

You have two options.

option 1: using the template.php of your admin theme

Pick the right theme to customize.  Remember that by default, drupal 7 uses a different theme for administration and there is a setting under admin/appearance that says what your admin theme is and if content editing should use the admin theme.  look at this setting and figure out whether you want to customize your main theme or your admin theme.
once the theme has been identified, if that theme is a core theme and not one that resides in sites/all/themes or sites/something.com/themes, you may want to create a base theme rather than changing the existing theme.  it is a bad idea to change a core theme anyways.  Even if it is a downloaded theme, it makes sense to create a subtheme so that you can keep upgrading the downloaded theme when new versions come out.
(optional) to create a subtheme.  lets say, your admin theme is seven and it is also being used for content editing, simply create a folder called my_seven under sites/all/themes. next add a my_seven.info under the newly created my_seven directory with the following contents

base theme = seven
name = My Seven
description = My simple one-column, tableless, fluid width administration theme (child of Seven).
Now add a file called template.php under the same folder with the following contents.  please note that the form id is strictly derived from your content types machine name.  the template name however can be anything you please but -node-form looks like a good convention to follow.

<?php

function my_seven_theme() {
  return array(
    '<my_content_machinename>_node_form' => array(
        'arguments' => array('form' => NULL),
        'template' => '<my_content_machinename or anything else>-node-form',
        'render element' => 'form',
    ),
  );
}

now create a <content_type_machinename>-node-form.tpl.php file with the following contents to test if things are working.. once you see the custom form, just change the tpl.php to your heart's content. pick a custom field other than title to be sure it is working fine.. ideally pick something that is not a simple text field.  a term reference field type would be a good candidate to ensure that your subtheme is working ok.

    <?php print drupal_render($form['title']); ?>

    <?php print drupal_render($form['field_<my_field1>']); ?>

clear your theme registry cache (actually not required for the first time a theme is made use of but do it anyways)
set the new subtheme as the admin theme using the admin/appearance page.
edit a content or create a new content and you should see your modified form.

option 2: using your own drupal module to customize the form

create a new folder called custom_content_forms under sites/all/modules
create a custom_content_forms.info file with the following contents

name = My Custom Content Forms
description = A trivial module to customize my content entry forms such as smartphone
core = 7.x

create a custom_content_forms.module with the following content

<?php

function custom_content_forms_theme() {
    return array(
        '<contenttype_machine_name>_node_form' => array(
            'template' => '<contenttype_machine_name>-node-form',
                'render element' => 'form',
        ),
    );
}

now create a <content_type_machinename>-node-form.tpl.php file with the following contents to test if things are working.. once you see the custom form, just change the tpl.php to your heart's content. pick a custom field other than title to be sure it is working fine.. ideally pick something that is not a simple text field.  a term reference field type would be a good candidate to ensure that your subtheme is working ok.

    <?php print drupal_render($form['title']); ?>

    <?php print drupal_render($form['field_<my_field1>']); ?>

go to administration and enable the new module and you should see your customized form when you add or edit content of the targeted type.

NOTE: If you customize using both mechanisms, drupal will prefer the theme over the module.

EDIT: the above will only produce the fields.  you wont get the node settings menu and submit and preview buttons by default.  if you just add a

<?php print kpr($form); ?>

on the page (devel module needs to be enabled for kpr to work) to produce a dump of the $forms array.  You will see that you can get these things on your form page quite easily by adding the following to the tpl.php

<?php print drupal_render($form['additional_settings']); ?>

<?php print drupal_render($form['actions']); ?>


How to control Block revisions before being published?

I would use the Bean module for this. Here is a quote about its project page:

  Think of a Bean as a method to provide new types (compared to node this would be a content type) which then provides an add content interface to create as many blocks as you require (see screenshot below). The bean content can then be placed around the site just like any other block.

The Bean module also works great in combination with the UUID and UUID Features Integration modules. On top of that, after you become familiar with the Bean module, you might find other cases in your site where you also want to use the Bean module.

Moreover, by using Beans (i.e. entities), you qualify also for considering the Content Publishing System module (CPS for short) ... from commonly known "merlinofchaos". Here is an excerpt from that project page:

  ... CPS is a radical way of handling revisions for entities. It takes total control over revision management for all supported entities. For CPS-enabled entities, the revision tab is completely replaced and users are not allowed to manually create or move around revisions.

The video tutorial Drupal Bean module tutorial - using Bean Admin UI provides a great introduction to really understand the power of this module, and the kind of things you can do with it (by only using site building techniques, no custom coding involved). It also shows how the Bean module transforms Drupal blocks into fieldable entities.

A few more interesting issues related to all this:

bean workflow (published-deploy, unpublished-nodeploy)
Bean revision workflow support?


Send to 403 page if all Selection Rules aren't met for all Variants

I took care of this using hook_node_view(). This will only run if it is using the node system.

/**
 * Implements hook_node_view().
 */
function mymodule_node_view($node, $view_mode, $langcode) {
  if ($node->type == 'collection' && $view_mode == 'full') {
    drupal_access_denied();
    drupal_exit();
  }
}


How to change DateTime field value on form submit

The form value need to be an call DrupalDateTime, so you can directly pass $date as value.


Drupal.settings.mymodule is not an object

It should be:

drupal_add_js(array('mymodule' => $vars), 'setting');

But ideally you'd be using a render array instead, and loading the settings/files into the page with the #attached method.


Creating Number fields (integer and decimal) manually in code for custom forms

After some googling and a bit of thought of how I've used stuff in the past. You're confusing a FAPI element with a Field Widget. They are not the same thing, this has been discussed before on Drupal.StackExchange. And is fully answered there in terms of why they are different.

I think your easiest solution is to create your own #element_validate function and not rely on the validate function provided directly by number_field_widget_validate -- but I would copy its guts essentially and create your own validate function from it. The preg_replace is failing because your FAPI element is not a Widget and has no $field['settings']. That's what I think is going on.


How do I make a checkbox form initially have all options checked?

The actual form element values when selected are always the keys of what you have inside $options. You also can see that when inspecting the markup. So simply use '#default_value' => array_keys($options) to have all options preselected.
$form['search_block_type'] = [
  '#type' => 'checkboxes',
  '#title' => t('Content types'),
  '#description' => t('Select content types'),
  '#options' => $options,
  '#default_value' => array_keys($options),
];


I would check for File IO; what does profiling your site tell you. I had similar issues and created the http://drupal.org/project/imageinfo_cache module and my views performance improved a lot by reducing file IO.

Seeing that your on shared hosing, checkout this http://kpayne.me/2012/02/04/use-register_tick_function-to-profile-your-code/


Custom webform component for displaying a list of nodes

To answer my own question. My solution was to add a 'Add to Cart' button on the node which stores that node to the session. I created a new webform component based on textarea that is readonly and lists all nodes that the user added.


Token [commerce-order:payment-method-information] does not display anything

A couple of things.

Have you updated removed the text in the Information field on the payment's configuration page:

Do you have a filtered_html text-format? Is it configured correctly?
If you're not using this in tandem with Commerce Message, you'll need to be using it.


Is there a way to do text substitution within fields in Views?

Have a look in your view under Advanced -> OTHER -> Theme: [Information].

You'll see each field can be themed separately either across the board or in a set of themes, or on a specific theme, pick whichever file name best suits your needs and add a new file to your theme's template folder with that name.

You can use the link on the field name in that window to grab the default starting point for that field and then edit it.

Once you've created the file and put the default text in it, start playing around with preg_replace(), this uses regular expressions to replace certain characters.  Here's a starting point, it replaces hyphens and underscores with spaces in the $output variable (I think. My regex is a bit shaky):

preg_replace('/-|_/',' ',$output);


I'd suggest you follow the official install instructions here after removing your current install - http://docs.drush.org/en/master/install/

When you have it installed then navigate to your home folder:

cd ~/
ls -lash

At this point your .drush folder should have your user as owner (not root)

If it doesn't then run

sudo chown myusergoeshere:myusergoeshere .drush -R

You can run ls -lash again and confirm the right user and group.

You should now be able to run drush without using sudo.

The reason you get that error is because when you installed it the system created the folder using the root user in your home directory so as your user you don't have permission to modify the folder.


Views selective filters show terms hierarchy

I realised the BEF desired option "Nested checkboxes" was missing for all selective filters. Since into  better_exposed_filters_exposed_form_plugin.inc, the missing option depends on :

if ($bef_nested) {
  $display_options['bef_ul'] = t('Nested Checkboxes/Radio Buttons');
}

So I added the following :

/* line 314 */
if ($filter instanceof views_handler_filter_selective) {
  $bef_nested = TRUE;
}
/* line 493 */
if ($bef_nested) {
  //...
  $bef_options[$label]['more_options']['bef_select_all_none_nested'] = array(
    '#disabled' => !$filter instanceof views_handler_filter_selective &&(!$filter->options['expose']['multiple'] || !$filter->options['hierarchy']),

I know this is a very quick hack and should be improved for general use. Alternate proposals are warmly welcome.

Last, I had to patch also Views selective filters handler, resulting in :

case 'HCHY':
  $options = array();
  //get remaining terms tids
  $remaining_terms = taxonomy_term_load_multiple(array_keys($oids));
  $tids = array();
  foreach ($remaining_terms as $term) {
    $tids[$term->tid] = $term->tid;
  }
  //get vocabulary tree
  $anyterm = array_shift($remaining_terms);
  $tree = taxonomy_get_tree($anyterm->vid);
  if ($tree) {
    //we flag the terms to avoid displaying them more than once
    $flagged = array();
    //we keep tree items if they match with current selection
    foreach ($tree as $trm) {
      if(in_array($trm->tid, $tids ) && !in_array($trm->tid, $flagged) ){
        //so we always keep its parents displayed
        $parents_all = taxonomy_get_parents_all($trm->tid);

        if($anyterm->vid == '3'){//country vocab, Three levels taxonomy
          switch (count($parents_all)) {
            case 3:
              $parent = $parents_all[1];
              $gd_parent = $parents_all[2];
              break;
            case 2:
              $gd_parent = $parents_all[1];
              break;
            default:
              break;
          }
          //Add the gd_parent to options
          if(!in_array($gd_parent->tid, $flagged) && !is_null($gd_parent->tid)){

            $gd_parent_depth = get_term_depth($gd_parent->tid)-1;
            $choice = new stdClass();
            $choice->option = array($gd_parent->tid => str_repeat('-', $gd_parent_depth) . $gd_parent->name);
            $options[] = $choice;
            $flagged[] = $gd_parent->tid;
          }
          //Add the parent to options
          if(!in_array($parent->tid, $flagged) && !is_null($parent->tid)){

            $parent_depth = get_term_depth($parent->tid)-1;
            $choice2 = new stdClass();
            $choice2->option = array($parent->tid => str_repeat('-', $parent_depth) . $parent->name);
            $options[] = $choice2;
            $flagged[] = $parent->tid;
          }
        }

        //last, add the term itself to options
        $choice3 = new stdClass();
        $choice3->option = array($trm->tid => str_repeat('-', $trm->depth) . $trm->name);
        $options[] = $choice3;
        $flagged[] = $trm->tid;
      }
    }
  }
  $oids = $options;

/*
 * Returns a term depth (https://www.drupal.org/node/886526#comment-7708315)
 */
function get_term_depth($tid) {
  $limit = 5;
  $depth = 0;
  while ($parent = db_select('taxonomy_term_hierarchy', 't') ->condition('tid', $tid, '=') ->fields('t') ->execute() ->fetchAssoc()) {
    $depth ++;
    $tid = $parent['parent'];
    if ($depth > $limit) {
      break;
    }
  }
  return $depth;
}

Both are necessary, usual nested checkboxes from BEF do not work as is. This might be useful for some of you.


What qualifies as "active development" on drupal.org?

If you have edit permissions on a project, you see that it is a vocabulary:

The link is to Maintenance of your project.  In other words, it is essentially an honor system that the project creator sets.  Unfortunately, developer loses interest in a project they also tend to lose interest in maintaining the webpages and documentation.

Clive has summarized the rest.


What is the best order of content deletion on Drupal sites?

Yes, delete content first, before you delete the content type. It won't actually break anything in core Drupal if you do delete the type first, but you'll end up with orphaned content; which can be a pain.

Beyond that it comes down to what custom/contrib modules you have installed, and how they're being used. There are hundreds of modules that make use of nodes/content types, all in different ways, so whether or not you would need to do anything specific for each of those depends on the module itself, and what it's expecting.

For example, deleting content and content types may or may not break a particular View, depending on how it's configured (maybe there's a custom preprocess function relying on the content type field not being empty).

Deleting a content type provided by a Feature might break something in that feature if there's custom code relying on it.

Blocks don't have any relation to nodes/content types by default, so if you have something installed which connects them, you might need to do something specific to avoid that module producing errors.

TLDR; there's no single answer - list out the modules you have installed, work out which ones of those have interaction with nodes and content types, and come up with a basic plan of action for each that you follow before deleting.

If that's too much work, then just make sure you remove everything in your site that relates to those nodes or content types before deleting them.


In the switch statement you provide, you are switching over $environment variable. It sounds like it will never be passed a URL or 'custom page' value.

You are also trying to use $node object but you have not loaded it from your code. You are also not passing $node as an argument. Also an $adobe_dtm variable is used but never defined. Plus, you are using = to do an equality check, you need == or ===. = is assigning 'my_node_id' to your variable instead of compare it.

In order to have a $node object present in this function, you need to do one of two things to get it:

$node = menu_get_object('node');
$node = node_load(arg(1));

Then you can just add this after the switch statement:

function module_script_src($environment) {
  $script = '';
  $script_id = variable_get('script_id', '');
  $script_hash = variable_get('script_hash', '');

  switch ($environment) {
    case 'prod':
      if ($script_id && $script_hash) {
        $script = '//example.com/' . $script_id . '/lib-' . $script_hash . '.js';
      }
      break;

    case 'dev':
      if ($adobe_dtm && $site_hash) {
        $script = '//example.com/' . $script_id . '/lib-dev' . $script_hash . '.js';
      }
      break;

  }

  if ($node = menu_get_object('node')) {
    if ($node->nid == "my_node_id"):
      $script = '//example.com/' . $script_id . '/custom-' . $script_hash . '-.js';
    }
  }

  return $script;
}

You may need to think through the cases involved in building the script value. It looks like the switch statement is not even necessary, because $script value is basically the same - in which case you can clean up the code by simplifying it.


Automate creation of taxonomy terms for use with migration module

depends when you want to create them, in a new site or importing them into an existing one?

If you're building an install profile you could write an install script to create the taxonomy and terms as you need.

If you're trying to export/import into existing sites then it might be a bit harder.

features can't export taxonomy terms by itself because they have sequential ID values and so don't have a UUID that can be safely ported across sites.

that said, there are other modules out there helping to fix that problem - http://drupal.org/project/uuid is somewhere to start your research. Fair warning, you might have test a few patches for existing modules to get the solution you're after..


You can use the Pathauto i18n module:

  This module provides functionality to create aliases for each
  language. Also this module will be helpful, if you use field
  translation and you want show node on all language with paths,
  different from node/nid.


Smart way to compare drupal instance files with official release to search for modified files

The Hacked! module is exactly what you're after:

  This module scans the currently installed Drupal, contributed modules
  and themes, re-downloads them and determines if they have been
  changed. Changes are marked clearly and if the diff module is
  installed then Hacked! will allow you to see the exact lines that have
  changed.


hook_form_form_id_alter doesn't save data by default

hook_form_form_id_alter only alters the form object for presentation / behavioral changes on existing forms. It doesn't alter processing or storage for existing forms.

For that you'll need to add a custom submission handler, or use the Form UI to create new custom user fields if you don't need custom processing/storage needs.


Drupal + Moodle SingleSignOn logout issues

$cookie_domain can only be set to a domain that you want the Set-Cookie header to specify. This doesn't include protocol or path, just the domain with a leading dot (e.g. ".example.com"). If you leave $cookie_domain commented out, the browser will default to the domain that you requested it on.

If you need to access a Drupal site by IP when its cookie is set to another domain, you can create a subdomain on your hosts file that maps to the IP.

128.79.128.44 dev.example.com

Once that's saved to your hosts file, you should be able to browse to http://dev.example.com/ and have your web browser send the relevant cookies (assuming the cookies of domain are set to "example.com").


Problem in admin login, showing blank page in drupal 7?

After RND I found that "WSOD" or "Page not found" error occurred due to two reason.

Either Clean URL  is disable : If we want to check that Clean URL is enable or not then in URL "/?q=user/login" add this, if page shown it mean that Clean URL is disable.
Cache not clear : If your login page is working properly then login through admin & clear Cache.

NOTE : After work on admin part try to log-out a/c. Sometimes due to this reason some unconditionally error occured.


In Drupal 7 you can acheve this using the Commerce feeds module.
Also check this tutorial.

I couldn't find anything similar for Ubercart; maybe back-porting the Commerce feeds module is the only way to go.


Display all nodes posted on a certain month and day between 1990 and 2014

The custom module method is:

$nodes = node_load_multiple(db_query("SELECT nid
    FROM node
    WHERE MONTH(FROM_UNIXTIME(created)) = 3 AND DAY(FROM_UNIXTIME(created)) = 30 AND
    YEAR(FROM_UNIXTIME(created)) BETWEEN 1990 AND 2014")->fetchCol());

As far as I'm aware this isn't possible using the views UI so you would have to use hook_views_query_alter to get this working using views.


Filefield Path uses hook_entity_insert() to operate with file directory. The hook_node_insert is called before hook_entity_insert, so the file isn't processed yet there.
See: https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_save/7

module_invoke_all('node_' . $op, $node);
module_invoke_all('entity_' . $op, $node, 'node');

You should use that hook as well. Just make sure, your module have higher weight than ffp. (Check (and increase if necessary) the weight field of your module in the system table.)


How do I fix a site after I removed a module?

Run the following query.

select info from system where name = 'module_name';

You will get a blob. Within this blob look out for text after version. You can find the version of the module here.

Download this version of the module. Place it in sites/all/modules folder(you can also find out the previous location from the file-name field in system table), uninstall the module. Now delete the module.


Keyword research does not find any keywords under keyword stats

Keyword research is because of Keyword Research Module, which might have installed as suggestion by SEOTools module.

The report you are looking for is supposed to be pull form third party tools, or to be imported from google, which basically will help you deciding what keyword to use on your site.

Watch this demo for better understanding if you have not watched it yet.
- http://getlevelten.com/tools/contentanalysis/keyword-research/drupal/screencast

Please follow the module installation instructions. Module page says

  To get full reporting with integrated keyword statistics you will need
  to connect to or import from a 3rd party data source. The module will
  work without a 3rd party data source, still providing tools for
  organizing site keywords and tagging nodes and providing links to
  external tools for assessing keyword statistics. Currently the Keyword
  Research module supports:

Wordtracker - premium keyword research service with a free demo key that provides up to 15 suggested phrases per API call.
Google Keyword Tool - a free tool but data must be imported via file download
WordStream (via WordStream module) - freemium service. Free account provides 200 API calls/mo
Scribe SEO (via Scribe SEO module) - paid service starting at just $17/mo.


How to run entityfieldquery on all fields in node that reference users

Can you try rephrasing your question? It is not clear what you are trying to accomplish. Do you want to load all nodes that use the same field to reference a user?

If so, you would use the fieldCondition() method. Something like

->fieldCondition('field_name', 'target_id', $uid)

See https://api.drupal.org/api/drupal/includes!entity.inc/function/EntityFieldQuery%3A%3AfieldCondition/7 for more information.


When should I be using database transactions?

When you're running multiple queries in the same function/context that change data in the db, and the failure of any one of those queries would leave your data in an inconsistent state...that's when you should be using a transaction.

To the best of my knowledge there's no point in wrapping single queries in a transaction (it seems redundant. The query will either fail or succeed and you can catch those on an individual basis). Even if you're running multiple queries that won't leave data in an inconsistent state should one of them fail, I would say the same thing goes. You can catch errors for each query individually, and fail/continue gracefully.


Center the open layer map when in edit mode

you need to enable placeholderlayer in openlyers map with a marker of your choice. and then in behaviours you need to zoom to layer and enable placeholder layer and save.


What is the difference between the Load and Render objects in Devel?

The "Load" tab shows the output of node_load(), while the "Render" tab shows the output of node_view(). In the first case, the output is a node object; in the second case, the output is an array as accepted by drupal_render().


Receiving notifications when user edits a node?

Newer versions of the Workbench Moderation module integrate with Rules.  I am not sure if the patch is in the stable tree, or whether you need to use the dev version, though.

Assuming you have a version that supports this, then

add a new rule
for the reaction, choose Node: After moderation transtion
for the action, choose Send mail
if needed, you can add conditions based on the old and/or new moderation state.

After that, just configure the conditions and the email that gets sent out.


Show a field to logged-in user in Drupal 8 views

If you want to hide the price field globally to anonymous users, consider using something like field permissions.

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

This could potentially hide the price in any context it is displayed.

If you need to use twig, other solutions include overriding the templates for the view(s) and/or the field itself.

I would recommend addressing this kind of override from a code side, as it could potentially reveal sensitive information based on the front-end.


How to override taxonomy page with users view?

As per reviewing taxonomy_menu function, you need to replace path taxonomy/term/% with taxonomy/term/%taxonomy_term in "show users" view.

If you want to use path alias, set view path like this: dictionaryname/%taxonomy_term

Also, check Taxonomy and Views modules weights, make sure Views module weight is higher than Taxonomy module.


Add product thumbnail to user/%/purchased-files?

You need to change page callback for path user/%/purchased-files in hook_menu_alter() and your custom callback should be based on code of uc_file_user_downloads() function, you need to change it, add new column with product image. I guess you need to change query in that function to get more data from 'uc_file_products' table about the product id, and based on that you can get all product info etc


Restrict access for a specific forum to a specific user role

Taxonomy Access Control Lite is a good module to achieve this.

  This node_access module governs access to nodes based on the taxonomy
  terms applied to the nodes. A simple scheme based on taxonomy, roles
  and users controls which content is visible.

  As the name implies, this module shares some functionality with an
  earlier module called Taxonomy Access Control (TAC). If you are
  shopping around for an access control module to use, consider that one
  as well. See this module's README.txt for an explanation of "why yet
  another access control module".

I have implemented one of my site for same purpose.

You can also go for

Content Access and ACL modules.

  This module allows you to manage permissions for content types by
  role and author. It allows you to specifiy custom view, edit and
  delete permissions for each content type. Optionally you can enable
  per content access settings, so you can customize the access for each
  content node.

One more Option Using Group module.

  The Group module allows you to create arbitrary collections of your
  content and users on your site and grant access control permissions on
  those collections

  Out of the box, Drupal only allows a person to view, create or edit
  the different content types you create. However, you might want to be
  able to let them view or edit all content types, but only in a
  specific section of the site.


How to implement User roles for specific taxonomies?

It appears to me that there are 2 ways to answer your question. Read on for more details ...

Option 1: The Organic Groups module

Organic Groups is a possible answer to your question. It is probably the module that most users are familiar with.

If you're not familiar (enough/yet) with Organic Groups, then reviewing the amazing set of (free) videos to Learn Organic Groups might help.

Option 2: The Group module

Maybe you want to give it a try to use the Group module, which is like an alternative for Organic Groups. Group allows for creating arbitrary collections of your content and users on your site, and grant access control permissions on those collections. It is available as of D7, and has a D8 version also. The Group module creates groups as entities, making them fully fieldable, extensible and exportable.

Resources:

Community documentation for the Group module.
Video tutorial "How to use the Group module in Drupal 8 to manage editorial access control to different areas of a web site".

Comparing both modules

For more details about how Group compares to Organic Groups, refer to my answer to "What are the features of the Group module versus Organic Group module?".


it works and its even blazing fast.

tested on

drupal core 8.3.7
postgresql 9.6.3
amp stack - XAMPP

drupal case to follow on postgres drupal integration
https://www.drupal.org/node/2564307


Search and edit your php.ini file, you must search this line:

;extension=php_pdo_mysql.dll

remove the ; and save the file, then restart your webserver.


How do I use Drush 8 site aliases in Drush 9?

Aliases are now provided in YAML files. According to the example aliases file for Drush 9:

  To convert legacy alias (*.aliases.drushrc.php) to yml, run the site:alias-convert command.

So running the command:

drush site:alias-convert

should do the trick.


This would be difficult I believe, because every anonymous visitor is essentially treated as the same, as one account.


Determine main menu item on front page updating menu--main.html.twig

To get the path from item.url you would have to use the method toString():

  {{ item.url.tostring }}

Instead of comparing strings a better approach might be to check for the route name of the frontpage:

  {% if item.url.routed and item.url.routename == '<front>' %}
    Front Page
  {% endif %}


Drupal 8, override User Class for a custom added field

Don't. The field system doesn't work like that, there is currently no useful way to get autocomplete.

You could replace the entity class with your own and add methods for your fields, but it's not worth the trouble IMHO as you might get into trouble of some other module wants to replace the class as well.

You could add helper method or functions somewhere else and pass in the entity.


how to include one drush make.yml file in another?

Edit: I do see that you were using the wrong keyword, it should be includes and not imports.

It looks like you have the correct syntax above I believe. We use something like the code below in our make process, there are three different core makes that we call that one in, local, development, and build (we wanted to get updated versions in local and more stable ones in dev and build, just so we can update when appropriate.). It works pretty well but see the code below for an example. Thanks!

api: 2
core: X.x

defaults:
  projects:
    subdir: "contrib"

includes:
  - drupal.make.yml
  - libraries.make.yml
  - modules.make.yml
  - themes.make.yml
  - custom.make.yml

Here is the link for the Drush documentation for the make files, I didn't notice that they had swapped over to YML in the make docs or I would have started with this probably: Drush Docs - Make.


Users with no roles are getting onto my system

Users with no roles are how the default "Authenticated user" role is listed.  I.e. these have the access level that the system gives the role ""Authenticated user".

This by itself is nothing to be concerned about.

If you don't want to allow bots and fly-by users to create accounts, navigate to Home » Administration » Configuration » People » Account settings and under Registration and cancellation, click that only admins can create new accounts.

If you want people to able to create accounts, but not bots, you need to let the registration process tell bots and humans apart.  One of these modules may help:

CAPTCHA - See also: How to add CAPTCHA to registration
In particular; CAPTCHA Riddler
Mother May I

However, in 2015, bots like XRumer knows how to do most CAPTCHAs including math and "warped" letters - you may need to experiment a bit to find a CAPTCHA configuration that works.

But preventing spam registrations are actually the topic of this question: Unknown User Registered into my system


The path where a node is rendered is at node/%node, where %node is the nid of the node.
Example : http://example.com/node/1, and the path which is displays book/content/book-name-alias is an alias of the node/%node path.

So, to implement this override the node/%node path using either a view page (how to), or a panel page (how to) with the same path.


How to implement less than / greater than in views contextual filters

Have you tried using the regular filter (granularity of hour) and selecting the 'relative date' instead of the hard-coded date?  You could use 'now' to do a greater than or or equal to the current time, which is the same as

Screenshot attached:


Deny access to non-existing sub-paths that bubble up to an existing node

check admin/config/system/site-information and configure, in my site it's empty and all wrong urls get a drupal msg that the page couldn't be found.


There can be two things which I can think of.

Most SOLR installation guides advise you to edit IPAccessHandler in server/etc/jetty.xml to whitelist certain IP addresses. Often this is 127.0.0.1, but that would prevent access from localhost via IPv6. So you maybe should also white label the IPv6 localhost address ::1, or connect explicitly via IPv4 127.0.0.1.
Since SOLR 4.x you should also include your core name in the url. Search API Solr clearly states this. It might apply to Apache Solr module as well. This would mean your should enter a URL like: http://localhost:8983/solr/<core name>.


Content type select field is not listing in front end

when you create new field of type "list(text)" and then click "save"
you will go to new page where you have to insert the values you want the user to select from, add all the values in that page one value per line.
you can also assign key to the value by using this format "key|label"


Get Fields of a custom Content Type from Database in Drupal 7

You could always try field_get_items if you know the names of the fields you want. field_get_items('node', $node, 'field_name');

Although node_load() should be providing the fields for you and can be found at $node->field_name

Also Attiks advice is sound, I would also not recommend doing this in tpl


Entity reference field with custom class

Inside your tempalate.php file, add the following for that field. This is the standard implementation of theme_field. I added the line if ($delta == 1) $classes .= ' first'; to add the class.

function yourthemename_field__yourfieldname ($variables) {
  $output = '';

  // Render the label, if it's not hidden.
  if (!$variables ['label_hidden']) {
    $output .= '
' . $variables ['label'] . ':&nbsp;
';
  }

  // Render the items.
  $output .= '
';
  foreach ($variables ['items'] as $delta => $item) {
    $classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even');
    //add your class here
    if ($delta == 1) $classes .= ' first';
    $output .= '
' . drupal_render($item) . '
';
  }
  $output .= '
';

  // Render the top-level DIV.
  $output = '
' . $output . '
';

  return $output;
}

Furthermore, you can change this for different view modes and different bundles. The rest is in documentation.


DrupalQueue worker callback in separate file

I was looking for this too. Turns out that it is not supported, judging from source in drupal_cron_run(). If your queue worker is sizable, one option is to create an intermediary worker callback in your .module file, then include and execute the mymodule.queue.inc worker from that function.


How to conditionally render fields with a different formatter

I would try using the Context module API and adding a new reaction plugin.


Example of how to configure contextual filters with taxonomy using php arguments to display a view of commerce products?

On the first run, I was taking the approach of fetching the URL path that contained the related taxonomy data using the contextual filter's path argument selector.

After a good number of hours, I took a completely different approach to solve this problem. I actually figured out how to load the taxonomy field data into the contextual filter via php using the following code:

It will now grab any taxonomy data on the page if it exists. You will need to change it to your field settings.

return menu_get_object()->field_EXAMPLE_vocabulary[und][0][tid];

You can view my views configuration setup here: http://prntscr.com/18snhm

Looks like this once implemented:

http://img703.imageshack.us/img703/3733/lgt1356.png


Attachment of Taxonomy Term Description shows All descriptions on term page instead of only one

You need to add a contextual filter to the attachment view. This should be the taxonomy ID. And you have to set the Inherit contextual filters: to Yes


Nexus theme tb mega menu showing below slideshow

You need to find out the class of tb mega menu and add

{
    position: absolute;
    z-index: 2;
}

Note: z-index max display on top.


The best way to render field content without any  wrapper

Look in the core modules/field/theme/ folder, copy the field.tpl.php file to your theme then rename it to whatever the system name for the field is. i.e field--body.tpl.php

Edit the file to remove the surrounding divs and anything else you don't want. All you actually need is the foreach and the render($item);

Don't forget to clear the cache so it will pick up the new file, hope that helps.


How do I create a view that uses data from an external site

You can use views_database_connector and include connection details to your settings.php and database will be available to views

add connection details to your settings.php

"example_db" = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'example',
      'username' => 'example_user',
      'password' => 'example_pass',
      'host' => 'xxx.xxx.xxx.xxx',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

and when you create a view you can choose specific table from this database to connect to

Should work for both drupal 7 & 8


You can create forms everywhere you want.

Your code adds form elements without a surrounding  element. That makes it useless.

Define your form in a separate function and call drupal_get_form('your function name') to make it working. See the form generation doc for a full description.


It's actually very straight forward! If you want to not completely override the /cart url (basically, leaving the /cart in tact, but simply link key user interface elements directly to checkout) then you can skip to step 2...

Step 1: Overriding the cart view

You will want to do three things:

First, you'll want to "alias" the "/cart" to "/checkout" (see screenshot above) ... this will ensure all system links that go to cart actually just link to "/checkout"
Second, you'll want to override the system path "/cart" and have it redirect to an appropriate location. (code below)
Finally, you'll need to disable the view "Shopping cart form" (otherwise our hook_menu_alter may not work).

See verified code below (as in I checked to make sure this works).

<?php
function mymodule_menu_alter(&$items) {
  $items['cart']['page callback'] = '_mymodule_redirectcart';
}
function _mymodule_redirectcart() {
  global $user;
  $account = $user;
  $cart = commerce_cart_order_load($account->uid);

  // if user doesn't have a cart, go to <front>
  // else if user's cart is empty
  if ($cart == false || count($cart->commerce_line_items) == 0) {
    drupal_goto('<front>');
  }

  // go to checkout
  drupal_goto('checkout/'.$cart->order_id);
}
?>

Don't forget to disable the shopping cart form

Step 2: Making a one page checkout

I borrowed the step-by-step from an excellent "Express Checkout" blog.

From http://www.example.com/admin, click on the Store link, then Configuration, then Checkout settings
Drag the Review item out of the Review order section and into the disabled section
Drag the Payment item out of the Review order section and up into the Checkout section
Click Save Configuration

Step 3: Modify the title and button

This step is optional, but useful. Basically, we just use hook_form_alter to change the "Continue" button to indicate that payment will be taken and we modify the page title to "Cart" to further our ruse that this is the cart page and not checkout.

<?php
function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'commerce_checkout_form_checkout') {
    drupal_set_title("Cart");
    $form['buttons']['continue']['#value'] = t('Proceed with purchase');
  }
}
?>

Step 4: Your new cart checkout

This is not really a step, but it is the result of your effort. Now your new "cart" has a checkout/payment pane. Only thing you would be missing from the original cart is the ability to modify your cart (remove products) and that is where this process would fail you.

Other Thoughts

If your customers will need to be able to modify the cart (most likely the case), then you will need to link to a clone of the commerce_cart_view at a unique url (perhaps /cart-edit?) and then add a link called "Edit Cart Contents" in the footer of your cart contents view to indicate that they can remove items, but they have to click a link to do it.

The view you want to clone is called "Shopping cart form" and the clone option can be found at /admin/structure/views
Make sure you edit the path in your cloned view to "cart-edit" or some variation.
Edit the footer of the "Shopping Cart Summary" view found at /admin/structure/views/view/commerce_cart_summary/edit to look like the below:

The reason you can't modify cart items in checkout is that "forms within forms" is not a straightforward thing to implement, but linking to a view to edit your order is pretty simple and everyone wins with a 10 minute change.


You'll need to use file_create_url() and the 'PHP code' format (comes with the core 'PHP filter' module) for this to work:

<img src="<?php print file_create_url('public://img/screenshot.png'); ?>"/>

If possible I would suggest adding it inside the block's template file instead though.


How to set viewing of Bookmarks User Profile tab to just the owner?

Try "permissions" and "view own published content."


There are 3 different things called "block" in Drupal 8. plugins, config entities and content blocks. See Adding custom block problems for an explanation.

But yes, to answer your question, content blocks are exposed as block plugins and can then be used not only for placing blocks in regions but also with page_manager/panels. You don't need anything else.

One limitation is that they can't be exported easily into config, since they are content. If you don't need extensible structure but only a text or a reference, then you could build your own block plugin or wait for a contrib module to do that (I recently saw a module that did basically that in 7.x with its own plugin system, would be very easy to make the same for 8.x as core provides 90% of what's needed. Can't remember the name right now.)


How to bulk add information to the profiles of users?

Step 1

Use the Rules module to create a Rules Component, which includes whatever Rules Conditions you might need (if any), and with a Rules Action to Set a data value, for each of those fields you want to be updated.

Step 2

Create a view of the group of users for which those fields should be added. Then transform that view into a view that uses Views Bulk Operations, and use the technique documented in "How to use Rules to create a custom bulk operation for a VBO view?". In doing so, you'll then be able to use the Rules Component from Step 1.

Tutorial

To get the idea, have a look at the video about Using Rules components with VBO" which uses a Rules Component with (only) 1 parameter. If you want even more, then also watch the subsequent "Using Rules components with more than one parameter" video.

Attention: to process like 100.000 entities at once is quite a challenge (memory requirements, etc). Therefor you might want to also watch the video about "More details about VBO settings" ... Before you are tempted to use VBO for processing them all at once ...

PS: this answer is for D7 ...


Is it normal after editing an item in one display for Views to always go back to the first display

Its just a bug of views/settings/advanced and the setting "Disable JavaScript with Views".

At the time of asking this question, I was troubleshooting errors in the Views plugin Draggableviews that were appearing in the Views UI.

Related to this is another bug where its impossible to remove a Filter Criteria value without JavaScript enabled.


how to enable comments only to subscribed users

Here is a programmatic way to do this, add this code to your custom module

NOTE:

In the following code my content type name is article, change it to yours.

Also this code can not handle functionality for anonymous user as I couldn find a way to track if anonymous user is already registered or not.

/**
  * Helper function to check if user is registered to a given event node or node.
 */
function check_if_user_is_registered($node, $uid) {
   $return = FALSE;
   $registrations = node_registration_load_multiple(FALSE, array(
      'uid' => $uid,
      'nid' => $node->nid,
      'cancelled' => 0,
    ));
  if(is_array($registrations)) {
    foreach($registrations as $registration) {
      if($registration->author_uid == $uid) {
        $return = TRUE;
      }
    }
  }
  return $return;
}

/**
  *  Implements hook_node_load().
 */
function MYMODULENAME_node_load($nodes, $types) {
  global $user;
  foreach ($nodes as $node) {
    if($node->type == "article") {
      $access = check_if_user_is_registered($node,$user->uid);
      if(!$access) {
       $node->comment = 0; // to close comments
      }
    }
  }
}


Where you place the code depends on when you want it to run. Usually these things goes best in hook_cron(), but cron needs to be set up to run for that to work.

Instead of doing bulk update you might want to consider changing the published value in hook_node_presave() instead, i.e. when saving the node. Example (untested):

function mymodule_node_presave() {
  $w = entity_metadata_wrapper('node', $node->original);
  $var = $w->field_status->value();
  if ($var == 'Closed') {
    $w->status = 0;
    $w->save();
  }
}

Concerning your code otherwise it should work afaik, but it would be better to load all nodes at ones. Something like this:

$nodes = node_load_multiple(array_keys($result['node']));
foreach ($nodes as $node) {
  $w = entity_metadata_wrapper('node', $node);
  $w->status = 0;
  $w->save();
}

Cheers,


How to hide VBO multipage selector in a view

on your views, it should be a field "Content: Node operations bulk form"

if you want totaly remove VBO, hide or remove the field, but if you want to hide specified action use " Only selected actions"


Unsubscribing from mailing list for anonymous user in simplenews

I needed the same thing, so I thought I'd share my solution.

In hook_form_alter():

  // Check that this is a simplenews form and the user is anonymous
  // If so, add an Unsubscribe button with a custom submit handler before the
  // default simplenews form submit handler is called
  if (strpos($form_id, 'simplenews_block_form') !== FALSE && $user->uid == 0) {
    $form['unsubscribe'] = array(
      '#type' => 'submit',
      '#value' => t('Unsubscribe'),
    );

    $form['unsubscribe']['#submit'] = $form['#submit'];
    array_unshift($form['unsubscribe']['#submit'], 'custom_simplenews_form_unsubscribe');
  }

Then the custom submit handler will be something like this:

function custom_simplenews_form_unsubscribe(&$form, &$form_state) {
  // Change action to unsubscribe and exit so the simplenews handler will take over
  if ($form_state['clicked_button']['#value'] == 'Unsubscribe') {
    $form_state['values']['action'] = 'unsubscribe';
    $form_state['values']['submit'] = 'Unsubscribe';
  }
}

So, when control is passed to simplenews_block_form_submit() in simplenews.subscription.inc the user will be unsubscribed using the module's workflow.


Date Calender Starting Date of Field B should be equals to or advanced from the Ending Date of Field A

Try out Webform Validation module

  This module adds an extra tab to each webform node, allowing you to
  specify validation rules for your webform components.

OR in other case, write custom code, Use hook_form_alter() to apply custom validation

function mymodule_form_alter(&$form, &$form_state, $form_id)
{
    print $form_id;

    if($form_id=='webform_client_form_1') //Change webform id according to you webformid
    {
        $form['#validate'][]='mymodule_form_validate';
        return $form;
    }
}

function mymodule_form_validate($form,&$form_state)
{
    $phoneval=$form_state['values']['submitted']['phone'];//where "phone" is field name of webform phone field
if($phoneval=='')
{
form_set_error('phone','Please fill the form field');
}
/** THEN USE REGULAR EXPreSSION TO VALIDATE IT
In above example i have check if phonefield is empty or not
**/

}


What might be causing my problem to access user variables in Rules?

Not sure what the reason might be that is causing your problem. But something that you could do to make this work, for sure, is like so:

Add a Rules Action "Fetch entity by id", whereas you want to fetch the user entity, and where you use the uid of the "current-user". For any subsequent Rules Action, you then have all fields of that user available as tokens.
Enable the Conditional Rules module, which allows you to specify Rules Conditions as part of Rules Actions. Using that technique, you can then like "move" any of your existing Rules Conditions (ie the ones where you need those user variables, as per your question). In doing so, you can then use any of the tokens that you made avaiable via the preceeding Rules Action "Entity has field".

BTW, no dangerous PHP code (stored in your database) needed to get this to work ...

Easy, no?


Error message getting displayed but not getting highlighted fields in Drupal 7

First argument of form_set_error tells Drupal what element should get highlighted. Obviously empty string means "none", so your code works exactly as designed.

To make field required, you can go a simpler way: Use #required attribute and let Drupal take care for details.

To round it off, as Clive said, your code would be:

form_set_error('field1', t('one field is required'));

But if you're just checking for an empty field, use #required.


Help with debugging and fixing errors with SalesForce Mapping Module

Without being able to find an answer to the issues I was having, I did finally get the mapping module to work by downgrading XAMPP and instead of using PHP 5.6 used PHP 5.3, which enabled the Mapping module to begin functioning properly.


Add inline style to render array attributes, without XSS filtering

I'd use '#type' => 'inline_template' for this: You can do everything what you can do in a regular .twig file, just inlined in code:

  $build[0] = [
    '#type'       => 'inline_template',
    '#template'   => '
{{ bar }}
'
    '#context' => [
      'foo' => $youtube_thumbnail
      'bar' => $whatever
    ]
  ];
  return $build;

Here is a complete list of render elements / #type 's for render arrays. (For Forms API, here is the sub-list of FormRenderElements)


Add this to your (template) .tpl.php file

<?php

if ($node = menu_get_object()) {
  // Get the nid
  $nid = $node->nid;

$node = node_load($nid);
$wrapper = entity_metadata_wrapper('node', $node);
$field_value = $wrapper->field_price->value();

if ($field_value == 0) {
  print 'On Request';
  } else {
  print $field_value;
  }
}

?>

Not sure if the machine name of price is field_price.

If the machine name is just price then use $field_value = $wrapper->price->value(); instead.


How do I print the output of a field as a link on node.tpl.php?

This looks like it's happening because you are trying to input the entire rendered field (including styling) into the links href.

As per the description:

  The field_view_value() function can be used to output a single formatted field  value, without label or wrapping field markup.

To use field_view_field, try something like:

if($node->type == 'article')
{
    $link_field = field_view_field('node', $node, 'field_href');
    print l(t($link_field['#items'][0]['safe_value']), $link_field['#items'][0]['safe_value']);
}

This example assumes a node of article type, and a field with a machine name field_href. running it through l() (despite using the safe value) will help ensure it is sanitised properly before being output.

You can also take a look at the Link field module:

  The link module can be count to the top 50 modules in Drupal
  installations and provides a standard custom content field for links.
  With this module links can be added easily to any content types and
  profiles and include advanced validating and different ways of storing
  internal or external links and URLs. It also supports additional link
  text title, site wide tokens for titles and title attributes, target
  attributes, css class attribution, static repeating values, input
  conversion, and many more.


Here's the answer, which is just an extension on the comment from @berramou

$file = file_load($fid);
  $message["params"]["attachments"][] =[
    'filepath' => $file->getFileUri(),
    'filemime' => '' // argument must be present, but can remain empty
  ];
}


Create user without password using rest api

Just like when you create a user on user/register, the visibility/requiredness of the password field depends on the verify_mail setting.

If e-mail verification is enabled, then you must not provide a password, if disabled, you must provide one.


Reason of page--membership.tpl.php not working for sitename.com/membership may be:
Drupal used templates as page--[front|internal/path].tpl.php based on the internal path of the current page. Do not confuse the internal path to path aliases (Pathauto module uses path aliases) which are not accounted for.

To create the template for page--membership.tpl.php one may try one of the following methods:

Create template as page--node--[NODE_ID].tpl.php, here replace the [NODE_ID] with the node id of membership page.
To get recognize the aliased paths, you have to add the aliased path as part of the theme suggestions: https://groups.drupal.org/node/130944#comment-425189


A derivative image is generated on the fly when served over HTTP. When the derivative image is requested in HTTP, if the file doesn't exists, the HTTP request is handled by Drupal. Drupal will use the image_style_deliver() page callback to generate the derivative image and deliver it. Once the image exists, Drupal will not handle the request and the file is directly delivered.

If you need to access to files externally without using HTTP to access them, you can use image_style_create_derivative($style, $source, $destination) to create the derivatives images. You will need to provide the destination path for the derivative image, which you can get with the image_style_path($style_name, $uri) function.

The following (untested) code should ensure that the derivatives for the image file identified by $fid are generated for the styles whose names are in the $styles array.

$original = file_load($fid);
foreach ($styles as $style_name) {
  $derivative_uri = image_style_path($style_name, $original->uri);
  image_style_create_derivative($style_name, $original->uri, $derivative_uri);
}


Assuming that you allow decimal in the quantity field, you can use the hook_form_alter() hook. It is one of the most used drupal hooks.

/**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&$form, &$form_state, $form_id) {

  // add to cart form
  if (strpos($form_id, 'commerce_cart_add_to_cart_form_') === 0) {

    // Replace the text quantity field with a select list.
    if (isset($form['quantity']) && ($form['quantity']['#type'] == 'textfield')) {

      $product = commerce_product_load($form['product_id']['#value']);
      $price = commerce_product_calculate_sell_price($product);

      $select = array(
        '0.1' => '100grams '.commerce_currency_format(1*$price['amount'], $price['currency_code'], $product),
        '0.2' => '200grams '.commerce_currency_format(2*$price['amount'], $price['currency_code'], $product),
        '0.3' => '300grams '.commerce_currency_format(3*$price['amount'], $price['currency_code'], $product),
        '0.4' => '400grams '.commerce_currency_format(4*$price['amount'], $price['currency_code'], $product),
      );

      $form['quantity']['#type'] = 'select';
      $form['quantity']['#options'] = $select;
      $form['quantity']['#size'] = 1;
    }
  }
}


Manually removing database records of a module

I second the voices above.

My recent experience to get out of the pdoexception is crude and more akin to a 'big hammer' rather than anything elegant.

make a backup of your database and the code
either use a UI like phpmyadmin OR sql if you feel more comfortable with code
create the table it says is missing (website_staging.search_api_server)
add at least 1 variable (id)... take the defaults of integer
you don't have to add a value to the table, just create it and add the definition for the id variable
try your uninstall again

In my case for my custom module practice development, I also had to add a second variable because there were two 'keys' on the table.  But I'd try this with just the one variable (id)... hopefully it will be enough to get you out of the PDOexception and onward to module/code review.

The concept here is to give Drupal the minimum info it needs via manual PHP/SQL creation so it can 'connect the dots' and move forward to execute your commands (uninstall).
JW


Access image/file with REST and Basic Authentication

In my view, Basic Authentication will work only for giving username and password whereas cookie will use the authenticated user cookie set in browser and display results.

If you want to use basic authentication and get file information just see below code:

$username = 'SITE USERNAME';
$password = 'SITE PASSWORD';
$url = 'SITE URL';
$response = \Drupal::httpClient()->get($url . "/entity/file/FILE ID?_format=json", [
  'auth' => [$username, $password],
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);
$json_string = (string) $response->getBody();


This module does the job, https://www.drupal.org/project/views_summarize, also I'm using a bootstrap sub-theme and all modules above mensioned break css, and this module does not.


How do I enable authenticated users to be able to add ubercart products?

Ubercart products are nodes, so access is controlled in the normal way:

Visit the permissions page, and assign whatever roles make sense to the "create", "edit", etc permissions for the relevant product content type.


How to get "Show block on specific pages" working?

When you use this field don't provide the leading slash.  Try node/36.

Not sure why the alias wouldn't work - perhaps there's a character out of place.  Node numbers work better because the block then doesn't disappear if the alias changes.


How to give a particular role, the right to register new user

I couldn't get why it's a problem, you are already there, just simply create a role "Webmaster" if you dont have one already, and give this role the same permission "Administer Users" too. but if you only want to give specific permission such as ONLY creating users you might need Administer Users by Role module

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

  To use this module:

  Create a role for the users who you'd like to be able to
  create/edit/delete other users Give that new role the 'administer
  users' permission and give it the desired Administer Users by Role
  permissions If the user-being-edited has multiple roles, the
  user-doing-the-editing must have permission to edit ALL of the
  user-being-edited's roles.


Same View, different displays, One page, same exposed filters. Possible?

So I solved this by using Attachments in my view.

Each attachment had a separate filter.


Custom field: process submitted before storing

messageFormValues in the widget class did the job.

class MyDefaultWidget extends WidgetBase {
  ...
  /**
   * {@inheritdoc}
   */
  public function massageFormValues(array $values, array $form, FormStateInterface $form_state) {
    // Change the format of $item['sections'] from array to pipe delimited string.
    foreach ($values as &$item) {
      $sections = [];
      if (is_array($item['sections'])) {
        foreach ($item['sections'] as $s) {
          if ($s !== 0) {
            $sections[] = $s;
          }
        }
      }
      $item['sections'] = implode('|', $sections);
    }
    return $values;
  }
  ...
}


How do I create a dynamic link for a block?

You can get the node id from the url, since all nodes are displayed at node/[nid]. So if you in your block do

$nid = arg(1);
$node = node_load($nid);

You will get the node which has the title and the nid that you can use in your links. You would need to check that the block is on a node page as well by doing:

if (arg(0) == 'node')


Need to change the subdomain URL structure - D7

I believe you will still need some mod_rewrite redirection rules (RewriteRule), but only after the fact; it can be used used to ensure users accessing subX.example.com get redirected appropriately to the new content URL instead of mod_rewrite being the solution to the problem (which, as you mentioned, is not what you wanted).

Have you tried using pathauto to set a URL pattern and then using views_bulk_operations to mass update node aliases? I recall VBO will overwrite any existing alias, but if it doesn't simply make a database backup for good measure and then drop your existing node path aliases from the database directly as they will be regenerated anyways using VBO.

If you need to create redirects from the old node aliases to the new ones (ignoring the hostname component), the redirect module will automatically create 301s.

Here is a quick guide on pathauto + VBO: http://drupal.org/node/1326928


Attached view ajax call (lazy load) with exposed filters

U can use quicktab module for the same. Create Tab with it, and select your view which u want to use. After that there is an option to check how to load content of the tab, u can either choose to load at once, or on click of tab using ajax.


How do I find the hooks used by this module?

As @Kevin says, modules should have a modulename.api.php file with examples that implement hooks that the module provides.

When this file is not available you can search for the code that creates a hook in Drupal.

Drupal 8

Look for following functions of the ModuleHandlerInterface, usually implemented by the ModuleHandler class:

invokeAll
alter

Using grep it's easy; just go to the module's root directory and execute:

 grep '\->invokeAll(\|\->alter(' * -r

This command looks for the strings ->invokeAll (creates regular hooks) and ->alter (creates alter hooks).

For example, if you use this grep command with core's module User you get:

src/Entity/User.php:    \Drupal::moduleHandler()->alter('user_format_name', $name, $this);
user.module:  \Drupal::moduleHandler()->invokeAll('user_login', array($account));
user.module:    \Drupal::moduleHandler()->invokeAll('user_cancel', array($edit, $account, $method));
user.module:  \Drupal::moduleHandler()->alter('user_cancel_methods', $methods);
user.module:  \Drupal::moduleHandler()->invokeAll('user_logout', array($user));

So, this module creates the following hooks:

hook_user_format_name_alter
hook_user_login
hook_user_logout
hook_user_cancel
hook_user_cancel_methods_alter

Drupal 7

Same procedure, but in this case you have to look for the functions module_invoke_all() and drupal_alter().

grep 'module_invoke_all\|drupal_alter' * -r

Keep in mind that this method is not 100% reliable, as some modules use their own hook creation implementation (I've seen this in Drupal 7 mainly), but it's a good starting point if the said modulename.api.php file is missing.

Entity Clone

Unfortunately Entity Clone doesn't create any hook, and the command yields no results.

invoke

There are certain hooks that are only invoked in a particular module, see ModuleHandler::invoke and module_invoke. As they only affects certain modules they are less used than regular ones (they are some kind of internal use hooks).


My solution was simple: After updating Drupal8, ensure you run any pending scripts! Otherwise you will not be able to do certain things with your Drupal8 site.
Yesterday I updated my Drupal from some ancient version to the latest stable Drupal8. I noticed I can't add images [the forever loading problem], and I'm just a home user not behind a fancy firewall. After updating 13 pending scripts, everything was fine.
I'm not a very technical person, but I wanted to share my solution because no one else had shared this.
My website is ontu.org and thus the settings page for me was here:
http://ontu.org/admin/reports/status

Change that URL to your site and you'll quickly go to your settings page. There may be multiple issues reported on that page, so notice everything on there.


Show node for specific content type using views contextual filter

A simple query alter will do the job.

Say example you are using a module my_views_invoice

    function my_views_invoice_views_query_alter(&$view, &$query) {

    $nodeid = $view->args[0][1]; // get the node id from contextual filters. Ex :Array ( [0] => node [1] => 1 )

   $content_type =  node_load($nodeid) ;// get the content type from the node load : Ex $content_type->type

      if ($view->name == '<Your view name>') {
// Add a where condition in the query like below..

        foreach ($query->where[0]['conditions'] as $key => $conditions) {
          if ($conditions['field'] == 'node.type') {
            $query->where[0]['conditions'][$key]['type'] = $content_type->type;

          }
        }
    }


Feeds import from Restful Web Service module output

I just want to post my plan for everyone to review and response.  After days of no response, it does mean I'm having a crazy idea.

I've re-think my solution and came up with writing my own custom module to do the data copy from one content type to another.  It was easy than I expected.  Copy of data from one content type to another is very easy if the both field type are the same.  It's a straight assign of field from one node object to another content type object.  That's it.


What are the steps to be undertaken while writing a .install file for drupal 7 module?

as Clive says you should use hook_schema for creating your custom tables and then
hook_update_N
https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_update_N/7
for the updates of your tables module.


(Drupal 6.28) Blocks list suddenly doesn't show correctly

That to me looks like an issue with theme update. Did you changed your theme recently. It yes, then try clearing your cache.


If you directly edit .htaccess (at the root directory of Drupal), I suppose you may as well be very careful, because any update of Drupal may delete it.  For that reason, as I understand it is not recommended in general.

I have been using Redirect module for that purpose and am content with it.
With the module, you can manually set the redirection for each path in its configuration panel.  But as you have hundreds of paths, perhaps you want a programmatical way.
An article by Dale McGladdery is concise and helpful for how to do that, using the module (It uses the Migration module; in your case ignore that part and set "From" and "To" URLs to suit your requirements).  Basically, you use redirect_save($redirect) function, where $redirect is the stdClass object, definining the paths and type of redirection.

A potential trouble in his example is, if the same redirection exists, it raises an error.  Therefore if you ever rerun the process to set up the redirections, you will have a trouble.  To overwrite the existing redirection, you need to appropriately set rid of the object to pass to the funciton redirect_save().
I have done that in my migration, and you can have a look at the source code at GitHub (complete() section), if you want to have a look at an example.


Rewrite markup of a field in twig template

Sorry I couldn't be more verbose earlier, I was typing from a phone.

One way to solve this would be to just create a new template variable. Also, its easier to use the field value instead of parsing the render array - the contents of that array could change without warning. Not saying it happens a lot, but is possible. Just access the field value directly in one of two ways:

$field_value = $node->get('field_name')->value;

or

$field_value = $node->get('field_name')->getValue();

Note that not all fields will work that way, but most basic ones like text or textlong do. Reference fields for example will work a little differently.

function mytheme_preprocess_node(&$variables) {
  $node = $variables['node'];

  if ($node->getType() == 'mytype') {
    if (!$node->get('field_my_field')->isEmpty()) {
      $variables['new_variable'] = $node->get('field_my_field')->value;
    }
  }
}

Then, in your node--node-type.html.twig template of your theme, where you want the field output, do:

{{ new_variable }}

Note that if you use ->getValue() above, you need to dig into that value array to get the actual value as opposed to ->value.

Always isolate the effort to the node type(s) and templates it should affect. In your question, you say you have this:

function mytheme_preprocess_node(&$variables) {
    $variables['content']['field_my_field'][0]['#markup'] = $newValue;
}

This code will fire for every node in the system any time it is loaded on that active theme. Unless that field exists on every single node type, it will cause a lot of warnings/notices in your logs. If you moved the field from visible to hidden from the admin UI, this code will fail as well, since the field will be removed from the content render array and not exist. I tend to also enforce checking both the node type and the view mode of that node being rendered too, but that is all up to what your design requirements are.


Never show the term name if the user has no permission to view the term

You could implement hook_menu_link_alter in a custom module and modify access to /taxonomy/term/xxx, if need be, by overriding the existing access callback with your own.

You will need to look at the menu router table to see exactly what menu item you want to alter.


Set default text format for a content type

If the field is Wysiwyg, so you might want to configure the "Wysiwyg" profile settings, then it will be available in the Structure » Content types » contentType name  » Manage fields.


How do I get rid of a table doesn't exist warning?

If ok with some code, you could also try running

drupal_install_schema('xmlsitemap');

and that should recreate the xmlsitemap tables, backup db first.

more info:

xmlsitemap_install
xmlsitemap_schema


For the user groups, use the auto assign role module and you could use content profile and CCK to create profile fields that the user can fill in.  You could use the content permissions module that's a part of CCK to allow a user to create a profile but not to edit certain fields once they've been created.


How to do Domain site name translation (DA module)

The project page of the "Domain Access" module says:

  If you use the contributed i18n module suite, you should use the Domain Variable module instead of the provided Domain Configuration and Domain Settings modules.

Therefore, I think you should try the Domain Variable module, to check if it fixes you issue.


You will need to create a webform as node. Edit the node and navigate to:

Webform tab -> Form Settings tab -> Advance Settings (located at the bottom of the page).
Check the checkbox for Available as block and your webform will be a block.


Apache Solr Search proper syntax in url?

You should integrate Updated Apachesolr module.
Write some custom menu hook to invoke your custom function.

 $query = apachesolr_current_query();
 $params_query = $query->getParams();

The above two statements will help us to check our solr queryString that we have triggered from our application.

/**
 * Implementation of hook_search_execute().
 */
function Custom_Function($keys = NULL, $conditions = NULL) {

  $filters = isset($conditions['fq']) ? $conditions['fq'] : array();
  $solrsort = isset($_GET['solrsort']) ? $_GET['solrsort'] : '';

  $response = NULL;
    $filt = array();
  // add custom filters if you want to add few custom filters in certain conditions.
   if($_GET['some key'] == 'some condition') {
        $filt[] = array('name' => 'entity_type', 'value' => 'trend_tips');
      }else{
        $filt[] = array('name' => 'im_16_field_category', 'value' => $_GET['category']);
      }
  $filters = $filt;
  $results = apachesolr_search_run('apachesolr', array('q' => $keys, 'fq' => $filters), $solrsort, 'search/' . arg(1), pager_find_page());

    // Set name for search results
    $query = apachesolr_current_query();

    $params_query = $query->getParams();

    if (module_hook($module, 'search_page')) {
      return module_invoke($module, 'search_page', $results);
    }
 }
/**
 * Implementation of hook_apachesolr_query_prepare().
 */
function CustomeModule_apachesolr_query_prepare(&$current_query) {

  // add query filters for Style tips and trends
  $current_query->addParam('fl', 'tm_image,tm_url,content');
  $current_query->addParam('qf', 'tm_title');
  $current_query->addParam('qf', 'tm_short_content');
  $current_query->addParam('qf', 'tm_perex');
  $current_query->addParam('mm', '1<-90%'); // if you write more then 1 word to search, solr search as 'OR'
  $current_query->addParam('bf', 'recip(rord(created),4,5759,5759)^5.0'); // remove time dependency on search results

  // remove following content types (product and page) from search
    $current_query->addFilter('entity_type', 'product', true);
    $current_query->addFilter('bundle', 'page', true);
    $current_query->addFilter('tid', "63", true);
    $current_query->addFilter('tid', "64", true);

  $current_query->addParam('facet.field', 'bundle');
  // add a new facet type for filter trends and tips on search results

}

Please let me know if the above codebase helped to get some grip.

Thanks