# Question
Title: Where should I search uncompressed .css?
I try to update styles on a Drupal site. But when I go to `sites/default/files/css/` I find only set of gzipped .css files. Where should I search uncompressed files to edit them? Developer Tools shows path to gzipped files, naturally.

# Answer
> 3 votes
> when I go to sites/default/files/css/ I find only set of gzipped .css files

You need to change your configuration.

Go to Configuration \> Performance

and unchecked the aggregate and compress CSS files box, Save Configuration.

You then need to go to `/sites/all/themes/YOURTHEMENAME/css` folder and hopefully you should see `.css` files now. **(Assuming you are using Drupal 7 and NOT using Drupal 8)**

```
(might need to re-start FileZilla to seem them, assuming you are using FileZilla that is.)

```

---
Tags: theming
---


# Question
Title: How can I edit a custom field with Rule and VBO of a NOT published node?
I'm currently stuck in the creation of a custom rule. I've created a content type "Avviso" with a publishing date field (start & end) and a custom field\_stato with this values:

* Not active
* Active
* Terminated
* Archived

Now I would like to change the value of field\_stato and publish all nodes with date\_start \< now \< date\_end. For that I've created a view with a VBO field, a Rule (triggered by the cron) and a component (of type rule) that do the job.

The problem is that the rule can see only node already published and -of course- cannot switch the node itself to "Published" state. With already published nodes the rule works fine.

Is there any restriction or permission with rules and unpublish content=?

(see images)

# Answer
> 0 votes
Cron runs as an anonymous user. Ensure that the view permissions allow an anonymous user to access. Set the access to role:

Then, set the role to anonymous:

That should allow you to bypass the regular permissions that would normally not allow you to see it.

Also, ensure that your rule includes a rule to save the entity. I'm not 100% sure that it will save the entities you reference automatically, but it is more clear.

Also also, you may need to check the permissions on your rules to ensure that they can be executed by anonymous as well:

---
Tags: rules, views
---


title: How to redirect to search result page?

text:
# Question
Title: How to redirect to search result page?
I’ve activated the search form block on my Drupal home page.

When a user enters a keyword and presses search button, I would like to redirect to the search page result.

How can I do that?

# Answer
> 1 votes
```
function MyModuleName_form_alter(&$form, &$form_state, $form_id)
{
   if ($form_id == 'search_form_id') {
     $form['#submit'][] = 'MyModuleName_custom_serch_form_submit';
   }
}

function MyModuleName_custom_serch_form_submit($form, &$form_state)
{
  if(isset($_GET['q']) && !empty($_GET['q']))
  {
     $string_serch= $_GET['q'];
    drupal_goto("http://yourdomain.com/search?q=".$string_serch);
  }
}

```

# Answer
> 1 votes
You can redirect search result by using `hook_search_box_form_submit`

```
function mytheme_search_box_form_submit($form, &$form_state) {
   $form_state['#redirect'] = 'path of redirect';
}

```

---
Tags: search
---


title: How to translate URL aliases?

text:
# Question
Title: How to translate URL aliases?
I have the following path `mysite/basic-page/about-us` I need translate it to:

# Answer
> 2 votes
You can use the i18n (Internationalization) module (requires the Variable module).

You can follow this tutorial.

# Answer
> 1 votes
Have a look at the Transliteration module. Here is a quote from its project page:

> Provides one-way string transliteration (romanization) and cleans file names during upload by replacing unwanted characters.
>
> Generally spoken, it takes Unicode text and tries to represent it in US-ASCII characters (universally displayable, unaccented characters) by attempting to transliterate the pronunciation expressed by the text in some other writing system to Roman letters.

Here is a sample of what this module does for "**file names**":

However, it can also be used to transforms an URL like `mydomain.com/последние-новости-в-Украине-и-мире` in something like `mydomain/poslednie-novosti-v-Ukraine-i-mire`. To do so, you also need to enable the Pathauto module. After that, go to the Pathauto setting page and check "Transliterate prior to creating alias". For more details on that, refer to "D7 Pathauto transliteration". **Attention**: this does not "fix" already created aliases (those need to be deleted and recreated).

---
Tags: uri, i18n-l10n, transliteration
---


# Question
Title: What are some drupal 7 mega menus that allows view blocks to be inserted?
I was wondering what mega menu's for drupal 7 that allow view blocks to be inserted? Currently I only know about xo mega menu, but i was wondering what other ones do people use or other workarounds you might have for putting in view blocks into drop down menus.

# Answer
> 6 votes
You can use Menu Attach Block module to render block as menu.

> Menu Attach Block allows you to attach blocks to standard core Drupal menu items. This is especially useful for creating complex dropdown menus and mega menus.
>
> Any block can be used, including blocks generated by other modules. Blocks generated by Views are particularly good candidates for embedding.

# Answer
> 1 votes
There are quite a few modules that allows you to built megamenus which allows you to insert views blocks.

Other than what bala have mentioned above following are the modules which worth a try.

Menu Views It can be integrated with superfish, nice menus and menu block modules.

TB Mega Menu It has a very nice UI and mobile menu built in.

MuchoMenu This module allows users to create mega menus that have mini panels as their flyout content. The benefit is that ANY type of content or UI can be added to the menu flyouts.

# Answer
> 0 votes
https://www.drupal.org/project/ultimenu

This also has Drupal 8 version for it aswell.

---
Tags: 7, routes, blocks
---


title: Trouble with FieldItemList::view

text:
# Question
Title: Trouble with FieldItemList::view
I have a custom content entity that renders fine in its page view and form. I'm now trying to view one of its fields in a table using an EntityListBuilder, but the following code throws an error message:

```
public function buildRow(EntityInterface $entity) {
  $row['id'] = $entity->id();
  $row['email'] = $entity->email->view();

  return $row + parent::buildRow($entity);
}

```

Results in:

> **Fatal error:** Call to undefined method Drupal\my\_module\Entity\MyEntity::render() in /.../core/lib/Drupal/Core/Template/Attribute.php on line 294

Apparently the view builder expects a render() method, which I do not have, and which I do not want to implement, since the entity renders fine otherwise...

Also tried EntityViewBuilder::viewField() with no success.

Even when I'm viewing a node instead of my custom entity, I get the same message.

# Answer
> 1 votes
The function `buildRow` returns a render array. You can put simple strings directly in the array, because later it will be put in another html structure like a table. An example from core, where it is used both ways (CommentTypeListBuilder.php):

```
public function buildRow(EntityInterface $entity) {
    $row['type'] = $entity->label();
    $row['description']['data'] = ['#markup' => $entity->getDescription()];
    return $row + parent::buildRow($entity);
  }

```

So using the '#markup' element is optional. You can use it to be on the safe side, when you don't know how your render array is processed.

For complex elements you need a render element. The method view() would generates this:

```
$row['email'] = $entity->email->view();

```

But this does not work. The problem seems to be in the custom entity. According to the error message there is a call to an undefined method `render`, which should be defined in `MyEntity`. Your entity does not know how to handle the email field.

If you don't want to theme the field, you can use the value as markup:

```
$row['email']['#markup'] = $entity->email->value;

```

Or you can put the field as an object:

```
$row['email'] = $entity->email;

```

Or you can build your own render array, for example as a link:

```
$row['title'] = array(
      '#type' => 'link',
      '#title' => $entity->label(),
      '#url' => $uri,
    );

```

---
Tags: entities, 8
---


# Question
Title: What do array keys in the database definition array mean?
I have following code in my `settings.php` file:

```
$databases['default']['default2'] = array(
  'driver'    => 'mysql',
  'database'  => 'rotary',
  'username'  => 'root',
  'password'  => 'root',
  'host'      => 'localhost',
  'prefix'    => '',
);

$databases['rotary2']['default1'] = array(
  'driver'    => 'mysql',
  'database'  => 'rotary2',
  'username'  => 'root',
  'password'  => 'root',
  'host'      => 'localhost',
  'prefix'    => '',
);

```

I know that the first keys i.e. `default` & `rotary2` are the database names.

What are the keys `default2` & `default3` for?

# Answer
> 2 votes
Here is the explanation from the `setting.php` file:

> For each database, you may optionally specify multiple "target" databases. A target database allows Drupal to try to send certain queries to a different database if it can but fall back to the default connection if not. That is useful for master/slave replication, as Drupal may try to connect to a slave server when appropriate and if one is not available will simply fall back to the single master server.
>
> The general format for the $databases array is as follows:
>
> ```
> $databases['default']['default'] = $info_array;
> $databases['default']['slave'][] = $info_array;
> $databases['default']['slave'][] = $info_array;
> $databases['extra']['default'] = $info_array;
>
> ```
>
> In the above example, `$info_array` is an array of settings described above. The first line sets a "default" database that has one master database (the second level default). The second and third lines create an array of potential slave databases. Drupal will select one at random for a given request as needed. The fourth line creates a new database with a name of "extra".

I hope this will give you clear idea about `default2` and `default3`.

---
Tags: 7, database
---


# Question
Title: How to hide My results tab for the User using Quiz module in Drupal 7
It looks so silly to ask these questions but I'm beginner in drupal. I need a help on implementing the modules. I'm trying to build a portal using Quiz Module wherein I need to hide a tab for the user but should be visible to administrator.

Is it possible to hide the My results tab in drupal 7? If so how?

# Answer
You can use Tab Tamer module.

Project page says:

> Tab Tamer is an administration utility that provides easy re-ordering, hiding, and deactivation of tabs and subtabs.

For more information go through the module documentation.
> 2 votes

# Answer
Just go to **modules-\>quiz core module** and in `configuration/permission` uncheck **view own result**. That is it. If you want to re-enable it, just check it
> 0 votes

---
Tags: quiz
---


# Question
Title: How to find the culprit module that's causing all my views not to display anymore?
The Views on my site were working perfectly until I updated a bunch of modules and now I get these errors and the views don't display:

> Warning: include(/home/x/public\_html/.tpl.php): failed to open stream: No such file or directory in theme\_render\_template() (line 1525 of /home/x/public\_html/includes/theme.inc).
>
> Warning: include(): Failed opening '/home/x/public\_html/.tpl.php' for inclusion (include\_path='.:/usr/lib/php:/usr/local/lib/php') in theme\_render\_template() (line 1525 of /home/x/public\_html/includes/theme.inc).

How would one debug this issue to get the view to show up again?

I went to the line 1525 in theme.inc and it shows this:

```
1517 function theme_render_template($template_file, $variables) {
1518   // Extract the variables to a local namespace
1519   extract($variables, EXTR_SKIP);
1520
1521   // Start output buffering
1522   ob_start();
1523
1524   // Include the template file
1525   include DRUPAL_ROOT . '/' . $template_file;
1526
1527   // End buffering and return its contents
1528   return ob_get_clean();
1529 }

```

The error is telling me some template isn't found, but how do I trace back to where this function got called to find the culprit module that's causing all my Views not to display?

# Answer
> 1 votes
Classic disabling modules one by one to see which update is causing the problem. After that, try the garland theme.

# Answer
> 0 votes
Perhaps you did not run the update.php script

so go to `www.yourwebsite.com/update.php` and update the database.

**PS:** Any time you update Drupal or any module, you should run update.php

--

**If you did run the update.php script**, then:

I assume you made a backup before upgrading both Drupal and the modules.

Maybe you should revert back to the backup and then upgrade them one at a time. (you can do this fast using Drush, if you like.)

You would need to revert back to the module versions that you were using before updating them. Hopefully, you backedup your /sites folders like you should.

--

Another possibility might be that you have module files missing, perhaps they didn't get uploaded for some reason. (connection timmedout ?)

# Answer
> 0 votes
If update.php does not fix the problem, try running Registry Rebuild. This will ensure Drupal correctly knows where all the files it needs to load are located.

Also, when you updated modules did you follow the correct procedure, which is to remove the existing module files before installing new ones? If you don't do this it can cause unexpected results.

---
Tags: 7, views, debugging
---


# Question
Title: Form submission not working in template file
While theming form in template file I used `drupal_render` to print selected fields of form. But after hit submit button, data is not saving, means submit button is not working.

I know one solution is to use `drupal_render_children` but it is giving me every child of form, means I'm getting all of the elements of form.

**I don't want form's each and every element.**

Only selected fields should get rendered.

**Any way to print form selected field elements in tpl file with a working submit button?**

# Answer
> 1 votes
One more standard way to hide form elements is to make their `#access` property to false , or use hide function or unset function to hide undesired elements . then you can render $form .

for example imagine you are going to hide `$form['details']['name']` , in hook\_form\_alter you can use this snippet :

```
$form['details']['name']['#access'] = FALSE;

```

or you can hide it from being displayed , using this snippet :

```
hide($form['details']['name']);

```

then you can easily render your form in any place you desire using

```
print drupal_render(drupal_get_form('FORM_ID'));

```

# Answer
> 2 votes
You can render form specific form elements with the help of `drupal_render`. And in order to make submit button work, render all hidden form items and your submit button will work fine then.

Necessary fields for form submission are:

```
echo drupal_render($form['form_build_id']);
echo drupal_render($form['form_token']);
echo drupal_render($form['form_id']);

```

and ofcourse your submit button too.

# Answer
> 1 votes
Please add these four lines after render all your content type or form fields in below sequence.

```
 1. drupal_render($form['form_build_id']);
 2. drupal_render($form['form_id']);
 3. drupal_render($form['actions']);
 4. drupal_render($form['form_token']);

```

---
Tags: forms
---


title: How programmatically filter text?

text:
# Question
Title: How programmatically filter text?
I need to display a text and apply the chosen filter to it. The text is saved using the `text_format` field type.

So I know the original text, I know the chosen format type but I don't know how to actually filter the text.

How can I programmatically filter text? Thanks

# Answer
This post on stackoverflow describes how to do this programmatically.

Just call check\_markup and pass in your text and the filter id.

```
check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE)

```

> Run all the enabled filters on a piece of text.
> 10 votes

# Answer
With `check_markup()` function you are forced to use text format (text format = banch of filters).

If you want to use only **ONE**, exact filter without full filter format (like: *Convert line breaks into HTML*) then use this custom function.

```
/**
 * Custom function to use only ONE filter wightout full format.
 *
 * @param {string} $string String to filter.
 * @param {string} $filter Filter name to use on $string
 * @return {string}        Filtered string.
 */
function filter($string, $filter) {
  $filters = filter_get_filters();
  $filter_autop = $filters[$filter];

  return $filter_autop['process callback']($string);
}

```

You can check list of available filters with `dpm(filter_get_filters())`.
> 4 votes

---
Tags: 7, entities, input-formats
---


# Question
Title: Making tags in Taxonomy-view appear dynamically?
## Background

I've created a Taxonomy-view that shows about 5 terms each time from a vocabulary of about **40** terms.

## My desire

I need that in every page refresh, 5 different tags will be shown Randomly/dynamic, and not the same tags that appear there time and again.

* I want to do it with the Views module itself, without further contribs.
* I don't want to customize anything manually, rather using only the UI.

## Clarification note

I'm not talking about random sorting of the existing 5 tags, rather I mean that each page refresh will bring different 5 tags, that are (generally) different from those in the previous refresh.

# Answer
Add Sort Criteria: Global: Random in view

Change the pager limit according to your requirement
> 0 votes

# Answer
In response to your reply to Aldi, is global:random the only sort criteria you've chosen? And if not, is it at the top of the sort list?

I've no idea why Aldi's suggestion wouldn't work but without any coding, the easiest plan B would be to use global:random with a pager and use css to hide that specific pager.
> 0 votes

---
Tags: views
---


title: Remove default css file

text:
# Question
Title: Remove default css file
I need to remove `jquery.ui.theme.css` file, for this in my template.php I implement the below mentioned code:

```
function GNG_css_alter(&$css)
{
unset($css[drupal_get_path('module', 'misc') . '/ui/jquery.ui.theme.css']);
}

```

but its not working.

# Answer
> 0 votes
```
<?php
/**
 * Implements hook_css_alter().
 */
function seven_css_alter(&$css) {
  // Use Seven's vertical tabs style instead of the default one.
  if (isset($css['misc/vertical-tabs.css'])) {
    unset($css['misc/vertical-tabs.css']['data'] = drupal_get_path('theme', 'seven') . '/vertical- tabs.css');
  }
  // Use Seven's jQuery UI theme style instead of the default one.
  if (isset($css['misc/ui/jquery.ui.theme.css'])) {
    unset($css['misc/ui/jquery.ui.theme.css']['data'] = drupal_get_path('theme', 'seven') . '/jquery.ui.theme.css');
  }
}

```

# Answer
> 0 votes
You can use `hook_library_alter`

```
function garland_library_alter(&$libraries, $module) {
  if ($module == 'system') {
    $js = drupal_get_path('theme', 'garland') . '/ui/ui.garland.css';
    $libraries['ui']['css'][$js] = $libraries['ui']['css']['misc/ui/ui.theme.css'];
    unset($libraries['ui']['css']['misc/ui/ui.theme.css']);
  }
}

```

# Answer
> 0 votes
The code you have implemented (`drupal_get_path('module', 'misc')`) asks drupal to check for a module which is named misc , which is probably wrong , so when you use drupal\_get\_path the first parameter is going to be what object are you going to find is it a Module or is a Theme , the next parameter is the machine name of that object . so you cant find a folder which is called misc just by calling this function . this function leads to root of a theme or module.

so the right code is:

```
function GNG_css_alter(&$css)
{
  unset($css[drupal_get_path('THEME or MODULE', 'It's NAME') . '/ui/jquery.ui.theme.css']);
}

```

---
Tags: theming
---


# Question
Title: Rating for anonymous users plus redirection to the login page
I am using the Fivestar module for product rating with Ubercart. I want to enable rating for anonymous users. At the same time, when the user rates the product, this must be redirect to login page.

Is there any possibilities for doing this?

# Answer
> 1 votes
Try the Voting Rules module.

> Administrators can configure actions to occur when a user submits a vote, when a user deletes a vote, and when the results of a vote are calculated. Currently, Voting Rules supports votes on nodes, users, and comments.

I didn't test it, but using it is possible to achieve what you want with the the Rules module.

---
Tags: ubercart, rating
---


# Question
Title: Is there an alternative private messsage module that integrates with Views?
As far as I can tell it's the only real solution on the block. But it has major drawbacks that make it unusable for most sites. Mainly its not built with views, therefore easy customization is out of the question unless I change the code.

Are there any alternatives, paid or free, that beat privatemsg and integrate with Views?

# Answer
You can also consider theming Private Message. Private Message is an extremely powerful module that offers a much higher degree of customization than some sites may need (messages can be sent to users + roles at the same time, etc.)

For my site, I added several tweaks to actually limit/reduce Private Message's functionality (users can only have one thread per user, users can only message one user at a time, users cannot send more than three messages in a row to the same user, etc.)

Messaging systems are pretty complex so I found it easier to start with the huge number of options Private Message provides and then reduce them.

You could also help work on privatemsg views integration, though this is a huge project.
> 1 votes

# Answer
You can use the message private module. It has the ability of integration with Views module. It's a little new so may lack some features. If you want to stick with privatemsg then there is a patch here which can integrate it with Views.

I hope this helps.
> 0 votes

---
Tags: privatemsg, 7
---


# Question
Title: How to log the history of nodes viewed by a user, and report about them?
I want to have this feature that for each user logs the nodes that the user viewed.

In another words, **recent nodes viewed by each user**. I want have a block that shows each nodes user viewed , something like `imdb.com` user history view.

How can I achieve this job? Do you know good module for Drupal 7? Do you think it is possible achieve that with views or my custom query? Or I should write custom simple module and get help `hook_node_view` .... ?

# Answer
You can try using Recently Read module...

> Recently read allows site administrators to enable blocks displaying a history of recently read content (nodes) both to anonymous and authenticated users. For logged in users, each user has its own history. For anonymous users, the history is based on sessions. This module may be useful i.e. for displaying recently viewed products on the e-commerce site.
> 2 votes

# Answer
# Logging the nodes visited by a user

Here are some modules that might be a possible fit for logging the nodes visited by a user (quotes are from their project pages):

* Visitors:

Comes with a set of **Visitors Reports**, such as:

+ User activity report (hits, nodes, comments).
    + A *Visitor* tab that is added to each node, with details about Referrer, Date, User, IP address, User agent.

It also comes with a **Visitors Block**, which includes data about:

+ Total Visitors.
    + Unique Visitor.
    + Registered Users.
    + Last Registered User.
    + Published Nodes.
    + Your IP.
* Counter:

> ... counts how many visitors on your website. This module provides real time counting. All data saved to database.
* User Visits (with related User Visits Advanced):

> ... tracks visits and referrer from other users on a user's profile page. It displays the latest visitors on a user's profile page and provides two blocks one with the latest visitors on a user's profile page and one with the latest visitors on own profile page.
>
> See User Visits Advanced for additional functionality.
* Node view count:

> ... allows to count node views. Unlike statistics module, this module records each view of node with user uid and timestamp. So now you can know how many times a user viewed node by day, week, month and etc.
>
> This module is integrated with Views module. You can use it to create different statistics pages, output new not viewed nodes for user and many more.

# Reporting about the logged nodes

Typically all modules suggested above come with their own set of (fixed) reports, whereas these reports are about data stored in the tables these modules maintain.

If the reports they come with don't meet all your reporting requirements, you could use something like the Views or Forena modules to create custom reports (and charts) about the data stored in any of these tables. Another option is to create a custom module (with custom queries) for this kind of reporting.

Disclosure: I'm the maintainer of the Visitors, and co-maintainer of Forena.
> 0 votes

---
Tags: 7, nodes
---


# Question
Title: Print message only if checkbox field is alter using form alter
I have created a checkbox in user edit using form alter and based checkbox state I want to print the message. For this I used below code

```
function module_form_user_profile_form_alter(&$form, &$form_state) {

  $form['account']['checkbox'] = array(
    '#type' => 'checkbox',
    '#title' => 'Test check',
   );
   $form['#submit'][] = 'module_simplenews_unsubscribe';
}

//~ //Submit handler for Subscribe/unsubscribe newsletter.
function module_simplenews_unsubscribe($form, &$form_state) {

  if ($form['account']['checkbox']['#value'] == 0) {
    drupal_set_message(t("You are checked"));
  }
 if ($form['account']['checkbox']['#value'] == 1) {

    drupal_set_message(t("You are unchecked"));
  }
}

```

It works fine. When checkbox is checked/unchecked and user saves the profile it prints respective message. But when user doesn't modify this checkbox field and modify some other field and saves, again it prints message based on checkbox state.

I want to display the message only when checkbox field is modified. How can I achieve this?

# Answer
You can use form\_state instead of form in your submit handler and use `default_value` of check box in your form alter

```
$form['account']['checkbox'] = array(
    '#type' => 'checkbox',
    '#title' => 'Test check',
    '#default_value' => 0,
   );

```

and then your submit handler will go like this

```
function module_simplenews_unsubscribe($form, &$form_state) {

  if ($form_state['values']['checkbox'] == 0) {
    drupal_set_message(t("You are checked"));
  }
 if ($form_state['values']['checkbox'] == 1) {

    drupal_set_message(t("You are unchecked"));
  }

```

Use debug tools for proper index of form\_state for checkbox.
> 1 votes

---
Tags: 7, forms
---


# Question
Title: Getting wrong output after implemented `theme_item_list`
I have Drupal version 7.41 and I am using xubuntu 14.04 as my OS.

I have a module that displays footer links as a list. The module will fetch available links from the database and show them in individual blocks. Here is my fetch function:

```
function footer_links_footerblock_contents($variables) {
switch ($variables) {
    case 'group_1':
        $query = db_select('footer_links', 'fl')
                ->fields('fl', array('name'))
                ->condition('fl.group', 1);
        break;
    case 'group_2':
        $query = db_select('footer_links', 'fl')
                ->fields('fl', array('name'))
                ->condition('fl.group', 2);
        break;
    case 'group_3':
        $query = db_select('footer_links', 'fl')
                ->fields('fl', array('name'))
                ->condition('fl.group', 3);
        break;
    case 'group_4':
        $query = db_select('footer_links', 'fl')
                ->fields('fl', array('name'))
                ->condition('fl.group', 4);
        break;
    case 'group_5':
        $query = db_select('footer_links', 'fl')
                ->fields('fl', array('name'))
                ->condition('fl.group', 5);
        break;
}

return $query->execute();
}

```

The result array produced from the `$query->execute();` will be going to my module's block\_view function:

```
function footer_links_block_view($delta = '') {
switch ($delta) {
    case 'group_1':
        $block['subject'] = t('Footer Group 1');
        if (user_access('access content')) {
            $result = footer_links_footerblock_contents($delta);
            $items = array();
            foreach($result as $node) {
                $items[] = $node->name;
            }
            if (!empty($items)) {
                $block['content'] = theme('item_list', $items);
            }
            else {
                $block['content'] = t('');
            }
        }
        break;
    case 'group_2':
        $block['subject'] = t('Footer Group 2');
        if (user_access('access content')) {
            $result = footer_links_footerblock_contents($delta);
            $items = array();
            foreach($result as $node) {
                $items[] = $node->name;
            }
            if (!empty($items)) {
                $block['content'] = theme('item_list', $items);
            }
            else {
                $block['content'] = t('');
            }
        }
        break;
    }
    return $block;
}

```

In there I used the theme function `theme('item_list', $var)` to display them as a list. I have overridden the theme function like this in my `template.php` file:

```
function mytheme_item_list($variables) {
$output = '<div class="col-lg-2">';
$output .= '<ul class="list-unstyled">';

foreach ($variables as $member) {
    $output .= '<li><a href="#">' . $member . '</a></li>';
}

$output .= '</ul></div>'; return $output;
}

```

And here is my problem. When I looked at the output in the footer section, I see list items that are not even in my database in which I fetch. I see 'Array', 'ul', 'item\_list' extra added list items. What is the source of this extra output? Am I not properly overriding the theme function?

# Answer
Your code is wrong, since the items to render are in `$variables['items']` not `$variables` as evident in `theme_list_items()`.

```
function theme_item_list($variables) {
  $items = $variables['items'];
  $title = $variables['title'];
  $type = $variables['type'];
  $attributes = $variables['attributes'];

  // Omissis
}

```

You are confusing what the theme function gets in Drupal 7 with what the same theme function gets in Drupal 6.

In general, in Drupal 7 what the theme functions need to render is always an index of the array `$variables` passed them; they never use `$variables` directly like your code does.

```
function theme_table($variables) {
  $header = $variables['header'];
  $rows = $variables['rows'];
  $attributes = $variables['attributes'];
  $caption = $variables['caption'];
  $colgroups = $variables['colgroups'];
  $sticky = $variables['sticky'];
  $empty = $variables['empty'];

  // Add sticky headers, if applicable.
  if (count($header) && $sticky) {
    drupal_add_js('misc/tableheader.js');
    // Add 'sticky-enabled' class to the table to identify it for JS.
    // This is needed to target tables constructed by this function.
    $attributes['class'][] = 'sticky-enabled';
  }

  $output = '<table' . drupal_attributes($attributes) . ">\n";

  if (isset($caption)) {
    $output .= '<caption>' . $caption . "</caption>\n";
  }

  // Omissis
}

```
> 0 votes

---
Tags: theming
---


# Question
Title: How do I trigger Infinite Scroll with FancyBox in Drupal 7
I have a gallery of photos which uses Infinite Scroll as the pager. I am also using the fancyBox module so that when I click each photo it appears in an overlay, with the photos grouped per page so I can cycle through them with the FancyBox overlay.

The problem I have is that I can only cycle through the photos that have already been loaded by the Infinite Scroll (which makes sense as they are the only photos the Infinite Scroll has 'seen'). But what I want is to trigger the infinite scroll to load more photos just before I reach the end of the cycle with the FancyBox overlay so a user can simply use the overlay to cycle through all the photos on the site without having to use Infinite Scroll to load them all first.

Any help with the sort of thing I should be thinking about to try and achieve this?

# Answer
ugh... sounds like you'll need custom work. But try the Image Lazy Loader Module

> This is a small helper module which will automatically lazyload all images for sites with multiple images, which will make the site load faster.
>
> All images will only load when it's visible to the browser window.
> 0 votes

---
Tags: media, views
---


title: Installing TinyMCE Text Editor

text:
# Question
Title: Installing TinyMCE Text Editor
I followed this video tutorial in youtube for installing TinyMCE Editor in drupal. Below are the steps I did.

```
1. Downloaded and installed the updated WYSIWYG 7.x-2.2, IMCE 7.x-1.9 and IMCE Wysiwyg API bridge 7.x-1.0 succesfully.

2. Downloaded TinyMCE and placed it on `htdocs\drupal\sites\all\libraries` succesfully.

3. Installed TinyMCE unsuccesfully.

```

I refresh drupal's page and still gets the 'Not installed.' message.

I suspect the path may be wrong/different from the image above. The actual path in my computer is `sites\all\libraries\tinymce\js\tinymce\tinymce.min.js`

I downloaded TinyMCE here. Where did I go wrong?

# Answer
There might be TinyMCE version issue with 4.7.x. Once I have facing the same problem. Then I uses the version 3.5.x of TinyMCE and its worked fine for me.

I hope it will work.
> 3 votes

# Answer
I had to do quite a bit of work to get WYSIWYG to work properly. While I preferred TinyMCE, I ended up using CKeditor 4.4.4 after it was all said and done, since I am using "Footnotes" Add-on. The setting for this editor were much easier to configure and get working.

Good documentation on this is easy to find and troubleshoot: http://ckeditor.com/

I ended up adding the editor the Libraries folder and changed settings in the modules folder to point to the file directory that was needed. It's been over a year since I did this and I changed things so many times that I can't remember what was right or wrong.

The end result is, it's nice having a WYSIWYG that works, that I haven't had to mess with for over a year.
> 0 votes

---
Tags: 7, forms, wysiwyg
---


title: Import data from remote database

text:
# Question
Title: Import data from remote database
I want to import locations from my remote **non drupal** database. I can't use **feed** as it does duplication. Is there any custom solution?

# Answer
Welcome to Drupal!

If you don't want to use feed then I suggest query the data and insert it into your Drupal site using rest services. You can find dozen resources on how to use services. I would suggest to allow anonymous user to add location for testing purpose one example is like this

```
foreach ($locations as $key => $value) {

       $location_node = array(
        'type' => 'recording', //content type e.g. 'page' or 'article'
        'title' => 'test layer',
        'body[und][0]' => array('value' => 'This is my test value'),

);

}

```

I hope this will help.
> 0 votes

# Answer
Generally the migrate module is very flexible.
> 1 votes

---
Tags: migrations
---


# Question
Title: Create fieldable bundle types for an entity with Drupal Console
I am trying to recreate the functionality of a NodeType/Node entity at a basic level.

I want to define entity types (FooType) which can be fielded individually, just like NodeType can be.

I used the Drupal Console to generate a config entity and content entity. Out of the box, it creates types and content entities of those types. However you can't field those types, I don't see a way to add that.

When I try to mimic the annotation in NodeType to allow fields, I get the following error when I try to save a field to a FooType:

```
Missing bundle entity, entity type foo_type, entity id foo.

```

Where am I going wrong? Is this something the Drupal Console can already do and I missed it?

Update:

So I think I am past the original issue... now when I want to add a field on a type, I get:

```
Attempt to create a field 'field_testfield' without a bundle.

```

The URLs don't seem to be correct, as it keeps dropping me back on Foo entity settings instead of stay within FooType, where I am trying to add fields to.

# Answer
I eventually got it by comparing how NodeType/Node is defined:

http://cgit.drupalcode.org/user\_alert/tree/src/Entity?h=8.x-1.x

Now I can have unlimited entity types and add fields to them for different content configurations of the entity.

I started out by generating a config and content entity with the Console, but found that in order to get a more intuitive user interface, I had to modify the routing.yml and some of the paths as well.

Just a note for those looking for the same functionality.
> 0 votes

---
Tags: 8
---


title: base_url for both http and https?

text:
# Question
Title: base_url for both http and https?
I have a site that is accessible both through http and https. I see the security review complains that `base_url` is not defined in `settings.php`.

However when I define it as `http://example.com`, and flush all caches, my template in https is not rendered.

When I comment out the `$base_url` line in `settings.php` everything comes back to normal.

How can I resolve this problem?

# Answer
> 5 votes
You probably need to do something like this:

```
$protocol = (!empty($_SERVER['HTTPS'])) ? 'https' : 'http';
$base_url = $protocol . '://mysite.com';

```

...so that Drupal knows which protocol to use depending on how the site was accessed.

# Answer
> 3 votes
I have had luck with:

```
$base_url = '//mysite.com';

```

Also, to maintain the session cookie, I usually add:

```
$conf['https'] = TRUE;

```

which allows for mixed mode.

# Answer
> 2 votes
This works well for me with several domains on the same Drupal install over CloudFlare:

```
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
  $base_url = $_SERVER["HTTP_X_FORWARDED_PROTO"] . '://' . $_SERVER['HTTP_HOST'];
} else {
  $base_url = 'http://' . $_SERVER['HTTP_HOST'];
}

```

Like this it also works well with CloudFlare flexible SSL. I can access the site both with and without SSL.

(It seems you don't need the Cloudflare module but it wouldn't hurt either to enable it.)

# Answer
> 0 votes
Unfortunately the problem with setting the protocol relative to the accessed URL is that the site only references that when building the cached files and therefore creates all references to files and resources based on what protocol is used when rebuilding the site cache.

So, if you rebuild the cache from https, then all links are https. If you rebuild the site from http, then all links are http.

Rebuilding from https works best, but browsers may still block the secure content and may require users to manually allow the blocked content.

---
Tags: security, subsites
---


# Question
Title: Dynamic select lists (dependent dropdowns)
I created 2 dependent dropdowns in Drupal 7. In the first dropdown you need to choose the device, in order to see its attributes in the second dropdown.

When an option from the first list is selected, the Ajax throbber appears but it doesn't seem to be working and I don't get the appropriate options in the second dropdown.

I have read all examples and resources I could find online, but I haven't found how to fix this. Any help would be very much appreciated.

Below I attach the relevant code. Apologies in advance, I am new in Drupal.

```
function my_module_getdevicesfromrooms() {
  $dropdown1 = array();

  $tabdelimited = file_get_contents("http://.../tabdelimited");

  // some code
  return $dropdown1;
}

/**
 * The device name is required in order to get the attributes using this function
 */
function my_module_getattributesfromdevices($test) {
  $dropdown2 = array();
  $tabdelimited = file_get_contents("http://....");
  // some code

  return $dropdown2;
}

function my_module_form_ajax($form, &$form_state) {
  $form['#prefix'] = "<div id='latest-div'>";
  $form['#suffix'] = "</div>";
  $options_first = my_module_getdevicesfromrooms();
  $value_dropdown_first = isset($form_state['values']['my_module_deviceurn']) ? $form_state['values']['my_module_deviceurn'] : $options_first;

  $state2 = my_module_getattributedfromdevices($value_dropdown_first);

  $form['my_module_deviceurn'] = array(
    '#type' => 'select',
    '#title' => 'Device',
    '#options' => $options_first,
    '#default_value' => $value_dropdown_first,
  );

  $form['my_module_apply'] = array(
    '#type' => 'button',
    '#title' => t('Apply'),
    '#default_value' => t('apply'),
    '#ajax' => array(
      'callback' => 'my_module_ajax_callback',
      'wrapper' => 'nodes-div',
      'method' => 'replace',
      'effect' => 'fade',
    ),
  );

  $form['my_module_attributes'] = array(
    '#type' => 'select',
    '#title' => t('Attributes'),
    '#options' => $state2,
    '#default_value' => variable_get('my_module_attributes', ''),
  );
  return $form;
}

function my_module_ajax_callback($form, $form_state) {
  return $form;
}

```

# Answer
On your callback function, you need to setup a callback help. Basically getting your form data. Now my code is for D6 so some functions might be slightly different but check this out. I left some of my tweaks in there. You'll just have to adjust accordingly. but the big thing is the callback helper function.

```
function MOD_js_callback() {

// use of ajax callback helper to set form variables again
$form = MOD_callback_helper();

// grab form['datacenter_devices'] data and drop into changed_elements
// simply to not confuse rebuilt form with 'global' form
$changed_elements = $form['datacenter_devices'];

// Prevent duplicate wrappers.
unset($changed_elements['#prefix'], $changed_elements['#suffix']);

// concat status_messages and call drupal_render to render elements array for output.
$output = theme('status_messages') . drupal_render($changed_elements);
drupal_json(array(
    'status'   => TRUE,
    'data'     => $output,
));
}
function MOD_callback_helper() {

$form_state = array('storage' => NULL,'submitted' => FALSE);

$form_build_id = $_POST['form_build_id'];
$form = form_get_cache($form_build_id, $form_state);
$args = $form['#parameters'];
$form_id = array_shift($args);
$form_state['post'] = $form['#post'] = $_POST;
// Enable the submit/validate handlers to determine whether AHAH-submittted.
$form_state['ahah_submission'] = TRUE;
$form['#programmed'] = $form['#redirect'] = FALSE;
drupal_process_form($form_id, $form, $form_state);

$form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);

return $form;
}

```
> 0 votes

# Answer
A simpler way to achieve this is you could use Hierarchical select, https://drupal.org/project/hierarchical\_select This will trigger the options in the dependency list whenever the source list is selected.
> 0 votes

# Answer
Try this code. This is not adapted to your code, but to your question. I have a working example which does exactly what you ask for. I don't find the throbber code in your example. Here we have 2 fields. Brand selection changes the property of ajax autocomplete of model field. The change is done in function `mymodule_models_update`

```
 $form['brand'] = array(
   '#type' => 'select',
   '#title' => t('Brand'),
   '#options' => $brands,
   '#default_value' => $brand,

'#ajax' => array(
    'callback' => 'mymodule_models_update',
    'wrapper' => 'models_wrapper',
    'progress' => array(
        'message' => '',
        'type' => 'throbber',
    ),
),

```

);

```
$form['model'] = array(
    '#type' => 'textfield',
    '#title' => t('Model'),
    '#description' => 'Please note available models change based on the brand.',
   '#required' => FALSE,

   '#autocomplete_path' => 'providers/autocomplete/' . $brand,
   '#attributes' => array("placeholder" => t('Model')),
   '#prefix' => '<div id="models_wrapper">',
   '#suffix' => '</div>',

```

);

```
 function mymodule_models_update($form, &$form_state) {
  unset($form_state['input']['model'], $form_state['values']['model']);
  $brand = $form_state['values']['brand'];
  $form['model']['#autocomplete_path'] = 'providers/autocomplete/' . $brand;
  return form_builder($form['#id'], $form['model'], $form_state);
} // function

```
> 0 votes

---
Tags: 7, forms, ajax
---


# Question
Title: Having trouble using responsive feature of Superfish
I am using the Superfish module for Drupal 7.x, and the menu itself works as advertised. However, no matter what configuration options I try, I cannot get the main menu to change into a select menu when at smaller screen sizes. It just attempts to render the original menu (which, of course, becomes a mess at smartphone size). I'm not even sure where to start looking for a problem. Any clues would be appreciated!

# Answer
I ran into the same problem a while ago, and wound up writing some javascript/css to convert a multi-level superfish menu into a windowshade-style menu. It wasn't very elegant, though, and I later found the Responsive Menus module - it was very easy to set up, from what I remember, and worked with Superfish right out of the box. It also provides several styles of mobile navigation -- though not a select menu, if that's specifically what you want.
> 1 votes

---
Tags: 7, theming, navigation
---


# Question
Title: Captcha image is not detected but installed and working properly
I have installed Captcha and Image Captcha submodule (included in Captcha). It works perfectly, and displays the captcha image. However, when trying to install Captcha Refresh module, I found that Drupal believes that the module is not installed. I had to reinstall once ago, many time ago, the module Captcha because it was not working (uninstalled, deleted, uploaded again, installed). Maybe this corrupted the system table or anything? How can I teach Drupal to detect the module?

# Answer
I have found this reference and following the comments, I detected that I had replicated the folder /modules/ inside of /sites/all/modules/, and the first folder contained a replica of the captcha folder, so this is why Drupal was confused about what module was installed. After deleting the folder, everything went OK.

What convinced me is that I had a copy of the whole database and a mirror site, but obviously without the replicated folder, and in the mirror site everything went OK. After discarding a permissions problem, I was convinced that it was a duplicate folder, and had to look in all places. Finally, it was at glance.
> 0 votes

---
Tags: 7, installation
---


# Question
Title: Why does the Path Breadcrumb module change URLs?
I have a multilanguage site. I had a link to `node/drupal_get_path_alias('node/15')` and works perfectly identifying the language of the site, so it gets the correct path ("products" for english, "productos" for spanish). I have installed Path Breadcrumb, tried to configure, and to my surprise, the link which previously worked is rewritten to the incorrect language, instead of "/productos" is "/products". **The link is in the main HTML, in the `preprocess_page`**. Why does Path Breadcrumb rewrites a path instead of just creating the breadcrumb? I uninstall the module and all works as intended again.

# Answer
> 0 votes
It was completely my fault. Path Breadcrumb works perfectly. The problem is that I had a path alias which instead of being English, it was All languages, and so the module didn't know what link to choose. I hadn't noticed the error before installing the module, and somehow the module installation made the error to be detectable.

---
Tags: 7, uri, i18n-l10n
---


# Question
Title: How to show the slide dots using the Slick Carousel module?
I'm using the Slick Carousel module and I can't see where / how to add the paging dots below the carousel images. The module boasts that it has this feature.

I've tried altering the .js file (and the .min version) but can't seem to force them to show.

Does anyone know where to turn this on?

# Answer
> 2 votes
You need to enable the slick module **and** the slick ui module, after that go to Configuration -\> Media -\> Slick Carousel (admin/config/media/slick).

From there you can edit the default profile for slick carousel or create a custom one. There you can enable or disable dots and of course various other options.

---
Tags: javascript
---


# Question
Title: When do you and when don't you revert a feature?
That's basically the question.

Or should I always include this `hook_update_N()` when ever I recreate/update a feature.

```
function my_global_update_7001(&$sandbox) {
  $feature = features_get_features('my_feature');
  $components = array_keys($feature->info['features']);
  features_revert(array('my_feature' => $components));
  ...
}

```

# Answer
> 1 votes
You do not write update hooks for features. To update a feature you modify your content types, views, fields, etc. Once your changes have been made you recreate the feature. When you push your new feature to another environment (dev, qa, live) that has a different version of the database, (i.e. the changes you just made) you use revert to update the environment.

# Answer
> 1 votes
Often I find that the feature needs to be reverted, but it's not 100% predictable. I do as you suggest and revert the feature in the update hook whenever there's a change. You never know if an update to Features module will affect when you can get away without reverting.

The alternative would be to do `drush fu all` in a deploy script.

---
Tags: hooks, features
---


title: User menu tab content

text:
# Question
Title: User menu tab content
On the /user page i've created two tabs:

```
function hook_menu() {

    $items['user/%/My-Courses'] = array(
        'title' => 'My Courses',
        'type' => MENU_LOCAL_TASK,
        'page callback' => 'drupal_get_form',
        'page arguments' => array('hook_form'),
        'access callback' => 'hook_access',
        'access arguments' => array('access content'),
    );

    $items['user/%/Privacy-Statement'] = array(
        'title' => 'Privacy Statement',
        'type' => MENU_LOCAL_TASK,
        'page callback' => 'drupal_get_form',
        'page arguments' => array('hook_form'),
        'access callback' => 'hook_access',
        'access arguments' => array('access content'),
    );

    return $items;
}

```

What i'm trying to do is add a link to the my courses tab, and a privacy statement (just text) to the privacy statement tab.

```
function hook_form(){

$form['privacy'] = array(
    '#type' => 'textfield',
    '#value' => 'Privacy statement',
  );

 // returns whatever you want to appear in that tab.
 $form['link1'] = array(
     '#type' => 'submit',
     '#value' => t('This will show the customers courses.'),
 );

 return $form;
}

```

The problem is that it's adding both the link and statement to both tabs.

How would I go about targeting each tab individually?

# Answer
I think you'd be better off creating *2 separate forms for each tab*, but if you want one form to handle both you can use the function `menu_get_item()` to determine the menu path that routed to the form.

```
  $menu_item = menu_get_item();
  if(isset($menu_item['path']) && $menu_item['path'] == 'user/%/Privacy-Statement') {
    //@TODO: Add form elements specific to privacy tab
  }

```
> 2 votes

---
Tags: hooks, routes
---


title: How do I render my module content?

text:
# Question
Title: How do I render my module content?
I have followed the "hello world" module tutorial at https://www.drupal.org/developing/modules/8. At the end of the tutorial, you create a custom page which gets generated from a render array you created in the module's controller. The content is a single line of text, contained in the `#markup` field in the render array.

Now I'm trying to go beyond and create a more complex page, with some ajax-enabled elements. Hard-coding a bunch of HTML and Javascript into the #markup field does not seem to be the way to go. And looking through other modules, I see that most do not have a `#markup` field, but a bunch of other fields, some of which seem to be custom fields (possibly adhering to an unknown naming convention), and others which appear to be defined by Drupal core. But in some cases it's not clear which are which, and after hours of searching the Drupal documentation and the wider internet, I cannot find a clear explanation of how the different fields in the array are interpreted and translated into HTML. (It seems that "theme hooks" may be involved somehow, but it's not clear to me which hooks are needed or where those hooks should be defined)

Can someone provide or point me towards an explanation of how to get to a desired HTML layout and set of javascript behaviors using render arrays?

# Answer
There's a naming convention at work here. Apparently the convention is "'base\_hook\_name\__sub\_hook\_name'." I don't know what "base\_hook\_name" or "sub\_hook\_name" mean, but I do know that if you create a module called *mymod* and create a function in *mymod.module* named `mymod_theme()`, Drupal will find it and use it to theme your module.

`mymod_theme()` should return an array of what I'll call "theme arrays" which are arrays containing things like the name of the template to use, and the variables that will get delivered to the template. The possible fields in these arrays are documented at https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!theme.api.php/function/hook\_theme/8

'template' is one of the fields, and can be used to specify the twig template to use.

So continuing with the *mymod* example,

in mymod/mymod.module:

```
mymod_theme(){
    return array(
        'mymaintheme' => array(
            'template' => 'mymodtemplate',  //corresponds to templates/mymodtemplate.twig.html
            'variables' => array(           //the template file will use these variables
                'title' => NULL             //we define the variable names and assign NULL
                                            //(optionally, we could assign a default value instead).
                                            //The actual values will be populated from the
                                            //render array that our controller will create

            )
        ),

        'someothertheme' => array(
            'template' => 'adifferenttemplate',
            'variables' => array(
                'aVariableInMyTemplate' => NULL
                'anotherVariable' => NULL
            )
        )
    );
}

```

in mymod/src/Controller/mymodController.php

```
public function thisGeneratesContent(){
    return array(
        '#theme' => 'mymaintheme',  //matches one of the themes returned from mymod_theme()
        '#title' => t('My Module')  //we defined a variable in our theme called 'title' so this value
                                    //gets passed to the template file, where it replaces instances of {{title}}
    );
}

```
> 0 votes

# Answer
Drupal is build and designed around the idea that the markup produced by a module is themable (ie. it can be changed by a theme independently of the module). Which mean that markup for a page is usually build using Drupal theming system. Basically, you define templates then use them in your render arrays. In your render arrays, `#theme` define the used templates, almost ever other entries are specific to the templates and used to inject variables into the template or its preprocess functions.

To add CSS and JavaScript you need to attach them to your render arrays with `#attached` as *assets libraries*, see the Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 module documentation for details. This is used to allow Drupal core and other module to optimize inclusion of the CSS and JS files into your page.
> 1 votes

---
Tags: 8
---


# Question
Title: How do you remove the "user login" block?
I know this is a simple question, but I've searched for way too long.

I just want to remove the user login box so that all accesses to the site, apart administrator access, will be anonymous. We don't want users to create accounts on the system.

# Answer
> 10 votes
You may disable block on *admin/structure/block* page, but users can create new accounts from */user* page. It's best practice disable creating new accounts by visitors.

* For drupal 7 go to *configuration -\> people -\> account settings -\> registration and cancellation* and set "Who can register accounts?" -\> "Administrators only".
* For drupal 6 go to *administer --\> user management --\> user settings* and set "Public registrations" --\> "Only site administrators can create new user accounts."

# Answer
> 3 votes
Blocks can be enabled or disabled at the blocks menu item located under the structure menu item. (admin/structure/block)

# Answer
> 0 votes
In Drupal 7, my login controls were not adjusted by visiting the "Blocks" page.

Instead, visit your theme's settings page "admin/appearance/settings/\[theme name\]" and disable the secondary menu

---
Tags: 7, users
---


# Question
Title: New taxonomy vocabs being generated with blank, broken fields
I have a standard Drupal 7 site with Commerce modules enabled. Enabled the `taxonomy` module and created a vocab, but when I go to manage fields, there's an odd blank field there that causes "save" to break, as well as viewing the display options. Equally, trying to edit or delete the field doesn't work as the URLs they point to are non-existent (/fields/ and /fields//delete, respectively).

I was deleting data from some commerce tables and field\_data\_\* tables in the db in order to clear out product info, so that could be a culprit; but I don't know why it would affect field definitions, especially in taxonomy terms.

Any ideas? Thanks.

### Manage fields page:

### Manage display page:

### Enabled modules:

```
matt@MaffBookPro:~/work/freelance/plainbear/plainbear.co.uk/www/sites$ drush pm-list | grep 'Enabled'
 Administration                       Administration menu (admin_menu)                                      Module  Enabled        7.x-3.0-rc5
 Chaos tool suite                     Chaos tools (ctools)                                                  Module  Enabled        7.x-1.9
 Commerce                             Cart (commerce_cart)                                                  Module  Enabled        7.x-1.11
 Commerce                             Checkout (commerce_checkout)                                          Module  Enabled        7.x-1.11
 Commerce                             Commerce (commerce)                                                   Module  Enabled        7.x-1.11
 Commerce                             Commerce Multicurrency (commerce_multicurrency)                       Module  Enabled        7.x-1.3
 Commerce                             Commerce UI (commerce_ui)                                             Module  Enabled        7.x-1.11
 Commerce                             Customer (commerce_customer)                                          Module  Enabled        7.x-1.11
 Commerce                             Customer UI (commerce_customer_ui)                                    Module  Enabled        7.x-1.11
 Commerce                             Line Item (commerce_line_item)                                        Module  Enabled        7.x-1.11
 Commerce                             Line Item UI (commerce_line_item_ui)                                  Module  Enabled        7.x-1.11
 Commerce                             Order (commerce_order)                                                Module  Enabled        7.x-1.11
 Commerce                             Order UI (commerce_order_ui)                                          Module  Enabled        7.x-1.11
 Commerce                             Payment (commerce_payment)                                            Module  Enabled        7.x-1.11
 Commerce                             Payment UI (commerce_payment_ui)                                      Module  Enabled        7.x-1.11
 Commerce                             Price (commerce_price)                                                Module  Enabled        7.x-1.11
 Commerce                             Product (commerce_product)                                            Module  Enabled        7.x-1.11
 Commerce                             Product Pricing (commerce_product_pricing)                            Module  Enabled        7.x-1.11
 Commerce                             Product Pricing UI (commerce_product_pricing_ui)                      Module  Enabled        7.x-1.11
 Commerce                             Product Reference (commerce_product_reference)                        Module  Enabled        7.x-1.11
 Commerce                             Product UI (commerce_product_ui)                                      Module  Enabled        7.x-1.11
 Commerce (contrib)                   Card on File (commerce_cardonfile)                                    Module  Enabled        7.x-2.0-beta5
 Commerce (contrib)                   Commerce Addressbook (commerce_addressbook)                           Module  Enabled        7.x-2.0-rc9
 Commerce (contrib)                   Commerce Backoffice (commerce_backoffice)                             Module  Enabled        7.x-1.5
 Commerce (contrib)                   Commerce Backoffice content (commerce_backoffice_content)             Module  Enabled        7.x-1.5
 Commerce (contrib)                   Commerce Backoffice Order (commerce_backoffice_order)                 Module  Enabled        7.x-1.5
 Commerce (contrib)                   Commerce Backoffice Product (commerce_backoffice_product)             Module  Enabled        7.x-1.5
 Commerce (contrib)                   Commerce Billy (commerce_billy)                                       Module  Enabled        7.x-1.0
 Commerce (contrib)                   Commerce Billy Mail (commerce_billy_mail)                             Module  Enabled        7.x-1.0-beta5
 Commerce (contrib)                   Commerce Billy PDF (commerce_billy_pdf)                               Module  Enabled        7.x-1.0
 Commerce (contrib)                   Commerce Checkout Progress (commerce_checkout_progress)               Module  Enabled        7.x-1.4
 Commerce (contrib)                   Commerce Default Product Variant (commerce_default_product_variant)   Module  Enabled        7.x-1.3
 Commerce (contrib)                   Commerce Devel (commerce_devel)                                       Module  Enabled        7.x-1.0-beta6
 Commerce (contrib)                   Commerce Devel Generate (commerce_devel_generate)                     Module  Enabled        7.x-1.0-beta6
 Commerce (contrib)                   Commerce Feeds (commerce_feeds)                                       Module  Enabled        7.x-1.3
 Commerce (contrib)                   Commerce Message (commerce_message)                                   Module  Enabled        7.x-1.0-rc3
 Commerce (contrib)                   Commerce Product Add On (commerce_pado)                               Module  Enabled        7.x-1.5
 Commerce (contrib)                   Commerce Reorder (commerce_reorder)                                   Module  Enabled        7.x-1.1
 Commerce (contrib)                   Commerce Search API (commerce_search_api)                             Module  Enabled        7.x-1.4
 Commerce (PayPal)                    PayPal (commerce_paypal)                                              Module  Enabled        7.x-2.3
 Commerce (PayPal)                    PayPal Express Checkout (commerce_paypal_ec)                          Module  Enabled        7.x-2.3
 Commerce (shipping)                  Flat Rate (commerce_flat_rate)                                        Module  Enabled        7.x-1.0-beta2
 Commerce (shipping)                  Shipping (commerce_shipping)                                          Module  Enabled        7.x-2.2
 Commerce (shipping)                  Shipping UI (commerce_shipping_ui)                                    Module  Enabled        7.x-2.2
 Commerce (Tax)                       VAT (commerce_vat)                                                    Module  Enabled        7.x-1.0-rc2
 Commerce (Tax)                       VAT Product field (commerce_vat_field)                                Module  Enabled        7.x-1.0-rc2
 Commerce (Tax)                       VAT Reference Field (commerce_vat_reference)                          Module  Enabled        7.x-1.0-rc2
 Commerce - Payment                   SagePay Integration for Drupal Commerce (commerce_sagepay)            Module  Enabled        7.x-1.0
 Commerce EU VAT                      Commerce EU VAT (commerce_eu_vat)                                     Module  Enabled        7.x-2.4
 Commerce EU VAT                      Commerce EU VAT GB (commerce_eu_vat_gb)                               Module  Enabled        7.x-2.4
 Core                                 Database logging (dblog)                                              Module  Enabled        7.41
 Core                                 Field (field)                                                         Module  Enabled        7.41
 Core                                 Field SQL storage (field_sql_storage)                                 Module  Enabled        7.41
 Core                                 Field UI (field_ui)                                                   Module  Enabled        7.41
 Core                                 File (file)                                                           Module  Enabled        7.41
 Core                                 Filter (filter)                                                       Module  Enabled        7.41
 Core                                 Image (image)                                                         Module  Enabled        7.41
 Core                                 List (list)                                                           Module  Enabled        7.41
 Core                                 Node (node)                                                           Module  Enabled        7.41
 Core                                 Options (options)                                                     Module  Enabled        7.41
 Core                                 System (system)                                                       Module  Enabled        7.41
 Core                                 Taxonomy (taxonomy)                                                   Module  Enabled        7.41
 Core                                 Text (text)                                                           Module  Enabled        7.41
 Core                                 Update manager (update)                                               Module  Enabled        7.41
 Core                                 User (user)                                                           Module  Enabled        7.41
 Date/Time                            Date (date)                                                           Module  Enabled        7.x-2.9
 Date/Time                            Date API (date_api)                                                   Module  Enabled        7.x-2.9
 Date/Time                            Date Popup (date_popup)                                               Module  Enabled        7.x-2.9
 Date/Time                            Date Views (date_views)                                               Module  Enabled        7.x-2.9
 Development                          Devel (devel)                                                         Module  Enabled        7.x-1.5
 Development                          Devel generate (devel_generate)                                       Module  Enabled        7.x-1.5
 Features                             Commerce Features (commerce_features)                                 Module  Enabled        7.x-1.1
 Features                             Features (features)                                                   Module  Enabled        7.x-2.7
 Features                             ServicesExample (servicesexample)                                     Module  Enabled
 Feeds                                Feeds (feeds)                                                         Module  Enabled        7.x-2.0-beta1
 Fields                               Address Field (addressfield)                                          Module  Enabled        7.x-1.2
 Fields                               Entity Reference (entityreference)                                    Module  Enabled        7.x-1.1
 Message                              Message (message)                                                     Module  Enabled        7.x-1.10
 Message                              Message notify (message_notify)                                       Module  Enabled        7.x-2.5
 OAuth                                OAuth (oauth_common)                                                  Module  Enabled        7.x-3.2
 OAuth                                OAuth Provider UI (oauth_common_providerui)                           Module  Enabled        7.x-3.2
 Other                                CORS (cors)                                                           Module  Enabled        7.x-1.3
 Other                                Entity API (entity)                                                   Module  Enabled        7.x-1.6
 Other                                Entity tokens (entity_token)                                          Module  Enabled        7.x-1.6
 Other                                Job Scheduler (job_scheduler)                                         Module  Enabled        7.x-2.0-alpha3
 Other                                Libraries (libraries)                                                 Module  Enabled        7.x-2.2
 Other                                Multiple Node Add (multi_node_add)                                    Module  Enabled        7.x-1.0-beta4
 Other                                Token (token)                                                         Module  Enabled        7.x-1.6
 Other                                Weight (weight)                                                       Module  Enabled        7.x-2.5
 Performance and scalability          Boost (boost)                                                         Module  Enabled        7.x-1.0
 Rules                                Rules (rules)                                                         Module  Enabled        7.x-2.9
 Rules                                Rules UI (rules_admin)                                                Module  Enabled        7.x-2.9
 Search                               Search API (search_api)                                               Module  Enabled        7.x-1.16
 Search                               Solr search (search_api_solr)                                         Module  Enabled        7.x-1.9
 Services                             Commerce Services (commerce_services)                                 Module  Enabled        7.x-1.x-dev
 Services                             Plain Bear Commerce Services (pb_commerce_services)                   Module  Enabled
 Services                             Services (services)                                                   Module  Enabled        7.x-3.12
 Services                             Services Views (services_views)                                       Module  Enabled        7.x-1.1
 Services - authentication            OAuth Authentication (services_oauth)                                 Module  Enabled        7.x-3.12
 Services - servers                   REST Server (rest_server)                                             Module  Enabled        7.x-3.12
 Views                                Eva (eva)                                                             Module  Enabled        7.x-1.2
 Views                                Views (views)                                                         Module  Enabled        7.x-3.11
 Views                                Views Bulk Operations (views_bulk_operations)                         Module  Enabled        7.x-3.3
 Views                                Views megarow (views_megarow)                                         Module  Enabled        7.x-1.5
 Core                                 Bartik (bartik)                                                       Theme   Enabled        7.41
 Core                                 Seven (seven)                                                         Theme   Enabled        7.41

```

# Answer
> 1 votes
`[The sound of tumbleweed gently rolling past]`

Well, cheers for all the help guys ;)

Finally managed to fix it myself. The culprit was `commerce_services`, fixed with this patch and documented in this drupal.org thread.

---
Tags: 7, commerce
---


# Question
Title: Nest a Field Widget's primary field in a Fieldset array
I'm porting over some logic that's working on a custom form to a new field widget; however, due to some javascript logic the custom form needs the end field to be nested within other elements, but when I try to nest the element in the widget, the value is not sent through the form.
Forcing a name attribute like I do below doesn't seem to help.

```
$element['filter']['client_selector'] = array(
    '#title'=>'Your Clients',
    '#type'=>'fieldset',
    '#theme'=>'mymodule_option_selector',
    '#list'=>$client_selector
);
$element['filter']['client_selector']['tid'] = array(
    '#type' => 'hidden',
    '#default_value' => $selected_client,
    '#attributes'=>array('class'=>array('hidden-value'),
        'name'=>$instance['field_name'] . '[' . $langcode . '][' . $delta . '][tid]'),
);

```

This works to send the value, but not with the selector system

```
$element['tid'] = array(
    '#type' => 'hidden',
    '#default_value' => $selected_client,
    '#attributes'=>array('class'=>array('hidden-value')),
);

```

Thanks!

# Answer
I ended-up just adding a submit and validation callback that re-aligned the index.

In the hook\_field\_widget\_form

```
function mymodule_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
//  widget form logic....

//  Add a custom submit handler to realign the values
    $form['#submit'][] = 'mymodule_option_selector_submit_validate';
    $form['#validate'][] = 'mymodule_option_selector_submit_validate';

//  Tell the form what field uses the option selector so it knows which fields to relign
    if(!isset($form['#option_selector_fields']))
        $form['#option_selector_fields'] = array();
    $form['#option_selector_fields'][] = array(
        'field_name'=>$instance['field_name'],
        'langcode'=>$langcode,
        'delta'=>$delta,
        'columns'=>$element['#columns'],
    );

    return $element;

}

function mymodule_option_selector_submit_validate($form, &$form_state){
    if(isset($form['#option_selector_fields'])){
        foreach($form['#option_selector_fields'] as $field_data){
            foreach($field_data['columns'] as $column)
                $form_state['values'][$field_data['field_name']][$field_data['langcode']][$field_data['delta']][$column] =
                        $form_state['values'][$field_data['field_name']][$field_data['langcode']][$field_data['delta']]['filter']['client_selector'][$column];
        }
    }
}

```

Still would be nice to know if there is some kind of toggle in the widget form system to accommodate this.
> 0 votes

---
Tags: entities
---


# Question
Title: How to organize categories and subcategories of products in menus?
I have product content type that I want to display in a menu. Every product belongs to subcategory that belongs to main category, for example:

```
Computers:
   PC:
      - product 1
      - product 2
      - product 3
   Laptop:
      - product 1
      - product 2
      - product 3
   Tablets:
      - product 1
      - product 2
      - product 3

Phones:
   Android:
      - product 1
      - product 2
      - product 3
   iOS:
      - product 1
      - product 2
      - product 3

```

When clicking on products item in main menu, I need to display a horizontal menu with main categories (Computers, Phones) and a vertical menu with subcategories (PC, Laptop, Tablets). Computers \> PC should be the default selection. Whenever any category/subcategory is selected it should display a list of links to the product page.

What are the most common modules use to do something like this? Are there any tutorials or basic steps I can take to accomplish this goal?

# Answer
while you want to display category, sub category and node at the same time, so you have to use views. you can use group by in the views and groups the results depending on category and subcategory.

but you also mention that you don't want to show product unless you click on the subcategory, to get this there is many ways, the simplest one is create view that shows the category and subcategory, when you click on it it will drive you automatically to the taxonomy page.

if you don't want to use views you can use taxonomy modules in Drupal there are a lot of them.
> 0 votes

---
Tags: taxonomy-terms, routes
---


# Question
Title: Lost all JS and CSS on updating the module?
I had added **JS** and **CSS** in the **views** module using the **.info** method. Made JS and CSS file in the views module file (`as sites/all/modules/views/jsfile.js & sites/all/modules/views/cssfile.css`) and attached it through `views.info` file. It was working fine. But today got an update notification of **views** module and updated the views and those all customized css & js things gone. Code was small so I made it again. But what is the right way to do this? So on update it will not go away? I believe adding css & js by `.info` method also a one of standard method.

# Answer
That is why you should never do any modification to a module. The proper way to do this is to add the **js** and **css** to your custom theme using the same method you have done for views. It is strongly discouraged to modify module or add anythings to the module otherwise on update all the changes will be lost.
> 4 votes

---
Tags: views, javascript
---


# Question
Title: How to modify the display of custom line items in the ADD To Cart Form?
My issue is this, imagine that I have created a few custom line item types in Drupal Commerce called:

* Text on TShirt FRONT
* Text on TShirt BACK

I use these two fields in the ADD To Cart Form checkbox so that the customer can specify what the want on the fron of the Tshirt to say and the back. So far so good.

The issue is that how do I change the display of this product node so for example I don't want it to appear in a single column but in two columns side by side.

I have tried Panels, I have tried Display Suite, this is not working. I can't even change the order of fields say I wanted the back to show up first and then the front.

I have tried changing things around in line item configuration display, which doesn't work and I have also tried changing the disply of the product display content type, (which btw does not even show the individual fields of the add to cart forms).

I am not good with coding so I would appreciate if I can work on this from the front end with any modules.

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

---
Tags: commerce
---


# Question
Title: Password Security for Downloading PDF in drupal7
i have a file upload field type in my content type. so user can upload PDF file in that. i want to make password security for downloading the PDF. Can anyone help on this?

Thanks in Advanced.

# Answer
> 2 votes
There are two methods to ensure security of your files:

1) You can choose the "Private downloads" method in admin/settings/file-system, and

* Either set your files path to a directory outside your web root so that they don't have an URL
* or leave them where they are and protect them with some .htaccess directive (Order deny,allow and deny from all).

Apache won't serve them directly, and Drupal will read them and serve them with a virtual path system/files.

Then you can set permissions for the files by using an access control module (content\_access or nodeaccess or node\_privacy\_byrole or og) and restricting access to the posts where they were uploaded, so that only some user roles can see them.

**Caveats:**

* Your file-related modules must support the private download method
* The private method is a bit slower because of the additional processing.
* If you already have uploaded files their links may break if you change the download method now.

2) You can use pdf using mpdf module. it offers the ability to password protect your files.

---
Tags: files
---


title: Output Path to File Content in Views

text:
# Question
Title: Output Path to File Content in Views
In a view I would like to output just the path to the piece of content where the file is referenced like the below:

```
http://www.example.org/file/1

```

I DO NOT want to link directly to the file itself.

I thought it would be a simple task but most of the fields are adding html (like `<a href="http://www.example.org/file/1">View</a>`).

**I am filtering by a file type of "Video"**. I have tried adding the below with no success:

```
File: Download Link
File: Edit link
File: Link
File: Path

```

And have also tried using a relationship:

```
Content: Link
Content: Path

```

I have been able to get it working by rewriting the File: File ID field and hard-coding the url with the \[fid\] as a token, but that's a horrible solution.

# Answer
Please try to locate another relationship named "File Usage: File" After that you should be able to add a field type "File: Path". In the field options you can decide how the output is formatted: as server-path (public://yourpath) or as download path.
> 0 votes

---
Tags: views, files
---


# Question
Title: Display the amount of the order on the block cart
do you know how to display the amount of the basket next to the number of elements? As this page http://demo.commerceguys.com/cart

thank you

```
/**
* Returns the title of the shopping cart menu item with an item count.
*/
function commerce_cart_menu_item_title() {
global $user;

// Default to a static title.
$title = t('Shopping cart');

// If the user actually has a cart order...
if ($order = commerce_cart_order_load($user->uid)) {
// Count the number of product line items on the order.
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$quantity = commerce_line_items_quantity($wrapper->commerce_line_items,             commerce_product_line_item_types());

// If there are more than 0 product line items on the order...
if ($quantity > 0) {
  // Use the dynamic menu item title.
  $title = format_plural($quantity, 'Shopping cart (1 item)', 'Shopping   cart (@count items)');
 }
 }

return $title;
 }

```

# Answer
In Commerce Kickstart, you're actually looking at a view. The footer of the view displays a line item summary:

You can read through the handler's render() function to see how it actually gets that information.
> 2 votes

---
Tags: commerce
---


# Question
Title: Can I update from 7.34 to 7.41 directly? What is the safest way to do so?
I have a site built using Drupal 7.34, and now I want the core to be upgraded to 7.41 and would like to know the safest way to do it.

# Answer
> 7 votes
Yes, Drupal Core is self-contained in that any forward version of Drupal contains all the updates of intermediary versions of Drupal you are missing. So, you don't have to install and update Drupal manually through every single version of Drupal that is released.

The recommended way is to simply overwrite your drupal site files as per the distributed documentation with Drupal. Put your site in Maintenance Mode and run the update script.

Alternatively, you can upgrade Drupal via Patches: https://fuerstnet.de/en/drupal-upgrade-easy-way

# Answer
> 4 votes
Using drush to upgrade is for me the best, safest (as it does backups) and fastest way to upgrade Drupal, so:

Backup your databases and your files first.

```
drush archive-dump

```

Then to update core you can run

```
drush up drupal

```

# Answer
> 3 votes
> Can i upgrade from 7.34 to 7.41 directly? What is the safest way to do so?

Yes you can.

**Step 1)**

Backup your server's Database and your Drupal folder.

**Step 2)**

Follow this Video Tutorial Update Drupal Core to newer version which is the safest way to do it.

**Quick Summary of the Video**

1. Download Drupal 7.41 zip file and extract its contents.
2. Delete the `Sites folder` and also `.gitignore` `.htaccess` and `robots.txt` files.
3. Upload everything onto your server and overwrite the files.

**Once you uploaded and overwritten everything on your server**

4. Put your website in `Maintenace Mode` (Configuration \> Maintenance Mode)
5. Go to `www.yourwebsite.com/update.php` and update the database
6. Take your website out of `Maintenace Mode`
7. Delete `Install.php` from your server. (not covered in the video, but its good to do it)

---
Tags: 7, updating
---


# Question
Title: <div> added to Views header (global unfiltered text) disappears with inspect element
I'm trying to wrap a tag around some content in my View header but it's not working as intended.

I'm using the Global: Unfiltered text as the type of header content. I'm inserting the div like so:

```
<div class="some-class"><h2>header</h2></div>

```

It saves it alright and when I go back and view it it's still in there...but for some reason it doesn't show up in the HTML when I inspect element. The h2 tag shows up but not the div wrapped around it.

Thoughts on how to fix this?

# Answer
Add your header (for quick testing purposes, so you don't need to add it to a css file)

```
<style>
 .some-class { border: solid red; }
</style>

```

To double check that indeed it's not there.

If it's not there (you don't see anything red), then try using **Global: Text area** instead and use Full HTML as your text format.
> 2 votes

---
Tags: views
---


# Question
Title: No results behavior in Views not working when referencing another field after cache clear
**My Setup:**

I am using Drupal 7.41 and Views / Views UI 3.11.

1. I have a taxonomy named *sermon series* that includes a field called *series image*.
2. I have a content type called *sermons* that has an image called *sermon image* and a term reference to the *sermon series* taxonomy.
3. Lastly, I have a View called *sermons* that:
    * pulls in the most recent 1 node from the content type *sermons*
    * has a relationship to the taxonomy *sermon series*
    * has the first field in the *fields* list as the **sermon series image** (from taxonomy) and is set to "hide from display". The *replacement pattern token* for this field is \[field\_sermon\_image\_2\]
    * has the second field in the *fields* list as the **sermon image** (from content type) and is set to show in the display.
        + this field has a *no results behavior* set to the token \[field\_sermon\_image\_2\]

**Expected Behavior:**

If the most recent node has an image associated with it, that image will show. If there is no image associated with the node, it will show the image associated with the taxonomy *sermon series*.

**Actual Behavior**

When I create a node **with** the *sermon image* filled out, everything works as expected and the view shows the sermon image associated with the Node shows.

When I create a node **without** a sermon image filled out, the view correctly shows the *sermon series image* associated with the taxonomy *sermon series*.

Here's where it gets weird. If I create a node **without** a sermon image filled out, see the view correctly show the *sermon series image* from the taxonomy, then either clear cache or wait until cache expires, no image shows up at all. I know the fallback is working correctly as even the \[field\_sermon\_image\_2\] has a *no results behavior* fallback to a *generic* image and that's what always shows up.

Through some testing, I found that unpublishing the node, viewing the *view*, then re-publishing the node will bring the correct image back (at least until the next cache flush).

I'm not sure where to look for this odd behavior. It seems like I have everything setup correctly in my view as I can get the correct images to show up, I just can't get them to show up consistently.

Any advice you can give would be appreciated. Thanks!

# Answer
I replicated your scenario and its working fine for me.

Here is what I did.

1. In Taxonomy I added a **Vocabulary** called "**Sermons**", I added an **image field** called "**tax image**"
2. I added a **term name** of "**Mega Man**" to Sermons, and **uploaded a mega man picture** to the "**tax image**" field.
3. Created an **Article** with title of "**Enter Shikari is awesome**" which has "Article Picture" as a field and I **uploaded a picture of the band**. Term Ref "Mega Man"
4. I Created another **Article** with title "**Woooo**" this time **I did not upload any image** to the "Article Picture" field. Term Ref "Mega Man"

**Now in Views**

5. In **FILTER CRITERIA** I added **Content Type** Is one of **Article** (so it only shows Article nodes)
6. In **RELATIONSHIP** I added **Content: Taxonomy terms on node**

* Check marked "Sermon Series"
    * Check marked **Require this relationship**.

7. In **FIELDS** and I added the "**tax image**"

* checked **exclude from display**.
8. In **FIELDS** I added "**Article Picture**"

* No Results behaviour I put the token \[field\_tax\_image\]

9. I put a cache of 1 hour.

**So here is what my View looks like**

10. I added another **Article** with title "**Kewl its working!!!**" with Term Ref "Mega Man" and **left the "Article Picture" field empty.**
11. **I Cleared the cache** (since my view is cached, it won't show "kewl is working!!! until I clear it).

**RESULT AS EXPECTED** `Kewl its working!!!` and `Wooo` do `not have Article Pictures`, so Mega Man (tax image) shows up.
> 0 votes

---
Tags: views, taxonomy-terms
---


# Question
Title: How to create a chart about a date range if some dates in this range are missing?
I use charts module Charts and I want to create a view that shows the stats from a date range.

I have an exposed filter and this filter has a between range. I want to show all dates from values of exposed filter.

I provided the values `7/10/2015` and `15/10/2015` as my date range and always show the dates if no stats exist for specific days in this range.

For example: 7/10/2015, 8/10/2015, 9/10/2015, 10/10/2015, 11/10/2015, etc. up to 15/10/2015,

Attached an image to understand what I want (how the chart should look like).

How can I do this, with filter, arguments or handlers, please give me a example.

For this moment the module "views between date filter" is not working as I want: it only shows all dates for which some data exist. But always need show the dates that no have results.

# Answer
> 0 votes
I'm assuming you're using the Charts module and that your problem is similar to what is detailed in Comment nr 12 of Issue nr 2052429. Here is part of what that comment includes:

> ... It's not an issue Google Charts could actually fix, as there is no "labels" sent to Google Charts for the chart addons for it to recognise gaps in the data ...

So at a minimum I recommend you to try the most recent DEV version, and apply the patch attached to that comment, to check if that helps in your case. If it doesn't, know that it is a prereq for sure (without that patch you won't be able to get it to work).

If applying the patch is not sufficient, then I'd recommend what's written in the "Bonus tip" of Steps to create charts using the views UI, i.e.:

> You may find it easier to start with a "Table" display and convert it to a chart display after setting up the data. It can be easier to visualize what the result of the chart will be if it's been laid out in a table first.

In other words: before trying to create a chart, make sure the tabular version of it has the correct data displayed.

Disclosure: I'm a co-maintainer of the Charts module (+ author of its community documentation),
I hope this does not violate the site's policy on self-promotion.

---
Tags: 7, views, charts
---


# Question
Title: Register an anonymous user when entity form is submitted with rules
I have created an entityform called "Order Request". This form has fields for the user to enter their first name, last name, email address, and their order contents. I would like to register this anonymous user when they submit this form. I have this working, configured with the Email Registration module and Rules to use these fields to create the new user.

However, the problem is this: Both anonymous and registered users (with the role: customer) need to be able to use the form. I need to prevent an error if there is already an account created using the email address submitted in the form. I would like to check that and not fire the rule to create a new account. How can I create this conditional in my rule? Hope that's clear. Thanks

# Answer
> 2 votes
I thought the field validation module should have been able to do this but I couldn't make it validate against the user mail field. Maybe you could try that and have better luck.

The other option which definitely works and requires no coding is to use the Views Bulk Operations (VBO) module and use rules conditions to check the number of results for that email address.

a. VBO Mail Check View

1. Create a new view page to display users.
2. Add the "Bulk operations: User" field (no changes needed).
3. Add the contextual filter, "User: Email" and provide the default, "Raw value from Url, path component 2".
4. Test with the preview using a valid email address and make sure one result shows before proceeding.

b. New rule condition in your main rule for when the entity form is saved.

1. "Check number of results returned by a VBO View"
2. Choose the view and page display you created above.
3. Send the text field from the entity form as an argument. (This will be path component 2 in the VBO view above)
4. Set the minimum value to 1.
5. Negate the condition.

This will make the rule fire if the VBO view returns zero results ie. no email.

c. Create a new rule to show an error if the mail exists.

1. Same condition as above.
2. I don't really know why this works but anyways. Add an AND above the condition, negate it and indent the condition which is also negated. (move it to the right like it's a child). It will look like

Entity has field

NOT AND

NOT Check number of results returned by a VBO View

3. Action: Display site message and tell the user that the email is already in use.

It looks a bit convoluted but should only take a few minutes to get working. Good luck!

---
Tags: rules, users, entities
---