EntityFieldQuery not returning Bundle data

What should I expect to see in $result

You should expect to see an array of data that represents the entities that match your query. This array will contain a key for each entity type it returns, and an array within each of those keyed by the individual entity IDs. The inner-most array will contain bundle key data for the entity. You will need to run the ID(s) through entity_load() or equivalent if you want access to general field/property data for the entities.

  why aren't I seeing it?

Not really possible to say without more information. If you know that you have existing entities that match the criteria, and they're not showing up in an EFQ, that's potentially the sign of a deeper problem with your installation (or it might not be, it depends).

If that's the case, clear your caches and try again. If that doesn't fix it, reinstall your entity module. After that, you're left with step-debugging to find out what DB query is being produced, you can run that against MySQL proper to see what's going on, and so on.


Is there a way to log changes to module settings for better long-term administration and debugging?

Here is our workflow.

First of all you code base should use a versioning system as Git or Subversion, doesn't matter which you like or want use, but the main point its to use a versioning system.

Then you should give a look to Features module and all his modules relatives. This will allow you to create a set of module that include standard configuration and etc.

So, mostly popular modules are using either variables or ctools to manage their configuration, for those who sue CTools, Featues will help you export their configuration, for the others you've Strongarm.

I think just with this, you will covers at least 80% of your configuration, for the rest your should either move it to features or use hook_update_N with a module.

Here what is important its that all your configuration must be inside files and committed to the versioning system.

Like that, you will which configuration has been changed and see the historic through the versioning system.

I think the most important part its to move the already existing into Features and force people to use Features when they are doing changes in the configuration.


What is the difference between the "complete" and " checkout complete" order statuses?

None of the above. You should be using hook_commerce_payment_order_paid_in_full(), which is always invoked the first time an order's balance drops to $0 or less.
Read more about it in commerce/modules/payment/commerce_payment.api.php.


How to apply node access rules when querying menu_links table

Yes, menu_get_item() will set return an access element that notes whether the current user has access.

  $siblings = db_select('menu_links', 'ml')
    ->fields('ml')
    ->condition('plid', $target['plid'])
    ->condition('hidden', 0)
    ->orderBy('weight')
    ->execute();
  foreach($siblings as $sibling) {
    $menu_item = menu_get_item($sibling->link_path);

    if($menu_item['access']) {
      //Current user has access
    } else {
      //Current user doesn't has access
    }
  }


Why is the first visit to a rarely used site slow or even lead to timeout?

There isn't a lot of information, and the answer is likely specific to your instance, but my first guess is that you are experiencing the effects of one or more cache misses.

If you are using APC, then your rarely used site may not have core files in the bytecode cache.  Subsequent visits will.

If you are using MySQL query caching, then your rarely used site likely doesn't have anything in the cache, so all queries need to actually run.

The Drupal cache entries themselves (ie, the variouls cache table) may also be stale, so initial slowdowns could be caused by this.

If you are using Poormanscron, then this could be running, too, on initial page loads.


empty page creation and filling it with blocks

Seems like Panels would be good for this. You'd create a panels Page and then assign the relevant blocks.


While Drupal 7 is probably the "right" thing to do, there are a few good reasons to stick with Drupal 6.

One is the status of the modules you need.  Drupal 7 versions will be less mature than their Drupal 6.  They may have better features, but may also have bugs.  Some just don't have Drupal 7 versions yet.  You need to go through your modules and make this assessment yourself.

The other is how much legacy code you wish to reuse.  Yes, you can port, but that leads me to my next point.

Most of the projects I work on are sites for clients, and are firm-fixed-cost and firm-schedule.  In my case, I have to be conservative with third-part module choices.  My clients don't care if a project is late because of a bug in a module.  In their eyes, that is my responsibility.  Yes, I can debug modules and provide patches.  But, this takes time and   maintainers don't always accept patches.

All of this weighs into the version choice decision.


How do i select all from database and do while loop with them

Try with this:

   $results = db_select('cities', 'c')
    ->fields('c')
    ->execute()
    ->fetchAll(PDO::FETCH_ASSOC);

   foreach ($results as $result){
    $city_id = $result['city_id'];
    $city_name = $result['city_name'];
   }


How do I override an entity view controller?

I think you may be unsetting some things in your alterRoutes method doing it the way you are. (However, I can't tell if or why that's happening after looking at Route::addDefaults().)
I'm doing the same thing for a media entity's route. My alterRoutes method is a little different - I'm using Route::setDefault().
public function alterRoutes(RouteCollection $collection) {
  if ($route = $collection->get('entity.media.canonical')) {
    $route->setDefault('_controller', '\Drupal\my_module\Controller\MyController::view');
  }
}

Additionally, the variable names in your controller methods are important - they must match the variable name from the route definition. See the documentation for Using parameters in routes

In most PHP code the name of the variable does not matter but here it does: the name of the method argument must match the slug. Conversely, if the method argument name matches the name of the slug, the parameter will be passed in, irrespective of the order of arguments.


How to create 3d charts using Charts module and Highcharts library?

In the latest -dev version of the Charts module (D8), there is a checkbox to enable 3D for Highcharts and Google.


jQuery.browser.msie depreciated in 1.9 trying to fix in Drupal 7

Drupal ships with a particular version of jQuery.

Using a different version of jQuery means refactoring various core javascript code.

If you want to use a more recent jQuery version, you can check the available versions provided by the jquery_update module which provides that refactored replacement javascript.


Override comment.tpl.php and add the following to it:

<?php print 'Comment #' . $id; ?>

(You obviously add it to the spot in the template where you want the comment number to appear.)

Here is the contents of my override for comment.tpl.php for Bartik;

<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

    <?php print $picture; ?>

        <?php print $author; ?>
        <?php print 'comment #' . $id; ?>

        <?php print $created; ?>

        <?php print $permalink; ?>

    <?php if ($new): ?>
      <?php print $new; ?>
    <?php endif; ?>

    <?php print render($title_prefix); ?>
    <h3<?php print $title_attributes; ?>><?php print $title; ?>

    <?php print render($title_suffix); ?>

    <div class="content"<?php print $content_attributes; ?>>
      <?php
        // We hide the comments and links now so that we can render them later.
        hide($content['links']);
        print render($content);
      ?>
      <?php if ($signature): ?>

        <?php print $signature; ?>

      <?php endif; ?>

    <?php print render($content['links']); ?>


How to handle password field for externally authenticated users (Oauth2)?

It depends on how you want Oauth integration to work.

If the Oauth integration is a supplement, then you should let users define a password themselves, so they can either login with username/password or Oauth. If you don't want users to login directly on the Drupal site with credentials but only use Oauth, you can use user_external_login_register. This willassign a random password to the user, since the password property is required, a random password is generated on the fly:

...
$userinfo = array(
  'name' => $name,
  'pass' => user_password(),
  'init' => $name,
  'status' => 1,
  'access' => REQUEST_TIME,
);
$account = user_save(drupal_anonymous_user(), $userinfo);
...


mysql_query doesn't work but db_query does on a simple SELECT query

Just to start with let me very clearly say, never ever use mysql_query unless you really have to (multiple databases with different backends fx).

Why? db_query has a lot of security features built in to help prevent SQL injections, and it makes your site database agnostic (you won't have to change code if you change the database backend) and it allows you to use table prefixes without hardcoding them in the queries.

Anyways the reason why mysql_query doesn't work is because you need to create a connection to the database first using the database credentials, something drupal does automatically for you, when you use db_query.

If you really want to throw away all the good Drupal does for you and use mysql_query anyways, take a look at mysql_connect.


This a documentation error.

The correct path for users is user/%user/display

In case of nodes should be node/%node/something


How to read JSON from external URL and display in a block?

For the most basic solution, you would need to:

Create a custom module;
Implement hook_block_info and hook_block_view to define your block (see block_example.module for examples);
When generating the block content, use drupal_http_request to retrieve the json data from your URL and process the return value as needed.

A more complex version of your custom module could for instance involve implementing hook_block_configure to make the URL configurable from the UI, using theme functions to generate the HTML output, and caching/storage of the return value.

A completely different approach, which may or may not be appropiate in your case, would be to use the Feeds module to retrieve the JSON and store the data as nodes, and use the Views module to generate a block listing those nodes.


Drupal menu management seems lacking compared to WordPress: Am I missing anything?

On node edit page, upon checking "Provide a menu link" populates a select box with menus and theirs items which are associated with this content type. To include other menus you need to edit your content type.
You are right in this regard but there can be some module.


How to update the database schema without losing existing data

When you want to apply database schema changes you don't reinstall the module. You apply these changes via hook_update_N() from your MYMODULE.install file.

See Updating Database Schema and/or Data in Drupal 8 on drupal.org.

  If your module is making a data model change related to database
  schema that your module defines with hook_schema(), then you need to
  properly update your data model. The two steps are:

  Update your hook_schema() code so that it reflects your new data model if the database table and field definitions have changed. This
  will make sure that people that install your module after you made the
  change will install the correct database tables. See the Schema API
  documentation for details on that.
  Write a hook_update_N() function. This will update the database for existing users of your module who already had it installed before
  you made the change so that they can continue to function. This is
  described below.

There also is a sample on how to add a new table from hook_update_N():

$spec = [
  'description' => 'My description',
  'fields'      => [
    'myfield1' => [
      'description' => 'Myfield1 description.',
      'type'        => 'varchar',
      'length'      => 255,
      'not null'    => TRUE,
      'default'     => '',
    ],
    'myfield2' => [
      'description' => 'Myfield2 description',
      'type'        => 'text',
      'not null'    => TRUE,
    ],
  ],
  'primary key' => ['myfield1'],
];
$schema = Database::getConnection()->schema();
$schema->createTable('mytable2', $spec);


How to hide field from entity display view programmatically?

Anyway found solution, example of field instance:

field_create_instance(array(
    'field_name' => FIELD_GALLERY_VIEW_FIELD_NAME,
    'entity_type' => 'node',
    'bundle' => 'article',
    'label' => t('Choose gallery View'),
    'description' => t('Gallery view type for display gallery field collection'),
    'widget' => array(
        'type' => 'OPTIONS_SELECT',
        'weight' => 0,
        'settings' => array('size' => 50),
    ),
    'display' => array(
        'default' => array(
            'label' => 'hidden',
            'settings' => array(),
            'weight' => 1,
            'type' => 'hidden'
        ),
        'teaser' => array(
            'label' => 'hidden',
            'settings' => array(),
            'type' => 'hidden',
        ),
    ),
    'required' => TRUE,
));


Drupal change the number of items in view PHP

insert HTML markup on the View header and make three buttons with HTML markup and then link each of the button like

10 elements

20 elements

30 elements

After this you can style the button however you want.


How to pass variables to overridden Twig template located in module?

You need to function MYMODULE_preprocess_node_add_list.

function MYMODULE_preprocess_node_add_list(array &$variables) {
  $variables['hello'] = 'world';
}

This preprocess hook is actually called HOOK_preprocess_HOOK. See the last HOOK in its name? You need to target the 'base hook' which is node_add_list. So preprocess that instead of the page.


hook_menu

items['authorize-form'] = array(

  'title' => t('Pay via Authorize'),

  'page callback' => 'generate_authorize_form',

  'access arguments' => array('access content'),

  'type' => MENU_CALLBACK

);

Callback function to generate authorize form using Authorize.net SDK

function generate_authorize_form(){
    require_once 'anet_php_sdk/AuthorizeNet.php'; // The SDK
    $url = "http://YOUR_DOMAIN.com/index.php";
    $api_login_id = 'xxxxxxxxx';
    $transaction_key = 'xxxxxxxxxxxxxxxx';
    $md5_setting = 'xxxxxxxxx'; // Your MD5 Setting
    $amount = "5.99";

    ob_start();
    AuthorizeNetDPM::directPostDemo($url, $api_login_id, $transaction_key, $amount, $md5_setting);

    $output = ob_get_content();
    ob_end_clean();
    return $output;
}


View with two filter groups using "OR" not aggregating correctly

The answer to this was actually quite simple, and the source of error was misunderstood.

The filter groups were NOT the issue at all, but rather that there were excluded fields in the view which were not set to "count" under their aggregation settings. This broke the count. If you are having this issue, make sure all fields in your aggregation view are set to "count".


How to add global variable in custom js file

You can do something like

(function ($, Drupal, undefined) {
    var my_global;

    Drupal.behaviors.exampleModule = {
        attach: function (context, settings) {
            my_global = 1234;
        }
    }
})(jQuery, Drupal)

and the Javascript scope-chain rules will make my_global visible to your whole closure.  If you need a true global, move the declaration of my_global:

var my_global;

(function ($, Drupal, undefined) {
    Drupal.behaviors.exampleModule = {
        attach: function (context, settings) {
            my_global = 1234;
        }
    }
})(jQuery, Drupal)

Personally, my JS files for Drupal start out as

var MYMODULE = (function(me, $, Drupal, undefined) {
    me.name = "MYMODULE";

    function attach (context, settings) {
        console.log(me.name + ".attach()");
    }

    Drupal.behaviors[me.name] = {
        attach: attach
    };

    return me;
}(MYMODULE || {}, jQuery, Drupal));

and I then add locals for module-wide variables, or directly to the module if other modules need them.  The article JavaScript Module Pattern: In-Depth explains this very well.


Which module can I use to visualize Drupal log data in the format of a chart?

Native charting modules

Have a look at the Comparison of Charting modules. Here is a quote from it:

  There are a variety of modules that facilitate the creation of charts. When it comes to charting in Drupal, the saying "There's a module for it" doesn't really apply. In this case, it's more accurate to say, "There are plenty of modules for it" ...

  These modules support for various charting libraries that may be desirable based on a site's desired appearance, feature-set, and licensing needs.

Here is the shortlist of 'native' charting modules, for which at least 1 official release exist (quote from that comparison also):

Forena facilitates the creation of charts  by using the SVG Graph library. Forena does not depend on Views for creating charts, however it can be used as an extra views style plugin.
Google Chart Tools provides a simple API to build interactive SVG charts, using the Google Chart Tools.
Chart currently only supports the deprecated Google Chart Tools: Image Charts, which is deprecated as of April 20, 2015. Though issues #2371567, #2371075 and #2368793 are about addressing that. It is the most commonly used charting module today (over 25K reported installs, which is more then double of all other native charting modules together).
Charts (not to be confused with the charting module with namespace chart !!!) provides an API that can be used as a stand-alone API, and the integration with Views supports building charts with no coding.
Charts and Graphs, which is an API for developers. It can be extended by third-party modules that want to add their own charting implementations. It does nothing by itself. It should only be installed if some other module requires it. Views Charts is one of the modules using it.
Flot provides an API and views integration for using the Flot graphing library.

Note: there are quite a few additional 'native' charting modules, though they do not have an official release (yet), only dev, alfa or beta versions.

Forena showcase

Have a look at my answer to "Views Table with Taxonomy Terms for Columns and Rows", which details how I once created a crosstab report (using the Forena module) that looked like so:

Then look at the video demo "How to create Crosstab Tables and (related) charts" to get an idea what it takes to create a chart from such crosstab tables.

Disclosure: I'm the author of the comparison and co-maintainer of the Charts, Chart and Forena.


How to reduce the delay in sending email notifications about new content?

As an alternative to what you're trying to get to work, you might want to consider using the Rules module.
Below is a summary of how you can get this to work:

Introduce an additional flag to allow "flagging" these (new) nodes by all users "with the role that should receive these eMails" (as in your question). Let's assume you label that flag as "eMail notification outstanding" (to indicate that something still needs to happen to send that eMail later on).
Create a rule to flag the newly saved content, using the new flag (from step 1) for each of the users "with the role that should receive these eMails". A possible approach for this is to build a list of these users using Views bulk operations (VBO) module, which is then processed by the rule to actually flag this content by those users.
Use the Views and the Views bulk operations (VBO) modules to create a VBO list of all flagged nodes (flagged by the new flag in step 1), sorted by flagging date (oldest first), and limit the results to the first X users only (pick a value for X that fits your needs).
Create a new Rules Component that "loads the VBO list" (from step 3) and add a loop to that rule to perform these Rules Actions:

eMail each of the users in that VBO list.
unflag (using flag from step 1) the node (for the user for which you just produced an eMail). This to indicate that the eMail notification was completed (no longer outstanding).
In that same rule, as the very last Rules Action, add an action to reschedule the exectuion of the same rule within Y minutes or hours  (pick a value for Y that fits your needs).

Use the Rules UI to manually trigger the very first execution of that self-rescheduling Rules Component (from step 4.).

Using the above approach, every Y minutes (or hours), Rules will notify X users "as requested". Obviously, you'd have to think a bit about what the best values for X and Y would be in your case. E.g. if you have thousands of users in that role (to receive the eMails), you've to be careful to prevent that your eMails would be considered as spamming. However, if you only have a few users in that role, you should be OK with a low value of Y (even like every 5 minutes or so?).


how to add field_image widget (imagefield crop) to a custom form api

Problem is, Field API and Form API are separate things. You can add form elements to custom forms created with Form API, and you can add fields to custom entities created with Field API, but you can't really cross the border. Well, you can wrap form element into a field, but not the other way around.


Utilizing admin panel values elsewhere in a module

You need to utilize system_settings_form when you write your admin form.

function mymodule_admin_form($form, &$form_state) {
  $form['my_textfield'] = array(
    '#type' => 'text',
    '#title' => 'Title',
    '#default_value' => isset($form_state['values']['my_textfield']) ? $form_state['values']['my_textfield'] : '',
  );

  return system_settings_form($form);
}

Submitting this form will call system_settings_form_submit which saves all the form fields as a variable, so you need to be careful when naming the form fields.

Now all you need to do is call:

variable_get('my_textfield', 'default value to return if no value is set');

from any function after drupal is bootstrapped.

Here's more information on how to create a configuration form: Creating the configuration form


URL-dependent templates only evaluated once, incorrectly cached

As stated you would need a cache context for the block, more specifically the "url.path" cache context. You could add it in a preprocess hook, but it requires some PHP knowledge.
You could try the Blocache module which lets you change the Cacheability metadata for any block. Once enabled, select "Contexts" and check "url.path". Disclaimer: I have not tried this module myself, but it looks like it would solve your problem.


Webform views - creating a filter using date from user-submitted data

I just found a patch for this exact functionality. Out of the box, you are right, it acts as its a straight up text field. If you were to use entityform instead of webform, I believe you would be able to do this as it uses normal drupal fields.

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


In Scald, is there a way to link a scald atom shown using an image style to the original image?

This option is not for the automatical link purpose.

What you want is always to link to the original image. This is configurable in the Manage Field display tab.

In your 2nd setup, enable "Link to content" will link to the content (the host entity, not the atom itself). If you want the image is linked to the atom, then there are two options:

Write a custom player and use it (the current player has no "link" option)
Configure qt the Manage display of the atom (admin/structure/scald/image/display), hide the atom itself and show the image field, with the link option.


An AJAX HTTP error ocurred. HTTP Result Code: 500 (while trying to rebuild content access perms)

The problem with this was the server, the server was refusing the ajax request, maybe a php memory problem I have migrated my drupal website to a VPW


What do I do with the list of blocked IP addresses

We've all been there and felt that.

This is time consuming.  You could report the abuse to the abuse@domain.xyz email by looking up the Whois record for each IP.  This email address and investigation are required by ...

  The 2013 Registrar Accreditation Agreement (RAA) requires
  ICANN-Accredited registrars to provide abuse contact information and
  take steps to investigate reports of abuse. This includes:

  Maintaining an abuse contact to receive abuse reports involving domain
  names sponsored by the registrar, including reports of illegal
  activity, and publishing an email address to receive reports on the
  home page of the registrar's website;

  Taking reasonable and prompt steps to investigate and respond
  appropriately to any reports of abuse;

  Establishing and maintaining a dedicated abuse point of contact to
  receive reports of illegal activity filed by law enforcement or other
  similar authorities designated by the government of the jurisdiction
  in which the Registrar is established or maintains a physical office.
  The registrar should review such reports within 24 hours of
  submission. This includes a dedicated email address and telephone
  number that is monitored 24 hours a day, seven days a week;

  Publishing on the registrar's website a description of its procedures
  for the receipt, handling, and tracking of abuse reports; and

  Providing an abuse email address and telephone number in Whois
  results.

  The full abuse contact requirements are provided in Section 3.18 the
  2013 RAA.

CleanTalk.org and abuseipdb.com  will accept the IPs and emails you find as spam.  One at a time though so start with the biggest offenders.

  When you sent a report, the IP or Email address with malicious
  activity will be added in our blacklist database with status
  "Suspicious". If we will receive other abuse reports so the status
  will be changed to BlackListed.

Spamcop.net will take spam emails you find then sends "warning information to the internet service provider responsible for hosting the services used by the spammer (web sites and email sending sites)."

Rather than "a growing list of blocked IP addresses", have you considered blocking by country or region or IP range?  You can do that through the .htaccess file or Drupal modules.

I hope this gets you started in your crusade for a better world.


For custom menu blocks the format for the block template file name is

block--menu--<menu_machine_name>.tpl.php

Note: All machine names begin with the 'menu_' prefix and all hyphens are converted to underscores.


List nodes from a taxonomy based on a field

So you need to do the following:

1) Create a view for products

Install Views Field View module
http://drupal.org/project/views_field_view Create a view for 4
products. Make sure it has contextual filter for term id set.
Save it

2) Create a taxonomy view

Create taxonomy view, set display as block, so you could output it in
a block
Add 'taxonomy term parent' filter and make it equal to 0. This way you'll select only parent terms
Select Views Field View in Fields and set it to output a view for products
Save

So now you should have a block which outputs parent taxonomy terms and under each term you have a list of products.

Let me know how it works.


A block is visible in a page depending on two conditions:

None of the condition plugins associated to the block marks the block as not visible
The current user has the permission to see the block

Assuming the block is visible at a specific path is wrong because the current user could simply not have the permission to view it. Adding to that the fact that any third-party modules could define new condition plugins, the only way to avoid duplicating in code the block settings done from the user interface is using code similar to the following one.

function mymodule_preprocess_html(&$variables) {
  // Replace 'block_id' with the ID of your block.
  $block = Block::load('block_id');
  if ($block && $block->access('view')) {
    // The block is visible to the current user.
    // Replace 'the-class-to-add' with your CSS class.
    $variables['attributes']['class'][] = 'the-class-to-add';
  }
}

Remember to add the correct use statements on the top of the file containing that code (e.g. use Drupal\block\Entity\Block; to be able to access the block entity class).


How to upload media to S3 using entity browser and Flysystem S3 module


Print profile2 fields in user-profile.tpl.php

If these fields are already a part of $user_profile and what you are wanting to do is print them in another place/div on the page, you can do something like this:

<?php
  hide($user_profile['field_name']);
  hide($user_profile['field_twitter']);
  hide($user_profile['field_facebook']);
  hide($user_profile['field_role']);
?>
<div class="profile"<?php print $attributes; ?>
  <?php print render($user_profile); ?>

  <?php print render($user_profile['field_name']); ?>
  <?php print render($user_profile['field_twitter']); ?>
  <?php print render($user_profile['field_facebook']); ?>
  <?php print render($user_profile['field_role']); ?>

Eg, hide() the fields you want to print elsewhere, then render() the rest of the profile and then finally render() those specific fields where you want them.

Now, if you are getting an error because these don't exist everywhere, you can do something like this:

<?php if (isset($user_profile['field_facebook']): ?>
  <?php hide($user_profile['field_facebook']); ?>
<?php endif; ?>

and a similar wrapping around the final printing (ADDITION: this appears to be unneeded as I didn't get any errors when I did a hide($user_profile['i_got_nothing_to_hide']); and a quick look at the code for hide and render shows that they pretty smart/sneaky about being passed undefined variables or keys)

Or you could check on the user role,  but if this is going to begin to put a lot of php logic into the template, you may want to investigate preprocessing() it and using a special template for the user profile of the users with this/these roles.


How can I use a view on site2 that consumes data from site1?

The External Entities module can help you in this task.

  This module allow you to connect to datasets from external databases
  and use it in your Drupal 8 website. While content lives external,
  Drupal sees those remote entities as internal. This makes it possible
  to alter the field displays, add references, comments, pathaliases,
  share buttons, webshop products and more.

You can read to Drupalize remote data with external entities.


Search button with 'lens' icon on the exposed view's filter - Drupal 7

The code you posted is good. The only "problem" is that your lens image is "sprites" image - designed to be shown only partially, depending on the state of your button. There is no standard for this, so Drupal does not support this. You ave two options there:

Cut your image, leave only the part you need.
Use CSS to implement sprite style your image was created for.


Try setting width:220px to the left td elements in the table.

In css:
table tr td:first-child {width: 220px;}


How do I increase the length of a text-field with saved values?

I got an answer from my friend as well. I would like to share his code here:

/**
 * Update field.
 */
function MODULE_update_8301() {
  $db = \Drupal::database();
  $field_name = 'field_MY_TEXT_FIELD';
  $table_prefixes = [
    'node',
    'node_revision'
  ];
  foreach ($table_prefixes as $table_prefix) {
    $db->schema()->changeField(
      "{$table_prefix}__{$field_name}",
      "{$field_name}_value",
      "{$field_name}_value",
      [
        'type' => 'varchar',
        'length' => 255,
        'default' => '',
      ]
    );
  }

  $config = \Drupal::configFactory()->getEditable('field.storage.node.' . $field_name);
  $settings = $config->get('settings');
  $settings['max_length'] = 255;
  $config->set('settings', $settings);
  $config->save();
}


How to get the nearest place from database

You have to play around location views. Add a filter and argument to sort by proximity.


Complicated module update error HTTP error 0

I had the exact same problem and the solution given by Neograph734  was to manually add the module. If you have Filezilla, connect to your drupal site files. Go to Sites-->all--->modules--->  Locate the captcha folder, delete everything in that folder. Upload the updated captcha module files. (Download and upzip first).

Once this is done, you will also need to update the database. It will show you where to do that once you click on reports. Once the database is updated, your module should now be upgraded and working. :)

No more nasty notices about having to upgrade it!


How do I access the array of label values?

The field definitions are in a slightly different place, you can extract all labels with something like this:

$labels = array();
foreach ($view->display['NAME_OF_DISPLAY']->display_options['fields'] as $definition) {
  $labels[] = empty($definition['label']) ? 'No label' : $definition['label'];
}


If you look in the source code of the module you find that tag is a configuration entity (http://cgit.drupalcode.org/dfp/tree/src/Entity/Tag.php). This type of entities are not fieldable like content entities. But you can add custom fields by altering the config form and store the added fields in your module configuration.

Here is a how-to for this:

https://www.webomelette.com/drupal-8-custom-data-configuration-entities-using-thirdpartysettingsinterface


It is possible with Node Convert.

  Node Convert adds a menu tab "Convert" on the node view page, i.e. node/1/convert, which gives the ability of converting the node from it's current node type, to another node type. Also it gives the ability of transfering all the custom cck field values of the current node type, to the destination cck fields, or discard them. As of 5.x-1.4 you can bulk convert many nodes of the same type, to another one that can be accesed in Administer-> Content -> Convert Nodes.


Can't hide fields in user registration form at new menu path

Follow Drupal's standards and change your hook_menu:

/**
 * Implements hook_menu().
 */
function MY_MODULE_menu() {
  $items['admin/author/create'] = array(
    'title' => t('Author'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('MY_MODULE_author_form'),
    'type' => MENU_CALLBACK,
    'access callback' => TRUE,
  );

  return $items;
}


Programatically save comma-separated string as value of taxonomy field

try that:

$terms = explode(',', $string);
foreach ($terms as $key => $term) {
  $node->field_taxonomy[LANGUAGE_NONE][$key]['value'] = $term;
}


drupal_render not working in views-exposed-form.tpl.php?

Ok I noticed that #printed = TRUE on all my form elements, so they are not being printed. Going to make a new question for why they are set that way.


How to translate 'ago' in interval time formatter in views?

can't we do like this?

  //Get today's date.
  $today = getdate();
  //Calculate the date "1 week ago".
  $start_time = mktime(0, 0, 0,$today['mon'],($today['mday'] - 7), $today['year']);

Also, you can change those zeroes to make 'n' hours/ minutes/ seconds ago.


How to hide user picture based on the value of a field in their profile

template_preprocess_user_picture seems to be fair enough approach to me, the hook should be able to unset profile picture from any instance including views etc.

Only thing I doubt could go wrong in your code is conditional unsetting of images. To make sure could you comment out the condition

function MYMODULE_preprocess_user_picture(&$variables) {
        $variables['user_picture'] = '';
}

If that unset your field than problem can be narrowed to make the condition working.

Probable problem with your condition
Can you check if you are getting fields in $variables['account'] object$variables['account'], if not you might need to object the user account and check the field conditions

$uid = $variables['account']->uid;
$account = user_load($uid);
function MYMODULE_preprocess_user_picture(&$variables) {
  if ((!isset($account->field_user_publish_photo) || $account->field_user_publish_photo[LANGUAGE_NONE][0]['value'] == '0') && $variables['logged_in'] != 1) { // hide user photo when Publish photo is turned off
      $variables['user_picture'] = '';
  }
}


Jquery.on method returns undefined is not a function

depending on the version of Drupal you are running, it is likely a jquery version issue. Drupal 7 for example defaults with jQuery 1.4 if memory serves, and .on() was added to jQuery in version 1.7.

You could try jQuery Update module:

Upgrades the version of jQuery in Drupal core to a newer version of jQuery.

Drupal 5 to jQuery 1.2.6

Drupal 6 to jQuery 1.3.2

Drupal 7 to jQuery 1.5.x, 1.7.x, 1.8.x, 1.9.x, 1.10.x and jQuery UI 1.10.2

Drupal 8: TBD


How to change the path when cloning the Taxonomy term view?

To change the path that user's will see, you don't actually want to update the view path (which is not obvious), you need to change the path of the taxonomy vocabulary and its terms.  The Pathauto module makes this easy by creating a pattern for your blog taxonomy at: /admin/config/search/path/patterns (once pathauto is installed and working)


If you're wanting a module-based solution the Context Query Parameters module adds Query String condition that lets you check for multiple query values.

  This module introduces a Context condition that allows you to trigger
  a Context based on query parameters on a given page request.


When you need to lazy-load inline-images, I'd recommend doing that so via Filter plugin system.

That way you wouldn't need to alter any of the HTML in the node body/content.

The filter would be responsible of making the necessary markup changes to support lazy loading images.

The filter plugin should be FilterInterface::TYPE_TRANSFORM_REVERSIBLE type to avoid making changes to node content. That way in CKEditor the images could be maintained same as before. But when they are viewed in the page they would be lazy-loaded.

Here's the plugin I created for my projects:

<?php
// This plug needs to be placed in a custom module:
// `modules/custom/YOURMODULE/src/Plugin/Filter/FilterLazyload.php`

namespace Drupal\YOURMODULE\Plugin\Filter;

use Drupal\Component\Utility\Html;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;

/**
 * Provides a filter to lazy-load images.
 *
 * @Filter(
 *   id = "filter_lazyload",
 *   title = @Translation("Lazyload images"),
 *   description = @Translation("Lazy load images via bLazy"),
 *   type = Drupal\filter\Plugin\FilterInterface::TYPE_TRANSFORM_REVERSIBLE,
 *   weight = 20
 * )
 */
class FilterLazyload extends FilterBase {

  /**
   * {@inheritdoc}
   */
  public function process($text, $langcode) {
    $placeholder_src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';

    $result = new FilterProcessResult($text);
    $html_dom = Html::load($text);
    $images = $html_dom->getElementsByTagName('img');

    foreach ($images as $image) {
      $src = $image->getAttribute('src');
      $image->removeAttribute('src');
      $image->setAttribute('data-src', $src);
      $image->setAttribute('src', $placeholder_src);
      $classes = $image->getAttribute('class');
      $classes = (strlen($classes) > 0) ? explode(' ', $classes) : [];
      $classes[] = 'b-lazy';
      $image->setAttribute('class', implode(' ', $classes));
    }

    $result->setProcessedText(Html::serialize($html_dom));

    return $result;
  }

  /**
   * {@inheritdoc}
   */
  public function tips($long = FALSE) {
    return $this->t('All inline-images will be lazy-loaded.');
  }

}

You still need to attach bLazy library and the initiator js to all pages. But you don't necessarily need the Blazy module to make this plugin work.


On entity save, identify the user fields that have been changed

Per the hook_entity_update() documentation:

This hook runs once the entity storage has been updated. Note that hook implementations may not alter the stored entity data. Get the original entity object from $entity->original.

In your event listener, you can compare the email/password fields on $entity & $entity->original to check if they have changed.


Setting up sub sections with their own editors

Organic Groups is probably what you're looking for. Checkout the following help resources.

the module's project page: http://drupal.org/project/og
NodeOne's Learn Organic groups
Modules Unraveled's Organic Groups


You  an can put HTML in there, just make sure you choose an Input Format (Text Formats in D7) that allows you to use the HTML tags you'll be putting in there.


How to show tooltips on form labels based on view filter descriptions in a Bootstrap sub-theme?

You can do it in form alter, here's an example (add additional conditions yourself):

/**
 * Implements hook_form_FORM_ID_alter().
 */
function yourmodule_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  $field_name = 'filter-title';
  $form['title']['#attributes'] = array(
    'data-toggle' => 'tooltip',
    'data-original-title' => $form['#info'][$field_name]['description']
  );
  $form['#info'][$field_name]['description'] = '';
}


I have done this by setting up two displays of my view

Display 1 is a page display, with the path 'foo/date/%/%'.  This then gets a pair of contextual filters, the first is for the year (the first argument).  The second is for the month (the second argument).

Display 2 is a page display, with the path 'foo/date/%'.  This gets a single contextual filters, the year.


Cannot get theme_links__system_main_menu($variables) to fire now matter what

The Adaptive theme never calls links__system_main_menu from its page.tpl.php file, hence providing an override has no effect and it falls back to theme_links. If you want to override it you will have to provide your own theme suggestion in preprocess hook function.

Look here for more info: THE DEFINITIVE GUIDE TO DRUPAL 7


preventing a date form element from displaying 'day', 'month', and 'year' labels?

I think the property you're looking for is #title_display, not #display_title. Also you wouldn't set it to FALSE but one of these:

before
after
invisible
attribute

In your case you'd want to set it to invisible:

$form['element']['#title_display'] = 'invisible';

That will render the label, so your form remains accessible, but hide it from display.


Adding custom classes to Views Filters (view-filters) and Content (div.view-contents)

Views provides a lot of .tpl files for doing just this. They are found in the /theme folder of the views module folder. The one you want is views-view.tpl.php

Simply copy views-view.tpl.php into your theme's templates folder and edit ~ line 43 to include your bootstrap classes and whatever other markup you require ;)


How to pass arguments to a view from Rules?

I think you're making it too complicated. As per the "Any other ideas on solving this would be much appreciated ..." in your question, I'd rather use the Views Rules module (instead of VBO), as further detailed below.
1. About the Views Rules module
The Views Rules module makes Views data available in Rules, enabling intuitive rule configuration for dynamic data. Some details from its project page:

... provides two types of elements in Rules, configured with a "Rules" view display:

Views loop: A views loop is similar to a regular Rules loop, but allows looping over rows of view results.

Collect view result rows (action): This action collects each variable in all view result rows into list variables for use in Rules.

Tip: When selecting the data type for variables in the view, if the field is an entity identifier (e.g. Node ID), you can set the data type to the entity type (i.e. Node) to directly use the variable in Rules as an entity!

2. Create a view of display type 'Rules'
After you enable the Views Rules module, you can use Views to create a view of the users you're interested in. I.e. "those users that hold an expiring license, and that have been issued a new invoice which remains unpaid" (as in your question). Add of view of display type Rules (important, that's the key to make it work!). Here is how you can add such display:

Next configure the row variables, by using the link that says "edit field info", as shown here:

You probably want to use one or more of the variables similar to those that are shown in this screenprint:

3. Create a rule using the view of display type 'Rules'
Create a rule with the appropriate Rules Actions in it, using these guidelines:

Use the link that says Add view loop to add a Views loop, and select the "Rules" display created in the previous step.
Configure the parameters and variable names.
For each user contained in your Views loop, perform whatever Rules Action that fits your requirement, using the variables you configured at the end of the previous step (you may have to revisit the previous step to add more similar variables there if needed). If you created the Rules row variables as suggested in the previous step, your actual eMail can use tokens such as [usermail:value], [username:value], etc.

4. Use the 'Rules Once per Day' module
Use the "Rules Once per Day" module. Here is how it works (as per the comment in issue 2495775, from the module owner):

You specify a trigger hour on the administration settings page for this module.
The Rule trigger will then run when cron tasks are first run after the start of that hour. The actual run time will depend on your cron task timings.

So this is another way to understand/Read this:

The "Event" will only be triggered when a cron job is run.
And that event will only be triggered 1 time / day, i.e. "next time cron runs after the trigger hour has passed".

Easy, no?


Removing cached reference to missing table: services_user?

That table was added in Services 7.x-3.10; it sounds like one of three things has happened:

You've updated the module but not run the database updates. If you have drush run drush updb, or visit /update.php to go through the process.
You've already run the updates but something went wrong
The table was removed accidentally (maybe by a backup restore)

In either of the last two cases, you can install the table manually with:

$schema = drupal_get_schema_unprocessed('services');
db_create_table('services_user', $schema['services_user']);

or

module_load_include('install', 'services');
services_update_7402();


The CKEditor image dialog is a form, so you can change it via Drupal Form API with hook_form_alter:

/**
 * Implements hook_form_alter().
 */
function MyModule_form_alter(&$form, $form_state, $form_id) {
  // Check if the form is editor_image_dialog.
  if ($form_id == 'editor_image_dialog') {
    // Make caption required.
    $form['caption']['#required'] = TRUE;
    // Change default_value to true.
    $form['caption']['#default_value'] = TRUE;
  }
}


The drush command 'migrate-manifest' could not be found

answering my own question, this is now in the contrib module migrate-manifest:


What is the alternative of hook_custom_theme in Drupal 8?

That is a service now. See \Drupal\user\Theme\AdminNegotiator for an example, which is registered as a tagged service:

theme.negotiator.admin_theme:
  class: Drupal\user\Theme\AdminNegotiator
  arguments: ['@current_user', '@config.factory', '@entity.manager', '@router.admin_context']
  tags:
    - { name: theme_negotiator, priority: -40 }


Get views to format an image field for HiDPI / high pixel density / Retina displays

srcset has (or will have) decent support in browsers.  What I do, is make _2x image styles for everything, and then do a custom theme_image_style():

/**
 * Implements theme_image_style().
 */
function MYTHEME_image_style($variables) {
  // Determine the dimensions of the styled image.
  $dimensions = array(
    'width' => $variables['width'],
    'height' => $variables['height'],
  );

  image_style_transform_dimensions($variables['style_name'], $dimensions);

  $variables['width'] = $dimensions['width'];
  $variables['height'] = $dimensions['height'];

  // Determine the URL for the styled image.
  $path = $variables['path'];

  $variables['path'] = image_style_url($variables['style_name'], $path);

  // See if we have alternates for the srcset
  $image_styles = &drupal_static(__FUNCTION__);
  if (empty($image_styles)) {
    $image_styles = array_keys(image_styles());
  }

  $variables['srcset'] = array('1x' => $variables['path']);

  if (in_array($variables['style_name'] . '_2x', $image_styles)) {
    $variables['srcset']['2x'] = image_style_url($variables['style_name'] . '_2x', $path);
  }

  return theme('image', $variables);
}

and then

/**
 * Implements theme_image().
 */
function MYTHEME_image($variables) {
  $attributes = $variables['attributes'];
  $attributes['src'] = file_create_url($variables['path']);

  // Add in normal attributes.
  foreach (array('alt', 'title', 'width', 'height') as $key) {
    if (isset($variables[$key])) {
      $attributes[$key] = $variables[$key];
    }
  }

  // Add in our srcset if we have two or more.
  if (count($variables['srcset']) >= 2) {
    $srcset = array();

    foreach ($variables['srcset'] as $size => $path) {
      $srcset[] = file_create_url($path) . ' ' . $size;
    }

    $attributes['srcset'] = join(', ', $srcset);
  }

  return '<img' . drupal_attributes($attributes) . ' />';
}

You can also feature detect with Modernizr for srcset and retina support, and then swap out the image src with JS shenanigans if you want.

You can also see if the Picture module does what you want, but there is debate in the community about when <picture> should be used and not used.


How to create multi-value, multi-bundle entity reference fields in code?

Sorry for the long code dump but there's really no other way to do this:

field_create_field(array(
  'translatable' => '0',
  'entity_types' => array(),
  'settings' => array(
    'target_type' => 'node',
    'handler' => 'base',
    'handler_submit' => 'Change handler',
    'handler_settings' => array(
      'target_bundles' => array(
        'article' => 'article',
        'page' => 'page',
        'webform' => 'webform',
      ),
      'sort' => array(
        'type' => 'none',
        'property' => 'nid',
        'field' => 'body:value',
        'direction' => 'ASC',
      ),
      'behaviors' => array(
        'views-select-list' => array(
          'status' => 0,
        ),
      ),
    ),
  ),
  'storage' => array(
    'type' => 'field_sql_storage',
    'settings' => array(),
    'module' => 'field_sql_storage',
    'active' => '1',
    'details' => array(
      'sql' => array(
        'FIELD_LOAD_CURRENT' => array(
          'field_data_field_entity_reference' => array(
            'target_id' => 'field_entity_reference_target_id',
          ),
        ),
        'FIELD_LOAD_REVISION' => array(
          'field_revision_field_entity_reference' => array(
            'target_id' => 'field_entity_reference_target_id',
          ),
        ),
      ),
    ),
  ),
  'foreign keys' => array(),
  'indexes' => array(
    'target_id' => array(
      'target_id',
    ),
  ),
  'field_name' => 'field_entity_reference',
  'type' => 'entityreference',
  'module' => 'entityreference',
  'active' => '1',
  'locked' => '0',
  'cardinality' => '-1',
  'deleted' => '0',
  'columns' => array(
    'target_id' => array(
      'description' => 'The id of the target entity.',
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
    ),
  ),
  'bundles' => array(
    'node' => array(
      'page',
    ),
  ),
));

The target_bundles in the handler_settings is where you assign the different bundles, and the cardinality of -1 ensures unlimited values for the field.

In case you're interested, this is the code that allowed me to build the above definition from an existing entity reference field (which seems to have originated at this blog post):

$entity_type = 'node';
$field_name = 'field_entity_reference';
$bundle_name = 'article';

$info_config = field_info_field($field_name);
$info_instance = field_info_instance($entity_type, $field_name, $bundle_name);
unset($info_config['id']);
unset($info_instance['id'], $info_instance['field_id']);
include_once DRUPAL_ROOT . '/includes/utility.inc';
$output = "field_create_field(" . drupal_var_export($info_config) . ");\n";
$output .= "field_create_instance(" . drupal_var_export($info_instance) . ");";
drupal_set_message("<textarea rows=30 style=\"width: 100%;\">". $output .'</textarea>');

It's a handy little script; I'm sure I've posted it somewhere here before but I can't find it at the moment.


Displaying HTML entities in title through a view

Yes! You need to add the attribute 'html' => true. This is a link property in Drupal 7. If you render any link in Drupal 7 and want to add some extra HTML inside it you need to set array('html'=>true).


Send list of node title and body via email to users

Hope this will help you create a module with hook_cron

    function mymodule_cron()  {

      $time_fetch=time();
    $result = db_query("SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created, 'node' AS field_data_body_node_entity_type
    FROM
    {node} node
    LEFT JOIN {node_revision} node_revision ON node.vid = node_revision.vid
    LEFT JOIN {node} node_node_revision ON node_revision.nid = node_node_revision.nid
    WHERE (( (node.status = '1') AND (node.type IN  ('question')) AND (node.created BETWEEN $time_fetch+0 AND $time_fetch -604800) ))
    ORDER BY node_created DESC")->fetchAll(PDO::FETCH_ASSOC);
            //WHERE date BETWEEN DATE(NOW( ) + INTERVAL 7 DAY ))->fetchAll(PDO::FETCH_ASSOC);
        $all_user = db_query("SELECT users.mail AS users_mail, users.uid AS uid, users.created AS users_created
    FROM
    {users} users
    WHERE (( (users.status <> '0') ))
    ORDER BY users_created DESC")->fetchAll(PDO::FETCH_ASSOC);

        foreach ($result as $mail_data)
        {
            foreach ($all_user as $user_mail) {
            //dpm($mail_data);
            //dpm($user_mail);
//here i think you can use the drupal_mail function
            //$message = drupal_mail('mymodule', 'message_key', $to, user_preferred_language($user), array('body' => $body, 'subject' => $subject, $from, TRUE));

        }
        }
        }

the drupal mail api is here drupal_mail


User role weaker than authenticated user

This doesn't appear to be documented in the LoginToboggan interface anywhere but the default behaviour actually does what you want it to do.

You need to create new role like you mentioned, a pre-authenticated user.
After creating the new role go to LoginToboggan config page and select this new role as your Non-authenticated role and save.
Now when you go back to the permission config page you'll see this new role is excluded from the authenticated user permissions, just like the anonymous user.


Why can anonymous users access private files using the system URL?

/sites/default/files/private/assets/image.jpg will never work because of an .htaccess directive prohibiting direct access to that directory.

Beyond that, this strikes me as an issue with OG.  I'd try executing a module_implements('file_download') and have a look at what modules might be interacting with determining if a given file is accessible.


How to Map files if I have fid in Drupal 6 table and field in Drupal 7 content type?

I think you also need to specify the file_class:

$this->addFieldMapping('field_image', 'fid')
  ->sourceMigration('ExFiles');

$this->addFieldMapping('field_image:file_class')
  ->defaultValue('MigrateFileFid');

This is explained in the file migration docs; without the class, the source is assumed to be a URI and not a fid.


Fatal memory Error at the bottom of the page but not WSD. What this means?

You can change the amount of memory available in your php.ini file (i think) - making more memory available to your drupal installation and thereby doing away with this error

see https://drupal.org/node/76156
and https://drupal.org/node/1915140

for further details


Hide the Drupal /user/register form from spam, but leave open registration to Commerce/Ubercart

Basically you can keep user registration functionality, notification emails etc.. and prevent access to the user register page by either altering the registration form, or better yet, the page callback for the entire page.

e.g:

/**
 * Implements hook_menu_alter
 **/
function MODULE_menu_alter(&$items) {
  // Deny all access to the user/register page.
  // Administrators can still create user accounts via admin > people
  // Notification emails etc.. are still operational
  // and Commerce / Ubercart can create user accounts following checkout etc..
  $items['user/register'] = array(
    'access callback' => FALSE,
  );
}


Taxonomy terms are still entity reference fields, just like the field you have connecting your events and venue nodes. So there is no need to duplicate the same functionality.

You can list the Events referencing the Venue with a Views Block:

Create Content Views with Block display listing Events
Add a Contextual filter for the field_hosted_by field and configure it:
When the filter value is NOT available
Provide default value
Content ID from URL
When the filter value IS available or a default is provided
Specify validation criteria
Content
Venue
Save the Views and place the Block in a region of your choice to be displayed on Venue pages

You cant test the views output by entering the node ID of a venue node into Preview field, before placing the Block to test it's working.


How to display a computed field in an automatic node title?

What about setting up a rules event to set a data value for the node title using the event "after content is saved" ?

This should work...

Set up a rule with the event "after content is saved".
Set up the action "set a data value"
Choose the title field, and use the tokens to set your value.


Why is the CSS rule that I applied via the CSS injector module not active on my mobile device?

Clear cache or CSS aggregation bug

Comment #1 in issue # 1588822 contains some interesting hints that might help to answer your question:

to see the changes, you must clear the cache. Since your question doesn't mention anything like that, make sure you did cear the cache.
bugs in CSS aggregation can be problematic with specific CSS constructs. If you trigger one of those, it can result in CSS being omitted from the aggregation CSS file.

CSS rule overwritten by another module

And the rules provided by this module might be overwritten by another module, as briefly mentioned in the last paragraph of the module's readme.txt ...

CSS edits via external editor

CSS edits via external text editor not displaying (which only applies to the 7.x-2.x version, not to 7.x-1.x) might be what's causing the issue.


Use single values added by field-collection module in Views?

I've recently done this before. It's really easy, you can create a Node type view. Then you just add the field collection field that's attached to your node as a Relationship, in your case "Content: Gallery and caption".

Then after you've added the relationship, when you click "Add" on the fields, your field collection fields will be available to select. Their names will start with "Field collection item: *".

If you're using Node reference field inside your field collection then you need to add one more relationship. See this issue and #2 comment for solution.


Random product variations "not available"

In my case it depended on which variation I physically have first in the variation list. If the product I have first in the variation list has a price and positive stock number, then I get an Add To Cart button for all variations.

If the product I have first in the variation list does NOT have a price greater than $0 and positive stock number then for ALL variations I get "Product Not Available".

So for me physically dragging and changing the order of the variations is what changed whether I saw Add to Cart, or Product not Available - I had to have an eligible product listed first in the variation order.

The only catch is, it allows you to click the Add To Cart button on products that are not eligible for checkout, however it does not add anything to the cart or functionally mess things up.

Naturally I would prefer the Add To Cart button change dynamically depending on the status and info of that variation, but technically this works.


How can I show the drop-down lists for countries/administrative areas (from Addressfield) as exposed filters in Views?

As of right now, there is no such views integration in the Addressfield module, although the linked issue does include a discussion of possible directions to take to tackle the problem.


Why does my site still use URLs containing the "q" query parameter?

The initial ?q= has nothing to do with pathauto, that is handled by Clean URLs. You should start by verifying that you have those enabled on admin/config/search/clean-urls

If clean URLs are enabled but don't work, or fail to become enabled, the most common cause is that the .htaccess file from the Drupal root directory is missing. This is unfortunately somewhat common since the leading dot in the filename makes the file hidden.

Occasionally, the clean URLs test gives a false negative result.

This assumes you are running a Apache web server; otherwise, you will need to seek URL rewriting help for your particular webserver. You will be able to find Drupal specific instructions to the vast majority of webservers with Google.


Login error: call to undefined function entity_load in User module

Your error's stating that it can't find a function that should be in drupal core. Check you includes folder. There should be a file in there called common.inc, make sure the function entity_load is defined in there.


A route is a path which is defined for Drupal to return some sort of
  content on

source: Routing system overview

You can think of it like this, a route creates a url that displays a page. This route has a controller which executes the function/method that is in the controller class.

my_module/my_module.routing.yml

my_module.content:
  path: '/fetch'
  defaults:
    _controller: '\Drupal\my_module\Controller\DoC2cController::content'
    _title: 'Hello World'
  requirements:
    _permission: 'access content'

In the example above when you go to /fetch it will execute the content() method that is inside the DoC2cController class php file. This method must return a render array.

For more in depth info read Structure of routes.

my_module/src/Controller/DoC2cController.php

<?php

namespace Drupal\my_module\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Form\drupal_set_message;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
 * Defines HelloController class.
 */
class DoC2cController extends ControllerBase {

  /**
   * Display the markup.
   *
   * @return array
   *   Return markup array.
   */
  public function content() {

    $apikey = ""; //API KEY MUST BE PUT HERE GOT FROM DB
    $origin = ""; //ORIGIN EXT MUST BE PUT HERE OR GET FROM SOMEWHERE
    if ($apikey == "") {
        drupal_set_message(t('APIKEY MISSING'), 'error');
        throw new NotFoundHttpException();
    } else if ($origin == "") {
        drupal_set_message(t('ORIGIN MISSING'), 'error');
        throw new NotFoundHttpException();
    } else {
        $opts = array(
           'http' => array(
               'method' => "GET",
               'header' => "Content-type: application/json\n"
                           ."X-Api-Key: ".$apikey,
           )
        );

        $context = stream_context_create($opts);
        $response = file_get_contents("https://....../api/originatecall/".$origin."/".$_POST['number'], false, $context);

        //echo $response;
        $response = "CALLING...";
    }

    // Make response string translatable
    $translatable_response = new TranslatableMarkup("@reponse", [
      '@response' => $response,
    ]);

    return [
      '#type' => 'markup',
      '#markup' => $translatable_response,
    ];
  }

}


Can I create non-default EntityReferenceSelection?

Finally, after some investigation, two required items never documented:

unlike the core EntityReferenceSelection plugins that, for some reason, get away without it, you have to provide

deriver = "Drupal\Core\Entity\Plugin\Derivative\DefaultSelectionDeriver"

in the plugin annotation.

It might be completely unnecessary in your case but you have to make sure your custom entity type has an entity_key named label. If it doesn't, core will use PhpSelector instead of your selector, forcedly.


How to prevent user point totals from going below a threshold for a given user?

Here the solution with custom module implementation:

implement hook_userpoints($op, $params) function in your custom module to check the user points in every transaction with two option called points before and points after.

For your thing check if the points are less than your threshold value, set your threshold value after the transaction.

for more referencehttp://api.worldempire.ch/api/userpoints/functions?page=1 check this.


grabbing data and displaying it in block twig

Because you've specified the template parameter in the hook_theme function the template file name should be exactly as specified block--no_athelete_match.html.twig. The underscores are converted to dashes only in the case where the template parameter is not specified in the hook_theme function.


When you installed Drupal you should have had to setup a main account:

That is the login you should be using, if you don't know that password go to /user and click Forgot Password and you can retrieve your login if you remember username or email you used. Since you got (Pending Admin Approval) it should be that email that is registered as main account.

(Pending Admin Approval) emails are sent when someone else tries to register an account on your site.


So since nobody provided acceptable answer, based on the above comments I tried the following bash-script and it worked flawlessly:

sudo -u $USER /usr/local/bin/composer --quiet create-project drupal-composer/drupal-project:8.x-dev $HOME/public_html --stability dev --no-interaction
cd $HOME/public_html/web
drush si -y \
  --db-url=mysql://$MYSQL_USER:$PASS@localhost/$DB \
  --site-name=$DOM \
  --site-mail=$EMAIL \
  --account-mail=$EMAIL \
  --account-name=$USER \
  --account-pass=$PASS >> /dev/null 2>&1


You are probably wanting something like Commerce Cart Estimate.


How can I let registered users upload images using a form in Drupal 7?

You need the field permission module. Everything is already contained in Drupal core.

Create a content type.
Add an image field and allow multiple instances of this field.
With help of the field permission module make sure registered users have the right to edit your image field.
Configure ImageCache to output the images the way you want.

As an add on you might have a look at views, wich allows you to output many nodes with their images, sorted and/or filtered the way you want.


Clean up test payment transaction from drupal commerce site

The short answer is there is no such page. What you're attempting to build with VBO should work well, but currently there is no automatic deletion of payment transactions when orders are deleted. It's questionable whether or not we actually want that to be the default behavior. However, if you're just using VBO driven by custom rules components, you should be able to load any payment transaction referencing the order to be deleted and delete them from within the same rule. Using commerce_order_delete() will not delete payment transactions; for that you'd need commerce_payment_transaction_delete().


You can set multiple path aliases for one node, this is no problem. If you can't do it with Pathauto, then it's possible with custom code when saving the node.

But in your case it might be more efficient to set up different routes for /ticket/{node} and /discussion/{node}. You can either set a fixed route parameter or use a custom node controller to set a marker, that you can use in theme name suggestion to choose the custom template.

Another solution would be to set up a View with a contextual filter for the node and two displays with different paths. Choose for each a different view mode to get different templates. Technically it's almost the same, but you need no custom module, because Views sets up the routes for you.


Redirect after login for specific role on specific day using Rule

There is an interesting comment in issue 2495775, related to the "Rules Once per Day" module, from the module owner. It says:

  You specify a trigger hour on the administration settings page for this module. The Rule trigger will then run when cron tasks are first run after the start of that hour. The actual run time will depend on your cron task timings.

The way I understand/Read this (haven't experimented with it yet though) is like so:

The "Event" will only be triggered when a cron job is run.
And that event will only be triggered 1 time / day, i.e. "next time cron runs after the trigger hour has passed".

Obviously, by using the "Day of the week is a"-option, an extra condition might be that the day has to match also.

With that in mind, it appears to me that this module can not help you to implement what you're trying to do. You want something to happen "when some user performs login", not "when some cron job is run".

But, maybe there is a way to reach your goal by cutting your problem / question in 2 parts:

Create a 1st rule that takes care of "Redirect after login for specific role to "some URL".
Create a 2nd rule that, using the "Rules Once per Day" module, sets the path for that "some URL". To actually set the path, their might be multiple options / modules to consider. I'm think of things like 'global redirect', using some 'token', maybe using the Variable module, etc (more investigation / research needed to find the best fit).

Yes the Rules module is one of those amazing Drupal modules. However it does have some challenges with processing dates ... (= open issues in its issue queue).

If the above doesn't help, then consider using an approach as detailed in the (great) answer to the question about Rule to check if a date value is a specific day of the week ...

Curious to hear if you can get it to work somehow.


migrate drupal site , error occured, the site was down

I solved the problem,  the link : https://www.drupal.org/node/1882292  i just follow the #11 's method and create the image_dimensions table.


Dashboard doesn't contain the "Customize dashboard" link

To see the Customize dashboard link, the logged in user needs the Admin blocks permission, as said in admin/people/permissions.

  Customizing the dashboard requires the Administer blocks permission.

This is how I see it when logged in as user #1, who has all the permissions.

This is how I see it with an account without that permission.

If then I give the Administer blocks permission to that account, this is how the dashboard appears.


I don't see the destination configuration here - presumably the plugin is entity:file, correct? Are you setting default_bundle there, so the file entities are created with the correct type (the bundle those fields are attached to)?


Include a PHP file located in the home directory in a module

Drupal 7 defines the constant DRUPAL_ROOT, which contains the name of the directory where Drupal is installed. It is used from Drupal functions, such as module_load_include() in a way similar to the following one:

if (function_exists('drupal_get_path')) {
  $file = DRUPAL_ROOT . '/' . drupal_get_path('module', $module) . "/$name.$type";
  if (is_file($file)) {
    require_once $file;
    return $file;
  }
}

In your case, you should use the following code:

require_once DRUPAL_ROOT . "/$filename";

The variable $filename contains the name of the file to load.


Database object syntax for where conditions giving error

You need a where():

$query = db_select('punbb_posts', 'p')
->fields('p', array('id', 'message', 'posted', 'poster_id'));
$query->join('punbb_topics', 't', 'p.topic_id = t.id');
$query->addField('t', 'posted');
$query->addField('t', 'id');
$query->addField('t', 'subject');
$query->addField('t', 'forum_id');
$query->addField('t', 'first_post_id');
$query->where('t.first_post_id = p.id');


In Drupal 7 With Latest CKEditor, Media upload button not working

I found the solution:
in order to use the upload plugin, the user has to either have the Edit media or the Administer media permission.


how to output image file from database drupal 7?

Firstly save image to your server and then you can output the image.

You can save image by using file_save_upload().

  file_save_upload : Saves a file upload to a new location.

$file = file_save_upload('myimage',array(), 'public://');

Get fileid(fid) of the image

$fid=$file->fid;

And then save this $fid to your database.

After it get fid from database

  $upload_record = file_load($fid);
  $url = $upload_record->uri;

  $render_image = theme(
    'image_style',
    array(
      'style_name' => 'Style_name',
      'path' => $url,
      'getsize' => TRUE,
      'attributes' => array(
        'width' => '250',
        'height' => '162')
      )
    );

Now print $render_image variable where you want to display image.


Here is another approach to write Dynamic queries. We generally write queries in phpmyadmin or mysql command prompt and then convert them to D7 style or dynamic queries using Query coder module.

For example, as per your question, you want to find out all those records in child table which don't exist in parent table.

So D6 style query,

db_query("SELECT c.* FROM {child} c LEFT JOIN {parent} p ON c.p_id = p.p_id WHERE p.p_id IS NULL");

after converting to D7 style query using query coder module would look like,

$query = db_select('child', 'c');
$query->fields('c', array('*'));
$query->leftJoin('parent', 'p', 'c.p_id = p.p_id');
$query->isNull('p.p_id');
$result = $query->execute();


View that display single node which has id the same as last part of url (from last / to the end)

Normally the parameter is not named, it is a single % without name:

portfolio-entries/%

The example node/%/feed is also a single % in the middle part of the url. The third part of the url is a fixed feed, so that only urls with a /feed at the end will match.

To use this parameter for filtering you need to set a contextual filter in the advanced settings. If you only have one parameter, this filter will automatically get this, when selecting the field you want to filter.


The correct way to alter contextual links is to use hook_contextual_links_alter.

In your case, it should look something like:

function my_module_contextual_links_alter(array &$links, $group, array $route_parameters) {
  if ($group === 'block') {
    // Hide Configure Block option.
    unset($links['entity.block.edit_form']);
  }
}

The contextual links are heavily cached in the browser, therefore you need to make sure that the browser session cache is cleared - window.sessionStorage.clear(); - source.


Drupal Menu Page Callback Function went wrong with arguments

Really embarrassed to say I made one tiny small mistake in this line of code:

return t('Hello, @first_name @last_name'，
array('@first_name' => $first_name, '@last_name' => $last_name));

I was typing the first comma while switched to Chinese Simplified PinYin, correct code should be:

return t('Hello, @first_name @last_name',
array('@first_name' => $first_name, '@last_name' => $last_name));

After I changed it, everything is okay now. Thank you all for paying attention to my silly question.


How do I enable User 1 rights in minimal installation?

User 1 doesn't need any roles to have super user status. User 1 is exempted from the permissions system entirely. So, they automatically have all permissions, regardless of roles they may or may not have.


Display a field 'Category' on the home page

Every field that is associated to a node is shown in the node view page, if the field is not set to be hidden.
You don't need to change the template file used for nodes, as it shows all the node fields by default. If you are not seeing a field is probably because that field settings are set to not show that field.

As you are referring to the home page (a.k.a. the front page), which normally shows the teaser of nodes promoted to front page, check the field settings for the teaser view mode.


Taxonomy term: "The requested page "xx" could not be found."

I will answer my own question on this one:

On a site that has several vocabularies, enabling the selection of one of those vocabularies in the contextual filer of the default taxonomy view, removes the paths assigned to the terms of other vocabularies (those that have nothing to do with the view.) Those paths then default to the root directory and the term pages can no longer be found (or used in another view, etc.)

Un-selecting the vocabulary returns functionality to the term paths of other vocabularies but also allows the existing view to be displayed on all vocabulary term pages (this appears to be functioning as designed however.)

It appears to be a bug in the taxonomy module for which there is no fix. :(


hook_block and rendering a form in content section

When using my case statements for my form entities, I forgot to add in a break;

It all works nicely now!!


ctools modal form shows ugly access denied

I will try to answer this myself. There is no mentioning of this issue in the CTools project itself but the issue is mentioned at the CTools Auto-modal project https://drupal.org/node/1450232

There is also a solution:

implement hook_page_delivery_callback_alter
check if callback is made by one of your ajax links
if so, check is user has access by using menu_get_item and inspecting the resulting router item
if access is ok, do nothing
if access denied or page not found, render a message

The solution at CTools Auto-modal renders the message in the CTools modal box. But I preferred to kill the CTools modal and just do nothing:

$commands[] = ctools_modal_command_dismiss();
print ajax_render($commands);
exit();

This way the dreaded drupal ajax error will never appear.


How to remove a fieldset from around a Mailchimp Subscription field?

You need to use YOURTHEME_form_alter of YOURMODULE_form_alter https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_form_alter/7

there you can alter that form. dpm or print_r $form and see where that fieldset is defined and you can unset it

you will see something like

array(
   'some_field' = array(
    '#title' = 'some title',
    '#type' = 'fieldset',
  )
)

then you can do

unset($form['some_field']['#type'])

that should do the job


This is a great example use-case for the Profile 2 module.

As listed on the project page:

  Profile2 allows for creating multiple profile types, which may be assigned to roles via permissions (e.g. a general profile + a customer profile)


How to collect payments for the missed periods with the hard decline status?

If a customer has a hard decline, they'll need to log in and create a new stored payment option. They can create new stored payments via their account dashboard:

If memory serves, it should then be used by default.


Library item field doesn't show up the remove button

There is no dedicated delete button. Drupals default behavior (including paragraphs) is to automatically delete every empty field at the end of the list. The empty field you see is just a convinience for faster adding of a new item.

Side node: To delete e.g. the first item of the list, remove the content and drag it to the bottom.


That error is often caused by PHP files that generate output they should not. Generally it's caused by errors like having a closing ?> and then a blank line at the end of the file. It's possible that a blank line was added during whatever process you used to move the file to the production server (git, lots of editors, and a few FTP clients will sometimes do this automatically).

In your case I would check /home/zantech0/public_html/yoursitename.com/themes/business/includes/skins-menu/skins_menu.inc to see if it does something that generates output (and therefore triggers PHP to send response headers).


How to redirect from node view to node edit page in a view?

Steps to achieve:

Add new field: 'nid'

Add nid field to view above the title field.
Exclude nid from display.
Goto arrangement and put it above the title field, so that it can fetch it.

Change to existing field: 'title'

Open title field settings.
Uncheck Link this field to the original piece of content.
Expand REWRITE RESULTS section.
Check Output this field as a link checkbox.
Put node/[nid]/edit to the Link path input.


You can use Drupal.behaviors, which is fired upon page load.

function doSomething()
{
  // Do something
}

Drupal.behaviors.myModule = {
  attach:function() {
    doSomething();
  }
};


Permission problems after migrating from Apache to IIS

From here I got the idea to run the following command on a console ("Determining the account used as IIS anonymous identity"):

%windir%\system32\inetsrv\appcmd.exe list config "MyDrupalAppPool" ^ /section:anonymousAuthentication

The result was the following:

<system.webServer>
  <security>
    <authentication>
      <anonymousAuthentication enabled="true" userName="IUSR" />
    </authentication>
  </security>
</system.webServer>

And then running the following command seems to have solved the problem of writing to/deleting from the "files" directory:

icacls c:\<mydrupalpath>\sites\default\files /t /grant IUSR:(OI)(CI)(M)

I don't know if it's secure enough... Please leave comments if you think there is any kind of problem with this approach. Thanks.


How to get the language code when a language name is given?

You can do it with this code.

// Language to search.
$find = 'French';

// Getting all the available languages.
$languages = \Drupal::service('language_manager')->getStandardLanguageList();

$key = key(array_filter($languages, function ($array) use ($find) {
  if (array_search($find, $array) === FALSE) {
    return FALSE;
  }
  return TRUE;
}));

// If you have the devel module installed you can use the dpm function.
dpm($key);


Multiple content types from Views module, not old nodes from one of them

To filter out content that has a "final date" that is in the past, you can set up a filter as follows on the view for this content type.

Filter on "final date" "is greater than or equal to" an offset date of "+0 minutes".

Screenshot below shows the final setting (in the screenshot example I used the "Post date" as the date field to filter on, but in your case it should be "Final date.")

Alternately, you could look at the Scheduler module and instead of using a "Final date" field, schedule these nodes to unpublish at a certain date. Depends on your use case.


Send message to customer after the order has been created by administrator

You could do that by adding a rule to fire on order update and checking to see if the order the order status was previously somestate and the current state now processing or completed.

Of course, you'd have to ensure that the states you wanted match your workflow.


PhpMyAdmin is by far the most popular tool for managing MySQL. It is a webapp which is simple to install and lets you do most tasks through a GUI.

There are many alternatives, notable Chive (more shiny, ajax based tool) and Adminer (more minimalistic). If you want a stand alone application, Sequel Pro might be worth a look.


How can I change the user login tabs labels?

As shown in the answer to the duplicate question you can use template_preprocess_menu_local_task from a custom theme or hook_preprocess_HOOK from a custom module to override the tabs.
If you want to do it right, you also set the page title and the HTML title to display the same strings. Maybe keep things DRY and get the $target_routes array from a small helper function.
First the tabs:
/**
 * Implements hook_preprocess_HOOK().
 */
function MYMODULE_preprocess_menu_local_task(&$variables) {

  $target_routes = [
    'user.login' => t('sign in'),
    'user.register' => t('sign up'),
    'user.pass' => t('reset account'),
  ];
  $current_route = \Drupal::routeMatch()->getRouteName();

  if (isset($target_routes[$current_route])) {
    /** @var \Drupal\Core\Url $url */
    $url = $variables['link']['#url'];
    $route_name = $url->getRouteName();
    $variables['link']['#title'] = $target_routes[$route_name];
  }
}

Then the page title:
/**
 * Implements hook_preprocess_HOOK().
 */
function MYMODULE_preprocess_page_title(&$variables) {

  $target_routes = [
    'user.login' => t('sign in'),
    'user.register' => t('sign up'),
    'user.pass' => t('reset account'),
  ];
  $current_route = \Drupal::routeMatch()->getRouteName();

  if (isset($target_routes[$current_route])) {
    $variables['title'] = $target_routes[$current_route];
  }
}

And finally the HTML title:
/**
 * Implements hook_preprocess_HOOK().
 */
function MYMODULE_preprocess_html(&$variables) {

  $target_routes = [
    'user.login' => t('sign in'),
    'user.register' => t('sign up'),
    'user.pass' => t('reset account'),
  ];
  $current_route = \Drupal::routeMatch()->getRouteName();

  if (isset($target_routes[$current_route])) {
    $variables['head_title']['title'] = $target_routes[$current_route];
  }
}


Assuming you have a module called 'helloworld', and entity type called 'vechile' and a bundle called 'car'.Here is some code that should do the trick.

/**
 * Implements hook_menu().
 */
function helloworld_menu(){
$items['feedbackform'] = array(
'page callback' => 'example_my_eck_form_page',
'access arguments' => array('Access feedback form'),// permission
'type' => MENU_CALLBACK,
);
return $items;
}

function example_my_eck_form_page(){
   module_load_include('inc', 'eck', 'eck.entity');
   $bundle_name='car';
   return eck__entity__add('vechile', $bundle_name);
}

function helloworld_permission() {
   return array(
    'Access feedback form' => array(
      'title' => t('Access feedback form'),
    )
  );
}

Access feedback form is a custom permission so you still would have to give that permission to the  users from admin to be able to access the path.


Different front page node depending on logged in?

There is several solutions to go about this

but the easy way out is this module

Frontpage module

but you can also make a simple  rule that says that if the user is logged in

Rules module

Node.js Alternativ solution

hope it helps you on the way


Drupal does rewrite url but can't load css/themes

Maybe I am missing something, but you shouldn't need the .htaccess rewrite.

It is likely that the 'conflict' is it rewriting the path to your styles. View the source and check what happens when you try to navigate to your css etc.

To achieve this effect all you should need to do (unless I am missing something) is to enable clean URLs, this will remove the index.php?q=.

Then to add .html go to admin/config/search/path/patterns (with pathauto installed) and add .html after [node:title] or [term:name], whichever you are using.

So your patterns would look like:
[node:title].html
and
[term:name].html


Find target bundle(s) for a specific entityreference field

Drupal 8 version:

$bundles = \Drupal::entityManager()
->getAllBundleInfo()['node'];
 foreach ($bundles as $id => $value) {
 $node_fields = \Drupal::entityManager()
  ->getFieldDefinitions('node', $id);
   foreach ($node_fields as $field) {
      if ($field instanceof \Drupal\field\Entity\FieldConfig) {
        if ($field->getType() == 'entity_reference') {
          $target_bundle = $field->getSettings()['handler_settings']['target_bundles'];
          kint($target_bundle);
        }
      }
    }
  }

With $target_bundle, You can do something like this as well to filter out a specific bundle:

if ($target_bundle != null && key($target_bundle) == 'mybundle'){
  kint($field->id());
}


How to allow editing a single node to a single user?

I would setup all those nodes as a particular content type and author. Then you could give those users a role once they register that allows them to edit their own nodes for said content type. Then you will of course need some custom code that runs at that time to find one of those nodes and change the author to the registered user so that they can edit it. Probably could the last part with Rules but you might need to use custom php to find a node and change the author.


Does anybody else encounter issues with the new Flexslider 2.3.0 library and Drupal?

I realized that the most recent version does not work with the Drupal flexslider module. I downgraded the flexslider JS library to version 2.2.2 and the flexslider Drupal module got recognized.

I used the following JS library version of flexslider ... here you can find all releases


Not sure where you're trying to do this, but if it's a node edit form, you can just change the widget to "Check boxes/radio buttons" on Manage Form Display (admin/structure/types/manage/<content_type>/form-display). Make sure the Options module is installed.

For an exposed filter in a View, say, you can use a hook_form_alter to change the #type to whatever you want; e.g.:

function YOUR_MODULE_form_views_exposed_form_alter(&$form, FormStateInterface $form_state) {
  $form['field_your_field']['#type'] = 'checkboxes';

  // If there's no user input (code not shown), rebuild the form.
  $form_state->setRebuild();
}

Only makes sense if #multiple is set to TRUE of course.

UPDATE: Added the call to setRebuild().


Using same pictures twice in one node (media module)

No solution right now, because all the cropping modules stores their information using fid, without entity id or something else which can give information where it will be used. As a workaround on this problem, I altered some crop forms and created a new image per each crop.


How to get teaser break to work with WYSIWYG + CKEDITOR?

Adding <!--> to the set of allowed HTML tags for the Filtered HTML format solved this problem for me. To do so, these are the steps to be performed:

Navigate to admin/config/content/formats/filtered_html.
Within "Filter settings", select the "Limit allowed HTML tags".
Within the field with label "Allowed HTML tags", add the string <!--> (in addition to whatever set of HTML tags you already have).
Save configuration.


How do I show a list of users and display only partial email addresses?

My solution for this is to go with adding a Views handler to the email field. The idea is to add a checkbox maybe saying "Mask part of the email address".

So you need to:

Check the Views field handlers page for reference.
You will see that there is a field handler for the user email which is called views_handler_field_user_mail. So this is what we need to add some settings and logic to "mask" parts of the email address.

That would be it. All you need to study now is how to structure and create the handlers and you can search for the guide you understand most but this(Drupal 7 Views 3 custom field handler) contains a good sample code too.

Of course the logic of masking the string/email will be all you already depending on your preferences or requirements.


Differences between Firefox and Chrome in the Omega theme

As I previously mentioned in comment, its not related to Omega nor Drupal, but you can still try to use normalize.css.

A modern, HTML5-ready alternative to CSS resets (as used by Twitter
Bootstrap, HTML5 Boilerplate, TweetDeck, Soundcloud, and many others)

Alrternatively as you didn't provide any link or capture, I suggest to check your styles and libraries list in your omega subtheme settings, go to Appearance > THEMENAME > Settings , under Toggle styles and Toggle Libraries


There is really no silver bullet that can be used to completely stop spam. Spam can only be minimized.

Spam entered by human beings will still always get through -- and there are more and more human being spam farms out there.

The best solution that I have found is to work with Mollom rather than ReCaptcha.

Just as @Bisonbleu mentioned in the comment. Another module you can make use of is the honeypot module

  Honeypot uses both the honeypot and timestamp methods of deterring
  spam bots from completing forms on your Drupal site (read more here).
  These methods are effective against many spam bots, and are not as
  intrusive as CAPTCHAs or other methods which punish the user.


How to insert a View inside other View as the last row of the parent View?

Use views_field_view module.
This module help you to embed a view as a field in a view.


Easily theming Form Fields - How to get minimum HTML required for form field in Drupal 7

I can't advise that you remove the labels as your website will instantly become inaccessible and fall foul of disability discrimination guidelines.

That being said, you can override the output for all form elements by implementing an override of the theme_form_element function. The easiest thing to do would be to copy that function in its entirety into a function in your site's theme called MYTHEME_form_element(&$variables), and then step through the code trimming out the elements that you don't want to be output.


Drupal 8 Views filer results by logged in user association

You can find answers here with detailed steps about how to do that. Search for "sibling entity reference" or something longer.

Basically, you do do it with a couple of Relationships and a Contextual filter. You need Relationships to get the referenced Content into your Views, because when you create Products views you will only have Products fields available.

So you create a list of Products, add the ER Relationship for the Client info, add another Relationship that is using the first one for the users referencing the Client, then you can add the User ID contextual filter that is using the second Relationship and set it to provide default value from Logged in user.


Views (Search API): Search taxonomy parent and display all children

There's a wonderful little checkbox in the Search API workflow tab which enables it.

Head to:

admin/config/search/search_api/index/*your solr server*/workflow

(You'll need to have created a server to get to this.)

And then tick the box "Index Hierarchy".

In callback options select the taxonomy field where you would like searching for the parent to include the child.


Add code below:

class MYCUSTOMBLOCK extends BlockBase {
  public function build() {
    return array(
      '#markup' => '', // the content of your block
    );
  }
  public function getCacheMaxAge() {
   return 0; // No caching gets applied here
  }
}


How to inject configuration values into services?

You can use a factory for your app.mailer service. The factory take cares of retrieving the configuration for the service. The service can stay decoupled from the configuration service and does not need to know how the config parameters are named.

services:
  app.mailer:
    class:       Drupal/mail_module/Mailer
    factory:      Drupal/mail_module/MailerFactory:create
    arguments:    ['@config.factory']

class MailerFactory {
  static function create($config) {
    return new Mailer($config->get('mail.config')->get('transport'));
  }
}

class Mailer {
  public function __construct($transport) {
    $this->mailTransport = $transport;
  }
}


field widget is not saving selected value to database

Try adding the following line below form_set_value().

$element['#value'] = 'new_value';

P.S. Borrowed from Alter taxonomy autocomplete value


How do I fix the errors I get after removing the comment field from a content type?

Given your error stacktrace:

Check function gavias_sanbro_preprocess_node() (Line: 287 in your gavias_sanbro.theme theme file).

This preprocessing function obviously tries to access the comment field without checking, whether it exists. As you uninstalled the field, it is causing your exception.

You may comment out, remove, or alter the code accordingly.


Typically searching with the default search box results in a url that looks like this:

/search/node/[search term]

So you can capture that search term (in your custom module presumably) with a line like this:

$path = explode('/', $_GET['q'], 3);

// Make sure the path you got has three components and begins with 'search'
if(count($path) == 3 && $path[0]=="search") {
   // Get component #3 (index starts at 0)
   drupal_set_message("Here are my search terms: " . $path[2]);
}


2 views blocks on 1 page - no duplicate results

There are a few solutions:

You can use Panels module to build your page. Using this module you can insert a block in multiple times.
You can use this code into different regions to display the view

<?php print views_embed_view("VIEW_NAME","MACHINE_NAME","ARGUMENTS");

The views_embed_view displays the view.
You can also load the block itself despite of what entity has generated it's content by the following code

<?php
  $block = module_invoke('module_name', 'block_view', 'block_delta');
  print render($block['content']);
?>

The How to insert a block into a node or template in Drupal 7? gives you more details about the arguments of above code.


Autocomplete views exposed textbox for Entity reference field

I found an answer here : Drupal 7 Views Autocomplete Filter | Code Karate

Following this solution I installed Views Autocomplete Filter module and then in the view, I added a relationship based on field machine model and then a filter of type title of machine was provided .

Everything works great now.


Custom configuration forms: translation access denied

For anyone stumbling towards a similar problem: it seems you have to set-up not only schema, routing and config_translations yml files but you also have to define each configuration in installation yml files so your config is picked up by Drupal.

So I had to include a faq.settings.yml file in /install of my custom module directory, like:

faq_title: ''
faq_text: ''
faq_cta_label: ''
faq_cta: ''
langcode: en

And boom you got yourself a translatable configuration form.


Drupal7 - How to display both summary and body on full view?

It would be better to use print drupal_render( field_view_field('node', $node, 'safe_summary') );.

This will also handle i18n.


How to replace Operations links (dropdown) by icons?

There is probably a better way, but you could use CSS to hide the text and display an image background over the space instead.


I have managed to solve this - I needed to change the formatter for the field to "Key".