# Question
Title: How to make user as an exposed filter option in filter criteria of a normal view?
In a view, I want list of users of specific role to be exposed filter option, which will list all users of that role.

**Example:** What I want is in view type like order or customer of ubercart(example), I want user to be filter criteria with exposed filter option of specific role(buyer or seller). If i select one user that particular user order should be listed.

Is that possible?? If so then how?

Thanks in advance.

# Answer
> 0 votes
You may install this module Total Control module. After installing this module goto this link **yourdomain.com/admin/structure/views/view/control\_users/edit**

This view provides the functionality you want.

To see it working you visit the page through this link **yourdomain.com/admin/dashboard/users**

**EDIT** I have export the view and pasted it below in-case you just need a reference and don't want to install that module.

```
$view = new view();
$view->name = 'control_users';
$view->description = 'Total Control over user accounts: Contains a panel pane and a page to control user accounts.';
$view->tag = 'total_control';
$view->base_table = 'users';
$view->human_name = '';
$view->core = 0;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Defaults */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->display->display_options['title'] = 'User Accounts';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'have total control';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['exposed_form']['options']['submit_button'] = 'Filter';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '35';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
  'name' => 'name',
  'mail' => 'mail',
  'rid' => 'rid',
  'status' => 'status',
  'created' => 'created',
  'login' => 'login',
  'delete_node' => 'delete_node',
  'edit_node' => 'edit_node',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
  'name' => array(
    'sortable' => 1,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'mail' => array(
    'sortable' => 1,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'rid' => array(
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'status' => array(
    'sortable' => 1,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'created' => array(
    'sortable' => 1,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'login' => array(
    'sortable' => 1,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'delete_node' => array(
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'edit_node' => array(
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
);
/* Field: Bulk operations: User */
$handler->display->display_options['fields']['views_bulk_operations']['id'] = 'views_bulk_operations';
$handler->display->display_options['fields']['views_bulk_operations']['table'] = 'users';
$handler->display->display_options['fields']['views_bulk_operations']['field'] = 'views_bulk_operations';
$handler->display->display_options['fields']['views_bulk_operations']['label'] = '';
$handler->display->display_options['fields']['views_bulk_operations']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['display_type'] = '0';
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['enable_select_all_pages'] = 1;
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0;
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10';
$handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array(
  'action::user_block_user_action' => array(
    'selected' => 1,
    'postpone_processing' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::views_bulk_operations_delete_item' => array(
    'selected' => 0,
    'postpone_processing' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::views_bulk_operations_script_action' => array(
    'selected' => 0,
    'postpone_processing' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::views_bulk_operations_modify_action' => array(
    'selected' => 0,
    'postpone_processing' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
    'settings' => array(
      'show_all_tokens' => 1,
      'display_values' => array(
        '_all_' => '_all_',
      ),
    ),
  ),
  'action::views_bulk_operations_user_roles_action' => array(
    'selected' => 0,
    'postpone_processing' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::views_bulk_operations_argument_selector_action' => array(
    'selected' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
    'settings' => array(
      'url' => '',
    ),
  ),
  'action::system_send_email_action' => array(
    'selected' => 1,
    'postpone_processing' => 0,
    'skip_confirmation' => 1,
    'override_label' => 0,
    'label' => '',
  ),
);
/* Field: User: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
/* Field: User: E-mail */
$handler->display->display_options['fields']['mail']['id'] = 'mail';
$handler->display->display_options['fields']['mail']['table'] = 'users';
$handler->display->display_options['fields']['mail']['field'] = 'mail';
/* Field: User: Roles */
$handler->display->display_options['fields']['rid']['id'] = 'rid';
$handler->display->display_options['fields']['rid']['table'] = 'users_roles';
$handler->display->display_options['fields']['rid']['field'] = 'rid';
/* Field: User: Created date */
$handler->display->display_options['fields']['created']['id'] = 'created';
$handler->display->display_options['fields']['created']['table'] = 'users';
$handler->display->display_options['fields']['created']['field'] = 'created';
$handler->display->display_options['fields']['created']['label'] = 'Created';
$handler->display->display_options['fields']['created']['date_format'] = 'custom';
$handler->display->display_options['fields']['created']['custom_date_format'] = 'm/d/Y';
/* Field: User: Last login */
$handler->display->display_options['fields']['login']['id'] = 'login';
$handler->display->display_options['fields']['login']['table'] = 'users';
$handler->display->display_options['fields']['login']['field'] = 'login';
$handler->display->display_options['fields']['login']['date_format'] = 'custom';
$handler->display->display_options['fields']['login']['custom_date_format'] = 'j/d g:ia';
/* Field: User: Edit link */
$handler->display->display_options['fields']['edit_node']['id'] = 'edit_node';
$handler->display->display_options['fields']['edit_node']['table'] = 'users';
$handler->display->display_options['fields']['edit_node']['field'] = 'edit_node';
$handler->display->display_options['fields']['edit_node']['label'] = 'Edit';
$handler->display->display_options['fields']['edit_node']['text'] = 'edit';
/* Sort criterion: User: Created date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'users';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: User: Name */
$handler->display->display_options['filters']['uid']['id'] = 'uid';
$handler->display->display_options['filters']['uid']['table'] = 'users';
$handler->display->display_options['filters']['uid']['field'] = 'uid';
$handler->display->display_options['filters']['uid']['operator'] = 'not in';
$handler->display->display_options['filters']['uid']['value'] = array(
  0 => 0,
);
$handler->display->display_options['filters']['uid']['expose']['label'] = 'User: Name';
$handler->display->display_options['filters']['uid']['expose']['operator'] = 'uid_op';
$handler->display->display_options['filters']['uid']['expose']['identifier'] = 'uid';
/* Filter criterion: User: Roles */
$handler->display->display_options['filters']['rid']['id'] = 'rid';
$handler->display->display_options['filters']['rid']['table'] = 'users_roles';
$handler->display->display_options['filters']['rid']['field'] = 'rid';
$handler->display->display_options['filters']['rid']['exposed'] = TRUE;
$handler->display->display_options['filters']['rid']['expose']['operator_id'] = 'rid_op';
$handler->display->display_options['filters']['rid']['expose']['label'] = 'Roles';
$handler->display->display_options['filters']['rid']['expose']['operator'] = 'rid_op';
$handler->display->display_options['filters']['rid']['expose']['identifier'] = 'rid';
/* Filter criterion: User: Name */
$handler->display->display_options['filters']['uid_1']['id'] = 'uid_1';
$handler->display->display_options['filters']['uid_1']['table'] = 'users';
$handler->display->display_options['filters']['uid_1']['field'] = 'uid';
$handler->display->display_options['filters']['uid_1']['value'] = '';
$handler->display->display_options['filters']['uid_1']['exposed'] = TRUE;
$handler->display->display_options['filters']['uid_1']['expose']['operator_id'] = 'uid_1_op';
$handler->display->display_options['filters']['uid_1']['expose']['label'] = 'Username';
$handler->display->display_options['filters']['uid_1']['expose']['operator'] = 'uid_1_op';
$handler->display->display_options['filters']['uid_1']['expose']['identifier'] = 'name';
/* Filter criterion: User: E-mail */
$handler->display->display_options['filters']['mail']['id'] = 'mail';
$handler->display->display_options['filters']['mail']['table'] = 'users';
$handler->display->display_options['filters']['mail']['field'] = 'mail';
$handler->display->display_options['filters']['mail']['operator'] = 'contains';
$handler->display->display_options['filters']['mail']['exposed'] = TRUE;
$handler->display->display_options['filters']['mail']['expose']['operator_id'] = 'mail_op';
$handler->display->display_options['filters']['mail']['expose']['label'] = 'E-mail';
$handler->display->display_options['filters']['mail']['expose']['operator'] = 'mail_op';
$handler->display->display_options['filters']['mail']['expose']['identifier'] = 'mail';

/* Display: User Admin */
$handler = $view->new_display('page', 'User Admin', 'page_1');
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['path'] = 'admin/dashboard/users';
$handler->display->display_options['menu']['type'] = 'tab';
$handler->display->display_options['menu']['title'] = 'User Accounts';
$handler->display->display_options['menu']['weight'] = '-14';

```

---
Tags: 7, users, views
---


# Question
Title: 'Create Node' form as part of panelized page
How can I add 'create node' to a panelized page? I basically want to have the 'create x CT' form at the top, with a view of submitted nodes below. What's the best way to achieve this with panels? thanks

# Answer
> 0 votes
You have to add a Context **Node add form** to your panel and afterwards, you can select the appropriate edit form in the 'Form' section when you add content to the panel.

---
Tags: panels
---


title: Menu doesn't link to alias URL

text:
# Question
Title: Menu doesn't link to alias URL
I'm having difficulty on a fresh Drupal installation getting the menu to use an alias (let's say "foo") rather than "node/#" link. The alias works when I type it straight into my browser. When creating the menu, I specified the alias (foo) but it automatically applies the system path to it.

The message that comes up is:

```
The menu system stores system paths only, but will use the URL alias for display. home has been stored as node/1

```

This doesn't come up as an error, rather just an information dialogue.

For this installation I did a minimal install as I wanted it to be a fairly simple website. I've never done this before so there were a few modules I had to enable to get it working how I wanted. I'm thinking maybe there's a module or menu setting that isn't enabled by default using the minimal install.

I'm not using any language packs, and none of the solutions on the following questions were successful (most revolve around languages.)

# Answer
> 2 votes
You can use Pathauto and Global Redirect Module.

# Answer
> 0 votes
I guess you need pathauto module.

# Answer
> 0 votes
You could use the Pathauto module for this.

> The Pathauto module automatically generates URL/path aliases for various kinds of content (nodes, taxonomy terms, users) without requiring the user to manually specify the path alias. This allows you to have URL aliases like /category/my-node-title instead of /node/123. The aliases are based upon a "pattern" system that uses tokens which the administrator can change.

For more detail about this module you could read the READMe.txt of this module.

---
Tags: routes, path-aliases
---


# Question
Title: Drupal Commerce Line Item temporary delete?
I need to temporarily remove a few line items from an order. I can remove them well enough, but they won't add back. There aren't any error messages in watchdog, the error log, or on screen.

Here is the code I have currently:

```
$orderWrapper = entity_metadata_wrapper('commerce_order', $order);
$removedLineItems = array();

// Loop over each line item on the order.
foreach ($orderWrapper->commerce_line_items as $delta => $lineItemWrapper)
{
  $product = $lineItemWrapper->commerce_product->value(); // Get id to pass to line_item_delete

  if ($product->some_field[LANGUAGE_NONE][0]['value'] !== 'some condition')
  {
    $lineItem = commerce_line_item_load($lineItemWrapper->getIdentifier());
    $removedLineItems[] = $lineItem;

    commerce_line_item_delete($lineItemWrapper->getIdentifier());
    unset($orderWrapper->commerce_line_items[$delta]);
  }
}
commerce_order_save($order);

// Run some other code on $order
somePlugin_someFunc($order);

// Add back items removed for package calculation
if (count($removedLineItems) > 0)
{
  foreach ($removedLineItems as $lineItem)
  {
    commerce_line_item_save($lineItem);

    $orderWrapper->commerce_line_items[] = $lineItem;
  }

  commerce_order_save($order);
}

```

Anyone have an alterative to the above?

# Answer
Turned out the issue was simpler than I thought. If you think about the field between line\_items and orders as a reference, it makes sense to just remove that reference, save the order, than re-add it later. I assume the issue was arising that Drupal didn't like deleting than recreating the exact same line\_item, so if it isn't ever deleted, than the reference can just be updated.
> 0 votes

---
Tags: commerce, entities
---


title: Set a date field by rules

text:
# Question
Title: Set a date field by rules
I have a problem that has been discussed a lot, but I still fail at dealing with it.
I need to *get* and *set* the the value of the field by Rules. I put my conditions allright, then I define "Set a data value" as a desired action. At this point, the direct input is disabled, I can only point to another field (as far as I can understand): "switch to direct input mode" is disabled (does not appear, in fact).
Now,I've seen a number of discussions related to the issue. It seems to be related to the way the *Date* module handles things.

The issue seems widely discussed: Date module:
https://drupal.org/node/1431952 (Date field will only set in Rules if it already has a value)
https://drupal.org/node/1153766 (provide a property setter callback)
Rules Module:
https://drupal.org/node/1611666 (Action "Set a data value" is not working for date field)

There are also more general guides
Drupal 7, Rules, Convert text to date and set a date field (as setting the date supposedly works for timestamps)

While most of the problems seem solved, I can't achieve the simple (I assumed) goal I want to get to. Can anybody explain how to connect the pieces of information and make it work as intended?

# Answer
The patch from https://drupal.org/comment/8195767#comment-8195767 seems to solve the problem.
> 0 votes

---
Tags: rules, datetime
---


# Question
Title: The most efficient way to query the user table and custom profile info based on UID
I am trying to grab a specific users profile info + custom profile fields `WHERE uid = X`, I have used the views module currently and copied that sql however that creates a massive query. I was wondering if there is a better way to query Drupal 6 other than views to grab the UID, name, email, + my custom fields?

`SELECT profile_values_firstname.value AS profile_values_firstname_value,
profile_values_firstname.uid AS profile_values_firstname_uid,
profile_values_surname.value AS profile_values_surname_value,
profile_values_surname.uid AS profile_values_surname_uid,
profile_values_telnumber.value AS profile_values_telnumber_value,
profile_values_telnumber.uid AS profile_values_telnumber_uid,
users.mail AS users_mail,
users.uid AS users_uid,
users.access AS users_access,
users.name AS users_name
FROM node node
 INNER JOIN users users ON node.uid = users.uid
LEFT JOIN profile_values profile_values_firstname ON users.uid = profile_values_firstname.uid AND profile_values_firstname.fid = '1'
LEFT JOIN profile_values profile_values_surname ON users.uid = profile_values_surname.uid AND profile_values_surname.fid = '2'
LEFT JOIN profile_values profile_values_telnumber ON users.uid = profile_values_telnumber.uid AND profile_values_telnumber.fid = '3'`

# Answer
> 1 votes
There are a few ways your query can be improved. First, there were some multiple queries for the user's id which I removed. Second, your query was selecting from the node table and then inner joining with the users table which can cause some undesired results (e.g. only users who have created content on your site will show up) and it is also less performant.

Here's the improved query. Since all profile values are stored within the same table using a 'fid' field id to differentiate them one has to do an inner join for each value that you want to select. Hence the query has to be a little longer than one would hope.

> SELECT profile\_values\_firstname.value AS profile\_values\_firstname\_value, profile\_values\_surname.value AS profile\_values\_surname\_value, profile\_values\_telnumber.value AS profile\_values\_telnumber\_value, users.mail AS users\_mail, users.uid AS users\_uid, users.access AS users\_access, users.name AS users\_name FROM users users LEFT JOIN profile\_values profile\_values\_firstname ON users.uid = profile\_values\_firstname.uid AND profile\_values\_firstname.fid = '1' LEFT JOIN profile\_values profile\_values\_surname ON users.uid = profile\_values\_surname.uid AND profile\_values\_surname.fid = '2' LEFT JOIN profile\_values profile\_values\_telnumber ON users.uid = profile\_values\_telnumber.uid AND profile\_values\_telnumber.fid = '3'

---
Tags: views, users, database
---


title: Show new Flag's with views

text:
# Question
Title: Show new Flag's with views
is it possible to get the amount of "new flags" in views? Like the "new comments" field. For example a user's article was flagged 2 times. After his login he should see in a view: "2 new flaggs on your article".

Drupal 7; Views 3; Flag 7.x-3.2

thanks for ur help! lolhonk

# Answer
So add relationship "your\_flag"

and in **Sort criteria** delete default **Content: Post date (desc)**

and add Flags: **Flagged time**

PS maybe i don't understand you, why you need in views this show? not in teaser node?
> 1 votes

---
Tags: views, flags
---


title: Price comparison website

text:
# Question
Title: Price comparison website
I have two sets of taxonomy lists

* Engine Codes
* Vehicle Make and model

Now I'd like to link the two taxonomy terms from different lists/vocabs e.g.

Nissan Skyline R33 GTR (Vehicle make and model) - - - \> RB26DETT (engine code) RB26DETT (engine code) --\> Nissan Skyline R33 GTR (Vehicle make and model)

I'd like to do this without having to manually input it twice. In some cases the same vehicle may have different engine codes, and visa versa.

So If I look at the Taxonomy term page for Nissan Skyline R33 GTR, it lists the RB26DETT and visa - versa.

I'm not sure (i) which module to use, and (ii) whether I should use term reference, or entity reference.

I'm new to this and learning so appreciate any help/advice!

Thanks Shah

# Answer
While I don't have the detailed steps, I suggest you look to the Views module. The relationships and/or contextual filters provide WHERE and FROM type SQL queries.

If you have two views, one based on each vocabulary (taxonomy lists), and each has a contextual filter (with block settings to show only on specific page) then you will get a correlated listing on page/block sets.

If you have troubles getting it going, try exposed filters and AJAX refresh options - Get close enough to help your users help themselves. From a marketing angle, even if automatic/ideal results aren't automatic yet, IF views exposed filters get your customers/staff/partners to answers within 60 seconds from only a click or two, AND they also see message/indication you are actively working on the automatic results, the anticipated "better" site will up their anticipation and your reputation with most people (if, of course, presented with care).

Alternate possible "maybe" modules are "Views Field View" or "EVA". The "Better Exposed Filters" module might also be handy.

Try a search inurl:tutorial-6-10-views-relationships-and-contextual-filter for a great video.

Good luck.
> 0 votes

---
Tags: entities, taxonomy-terms
---


# Question
Title: Page always takes at least 30 seconds to load
I have a site set up on Godaddy and a constant frustration is that it always takes at least 30 seconds to load. Total time for queries was under 200ms. I decided to write the following script:

```
function getmillisecs() {
   list($usec, $sec) = explode (' ', microtime());
   return (double) $sec + $usec;
}

$start = getmillisecs();

define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$end = getmillisecs();

$result = $end - $start;

echo round($result * 1000, 3);

```

All it does is output how much time passes between the start and end of the script. The time I got was 30521.649ms. Taking out everything related to Drupal dropped the time to 0.089ms. What is causing the huge delay? Thanks.

# Answer
> 1 votes
It could be several things:

* Views executing sql queries that have performance problems.
* Cache problems (Do you have enabled the Drupal's cache?).
* (If you have a VPS) maybe the server that you are sharing is under heavy load.
* (If your site is integrated with web services) maybe the web service is having performance problems or connection problems.

Try to check the logs of the site to see is there are errors or anything that could be related to this problem.

Another alternative is to use a profiler like Xhprof (there is a module for drupal) or XDebug.

Could you share with us the url of the website?

---
Tags: 7
---


# Question
Title: Whats causing Drupal to freeze when creating/editing a mini-panel?
I'm quite new to drupal.

Drupal has been freezing for me when I try and create or sometimes edit a minipanel. Once I select the panel layout and start adding content it just remains in the lightbox 'grayed' state and wont let me click or do anything. It's almost like it's trying to load but I've left it for an hour and it's completely frozen.

I've tried on Firefox and IE10 and get same issue. Also upgraded my drupal from 7.23 to 7.24 today so a completely new core is running but still hangs like this.

I haven't fully explored everything yet in drupal so I don't know if other sections will do this. So far it's just the minipanels section.

Does anyone have any suggestions? Thanks.

# Answer
> 1 votes
By the description of your problem, it seems to being caused by a Javascript error.

Try to check with Chrome DevTools, Firebug or the debug tool of your preference on the browser, go to "Console" tab and look for Javascripts errors or maybe on the "Network" panel to check for XHR (ajax) problems.

---
Tags: javascript, panels, performance
---


# Question
Title: How to make download file link to open form and mail the download link to email?
**My flow is like that.**

1. I have scroll-able list of download links for Private files.
2. When user click on Download File link it will show Form to gather some data like first\_name, last\_name, email and Phone.
3. after submission Link will be forward to email Id specified in form with KEY will check Once download the file link will be expire.
4. Second Mail goes to admin and Data will be stored to system as Sales Lead.
5. File will be get to User.

I have created Views to List all the Files as a Block and Link added to download file using yourdomain.com/get/file/1

Is there any suggestion for that or specific module tutorial available so, I can check...

# Answer
> 1 votes
There is simple solution for this.

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

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

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

---
Tags: views, 7, files
---


# Question
Title: How to provide pagename.tpl.php to specific page?
I have basic knowledge of Drupal ,I know that if I am giving page name with .tpl.php file taht directly apply to that specific page .but to apply that I don't know so can you please help me ?

# Answer
> 2 votes
copy this code to template.php (donot forget to change the **yourtheme** name)

```
function yourtheme_preprocess_page(&$vars) {
  // Do we have a node?
  if (isset($vars['node'])) {

    // Ref suggestions cuz it's stupid long.
    $suggests = &$vars['theme_hook_suggestions'];

    // Get path arguments.
    $args = arg();
    // Remove first argument of "node".
    unset($args[0]);

    // Set type.
    $type = "page__type_{$vars['node']->type}";

    // Bring it all together.
    $suggests = array_merge(
      $suggests,
      array($type),
      theme_get_suggestions($args, $type)
    );

    // if the url is: 'http://domain.com/node/123/edit'
    // and node type is 'blog'..
    //
    // This will be the suggestions:
    //
    // - page__node
    // - page__node__%
    // - page__node__123
    // - page__node__edit
    // - page__type_blog
    // - page__type_blog__%
    // - page__type_blog__123
    // - page__type_blog__edit
    //
    // Which connects to these templates:
    //
    // - page--node.tpl.php
    // - page--node--%.tpl.php
    // - page--node--123.tpl.php
    // - page--node--edit.tpl.php
    // - page--type-blog.tpl.php          << this is what you want.
    // - page--type-blog--%.tpl.php
    // - page--type-blog--123.tpl.php
    // - page--type-blog--edit.tpl.php
    //
    // Latter items take precedence.
  }
}

```

all examples are inside the comment which format you should follow in side the template folder for creating tpl.php '%' is use for all, best of luck, note : don't forget to clear the cache you can use devel\_themer module for specific suggestions of tpl's.

---
Tags: 7
---


# Question
Title: Access to admin/people/create is DISABLED
I am using Drupal 7.24. After I disabled these modules `Checklist API, Connector and Features`. I got this message `Access to admin/people/create is DISABLED.`. And when I go to admin/peope/create, the email and password fields are pre-filled with user 1 email and password. How can I resolve this issue. Are the modules I just disabled related with this issue?

Anyone please help me resolve this issue.

Thanks.

# Answer
> 0 votes
The pre-filled is because your cache browser and properly you check `admin/people/create` by no `user=1` . There are 2 please to effect registration
one :
`admin/config/people/accounts`
**Registration and cancellation**
Who can register accounts?

* Administrators only
* Visitors
* Visitors, but administrator approval is required

and anther in `admin/people/permissions`

**User**
`Administer permissions` Warning: Give to trusted roles only; this permission has security implications.

`Administer users`
Warning: Give to trusted roles only; this permission has security implications.

.

check 2 this place and make sure you select correct(according you application ) and correct permission. your problem not dependency on module disabling :)

---
Tags: users
---


# Question
Title: How do I make changes to the user registration function?
Just to clarify: I don't mean customizing the registration page. I've already managed to customize it to display what I want. What I'd like to know is if it's possible to make any changes to the function that inserts the info to the database after the user submits the form. The site I'm working on has a phpbb3 forum and I'm looking for a way to get a user registered in both after registering in the main site. I'm aware of the phpBB SSO module but that handles signing in, not registration. Also, I haven't been able to get phpBB SSO to work, either. Thanks.

I'm using phpBB3 instead of Drupal's Forum module because this is a migration from an already existing site that used phpbb. The client wants it this way and getting everything to look and function like their original site would take too long.

# Answer
You can use

`hook_user_insert`

to add additional code to the new user account creation process.

More information on the User API
> 1 votes

# Answer
Apart from David's solutions, you can implements `hook_form_alter` hook in your custom module.

```
    /**
     * Implements hook_form_alter()
     */
    function custom_feature_form_alter(&$form, &$form_state, $form_id) {

    //dpm($form_id); to check form id

      if ($form_id == "registration-form-id") {

        // $form['#validate'][] = 'custom_feature_profile_validate';
        $form['#submit'][] = 'custom_feature_profile_submit';

      }
    }

    function custom_feature_profile_submit($form, $form_state) {

    dpm($form_state['values']);
//your code

    }

```

Kindly see that `registration-form-id` is id of `user registration form`.
> 0 votes

---
Tags: 7, users
---


# Question
Title: Detecting a form change. Is jQuery the way to go?
I have got a form with quite a lot of checkboxes (can go up to the 100's) in a table and I would like to detect if a checkbox has been clicked by the user. If they have, I would like to automatically display a warning in the form informing the user that they need to save the form if they want the changes to take effect. Similar to how the draggable tables in Drupal work. Anytime, a form element changes, then, show a warning.

My question is, will using jQuery to attach a change event on each checkbox take a major performance-hit? Is there a faster Drupal way to do it? Will using the Drupal way, make performance faster?

# Answer
> Will using jQuery to attach a change event on each checkbox take a major performance-hit?

Probably, but it depends on the client's configuration. I have a form with around 3 hundred of controls, half of them hidden, some of them auto-copying content using jQuery, and sometimes FireFox has it's problems with it.

> Is there a faster Drupal way to do it?

Nope, Drupal way is to use Behaviors, or states, and **Behaviors & states thou shalt use**... but they are merely Drupal's way to initiate jQuery-based code.

> Will using the Drupal way, make performance faster?

Nope, as Drupal way is basically jQuery way too. But it will *merely* allow you to be reasonably sure that other modules will not interfere with your code (without any significant slowdown).
> 2 votes

---
Tags: javascript, forms
---


# Question
Title: Media queries only applied for authenticated users
i'm working on a responsive theme using compass / susy, and i had issues on application of media queries.For example, images weren't responsive on mobile, or weren't on full size for desktop. i did test on different browser and the only one that work were one for connected user.so i did connect me under others browser and media queries were applied. so what can i do to fix this uge problem ?

thanks

# Answer
> 1 votes
As Molot commented it is just a cache problem. You need to clear your browser cache to get the updated css. Another trick that works for me is to add a query string in the URL (e.g `http://example.com/node/test?awy`). You may need to turn off the css aggregation under `Performance` page to make sure that you will get the updated css and not the cached copy.

You can use Drush to clear your cache by using `drush cc all`.

---
Tags: theming
---


# Question
Title: ul list with ajax items is not build correctly
I have an ul list, which is build with default items, depending on a dropdown value. When I change the dropdown, the area with the ul should be replaced by ajax with new items depending on the selected dropdown value. The problem is: After replacing the div with the ul inside, the ul tag is opened and closed immediately, the li items are generated directly after the ul closing tag. Here is some sample code:

```
 $drop_value=isset($form_state['values']['dropdown'])?$form_state['values']['dropdown']:$default_value;
 $form['images']['drop_area'] = array(
  '#markup' => '
    <div class="ui-widget ui-helper-clearfix">
      <div id="newloc" class="ui-widget-content ui-state-default">
        <ul id="newloclist_ul" class="itemlist ui-helper-reset ui-helper-clearfix"/>
        '.get_items($drop_value).'
        </ul>
      </div>
    </div>',
  '#prefix' => '<div id="drop_area">',
  '#suffix' => '</div>',
);
function get_items($drop) {
  ...
  //builds li elements
  return $li_elements;
}

```

The ajax event is assigned to the dropdown. The output is correct after loading the page with the $default\_value. After changing the dropdown, the li elements are generated correctly, but the resulting html looks like this:

```
<ul id="newloclist_ul" class="itemlist ui-helper-reset ui-helper-clearfix"></ul>
<li class="ui-widget-content ui-corner-all">item</li>
...

```

Why do the li elements are generated outside the ul, although the function for generating the items is called inside the ul markup? I also tried to declare a variable before the markup, holding the result of the get\_items function, but this has the same effect...

Thx.

# Answer
> 2 votes
```
$drop_value=isset($form_state['values']['dropdown'])?$form_state['values']['dropdown']:$default_value;
$form['images']['drop_area'] = array(
'#markup' => '
<div class="ui-widget ui-helper-clearfix">
  <div id="newloc" class="ui-widget-content ui-state-default">
    <ul id="newloclist_ul" class="itemlist ui-helper-reset ui-helper-clearfix"/>
    '.get_items($drop_value).'
    </ul>
  </div>
</div>',
'#prefix' => '<div id="drop_area">',
'#suffix' => '</div>',
);
function get_items($drop) {
  ...
  //builds li elements
  return $li_elements;
}

```

In your above code try after remove the "**/**" at the end of **ul** tag.

Then your code should be :

```
<ul id="newloclist_ul" class="itemlist ui-helper-reset ui-helper-clearfix">

```

---
Tags: forms, ajax
---


title: How can I reset my password in drupal7

text:
# Question
Title: How can I reset my password in drupal7
I am new to Drupal and this forum.

My problem is that I want to reset my password in Drupal without logging onto my site, but I can only access user/password when I'm logged in.

I've searched a lot and haven't been able to find anything else.

Can anyone help me out?

# Answer
If you have drush installed, you can reset your password from the command line using

```
drush upwd --password="givememypasswordback" admin

```

For more information you could see the link.
> 6 votes

# Answer
You have several ways to achieve this:

* Visit *yousite.com/user/password* then enter your email address and you'll then receive an email with a link to reset your password on your Drupal site.
* With drush, you have two different ways of doing things:

```
$ drush uli --uid=1 --uri=http://yoursite.com

```

This command will return a URL that will allow you to log in to the site without actually knowing your admin password. Handy.

* Or as previously suggested by @Nitesh Sethia, using drush, again, to reset your admin password:

```
$ drush upwd <username> --password="<newpassword>"

```
* Another interesting option is to use the password-hash.sh script that ships with Drupal. At the root of your Drupal codebase, type:

```
$ ./scripts/password-hash.sh <newpassword>

```

This will return a hash with the SHA 512 security. Copy that hash, now log in to your MySQL prompt or via phpMyAdmin (or whatever other GUI of your choice). Select the "users" table and update your admin account by replacing the "pass" hash by your newly generated one. Save. Done. Assuming you'll go for the MySQL prompt and will want to reset UID 1 (superuser) password, run:

```
    mysql > UPDATE `<yourdatabase>`.`users` SET `pass` = '<yourhash>' WHERE `users`.`uid` = 1;

```

**Last option that I wouldn't recommend** is to temporarily hack your `index.php` file so that, under `drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);` you add:

```
    require_once 'includes/password.inc';
    echo user_hash_password('<newpassword>');
    die();

```

Now hit the homepage, copy the hash, and update the "pass" field in the database as explained previously. Revert the changes in `index.php`. Done.
> 2 votes

---
Tags: users
---


# Question
Title: How can I hide exposed filter control if the filter is not applicable to existing views results?
I have created a view with three exposed filters. Now I have to hide these Fields dynamically - if field is not present in any of the content types of the nodes in current result, filter based on this field should not be visible. I am using Drupal 7.

# Answer
> 0 votes
You have to create a small module or add a function into template.php where you use a one of the hook alter functions. You test your view results for a given set, and if you at that result don't need the filter you unset it. Probably the best hook is: hook\_views\_pre\_render.

"https://api.drupal.org/api/views/views.api.php/group/views\_hooks/7"

Check out the comments on the hook\_views\_pre\_render function to get an idea of how to use it. Hope this gets you on your feet.

---
Tags: views
---


# Question
Title: Advices for tunning my server for better performance and scalability
I am working on a web application which will primarily be used by authenticated users. The web application imports records from CSV files using the Feeds module, MongoDB was chosen to store this data because it is much faster to do the writes rather than in MySQL. The application is importing thousands of records every day really fast. The records are referenced to the users and when they log in, they can consult their information. The application is also used as an API for the mobile app.

I have a 17gb AWS EC2 Instance as the server.

Varnish is install working perfectly serving content for anonymous users. I'm getting around 3000-4000 requests per second which is more than enough.

My problem is when benchmarking for authenticated users, on API pages that are only json content I get only 24 requests per second. And other pages I get like 9 - 11 requests per second. Here is some apache benchmark output.

```
Concurrency Level:      100
Time taken for tests:   9.154 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      1790900 bytes
HTML transferred:       1731600 bytes
Requests per second:    10.92 [#/sec] (mean)
Time per request:       9154.469 [ms] (mean)
Time per request:       91.545 [ms] (mean, across all concurrent requests)
Transfer rate:          191.05 [Kbytes/sec] received

```

Memcache is installed, using memcache\_storage module, for some reason I got slightly higher requests per second using this module rather than memcache. 4Gb are set as Memcache cache. Here is some Memcache statistics output.

```
Cache Information
Current Items(total)    10730 (95109)
Hits    644064
Misses  74324
Request Rate (hits, misses) 1.44 cache requests/second
Hit Rate    1.29 cache requests/second
Miss Rate   0.15 cache requests/second
Set Rate    0.19 cache requests/second

```

APC is also installed, working perfectly.

I don't have many modules installed:

CORE

block, field, field sql storage, field UI, file, filter, image, list, locale, menu, node, number, options, path, system, taxonomy, text, user,

CONTRIB

content access, varnish, ctools, eck, feeds, feeds ui, feeds tamper, feeds tamper ui, email, field permissions, hsm field, node reference, references, user reference, jquery update, mongodb, mongodb storage, mongodb watchdog, entity api, disable messages, image url formatter, job scheduler, libraries, quicktabs, quicktabs styles, apc, eck entitycache, entitycache, memcache storage, services, rest server, entityfieldquery views, views, views json, and views ui.

As for the Devel output, usually I get something like this. (This output was after I refresh the page)

```
Executed 57 queries in 10.79 ms. Queries exceeding 5 ms are highlighted. Page execution time was 167.27 ms. Memory used at: devel_boot()=1.36 MB, devel_shutdown()=13.96 MB, PHP peak=14.25 MB.

```

\_drupal\_session\_write query is always the longest, it never executes in less than 8 ms, and sometimes it reaches 500 ms like in the output below.

```
Executed 57 queries in 607.49 ms. Queries exceeding 5 ms are highlighted. Page execution time was 2395.87 ms. Memory used at: devel_boot()=1.36 MB, devel_shutdown()=13.96 MB, PHP peak=14.25 MB.

```

These are my PHP settings in settings.php

```
/**
 *MongDB configuration
 */
 $conf['mongodb_connections'] = array(
   // Connection name/alias
   'default' => array(
     // Omit USER:PASS@ if Mongo isn't configured to use authentication.
    'host' => 'mongodb://localhost',
     // Database name
     'db' => 'mydb',
   ),
 );
 $conf['mongodb_watchdog'] = 'mydb_logs';
 $conf['field_storage_default'] = 'mongodb_field_storage';

/**
 *Memcached
 */
$conf['cache_backends'][] = 'sites/all/modules/memcache_storage/memcache_storage.inc';
$conf['cache_default_class'] = 'MemcacheStorage';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['session_inc'] = 'sites/all/modules/memcache_storage/includes/session.inc';
$conf['lock_inc'] = 'sites/all/modules/memcache_storage/includes/lock.inc';

/**
 *Varnish
 */
$conf['cache_backends'][] = 'sites/all/modules/varnish/varnish.cache.inc';
$conf['cache_class_cache_page'] = 'VarnishCache';

/**
 * Add APC Caching.
 */
$conf['cache_backends'][] = 'sites/all/modules/apc/drupal_apc_cache.inc';
$conf['cache_class_cache'] = 'DrupalAPCCache';
$conf['cache_class_cache_bootstrap'] = 'DrupalAPCCache';

```

Configurations in my.cnf file.

```
key_buffer_size = 12M

query_cache_size = 32M

query_cache_limit = 2M

query_cache_type = 1

# InnoDB caches.
innodb_buffer_pool_size = 500M
innodb_flush_method = O_DIRECT

max_connections = 75

table_cache = 96

sort_buffer_size = 12M

tmp_table_size = 12M

```

I really feel lost at this moment, I have read numerous articles about performance and scalability and I feel like I've done most of the things that are mentioned, but don't seem to work at all. I'm stressed because I feel like the server will crash really fast with this numbers. I hope someone can give me advices.

Kind regards.

# Answer
I think you didn't have any answer yet because your question is way too specific. I would advise you break it down into several precise questions so that you can get...well, precise answers. There's no way someone can provide a perfect answer here.

But let's try and start helping you a bit.

* Since your application will be primarily used by authenticated users and this is where you've noticed performance troubles, I'd suggest you don't focus on Varnish at all for the time being.
* Benchmarking with Apache AB hasn't been the most reliable load testing tool in my experience. I would recommend Apache jMeter instead, and, if you can afford it, try and get a world-class Cloud load testing provider such as Soasta, or, for a less expensive option, try Blitz.io.
* **MongoDB**: you should try and search for answers on StackOverflow directly where you can get ahold of experienced MongoDB folks there and ask new questions if needed.
    + Note that you'll not find much experience with MongoDB in the Drupal community. I know that there's at least one major site using it for fields storage (examiner.com) but this also requires a pretty deep expertise and is prone to giving you troubles maintaining it in the long run. I'd thus question this whole decision and would step back a little to determine if going with MySQL instead would truly be a bottleneck or if it would simply be slower, but acceptable, still. Smaller batch imports are usually the solution to most Feeds performance issues.
    + Note also that @chx is pretty heavily involved with MongoDB development for Drupal. You'll find 20+ "Drupal 8 progress from my / MongoDB perspective" blog posts on his site.
    + Pretty sure you know about the https://drupal.org/project/mongodb module, but just in case, here you go :-)
* **Memcache Storage** isn't necessarily the best option. There's been a pretty heated discussion at https://drupal.org/node/2060753 where you'll be able to see that it might be better to fix the main Memcache project rather to try and go with a competing module that is highly unlikely to get the same level of community work than memcache. Also, performance benefits have been widely discussed as the benchmarking methodology used is debatable.

My main advice to you is: keep things simple, remove as many layers of complexity as you can, and start from there. Use the https://drupal.org/project/memory\_profiler module to know what pages are very slow, or go to the next level with XHprof profiling (there's a module for that!)
> 1 votes

---
Tags: 7, caching, performance
---


title: Printmail Form inside Colorbox

text:
# Question
Title: Printmail Form inside Colorbox
I am actually trying to load the printmail form inside a colorbox. But when I am trying to build up a link like this:

```
<a href="/pages/demo/printmail/64?width=500&height=500" class="colorbox-load init-colorbox-load-processed cboxElement">Send as email</a>

```

The colorbox opens, but returns **"This content failed to load."** Someone got an idea how to workaround that?

# Answer
You should use the `colorbox-node` instead of `colorbox-load` First check have you already installed the Colorbox and the Colorbox Node modules.

Then, your link would be similar to the following one.

```
<a href="/pages/demo/printmail/64?width=500&height=500" class="colorbox-node">Als E-Mail versenden</a>

```
> 0 votes

---
Tags: javascript
---


title: Posts of a taxonomy term in views block

text:
# Question
Title: Posts of a taxonomy term in views block
I have created a Taxonomy vocabulary called "Model" that has some Term like: `Beautiful - Cool - Cute - Awesome` so-forth.
Now, i want to show most recent 6 posts under "Beautiful" term from "Model" vocabulary using a views block. But can't understand how to build the views block. I came through this many Q like this

but cant understand how to make a views block to show recent 6 posts under "Beautiful" term from "Model" vocabulary using a views block? Any idea? Thanks

# Answer
Create a view and then under display configuration settings set **Items to display** = 6 and also select **sorted by** as **Newest First**. Then go to Filter Criteria and add filter **Content: Has taxonomy term** Then select term "**Beautiful**" Then add a new block display to the view and save. Refer the images below.

**Step 1:**

**Step 2:**

**Step 3:**

**Step 4:**

**Step 5:**
> 2 votes

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


# Question
Title: combining two taxonomy fields into one exposed filter dropdown
I have created two `taxonomy` fields (`home team` and `away team`) with a content type.

I have created a `views` to display the list content of content type. In view, I have added `taxonomy` filter for `home team` and `away team` which is showing two `taxonomy` filter in the views page.

I would like to combine both `taxonomy` filter into single exposed filter.

# Answer
> 0 votes
Create only one taxonomy vocabulary like **Team Type**. Then add

> **home team** and **away team**

as terms in that vocabulary. Then add the new vocabulary as filter in view.

**OR**

Otherwise use form alter, then alter the dropdown field in the exposed for and set the options in the select field manullay.

Refer this: How to alter filter in exposed filters form trough form\_alter hook

# Answer
> 1 votes
You can follow this using below step:

* Go to Administration -\> Structure -\> Views
* Edit your existing view or create new new.
* Add Filter for `taxonomy` for 'home' and 'away'
* Click on "Rearrange" filter icon in Filter section
* Click on "Create new filter group" and move filter "Home taxonomy" and "Away taxonomy" in new filter group.
* Select Operator as "Or" in new filter group and save the form.

---
Tags: views
---


title: drupal notification for content type

text:
# Question
Title: drupal notification for content type
I have a requirement to allow users to subscribe content type. When a new node of the subscribed content type is created, notification mail must be sent. I tried notify module but it only allows to subscribe while registration.

Is there any solution for unsigned users to subscribe a content type?

# Answer
I'd try to create a rule that's fired when new content is added and when a user is subscribed to it (check this with a condition). Use the 'Send email' action to send an email to the subscribed users.
> 1 votes

---
Tags: notifications, emails
---


title: Rate Widget Search API integration

text:
# Question
Title: Rate Widget Search API integration
I have a view for search results.

I want to add the "rating" widget, but I cant find a way how to include it in the Search API fields. =\> The views cant make the relationship. Is it possible ?

Clarification: The view is not the "ordinary" type -\> displaying contents, but it is displaying "Search index". I am able to display fields that are defined by the Search API settings page, but I am unable to add relationships, for example Rate Widget (Vote Results module).

As a solution, I embedded another view as a field. That seems to work, but I am asking if there is another approach out there.

# Answer
> 0 votes
The answer is: you cannot do it in other way, because the view entity is search\_api type.

---
Tags: search, rating, views
---


# Question
Title: Is there a way to get Drush to download all required dependancies for a specific module?
For example if you perform the following commands:

```
drush dl views
drush en views views_ui views_export

```

You will get the the following error when trying to enable the views modules:

> Module views cannot be enabled because it depends on the following modules which could not be found: ctools

Is there a way to get drush to download required module dependancies?

# Answer
> 18 votes
*Drush 5 and up:*

Newer versions of Drush (version 5 and higher) will ask you if you want to download the required dependencies when you enable (`drush en`) a module. It will also ask if you want to download the module itself if you didn't download it yet. Combined with the "-y" option (e.g. `drush en views -y`), everything will be downloaded and enabled automatically without asking further questions.

Note that the automatic downloading of dependencies may fail if the required module's name is not the same as its project name on drupal.org. For more info, see the my original answer for Drush 4 below.

*Original answer (Drush 4):*

No, there is no way to do that. The problem is that there is a difference between a module and a project. Often (but not always) the name of the project is identical to the module (or one of the modules) contained in the project. A single project (eg. Views) can contain multiple modules (views, views\_ui, views\_export). While `drush dl` downloads a *project*, `drush en` enables a *module*.

When a module declares dependencies, it declares dependencies on modules, not projects. When performing a `drush en`, Drush can check if the required module is available. However if it's not available, Drush has no way of knowing which project to download. For Drush to be able to automatically download required projects, work needs to be done in the underlying projects/modules infrastructure, so Drush can retrieve a mapping of projects and modules. See also Smarter handling of missing dependencies.

# Answer
> 9 votes
Actually, drush5 (still in development) has a map of known, common dependencies (content.module, ctools, ...). So it does indeed download ctools for you in your example.

# Answer
> 6 votes
this is not anymore a problem since latest versions of drush does this "automagically":

```
The following projects have unmet dependencies:[ok]
answers requires strongarm, references, nodereference_url, nodereference_count, eva
Would you like to download them? (y/n):

```

# Answer
> 2 votes
Some modules, or projects include a **drush make** script, which can download dependencies and install external libraries.

However This is mostly not the case, and there are issues with nesting of drush make scripts. It is still worth looking out for with some of the modules which are more complicated to set up.

# Answer
> 2 votes
Try the Quick update module. It will download all missing dependency projects for you.

Here is a quote about it (from the module's project page):

> ... provides a quick way to batch install multiple new projects or all the missing dependency projects.
>
> Drupal core provides a way to install module or theme one by one, but you can install multiple projects via the Quick update module. There is an admin UI to search the most installed projects easier.
>
> Additional, Quick update module finds all missing dependency projects for you, then you can just select all of them from the admin UI and install them in a batch process.
>
> The Quick update module depends on the Update module and uses the same workflow as the Update module. Thus, you can run the updates via the admin update page at /admin/reports/updates/update.

---
Tags: drush
---


# Question
Title: Override Commerce Kickstart Features ( and Features Override module error)
I have the Drupal Commerce Kickstart bundle in my project. This bundle contains a bunch of Features. Most of them are overridden now. It's not good to have most of setting inside the DB instead of features, so I want to save my changes inside my features.

As far as I know, it's not a good idea to modify the Kickstart Features, so I tried to use the Features Override module.

But, unfortunately, got "white screen of death" on Feautures Override Tab. Also, it broke all of my Kickstart Features.

The only "evidence" is the message:

> Notice: Array to string conversion in features\_override\_features\_export\_render\_addition()

PHP: 5.4.9 Commerce Kickstart: 7.x-2.9 Features Override: 7.x-2.0-rc1

Do you have any ideas how to fix this problem with Featuers Override, or just how can I move my settings from DB to code in my situation?

# Answer
> 0 votes
I've found that Features Override works nicely in simple scenarios, but I've been unable to get it working in more complex scenarios, such as modifying Drupal Commerce.

One alternative — instead of modifying the Features Components provided by Drupal Commerce — is to **clone them, make your changes to the cloned components, and then featurize the cloned components**.

---
Tags: features, commerce
---


# Question
Title: How to identify disabled fields in form submit handler?
I have a pretty complex form, on which fields are getting enabled and disabled conditionally. I'm using JavaScript to do that without call to server for performance purposes.

How can I not save values from fields that are disabled? Some of the conditions are not entirely based on field values, but also on user's behavior on a form, so it is not possible to simply recreate logic in PHP.

Currently I'm emptying disabled fields before submit, and then testing if `$form_state['values']['field']` is filled and `$form_state['input']['field']` is empty. If so, I assume field also got disabled, as my script does not allow to submit empty enabled fields. This gives me workable approximation of what I need, but prevents me from implementing graceful degradation for no-js clients, so I need a better solution.

# Answer
There's not really enough information in the question to provide a definitive answer but what I'd suggest is:

1. add one or more hidden fields to the form to hold state information
2. store values in the field(s) using javascript when the state of the form changes with user action
3. On the server side, use the value(s) from the hidden field(s) to represent the state of the form so you can employ them in validation logic.
> 1 votes

---
Tags: forms
---


# Question
Title: Drush alias - @alias status could not be found
**Problem**

I'm trying to create a drush alias following the excellent example posted here.

EXAMPLE:

```
$aliases['dev'] = array(
   'root' => '/path/to/drupal',
   'uri' => 'dev.mydrupalsite.com',
 );

```

MINE:

```
<?php
$aliases['main'] = array(
    'root' => '/srv/www/mysite/public',
    'uri' => 'main.mysite.net',
  );
?>

```

According to the example the following two commands are equivalent:

```
 $ drush @dev status
 $ drush --root=/path/to/drupal --uri=dev.mydrupalsite.com status

```

And if I run:

```
$ drush --root=/srv/www/mysite/public --uri=main.mysite.net status

```

I get a full report. But if I run

```
 $ drush @main status

```

I get the error `@main status could not be found`.

The alias file has been discovered, running `drush status` in the drupal root shows it has been found. It's `~/.drush/mysite.net.alias.drushrc.php`. What have I done wrong?

# Answer
The filename pattern `mysite.net.alias.drushrc.php` will only be parsed for aliases named @mysite.net. Rename this file to `mysite.net.aliases.drushrc.php`, and you'll be fine.
> 4 votes

# Answer
Do you have more than one alias? If so, I would recommend you rename the file as `<youralias>.aliases.drushrc.php` . Based on your example, this would give `main.aliases.drushrc.php` \- It doesn't hurt to have only one alias in such file anyway so I would default to `aliases.drushrc.php` every time, just to be on the safe side.

Next, confirm that the site alias is returned when you type:

```
$ drush sa

```

If it's not, clear drush cache to reload all changes:

```
$ drush cc drush

```

If this still doesn't work, run the command with the `--debug` flag and please post the debug log here.
> 3 votes

---
Tags: 7, drush
---


# Question
Title: How to create simple dynamic Views in Drupal 7
I have a Drupal 7 photo gallery that I would like to auto simulate a View to be created once new photo gallery content has been saved/published for it. For instance, I have a content type called "Gallery" with your basic fields: Title, Taxonomy and Image(w/ unlimited values). I want to be able to have a dynamic View fire off and create the new gallery once gallery content has been saved. So this way I don't have to login to create the view manually every time...it would instead pull the necessary unique values for new gallery View from the content: Taxonomy, URL Alias and Title. I'm thinking this is possible to do in some way with Token, Rules, View rules, or VBO. Perhaps even a hook may be necessary? -Thx

# Answer
Ok, after some long researching, I found the solution over here --\> \[l\]Context Filter with Path Alias in URL

Patrick and Stage many thanks, but your explanation indeed you don't have to add a bunch of modules or anything over complicated. Here's what i did: To recap in detail: I added a "Block View". This is important as it WILL NOT WORK in a Page View. I'm not too entirely sure why, but you'll get no results on your pages ...just only on the View preview will it show correctly. Perhaps it's due to the way the url's are created in Views .vs PathAuto. So a Block view here is the way to go.

My contextual filter is as follows:

WHEN THE FILTER VALUE IS NOT AVAILABLE Choose: 'Provide default value' Type: 'Raw value from URL' Path component:'2' Check: 'Use path alias'

WHEN THE FILTER VALUE IS AVAILABLE OR DEFAULT IS PROVIDED Check: 'Override Title'. Add the value of '%1' Check: 'Specify validation criteria' Validator: 'PHP Code' Add the value of: '$handler-\>argument = str\_replace("-"," ",$argument); return true;' then save

\*Plus make sure to add the %1 to the Title of the View as well. Save flush cache and your dynamic gallery will work by unique title!

Minor issues still: \- Need to find a way to remove special characters out of the title field when constructing the URL Validator. e.g. If a user uses "&" in their title name, then it can't create the url correctly. So I need a PHP string condition to handle special characters for instance: 'If !@#$%^&\*():"; then just remove the character'
> 1 votes

# Answer
If you want to create a gallery (album) per taxonomy term, you don't need to create a bunch of new views.

You can just create one view of the taxonomy vocabulary that you want to use to create the albums. Then, as new terms are created, new galleries will automatically be created.

To adjust the way the galleries themselves are displayed, if you're using taxonomy, you can adjust the built-in view for overriding the display of taxonomy terms.
> 0 votes

# Answer
I have something very similar. Dont make things too complicated with too many different modules.

First set up clean url in this format: gallery/{content title}

Create one view with the necessary fields and use the taxonomy filter to separate the different gallery types. Then use contextual filter to display the album from the url.
> 0 votes

---
Tags: views
---


# Question
Title: How To Force Commerce Cart View To Update (Ajax?)
I admit to being a Commerce -novice-. It's getting better, but it's still quite confusing in some spots. I've posted several questions here over the past year trying to skin the same cat in different ways. We have a Drupal 7 cart. The pricing is pulled in from an external web site via http\_request which updates the unit price of all items in the cart on hook\_form\_alter().

The problem is that the -initial- price that displays in the cart is always 0. The user always has hit to refresh the page for that pricing to update the View. Commerce seems to want to pull the unit price in from the Product nodes so after a user hits the cart displays but with a 0 unit price. When they hit -then- our code fires and updates the price.

So... I need is either: a) a way to force that view to 'refresh' when the page is rendered (ie. it initially loads with the zero prices, runs the http\_request code and -then- renders again). Yeah, it's ugly but I'm just sick of this.

b) Figure out a way using the Rules (which I haven't been able to do) to get the line item price to pull in from the http\_request with PHP. This -never- seems to work. It -always- wants to use a rule based on an existing field. If someone could give me a tutorial on how to use PHP with Commerce for the Unit Price I'd buy them a CASE of virtual beer!

c) Figure out a way to assign that http\_request price as the line item price when the user hits the 'Add' button. Again, probably a noob thing, but I cannot figure out how to override the Unit Price for the Line Item to the value I want. It -always- wants to use the Unit Price from the Product node.

ANY help would be most appreciated!

# Answer
> 2 votes
Implement a custom rules action and wire it to rules event *Calculating the sell price of a product*. The sell price of a line item can be forced to any value using the action *Set the unit price to a specific amount*. The missing piece is a custom rule action capable of retrieving the amount. As a starting point I propose the following (assuming the custom module is named *acme*):

```
/**
 * Implements hook_rules_action_info().
 */
function acme_rules_action_info() {
  return array(
    'acme_random_amount' => array(
      'label' => t('Generate random price (with params!)'),
      'group' => t('Examples'),
      'parameter' => array(
        'product_id' => array(
          'type' => 'text',
          'label' => t('Product SKU'),
          'description' => t('The SKU of a product.'),
        ),
        'account' => array(
          'type' => 'user',
          'label' => t('User'),
          'description' => t('A user account.'),
        ),
      ),
      'provides' => array(
        'amount' => array(
          'type' => 'decimal',
          'label' => t('Amount'),
          'description' => 'Return a random numeric amount, except for admin.',
        ),
      ),
    ),
  );
}

/**
 * Rules action: Generate and return random amount of money.
 */
function acme_random_amount($product_id, $account) {
  $amount = mt_rand(100, 1000);

  // Fix price for admin.
  if ($account && $account->uid == 1) {
    $amount = 420;
  }

  // Blue sells, let's boost the revenue.
  if (strpos($product_id, 'BLU') !== FALSE) {
    $amount *= 100;
  }

  return array(
    'amount' => $amount,
  );
}

```

The rule then looks something like this:

```
{ "rules_pick_random_price" : {
    "LABEL" : "Pick random price",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "acme", "commerce_line_item", "commerce_product_reference" ],
    "ON" : [ "commerce_product_calculate_sell_price" ],
    "IF" : [
      { "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "commerce_product" } }
    ],
    "DO" : [
      { "acme_random_amount" : {
          "USING" : {
            "product_id" : [ "commerce-line-item:commerce-product:sku" ],
            "account" : [ "commerce-line-item:order:owner" ]
          },
          "PROVIDE" : { "amount" : { "amount" : "Amount" } }
        }
      },
      { "commerce_line_item_unit_price_amount" : {
          "commerce_line_item" : [ "commerce_line_item" ],
          "amount" : [ "amount" ],
          "component_name" : "base_price",
          "round_mode" : "0"
        }
      },
      { "drupal_message" : { "message" : "Set the price of [commerce-line-item:commerce-product:sku] to amount: [amount:value] for user [commerce-line-item:order:owner:name]" } }
    ]
  }
}

```

Note that in order to get at the product SKU, it is necessary to introduce a condition *Entity has field* checking for the presence of the `commerce_product` field on the `commerce-line-item` variable.

Please keep in mind that this rule will be executed on every page request for every item in the cart. Additionally it is executed whenever an add-to-cart form is displayed. If this is on a high traffic site, you probably need to think about an appropriate caching strategy.

---
Tags: views, commerce
---


# Question
Title: Exportable options for views_plugin_display_extender
I have trouble implementing exportable options (using standard views export) for a views\_display\_extender. The corresponding issue is here: https://drupal.org/node/2128119

From looking at `views_object::export_options()`, it seems to me, that the declaration of option\_definition should be sufficient. But then again looking at `view::export()` I have the impression that only display handlers are called. But I don't really understand what else might get called.

Full code of the sandbox module in question is here: http://drupalcode.org/sandbox/berliner/2087181.git/tree

I would be glad about any solutions, ressources, docs or even smallest hints about this problem. I did an extensive research before posting the issue and as far as I can see from the docs, I did everything needed to make the modules options exportable.

# Answer
There is a working implementation of a views display extender in Authcache. The only difference I see between your code and mine is that I'm using `options_definition_alter` while you've implemented `option_definition`.
> 1 votes

---
Tags: 7, importing-exporting, views
---


# Question
Title: How to update a field, after a view page is visited?
Scenario:

I want to use a view to allow user to check a given code (string-like, eg "abc123") whether it is exists in the database, as well as whether the code has been checked before.

A content type called "code" is set up, has a field of "field\_code\_checked", either "0|Not yet checked" or "1|Checked", and the title field represents the "code" string. The title field will be use as argument a.k.a the contextual filter of a view page to check the code.

So a view page 'check' is set up. http://mysite.com/check/\[code-title\] =\> e.g http://mysite.com/check/abc123

For example: If 'abc123' exists and field\_code\_checked value is '0' (not yet checked), then view will output the code node information.

My problem is: how can I manage to update 'field\_code\_checked' to 1, once a checking visit is done? So when abc123 node is created, it has a field\_code\_checked set to 0 by default, when a user visit http://mysite.com/check/abc123, I want field\_code\_checked of abc123 node set to be 1. Any solution?

Thanks.

# Answer
> 0 votes
I end up use the hook hook\_views\_post\_render() to update field value.

---
Tags: views, entities
---


title: SEO for possible duplicate content

text:
# Question
Title: SEO for possible duplicate content
Website is about bands and musicians.

Musician can create the profile and add his bio. Band can create profile and add band members and their bio. Many musicians are members of several bands, so i will have bio of XY repeated on several pages of my website.

Any idea how to control this since site will be made and controlled more or less by users ?

# Answer
> 1 votes
I think the answer relies on the way you organize your content. I imagine **bands could be a content type**, with fields like bio, discography, pictures, videos and whatever, and **a field with multiple values** to add users, beeing the band musicians.

The users get their own fields from which bio. Then you can display a list of teasers of musicians in the band node, with a link to complete profile and bio.

EDIT : (for lazy or busy musicians :) I guess NY Big Band staff i.e knows all members's emails, names...

* **Create a role "band manager"** with the rights to create user accounts
* When an account is created by this role, **set up a rule** to send an automatic email to notify the musician, that an account has been created for him and he's welcome to check if his information is correct.

This way you 'll have a unique "musician content", without SEO duplicate problems, and you 'll also **improve the involvement** of musicians in your website.

---
Tags: 7
---


# Question
Title: Is there a way to expose the pager fields?
I'd like to let the user pick how many items are gonna be displayed on the page. Therefore, I need to display a field with a select or something.

Is there a way to make that directly through the UI, not with coding?

# Answer
> 9 votes
Yes, you can do that with Views.

In the pager settings for the View, select to expose the number of items to the user.

Make sure the textfield with available items per page options includes the default number of items per page.

# Answer
> 0 votes
Don't Forget in your View under 'Advanced' tab to change value of "Use AJAX" item to "Yes" Otherwise it doesn't show view exposed pager

thanx

---
Tags: paging, views
---


# Question
Title: View to display 2 posts from 1 content type 1 and 2 posts from content type 2
I want to display 4 featured posts on home page. 2 from the content type 1 and 2 from the content type 2. For this the straight forward way is to create two different views blocks. What I want to know if it is possible to display all 4 posts through a single view ??

# Answer
I have a multipart part answer to this question:

1. No, there's no way to do show exactly two nodes of one content type and two of another type using only 1 view if you want them grouped in a specific order.
2. If you don't care about that nodes of different content types are mixed up together, you can change your content-type filter to include multiple content types. This only uses one view but may not be **exactly** what you want.
3. If you give up on using only 1 view, Kojo's comment lays out an excellent and quick way to embed views inside of another view to create the desired effect. Just to recap: create one view for each content type, and put one of the views in the header of the other view. This gives the desired effect, but gives up on using only 1 view.
4. You could use a SQL query like this to create a custom theme hook that would have the intended effect without using Views at all. It would require SQL knowledge to maintain it, but it would also have a lot less overhead. Here's what you'd need to do:

Inside template.php in your theme:

```
<?php
/**
 * Implements hook_theme().
 *
 * This registers a custom function for use with the theme() function.
 * To make your featured nodes show up in a template, add this code:
 *
 *   print theme('featured_nodes');
 *
 * Whenever theme() is called with that argument, a certain preprocess function
 * will be called. I like to write SQL in those preprocess functions to
 * find raw data from the database. Then a template will be used to display
 * the information looked up in the preprocess function. Finally, the template
 * is returned as a string wherever theme() was originally called.
 *
 * Look up hook_theme in the API docs at http://api.drupal.org/ for more info.
 */
function mytheme_theme() {
    return array(
        'features_nodes'] = array(
            // Here I define which template should be used.
            // In this case, the template will be called featured-nodes.tpl.php
            'template' => 'featured-nodes',
        )
    );
}

/**
 * Implements hook_preprocess_hook().
 *
 * This function is triggered before the template is rendered. You can
 * pass variables into the template simply by adding them to $vars.
 */
function mytheme_preprocess_features_nodes(&$vars) {
    // This is a really simple query that looks up all the fields
    // on the node table for the 2 most recent nodes of type 1,
    // then it adds all the fields of the 2 most recent nodes of type 2.
    // Learning SQL is bigger than the scope of this question.
    $results = db_query('
        SELECT *
          FROM {node}
         WHERE type = "machine_name_of_content_type_1"
         LIMIT 2
      ORDER BY created DESC
         UNION
        SELECT *
          FROM {node}
         WHERE type = "machine_name_of_content_type_2"
      ORDER BY created DESC
         LIMIT 2
    ');
    $featured_nodes = array();

    // We use db_fetch_object() repeatedly to read out each result row.
    while ($row = db_fetch_object($result)) {
        $featured_nodes[] = $row;
    }

    // Anything in $vars will be added to the templates when they are rendered.
    $vars['featured_nodes'] = $featured_nodes;
}

```

Then, inside featured-nodes.tpl you'll have access the $featured\_nodes variable and you can display some very basic information about the nodes that you want (nid, title, author, and created date).

Here's an example of what should go inside featured-nodes.tpl.php:

```
<ul class="featured-nodes">
    <?php foreach ($featured_nodes as $node) : ?>
    <li><?php print l($node->title, "node/{$node->nid}"); ?></li>
    <?php endforeach; ?>
</ul>

```

NOTE: None of the above code is tested and it may require some tweaking.

Here's an in-depth blog post I wrote with more information on how and why to do version 4.
> 1 votes

# Answer
1. Create a view for your first content type. Limit the number of entries to two. Create the view as a page or a block, depending on your needs.
2. Add an attachment to the view by clicking 'add' next to 'Page' and/or 'Block' depending on step 1. Filter for your second content type.
3. In 'attachment settings' (second column), set 'attach to' to Page or Block, depending on 1. Set attachment position to 'after'.

That should do it.
> 0 votes

---
Tags: views
---


# Question
Title: preventing access to php files using htaccess doesnot allow ajax to use php files
i am using the following code in `.htaccess` to prevent access to `php` files from the browser

```
<Files ~ "\.php">
Order allow,deny
Deny from all
</Files>

```

the problem whit that is that when i deny access to php files ajax cannot use those `php` files either... how can i solve this... any help would be appreciated... thanks in advance... :)

# Answer
> 1 votes
I've no idea what you're trying to accomplish, but I believe you're seriously misguided about how a PHP-based website works.

If you set up `.htaccess`-rules to stop the browser from accessing any PHP-file, it is not only ajax that will be affected. *Every page* on your Drupal website will return 403 to any visitor, including `index.php` in the root directory. I doubt that you want this.

If you've got Apache configured correctly for PHP, the *contents* of a PHP-file are never transmitted to the client - only the result of processing it server side. Just point your browser to `sites/default/default.settings.php` to see how this works. Unless you've really munged your Drupal configuration, you should not need to do *anything* to stop the PHP-files from being browsed.

---
Tags: .htaccess
---


title: Restrict Users from viewing frontpage

text:
# Question
Title: Restrict Users from viewing frontpage
When user enter `http://localhost/node` then the user will be able to view all the nodes created in the site till date. In the site there are some content type which are viewable to all users on site and some are restricted to created users and shared users.How to stop users from viewing those nodes which they have not created. It will also be OK for me if user enter http:///node then "Page Not Found" displayed.

Please let me know your views.

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

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

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

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

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

Disclosure: I am the maintainer of Flexi access.

---
Tags: 7, nodes, security, users
---


# Question
Title: Problem with storing database queries values in array
I have a simple table with four field email,title,url & status

status can be '0' or '1'

There can be multiple values with status '1'. I want to store the all datas from the table with status '1' in array so i can output it later.

```
$values = db_query('select email,title,url from {example_table} where status= :one', array(':one' => '1'))->fetchAssoc();

```

The above array only stores one record in $values array.

# Answer
`fetchAssoc()` is only supposed to return a single result.

You're probably looking for `Statement::fetchAllAssoc()`

> Returns the result set as an associative array keyed by the given field.
> 3 votes

---
Tags: 7, database, theming
---


title: content type doesn't editable from UI

text:
# Question
Title: content type doesn't editable from UI
There is a way to prevent the editing of my custom contet type from UI? I have created my custom content type programmatically and I added a few fields and field groups. The content type and fields must not be editable by UI but only from code. I have tried to use the property 'locked' in hook\_node\_info() but without results, the content type is editable yet.

# Answer
> 0 votes
For ordinary users, you can just disable the "Edit any content" permission for the type in the **Node** section of *Administration » People » Permission* GUI:

However if you also need the to prevent user #1 (the default Administrator role) from editing, this will not work, since access controls are not enforced for that user. Instead, you can implement `hook_menu_alter()` to override the access callback for the node edit page, and provide your own instead:

```
function MYMODULE_menu_alter(&$items) {
  $items['node/%node/edit']['access callback'] = 'MYMODULE_node_edit_form_access';
}

function MYMODULE_node_edit_form_access($node) {
  $type = is_string($node) ? $node : $node->type;
  if ($type == 'my_type') {
    return FALSE;
  }
  return node_access('update', $node);
}

```

(Please note that user #1 should normally be trusted to not do anything stupid, so you should not usually have to use access control tricks to restrain user #1.)

Alternatively, you prevent anyone (including user #1) from editing any field (e.g. the body field) by disabling access the field `hook_form_alter`. You can do this with any field that makes up the content type.

```
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'my_form_id') {
    $form['body_field']['body']['#disabled'] = TRUE;
    $form['body_field']['body']['#value'] = $form['body_field']['body']['#default_value'];
  }
}

```

---
Tags: 7, nodes, entities
---


# Question
Title: How do I add description and keyword to the front page?
I would like to know how to set description and meta keywords for the front page. I use the Meta tags module for articles, but it is not working for the front page.

I use Panel as my front page.

My website is http://www.techiestuffs.com, and runs on Drupal 7.

if you see the HTML source of the front page, it only contains the following HTML:

```
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="shortcut icon" href="http://www.techiestuffs.com/sites/default/files/favicon.png" type="image/png"/>
<meta name="Generator" content="Drupal 7 (http://drupal.org)"/>
<title>TechieStuffs | Stuffs for Geeks</title>

```

I had tried adding these functions in template.php:

```
function yourtheme_page_alter($page) {
  $meta_description = array(
    '#type' => 'html_tag',
    '#tag' => 'meta',
    '#attributes' => array(
    'name' => 'description',
    'content' =>  'Description about the site'
  ));

  $meta_keywords = array(
    '#type' => 'html_tag',
    '#tag' => 'meta',
    '#attributes' => array(
    'name' => 'keywords',
    'content' =>  'Some Keywords about the site'
  ));

  drupal_add_html_head($meta_description, 'meta_description');
  drupal_add_html_head($meta_keywords, 'meta_keywords');
}

```

But this function does not seems to work as you can see in my websites source code.

Does anyone know how to work out this?

# Answer
In drupal 6 I used Nodewords which allowed you to set meta tags on the front page as a configuration. In D7 this has been replaced by Meta Tags which may do the same thing or you.
> 1 votes

# Answer
Add them in your theme file; whichever theme you're using, it should have an HTML skeleton that you can change.
> 0 votes

# Answer
Unfortunately, Views or Panels do not have meta tags by default. If you use either one for your frontpage, you can use the Meta Tags Quick Module, which allows the addition of the main meta tags for any path that is generated by Drupal.
> 0 votes

# Answer
I'm using Path-Based Metatags option in Meta tags quick module, enable module and go to front page, you will see Path-Based Metatags option...when you click on the option, you can fill in the fields that you want, you can also set the fields that you want to display (admin/config/search/metatags\_quick)...
> 0 votes

# Answer
I see this is an old thread, but in case people find and still looking for an easy solution. I didn't like the Drupal way or Meta Quick. Found this super easy module, Simple Meta, adds a tab at left side directly on every page. I edit only description and meta tag instantly appeared. https://drupal.org/project/simplemeta.
> 0 votes

---
Tags: panels, meta-tags
---


# Question
Title: I'm trying to create two content types at once in one form. One is a parent page the other a child page
So I'm workoing on a story archive website and I've created several interations using the Book module in drupal. However while I like all the stuff book does by default I need to streamline the process of content creation and I'm no longer sure I can do that easily with book module.

I am right now trying to figure out how to create a way to create both the front page and the first child page of a story/book in the system, and create an easier way to add a chapter to a story and tell drupal what the chapter number is. If anyone has any advice on this I would appreciate it emensly.

# Answer
> 0 votes
The Inline entity form module was built for pretty much that exact use case:

> Provides a widget for inline management (creation, modification, removal) of referenced entities.
>
> The primary use case is the parent -\> children one (product display -\> products, order -\> line items, etc.), where the child entities are never managed outside the parent form.
>
> Existing entities can also be referenced.

---
Tags: entities, nodes
---


# Question
Title: My hosting provider ask me to use xCache instead of the built in Drupal cache system
Just that I have a problem with a website (Drupal 7), the server falls down every night. My hosting provider ask me use xCache instead of built in Drupal cache system. Does it make any sense?

# Answer
> 3 votes
It makes perfect sense to use ***PHP opcode cache***, you should be using one if not already using. I'd recommend **APC** for PHP version 5.4 and less.

**xCache** is somewhat similar in the way it handles caching like APC, but the mechanism is different. You have to do quick research which one suits your needs and hosting compatibility.

If you are using PHP 5.5+ then it comes with in-house **OPcache**. Personally I haven't tested but when the package is bundled with software core it certainly grabs attention. You should check the use case for you.

**eAccelerator** is also nice one, I used to use it few years ago, but, when I got to play with more RAM, **APC** is beast.

The later part of your question says about

> use xCache instead of built in Drupal cache system

which is completely false, **xCache** or any other **opcode cache** is not replacement of **Drupal Cache**, it should be used together. Opcode cache is for PHP, it doesn't have anything to do with Drupal.

As for the part of replacement concerns, you can use **Memcached** instead of Drupal cache that is stored in database.

---
Tags: 7, performance
---


title: Rewrite the markup of panels page title

text:
# Question
Title: Rewrite the markup of panels page title
I'm trying to rewrite the output of the title of a panels page. I would like to add a class, for example. Actually, if I understand well, panels takes the layout from `page.tpl.php` then from the selected layout for its contents.
I tried to use `taxonomy-term.tpl.php` (I'm using the taxonomy page override by panels) but it doesn't work. Still, panels takes header, navbar and title styles from `page.tpl.php`.
Is there a way to avoid this? Is there a way to add a class or an id to the title element of a panels page?

Edit:
I found this which is for node\_view panels template. I don't know if for term\_view is different.

# Answer
> 0 votes
Following the comment on the panels issue linked in the question, I managed to make the panels page override for term\_view works.
This is the code added to *mytheme/**template.php***

```
function MYTHEME_preprocess_page(&$vars) {
  // if this is a panel page, add template suggestions
  if($panel_page = page_manager_get_current_page()) {
    // add a generic suggestion for all panel pages
     $variables['theme_hook_suggestions'][] = 'page__panel';
    // add the panel page machine name to the template suggestions
    $variables['theme_hook_suggestions'][] = 'page__' . $panel_page['name'];
        if($panel_page['name'] == 'term_view' ) {
           $vars['theme_hook_suggestions'][] = 'page__term_view';
}
}
}

```

Then, inside the *mytheme/templates/* folder, I added `page--term_view.tpl.php` with my custom page title display.

---
Tags: theming, panels
---


# Question
Title: How do I get the placeholder attribute into a Search API Solr Search field?
I'm using Search API Solr Search and can't seem to get a placeholder attribute in it. I've tried using hook form alter as I would on a normal search block, but doesn't seem to work with search api solr.

The id of the form = views-exposed-form-recipe-find-recipe-find-list
The name of the search input field = search\_api\_views\_fulltext

I've placed this function in my theme's template.php...

```
function marigold_institute_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'views_exposed_form_recipe_find_recipe_find_list') {
    $form['search_api_views_fulltext']['#attributes']['placeholder'] = t('Search by name or ingredient');
  }
}

```

I'm not quite sure what I'm doing wrong. This is the first time I've tried using hook\_form\_alter, so I could easily be missing something obvious. I tried the function on a normal search block using "search\_block\_form" for the id and name, and it worked. I just can't seem to get it working with search api solr search.

# Answer
The problem is the views exposed filter form always has an ID of "views\_exposed\_form", nothing more specific. My low-rent way round it was this:

```
function MYMODULE_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['search_api_views_fulltext'])) {
    $form['search_api_views_fulltext']['#attributes']['placeholder'] = t('blah');
  }
}

```

That works fine for my use case, but if you need something more specific you should be able to look in the `$form` or `$form_state` and find the View object, which you can use to identify which view/display is currently being altered.
> 0 votes

---
Tags: search
---


# Question
Title: How to change theme colors based on time of day for Adaptivetheme (or other theme that allows user-selectable colors)?
I'm using a custom subtheme of the Pixture Reloaded subtheme of Adaptivetheme. I want to change the theme colors based on the hour of the day. (I want a "day" theme and a "night" theme.)

I know that I can do this with the Themekey module, which allows you to specify rules for which theme to use. You can make a rule based on the time of day and have two different themes, but then I will have to maintain two entirely separate themes. Since all I want to change is the colors, taking this approach would be a maintenance nightmare.

Pixture Reloaded uses the **Color** module to allow users to select the colors, so I don't understand how to easily override it.

One thing I noticed is that there are a number of pre-defined color schemes. For my purposes, it would be sufficient to have a way to automatically use one pre-defined scheme during the day, and another at night.

How can I do this without creating (and maintaining) a copy of my original theme?

# Answer
Place the following code into your theme's template.php file.

```
/**
* Implements template_preprocess_html().
*/
function YOUR_THEME_preprocess_html(&$vars) {
  // Day / night background theming.
  $hour = date('G');
  $theme = 'day';
  if ($hour <= 6) {
    $theme = 'night';
  }
  elseif ($hour >= 6 && $hour <= 18) {
    $theme = 'day';
  }
  elseif ($hour >= 18) {
    $theme = 'night';
  }
  $vars['classes_array'][] = $theme;
}

```

Now your `<body>` tag should have the CSS class 'day' or 'night' depending on the current server time.

An example CSS code would look like:

```
body.day {
  background: #fff;
  color: #000;
}
body.night {
  background: #000;
  color: #fff;
}

```

for more info check this tutorial.
> 2 votes

---
Tags: theming
---


title: how to display overlay width and height

text:
# Question
Title: how to display overlay width and height
hi i'm using overlay paths module with overlay module. i have 2 questions

* how to set an overlay width , i tried as mynode/\*|200px but it doesn't works.
* is it possible to view a page in a overlay without header and footer .

# Answer
You should set your path in `admin/config/system/overlay_paths_ui` whit pattern like this `node/add|600px`. (I test it by myself, it effect after I clear cache in `admin/config/development/performance` ).
This module cant help you to set a height for overlay.(you can patch this module to provide your require ). Final and good solution for do your job is **use css**, set css in your css file

```
#overlay {
height :xxx px; !important
width :xxx px; !important
}

```
> 1 votes

# Answer
The following example shows how to modify the overlay when a specific node type (test) is displayed inside the overlay. The script re-size the overlay to 450px wide and also hide some unwanted items.

If you want to alter all the layouts no matter what, then overlay.tpl.php would be a better choice.

Declare your hook:

```
function mymodule_overlay_child_initialize() {
  // Add our custom JavaScript.
  drupal_add_js(drupal_get_path('module', 'mymodule') . '/overlay-child.js');
}

```

Add the code to your JavaScript file:

```
(function ($) {
  // Adjust the overlay dimensions.
  Drupal.behaviors.myModule = {
    attach: function (context) {
      $('#overlay:not(.mymodule-adjusted)', context).each(function() {
        var $test = $(this).find('.node-type-test');
        if ($test.length){
          // adjust the overlay
          $(this).css({
            'width'     : '450px',
            'min-width' : '450px'
          });
          $('.add-or-remove-shortcuts', this).hide();  // hide "add short-cut" button
          $('#branding', this).hide();  // hide branding container
        }
      }).addClass('mymodule-adjusted');
    }
  };
})(jQuery);

```

for more info check this tutorial.
> 0 votes

---
Tags: modal-dialogs
---


# Question
Title: Warning: Illegal string offset '#access' in views_handler_field_field->set_items() line 862 views_handler_field_field.inc
I'm having an error that I can't find an answer for, and was wondering if someone out there can help.

The error i get is...

Warning: Illegal string offset '#access' in views\_handler\_field\_field-\>set\_items() (line 862 of .../sites/all/modules/views/modules/field/views\_handler\_field\_field.inc)

I have created a view, that is showing a multiple value result of a photo gallery from 10 nodes of the same content type. Basically I have a content type for venues, and each venue can upload an unlimited number of photos for their venue. This view sits on one of the main national pages, and shows all photos from all venues.

Looking at line 862, the error is in the following bit of code

> ```
>   // field_view_field() adds an #access property to the render array that
>   // determines whether or not the current user is allowed to view the
>   // field in the context of the current entity. We need to respect this
>   // parameter when we pull out the children of the field array for
>   // rendering.
>   if (isset($render_array['#access'])) {
>     $items[$count]['rendered']['#access'] = $render_array['#access'];
>   }
>
> ```

Can anyone help me and shed a bit of light on this? It looks like a permissions problem if a user doesn't have access to the content, but my permissions are no different than they have been for the last 10 drupal sites I have built.

# Answer
I found the answer, I realised that as well as the error, I was also seeing a "1" appear after the grid items.

This bug is related to the Grid Field Display module, and the answer and patch can be found at https://drupal.org/node/2046435
> 1 votes

---
Tags: views
---