# Question
Title: How to modify and the location of modified hook_form_FORM_ID_alter?
I am learning to add a checkbox to registration form about agreeing to terms of use, found in `modules/system/system.api.php`, line 1708

I found an information here in modifying the hook\_form\_FORM\_ID\_alter here How to display the values after submit in drupal 7

I modified the file `modules/system/system.api.php` as instructed (FORM\_ID) changed to my form id, but nothing happens.

Could anyone provide a direction how to do that?

# Answer
> 1 votes
Dump! You did a big mistake! Never modify the core! You can use hook system

# Answer
> 1 votes
.api.php files are files that give developers information on the function and hooks that a module makes available to others.

So modules/system/system.api.php is just developer information on Drupal system module API type functions.

It is basically just documentation so you editing it will do nothing (except for then making that documentation incorrect, which is bad if anyone else wants to use it).

To properly implement a hook you need to create a custom module that implements that hook.

For example you might create a module called customregistration and then you might implement this:

```
/**
 * Implements hook_form_alter().
 */
function customregistration_form_alter(&$form, &$form_state, $form_id) {
  // Put your code here to alter the form.
}

```

For some form alter examples see Hook snippets: hook\_form\_alter.

It would be also very much worth your while to do some basic learning about writing drupal modules.

There are lots of good affordable textbooks and there are also pages like the Module developer's guide (and all it's child pages) and modules like Examples for Developers that all have useful information.

There is a lot of information but cutting corners on initial learning will possibly come back to haunt you in future.

---
Tags: 7, forms
---


# Question
Title: Notice: Undefined property: stdClass::$field imce drupal
I'm in trouble so maybe someone can figure it out: I'm trying to have singular folder for every user in imce (drupal7) and I want that the folder is a code that I can insert with a field in user profile. (like 78M4589)

well, this code generate the folder in the right place:

```
return 'users/'.$user->field_code['und'][0]['value'];

```

but in imce on the page i have this notice:

> Notice: Undefined property: stdClass::$field\_code in eval() (linea 1 di () : eval()'d code).

I really can't figure it out.

# Answer
The global $user object is not guaranteed to have all the fields loaded onto it.

Try specifically loading the user like this:

```
global $user;
// Load the full user object.
$account = user_load($user->uid);
// Get the user code.
$code = '';
if ($items = field_get_items('user', $account, 'field_code')) {
  $code = $items[0]['value'];
}
return $code;

```
> 1 votes

---
Tags: files
---


# Question
Title: Display a node form in default theme for admin
I think this question has been asked many times, but I am sorry not to find a working solution. May be I am doing something wrong. I want to display a specific node form in my default custom theme and not in the admin theme when the administrator logs in. However, other node forms should continue to display in the admin theme. Hence the "Use the administration theme when editing or creating content " should be checked.

I have tried the themekey module. I came across that there's something called themekey compatibility by which this can be achieved. But I fail to find an example.

I want the default theme for a specific content type. Also I tried the followings: hook\_custom\_theme & hook\_theme\_init as described in How to change the theme for a particular admin page in drupal?

Thanks

# Answer
> 2 votes
There is a hook that you can use to set which pages use the admin theme and which don't.

The hook is hook\_admin\_paths().

The node module uses this hook to provide the functionaity where you can set node forms to use the admin theme (see node\_admin\_paths()).

If you wanted to set certain paths to use the admin them (or not use it) you could implement that hook, however if you want to change admin paths that another module has already defined you need to use hook\_admin\_paths\_alter().

In this case the node module defines a wild card path for all node add pages like this `'node/add/*' => TRUE`

Since you only care about a specific node type you can ignore that and do this:

```
/**
 * Implements hook_admin_paths().
 */
function MODULENAME_admin_paths() {
  // We have configured the site to use the admin theme for node forms
  // however we want the article content type to use the default theme
  // instead of the admin theme.
  $paths = array(
    'node/add/article' => FALSE,
  );
  return $paths;
}

```

As you can see in path\_is\_admin(), where the check is done to see if the current page is an admin page, for a page to be an admin page it must have a matching path that is TRUE and also not have one that is FALSE. So by adding this FALSE in for this specific page you are overriding the wildcard node/add/\* from the node module.

The problem that you then have is the node edit page (if you also want that to use the same theme as the node add form), because the URL for the node edit page has nothing in it that relates to the content type so you can't override node edit pages based on their type.

You could get the node IDs of all nodes of your specific type and add each individual node edit path however if you have a large number of nodes that is not going to be ideal.

---
Tags: theming
---


title: How do I pass local settings?

text:
# Question
Title: How do I pass local settings?
The documentation on Drupal.behaviours suggests that local settings can be passed to Drupal's JavaScript behaviors.

Rather than hard coding my series data into my function:

```
series: [{
    name: 'Jane',
    data: [1, 5, 4]
}, {
    name: 'John',
    data: [3, 1, 2]
}]

```

how can I pass this series data to my function as settings, directly after the context?

JS code (my\_highcharts.js)

```
(function ($) {

Drupal.behaviors.my_highcharts = {
  attach: function (context, settings) {
    $('#drupal_behaviours').highcharts({
      chart: {
          type: 'bar'
      },
      title: {
          text: 'Drupal.behaviors'
      },
      colors: ['#50b432', '#ed561b'],
      xAxis: {
          categories: ['Apples', 'Bananas', 'Oranges']
      },
      yAxis: {
          title: {
              text: 'Fruit eaten'
          }
      },
      series: [{
          name: 'Jane',
          data: [1, 5, 4]
      }, {
          name: 'John',
          data: [3, 1, 2]
      }]
    });
  }
};

})(jQuery);

```

Module code

```
drupal_add_js(drupal_get_path('module', 'my_highcharts') . '/highcharts.js');
return array('#markup' => '<div id="drupal_behaviours" style="width:100%; height:400px;"></div>');

```

# Answer
For one thing I would suggest no using #drupal\_behaviours as a HTML element ID because it doesn't describe that element in any way.

It would more logically be called #chart or #highchart or something like that.

To add settings you can use drupal\_add\_js() (there are examples on that docs page) like this (in your custom module in PHP):

```
// add the series' to a javascript setting.
$series = array(
  array(
    'name' => 'Jane',
    'data' => array(1, 5, 4),
  ),
  array(
    'name' => 'John',
    'data' => array(3, 1, 2),
  ),
);
drupal_add_js(array(
  'moduleName' => array(
    'series' => $series
  )
), 'setting');

```

Then in the js you can access it like this:

```
(function ($) {

Drupal.behaviors.my_highcharts = {
  attach: function (context, settings) {
    $('#drupal_behaviours').highcharts({
      chart: {
          type: 'bar'
      },
      title: {
          text: 'Drupal.behaviors'
      },
      colors: ['#50b432', '#ed561b'],
      xAxis: {
          categories: ['Apples', 'Bananas', 'Oranges']
      },
      yAxis: {
          title: {
              text: 'Fruit eaten'
          }
      },
      series: settings.moduleName.series
    });
  }
};

})(jQuery);

```

Note how the settings object in the javascript mimics what you passed into drupal\_add\_js().
> 2 votes

---
Tags: javascript
---


title: Alternative to Field Collection

text:
# Question
Title: Alternative to Field Collection
Does anyone know an alternative to the module "field collection" ?

While the concept of field collection is very good, I'm having trouble with the collaboration of other modules, like e.g. features or search api. So I'm looking for alternatives.

# Answer
See the Multifield module.

> This project seeks to provide a true compound field solution for Drupal 7. As much as I love Field collection, it still has to save actual entities, and can cause performance problems due to having to load all the referenced field collection entities on node, or parent entity load.

I am not sure of its compatibility with Features or Search API though.
> 11 votes

# Answer
Try the Paragraphs module, it integrates with Search API and Features.
> 10 votes

# Answer
You could consider creating a new content type to represent the collection and then using Inline Entity Form to allow creation of the 'collection' inside of the content type referencing it. See: Inline Entity Form.
> 5 votes

---
Tags: entities
---


title: preserve format of node body

text:
# Question
Title: preserve format of node body
for output display I used http://foundation.zurb.com/docs/components/accordion.html

**I have the following code**:

```
 <section id="main-content">
<dl class="row accordion" data-accordion>
<h2 style="text-transform: uppercase;"><b>About Us</b></h2><br/>
<?php foreach ($view->result as $key => $value) {?>
<img class="media-object" src="<?php print $GLOBALS['base_path']."sites/default/files/about/thumbnails/".$value->_field_data['nid']['entity']->field_about_us_image['und'][0]['filename'];?>" alt="">
    <h2><?php echo $value->node_title;?></h2>
  <dd class="accordion-navigation">
    <a href="#pane<?php print $key;?>">
    <?php print $value->_field_data['nid']['entity']->body['und'][0]['summary'];?>...</a>
    <div id="pane<?php print $key;?>" class="content">
     <?php print $value->_field_data['nid']['entity']->body['und'][0]['value'];?></a>
    </div>
  </dd>
  <hr>
  <?php } ?>
</dl>
</section>

```

I want to preserve the format `HTML` of

```
<?php print $value->_field_data['nid']['entity']->body['und'][0]['summary'];?>

```

and

```
<?php print $value->_field_data['nid']['entity']->body['und'][0]['value'];?>

```

How Can I achieve this with Drupal 7?

# Answer
Are you talking about the spacing in the html itself? So the code looks visibly nested? Such as:

```
<div>
   <div>
      <div>
         something
      </div>
   </div>
</div>

```

If that's the case, you might want to try a WYSIWYG and add WYSIWYG CodeMagic
> 0 votes

---
Tags: views, theming, entities
---


# Question
Title: How to create Subtheme of Omega while Omega Tools and Drush both has some disclaimer and Moved to Github?
I am a beginner in Drupal. I am using Drupal 7.

I wanted to create Subtheme in Omega. Theses are the methods to create subtheme (With Omega Tools, Drush and Manually)in Omega.

I have install new core Drupal and installed Omega in my sites/all/themes folder. So, path for this would be:

"../sites/all/themes/omega"

I followed this Tutorial to create Subtheme using Omega Tools (As this is recommended for Beginners). Omega Tools is one of the Recommended Modules to create sub theme with Omega.

In Omega Tools there is one **DISCLAIMER:**

"**DISCLAIMER:** Do **not** use Omega Tools with the 4.x version of Omega. Please

* **create your 4.x subthemes using Drush!**

The Drush integration for Omega 4.x comes as part of the theme itself and does NOT require Omega Tools. Please uninstall Omega Tools if you are building a site with Omega 4.x."

So, this message leads me to the Drush where I saw the Drush project has moved to Github.

And theses are the Release Notes.

I read that we can also create sub theme with this method.

Thanks for your help!

# Answer
I'm speculating a bit, but Drush surely moved to github from the project page on d.o because it simply isn't a module. It is:

> a command-line shell and scripting interface for Drupal

So if you're thinking it's a module that needs be installed and enabled in your site, it isn't. It's a separate utility that needs to be installed on your machine.

You're absolutely right to want to stick with getting it installed for working with Omega, it does make life a lot easier. You can do so by following the detailed instructions on the github page.

There are also a bunch of questions in the tag that should help if you get stuck.
> 2 votes

# Answer
@Clive: First of all thanks for the useful information. As I am new to Drupal, I thought it was a module but thanks for clearing my doubts.

Yes, Drush is an amazing tool even though installing Drush for the first time is such a pain.

Here is some informations that might be helpful for those who might stuck like me in the future. I followed tutorial from this site to install Drush.

It is really very easy to create subtheme in omega using Drush. How to create subtheme in Omega.

File structure for the Subtheme is in: sites/all/themes OR sites/all/themes/omega.

These two links were also helpful to me to create subtheme:

1. Overview of Theme Files
2. Creating a Subtheme

Thanks!
> 0 votes

---
Tags: drush, theming
---


title: Entity Reference on multilingual sites

text:
# Question
Title: Entity Reference on multilingual sites
I am having a problem with getting Entity Reference to behave with a multilingual Drupal 7 installation using field translation (Entity Translation).

I have a node called 'Features' which has a bunch of dummy content entered in the default English and also in French. I have another node called 'Products' with an Entity Reference field in it for selecting the features.

So far so good, on the English form I see what I expect; I can select some of the references and save out.

When I create a French translation though, I see the following form:

I don't see any of the entities when creating or editing a French translation. Now, this in itself isn't a problem (for me) because the same selections should be made across all translations, but when I go ahead and save the French version, it will deselect all of the references in the English version of the node too.

Might I be missing something obvious with this? Is this expected behavior?

# Answer
While this doesn't answer the behavior of the Entity Reference fields over different languages, switching the entity selection mode to a view seems to have solved it.

As suggested by Lester, I'm still unsure if the default 'Simple' selection mode was taking issue with the title of my fields, although rather than using the Title module - which can trip up other modules, i have found - I tend to keep the old title field and label it 'Administrative title' while adding a separate 'Translatable title' to work with - so in that sense there shouldn't have been an issue with the 'Simple' selection method.

Either way, setting up an Entity Reference View which displays and searches the 'Translatable title' of my Features node seems to have worked!

---

EDIT:

@Dan - these labels, are they node titles or fields which you created?

The issue with standard node titles is that they are different from other fields and as such are not 'entities' - this means that entity translation will not work on them. The workaround is to either use the Title module to replace the default title field with an entity (I had some issues with this), or use a different field which you create yourself.

Once the field you need to translate is an 'entity' (basically an field you create yourself, or one generated by the Title module) you can enable translation for it when adding the field to a content type.

Next you need to create a new view containing whatever content you want to use and click the + button to add an 'entity reference view'. After configuring this view with the fields you want to display and saving you should find that when editing the Entity Reference field in your content type, you can change the Entity selection mode to Views and select your newly created view.

I hope that makes sense!
> 1 votes

# Answer
If you have enabled the i18n\_taxonomy module disable it.

The problem is i18n\_taxonomy tries to fill the available options, but no options are available by the i18n point of view because the use of two modules for transaltion.

So, again, disable i18n\_taxonomy, or go ahead with this module and disable entity translation for taxonomy terms.

I've just come across exactly your behavior and at least, in my case was for having this two modules enabled.
> 1 votes

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


# Question
Title: Syntaxhighlighter Insert do not working with CKEditor 4
CKEditor 4 Drupal Module do not depend on Wysiwyg module, so after configuring Syntaxhighlighter Insert module i can not understand how to have the "Insert Code" button in CKEditor, because in CKEditor Plugins section there is no option to enable the button! if you follow this article (http://jordanjr.com/articles/drupal-7-syntax-highlighting-using-wysiwyg-ckeditor-and-syntax-highlighter) then you will see that they need wysiywg module, but now CKEditor do not need wysiywg module!.. any idea to solve this? here is the screenshot:

# Answer
It's simple - switch to WYSIWYG module and install CKEditor as library. CKEditor module and WYSIWYG module are separated projects that happens to use the same library, so if you want to use modules and articles designed to work with WYSIWYG, you need WYSIWYG.
> 2 votes

# Answer
You can use codesnippet plugin for CKEditor and then in your Syntax Highlighter module settings change "pre" to "code". Use codesnippet plugin to enter your code and then change to source mode and change to where php is the language you are using so it could be css or jscript as well. Then just save and you'll have Syntax highlighter markup on target page. Unfortunately this is a workaround so either change CKEditor settings not to load on default so that the Syntax Highlighter classes are not lost or, repeat the process on each edit. We had a working codemirror plugin but it seems to have broken in CKEditor v 4.4.5 so, fingers crossed that becomes part of the standard setup in the next CKEditor module version.
> 0 votes

---
Tags: 7, wysiwyg
---


# Question
Title: Show all taxonomy terms on taxonomy term page
Though I saw a lot of posts on views & terms, this is new it seems.

I have a set of 1-level vocabularies. When user is on term page

```
mysite.com/vocabulary1/term1/

```

He should see also 'menu' - list of all terms of this vocabulary.

How can it be achieved?

P.S. I think that it's about context filters but I can't figure out how!

# Answer
> 0 votes
There are couple of modules to solve this purpose

Here is the config page of taxonomy menu block module

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


# Question
Title: Template.php - Hiding Specific Element on Node Edit
Drupal 7

Say I have a custom element being rendered out on my page.tpl.php (say it's named `$custom_element` in the below example), but this is also showing up on the **Node Edit page** because I want this user to *not use the admin theme* to edit Nodes but just same theme the front end is using to edit Nodes.

What hook do I use to hide this element when the user is editing the node? What's the best approach in this?

**My template.php file**

```
function mytheme_preprocess_page(&$vars, $hook) {
  if (in_array('page__mypagetype', $vars['theme_hook_suggestions'])) {
    $vars['custom_element'] = my_custom_element();
  }
}

```

Sorry if this doesn't make sense. I'm not sure I'm using the proper wording. Basically trying to figure out how to say "Drupal, while the user in logged in and editing these nodes, please don't show this element on the node edit page since it's printed in the page.tpl.php".

I know this can be done by creating a `page--node--edit.tpl.php` page. But isn't there a way to do this via a hook in the `template.php`?

# Answer
As fast solution, verify the value returned from `arg(2)` is different from `'edit'`.

```
   function mytheme_preprocess_page(&$vars, $hook) {
      if (in_array('page__mypagetype', $vars['theme_hook_suggestions']) && arg(2) != 'edit) {
        $vars['custom_element'] = my_custom_element();
      }
    }

```
> 2 votes

---
Tags: 7, theming
---


# Question
Title: Custom Views Relationship with Custom Entity
I have custom entity with just a base table and it is referenced with the node with its field field\_a. Now I want to create the relationship between these two entities (node and my custom entity). I can get the result working but I am not getting the node fields listed in the views field section.

// Base table for custom entity is "clinical\_trial\_research\_sites"

```
function clinical_trial_views_data_alter(&$data) {
 $data['clinical_trial_research_sites']['node'] = array(
    'title' => t('Clinical Trial'),
    'help' => t('Field Reference Appear in Location Content type.'),
    // Information of the referenced table!!
    'relationship' => array(
      'handler' => 'views_handler_relationship',
      'label' => t('Location'),
      'base' => 'field_data_field_site_comp_code', // node field table name
      'base field' => 'field_site_comp_code_value', // field column name of node field
      'relationship field' => 'site_comp_code', // This is referencing field in my custom entity
    ),
  );
}

```

I can get the sql working , inner join working but views is not listing all the fields of the node as I want to display the some of the fields from the nodes too!!. I think I am missing some information to tell the views that realtionship is not only field table but with the node as a whole!!

# Answer
I fixed it by copying some of the code from the entityreference. I have to use a different views handler for this relationship and add other attributes to that relationship

```
function clinical_trial_views_data_alter(&$data) {

  $data['clinical_trial_research']['clinical_trial_research_sites'] = array(
    'title' => t('Clinical Trial Research Sites'),
    'help' => t('Field Reference Appear in Clinical Trial Research Sites.'),
    'relationship' => array(
      'handler' => 'views_handler_relationship',
      'label' => t('Clinical Trial Research Sites'),
      'base' => 'clinical_trial_research_sites',
      'base field' => 'study_num',
      'relationship field' => 'study_num',
    ),
  );
  // The reference field in the node entity is not entity reference , its just a basic text field
  $data['clinical_trial_research_sites']['site_comp_code']['relationship'] = array(
    'handler' => 'views_handler_relationship_entity_reverse',
    'field_name' => 'field_site_comp_code',
    'field table' => 'field_data_field_site_comp_code',
    'field field' => "field_site_comp_code_value",
    'base' => 'node',
    'base field' => 'nid',
    'title' => t('Referencing entity'),
    'help' => t('Field Reference Appear in Location Content type.'),
    'title' => t('Location'),
  );
}

```
> 0 votes

---
Tags: views
---


# Question
Title: Limit a user to edit AND view only a specific content type?
I have a role dedicated to creating and/or editing a specific content type. It is the only activity to be allowed for this role.

I have set up login destinations module to go to the content overview and it pretty much works fine. Users can only edit the allowed content type and when they add content, they immediately get the content type they are allowed to use.

The issue is that I want the user in this role to ONLY see the content type they are allowed to modify. Currently, it lists all the nodes, which will be confusing for the folks using this role.

Any ideas on a way to use the content overview screen and limit the nodes viewable?

Thanks in advance.

# Answer
> 1 votes
If you have to control the list of content where they go to find content to edit, then you should use VIEWS & make list of only those content which they have permission to edit. Set a page for that list & navigate them there. It's pretty easy..

But if you want to restrict full content type for viewing then you can use Content Access module for that.

# Answer
> 0 votes
You can try Access Control Lists.

> The ACL module, short for **Access Control Lists**, is an API for other modules to create lists of users and give them access to nodes. It has no UI of its own and will not do anything by itself; install this module only if some other module tells you to.

# Answer
> 0 votes
Ok, depending on how many roles you have & how many content types they are allowed to use you can simply create ::

The content types to fit each particular role so when each ROLE TYPE adds content they could only see their Corresponding CONTENT TYPE nodes respectively..

this can be done using::

Permissions Roles Content type

It will leave a messy back end if you have tons of roles & content types but if their is only 2-3 it should be the easiest & simplest way..!

---
Tags: users, nodes
---


title: Drupal Commerce permission

text:
# Question
Title: Drupal Commerce permission
I've just noticed that the anonymous user can add staff to the cart but they cannot see the block. Also, I've create a display content view and anonymous users cannot see it.

I've tried to find the right permission but there is not a permission tutorial.

Is anyone has got experience with it?

I would like to leave anonymous users use the cart but then login once they have to pay.

How do i get it?

The problem comes when I add, in the view, the relationship with the product.

Thanks in advance

# Answer
> 2 votes
Two places that come to mind on the Permissions page (/admin/people/permissions) are:

* Under **Checkout**, look for *Access checkout*
* Under **Order**, look for *View own orders of any type*

# Answer
> 2 votes
I've just noticed that the problem comes when I add, in the view, the relationship with the product. Anonymous users cannot see it.

# Answer
> 2 votes
With respect to the view, under advanced make sure that SQL is NOT rewritten. This is a common reason why views won't work for Anon users.

# Answer
> 0 votes
I checked the "Require this relationship" option on the product relationship in the view, saved, and now the view shows items to anonymous users.

---
Tags: commerce, users
---


title: Basic "empty" entity type?

text:
# Question
Title: Basic "empty" entity type?
Is there a module that provides an empty entity, to which I can add my own fields. I guess it would include just an Entity-ID as a primary field, and work with other entity modules.

For me, nodes have too much baggage included: title, nid, vid, publishing options, author and date.

# Answer
> 0 votes
You should really check out the Console project. https://www.drupal.org/project/console

It allows for command line creation of modules, and will generate entities for your module.

Here's a video explaining it all in 5 minutes.

https://www.youtube.com/watch?v=agcqTEr5\_48

navigate to the modules directory in the drupal root in your command line tool

enter command: bin/console generate:module enter the name for your module

enter a machine name for your module hit enter for the default path

enter a description hit enter for defaults for rest of questions

enter command: bin/console generate:entity:content

enter the name of the module you just created

enter a class name for the Entity you are creating

---
Tags: 8, entities
---


# Question
Title: Drush site-upgrade : "Unknown option: --uninstall"
I'm trying to upgrade a Drupal site from 6.34 to 7.x using Drush. When I run `drush site-upgrade @alias`, everything goes well until step 12-a where it ends up throwing this error :

```
Unknown option: --uninstall.  See `drush help pm-disable` for available options. To suppress this error, add the option --strict=0.

```

I made some search about this and tried a few things :

`$options['strict'] = FALSE;`

* In that same drushrc file, I added this line :

`$command_specific['pm-disable'] = array('strict' => 0);`

This solution was proposed here : https://www.drupal.org/node/2074781

`alias drush='drush --strict=0'`

Neither of these solutions helped, I always get the same error.

```
OS: Ubuntu 14.10
Drush : 6.2.0
PHP: 5.5.12-2ubuntu4.1 (cli)

```

# Answer
My Drush configuration file was simply misplaced, I had to put it in Drupal's directory (sites/all/drush/drushrc.php) rather than ~/.drush/

When running `drush status` from your Drupal source site directory, make sure there is a Drush configuration loaded.

```
Drush version                   :  6.2.0
Drush configuration             :  /var/www/html/drupal/sites/all/drush/drushrc.php
Drush alias files               :  /root/.drush/my.alias.drushrc.php

```

And here is the content of file sites/all/drush/drushrc.php

```
<?php
$options['strict'] = FALSE;

```
> 4 votes

---
Tags: drush, updating
---


# Question
Title: Domain/theme name suddenly appearing in all links
I noticed that all my in-site links now have my domain/theme name inserted after the domain. For example:

www.mydomain.com/mydomain/calendar
www.mydomain/com/mydomain/events

It used to be:

www.mydomain.com/calendar
www.mydomain/com/events

The new links still work, but they don't look very clean.

I don't know what is causing this or where to begin troubleshooting. I don't see anything in the Path module's patterns that would cause this. Should I be looking for a cause in .htaccess or settings.php (.htaccess hasn't been touched in months.)?

Could it be a module? Here's what currently enabled:

```
# drush pm-list --type=Module --status=enabled
 Package                      Name                                                    Version
 Administration               Administration menu (admin_menu)                        7.x-3.0-rc4
 Administration               Administration menu Toolbar style (admin_menu_toolbar)  7.x-3.0-rc4
 Chaos tool suite             Chaos tools (ctools)                                    7.x-1.4
 Chaos tool suite             Custom content panes (ctools_custom_content)            7.x-1.4
 Chaos tool suite             Page manager (page_manager)                             7.x-1.4
 Commerce                     Cart (commerce_cart)                                    7.x-1.10
 Commerce                     Checkout (commerce_checkout)                            7.x-1.10
 Commerce                     Commerce (commerce)                                     7.x-1.10
 Commerce                     Commerce UI (commerce_ui)                               7.x-1.10
 Commerce                     Customer (commerce_customer)                            7.x-1.10
 Commerce                     Line Item (commerce_line_item)                          7.x-1.10
 Commerce                     Order (commerce_order)                                  7.x-1.10
 Commerce                     Payment (commerce_payment)                              7.x-1.10
 Commerce                     Price (commerce_price)                                  7.x-1.10
 Commerce                     Product (commerce_product)                              7.x-1.10
 Commerce                     Product Pricing (commerce_product_pricing)              7.x-1.10
 Commerce                     Product Reference (commerce_product_reference)          7.x-1.10
 Commerce                     Tax (commerce_tax)                                      7.x-1.10
 Commerce                     Tax UI (commerce_tax_ui)                                7.x-1.10
 Commerce (payment)           First Data Global Gateway e4 (commerce_firstdata_gge4)  7.x-1.0
 Commerce (payment)           First Data Global Gateway e4 Hosted Payment Pages       7.x-1.0
                              (commerce_firstdata_gge4_hpp)
 Contact Forms                Contact Forms (contact_forms)                           7.x-1.8
 Core                         Block (block)                                           7.32
 Core                         Blog (blog)                                             7.32
 Core                         Contact (contact)                                       7.32
 Core                         Database logging (dblog)                                7.32
 Core                         Field (field)                                           7.32
 Core                         Field SQL storage (field_sql_storage)                   7.32
 Core                         File (file)                                             7.32
 Core                         Filter (filter)                                         7.32
 Core                         Image (image)                                           7.32
 Core                         List (list)                                             7.32
 Core                         Menu (menu)                                             7.32
 Core                         Node (node)                                             7.32
 Core                         Number (number)                                         7.32
 Core                         Options (options)                                       7.32
 Core                         Path (path)                                             7.32
 Core                         PHP filter (php)                                        7.32
 Core                         Search (search)                                         7.32
 Core                         System (system)                                         7.32
 Core                         Taxonomy (taxonomy)                                     7.32
 Core                         Text (text)                                             7.32
 Core                         Update manager (update)                                 7.32
 Core                         User (user)                                             7.32
 Date/Time                    Date (date)                                             7.x-2.8
 Date/Time                    Date All Day (date_all_day)                             7.x-2.8
 Date/Time                    Date API (date_api)                                     7.x-2.8
 Date/Time                    Date Popup (date_popup)                                 7.x-2.8
 Date/Time                    Date Repeat API (date_repeat)                           7.x-2.8
 Date/Time                    Date Repeat Field (date_repeat_field)                   7.x-2.8
 Date/Time                    Date Tools (date_tools)                                 7.x-2.8
 Date/Time                    Date Views (date_views)                                 7.x-2.8
 Drupal for Facebook          Facebook API (fb)                                       7.x-3.4
 Drupal for Facebook          Facebook Apps (fb_app)                                  7.x-3.4
 Features                     Features (features)                                     7.x-2.2
 Features extra               FE Block (fe_block)                                     7.x-1.0-beta1
 Feeds                        Feeds (feeds)                                           7.x-2.0-alpha8
 Feeds                        Feeds Admin UI (feeds_ui)                               7.x-2.0-alpha8
 Feeds                        Feeds Import (feeds_import)                             7.x-2.0-alpha8
 Feeds                        Feeds XPath Parser (feeds_xpathparser)                  7.x-1.0-beta4
 Fields                       Address Field (addressfield)                            7.x-1.0-beta5
 Fields                       Conditional Fields (conditional_fields)                 7.x-3.0-alpha1
 Fields                       Link (link)                                             7.x-1.2
 Flickr                       Flickr (flickr)                                         7.x-1.6
 Flickr                       Flickr Block (flickr_block)                             7.x-1.6
 Flickr                       Flickr Filter (flickr_filter)                           7.x-1.6
 Flickr                       Flickr Sets (flickr_sets)                               7.x-1.6
 OM                           OM Maximenu (om_maximenu)                               7.x-1.44
 Other                        Advanced help (advanced_help)                           7.x-1.1
 Other                        Backup and Migrate (backup_migrate)                     7.x-2.8
 Other                        Entity API (entity)                                     7.x-1.5
 Other                        Entity tokens (entity_token)                            7.x-1.5
 Other                        Image crop (imagefield_crop)                            7.x-1.1
 Other                        Job Scheduler (job_scheduler)                           7.x-2.0-alpha3
 Other                        Job Scheduler Trigger (job_scheduler_trigger)           7.x-2.0-alpha3
 Other                        Menu attributes (menu_attributes)                       7.x-1.0-rc3
 Other                        Module Object Oriented Programming API (moopapi)        7.x-1.2
 Other                        Node clone (clone)                                      7.x-1.0-rc2
 Other                        Pathauto (pathauto)                                     7.x-1.2
 Other                        PDFThumb (pdfthumb)                                     7.x-1.1
 Other                        Redirect (redirect)                                     7.x-1.0-rc1
 Other                        Token (token)                                           7.x-1.5
 Path Breadcrumbs             Path Breadcrumbs (path_breadcrumbs)                     7.x-3.0
 Path Breadcrumbs             Path Breadcrumbs UI (path_breadcrumbs_ui)               7.x-3.0
 Performance and scalability  Boost (boost)                                           7.x-1.0
 Performance and scalability  Cache Expiration (expire)                               7.x-1.0-beta1
 Rules                        Rules (rules)                                           7.x-2.7
 Rules                        Rules UI (rules_admin)                                  7.x-2.7
 SEO                          Metatag (metatag)                                       7.x-1.4
 Spam control                 BOTCHA (botcha)                                         7.x-3.3
 Statistics                   Google Analytics (googleanalytics)                      7.x-1.4
 User interface               CKEditor (ckeditor)                                     7.x-1.16
 User interface               jQuery Update (jquery_update)                           7.x-2.4
 User interface               Lightbox2 (lightbox2)                                   7.x-1.0-beta1
 Views                        Views (views)                                           7.x-3.8
 Views                        Views Bulk Operations (views_bulk_operations)           7.x-3.2
 Views                        Views UI (views_ui)                                     7.x-3.8
 Webform                      Webform (webform)                                       7.x-3.21
 XML sitemap                  XML sitemap (xmlsitemap)                                7.x-2.0
 XML sitemap                  XML sitemap menu (xmlsitemap_menu)                      7.x-2.0
 XML sitemap                  XML sitemap node (xmlsitemap_node)                      7.x-2.0

```

# Answer
> 0 votes
$base\_url in settings.php was disabled; enabling it with my domain as the value seems to have resolved to problem.

# Answer
> 0 votes
happend to me to - I commented out \# RewriteBase /

in .htaccess and that did it for me - although i had to change all the links back to the original manually.

I haven't have time to troubleshoot why and what caused it.

# Answer
> 0 votes
Comment out # RewriteBase / in .htaccess file.

if you placed the drupal files in sub folder you need to add the RewriteBase /subfoldername in .htaccess file.

---
Tags: uri, navigation
---


# Question
Title: Commerce view of node checkout hides unpublished content, therefore can't relist
I'm using commerce node checkout and have enabled the predefined view, `Commerce Node Checkout Expire Posts (Content)` to give customers a list of content they've paid to publish.

The problem is, when the content expires and is unpublished, it disappears from the view output. This is problematic because that view contains the 'relist' button, meaning that customers can't relist expired content.

Has anyone found a workaround for this? (Or maybe I'm missing something?)

# Answer
> 0 votes
Fixed:

1. In the view, go to: Advanced \> Other \> Query Settings.
2. Switch on `Disable SQL rewriting`.

Unpublished nodes should now be visible in the view.

---
Tags: views, commerce
---


# Question
Title: How to create custom date display format in drupal 7?
I have created content type for an events in which I mentioned multiple values for date field. I want to display date like Nov. 2, 6 & 8 or Nov. 2-5, 12 2014 & Jan 22 2015

After some research I am able to create a view of event date field like

*Nov 23 2014, Nov 26 2014, Nov 30 2014, Jan 03 2015 to Jan 05 2015*

But still not getting format I want like

*Nov 23, 26, 30 2014 & Jan 03-05 2015*

# Answer
> 1 votes
If you are comfortable with coding then go for template file changes. You have to do changes in node.tpl.php.

Else you can do also without coding refer https://stackoverflow.com/questions/8375674/how-can-a-custom-drupal-date-format-be-added

If you have created view for event display then it is easy to display date field as you want. Go to date fields setting. There is a option for formatter. Like below screenshot. Here you can add custom date display format.

---
Tags: 7, datetime
---


# Question
Title: Taxonomy terms manipulation on node.tpl.php
I wanted to print taxonomy terms on my custom node-mytype.tpl.php but what I want is not to print all the terms as they are.

Each of these terms consists of 2-3 words. And I want to manipulate the terms as below:

**term1: word1 word2 word3**

I want to print this as:

> word3, word1 word2

If a node has one term it's easy and I can do this as below (of course there can be some other better way to do this):

**inside node-mytype.tpl.php:**

```
<?php if (!empty($node->field_my_taxonomy_term)) { ?>

    <?php $aut = ($node->field_my_taxonomy_term['und']['0']['taxonomy_term']->name); ?>
    <?php $exp = explode(" ", $aut); ?>

    <?php if (count($exp) == 2) {?>
    <?php print ($exp[1]); print t(", "); print ($exp[0]); print t(", "); ?>

    <?php } elseif (count($exp) == 3) {?>
    <?php print ($exp[2]); print t(", "); print ($exp[0]); print t(" "); print ($exp[1]); print t(", "); ?>
    <?php }?>

```

I want to print multiple terms as above. For example:

**term1: word1 word2 word3**

**term2: word4 word5 word6**

should be printed as that:

> word3, word1 word2 - word6, word4 word5

I have this:

```
   <?php $str = ''; ?>
        <?php if (isset($node->field_my_taxonomy_term[LANGUAGE_NONE]) && $node->field_my_taxonomy_term[LANGUAGE_NONE]): ?>

        <?php foreach ($node->field_my_taxonomy_term[LANGUAGE_NONE] as $obj): ?>
        <?php $str .= l($obj['taxonomy_term']->name, 'taxonomy/term/' . $obj['tid']) . ' - '; ?>
        <?php endforeach ?>

        <?php print trim($str, '- '); ?>
   <?php endif ?>

```

The below code prints the terms as that:

> word1 word2 word3 - word4 word5 word6

**What code should I use here to print the terms as I wanted?**

> word3, word1 word2 - word6, word4 word5

*(Drupal 7.34)*

# Answer
> 1 votes
Finally I did it as shown below (thanks SO):

```
  <?php if (isset($node->field_my_taxonomy_term[LANGUAGE_NONE]) && $node->field_my_taxonomy_term[LANGUAGE_NONE]): ?>
    <?php $allOf=''?>
    <?php foreach ($node->field_my_taxonomy_term[LANGUAGE_NONE] as $obj): ?>
        <?php $exp = explode (" ", $obj['taxonomy_term']->name);
            $exp_last = array_pop($exp);
            $eachOne = $exp_last .', ' .implode(' ', $exp);
            $allOf .= $eachOne . ' - ';
         ?>
    <?php endforeach; ?>
    <?php print trim($allOf, ' - '); ?>
  <?php endif ?>

```

This is working correctly.

# Answer
> 0 votes
```
<?php $str = ''; $terms = array();?>
<?php if (isset($node->field_my_taxonomy_term[LANGUAGE_NONE]) && $node->field_my_taxonomy_term[LANGUAGE_NONE]): ?>

<?php foreach ($node->field_my_taxonomy_term[LANGUAGE_NONE] as $obj): ?>
  <?php $terms[] = $obj;?>
<?php endforeach ?>

<?php
   $str .= l($term[2]['taxonomy_term']->name, 'taxonomy/term/' . $term[2]['tid']) . ', ';
   $str .= l($term[0]['taxonomy_term']->name, 'taxonomy/term/' . $term[0]['tid']) . ' ';
   $str .= l($term[1]['taxonomy_term']->name, 'taxonomy/term/' . $term[1]['tid']) . ' - ';
   $str .= l($term[5]['taxonomy_term']->name, 'taxonomy/term/' . $term[5]['tid']) . ', ';
   $str .= l($term[3]['taxonomy_term']->name, 'taxonomy/term/' . $term[3]['tid']) . ' ';
   $str .= l($term[4]['taxonomy_term']->name, 'taxonomy/term/' . $term[4]['tid']) . ' ';
?>

 <?php print trim($str, '- '); ?>
<?php endif ?>

```

---
Tags: theming, taxonomy-terms
---


title: Show map notes under map?

text:
# Question
Title: Show map notes under map?
Is it posible to show the selected data under the map also? When i enable "københavn" as show at the picture, then there should be a list of resturants downunder also?

# Answer
> 1 votes
Yes - this is possible with the great views support in the Leaflet module you are using:

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

I'm assuming that you are using Views to render the above map given the number of data points you are displaying (and if not you should consider it). If so, then the easiest way to do this would be to edit your view, and add an 'attachment' display based on the same arguments that you are using for the above view (including the contextual filters you are using) and then change the display format to whatever you want (ex. an html list, a table, etc.) Attach this to your map view (display below) and you're all set.

Another option would be to do the same but render it as a block display instead and then place this using context or block admin to place this right below your map view.

---
Tags: javascript
---


title: Drupal 6 Core Update Not Updating

text:
# Question
Title: Drupal 6 Core Update Not Updating
I am running Drupal 6 and have attempted to update the Core about 5 times recently, and it continues to tell me I haven't updated it. I AM running update.php, and doing it the way it's always worked before. But Drupal is not perceiving that I've done it.

No problems with individual modules updates. Drupal and following a procedure I've followed numerous times before, successfully. Not using Drush, but am using command line.

# Answer
Its better to use drush.

Goto your project source folder from terminal.

Use the following command to upgrade.

drush pm-update projects

Ex: `root@karthik$ drush pm-update projects drupal-6.34`

This will update your drupal core to 6.4 version.
> 0 votes

---
Tags: 6, updating
---


# Question
Title: Content type node not overwriting the default node.tpl.php even if I have cleared all cache's
I have a content type with a machine name of 'empresas' after reading the documentation I should be able to just create a node--empresas.tpl.php to toy with the output of this in my theme.

it seems to be not overwriting it. I am trying to hack something together and I am using the twitter bootstrap Drupal theme.

I have seem a similiar problem into another post in this forum but it seems like taht is not may problem because he have solve it by clearen all the cache's but that was not my case.

# Answer
Initially, i say like not to override the original theme folder,

Create a sub theme of the base theme, in your case create a sub-theme of twitter bootstrap. Then make the necessary changes in the sub-theme.

Enable only the sub theme.

And about overriding `node.tpl.php` file, your approach is correct `node--empresas.tpl.php`, should over-ride the display of this particular node content.

Cross check machine name, Enabled theme, path of the overriding tpl.php file.
> 0 votes

---
Tags: theming, nodes
---


# Question
Title: Add a signature and date line to node print template?
I am trying to find the cleanest way to create a signature (your written signature, not forum signatures) and date line on printable pages.

I would like to do it without actually changing template files just to keep things upgradable without going back and tampering with it (it might not be me). However, if I have to I will.

Basically I need to have a "sign and date" line that shows up only when a node is being printed not when viewed on the webpage.

Something like:

By signing this you agree to our terms of service and agree to pay the minimum service charge. ETC...

Name:\________________________Date:\_________

(\*Comments not printed)

Obviously, this doesn't need to actually show up on any webpage but only show when someone hits CTRL+P and prints the page.

Is there a module that can do this? Or is using the print module the best way to accomplish this? If it only requires a few lines of HTML/PHP, I would rather do that than add another module. I am using Display Suite...so maybe a custom view/field could work?

Thanks

# Answer
Add a code field to Display Suite that is visible on nodes, and add your HTML to the code field.

Place the field last for the specific view mode, and make sure to assign a class (or assign the class directly in the html of the code field) on outer html element.

Test that the html is displayed on node view (normal page view).

In you theme's style css (css that targets web page view) set the display of this class to none. Now it should only show for print. If it does not go into your theme's print.css file and set the display to block or whatever you prefer. If there is no print.css (highly unlikely) then just add a @media print rule to your css.
> 2 votes

---
Tags: 7, entities
---


# Question
Title: Where to write a jquery script for a registration form page which created using webform module in Drupal 7?
I have created a registration form page using the webform module. The registration form page contains personal info and billing info groups with fisrtname, lastname, email, age fields and a check box saying "billing info same as personal info". Where should I write a jQuery script to put all the personal info in billing info fields when the check box is checked?

1. I have created a js `folder/check_box.js` file in the bartik theme folder which i am using
2. then made changes in `bartik.info` file as `scripts[]=js/check_box.js`
3. then added `drupal_add_js` in `template.php`
4. cleared all caches

but still I cannot execute my script which I have written for check box or the fields.

```
$("#checkbox_id").change(function() {
  if(this.checked){
    alert("checked");
    });
})(jQuery);

```

This is my code to check whether its working or not. Is it correct? If not please help me with the code.

# Answer
First off, as rooby very accurately suggested in the comment section, you should not tamper with the Bartik theme directly. You have many possibilities on where to include a js script. You can read all of them in the relevant documentation in drupal.org.

The closest to what you describe is to subtheme Bartik and put all necessary js there, or even create a small custom module.

Apart from that, jQuery in Drupal uses the noconflict mode. Try to avoid the dollar sign but rather call jQuery. Although in your particular code should be ok as it is, there may be other instances in your script using $ that would prevent it from working. More on that here. Check your browser for js errors.

Last, there is no way for us to evaluate your jQuery code if it works properly or not as we do not have the produced HTML output nor the context of your provided js code.
> 0 votes

---
Tags: javascript
---


title: unique fivestar rating for each user

text:
# Question
Title: unique fivestar rating for each user
I have a fivestar rating field "field\_rate" in comments. I have only allowed a role "reviewer" to rate. if one reviewer say A sign in and rate the field the average is stored as stars. Now if another reviewer say B visits the same node, he can see the vote (overall avg of number of votes). I want that reviewers will not able to see each other rating so when reviewer B signs in he see only blank 5 stars instead of avg votes. At the same time i want editor role to view the average vote for that field. How can i achieve this?

# Answer
I have found a solution, its so simple. Just have to tweak display setting for the rate field in managed display to "user's vote". Enable permission to vote for reviewer only.

For editor, I have used hook\_node\_view and displayed average rating. Since editor has no permission to vote, he can only see the average votes on the field in the node view. While reviewer can see his vote as per display setting.
> 0 votes

---
Tags: 7, rating
---


# Question
Title: Using Drupal Bootstrap, I want the 'title' of my parent menu item to be a glyphicon and to drop to the search bar!
I am having 2 issues with Drupal Bootstrap, I have no idea how to set a leaf specifically in the menu to not only be a glyph of a search icon, but also how to add the search block to the dropdown.

I am going to probably stop using the main-menu and just add a few regions for it!

# Answer
If you're wanting to theme the menu items, you can:

1. Use theme\_menu\_link() in your theme template to alter markup / attributes before rendering
2. Use a contrib module https://www.drupal.org/project/menu\_attributes to add a custom class name e.g. icon-left icon-myname
3. Select the menu item via css and manually inject it there e.g.:

```
.menu-class .mid-class:before {
font-family: 'glyphicon';
content: '\utf-char-code';
/* other css here */
}

```

Adding the search block to the dropdown depends how you want to set this up, we'd need more specifics on what behaviour you're trying to achieve. Bear in mind that you can alter individual menu items through hooks in your template (e.g. theme\_menu\_link() above), and you can also render blocks programatically.
> 0 votes

---
Tags: theming
---


# Question
Title: Show help text above input and below title of a cck field
Hi I am working with a drupal 7 I have created multiple content types for the site. I want to display the content of the help text of a particular cck field above the input field instead of displaying it below the input field

# Answer
you could use template\_preprocess\_field ( preprocess for theme\_field ) to adjust the position of field description/help text.

Cheers
> 2 votes

# Answer
There's a module for that: Label Help

> In normal rendering of Drupal form fields, the field's "description" (i.e., its help text) gets placed below the form's input element, which is not necessarily the most useful place to place it. On textarea form fields that enable multiple input formats, for example, the field's help text gets placed below the text format selector and tips. This means that website users are unlikely to notice and read the help text.
> 1 votes

---
Tags: 7, entities
---


# Question
Title: A Multi-step Form to display Database Data at the End
I'm fairly new to Drupal but I'm building a site using Drupal 7. Most of the stuff is pretty standard Drupal things, but one of the things my stakeholders want is a tool that does the following (and I'm not sure the best way to implement this using Drupal 7- suggestions appreciated!):

* A **multi-step form** (with 1 question per form) with checkboxes and radio buttons only. Data is saved temporarily for users. At the end of the form when users request their **recommendatios** the site displays a list of resources (from the database) FORMATTED in a specific way (ie. image, text, and link to resource) IN ORDER of relevance BASED ON the selections they made in the form itself. And all of this should be displayed in a list view.

I'm imagining some sort of FORM API + Views interaction but like I said I'm new. Any suggestions from the community?

# Answer
> 1 votes
Don't really need the views to make it much complicated. It is all about creating a module. Here is a basic format.

In Drupal, start by creating a simple module. Two files should be created: The .info file and the `.module` file. For the sake of simplicity call the module **multiform**.

```
multiform.info
name = Multi Form
description = Creates a multi-step form.
core = 7.x
package = Custom
version = 7.0

```

Now that have the `.info` file, and go create the `.module` file. The first thing to add is a menu entry to the page in which the form will show on. Implement `hook_menu()` inside the module like this:

```
/**
 * Implements hook_menu().
 */
function multiform_menu() {
  $items['multiform'] = array(
    'type' => MENU_CALLBACK,
    'title' => 'Multi Form',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('multiform_primary_form'),
    'access callback' => TRUE,
  );
  return $items;
}

```

hook\_menu() was implemented with a page callback that renders a form. This function will register a menu item for us to use as our form page.

Add the wrapper form. The reason it need a wrapper form is because the other forms will need to be contained. Without it they are just separate forms. The wrapper form will glue them together. A submit handler must also be created.

```
    /**
     * Form implementation of primary multiform.
     *
     * @see hook_menu()
     */
    function multiform_primary_form($form, &$form_state) {
      // Check to see if anything has been stored.
      if ($form_state['rebuild']) {
        $form_state['input'] = array();
      }
      if (empty($form_state['storage'])) {
        // No step has been set so start with the first.
        $form_state['storage'] = array(
          'step' => 'multiform_first_form',
        );
      }

      // Return the current form
      $function = $form_state['storage']['step'];
      $form = $function($form, $form_state);
      return $form;
    }

    /**
     * Submit handler for the primary multiform.
     *
     * @see multiform_primary_form().
     */
    function multiform_primary_form_submit($form, &$form_state) {
      $values = $form_state['values'];
      if (isset($values['back']) && $values['op'] == $values['back']) {
        // Moving back in form.
        $step = $form_state['storage']['step'];
        // Call current step submit handler if it exists to unset step form data.
        if (function_exists($step . '_submit')) {
          $function = $step . '_submit';
          $function($form, $form_state);
        }
        // Remove the last saved step so we use it next.
        $last_step = array_pop($form_state['storage']['steps']);
        $form_state['storage']['step'] = $last_step;
      }
      else {
        // Record step.
        $step = $form_state['storage']['step'];
        $form_state['storage']['steps'][] = $step;
        // Call step submit handler if it exists.
        if (function_exists($step . '_submit')) {
          $function = $step . '_submit';
          $function($form, $form_state);
        }
      }
      return;
    }

```

`$form_state['storage']` is used to store which step of the form that is on. Each time this wrapper is called it will call the next step in the sequence of forms. Add first form with a few example fields. Notice that the `$form_state['storage']['step']` is storing this function as the default first called.

```
    /**
     * Menu callback form. First of three.
     */
    function multiform_first_form($form, $form_state) {
      if(!empty($form_state['storage']))
        $values = $form_state['storage'];
      $form['user_info']['username'] = array(
        '#type' => 'textfield',
        '#title' => t('User Name'),
        '#size' => 15,
        '#maxlength' => 15,
        '#default_value' => isset($values['username']) ? $values['username'] : NULL,
        '#description' => t('The user name that will appear to other users. You should not use your real name.'),
        '#required' => TRUE,
      );
      $form['user_info']['first_name'] = array(
        '#type' => 'textfield',
        '#title' => t('First Name'),
        '#size' => 32,
        '#default_value' => isset($values['first_name']) ? $values['first_name'] : NULL,
        '#required' => TRUE,
      );
      $form['user_info']['last_name'] = array(
        '#type' => 'textfield',
        '#title' => t('Last Name'),
        '#size' => 32,
        '#default_value' => isset($values['last_name']) ? $values['last_name'] : NULL,
        '#required' => TRUE,
      );
      $form['user_info']['email'] = array(
        '#type' => 'textfield',
        '#title' => t('E-mail Address'),
        '#size' => 32,
        '#default_value' => isset($values['email']) ? $values['email'] : NULL,
        '#required' => TRUE,
      );
      $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Next'),
      );
      return $form;
    }

This is a simple form that asks the user for some basic information. $form_state['storage'] is used to store the values of each form. As the form progesses it will populate the content here if returned. Easy enough. Now going to skip the validation hanlder, but that should be easy to code. The important part is the submit handler where we will be storing the user's data. Below is an example of the first submit handler.

    /**
     * Submit handler for the first form.
     *
     * @see multiform_first_form()
     */
    function multiform_first_form_submit($form, &$form_state) {
      $values = $form_state['values'];

      // Save values to the form storage, add the next step function callback
      $form_state['rebuild'] = TRUE;  // This is very important to have!
      $form_state['storage']['username'] = check_plain($form_state['values']['username']);
      $form_state['storage']['first_name'] = htmlspecialchars($form_state['values']['first_name']);
      $form_state['storage']['last_name'] = htmlspecialchars($form_state['values']['last_name']);
      $form_state['storage']['email'] = check_plain($form_state['values']['email']);
      $form_state['storage']['step'] = 'multiform_second_form';
    }

The first thing to do is make sure `$form_state['rebuild']` is set to true. This will allow the next form to be returned for rendering rather than a reload. Any value that collected should be placed in `$form_state['storage']`. The last part is setting the next step. This information will be sent to the wrapper form and will process the next form. In this case it is `multiform_second_form()`. In this form there will add checkboxes. The first part of the function is to make sure if checkboxes have been set previously that they are reset. Take a look.

/**
 * Form that is called second
 */
function multiform_second_form($form, &$form_state) {
  // Make sure the default values for the checkboxes are set correctly.
  if (!empty($form_state['storage'])) {
    $values = $form_state['storage'];
    if (!empty($form_state['storage']['food'])) {
      foreach ($form_state['storage']['food'] as $value) {
        if (!empty($value)) {
          $default_values[] = $value;
        }
      }
      if(empty($default_values)) {
        // Storage and experience are set, but no values were selected.
        $default_values = array();
      }
    }
    else {
      // Storage was set, but experience wasn't.
      $default_values = array();
    }
  }
  else {
    // Storage is not set.
    $default_values = array();
  }

  // Set options
  $checkboxes = array(
    1 => 'Pizza',
    2 => 'Hot Wings',
    3 => 'Subs',
    4 => 'Salads',
    5 => 'Garlic Bread',
    6 => 'Pasta',
    7 => 'Cake',
    8 => 'Ice Cream',
  );

  $form['additional'] = array(
    '#type' => 'fieldset',
    '#title' => t('Additional Information'),
    '#collapsible' => FALSE,
  );
  $form['additional']['food'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Food you like'),
    '#options' => $checkboxes,
    '#default_value' => $default_values,
  );
  $form['additional']['company'] = array(
    '#type' => 'textfield',
    '#title' => t('Company'),
    '#size' => 32,
    '#default_value' => isset($values['company']) ? $values['company'] : NULL,
    '#required' => TRUE,
  );
  $form['additional']['message'] = array(
    '#type' => 'textarea',
    '#title' => t('Additional Information'),
    '#description' => t('Please provide information about your job'),
    '#size' => 32,
    '#default_value' => isset($values['message']) ? $values['message'] : NULL,
  );
  $form['back'] = array(
    '#type' => 'submit',
    '#value' => t('Back'),
    '#limit_validation_errors' => array(),
    '#submit' => array('multiform_second_form_submit'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Next'),
  );
  return $form;
}

```

The first part may seem confusing, but just gathering what the user has picked before (in case they went to another portion of the form and came back here). Here doing the same thing as the other form, but now with two submit forms. One will take to the next form and one to the previous form. See how the submit handler handles this:

```
/**
 * Submit handler for the second step.
 *
 * @see multiform_second_form_start()
 */
function multiform_second_form_submit($form, &$form_state) {
  $values = $form_state['values'];
  $form_state['rebuild'] = TRUE;
  if (isset($values['back']) && $values['op'] == $values['back']) {
    $input = $form_state['input'];
    // The user clicked the back button, save values that were input
    if (isset($input['food'])) {
      $form_state['storage']['food'] = $input['food'];
    }
    if (isset($input['company'])) {
      $form_state['storage']['company'] = htmlspecialchars($input['company']);
    }
    if (isset($input['message'])) {
      $form_state['storage']['message'] = htmlspecialchars($input['message']);
    }
    $form_state['storage']['step'] = 'multiform_first_form';
  }
  else {
    $form_state['storage']['food'] = $values['food'];
    $form_state['storage']['company'] = htmlspecialchars($values['company']);
    $form_state['storage']['message'] = htmlspecialchars($values['message']);
    $form_state['storage']['step'] = 'multiform_third_form';
  }
}

```

The submit handler checks to see what button was pushed. If the back button was pushed it will set the step back to the previous form, if not it will set the step to the next and final form (at least for this form). Make the last form a nice and simple terms of use with a finished button.

```
/**
 * Form that is called third
 */
function multiform_third_form(&$form, &$form_state) {
  $form['terms'] = array(
    '#type' => 'fieldset',
    '#title' => t('Terms of Use'),
  );
  $form['terms']['terms_text'] = array(
    '#type' => 'textarea',
    '#title' => t('Terms of Use'),
    '#default_value' => t('I agree to the terms of use'),
    '#disabled' => TRUE,
    '#resizable' => FALSE,
  );
  $form['terms']['terms_checkbox'] = array(
    '#type' => 'checkbox',
    '#title' => t('I agree to the terms of use'),
    '#required' => TRUE,
  );
  $form['back'] = array(
    '#type' => 'submit',
    '#value' => t('Back'),
    '#limit_validation_errors' => array(),
    '#submit' => array('multiform_third_form_submit'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );

  $form['#submit'][] = 'multiform_third_form_submit';

  return $form;
}

```

Simple like the others, this last form just collects some more information. The storage of information, creation of users, etc can be placed in this form's submit handler.

```
/**
 * Submit handler for the third step.
 *
 * @see multiform_third_form()
 */
function multiform_third_form_submit($form, &$form_state) {
  $values = $form_state['values'];
  $form_state['rebuild'] = TRUE;

  if (isset($values['back']) && $values['op'] == $values['back']) {
    // The user pushed the back button. Clear out the terms checkbox.
    $form_state['storage']['terms_checkbox'] = NULL;
    $form_state['storage']['step'] = 'multiform_second_form';
  }
  else {
    $form_state['storage']['terms_checkbox'] = htmlspecialchars($values['terms_checkbox']);
    $form_state['storage']['step'] = 'multiform_form_complete';
  }
}

```

Done! Well, maybe. Notice the last part, calling another form. This is just to get the user to a new page and say "

> You have completed the form

". You could redirect to a new page or anything else you want. Here is the code for `multiform_form_complete()`.

```
/**
 * The complete form (Thank you page) for parent form templates.
 */
function multiform_form_complete($form, &$form_state) {
  $form['message'] = array(
    '#markup' =>  t('Thank you for submitting the form!'),
  );
  return $form;
}

```

Please have a try with this module. Modify it according to requirements. Let me know if any questions or comments about this process. It is rather long so didn't get much time to explain every detail!

Get more about multi-step form from the Drupal support here. https://www.drupal.org/node/717750

---
Tags: 7, views, forms
---


# Question
Title: How do I include jQuery scripts at the bottom of the <body> tag?
I want to include a JavaScript file at the bottom of the `<body>` tag, and I only want to include it for a specific node type, but my node.tpl.php file's content is only wrapped by `<article>` tag; there is no \` tag in this file. If I do this in the root template.tpl.php file, it will effect all pages, which is not what I want.

Can I do this via theme preprocess functions?

# Answer
The example on the documentation for `drupal_add_js()` can explain this.

```
drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });',
  array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
);

```

If you want to add jQuery files, just change `'type'` to `'file'`.
> 1 votes

# Answer
Drupal 7 has introduced several new techniques that allow you far greater flexibility and control in the scripts you can have on your Drupal site's pages.

jQuery is now namespaced to avoid conflicts with other Javascript libraries such as Prototype. All your code that expects to use jQuery as $ should be wrapped in an outer context like so.

```
(function ($) {
  // All your code here
})(jQuery);

```

If you don't, you may see the error `Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function` or similar.

Basic module code should go from something like this in Drupal 7:

```
(function ($) {
  Drupal.behaviors.exampleModule = {
    attach: function (context, settings) {
      $('.example', context).click(function () {
        $(this).next('ul').toggle('show');
      });
    }
  };

})(jQuery);

```

These behaviors are instigated as you declare them in JavaScript so to clarify, there is no need for defining behaviors within a theme's or module's PHP file.

When applying certain behaviors to elements through JavaScript, we apply a class to the element to depict whether or not the effect has been applied.

Using jQuery Once (integrated into D7 core), the developer experience of applying these effects is improved. Note that there is also the removeOnce method that will only take effect on elements that have already applied the behaviors.

```
Drupal.behaviors.mybehavior = {
  attach: function (context, settings) {
    $('input.mybehavior', context).once('mybehavior', function () {
      // Apply the MyBehaviour effect to the elements only once.
    });
  }
};

```

For best-practice examples, it's helpful to look at (comparatively) simple examples such as `misc/collapse.js` to see how it's done.

Thank you.
> -1 votes

---
Tags: theming, javascript
---


title: Drupal reuses its hash salt

text:
# Question
Title: Drupal reuses its hash salt
The instructions in default.settings.php say

> This variable will be set to a random value by the installer. All one-time login links will be invalidated if the value is changed. Note that if your site is deployed on a cluster of web servers, you must ensure that this variable has the same value on each server. If this variable is empty, a hash of the serialized database credentials will be used as a fallback salt.

but this explanation of salting says

> A new random salt must be generated each time a user creates an account or changes their password.

and goes on to clarify that each salted hash (eg password) should have its unique salt stored along with the hashed+salted password in the database.

Am I misunderstanding the article I read on salting, or is Drupal using a faulty practice for the sake of convenience, or is the article wrong, or is there something else going on?

# Answer
I have migrated other CMS's to Drupal and had experience moving user accounts. Drupal's password algorithm is extremely good.

The salt you are referring to in the settings.php is not used for passwords. The drupal\_hash\_salt salt is used for generation of things like cookies. Hence why it says you must keep it the same across all web servers if you are in a load balanced setup.

Generation of passwords uses the SHA512 algorithm with randomly generated salts using openssl php libraries (not mt\_rand or other weak random number generators).

If you want to learn more about password generation you can start here reading the API documentation for Drupal

You see that in the function to generate it calls a "private" function to generate a new password salt (`_password_generate_salt()`). Which in turn calls a lot of other private, custom Drupal functions (it is a long rabit hole).

So in general the password scheme used for Drupal is extremely deep and nested, it does not use PHP functions considered to be "weak".
> 14 votes

---
Tags: security, authentication-authorization
---


title: Using fields as variable in views

text:
# Question
Title: Using fields as variable in views
I'm not sure how to explain this in a good way, and my title may be way off.

I am using Views Data Export module and want to export a report for a specific user, and use his/hers name in the filename.

I have created a field in my user registration called "full name". Is there a way I can use this in my views etc. like for example "%full-name"? Any way I can achieve this?

I have tried to use "Report for \[user:field-navn\].doc", but then I get the filename "Report for \[user:field-navn\].doc" as filename, and not the name in it.

# Answer
as arpitr says, you need to include the field so that it becomes visible to Views. You can exclude it from view in the field settings if you don't want it to show - then try, borrowed from (adjust appropriately for your setup) here:

> It's not super-obvious how to do this, but it is pretty easy.
>
> The downloaded filename has nothing to do with the "path" in the "data export settings" - that is simply the path that is used to trigger the generation of the file.
>
> To set the actual filename, click "settings" next to "CSV file" in the View's "format" section. Then, check the "provide as file" box and then set the filename (including token) there.
> 0 votes

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


# Question
Title: How do I sort by taxonomy term parent, and then by post date?
I have the following taxonomy structure:

Locations

* Group 1
    + Location 1
    + Location 2
* Group 2
    + Location 3
    + Location 4
* Group 3
    + Location 5
    + Location 6

Pieces of content are being posted to the site, and each piece of content has a location and a post date associated with it. When the view is displayed, how can the results be grouped by parent term ID (group 1-3), and then grouped by post date within each group?

I've tried using the "taxonomy term: name" sort criterion, but then adding the "content: post-date" criterion seems to have no effect.

# Answer
> 2 votes
I think I found a way to do this--I added the "content: taxonomy terms on node" and "taxonomy term: parent term" relationships to the view.

The key is the "taxonomy term: name" criterion has a checkbox where I selected "parent", which appears only after you add the relationship. I added the post-date sort criteria after that, and it appears to be working the way I want.

# Answer
> 0 votes
For really simple sorting, such as it's outlined in the question it's easy but took me a while to find it (*no* relationships needed):

1. Add taxonomy term as a field and exclude it from the display.

Make sure you have the title field still in the display.
2. Then under **Format**, *click on "settings"* to the right of "format:"
3. Under "Grouping field Nr.1" choose the taxonomy term field.

Now all your content should be grouped according to their respective term:

* Term Name 1
    + Item 1 Title
    + Item 2 Title
* Term Name 2
    + Item 3 Title
    + Item 4 Title
* Term Name 3
    + Item 5 Title
    + Item 6 Title

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


title: Trouble associating EVA with profile

text:
# Question
Title: Trouble associating EVA with profile
Using profile2, I created a profile, and it works fine. I want to list content authored by that user on that profile page. So, I created an EVA view, and I can't seem to figure out the right contextual ID configuration. I tried a few several combinations to no avail. What may I be missing?

The overall purpose is to display a profile page for users, along with a listing of their content they authored, using Display Suite (yes, the EVA field is visible). I figured this would be the most simple way to build a profile page.

# Answer
> 1 votes
The answer was pretty simple, using Tokens. Set up your Content: Author relationship, and your User: UID contextual filter (using the author relationship). In your EVA, set your entity type to Profile, and bundle, accordingly. For Arguments, select "Use tokens from the entity view...". In the token replacement, use the token \[profile2:user:uid\].

Done! I know have my content authored by the user that belongs to the profile.

# Answer
> 1 votes
Synchronicity! I just answered this question which I think is essentially the same question. I don't have any experience with Profile2, but I think this advice is applicable. Hope this helps:

How to create an entity reference view that contextually filters based upon current user ID

# Answer
> 0 votes
You do not need a Content: Author relationship.

Use the following settings for the EVA Field display :

ENTITY CONTENT SETTINGS \- Entity type : User \- Bundles : User \- Arguments : id

CONTEXTUAL FILTERS \- Content : Author uid \- WHEN THE FILTER VALUE IS *NOT* AVAILABLE : Provide a default value \- Type : User ID from URL

Hope this could help someone :-)

---
Tags: 7, views, users, display-suite
---


title: Choosing from multiple default images

text:
# Question
Title: Choosing from multiple default images
What is the best solution for letting users choose from an array of default images when creating a node with a teaser image field?

The functionality I'm thinking of is similar to https://drupal.org/project/avatar\_selection , but for creating any node.

# Answer
The best for your case is Media. You can use a existing library or you can upload a new image and many other stuff.
> 1 votes

# Answer
Tip: Here is a module that lets you set automatic random images, check it out:

https://www.drupal.org/project/image\_field\_random
> 0 votes

---
Tags: media, nodes
---


# Question
Title: Is there a one-click solution that builds a private organic group (OG) and invites another specified user to that group?
I'm looking to let users initiate the creation a private organic group and invite another user to that group? I'd love to be able to craft a link (in a view of users perhaps) that adds a path like `/request/new/og/{uid}` to the routing table.

The idea is to match tutors to users needing help in a subject area.

I starting from a View based on User Accounts that presents a table as follows.

```
User       |  Tutoring Availability    | Request Tutor Group
-----------+---------------------------+---------------------
Abe        |  T/H Afternoons           | [ Request ]
Brian      |  M/W Mornings             | [ Booked ]
Courtney   |  Wknds Anytime            | [ Request ]
David      |  F All day                | [ Request ]
Mozzarella |  M All Day                | [ Request ]

```

In the request link above, I like to

1. Create new private OG (of content type 'group')
2. Make the Logged in user the group manager
3. Invite (not automatically subscribe) the other user (potential tutor)

I'd like to *not* have the user see any node creation from as these private groups will have non-creative names such as "Tutoring Session for Rob and Jim on Organic Chemistry." Users will communicate via another content type that helps to track tutoring benchmarks.

Update: I'd also be happy if someone can point me to a working code example of OG's API to create an organic group using functions from the og api.

Bounty reward may require some screen shots to create a good reference point for the community.

# Answer
> 2 votes
I would use Page Manager (part of ctools).

You can add an action or a tab to just about any page so you could have your view of users with a tab or link at the top (depending on your theme/styling) that requests a new organic group.

The URL would be based on the user view. For instance if your user view was at `/people/users` you could add a path at `/people/users/addgroup` which redirects to the OG group creation page.

Alternatively you can create whatever URL you want like /request/new/org/id and give people the link for it... then use that URL to redirect to the OG group creation page.

In order to hide the user being added to the form you should be able to use a parameter in the URL like `request/%tutor`, then pick up the argument in Page Manager and auto-populate the user as a member.

As for automatically filling out the form? Well, Automatic Nodetitles has worked well for me, you can build titles out of available tokens which is pretty neat. And you could probably run some javascript to click the submit button on page load but that's a kludge.

If you don't want them to see the node creation screen then yes, the API is the way to go. I haven't used OG so I'm not familiar with it, but most contrib modules have a `.api` file which gives an explanation of the available hooks. But you probably want to use one of their functions, just look through the code until you find one called `og_create_group` or something like that, figure out what to send it as parameters and you're off!

# Answer
> 0 votes
So I have a half baked method.

First, through features, I save a content type of a group and that exported feature a part of a module.

Second, using node\_export, I export a newly created private group that I call blue print. I save that export output to a the same newly created module.

Finally, later in the module, or at least in my current tests, I use the following snippet. I'm borrowing functionality from node\_export's node\_export\_import.

```
<?php
$file = realpath(".") . base_path() . drupal_get_path('module', '<name>') . '/included_features/private.group.export.drupal';
...
// search and replace to change values in blueprint as needed
...
$codestring = trim(file_get_contents($file));
dsm(node_export_import($codestring));

```

---
Tags: organic-groups
---


# Question
Title: How to remove "All Products" item in main menu of Commerce Kickstart 2?
I checked vocabulary collection, no "All Products" there.

Is it created programmatically? How can I remove/change this item?

# Answer
you can remove it at admin/structure/menu/manage/main-menu (deselect the tickbox)
> 0 votes

# Answer
I don't know why I couldn't find it, But I got it in admin/structure/menu/manage/main-menu eventually. This question is a pseudo-question.
> 0 votes

---
Tags: routes, commerce
---


# Question
Title: Should I use Libraries API if I only wish to use a 3rd-party library for my own custom module? version detection, duplicate declaration
I wish to use phpFlickr 3rd-party php library in developing my own custom module.

I considered Libraries API to centrally manage phpFlickr in `sites/all/libraries` but have some questions:

* What happens if there are other contrib modules that also use phpFlickr and manage it through Libraries API? If my module registers phpFlickr with Libraries API then would there not be a duplicate entry with Libraries API? Does it know if more than one module wants to use it?
* In general, how can I check for a minimum version of a library? with hook\_libraries\_info() a regular expression can be used to find the version, but there doesn't seem to be an explanation as to how to check for a minimum version.

I've already looked at the documentation for Libraries API and found it to be insufficient regarding examples ( https://www.drupal.org/node/1342238 ). I also looked at a page stating contrib modules that apparently used Libraries API ( https://www.drupal.org/node/1570568 ) but when I examined the code, it didn't seem to be the case, i.e. in the twitter module, I looked for "\_libraries\_info" but could not find it.

# Answer
> 0 votes
I think the answer would be to check for an API module that wraps the 3rd-party code inside a Drupal module, in my case this would be the Flickr API module, which has been fixed to use Libraries API:

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

If there isn't a wrapper for the 3rd-party code, then this would be the case to make one, by oneself.

# Answer
> 0 votes
This is the use case of libraries, if there is the library phpFlickr the in path that the libraries module search(/libraries, /sites/all/libraries) for example, you can use it, so the user do not need to add a new phpFlickr somewhere else.

As for minimum version, you can use the function version\_compare() from php.

---
Tags: 7, theming, files
---


# Question
Title: How can I add a link to users of an organic groups in views
I have a views which lists groups (I am using drupal commons distribution). I like to add a link in this view to members of that group. Any idea how this might be accomplished?

Thanks.

# Answer
Build a new view or block listing users and limit access to members of the users of group. Go to you current view and add a link to the new view or block.

Got to Structure\>Views and add a view. Name and set to Users

Set groups fields and filter to specific group.

Change the page URL

Save

Copy url of view and go to existing view and create the link.
> 0 votes

---
Tags: views, users, organic-groups
---


# Question
Title: Drupal Views : Cumulative filtering from an exposed tag cloud
Sorry for this newbie question... I hope you can help.

I need to set up a search result page, with a tag cloud as a filter. If user select one tag (termX), the matching rows are being displayed. He could refine his search by clicking on a second tag, to refine it even more (displaying results matching termX AND termY).

Ideally, the selected tags in the cloud, should be visually seen as "selected".

Any idea which module should I rely on ? Do I need to go through a custom development instead ? Any hints ?

# Answer
You could use views with exposed filters. You can set filter criteria to "exposed" so the user can choose which filter he would like to have. With the module "Better exposed filters" you have the possibility to format for example a select list as links.
> 0 votes

# Answer
All though the question is old. This answer might help someone else who is looking for a solution Tagadelic filters
> -1 votes

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


# Question
Title: How to give user opportunity to select attribute by checkbox
I use exposed filters in Views to give user opportunity to chose attribute of product. After his checking filtering starts automaticly. But problem is that format for chosing is drop menu. Is it possible to use checkboxes or radio buttons? It will be more userfriendly....

# Answer
Better Exposed Filters seems to be module you need:

> The Better Exposed Filters module replaces the Views' default single- or multi-select boxes with radio buttons or checkboxes, respectively. Description fields and Select All/None links can be added to exposed filters to make for a better user experience.
> 0 votes

---
Tags: views
---


# Question
Title: Installed Views Module but It did not appeared in Structure
I installed a fresh Drupal 7.22 on my localhost and installed Ctools and Views modules.

When i go to **Structure** i dint find **Views** link

I also cleared all cache but still same problem.

This is not my first Drupal experience, I created many views.

Here are the screen shots.

# Answer
You have to enable **Views UI** in order for it to show up under Admin -\> Structure.
> 3 votes

# Answer
If you are still not seeing after enabling Views-UI and IF YOU USING ADMIN MENU module to generate Admin Menus, You have to clear cache.

To do that,

Home Icon -\> Flush all caches -\> Administration menu Home Icon -\> Flush all caches -\> Menu
> -1 votes

---
Tags: views, nodes
---


# Question
Title: Rules sometimes don't convert saved node to nid
I have a strange problem with Rules. I try to set up 2-directional entity references. It works well with one content type, but fails with another. In the latter case, saved node is not converted into node when used as parameter in action like "Set data value" and Drupal tries to save it as array (which fails, of course).

So the questions is: Do you know about something (field, content type setting), which prevents Rules from properly converting saved object?

I'm using latest Rules dev from Drupal 7.

Rules export and error message can be found at https://gist.github.com/miloskroulik/898acaea40097724ff3e

# Answer
So, the problem was in the entity reference field Rules were operating on (when adding value to it). The only solution I was able to come up with was to create a new field.
> 0 votes

---
Tags: rules
---


# Question
Title: How to show pages other than nodes with the default language prefix
Content on our site exists in several languages. The default language is 'en'. Prefixes are shown in URLs, such as http://example.com/en/my/path or http://example.com/nl/my/path.

However, pages like the home page, and various views and custom pages, should not be localized -- they should show on the default language URLs, even if they list nodes in other languages.

The problem we face is that after somebody visits a page in non-default language, e.g. http://example.com/nl/my/path and they then go to the home page, the home page is on http://example.com/nl. This means that our the same non-node pages exist in several copies, each with only a different URL language prefix. Confusing for search engines, confusing for users, and heavy for the server (multiple page caching).

In other words, the home page and other non-nodes should always have the default language prefix, independently from the language of the previously visited page. Can this be achieved elegantly (without having to write custom .htaccess redirects)?

# Answer
Probably the easiest way that I know is to turn off "Determine the language from the URL (Path prefix or domain)." on the languages page at "admin/config/regional/language/configure". This way there is only 1 url for all content.

I do not know (of an elegant way) to have language prefix for nodes but not other pages.
> 1 votes

---
Tags: 7, i18n-l10n, path-aliases
---


# Question
Title: How do I set up a new Drupal instance with all the modules from a previous one?
I had a temporary instance of drupal set up with lots of modules. I now have a new instance of Drupal and I want to install all the same modules, but I can only see how to do it with the GUI admin interface, which is frankly, horrifically clunky and unwieldy.

Is there another way to do this without spending half a day manually installing them again?

I've only heard of Drush, but I'm not sure how to set this up on windows, so this might not be the best answer. Everything I search for online (e.g. 'Export drupal modules') points me back to a 'modules that exports nodes etc.', not a 'mechanism for exporting modules'.

I've also found something called Deploy but I can't tell if this is for modules or just nodes.

# Answer
This is where the concept of drupal distributions comes in.

Yes you will need drush, a make file with the modules you need and a profile that installs these modules upon site-install.
> 2 votes

# Answer
What you can do is copy the module folders from your previous Drupal instance to new one. This will do (but I don't suggest it). But if you do so then you need to enable all your modules from GUI admin interface. Another glitch would be that if there is any update to the module then you will not get the updated module.

But I suggest it's best to use **drush** and it will give you more functionality which I cannot list you here.

Installing Drush on Windows

also see this nice tutorial on OStraining

**EDIT:**

This is nice and simple tutorial to setup drush on windows Installing Drush on Windows - 1. Hope this helps to you.
> 1 votes

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


# Question
Title: How do I build a form with embedded view results
I need to create a sign up form that also displays all of the submitted values above each value on the same page. I have searched for hours and cannot find anything that describes how to achieve this. So it would be formatted like:

Sign Up Form

Results of value 1:

value1, user 1

value1, user 2

value1, user 3

\[enter value for value1\] \<= this is the form field to enter a new value1 for current user

Result of value 2:

value2, user 4

value2, user 2

value2, user 6

\[enter value for value1\] \<= this is the form field to enter a new value1 for current user

\[submit\]

I have come close with webform and building a webform-form--nid.tpl.php file to override the default template, and use views to create tables for the results but the view tables are listing all of blank fields as well. I have tried entitfyform but don't know how to split up the form to allow to have the views above each relevant section.

# Answer
> 0 votes
Sign Up Form

```
<?php
    function formfun_menu() {
    $items = array();
    $items['formfun'] = array( //this creates a URL that will call this form at "examples/form-example"
    'title' => 'FORM FUN',
    'description' => 'A form to mess around with.',
    'page callback' => 'drupal_get_form', //this is the function that will be called when the page is accessed.  for a form, use drupal_get_form
    'page arguments' => array('formfun_form'), //put the name of the form here
    'type' => MENU_NORMAL_ITEM,

    'access callback' => TRUE
  );
  return $items;
}

function formfun_upload_form($form, &$form_state) {

$form['add'] = array(
 '#type' => 'fieldset',
'#title' => t('Add company details'),
);
  $form['add']['companyname'] = array(
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => 'Company Name',
  );

  $form['add']['contactname'] = array(
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => 'Contact Name',
  );

    $form['add']['companyaddress'] = array(
    '#type' => 'textarea',
    '#required' => TRUE,
    '#title' => 'Contact Address',
  );

    $form['add']['postalcode'] = array(
    '#type' => 'textfield',
    '#title' => 'Postal Code',
  );

    $form['add']['city'] = array(
    '#type' => 'textfield',
    '#title' => 'City',
  );

    $form['add']['country'] = array(
    '#type' => 'textfield',
    '#title' => 'Country',
  );

    $form['add']['file'] = array(
        '#type'     => 'file',
        '#title'    => t('Choose a file'),
);

  $form['add']['submit_button'] = array(
    '#type' => 'submit',
    '#value' => t('Click Here!'),

  );
   return $form;
}

function formfun_submit($form, &$form_state) {

    echo '<pre>';
var_dump($form_state['values']);
echo '</pre>';

    db_insert('details')
    ->fields(array(
    'companyname' => $form_state['values']['companyname'],
        'contactname' => $form_state['values']['contactname'],
        'companyaddress' => $form_state['values']['companyaddress'],
         'postalcode' => $form_state['values']['postalcode'],
        'city' => $form_state['values']['city'],
         'country' => $form_state['values']['country'],
         'image' => $form_state['values']['file'],
   ))
   ->execute();
    drupal_set_message("successfully saved Security Settings");
    exit();
}

function formfun_validate($form,&$form_state)

{
  }

```

---
Tags: forms
---


# Question
Title: How to print an image field in Views with PHP filter
I'm trying to display an image in Views using the PHP filter. If the value of a boolean field (`field_primum`) is `TRUE`, I want the image to display.

The picture is available in `$row->picture`, but when I use this code:

```
if(isset($row->field_primum)) {
  if ($row->field_primum == "1") {
    print ("<div>$row->picture</div>");
  }
}

```

Only the ID of the image prints. How do I render the image itself?

# Answer
First of all load the file:

```
$file = file_load($row->picture);

```

Then format it as an image and render:

```
print theme('image', array('path' => $file->uri));

```
> 1 votes

---
Tags: views
---


# Question
Title: What module handles links of the form <a href="internal:archive">?
I'm maintaining a website with drupal 6 and recently did an update. I have some links of the following form:

```
<a href="internal:forum"> … </a>
<a href="internal:archive"> … </a>
<a href="internal:album/2014"> … </a>

```

Since the update, every link of that form is dead (since the navigator just tries to open the url "`internal:forum`", which is completely invalid as is)

It may be a module I forgot to enable again after the update, but I have too much of them to test them one by one, and none of them seems related to that sort of link at all.

What are those links? What is handling them and what do I need to make them work again?

# Answer
> 0 votes
As @Clive suggested in the comments, I was searching for a module involving links when I should have searched for some kind of text filtering.

I've found the responsible module : Path Filter, and I indeed forgot to enable it again after the update.

The `internal:forum` pattern is written in a node's content, and is changed to a valid path in the final page.

---
Tags: 7
---