# Question
Title: Main Navigation Menu: Throwing out the old and making a new
I've fought blood, tooth, and nail with the built in `Main Menu` in Drupal 7, and finally I've given up.

What I've done instead is implemented a block which I've placed into the `Main Navigation` area, and used pure CSS to control the menu. So far, I think it looks and works great.

**There's only a few problems:**

The company which I am writing this site for has a few users with administrative privileges whom only have a very small and limited knowledge of HTML.

I've installed the CKEditor (WYSIWYG HTML editor) module for the blocks, which has made everything much easier for them, but whenever they edit the raw HTML for the menu (which they don't like doing) this editor removes all of the CSS classes from the menu and destroys it.

Also, because of my block approach to the menu, they don't have the very nice `Configure Links` page that you would have with the built in menu.

**What I would like to do:**

I would like to make a `new menu module` which will work like the built-in `Main-Menu`, yet **not extend it** (I've tried both Superfish and NiceMenus, both of which extend the built-in menu, essentially inheriting all of its bugs).

I would like to make a `Configure Links Administrative Page` that will allow an administrator to configure the links as you would for the built-in main menu.

**My Question:**

Does anyone know how to view the source for the Main-Menu module, or if a **replacement** Main-Menu module exists that I can cut and hack apart?

So far, I haven't been able to find any of the source for the Main-Menu module or any replacements. I've only found extension modules like Superfish and NiceMenus.

If nothing exists yet, would anyone be able to point me in the direction of where to start, or (this may be too much to ask) walk me through how to do it and work on this project with me? I am very new to Drupal (I didn't know what it was two months ago) yet I have some extensive knowledge in software engineering.

I understand this has been tried several times, and proposed several times, yet I've not been finding any follow-ups to these questions. I thought this post might have been helpful, but I felt like I was just running in circles after reading it...

Thanks for the help everyone! I'll be looking forward to your responses!

# Answer
Search for a module called nice menus.

Another option is to create a custom block and inside it query the db yourself for the main menu links. You can also add the contextual list links button to your block.
> 0 votes

# Answer
Is it possible that you're using CKE v.4 and ACF is enabled? If so, unless you've registered the classes in cke-styles.js (or whatever its called) the Advanced Content Filter will strip them out.
> 0 votes

---
Tags: blocks
---


# Question
Title: How to create navigation menu on sidebar with different navigation links displayed on different pages?
I am using Drupal-7.

I have created Dropdown menu with Megamenu. Now, I wanted to create navigation menu on left side that menu items will be different on each page. I have created navigation block region for left side bar and wanted to create dynamic left side menu for each pages. For example:

If our page structure is:

```
1.0
1.1

    1.1.1

1.2
    1.2.1
1.3
    1.3.1
    1.3.2
    1.3.3
        1.3.3.1
    1.3.4
    1.3.5
    1.3.6

```

So, **on 1.0 page** on left side menu should appears like this:

```
1.0
    1.1
        1.1.1
1.2
    1.2.1
1.3
    1.3.1
    1.3.2
    1.3.3
        1.3.3.1
    1.3.4
    1.3.5
    1.3.6

```

On **page 1.1** left side menu - It should be **only - 1.1.1** On **page 1.2** left side menu - It should be **only - 1.2.1**

On **page 1.3**, it should be like this:

```
1.3
    1.3.1
    1.3.2
    1.3.3
        1.3.3.1
    1.3.4
    1.3.5
    1.3.6

```

On **page 1.3.1, 1.3.2, 1.3.4, 1.3.5** and **1.3.6 - no item** on left sidebar.

On **page 1.3.3 - only 1.3.3.1** should be there.

Can anyone please let me know that how should I create left side bar menu like this? Do I have to use Menu Block module for that? If I have to use Menu Block module then how do I create menu items that will be displayed different on each pages?

Thanks!

# Answer
> 3 votes
This totally looks like a Menu Block scenario, where you would want to enable the 'Make the starting level follow the active menu item.' setting. Also enable 'Block title as link', but don't enter a custom title as this would override the link.

# Answer
> 1 votes
Two options I can think of:

1) If you are not dealing with too many pages (3 in your example), create a separate menu for each page.

2) Create a custom module to build the menu items. This gives you more control over when a menu item is displayed, such as filtering by NID. Be sure the menu you want the items to show up in exists before your module creates the actual menu items.

The Example Menu Module may help: https://api.drupal.org/api/examples/menu\_example%21menu\_example.module/7

Edit: Another module that can get you part of the way is Menu Token: https://www.drupal.org/project/menu\_token

Menu Token module provides tokens, that can be used in the title or the path of menu items (links). For example, if you create a menu item with the path: "user/\[current-user:uid\]", the URL will be changed "on the fly" to: "user/1" (assuming you are user 1).

Tokens are provided by the Token module. Menu Token enables you to use both global tokens and entity tokens (node, user, term, etc). Entity tokens have several methods of substitution, including context, random and user defined.

---
Tags: routes, navigation, blocks
---


title: Add CSS class to view fields

text:
# Question
Title: Add CSS class to view fields
I would like to add a CSS class to fields in a view. The view in the screenshot takes the title, the summary, the date and the tags of articles that are published to the frontpage. I know how to add a class to the whole article in the GUI, but I want to add a class to fields on the article in the view.

I have made changes to existing CSS classes, but they appear on other parts of the site.

# Answer
> 4 votes
I found the answer on a video

1. Go to 'Edit View'
2. Click on the field you want to add a CSS class to
3. Go to the 'Style Settings'
4. Check 'Customize field HTML'
5. Check 'Create a CSS class'

# Answer
> 2 votes
What @David said.

Or, if you want to keep the customization out of the DB and put it in your theme, copy the views field template into your theme and rename it...

Find the original template in the Views module folder. Just make a copy and put it in your theme templates folder.

Then rename it... views-view-field--my-field.tpl.php

Add your classes, then clear the theme cache.

If you ever work on larger projects, sometimes the back end folks don't want you to do anything to the DB. This approach maintains a complete separation, and nobody steps on anyone's toes.

This template suggestion would apply anywhere 'my-field' is displayed. If you need more specificity, go into the view under **Advanced / Theming** and look at the available template suggestions for ideas.

---
Tags: views
---


# Question
Title: Configuration Management Module Keeps Saying 'needs attention'
I've just started using the configuration module to keep my Drupal database in sync between my development and live environments.

Documentation for this module is sparse, and I'm trying to understand how it works.

I went to the UI and started tracking a single custom content type. It goes ahead an tells me it is tracking that content type, plus all its custom fields and everything which is great.

But then when I go to the 'tracking' tab, it lists all the stuff it is tracking, and in the side tabs, it says that things 'need attention', for example the 'content type' tab says '1 needs attention'. Yet, when I look at the status of the tracked configurations, it simply says 'In sync'.

What exactly 'needs attention', and how do I make it stop saying this?

# Answer
> 0 votes
It means that there is a difference between activestore and datastore for those items.

Below you see that those items are overriden. The ones in data store are old versions. If this is a dev environment and those changes are necessarry, you can write these changes to datastore and push/migrate to prod environment.

The below changes are for example purpose and they are not necessarry to put to prod version, since they are about things like last running of cron, etc.

The below image a real change in activestore. You can write that down on datastore by clicking Write Activestore to Datastore.

---
Tags: 7, configuration
---


title: Cannot edit existing content

text:
# Question
Title: Cannot edit existing content
I've unfortunately run into a rather major issue on an existing Drupal site. I recently applied the updated from core 7.12 to core 7.14. Since then, I can create new content in the admin panel, yet I cannot edit or make any changes to existing content. I see the following errors:

> * Warning: array\_merge() \[function.array-merge\]: Argument #1 is not an array in \_form\_set\_class() (line 4134 of .../form.inc).
> * Warning: implode() \[function.implode\]: Invalid arguments passed in theme\_radios() (line 2809 of .../form.inc).
> * An illegal choice has been detected. Please contact the site administrator.

I deleted and reverted the site back to how it was before running these updates, yet again, after updating Drupal core, I still can't edit any content. Is there any direction that can be given in resolving this issue?

# Answer
> 1 votes
I had an issue similar to this. The update to Drupal core caused issues with content types using the References Dialog module. We noticed that altering any nodes with a type using these reference dialog fields had issues. What tipped me off was that the other content types didn't have an issue. Odds are that this error is being caused by another module. Here are a couple things you can try in a development environment:

1. Create a new content type with core fields (a title, body, and maybe an image field will work). Do you get the same problem?
2. Verify whether or not all of your content types are affected. I know you said you can't alter any content, but you can save yourself time by being absolutely sure. Choose a few nodes for each type and try editing them to see if you get any other issues. If you see that there are only some content types affected, you can find out what fields / widgets they're using and start to deduct which one is causing the problem.

Good luck!

---
Tags: 7, nodes
---


# Question
Title: How to handle duplicate .module files that live in 2 places?
I have not used Drupal before and have been thrown a project to fix up some things.

But I noticed the file I need to edit lives in two places:

* one in `includes/jobs.module`.
* another one in `sites/all/modules/jobs/jobs.module`.

Is one meant to be a sym link of the other or something? As this is not the case in the project I have been given. What file should I be editing?

I'm sure this is basic stuff for and Drupal dev. An suggetions?

# Answer
> 4 votes
There shouldn't be a job.module in the includes directory at all, your module files for your job module should all be in sites/all/modules/jobs.

You generally shouldn't put anything in (or modify anything in) the includes directory or you will make it harder for yourself to upgrade drupal core in future.

I would say you should:

1. check for any differences between the two files.
2. If they are different determine whether or not anything in includes/jobs.module should be in sites/all/modules/jobs/jobs.module. If so add it.
3. Delete includes/jobs.module

# Answer
> 3 votes
To further completed the answer from Rooby, you may want to consider using the Hacked module, which will identify various similar issues that may exist in your Drupal sites. Here is an excerpt from its project page:

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

---
Tags: 7, files
---


# Question
Title: How to configure paragraphs module for multilingual
I try to configure the Paragraphs drupal module for a multilingual website.

I have :

* set the content type translatable with field translation
* enable translation on the paragraphs field
* enable translation for the field in the paragraph bundle (or not)

However, when I create some content and translate it, the existing paragraphs are not displaying in the other language.

What's the correct/working way?

# Answer
> 0 votes
From the community documentation about Field Translation:

> Note: The Field Translation module does not provide content translation for fields. This functionality is provided by the Entity Translation (ET) module.

So could it be that the Entity Translation module is what is missing?

---
Tags: i18n-l10n
---


# Question
Title: Error after transfering process to a new host
I transfered my website to a new host and I am seeing this error:

> PDOException: SQLSTATE\[42S02\]: Base table or view not found: 1146 Table 'teise1\_katalogas.system' doesn't exist: SELECT name, filename FROM {system} WHERE status = 1 AND bootstrap = 1 AND type = 'module' ORDER BY weight ASC, name ASC; Array ( ) in system\_list() (line 136 of /home1/teise1/public\_html/imoniukatalogai.lt/includes/module.inc).

Anybody who knows how to resolve this error?

# Answer
These kinds of problems (after transfer to a new host) might be caused by some type of permission problems. At least if we may assume that the table in the error message does actually exist (if not that needs to be addressed of course).

So I'd verify that the userid specified in the settings.php file, has the appropriate access to the Drupal database (also specified in settings.php).

Another option is to verify the various items mentioned in https://www.drupal.org/node/1308308
> 0 votes

# Answer
Drupal stores all of your site's content and setting in the database. The 'system' table is a core table in Drupal, so if your web site was fully transferred, you should have it. It looks like your code is in place, but the the database wasn't, or was partially, transferred over.

It looks like you have the right user name and password since you're not getting a 'permission denied' error, so that's good. I would verify that you have your database migrated over.

Another possibility is that the database dump didn't finish with either the export from your old host, or possibly the import into the new host.
> 0 votes

# Answer
**'prefix' =\> 'arthur\_deco\_',** ---\> Simply add this line on your `settings.php`. This suggestion definitely solve your issue.

**Or**

Try to remove the field from `field_config` and `field_config_instance`.

```
drush sql-cli
mysql> DELETE FROM field_config WHERE field_name = [‘field_DELETED_FIELD’];
mysql> DELETE FROM field_config_instance WHERE field_name = [‘field_DELETED_FIELD’];

```

Clear cache after deleting i.e. `drush cc all`
> 0 votes

---
Tags: database
---


title: Translate message from tabledrag.js

text:
# Question
Title: Translate message from tabledrag.js
I try to translate the message that is used in the following JavaScript code.

```
Drupal.t('Changes made in this table will not be saved until the form is submitted.')

```

I use the String Overrides module; I tried also translation using settings.php. None of the methods work.

Does anybody have an idea on how to translate the sentence? I do not want to use big modules like localize.

# Answer
Drupal loaded only the needed strings on every page which we are included. Those strings are added in javascript itself.

I think this is fixed by across the script files before they are actually added to the page.

So, you should be able to translate that string into the translate interface.

For more help, You can see this link,

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

Hope it will be helpful.
> 2 votes

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


title: CCK Migrate filefield to file error

text:
# Question
Title: CCK Migrate filefield to file error
I tried using CCK Migrate and this happens and field fails to get migrated, can someone let me know how to read this kind of error:

```
Requesting rollback of field "field_evt_mat_download" due to failure to convert record:

array ( 'entity_id' => '4715', 'revision_id' => '4742', 'field_evt_mat_download_fid' => '9109', 'field_evt_mat_download_data' => 'a:1:{s:11:"description";s:32:"Presentation (Open as Read Only)";}', 'delta' => '8', 'entity_type' => 'node', 'language' => 'und', 'bundle' => 'event', 'field_evt_mat_download_description' => 'Presentation (Open as Read Only)', 'field_evt_mat_download_display' => '1', )

Cause:

exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'public://local marketing/event/member-appreciation-october/2012/' for key 'uri'' in D:\xampp\htdocs\aadev\dev7\includes\database\database.inc:2171 Stack trace: #0 D:\xampp\htdocs\aadev\dev7\includes\database\database.inc(2171): PDOStatement->execute(Array) #1

```

# Answer
Well I figured out that the `field_evt_mat_download` is actually in `field_data_field_evt_mat_download` so I solved the problem myself.
> 1 votes

---
Tags: 6, migrations, entities
---


title: Search results issue

text:
# Question
Title: Search results issue
I am using the drupal's built in search module, for this I have copied the `search-results.tpl.php` in my theme folder. Now I have to add images for search results too and also want to custom theme the template file. For images I have used the following approach: In my `template.php`:

```
function MyTheme_preprocess_search_result(&$variables)
{
if ($result['node']->type == "content_type") {
 $node = node_load($result['node']->nid);
 $prod_image = field_view_field('node', $node, 'machine_name_img', $display = array());
 $variables['image'] = $prod_image;
}
}

```

and then in `search-result.tpl.php`:

```
<?php if($prod_image):?>
    <?php print render($prod_image);?>
<?php endif; ?>

```

but its not working, can anybody knows how do I get the images related to search results, and how can I theme search results?

# Answer
You're using the wrong var name. In your preprocess function you're using `$variables['image'] = $prod_image;` to set the var. Whatever element name you use in the the `$variables` array will be the name of the var in the template. So in your case it should be:

```
<?php if($image):?>
    <?php print render($image);?>
<?php endif; ?>

```
> 0 votes

# Answer
You used some vars that don't even exist in this place. template.php:

```
function MyTheme_preprocess_search_result(&$variables){
  if ($variables['result']['type'] == "content_type") {
   $node = node_load($variables['result']['node']->entity_id);
   $prod_image = field_view_field('node', $node, 'machine_name_img', $display = array());
   $variables['image'] = $prod_image;
  }
}

```

and then in search-result.tpl.php(like in the answer of @Shawn Conn):

```
<?php if(image): ?>
  <?php print render(image); ?>
<?php endif; ?>

```

If you get the correct return out of this, dependes on what the line `$prod_image = field_view_field('node', $node, 'machine_name_img', $display = array());` will return
> 0 votes

---
Tags: 7, search
---


title: Show also content on users view

text:
# Question
Title: Show also content on users view
I have a Drupal View that was created to show users which are members of the site, this works fine but now the client wants to see not only users on the same view, but also content of type "X", but when I try to add the ***Filter Criteria*** for ***Content type = X*** , that Filter is not available (don't know why I can't see it), I don't know if this is related to the fact that this was a view created to show Users and not Content from the very beginning.

My question is, what would be the way (hopefully the easiest) to show not only users but also content of Type "X" on my view ? I don't need any logic between the user and the content, is just show on the view results Users and Content of type "X".

Thanks in advance.

# Answer
What about just creating two different views, one for users and another one for content? If there is no relationship between users and content, this might be the easiest solution.

You can create two different blocks and then display them together in your page (using Blocks, Context, Panels or whatever method you prefer).

Hope it helps,
> 0 votes

---
Tags: views, users
---


# Question
Title: How to generate commerce add to cart form on a page with full functionality?
I am building a small site with very simple products, what I am trying to do is build a product list based on one product node, it's more easy to use an example to explain.

Like I have a product node with these fields, title, unit number, unit, price, we call it \[base product\].

Title: juice unit number: 100 unit: ml /*milliliter*/ price: 3$

Now how to generate a product like this? Please note that the price are auto-calculated.

* juice 100ml 3$ add\_to\_cart\_form
* juice 200ml 6$ add\_to\_cart\_form /\* 3$x2 \*/
* juice 300ml 9$ add\_to\_cart\_form /\* 3$x3 \*/
* juice 400ml 12$ add\_to\_cart\_form /\* 3$x4 \*/
* juice 500ml 15$ add\_to\_cart\_form /\* 3$x5 \*/
* juice 600ml 18$ add\_to\_cart\_form /\* 3$x6 \*/
* juice 700ml 21$ add\_to\_cart\_form /\* 3$x7 \*/

Please note that this product is actually one product reference page but have several add\_to\_cart form buttons, all the information is generate from \[base product\]

Because the product is so simple that I don't want the user have to increase the product quality themselves by input numbers or click the add\_to\_cart buttons again and again, just pick up a quality and add\_to\_cart.

However, this also can be solved by adding product nodes with different quality number, but it's a pain if you want to change the price information when you product reference page have a much longer list for displaying, especially when all the products have a same \[base price\].

Any insight or suggestions will be much appreciated. Thanks in advance.

# Answer
use the inline entity form module to enable product variations. in the node you only have a product reference field, where you reference all your desired product(-variations)

then the user still can input the quantity, but also choose the product-variation. in your case the different ml-units.
> 0 votes

---
Tags: commerce
---


# Question
Title: Views Infinite Scroll and back button issue
I am using Views Infinite scroll module, Drupal 7. When i click on an item and go to next page and then click Browser back button, it takes me back to the start of the page.

When i click browser back button, i want the user to go back where he clicked/ or where he was on the previous page

Can somebody suggest any solution to this? Or any other module that can be used? Or an jquery script that would help?

I am badly in need of help.Thanks in advance!

# Answer
Try to use GD Infinite Scroll module.

> Provide an administration to use the infinite scroll jQuery plugin : auto-pager on custom pages using pager. You can use autoload on scroll or a load more button. This module is designed to works on any page with pagination (views, search results, heavily customised page, ...)
> 0 votes

---
Tags: paging, views
---


title: How to customize pager

text:
# Question
Title: How to customize pager
I have a code, that outputs a standard pager:

```
print theme('pager');

```

it outputs this:

```
<h2 class="element-invisible">Pages</h2>
<div class="item-list">
<ul class="pager"><li class="pager-current first">1</li>
<li class="pager-item"><a title="Go to page 2" href="/drupal/node?page=1">2</a></li>
<li class="pager-item"><a title="Go to page 3" href="/drupal/node?page=2">3</a></li>
<li class="pager-next"><a title="Go to next page" href="/drupal/node?page=1">next ›</a></li>
<li class="pager-last last"><a title="Go to last page" href="/drupal/node?page=5">last »</a></li>
</ul>

```

How can I change the HTML to something like this:

```
<ul class="pagination">
    <li><a href="#"><</a></li>
    <li><a href="#">1</a></li>
    <li><a href="#" class="active">2</a></li>
    <li><a href="#">3</a></li>
    <li><a href="#">></a></li>
</ul>

```

I looked into this thread: https://www.drupal.org/node/387786, created a function `bartik_preprocess_custom_pager` and a file `custom-pager.tpl.php` inside my Bartic theme templates, but I can't make it work.

```
print theme('custom_pager');

```

outputs nothing. Does anybody know, how can I customize the HTML output for a pager, creating one just for 1 page?

# Answer
As pointed out in my comment above, most of the details are wrong in your implementation above. Fortunately in Drupal 7, there are **six** theming functions for the pager:

These should allow you to make most of the customizations that you need. There's a good stackexchange answer about how to override Drupal theme functions() that you can refer to for the details.

Finally, you mentioned that you want to override the pager just for one page. I still think this might be worth doing with CSS alone, but in case it's not, you may be able to just override parts of the `$variables` array in whichever preprocess function contains the pager (I don't know off the top of my head if it's `preprocess_page` or `preprocess_node` or if it's accessible from any of the preprocess functions at all).
> 6 votes

# Answer
This is my answer from a previous post.

If you implement theme\_pager you'll be expected to create the entire pager render array from scratch using several theme function - theme\_pager\_first, theme\_pager\_previous, theme\_pager\_next and theme\_pager\_last. That seems like entirely too much work for adding one class.

Since theme\_pager calls theme\_item\_list at the very end to build the final render array, you can use hook\_preprocess\_HOOK to modify the pager render array before drupal renders it into HTML.

```
function THEME_preprocess_item_list(&$vars) {
  // make sure we're dealing with a pager item list
  if (isset($vars['attributes']['class']) && in_array('pager', $vars['attributes']['class'])) {
    // make sure there are items
    if (count($vars['items'])) {
      $vars['items'][0]['class'][] = 'test';
    }
  }
}

```

Clear the cache after adding this hook.

**UPDATE**: find the first li.pager-item:

```
function THEME_preprocess_item_list(&$vars) {
  // make sure we're dealing with a pager item list
  if (isset($vars['attributes']['class']) && in_array('pager', $vars['attributes']['class'])) {
    // loop the items and find the first .pager-item
    foreach ($vars['items'] as $index => $item) {
      if (in_array('pager-item', $item['class'])) {
        $vars['items'][$index]['class'][] = 'test';
        break;
      }
    }
  }
}

```

**UPDATE2**: find first and last li.pager-item:

```
function THEME_preprocess_item_list(&$vars) {
  // make sure we're dealing with a pager item list
  if (isset($vars['attributes']['class']) && in_array('pager', $vars['attributes']['class'])) {

    // loop the items and find the first and last .pager-item
    $first = FALSE;
    $last = NULL;
    foreach ($vars['items'] as $index => $item) {
      if (in_array('pager-item', $item['class'])) {

        // first
        if (!$first) {
          $vars['items'][$index]['class'][] = 'test';
          $first = TRUE;
        }

        // last
        $last = $index;
      }
    }

    if (!empty($last)) {
      $vars['items'][$last]['class'][] = 'test2';
    }
  }
}

```
> 2 votes

---
Tags: 7, theming, paging
---


# Question
Title: How to show categories and regarded node in drupal 7
I have a site in Drupal 7. I am using brands(taxonomy term) and product(node). For example I have 4 brand -- brand1 brand2 etc.. I need to show all 4 brands and regarding node .. When I click on brand 1 . then brand1 related node need to show..

I need something like this structure.. display all terms on left and right all regarding products.

# Answer
1. Create taxonomy(first add vocabulary and then add terms) by going to the below path:

> admin/structure/taxonomy

2. Configure your content type to add a field of type 'term reference':

> admin/structure/types/manage/article/fields

3. Add content and select your brand field.
4. Create a view by doing the following configurations shown in attached image.
> 1 votes

---
Tags: 7, views
---


# Question
Title: Passing variable from preprocess block to the block body
There is a block which its body is produced by `PHP Code`. I need to set a variable before loading the block and use it in it. This is my code

```
function THEME_preprocess_block(&$variables){
    $variables['var']="some text";
}

```

when I open the block configuration page and in its body I write

```
<?php print $var;?>

```

it prints nothing. How do I can pass variable from block template page in to the block body in the block configuration page?

# Answer
Your variable will be available in block.tpl.php. Consider making your own block like described on How to theme a custom block?. (You probably do not need `hook_theme()`.)

Using PHP directly in blocks (via UI) is not the best practice: It slows your site down, as the block needs to be rendered with every request, when it comes to caching.
> 2 votes

---
Tags: blocks, hooks, theming
---


title: Display Suite Custom Template Issues

text:
# Question
Title: Display Suite Custom Template Issues
I've been using Display Suite for Drupal 7 (with Bamboo theme,) and I'm trying to build a layout template that contains 5 rows, so I can place the appropriate fields into each row, making all content nice and tidy.

I've followed the instructions here, but I'm doing something wrong: https://www.drupal.org/node/1098068

I'm guessing it has to do with the PHP code, because I'm getting errors involving my wrappers. Here is the PHP code for the tpl.php file:

```
<?php

/**
 * @file
 * Display Suite Bamboo custom template.
 */
?>
<<?php print $layout_wrapper; print $layout_attributes; ?> class="ds-bamboo <?php print $classes;?> clearfix">

  <?php if (isset($title_suffix['contextual_links'])): ?>
  <?php print render($title_suffix['contextual_links']); ?>
  <?php endif; ?>

  <<?php print $first_wrapper ?> class="introduction<?php print $first_classes; ?>">
    <?php print $first; ?>
  </<?php print $first_wrapper ?>>

  <<?php print $second_wrapper ?> class="entry1-group<?php print $second_classes; ?>">
    <?php print $second; ?>
  </<?php print $second_wrapper ?>>

  <<?php print $third_wrapper ?> class="entry2-group<?php print $third_classes; ?>">
    <?php print $third; ?>
  </<?php print $third_wrapper ?>>

<<?php print $fourth_wrapper ?> class="entry3-group<?php print $third_classes; ?>">
    <?php print $fourth; ?>
  </<?php print $fourth_wrapper ?>>

  <<?php print $footer_wrapper ?> class="group-footer<?php print $footer_classes; ?>">
    <?php print $footer; ?>
  </<?php print $footer_wrapper ?>>

</<?php print $layout_wrapper ?>>

<?php if (!empty($drupal_render_children)): ?>
  <?php print $drupal_render_children ?>
<?php endif; ?>

```

I think it is very possible I am also writing my .inc file incorrectly. Here is that code as well:

```
<?php
function ds_ds_bamboo () {
  return array(
    'label' => t('Bamboo DS'),
    'regions' => array(

        'introduction' => t('Introduction'),
    'entry1-group' => t('Entry 1'),
    'entry2-group' => t('Entry 2'),
    'entry3-group' => t('Entry 3'),
    'group-footer' => t('Footer'),
          ),
    // Add this line if there is a default css file.
    'css' => TRUE,
      );
}

```

I would be very appreciative if someone can set me in the right direction. Thank you!

# Answer
> 1 votes
I have managed to solve this problem, and I'm posting my own answer here in hopes that it will help someone else struggling with this.

First, when creating a Display Suite Custom Layout, follow the directions here: \[https://www.drupal.org/node/1098068\]\[1\]

Then, if you are defining custom regions like I am, the trick is to create custom regions in your Drupal theme. To do this, go to *sites/all/themes* and enter the folder containing your theme. Then find your theme's .info file.

This should be where the regions in your theme are stored and created. To set up the regions that will work with the php code listed above, enter:

your\_region\_name = \[name\_of\_custom\_region\]

I created 7 regions this way. For example, my first region is named:

introduction = \[introduction\]

This may be slightly different given how your theme is set to define regions, but this is what worked for me. I entered my new regions after the pre-existing Content region defined in the theme. (I have no idea if that makes a difference, but that is what worked for me.)

After you have defined the regions, insert and alter the php code from the question above in your Display Suite tpl.php file. (The link in the first step shows you how to define this file.)

You will then change some of the php code to reflect your custom regions. For example, if you defined your first region as "introduction" the code should look like this:

```
    <<?php print $introduction_wrapper ?> class="introduction<?php print $introduction_classes; ?>">
    <?php print $introduction; ?>
  </<?php print $introduction_wrapper ?>>

```

You will then need to alter the code each time, entering the next region name that you defined in the .info file in order.

Lastly, you will need to update your Display Suite custom layout .inc file. I did this by defining each newly created custom region that I wanted to show up on the custom layout within Drupal. As an example, my code looked like this in the end:

```
    <?php
function ds_ds_bamboo () {
  return array(
    'label' => t('Bamboo DS'),
    'regions' => array(

    'articletitle' => t('Article Title'),
        'titleimage' => t('Title Image'),
    'introduction' => t('Introduction'),
    'entry1' => t('Entry 1'),
    'entry2' => t('Entry 2'),
    'entry3' => t('Entry 3'),
    'author' => t('Author Bio'),
          ),
    // Add this line if there is a default css file.
    'css' => TRUE,
      );
}

```

Doing this will create row-like regions that will allow you to neatly group Drupal fields together, giving you a template for future content.

As an example, my "entry1" region contains an image field, text field, another optional image field and text field, as well as a video embed field. Due to the structure of the code and Display Suite's field management, all of the fields and their content are kept nice and tidy within the custom region.

I hope this helps if you're struggling with defining custom layouts in Display Suite!

---
Tags: theming, display-suite
---


# Question
Title: Is there an efficient easy way to test Drupal code while developing it?
While writing code making sure, for example, I'm access the correct array property I keep refreshing the browser.(Or, that I didn't make a semantic mistake like that last sentence but in code) Is there a very simple and quick why to set up tests to do this instead? Simple test module seems like a huge deal and overkill. I love using Grunt watch while working with node.js. Is there an equivalent in Drupal?

# Answer
> 1 votes
As you're comfortable with Grunt, I've got a Gruntfile that I wrote that I use as a stub for most projects. You can find it here github.com/Chapabu/grunt-drupal-standards/. Just clone it to your project root and follow the installation instructions.

There are Drupal specific tasks there for doing to following:

* PHP linting of any custom code
* JS linting
* CSS linting
* Automatic clearing of theme registry when new templates are found
* PHP\_CodeSniffer tasks to ensure your code mets the Drupal Coding Standards

I need to make a few updates (i.e. remove Casper stuff, remove Compass tasks as I now use Libsass etc) but the tasks that are there should be enough to get you started.

There are also Grunt tasks for running PHPUnit tests or PHP Mess Detector (to name a couple of helpful suites) so it's pretty easy to add tasks to watches.

# Answer
> 0 votes
If you're already familiar with using Grunt, there's nothing stopping you from using it with Drupal. Grunt installs the same way on Drupal as with any other site.

Just a a couple of the many useful node-modules you could make use of are:

grunt-contrig-jshint (Can be configured to alert you to potential JS errors as soon as you edit the JS)

grunt-phplint (Can alert you to potential PHP errors whenever you edit PHP files)

Livereload - Can be set up to automatically update the page content without refreshing (For CSS and image modifications)

---
Tags: testing
---


# Question
Title: subscribe to nodes with entity reference
I'm building a music site and have an 'artist' content type that are referenced in product displays, articles etc. I want to enable users to subscribe to these artists and get notified whenever there's a product display, article, event etc. that references the artist.

I've been looking into the Message Stack module to achieve this (http://www.jacksonriver.com/news/message-stack), but haven't been able to make it work with entity reference.

Is this something anyone feels like helping me out with? Could be a very powerful feature IMO.

# Answer
Try flags + Rules + Views

I use something similar on a jobs site to allow users to subscribe to 'industries' (taxonomy) and be notified when a new job tagged with the industry is created.

In short: install the Flag module, and create a flag for taxonomy terms. This flag, when clicked, would fire a rule saying "Subscribe the user to this term" and this would happen with a nice Ajax link that does not reload the page.

Create another rule, saying something like "When new content is posted in X term, email all users who have flagged (subscribed to) that term."

Then build a couple of views: A page of all the terms (if you need this!), showing the Flag links (these can be text, or you can style them as nice images using CSS). The second view: A block, emulating a Subscriptions block - basically this block would appear on your 'Artists' pages, and it would show the terms together with their flag/subscribe links.

You could build a third block, to be shown on the user's profile page, listing the terms they're subscribed to. You might want to use the Context module to control the logic of where the blocks appear.
> 2 votes

# Answer
Try this module,

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

This module enables users to subscribe to be notified of changes to nodes.

Hope it should be helpful.
> 0 votes

# Answer
The subscriptions module that latikas pointed out may work. There are other ways to accomplish this, perhaps in a lighter way. This is what I would try:

1. In your Artist content type add an Entity Reference field to Users. Be sure to selecte "Unlimited" number of values in the configuration settings for this field.
2. Create a Rules Link (https://www.drupal.org/project/rules\_link) called e.g. "Subscribe", and attach it to your Artist content bundle. The rule component for this Rules Link should basically "Add an item to a list". In this case the list is the Entity Reference field to unlimited users you added above, and the item to be added is site:current-user. Be sure to configure the Rules Link so that it shows only for authenticated users. This Rules Link will now show a link in every Artist content type. When a user clicks the link, the Rules Link will fire, and will add him/her to the list of users Entity Reference field in the Artist content type.

Once you have this working, you can simply create another Rule that fires every time a display, article, etc that references the Artist content type is modified. This Rule would basically loop through all the users in the specific Artist user Entity Reference field, and send an email to each of them notifying them of the change.

The only caveat of this method is allowing users to unsubscribe. I'm sure this can be done, but would require a bit more time, which I don't have right now :)

I hope this helps.
> 0 votes

---
Tags: emails, flags
---


# Question
Title: Drush modifying variable on settings.php
Can I modify a variable of the setting php via drush? I actually want to change

```
ini_set('session.cookie_lifetime', 2000000);

```

to

```
ini_set('session.cookie_lifetime', 0);

```

# Answer
> 1 votes
If you're working on a web server then you can download WinSCP (for windows) or PuTTY. Then login as *root* and go to the folder that contains `settings.php`

For Putty:

> Simply nano 'filename'. That is: `nano settings.php`

This will open your file and you can make changes as you like.

With WinSCP:

> Folder structure opens up in a GUI . You can simply click and edit.

Hope this helps.

# Answer
> 3 votes
Drush cannot edit the settings.php file. You could do the above with sed. Let me know if you want the regex to do it.

# Answer
> 0 votes
I don't have enough Rep to comment on the second response here, but the best answer to the question

> Can I modify a variable of the setting php via drush?

is:

Drush cannot modify settings.php variables.

---
Tags: drush
---


# Question
Title: Unable to add Acquia Cloud site using Acquia Dev Desktop behind a proxy (Win 7)
I'm trying to use Acquia Dev Desktop 2 Beta behind a proxy at work (Win 7), but there doesn't seem to be any proxy configuration settings for the program.

When I try to log in to Acquia cloud, it times out and says:

> Login failed.
> Network error: Couldn't connect to server

Has anyone figured out how to make this work through your proxy?

# Answer
> 0 votes
Short answer is: "Proxy configuration is currently not supported in the most recent version of Acquia Dev Desktop"

There are some workarounds, that work with varying levels of success, but nothing solid that I've found.

---
Tags: acquia-dev-desktop
---


# Question
Title: Changing URL alias of webform breaks template
I created a webform with a URL alias of `contact-us`. The edit URL is `http://local.mysite.com/node/1/webform`. I have two custom templates, `page--node--1.tpl.php` and `webform-form.tpl.php`. Everything works correctly.

Now I've been asked to change the URL alias of the page to `feedback`. As soon as I do this, the form stops displaying. I've error-logged things out, and when the alias is changed, it's not getting to the `webform-form.tpl.php`.

I'm confused - I understood that `webform-form.tpl.php` (without a specific form name) would be applied to any and all webforms. Is this incorrect? Or is there something else I'm missing that would cause a URL change to break this way?

Edited to add that there are no changes to `template.php`.

# Answer
Check which template name Drupal suggests after you changed URL alias.

Enable debug option so you could see template name suggestions (they shown in the html source as commented out strings).

You should see something like this:

In your case the new suggestion could be: webform-form--feedback.tpl.php or page--feedback.tpl.php
> 0 votes

---
Tags: 7, theming, webforms
---


# Question
Title: What is the simplest way to flush cache at a predetermined date and time?
For site a) I would like to set up a schedule "page and else"cache clear every day at midnight. For site b) I would like to set up a schedule full cache clear every Wednesday day at midnight.

I am using the modules Varnish and Expire (Cache Expiration) to clear node caches when events occur (added deleted node etc).

As far as I can tell Rules does not provide Time/Date as an event which can be used as a trigger.

I am looking to do this internally in Drupal rather than on the servers cron. Is there a simple way to achieve this?

# Answer
> 1 votes
May be How can I schedule a rule to always be run at a specific hour of the day? can be useful , but using cron, build a module and in it's `hook_cron` function check for the current time, if it is your specific time use the cache\_clear\_all function and it's parameters to clear the page and else cache. just make sure that the cron is ran on Wednesday day at midnight. it's periodic run time should come to 24:59.

you can also check the clear drupal cache - php script for more options of clearing the cache statement.

---
Tags: caching, rules
---


title: Ckeditor: Add Cite tag

text:
# Question
Title: Ckeditor: Add Cite tag
I am using Drupal Ckeditor (The main one, not the WYSIWYG module).

I would like to add buttons to the interface for inserting `<quote>` and `<cite>` tags.

How can I do this?

It already has a `blockquote`, but I would like `<quote>` and `<cite>` as well.

# Answer
Here is a good tutorial in Custom buttons on CKEditor or Adding CKEditor Plugins Manually in Drupal . Before asking the question you should have let us know what you have done so far.

---

If you were checked the links, you would see that in the Adding CKEditor Plugins Manually in Drupal and **Add Plugin Part of CKEditor Module** section it explained where to put the plugin.
> 1 votes

---
Tags: wysiwyg
---


# Question
Title: missing cet_enable field in product type settings (Commerce Event Ticket)
I have installed the Commerce Event Ticket module along with any requirements and have enabled it. I see the following under column `description` in `admin/modules`:

> Allows tickets (with unique barcodes) to be generated for Commerce purchases.
>
> Version: 7.x-1.0-beta3
>
> Requires: Entity API (enabled), Commerce (enabled), System (enabled), Rules (enabled), Entity tokens (enabled), Product (enabled), Price (enabled), Customer (enabled), Address Field (enabled), Chaos tools (enabled), Line Item (enabled), Order (enabled), Commerce UI (enabled), Checkout (enabled), Cart (enabled), Product Pricing (enabled), Product Reference (enabled), Options (enabled), Field (enabled), Field SQL storage (enabled), Views (enabled), Order UI (enabled), Field UI (enabled), Product UI (enabled), Customer UI (enabled), Views Bulk Operations (enabled)
>
> Required by: Commerce Event Ticket PDF (disabled), Commerce Event Ticket Mail (disabled), Commerce Event Ticket Services (disabled)

Now, when I add a new product type (`commerce/products/types/add`) or go to `Manage Fields` of an existing product type, I do not get an existing field `cet_enable`. The list of available existing fields in the list box only contains:

```
<select class="field-select form-select" id="edit-fields-add-existing-field-field-name" name="fields[_add_existing_field][field_name]">
<option value="" selected="selected">- Select an existing field -</option>
<option value="field_link_to_page">Boolean: field_link_to_page (Link to page)</option>
<option value="field_date">Date: field_date (Date)</option>
<option value="field_eventdate">Date: field_eventdate (Date)</option>
<option value="field_price">Float: field_price (Price)</option>
<option value="field_image">Image: field_image (Image)</option>
<option value="field_img">Image: field_img (Image Gallery)</option>
<option value="field_myimage">Image: field_myimage (MyImage)</option>
<option value="uc_catalog_image">Image: uc_catalog_image (Image)</option>
<option value="uc_product_image">Image: uc_product_image (Image)</option>
<option value="field_table_description">Long text: field_table_description (Event Description)</option>
<option value="field_product_reference">Product reference: field_product_reference (Product reference)</option>
<option value="field_tags">Term reference: field_tags (Tags)</option>
<option value="taxonomy_catalog">Term reference: taxonomy_catalog (Catalog)</option>
<option value="field_external_link">Text: field_external_link (External link (leave empty for no link or use abov...</option></select>

```

How do I get access to the `cet_enable` field? This is after a core update to 7.34

I've filed a bug with the module but am also interested in how I can troubleshoot this best myself??? Thanks for hints and tips!

# Answer
Could this be related to some type of permission that is still missing? Also, consider adding a LINK in your question to point to the issue you created (it may help to further enhance this question also).

Did you receive any eMails by using this module?
> 0 votes

---
Tags: 7, commerce, debugging
---


title: New server runs with https

text:
# Question
Title: New server runs with https
I have a Drupal site that I am currently developing on a local environment. Recently I uploaded my site to a "live" environment and everything seems to load fine except for all admin functionality. My local server runs with http, while the "live" server configuration runs securely with https. I have noticed that I cannot get into the Drupal admin pages and forms with the Drupal site when running https on the "live" server. Both the overlay and regular admin pages wont load. When clicking a toolbar menu item I get the following javascript console errors: `Empty string passed to getElementById().` 5 times, and `Error: permission denied to access property "document"`. Weird... I cant 100% say that this is an https problem, but it seems to be the case.

With more research involving http vs https with Drupal sites, I learned of the securepages module. I have since installed it but cannot enable it on the "live" instance of the site due to none of the admin pages working. I also tried enabling it via drush and it wasn't working for me. So then I figured why not try to enable it on the local version and then upload the database and modules to the live site. I couldn't do that either because my local connection is http and the secure pages module will only allow enabling when its detected SSl. See the conundrum? Has anyone ever seen this before?

# Answer
> 1 votes
Yes. How you fix this depends on what you built and what you did. You did not say if you built a Drupal 6 or 7 site. It makes a big difference. You also did not say what mods you made to the settings.php file if any when you uploaded this new site.

Your $base\_protocol $base\_url

AND a $conf statement as to HTTPS will need to be properly set - depending on which version of Drupal you are using

You may need to modify the DNS zone to accept a wildcard for the domain depending on what kind of site and content it already has and the

$cookie\_domain may need to be properly addressed or Drupal (depending on which one you have ) may drop sessions and log people out by dropping the session if they switch between secures pages classes. See the issues que of secure pages for examples - and make sure you are looking at the issue that has to do with whichever version you have installed - Drupal 7 and Drupal 6 respond completely differently to SSL and HTTPS issues See https://www.drupal.org/project/issues/securepages?categories=All

See https://www.drupal.org/https-information for a head start and pointers

As to getting the admin pages to work - usually creating and setting $conf\['https'\] = FALSE; should allow http access again by forcing the entire site to non-secure

---
Tags: modal-dialogs
---


# Question
Title: Fatal error: Class 'SelectQuery' not found in includes/database/database.inc on line 813
```
Fatal error: Class 'SelectQuery' not found in /home/content/71/11241671/html/drupal/includes/database/database.inc on line 813

```

We built a site in a subfolder called /drupal while building the site, and then moved the files to the root directory when we were finished but it gave the above error on a WSOD.

I have tried:

* flushing the cache before moving
* tried the registry rebuild
* truncating and replacing the registry and registry\_file tables with a fresh install copy, and rebuilding the registry again
* rewrite base in htaccess
* setting a new base url in settings.php

But nothing has worked.

The second we put the files back into the /drupal folder, it works again. It also looks like the error mentions the file in the /drupal directory, which isnt there anymore.

This is on 7.37

Anyone have any ideas?

# Answer
Rolling back this patch... https://www.drupal.org/node/2170453 solved the first problem, and then using htaccess to define the correct php version fixed the next error.
> 0 votes

---
Tags: 7, wsod
---


# Question
Title: How to add a checkbox to a Content Type and act if box is set to true or yes
Module name, 'text\_grabber' Content Type, 'node' name 'essay' \**When I enable this module, I want a checkbox to be added to the ~/node/add/essay page. So when an user adds a new essay to the site they can select yes on the checkbox that will enable the text\_grabber module for that specific essay. If the user selects yes, I want to be able to add a js script specific to that essay before it is saved. This will allow me to execute code if event is triggered. Is this possible.

I think I can add a checkbox using an .install like mentioned here: Using field\_create\_field and field\_create\_instance to add a checkbox to a content type

but the other part, what can I do?? In layman's terms, I am not tremendously experienced.

# Answer
This created the fields on the table and showed up on the edit page (started file with opening php tag) "custom\_module.install"

```
function custom_module_install() {
  field_create_field(array(
     'field_name'  => "text_grabber_enable",
     'type'        => 'list_boolean',
     'cardinality' => 1,
     'settings'    => array(
        'allowed_values' => array(
          0 => '',
          1 => '',
         ),
      ),
  ));
  field_create_instance(array(
     'field_name'  => "text_grabber_enable",
     'entity_type' => 'node',
     'bundle'      => 'video',
     'label'       => t('Enable Text Grabber'),
     'required'    => false,
     'widget'      => array(
        'type'     => 'options_onoff',
        'settings' => array(
           'display_label' => 1,
        ),
      ),
  ));
}

```

Below is inside my custom\_module.module file. Hook node view changes what happens when a certain node type is loaded from what I understand. I used the Devel module to view exactly where the value was in the text\_grabber\_enable array of the node object (ex. dpm($node); within the node view function during testing)

```
function custom_module_node_view($node, $view_mode) {
    if($node->type == 'essay' && $node->text_grabber_enable[$node->language][0]['value']) {
        drupal_add_js('(function($) {alert("just a test but text grabber is enabled for this node"); }(jQuery));', array(
           'type' => 'inline',
           'scope' => 'footer',
           'weight' => 5,
           )
        );
     }
 }

```
> 0 votes

# Answer
You can add a field in a number of ways:

1. Edit the content type and add a Boolean field through the UI
2. In your .install file as you already mentioned
3. Using hook\_form\_alter() to add a #checkbox.

If you used option 1 or 2 you can pick up whether the field is checked or not using hook\_node\_presave() or hook\_node\_update().

If you used option 3 you'll probably need to add a #submit value to the form which calls a custom function in your module.
> 1 votes

---
Tags: nodes, entities, javascript
---


# Question
Title: Remove or Redirect Users who go to www.domain.com to domain.com
My drupal site is apparently accessible as both 'www.domain.com' and just 'domain.com'. Does anyone know of a way to remove the 'www' accessibility, or at least redirect users who go there to the 'domain.com' domain?

I've installed Global Redirect module but am not seeing options that solve this problem. Does Global Redirect module solve this problem or is this a stackoverflow question?

# Answer
> 8 votes
If you're using Apache with your setup, this is built into the .htaccess file that comes with the distribution of Drupal. Look for the following code and follow the instructions in the comments:

```
  # To redirect all users to access the site WITHOUT the 'www.' prefix,
  # (http://www.example.com/... will be redirected to http://example.com/...)
  # uncomment and adapt the following:
  # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  # RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

```

You'll have to replace example.com with your own site's domain.

---
Tags: redirection
---


# Question
Title: How can i add a span element within the search form using hook_form_alter?
I’m trying to customize a search box that appears in the global header, using hook\_form\_alter. I’ve succeeded in changing the submit button to an image but still need to do the following 2 things:

add placeholder text that reads ‘Enter search terms here….’ and then add a

```
<span class="sb-icon-search"></span>

```

within the form itself. This is for future use, i’ll be coding the field to hide/show when mousing over a search icon.

my hook\_form\_alter code is as follows:

```
function mytheme_form_alter(&$form, &$form_state, $form_id){
  if($form_id == 'search_block_form'){
  //dsm($form);
  $form[actions][submit]['#type'] = 'image_button';
  $form[actions][submit]['#src'] = drupal_get_path('theme', ‘mytheme’). '/images/search_trans.png';
  }
}

```

# Answer
> 2 votes
For the placeholder just add this line to the hook\_form\_alter

```
$form['FIELD_I_WANT_TO_ALTER']['#attributes']['placeholder'] = 'placeholder text';

```

The span can be done in a few ways but the shortest is

```
$form['hover_toggle']['#markup'] = '<span class="sb-icon-search"></span>';

```

---
Tags: forms
---


# Question
Title: Git push to drupal.org always returns "Everything up-to-date"
This same question was asked many times, but for now I didn't find any help in the responses.

I have a project in a sandbox which I frequently pushed to the DrupalGit repository without any issue during review process.

Then after successfully getting permission, I first wanted to simply promote my sandbox to a full project according to these instructions, but for some reason editing my sandbox page never showed me the "Promote" tab.

So I decided to create a full project from scratch, then I followed its "Version control" tab documentation to create and populate the corresponding repository: compared to the sandbox's one, you can see that it only contains the `myModule.info` file.
(this file is not the "true" myModule's info file: it was created in the earlier steps prescribed by the above doc).

Once successfully pushed this and added a "7.x-1.0" tag as also prescribed, I locally copied all my real files from sandbox to full-project directory, `git-add`ed them and `git-commit`ted them.

Then from now on, any `git push origin 7.x-1.0` simply returns "Everything up-to-date", and obviously nothing is updated in the DrupalGit repository.

I looked at many posts and docs, in the Drupal community and elsewhere, tried a lot of more or less serious methods.
I even dropped all files but `myModule.info` from my local repository: pushing this committed situation also returns "Everything up-to-date", and indeed the same after bringing them again.

I could observed something weird when clicking the `myModule.info` file to display its contents:

* in the sandbox repository it appears formatted with line numbers, as expected, and clicking "plain" displays its raw content
* but in the full project repository it displays in hexdump mode, And clicking "plain" causes its download to be proposed!

This clearly means that the file in a somewhat strange state, and midht be significative... but not for me at the moment :-)

# Answer
This not a real "answer" to the question I asked, but only the method I finally found to get out of my blocking situation.

Since it seemed not possible to make the remote repository to accept push attempts from its associated local repository, I took the problem from the opposite end.

After all it appears as a quite simple solution:

1. I renamed my local repository, say to `myModule.old`
2. I cloned the remote repository with
`git clone --branch 7.x-1.x [myName]@git.drupal.org:project/myModule.git`,
so getting a new `myModule` local repository
3. then I pasted whole contents from `myModule.old` into `myModule`, added and committed them
4. and finally used a simple `git push origin` (NOTE: without tag mentioned), with success

BTW, it's interesting to notice that trying with the tag mention again returned the "Everything up-to-date" message.
In the other hand, once pushed new contents, the `myModule.info` file displays normally rather than with the previous weird fashion.

Hope this helps somebody.
> 0 votes

---
Tags: version-control
---


# Question
Title: $page not targetting views block but $is_front is. Need help with trying to solve this in any way
I wrote this poorly the first time, more succinctly:

I need a custom node.tpl for the same content type in the front page teasers, the node itself, and a views listing of that node in the sidebar on every page. The problem is the front page uses teasers, while the nodes use full view, so I can't edit the markup of the sidebar nodes with just $page or $teaser because they would share the markup with the main content of either page.

---

The front page uses teasers to display nodes. I want different markup in the sidebar for the "most popular" views block, so I set it to use full view. This works fine on the front page.

The problem is on the individual nodes. I can't target the views block's markup in node.tpl. I made an identical views block with teaser view (because nodes use full view) instead but

```
<?php if ($page): ?>
<?php if ($view_mode == 'full'): ?>
// Node
<?php endif; ?>
<?php if ($view_mode == 'teaser'): ?>
// Views list
<?php endif; ?>
<?php endif; ?>

```

doesn't work. The opposite works fine on the front page:

```
<?php if ($is_front): ?>
<?php if ($view_mode == 'teaser'): ?>
// Node
<?php endif; ?>
<?php if ($view_mode == 'full'): ?>
// Views list
<?php endif; ?>
<?php endif; ?>

```

I tried `<?php if ($page == 1): ?>` as well, though I'm not sure if that's used.

Either way, why I can't just use views for everything is because 1. it breaks the AJAX of the rate module. Which is fine in the sidebar, but not on the front page. And 2. I'm using a link from within a field like this:

```
    <a class="full-link" href="<?php echo $node->field_download_link['und'][0]['value']; ?>">
        <div class="full-parent-episode-container">
            <div class="full-parent">
                <span><?php print render ($content['field_parent'][0]['#markup']); ?></span>
            </div>
            <div class="full-episode">
                    <span><?php echo $node->title; ?></span>
            </div>
        </div>
    </a>

```

so I can't have all of the "field-" divs, which break the link. If it matters I'm using $block to get the views list, again, to avoid those "field-" divs.

```
        <?php $block = module_invoke('views', 'block_view', 'sidebar_popular_full_view-block'); ?>
            <?php print render($block['content']); ?>

```

# Answer
1. See template\_preprocess\_node() for details on how the $page variable is created.

It is this:

```
$variables ['page'] = $variables ['view_mode'] == 'full' && node_is_page($node);

```

So it is only for the full view mode and only if you are viewing the node page of the node that is currently being themed.

So something like this will not work because `$page` will not be true if `$view_mode == 'teaser'`:

```
<?php if ($page): ?>
  <?php if ($view_mode == 'teaser'): ?>
    // Views list
  <?php endif; ?>
<?php endif; ?>

```
2. There is also currently a bug in the views module where if you have a view on a node page and one of the results of that view is the same node as the one whose page you are on then views will break the $page variable in the node template, causing it to always be FALSE.

To see if that is part of your problem try the patch at https://www.drupal.org/node/1574806

3. I would not theme a view mode differently in different places. For example the teaser would always look the same regardless of what page it was on. Then you just use:

If you are using teaser already for something else then use a different view mode (you could use the entity view mode module for this if you don't want to code it).
> 1 votes

---
Tags: 7, views, nodes, blocks
---


# Question
Title: Drupal Search- Linking Multiple Entities with Relations as a Single Unit
I've got a site that currently uses Views exposed filters for search. I'm looking at other search solutions for Drupal in an attempt to make more complicated searches possible.

The searches on my site are of users, but the catch is that each user, in addition to a user profile, has four nodes of four different content types connected to that profile with relations (from the Relation module). These four nodes should also be considered part of the user profile.

In Views, I handle this by adding the four relations to the view, which allows me to pull the four pieces of content into the view. My question is, is there a way to use Search API (with or without Solr) to link each user profile with its content based on the relations? Or is there another search solution for Drupal that can accomplish this?

I don't need a step-by-step tutorial; I just want to understand whether it's possible to use relations from the Relation module to link entities (nodes and users) as a single "unit" in search in Drupal.

# Answer
> 0 votes
This turns out to be really easy. On the **Create Index** page, just add the **Related Entity (User-\>Node)** Option for the relevant relation. The entities will then all be index together as a single unit and you can do Views and Facets and all sorts of fun things with them.

---
Tags: search
---


title: Validate text format when render page

text:
# Question
Title: Validate text format when render page
Im making an exportation process (from SQL Server to MySql) and in the text\_format column insert NULL values, currently the page is rendering the pure html (plain text) instead of render the html correctly in the browser.

Somebody know how to force the output text\_format to be filtered\_html to my specific content type?

Thanks in advance

# Answer
> 0 votes
Assuming the inserts are taking place on field tables (e.g. `field_data_body`, `field_data_field_MACHINE_NAME`), you shouldn't insert NULL into the \*_format columns. Rather, you should be inserting the machine name of your desired filter format (e.g. `filtered_html` for Filtered HTML or `full_html` for Full HTML). See the `filter_format` table for all available machine names for your installation.

---
Tags: input-formats
---


# Question
Title: Adding different auction prices for same product
I'm having same issue as krystalcode's issue.

First I created a product. Then added the content as auction product. While adding this content, the base price is considered to be the same as the product. So, do I need to add new product before creating an auction item?

It would be great if farhadhf, the owner of this Commerce Auction module will help.

# Answer
> 0 votes
As the author of this module or someone else couldn't reply this question, I'm creating new product before creating the content. Then I create the auction content and choose the related product.

---
Tags: 7, commerce
---


# Question
Title: How can I create template for specific page in module?
I am completely new to drupal, and just started learning.

Here's my issue:

I have created a module, called 'doom'. It has only one form.

I would like to remove all the default elements ( header, footer, sidebar ) and to add custom elements.

I tried this,

```
/**
 * Implements hook_theme_registry_alter().
 */
function doom_theme_registry_alter(&$theme_registry) {
    $module_path = drupal_get_path('module', 'doom');
    $template_file_objects = drupal_find_theme_templates($theme_registry, '.tpl.php', $module_path);
    foreach ($template_file_objects as $key => $template_file_object) {
        if (!isset($theme_registry[$key]['theme path']) || !preg_match('#/themes/#', $theme_registry[$key]['theme path'])) {
            $theme_registry[$key]['theme path'] = $module_path;
            $theme_registry[$key] = array_merge($theme_registry[$key], $template_file_object);
            $theme_registry[$key]['type'] = 'module';
        }
    }
}

```

This code changes all the pages in the site. But I just wanted to customize the template for 'doom' page. http://example.com/drupal/doom

# Answer
> 0 votes
As I understood, you need something like this:

```
/**
 * Implements hook_menu().
 */
function doom_menu() {
  $items['doom'] = array(
    'page callback' => 'doom_page_callback',
    'page arguments' => array(),
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );
}

/**
 * Implements hook_theme().
 */
function doom_theme() {
  // Get the path to this module and define theme dir.
  $module_path = drupal_get_path('module', 'doom');
  $theme_dir   = $module_path . '/theme';

  // Themable elements. This will look for "sample-template.tpl.php" file
  // in the "YOUR_MODULE_DIR/theme" folder. That file can be anything.
  return array(
    'sample-template' => array(
      'template' => 'sample-template',
      'variables' => array('content' => NULL),
      'path' => $theme_dir,
    ),
  );
}

/**
 * Menu callback.
 */
function doom_page_callback() {
  // Get your template and display ONLY the contents of that file.
  print theme('sample-template', array('content' => t('Optionally, pass dynamic content here.')));
}

```

And the `sample-template.tpl.php` file:

```
<div id="sample-template">
  <?php print $content; ?>
</div>

```

This should give you the idea. If you still want to theme the HTML header/footer from the front end theme, you should be able to create `page--doom.tpl.php` file there and customize what is displayed. In that case, just return the output instead of printing it in `doom_page_callback()`.

Hope this helps.

---
Tags: 7, theming
---


# Question
Title: How can I make a read only field  form with node authors' mail address on node edit page?
I would like to make a read only field form on a node edit page prepopulated with the e-mail address of the node author. I tried Markup module but couldn't get it done. Is there anyway to do this?

# Answer
see http://drupal.org/project/field\_permissions, from module description:

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

# Answer
The Field Readonly module will help you.

> Field Readonly displays non-accessible fields in edit forms as read-only items.
>
> Modules like the essential Field Permissions allow to make fields non-accessible by completely hiding them in edit forms even if user has the permission to view them. Field Readonly lets you display these fields back in edit forms, rendered the same way as in view mode.
> 0 votes

---
Tags: entities, 6
---


# Question
Title: How can I index only active user accounts in a user index?
I'm setting up Search API Solr to make a user search on my site. On this site, when a user account is cancelled, we keep the data but block the account (set the status to non-active). This is necessary to prevent abuse of the system, but I want to eliminate the risk that data from these accounts would be exposed in Solr search, so I am looking for a way to index only active users.

I've been digging around but couldn't find any way to configure the index to not add blocked users. How can I do this?

# Answer
> 0 votes
It turns out that Search API has a built-in filter for excluding unpublished nodes, but not users.

So here's a patch.

---
Tags: search
---


# Question
Title: Using drush into remote host is showing me local data
I have an alias setup for my remote host with the following in the script:

```
<?php
$aliases['lws'] = array(
    'root' => 'domain.com:/home/user/public_html',
    'uri' => 'domain.com',
    'remote-user' => 'user',
);
?>

```

But when I drush using (for example): drush @lws status

I get information back about my local machine and not about the remote machine. I know this is the case because my remote machine is Linux and my local machine is windows...and when I run drush from the remote machine itself it shows me different results than what drush on my local machine is giving me. Also the command above run locally shows me all the alias files I have setup on my local machine (for other drupal installs).

Any idea what might be going on here?

# Answer
> 0 votes
It'd be interesting to see what results you'd get if you modify your script above by removing the `domain.com:` (in 'root'), to make it look like so:

```
<?php
$aliases['lws'] = array(
    'root' => '/home/user/public_html',
    'uri' => 'domain.com',
    'remote-user' => 'user',
);
?>

```

At least that would make it look more like the samples for 'dev' and 'prod' as documented in https://www.drupal.org/node/1401522 .

Curious to hear if this helps somehow ...

---
Tags: drush
---


title: Specific user role can't log in

text:
# Question
Title: Specific user role can't log in
I'm having a very strange problem: Most user roles can login without a problem (administrators, clients, etc...).

But users with the 'registered user' role can not login through the form. The login form does not respond. In the log messages the failed login attempts are not logged.

The only way the users (with role 'registered user') can login is through the request new password link. So the user clicks on the link, receives an email with a login link, and when they click on the link in the email they are logged in. So than they can edit their account and even change the password.

However, when they log out again and try to login with the new password it does not work anymore, the form does not respond again.

The only way that user can get logged in again is through the request new password procedure.

Anyone have any idea what could be causing this?

I suspect it has something to do with some kind of permissions. Some of the modules i installed who could maybe give a conflict: Logintoboggan, Registration role

Any help would be greatly appreciated.

Greetings

# Answer
> 1 votes
Thanks for the help.

I did try to login with an email and username, same results for both.

But very strangely everything works now... And i have no idea what i did to fix it.

Last thing i did was update every module and the Drupal Core. And today the login form works again as it should...

I would love to give more information for future people experiencing this problem but frankly i have no clue what solved it.

Thanks again for all the help!

Greetings

# Answer
> 0 votes
Try to use below module :

1. Password Reset

> The password\_reset module allows for passwords to be reset without involving e-mail addresses through the use of security questions. This module would typically be used on sites that do not require users to enter their e-mail addresses or prefer not having to deal with spam folder issues etc.

2. Simple Password Reset

> This modules simplifies the password reset process.
>
> Without this module enabled, core Drupal prompts the user to log in via a one-time login form. After clicking "Log in", the user is brought to their profile edit form where at long last they can change their password.

3. Password Reset Landing Page (PRLP)

> The "PRLP" module enhances the original password reset landing page by letting a user set their new password at the same time they "log in" using the one-time-login link. It can also show a username and email address field. The password entry field can be configured to be mandatory. Other entry fields can be hidden through configuration and the page the user is taken to after login can be configured.

# Answer
> 0 votes
I had a similar issue and was kind of user error. As on our other Drupal installations I had it set to except both Username and Emails ; and on the site with an issue only Username. So the answer in this case was to make sure users where using their Usernames and not Emails ! \*Some\* Users Experiencing Login Failures

I hope this helps

---
Tags: users, authentication-authorization
---


# Question
Title: Installed Bluez theme as a sub-theme but can't change Appearance Settings
I'm using the Bluez theme (in D7). I created a sub-theme from it. It doesn't have a starter kit or anything so I just turned it into a sub-theme by creating an .info file, etc.

Things are working fine so far, but when I try to make any changes to the settings in 'Appearance' under 'Bluez Theme Settings' ... make the changes and then click 'save configuration' \> it says the 'configuration options have been saved' but ... they aren't.

Any idea what might be happening here? I'm thinking maybe there are template files I should be copying over to my sub-theme folder or something. Or maybe you can't create sub-themes out of themes that don't support sub-theming?

# Answer
In one of your comments you wrote you created your my\_bluez folder within the "*sites/all/templates folder*".

If that's really the name of the folder where you created the my\_bluez subfolder (i.e. that it is not a typo in your comment here), then I wonder what result you would get if you would rename that folder to "*sites/all/themes*". Because that would make it comply with the Community documentation about Installing themes (bullet 3 in that list there). It would make it even harder to realize for Drupal that my\_bluez theme is actually like a clone of the Bluez theme, no?. Just to be sure, after renaming that foled I'd then also clear the Drupal cache.

If that still doesn't work, then I wond if it could be related to some (missing) file permissions of that newly created folder.

Does this help somehow?

PS: Creating a "clone" seems to me like a better term of what you're trying to achieve. Creating a sub-theme is really something related to base themes in Drupal-eze.
> 1 votes

---
Tags: 7, theming
---


title: Multiple registration phases

text:
# Question
Title: Multiple registration phases
I'm having trouble figuring out how to have a registration in different phases. This is what I would like to do:

* A user registers with a name and an email or register with facebook.
He will receive an email to set his password.
* The user can now bookmark nodes. But when he would like to create a node of content type Proposal he needs to complete a full registration (I'm using Multi-step registration module). An email will be send to the administrator who needs to check the data and give the user a new role.

For now I have the second step. A user register with a complete form. But how can I add the facebook register or name/email register before it?

# Answer
Seems to me that you should consider the Profile2 module for getting this to work.

Excerpt from issue # 1796856 :

> Multi-Step Registration module works out of the box with Profile2 and all we need to do is assign the profile type to a particular step.

That same issue also contains some extra details about getting around possible access errors.

Refer to the Community documentation of Profile2 for more details about this module.
> 0 votes

---
Tags: 7, social-network, users
---


# Question
Title: Views with two content type and different fields in one table
I've got these two content types, A (2014) and B (2015), I'm tryging to combine in a view but content A needs field to view node and content B to edit node,

The view show the fields but it show both options edit and view for all contents.

My actual view

The view I would like to do

# Answer
> 1 votes
For things like this I use Views Conditional.
Work with the replacement variables and hide unused content.

# Answer
> 1 votes
Views Conditonal solved my problem

if content type A

```
<a href="node/[nid]/edit">2015.................................[edit_node]<span class="read"></span></a> <span class="read" style="margin-left:100px; text-align:right">[percentage]</span>

```

if content type B

```
<a href="node/[nid]">2014................................[view_node]<span class="read"></span></a>

```

---
Tags: views
---


# Question
Title: country based product price should be changed in commerce kickstart?
I have installed commerce kickstart. I have to add the two prices for single product.

> If Indian subscribers view the site means product price should display as 2000 INR.
>
> If other users visit the site means product price should display as $ 50.

How to identify the user whether view the site in India and other country and how to change the price also ? Anyone guide to me? Based on country how can i change the price also?

# Answer
> 2 votes
You can use IP based Determination of country module for identify the user ip address and the country.

You can use Commerce Multicurrency module for INR price field in the products content types.

By using Rules module to change the price for indian users

# Answer
> 1 votes
Commerce Multicurrency module can solve your issue.

This module enhances some of the multi-currency capabilities of Drupal Commerce.

> Current features:
>
> * UI for fine granular definition of exchange rates. (Every currency combination can be defined separately if needed)
> * Synchronization of currency exchange rates directly from the European Central Bank (ECB).
> * UI to specify which rates shall be synchronized and which are handled manually.
> * Generation of currency specific price fields inclusive generation of rule-set to handle them.
> * hooks for easy integration of custom currency exchange rate sources.

---
Tags: commerce, location
---


# Question
Title: How to display a customized button on a single form only?
I have created a reset button by adding a customized module (Reset) for webform. But this button gets displayed all over the site. I just want to display this button on a single webform.

Below is my Reset module code:

```
<?php
/*
 *
 *  creating  hook_form_alter()
 *
 */
function custom_example_form_alter(&$form,&$form_state,$form_id) {
            $form['webform_client_form_34'] = array(
            '#weight' => 1001,
            '#markup' =>'<input class="form-button" type="reset" value="Reset"/>',
            );
            return $form;
}

```

How should the if condition look like that I should be adding to it ?

# Answer
Find the form id first.

Assume your form id is 50 than,

```
function <module>_form_alter(&$form, $form_state, $form_id) {
  if (strpos($form_id, 'webform_client_form_50') === 0) {
    $form['actions']['reset'] = array(
      '#type' => 'button',
      '#value' => t('Reset'),
      '#weight' => 100,
      '#validate' => array(),
      '#attributes' => array('onclick' => 'this.form.reset(); return false;'),
    );
  }
}

```

OR

```
 if ($form_id == 'my_webform_client_form_id') {

Your code

}

```

---

Another method :-

In Drupal 7, you can either use hook\_form\_alter() or hook\_form\__alter(), which ever you prefer. Just make sure you get the naming and parameters right. Drupal 6 only supports hook\_form\_alter() however.

When you create these functions, also remember that Drupal may not always pick up on them until you've flushed the cache.

```
function mymodule_form_webform_client_form_44_alter(&$form, &$form_state) {
// code here;
}

```

Please remember to clear your cache also and try to disable/enable your module also
> 3 votes

# Answer
If you're using `hook_form_alter()` to do this, you need to have a if statement that looks at the form id that corresponds with your node. For example....

```
if ($form_id == 'webform_client_form_34') {
  $form['webform_client_form_34'] = array(
    '#weight' => 1001,
    '#markup' =>'<input class="form-button" type="reset" value="Reset"/>',
  );
}

```
> 2 votes

# Answer
To further complete/complement Shawn's answer (and the comment like "not working"), make sure you use the correct value for the `$form_id`.

To actually find this correct value, there are a few options, like:

* insert a line like `dpm($form_id);` in front of the if statement.
* use the Get Form ID module to easily find out form id of any form in Drupal, for which a video demo is available also. Here is a quote about it from its project page:

> By hovering over any form you will see a contextual link available. By expanding the link you will see the form ID. Click on the link and you will see a modal window with copyable form id and hook\_form\_FORM\_ID\_alter() hook suggestion.
* Use the improved and rebranded version of the (deprecated) Get Form ID module, which is the Devel form debug module, and for which a video demo is available. Here is a quote about it from its project page:

> By hovering over any form you will see a contextual link available. By expanding the link you will see the form ID. Click on the link and you will see a modal window with copyable form id and hook\_form\_FORM\_ID\_alter() hook suggestion.

After finding out the (for sure) correct value, I'd be curious if combining it with Shawn's answer you can get it to work ...
> 2 votes

---
Tags: webforms
---


# Question
Title: How do I exclude a single menu item from the sitemap?
In my sitemap, I am displaying main menu and footer menu, but as per requirement I don't want a specific menu item to display in the sitemap. My footer menu has following items:

* industrial
* mechanics
* sports

Is there a way not to add *mechanics* to the sitemap?

# Answer
Maybe you want to consider the approach described in comment # 1 in issue # 985138 (for D7), which is like so:

```
/**
* Override site_map function
*/
function hide_in_sitemap_preprocess_site_map(&$variables) {
  $mids = variable_get('site_map_show_menus', array());
  $output = '';
  if ($mids) {
    foreach ($mids as $mid) {
      $menu = menu_load($mid);
      // Use menu_tree_all_data to retrieve the expanded tree.
      $tree = menu_tree_all_data($mid);
        foreach ($tree as $branch => $value) {
          if ($value["link"]["options"]["hide_in_sitemap"]) {
            unset($tree[$branch]);
        }
      }

      if (module_exists('i18nmenu')) {
        i18nmenu_localize_tree($tree);
      }
      $menu_display = _site_map_menu_tree_output($tree);
      $rendered = drupal_render($menu_display);

      if (!empty($menu_display)) {
        $title = $menu['title'];
          $vars = array( 'title' => $title,
                        'content' => $rendered);
        $output .= theme('site_map_box', $vars);
      }
    }
  }
  $variables["menus"] = $output;
}

```
> 1 votes

# Answer
If you *just* don't want to ***display*** the link, a quick and dirty workaround with a little help from css could look like this:

```
li.menu-id_number  {
    display:none;
}

```

so for a page of content type "sitemap" and a menu link with an id number of "1234" this could look like this:

```
.page-sitemap li.menu-1234  {
    display:none;
}

```
> 1 votes

# Answer
You can do this by using Menu Item visibility module.

> This module exposes configurable and extendable visibility settings for menu links. For example, if you want to create a 'My account' link that points to /user, both anonymous and registered users have access to the /user path, so both will see the link, even if anonymous users do not technically have an account. Using this module will allow you to only have your 'My account' link visible to registered users, and hide it from anonymous users.
> 0 votes

---
Tags: 7, navigation
---


# Question
Title: How to add secondary exposed form elements using "Better exposed module" in views
I just want to know how to add elements like another exposed filter in this advanced tabs.Currently it is empty.

# Answer
> 0 votes
Below the field which will be secondary open **MORE OPTIONS** and check **This is a secondary option** check box and save.

After that, it will display in Advanced

---
Tags: views
---


title: Looking for a SEO plugin for Drupal

text:
# Question
Title: Looking for a SEO plugin for Drupal
For my internship I could use some help with the optimization for search engines.

Are there any plugins that will help me increase the SEO performance of the website im trying to optimize? So far I only found a checklist but thats not what im looking for. Wordpress has a Yoast plugin that checks every move I make to optimize it for search engines. Does Drupal have a similar plugin?

# Answer
> 1 votes
I thought the following was a bit like Yoast . SEO Compliance Checker - https://www.drupal.org/project/seo\_checker

Once downloaded install and enable.

SEO Checklist

Basic SEO Modules

Keyword Rules

Then go to configuration .

Once those modules have been enabled you’ll then have a nice set of Sliders to use in the ‘Thresholds for the SEO Rules’ box.
Set up your sliders depending on what the recommended levels are at the time.
From here you’ll then need to visit the Article that you want to optimise .

> Click on PREVIEW

The Keywords are taken from 'tags' .

---
Tags: 7
---


# Question
Title: Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration
I'm trying to deploy an instance of Drupal with Cloud Foundry. Everything loads up and seems to start correctly, but when I try to hit the page I get the following error in the logs.

> ../.htaccess: Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration

I'm using cloudfoundry/php-buildpack.

I was able to get the app to load the install page and run by commenting out this line in the .htaccess file.

```
Order allow,deny

```

However, I feel like this may cause security issues, and I really want a better fix to this issue.

# Answer
> 0 votes
PHP buildpack is currently using Apache HTTP Server 2.4. You see that error message because the Order directive has been deprecated in Apache HTTP Server 2.4.

You can either:

### Update the configuration file for Apache HTTP Server 2.4

Instructions for migrating can be found on Upgrading to 2.4 from 2.2.

### Enable the mod\_access\_compat module for Apache HTTP Server 2.4

This will allow you to keep using the older configuration style. To do this, you should copy this file from the build pack, place it in the root of your project directory under .bp-config/httpd/extra/httpd-modules.conf, and uncomment line #27. When you push, the build pack will detect all the enabled modules; include mod\_access\_compat from the configuration file and enable them.

# Answer
> 0 votes
The error is due to changes beetween Apache 2.2 and 2.4. 'Order' is deprecated. Solution is described here: https://systembash.com/apache-2-4-upgrade-and-the-invalid-command-order-error/

---
Tags: 7
---


title: Drupal 6 and Varnish Cache

text:
# Question
Title: Drupal 6 and Varnish Cache
Is Pressflow really required for Varnish? I ask because I've set up Varnish on my server with drupal 6.30 standard, and installed the Varnish module, and it's sped up my website no end. Really amazing speed results here, and I'm getting plenty of cache hits.

So my question, what's different about the Pressflow install, and why is it required for Varnish?

# Answer
Varnish and Pressflow are two different things.. Pressflow uses varnish to improve performance.. More details goes below..

Pressflow is “a derivative of Drupal core providing enhanced performance, scalability, and data integrity”. Basically, some really smart guys at Four Kitchens and elsewhere back-ported a bunch of Drupal 7 performance enhancements to the Drupal 6 (and even Drupal 5!) code base.

Pressflow adds the following features to Drupal.

* Support for database replication
* Support for Squid and Varnish reverse proxy caching
* Optimization for MySQL
* Optimization for PHP 5

What: Varnish is an HTTP accelerator and caching reverse proxy. Varnish is all about speed. It stores as much content as it can in the fastest place possible – RAM in this case – and bypasses the expensive process of making a request to Apache.

Why: Pressflow structures the Drupal content to be more cache-friendly, but we still need something to actually cache the content.

How: Varnish sits in front of Apache, accepts incoming connections from browsers and, if possible, fulfills the requests from its cache. If it can’t, it passes the request on to the underlying Apache/PHP stack. It then takes the response from Apache and forwards it on to the requesting browser. If the response from Apache is cacheable, Varnish stores it in RAM for fulfilling future requests.
> 3 votes

# Answer
Hmm. According to the Varnish documentation: Varnish and Drupal:

> Using Varnish with Drupal prior to version 7 will require the use of Pressflow, which backports Drupal 7's lazy session creation and other important performance enhancement. Without this, Drupal will create a PHP session cookie for all users, meaning Varnish is reduced to caching static files only.

This seems to contradict the statements made in the answers in this thread.
> 1 votes

---
Tags: caching, proxies, 6
---


# Question
Title: Custom page template for specific node - template inheritance
I'm trying to customize the page template for a specific node of a specific content type. This is what I have: Content type: Custom Page Node ID: 2

First, I need to customize all 'Custom Page' content nodes so I created a custom page template for them: page--custom-page.tpl.php

Then, I also need to customize a specific 'Custom Page' node so I created a custom page template for it too: page--node--2.tpl.php

But when I visit the node 2 page it is using the Custom Page (page--custom-page.tpl.php) template and not the page template I created specifically for that node.

How can I make the custom page template for that node work?

# Answer
Templates are chosen based on the other that they are in the `$variables['theme_hook_suggestions']` array.

So if you have a list:

```
page.tpl.php
page--node.tpl.php
page--node--1.tpl.php
page--node--edit.tpl.php

```

Then it will look from the bottom up and use the first template it finds.

From Drupal 7 Template (Theme Hook) Suggestions:

> When the page is actually rendered, the last suggestion is checked. If it exists, that suggestion is used. Otherwise the next suggestion up is checked, and so on. Of course, if none of the overriding suggestions exist, page.tpl.php is the final suggestion. This also explains why page--front.tpl.php, if it exists, overrides any other suggestion for the front page: it is always the last suggestion for the page designated as the front page.

Because you have custom code (I'm assuming your code here) that adds a tempalte suggestion to the end of that like this:

```
$variables['theme_hook_suggestions'][] = 'page__custom_page';

```

Then that suggestion is added to the end of the list, so will override all previous ones if it is present.

If you want to have different template precedence then you have to make the hook suggestions array use that order.

There are a number of ways you can do this and it depends what you want to achieve as to how you want to do it.

If you want your template to be last in the template precedence (first in the array) then you can do this:

```
array_unshift($variables['theme_hook_suggestions'], 'page__custom_page');

```

Other than that you can also use other PHP array manipulation functions to insert your suggestion in the middle of the array, or you could add your suggestion to the end, then add other suggestions after it again (it doesn't matter if a suggestion is in the array multiple times, the first time it is checked it will be used).
> 2 votes

# Answer
So, this is how I accomplished what I needed.

The template that I'm using is calling the theme\_preprocess\_page hook in the templates.php file to allow custom page templates per content type:

```
function myTheme_preprocess_page(&$variables) {
  if (!empty($variables['node'])) {
    $variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type;
  }
}

```

So if I have a content type with the machine name of `custom_page`, I can place a template named `page--custom-page.tpl.php` in the myTheme/templates directory to target those content types.

Then, to target a specific node (which in may case is node **15**) I added the following code to the function:

```
if(arg(1) == 15) {
  $variables['theme_hook_suggestions'][] = 'page__myCustomNode';
}

```

And created a page template named: `page--myCustomNode.tpl.php` and placed it in myTheme/templates directory.

This allowed me to have a custom page template for all **custom-page** content types, and a custom page template specifically for node 15, of the same content type.

The complete function looks like this:

```
function myTheme_preprocess_page(&$variables) {
  if (!empty($variables['node'])) {
    $variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type;
  }
  if(arg(1) == 15) {
    $variables['theme_hook_suggestions'][] = 'page__myCustomNode';
  }
}

```

I hope this helps someone needing to do the same!

If there is a better way of accomplishing this, please post it here! Thanks!!!
> 0 votes

# Answer
I realize this is quite an old question, but recently I found myself having to do this enough times that I wrote a module that provides the ability to specify custom page.tpl.php and node.tpl.php files for individual nodes.

The code within the module uses the techniques already mentioned here, so it just makes the process a bit less complicated. You still have to create the template files yourself, but no template.php file modifications are necessary:

https://www.drupal.org/project/cts
> 0 votes

---
Tags: 7, theming, nodes
---