# Question
Title: Getting parents' terms of terms tagged into a particular content type nodes
This is a bit confusing for me.

I am using Drupal 7 and Views 3.

I have a list of particular content type nodes tagged with a term (from a vocabulary "topic"). Vocabulary "topic" is 2 levels deep and nodes are tagged just with leaf terms. I have those same nodes tagged with another vocabulary ("level" vocabulary).

I'd like to get in a view all parent terms (exactly the term name) from the vocabulary "topic" whose children are tagged into a node which is tagged with a particular level (let's say beginners).

Let me show you an example:

Vocabulary "Level":

* Beginners
* Intermediate
* Advance

Vocabulary "Topic":

* Greek philosophy
    + Introduction to greek philosophy
    + First stage: Greek
    + Second stage: Greek
* Latin philosophy
    + Introduction to latin philosophy
    + First stage: Latin

My content type nodes can be tagged with both vocabularies but in the case of "topic" they are only allowed to be tagged, as I said, with leaf nodes (i.e. Introduction to greek philosophy, first stage:greek, second stage: greek, Introduction to latin philosophy or first stage:latin).

In this context if one particular node is tagged with "introduction to greek philosophy" and "beginners", I would get "Greek philosophy" on my view. If that same node is not tagged with "beginners" I wouldn't get it on my view.

I know it's a bit complex but I would really appreciate your help and orientation.

Thanks in advance.

# Answer
OK, so this solution has many steps, but the good news is that this is possible.

Here's what you need to do in your view:

* In your view that lists your nodes, add a relationship to the topic term reference field (called field\_topic) in my case. In the 'Advanced' section, add the 'Content: Topic' field, and rename it if you want in the configuration screen. As you can see, I did!

* Next, add one more relationship (the parent term of this Topic term). I'm filtering to only see term fields, and choose the '**Taxonomy term: Parent term**' option. Make sure, when you configure this second relationship, to choose that you want the Parent term of the already selected Topic term field.

* If you want - at this point you can select the "Taxonomy term: Name" field twice in your fields list (once with the 'Topic term' as the relationship and once with the 'Parent term' as the relationship to see that your two relationship are bringing up the correct terms).
* Finally, you're ready to set up a contextual filter! What you want is for this view (which I assume is a block view) to pull up only those nodes that share the same topic parent with the current node's topic parent. Sooooo, in your **Contextual filters** section (under 'Advanced'), choose the "**Taxonomy term: Term ID**" option. Under the 'Relationship' choose, 'Parent topic' (or whatever you named your parent term relationship). After all, we'll be filtering exactly by that - the term id of the parent of the topic term.
* Choose to '**Provide a default**' value for this filter when it's not available. The truth is, we have to get the parent term id from the current node ourselves (I don't know how else to do it). Choose that we'll provide it with 'PHP Code' and type in the following:

```
$node = menu_get_object();  // Get current node
$topic_term_id = $node->field_topic['und'][0]['tid']; // Just gets first topic term
$parents = taxonomy_get_parents($topic_term_id);
reset($parents); // Make sure pointer points to first element
return(key($parents)); // Return first key

```

Here's what my contextual filter looks like:

Obviously, I'm not really doing many checks in my code to test for the existence of terms, etc, but this should just about get you there. Let us know if it works. I just tested it and it works for me!!!
> 0 votes

---
Tags: views
---


title: Removing access by role restriction

text:
# Question
Title: Removing access by role restriction
I have a View with a Page display that only allows the returned data to be linked if the user is authenticated/logged in. I'm not using any extra modules that I can see (inherited site) that would enable access like this.

I simply want to remove that restriction. There is another view that looks the same except it's for Public and shows all the same data but not linked. (the data are pdf files).

On the authenticated display, next to Access in the Basic Settings it has authenticated user. If I click that user role (not the gear for options), then I'm shown a list of user roles to use for access restrictions. I click "None" and save, but the links are not there as an anon visitor. Same if I try by changing the user to Anonymous User. Note: In the permissions, anon has the right to see webfm attachments.

I noticed the URL is documents-public or documents-auth; so I made it just documents. No luck.

I visited the actual custom-page-type which puts the View in a content pane. I re-ordered the variants, removed all Selection Rules and that didn't do anything either.

I flushed all caches.

Somewhere, the view is still only showing a view based on whether a user is authenticated or not even though I've removed the access (it says "unrestricted" next to access) on both displays and removed all selection rules on the actual page.

I'm stuck on where else to look.

# Answer
For whatever whack reason, I had to click on the file-name in the views, which was already set to "output with links", change it to without links then back and it works.

Thanks you, JimaJamma and jerdiggity; your answers made me focus on the field in the view.
> 0 votes

---
Tags: views, 6
---


# Question
Title: After adding a column to a module's schema, should the new column also be placed inside hook_schema?
I have my own module which implements its own schema. I now want to add a column to the table provided by the schema, which I plan on accomplishing via `hook_update_N()` and `db_add_field()`.

My question is essentially what the title of this question is: after I add the new column to the schema, should the new column **also** be placed inside the module's `hook_schema()` implementation? Example (adds a column named `mynewcolumn` to the schema of the module `mymodule`):

```
function mymodule_update_6000() {
  $ret = array();

  db_add_field($ret, 'mymodule', 'mynewcolumn', array(
    'description' => t('This is my new column'),
    'type' => 'text',
    'size' => 'big',
    'not null' => FALSE
  ));

  return $ret;
}

```

At this point, do I place `mynewcolumn` inside `mymodule_schema()`? Or does `mymodule_update_6000()` fully take care of proper installation and uninstallation?

# Answer
> 2 votes
`hook_update_N()` is only used when updating a module, while `hook_schema()` and `hook_install()` are used only when installing a module. Since there are users who install the module, the database field must be also added in `hook_schema()`.

---
Tags: 6, database, installation, updating
---


title: Connect two webforms?

text:
# Question
Title: Connect two webforms?
* I have 2 webforms: survey webform and task webform.
* The entry point is task webform and it requires user to login.
* There is a controller or something to check if user has previously filled in a survey webform, if he/she did, go straight to task webform. Otherwise, need to go to survey form.
* I know how to create webforms, but not sure how to make such controller.

# Answer
I am not sure about your control here, whether to move from survey webform to task webform or the vice versa. But this is what I would do.,

1. On login query the "webform\_submissions" table with the logged in user's id and see whether he/she has submitted the webform before.
2. If he/she has not submitted it before load the webform say task webform.
3. If he has submitted this before, load the survey webform page.

You can make use of "hook\_user\_login" to redirect on login, also this can be used to query the "webform\_submissions" table.
> 0 votes

---
Tags: webforms
---


# Question
Title: forcefully / manually remove content type
Is it possible to manually remove a content type?

I've packaged it in a feature and now the content type is no longer needed; it's been deprecated. I'm unable to delete the content type after disabling the feature in the features panel and in the modules page.

# Answer
If you have devel install then go to sitename/devel/php and execute the following code.

```
node_type_delete('content_type_machine_name');

```

else you can run the same code inside hook\_init() of your custom module. Hope it helps.
> 1 votes

---
Tags: 7, nodes, features
---


# Question
Title: How to customize a single default taxonomy page?
In Drupal, we have default taxonomy pages. These pages have the same view. We want to change the layout of one of those pages. Is it possible?

# Answer
> 1 votes
If you are using the standard issue taxonomy module to output your pages, eg:

```
www.yourhost.com/taxonomy/term/###  (or whatever its eventual alias is)

```

you can modify `taxonomy-term.tpl.php` to do almost anything you want.

In D7, it's provided for you and basically looks like this:

```
<div id="taxonomy-term-<?php print $term->tid; ?>" class="<?php print $classes; ?>">

  <?php if (!$page): ?>
    <h2><a href="<?php print $term_url; ?>"><?php print $term_name; ?></a></h2>
  <?php endif; ?>

  <div class="content">
    <?php print render($content); ?>
  </div>

</div>

```

The key variable to your question is `$term` and you could do something like this:

```
<div id="taxonomy-term-<?php print $term->tid; ?>" class="<?php print $classes; ?>">

  <?php if (!$page): ?>
    <h2><a href="<?php print $term_url; ?>"><?php print $term_name; ?></a></h2>
  <?php endif; ?>

  <div class="content">
    <?php if ($term->tid==THE_TID_YOU_ARE_LOOKING_FOR): ?>
       <?php // do something different here ?>
    <?php else: ?>
      <?php print render($content); ?>
    <?php endif; ?>
  </div>

</div>

```

# Answer
> 0 votes
**Drupal 7:**

1. You need to have a separate view for that particular taxonomy term.
2. Create a views page
3. Under contextual filters, select Taxonomy term id \> Provide default value \> Fixed value \> Enter the taxonomy term ID here.
4. content which is displayed on this views page will be only for a particular term ID.

In case if you have to do the same for other terms, then just add a new page within the same view and set the taxonomy term ID and the page URL should be different.

**Drupal6:**

Create a node view

1. Create a node view and page display
2. Add a filter for a specific content type
3. Add the fields as you require
4. Under 'Arguments' add 'Taxonomy Term ID'
5. Select 'Provide default argument' \> 'Fixed entry'
6. Mention the term ID under 'Default argument'
7. Now when you run the page link, you'll see nodes related to a specific term

---
Tags: taxonomy-terms
---


# Question
Title: banner image showing on all pages except forum and views result pages
My image is showing on all pages except the forum and classifieds result pages.

How can I make sure it shows on all the pages?

In the block I have selected all pages and not checked any of diff types so that it should show site wide.

# Answer
> 2 votes
A quick inspection of your html shows that the block is showing up. However, the issue is you have a relative path in your img src, eg, you have this:

```
<img src="sites/default/files/autumnleaves.jpg">

```

and that works fine when you are in the top level of your site. But, when you go "down a level" it fails. Changing it to:

```
<img src="/sites/default/files/autumnleaves.jpg">

```

should fix the problem.

# Answer
> 1 votes
Like @jimajamma stated you are using a relative path which will be invalid when not in the top level of your site. I would recommend using an absolute path rather than a relative one, because then the url will still be valid even if your installation is in a subfolder of your webroot.

To generate an absolute url for your image you could use something like:

```
$url = url('sites/default/files/'.file_uri_target($uri), array('absolute'=>true));

```

---
Tags: theming
---


# Question
Title: CSS changes not taking effect in customized styles folder
I am trying to size the banner in a Jackson theme on my site to fit to the 960px wrapper size have in customized folder in sites/all/themes/mytheme/styles/mytheme.css but no matter what I do the length won't change, only the height which makes no sense at all.

I have tried flushing the cache several times but still no changes take effect.

The code in jackson styles.css is

```
#banner-wrap {
   background: transparent url(../images/main-sprite.png) repeat-x scroll center -90px;
   height: 133px;
   overflow: hidden;
   width: 100%;
}

```

I have successfully changed the height but if I change width from 100% to 960px it does nothing.

# Answer
> 0 votes
Make the changes to the style.css file which is in Jackson theme folder. Not under mytheme

1. Use

```
#banner-wrap {
background: transparent url(../images/main-sprite.png) repeat-x scroll center -90px !important;
height: 133px !important;
overflow: hidden !important;
width: 100% !important;
}

```
2. Add this in to `style.css` file
3. Flush the cache once.

# Answer
> 0 votes
Keep the 100% width in Jackson theme and make sure the image file is same width as the container.

# Answer
> 0 votes
As you theme's css file uses the image. It is better you should put the image in the theme's images folder itself so that you can give corresponding path such as `../images/main-sprite.png`. If you place image file under `sites/default/files` folder then relative path will change every-time you visit different URL. That is the reason why you are not able to get the image on view and forum page. Image path should be accessible from css folder so better to keep the image under `jackson_theme_path/images/main-sprite.png`. This should solve the problem.

---
Tags: theming
---


# Question
Title: How to remove the home link in menu breadcrumb in drupal
I am using menu breadcrumb module in my drupal. I get the breadcrumb like as Home\>Content\>Aboutus but i need a structure like Content\>Aboutus.How can i do this

# Answer
> 1 votes
You can check if your theme bring this option in appearance \> Theme settings

Or you'll have to use THEME\_breadcrumb hook. Here's the zen function, have a look at the bolded part.

```
function zen_breadcrumb($variables) {
  $breadcrumb = $variables['breadcrumb'];
  $output = '';

  // Determine if we are to display the breadcrumb.
  $show_breadcrumb = theme_get_setting('zen_breadcrumb');
  if ($show_breadcrumb == 'yes' || $show_breadcrumb == 'admin' && arg(0) == 'admin') {

    // Optionally get rid of the homepage link.
    $show_breadcrumb_home = theme_get_setting('zen_breadcrumb_home');
    if (!$show_breadcrumb_home) {
      array_shift($breadcrumb);
    }

    // Return the breadcrumb with separators.
    if (!empty($breadcrumb)) {
      $breadcrumb_separator = theme_get_setting('zen_breadcrumb_separator');
      $trailing_separator = $title = '';
      if (theme_get_setting('zen_breadcrumb_title')) {
        $item = menu_get_item();
        if (!empty($item['tab_parent'])) {
          // If we are on a non-default tab, use the tab's title.
          $breadcrumb[] = check_plain($item['title']);
        }
        else {
          $breadcrumb[] = drupal_get_title();
        }
      }
      elseif (theme_get_setting('zen_breadcrumb_trailing')) {
        $trailing_separator = $breadcrumb_separator;
      }

      // Provide a navigational heading to give context for breadcrumb links to
      // screen-reader users.
      if (empty($variables['title'])) {
        $variables['title'] = t('You are here');
      }
      // Unless overridden by a preprocess function, make the heading invisible.
      if (!isset($variables['title_attributes_array']['class'])) {
        $variables['title_attributes_array']['class'][] = 'element-invisible';
      }

      // Build the breadcrumb trail.
      $output = '<nav class="breadcrumb" role="navigation">';
      $output .= '<h2' . drupal_attributes($variables['title_attributes_array']) . '>' . $variables['title'] . '</h2>';
      $output .= '<ol><li>' . implode($breadcrumb_separator . '</li><li>', $breadcrumb) . $trailing_separator . '</li></ol>';
      $output .= '</nav>';
    }
  }

  return $output;
}

```

Zen provide an option to disable this feature :

```
$show_breadcrumb_home = theme_get_setting('zen_breadcrumb_home');
if (!$show_breadcrumb_home) {
  array_shift($breadcrumb);
}

```

---
Tags: 7, breadcrumbs
---


# Question
Title: validating the Uploaded Image name in Image field of Content type
I need to validate the Image Name uploaded via Image field in Content type.How can i validate the Image name.

Any Help is Appreciated

Thanks,

# Answer
> 3 votes
```
function hook_form_alter(&$form, &$form_state, $form_id){
    if($form_id == "YOUR_FORM_ID"){
        $form['#validate'][] = 'myvalidation_function';
    }
}

function myvalidation_function($form, &$form_state) {
    $file_fid = $form['field_your_content_type_image_field']['LANGUAGE_NONE'][0]['#value'][fid];
    $file = file_load($file_fid);
    $file_name = explode( '.', $file->filename);
    if($file_name[0] != $form['type']['#value']){
        drupal_set_message('your validation error');
    }
}

```

Hope this works. I have tested on my system :)

---
Tags: 7
---


# Question
Title: How to add some javascript in a form using form API?
I need to output some javascript codes as well as form fields.

I am using Drupal 6 and form API to build the form. How can I output those javascript codes? Is there a 'javascript' type like textfield/checkboxes ?

I have tried the code below but string 'Array' is printed on the page instead of js code:

```
$form['target'] = array(
'#prefix' => '<div id="newuser">' ,
'#value' => drupal_add_js('alert("hello)','inline'),
'#suffix' => '</div>'

```

);

# Answer
drupal\_add\_js() is for adding script tags to the page. It doesn't go in a form element.

```
 drupal_add_js('alert("Hello!")', 'inline');

```

would go by itself on a line. This would add that javascript to the page, so when the page loads you would get a pop-up that says "Hello".

and/or to add markup to the page you would do this:

```
$form['target'] = array(
  '#prefix' => '<div id="newuser">',
  '#value' => t('Hello'),
  '#suffix' => '</div>'
);

```

Which would add the text "Hello" to the form in the newuser div.
> 2 votes

---
Tags: 6, forms
---


# Question
Title: Next link on node page based on its taxonomy term
So here is what I'd like to achieve:

I'd like to put a Next link to every content of a type, that links to the next content with the same taxonomy term.

So for examle if I have A, B and C products with the term 'clothing' on them, I need a link A product that points to B, one link on B that points to C and so on.

How is this possible to do?

# Answer
It's only in Alpha but the Treewalk Previous / Next module appears to have that functionality:

> Previous/Next (Back/Forward) links for entity and other pages, that allow to visit them in a sequence.
>
> Unlike with the existing back/forward module, the sequence of items (entities etc) is not based on a view, but on hierarchical information already present in your site.
>
> * It provides a configurable block with prev/next links based on menu trees. The block is named "Treewalk Prev/Next (Menu)"
> * It provides Display suite fields with prev/next links based on entityreference / taxonomy\_term\_reference fields. The ds fields are named as "Treewalk Prev/Next (...)".

I've never used it but it might at least be a starting point to implement the logic yourself.
> 5 votes

# Answer
You can use the Flippy module for this.

> Flippy is an ultra-simple module that generates previous/next pagers for content types. On the Node type administration screen, you can turn Flippy on or off for each content type. It'll generate a unique pager for each content type, so you can page through Articles or page through Blog posts, but you can't page through all nodes on the site.
> -1 votes

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


# Question
Title: How to enable menu link when creating a new node?
I try to enable the menu link programmatically, here is how I do it:

```
function create_menu_link() {
    $node = new stdClass();
    $node->type = 'mytype';
    node_object_prepare($node);

    $node->menu['link-title'] = $menu_title;

    node_save($node);
}

```

But setting only the title is not working. In `$node->menu` there is some other variables like `mlid` and `plid` which are set to `0` it has to do with this ? The `menu_name` is set to `main-menu:0`, `module` is set to `menu`.

# Answer
> 5 votes
You'll need to create the menu item separately, using `menu_link_save`

```
$item = array(
  'menu_name' => 'main-menu',
  'link_title' => $node->title,
  'link_path' => 'node/'. $node->nid,
);
menu_link_save($item);

```

# Answer
> 1 votes
You don't have to create the link manually. The menu\_node\_save() hook will take care of link creation automatically when saving the node, if you provide the following variables:

```
  $node->menu['enabled'] = TRUE;
  $node->menu['link_title'] = t('My title');
  $node->menu['description'] = ''; // Needed even if empty to avoid notices.

```

---
Tags: 7, routes
---


title: How to set a validation error via ajax?

text:
# Question
Title: How to set a validation error via ajax?
I am using the formapi to create a form. On one of my fields I have an #ajax call. When the field is changed I call the function. I recreate the form and then replace the whole form on the page. This works fine.

When creating the form I have some logic that sets the form state to see if a field has a value. If it has a value then I show some more fields. If the value is not set then I don't show the fields. I am showing the fields by setting the `#access` on the field.

I need to add some validation on the form when the ajax call is triggered. I have tried adding the validation using `form_set_error()` in the function that creates the form and in the ajax callback but the error is not displayed on the screen.

Am I going about this the wrong way completely? How can I get the form error to display?

# Answer
> 0 votes
If the name of your form is modulename\_admin\_form() then you can add a function modulename\_admin\_form\_validate(&$form, &$form\_state).

In that validate function you can form\_set\_error() from in that validate function.

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


title: Code fails only if not logged in

text:
# Question
Title: Code fails only if not logged in
Hello I'm currently working in the template.php file to preprocess a view and i'm experiencing strange things:

This relates to a field collection field:

```
  $collect_field = $value->field_field_screenshot[0]['rendered']['entity'];

```

Without being logged in this code fails with

> Notice: Undefined index: entity

If logged in everything is fine...

Somebody could imagine what is happening here?

# Answer
> 0 votes
As per the error message, no such index `'entity'` exists in the array `$value->field_field_screenshot[0]['rendered']` Do a `dpm($value->field_field_screenshot[0]['rendered'])` when both logged in and logged out and you will see the difference.

Is `field_screenshot` associated with a user account or profile? In which case, the anonymous user object has no such field, so you're trying to assign to `$collect_field` something that doesn't exist. You should assert whether the user is logged in or not before doing the assignment.

---
Tags: views
---


title: Pulling data into a content type

text:
# Question
Title: Pulling data into a content type
I'm hoping to get some opinions on the best way to proceed. We are migrating our website from a Microsoft Environment to Drupal 7 and I appear to be having trouble wrapping my head around how to do a couple of things.

We have about 50 locations, and each location might have any number of workers. I have created 2 content types, Location & worker. What I want to do is to create a "view" (for lack of a better term) which will list all of my locations grouped by county. No problem. Now, when the user clicks on one of the locations, I want to show the data for the location (address, phone number, etc) but I also want the location content type to be able to pull a list of workers (from the worker content types) that are at that site.

I have a common field in each content type of location\_number, so basically what I need to do is a SQL JOIN operation. I've looked into the Views module and it seems that using that I would have to create a separate view for each location (unless I'm missing something), when what I really want to do is create a more 'generic' view which I can plug into node template and have it auto-generate what I need. I don't want to have to manage 50+ views.

My first instinct is to say write some custom PHP code that gets the data I want. In SharePoint, I would just write a web part with a simple LINQ query right back to the 2 lists and plug it into the page. Is there something similar in to this in Drupal or is there an easier way to go about what I"m trying to do.

Any advice is appreciated.

# Answer
This is core functionality in views and very easy to do with views relationships and entity references. Essentially, what you want to do is create a new entity reference field in your location content type to reference the workers, ex: "Related Workers". You would then add the workers to each of the locations using the normal edit form.

Now in the node output, you'll have a list of these referenced entities as a unordered list of links to the "Related Workers" node which you can customize using the display fields options.

To add these related workers (and all their fields) in a combined view (ex. the join you are referring to) you would just need to create a relationship, using this entity reference field.

This whole process is explained in this screencast from NodeOne

http://nodeone.se/sv/node/782
> 0 votes

# Answer
Thank you all for the replies.

I've got the relationships working and everything, however, now I'm having an issue with the actual implementation. I have a contextual filter of Nid on the view and when I use the "Contextual Filter Preview" box in the view creation form, it works beautifully, however, I've added the block to the page as I want it, but no matter which "Location" I click on, all of the workers show up, regardless of location. It's almost like the contextual filter is not working right in practice. Is there something I am missing?

Thanks for the help!
> 0 votes

# Answer
I got it! I wasn't using "Provide Default Value" --\> "Content ID from URL" in the contextual filter.
> 0 votes

---
Tags: views, nodes, database
---


# Question
Title: Why does Apache show such drastic differences in memory usage when using mod_php?
I've taken steps to reduce as much as possible the memory footprint of my Apache mod\_php processes by disabling Apache modules as well as Drupal modules.

When the server is under light load, I see memory usage between 40MB and 80MB. However, when the server is under heavy load and there are about 100 processes active, 90 of those 100 will be 12MB.

I'm assuming this is a good thing of course. I know that the PHP is embedded into each process so then why would there be such a drastic difference in the memory footprints, 12MB and 80MB, and why can those first 10 be in the area of the 12MB range?

# Answer
The main difference is that different requests to a Drupal site will do different things.

Serving up a static image, CSS, or JS file has very little overhead and the PHP handler doesn't do anything.

Serving up a cached page invokes the PHP handler and Drupal bootstraps, but the overhead is small, compared to other requests.

Serving up a non-cached page will cause a full Drupal bootstrap, and all of the PHP necessary to render the URL will run.

Serving up an image derivative will invoke PHP, and there will be additional memory overhead.

Serving up a page with an empty Drupal cache will result in all of the overhead of rebuilding the memus, registry, etc, and can cause a pretty big memory swell.

So, I suspect you are seeing the result of processes serving up different types of requests.
> 3 votes

---
Tags: performance
---


# Question
Title: Replacing core forum pages with views throws a warning
I set up views for `forum/%` paths to replace the core forum pages, and it works fine except I get this error:

```
Notice: Trying to get property of non-object in forum_menu_local_tasks_alter()
(line 169 of opt/jenkins/blahblah/modules/forum/forum.module).

```

Line 169 is the last line in this code block:

```
/**
 * Implements hook_menu_local_tasks_alter().
 */
function forum_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  global $user;

  // Add action link to 'node/add/forum' on 'forum' sub-pages.
  if ($root_path == 'forum' || $root_path == 'forum/%') {
    $tid = (isset($router_item['page_arguments'][0]) ? $router_item['page_arguments'][0]->tid : 0);

```

This is failing because `$router_item['page_arguments'][0]` is defined but it's a string, not an object.

So what are my options here?

* I don't want to hack the forum module to change that line
* I don't want to change the path of my views to something besides forum/%
* So I think I need to figure out how to unset `$router_item['page_arguments'][0]` so that that conditional will short circuit? Or is there another way?

# Answer
> 0 votes
I ended up just using a different URL and fixing links to point to that one. Not a real fix to my problem, but whatever.

---
Tags: 7, routes, views, nodes
---


# Question
Title: How to change the pagination of related entities displayed on a taxonomy term page?
On a default taxonomy term page, related contents are automatically paginated by 10.

Let's say those related contents are always nodes and we always display the default teaser view mode.

How can I change the number of *node teaser by page* **without using a module or a view?**

# Answer
The taxonomy module uses the `default_nodes_main` variable to decide how many to show per page (this happens around line 55 of taxonomy.pages.inc in case you're interested).

Usually you would implement a custom module and provide a form to override that variable for your users. But you don't *have* to do that, if you just want to set the variable once and be done with it use one of the following methods instead:

1. Use Drush (`drush vset default_nodes_main 20`)
2. Add a PHP snippet somewhere that will be run in your site (you only need to do it once)

```
variable_set('default_nodes_main', 20);

```
3. Use the Devel variable editor
> 1 votes

---
Tags: taxonomy-terms, theming, 7, paging
---


# Question
Title: How to rewrite the value of an array element in page.tpl.php
I'm totally new to PHP programming and modifying the values of Drupal output with php customisations, so sorry if this question seems dumb.

In Drupal 6 I need to rewrite the value of the array element named **image** shown below to strip out all instances of **../**

From Dev Load and Dev render tabs, the variable I need to change is here

**opengraph\_meta** (Array, 16 elements) (one of the 16 array elements) --- **image** (String, 45 characters ) **../../../images/spider-veins-before-after.jpg**

From the info I can see under the devel tab with themer info switched on, I think I should be looking to alter it in the variable in page.tpl rather than template.php

Any guidance?

# Answer
> 0 votes
You can use php's preg\_replace() function and parse through that array and replace the output. Keep in mind you'll need to know a little regex.

http://php.net/manual/en/function.preg-replace.php

example:

```
<?php
$string = 'The quick brown fox jumped over the lazy dog.';
$patterns = array();
$patterns[0] = '/quick/';
$patterns[1] = '/brown/';
$patterns[2] = '/fox/';
$replacements = array();
$replacements[2] = 'bear';
$replacements[1] = 'black';
$replacements[0] = 'slow';
echo preg_replace($patterns, $replacements, $string);
?>

```

---
Tags: 8, theming, hooks
---


# Question
Title: how to create two or more view with in a single view
I want to create a view which outputs as page . Within that view ,i need to create two or more views they will react based on the arguments to their parent view

# Answer
What you need is a views attachment to the main parent view. Fist you create a new Views Display, say a block. then on the parent view, attach that view to it. Now turn on inherit contextual filters so you can pass the arguments over to the other view. If you want finer control with the output and fields you can try: http://drupal.org/project/views\_php
> 0 votes

# Answer
Have you tried Views Field View?

> This module allows you to embed a view as a field in a view. A new field handler is made available, so this can also be used in area (header/footer/empty) handlers as well as rows.
>
> This view handler can accept arguments from fields of the parent view using tokens and pass them into the child view for each row. Raw or rendered token values can be used, as well as static values.
> 0 votes

---
Tags: views
---


# Question
Title: How to change checkboxes options with ajax callback
I'm sorry if this is repeated somewhere, but I really did try to look and couldn't come up with anything.

My scenario:

I have a form, and within that form I have a div/wrapper, with two elements in it: a) a text field and b) a checkboxes element

I have two different elements that change the values/options of those using the #ajax attribute

* 1) a textfield that, when changed, updates the value in a) and populates the options in b)
* 2) a button that's pressed (after the user enters some data) that adds an option to b)

1) works fine 2) semi-works; when you add (x), it doesn't show up (though the data gets stored in the DB fine). If you immediately add (y), (x) shows up in the options, but not (y). Add (z), and (y) shows up, and so on; so, it's always one back....

1) and 2) use different callback functions, but utilize the same wrapper

The form:

```
function waiver_create_waiver($form, &$form_state)  {
  $form['id'] = array(
    '#type' => 'textfield',
    '#title' => 'ID',
    '#ajax' => array(
      'callback' => '_update_user_info',
      'wrapper' => 'user-info-wrapper',
    ),
  );
  $form['user_info_div'] = array(
    '#prefix' => '<div id="user-info-wrapper">',
    '#suffix' => '</div>',
  );
  $form['user_info_div']['username'] = array(
    '#type' => 'textfield',
    '#title' => 'User Name',
  );

  $id = trim($form_state['values']['id']);
  $user = user_load_by_name($id);

  // Create the checkboxes
  $user_hardware = _get_users_hardware($user);
  $hardware_options = array();
  foreach($user_hardware as $h)  {
    $hardware_options[$h['hid']] = $h['hardware_type'] . ' (' . $h['manufacturer'] . ') ' . 'S/N: ' . $h['serial_number'] . ', Last Seen: ' . date('D, n/d/Y g:i a', $h['last_seen']);
  }
  $form['user_info_div']['selected_hardware_checkboxes'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Select Registered Hardware'),
    '#options' => $hardware_options,
  );

//...some textfields and selects for entering hardware info, removed for brevity...

$form['register_hardware_fieldset']['register_button'] = array(
  '#type' => 'button',
  '#value' => 'Register New User Hardware',
  '#ajax' => array(
    'callback' => '_update_hardware',
    'wrapper' => 'user-info-wrapper',
   ),
);

return $form;
}

```

Callback for 1) $form\['id'\]\['#ajax'\]

```
function _update_user_info($form, &$form_state) {
  $id = trim($form_state['values']['id']);
  $ldap_search = ldap_connector_query_ldap(trim($id)); // This is a custom LDAP query function
  $form['user_info_div']['username']['#value'] = ucwords(strtolower($ldap_search['cn'][0]));

  return $form['user_info_div'];
}

```

Callback for 2) $form\['register\_hardware\_fieldset'\]\['register\_button'\]\['#ajax'\]

```
function _update_hardware($form, &$form_state)  {
  $id = trim($form_state['values']['id']);
  if($id != NULL && $id != '')  {
    $user = user_load_by_name($id);
    // If the user isn't on the site yet, create an account for them
    if(!$user)  {
      $new_user = array(
          'name' => $id,
          'pass' => user_password(),
          'mail' => $id . '@email.com',
          'init' => $id . '@email.com',
          'status' => 1, // Active user
          'roles' => array(DRUPAL_AUTHENTICATED_RID => "authenticated user"),
      );
      $user = user_save(NULL, $new_user);
    }

// ...Find $hardware_type and $manufacturer from elements cut from above for brevity...

    // Insert the hardware in to the database...
    db_insert('waiver_hardware')->fields(array(
      'user_id' => $user->uid,
      'date_added' => REQUEST_TIME,
      'hardware_type' => $hardware_type,
      'manufacturer' => $manufacturer,
      ))
      ->execute();
  }
  return $form['user_info_div'];
}

```

EDIT: I've tried adding the options to the checkboxes element within the callback, as well as making the $form a reference call, but to no avail.

# Answer
I think the problem is simply a matter of the order the functions are run in.

The AJAX callback will run *after* the form has been built. So even though you're adding the new item to the database, the code to build the checkbox options (from `$user_hardware = _get_users_hardware($user);` downwards) has already run. Since it's already run, the new DB item won't be shown until the next time the page is loaded.

If that is the problem the fix would be as simple as adding a bit of code to the end of your `_update_hardware()` function, to populate the new options:

```
// ...

// Insert the hardware in to the database...
db_insert('waiver_hardware')->fields(array(
  'user_id' => $user->uid,
  'date_added' => REQUEST_TIME,
  'hardware_type' => $hardware_type,
  'manufacturer' => $manufacturer,
))->execute();

$hardware_options = array();
foreach($user_hardware as $h)  {
  $hardware_options[$h['hid']] = $h['hardware_type'] . ' (' . $h['manufacturer'] . ') ' . 'S/N: ' . $h['serial_number'] . ', Last Seen: ' . date('D, n/d/Y g:i a', $h['last_seen']);
}

$form['user_info_div']['selected_hardware_checkboxes']['#options'] = $hardware_options;

return $form['user_info_div'];

```
> 1 votes

---
Tags: ajax
---


title: Querying a web service via WDSL

text:
# Question
Title: Querying a web service via WDSL
I am thinking about creating a search engine frontend for a special use case using Drupal 7. There are some modules in the module directory, and questions like Consume SOAP web service in Drupal 7 on SO, but I still am confused.

How is the mapping from external datasets to dynamic Drupal nodes done? For every dataset I retrieve through my service's WSDL interface, I'll need to create a node, a block or anything displayable in Drupal.

Is this even possible within the scope of Drupal's framework?

# Answer
Yup its possible, PHP is specifically a web based language -- which Drupal is built upon.

For a REST based consuming service client for instance look at the Guzzle drupal community project. There is also the Services Client drupal community module to consume remote web services and uses UUIDs to map/sync fetched data. Your mileage may vary but all the pieces exist within Drupal and PHP. For instance even D7's core drupal\_http\_request can be used to craft your own HTTP requests, or your underlying PHP's installation CuRL library if you find drupals http function hindered by defaults.

There is also an issue and related sandbox project to add SOAP support to the Feeds drupal community module.

You say SOAP but thats only 1 piece of what can go over the wire. I've had to consume WS-\* + SOAP based APIs from Drupal/PHP and I ended up creating XML by hand with CuRL to do it all. There are also libraries such as:

http://wso2.com/products/web-services-framework/php/

or this library to extend php5 ext/SOAP:

https://code.google.com/p/wse-php/

Ultimately understanding the remote API specs, and inter-operating with them from Drupal is on you the developer.
> 1 votes

# Answer
> How is the mapping from external datasets to dynamic Drupal nodes done?

Effectively, it's done manually. You can use PHP5's SOAP client, or a third party one, and write your custom integration. There's no generalized module for this task, because each API is different.

The answer you linked to on SO shows the basics.
> 1 votes

---
Tags: 7, nodes, search, services
---


# Question
Title: Render date field in custom format in tpl file
In a content type tpl file I can print my date field with the following:

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

```

However I need a custom date format. So instead of something like this: Sunday, June 9, 2013 - 16:50

I need to print: June 9th Sunday

I cant change the default date formats site wide or the node's field, I need to just modify how its printed in this instance.

# Answer
Ive solved it a different way. Ive created a custom date format and I can chose that as the display option for the field for a specific view mode.

/admin/config/regional/date-time/formats
> 0 votes

---
Tags: 7, theming
---


# Question
Title: Is there a Drush command to check the distribution version?
Just that, Is there a Drush command to check the distribution version?

Let's say I have installed the commerce\_kickstart distributionn, how do I check the version of this distribution with Drush?

this one doesn't work:

> drush pmi commerce\_kickstart

# Answer
> 4 votes
As far as I know, no.

Since `commerce_kickstart` is not a module, but a profile, the *drush* commands for getting info about a module (e.g.):

```
drush pm-info commerce_kickstart
drush pm-list | grep commerce_kickstart

```

will not work.

# Answer
> 4 votes
Try using drush core-requirements command. It returns the status report in table form, and the information you want should be about 3 or 4 rows down.

```
drush rq | grep Kickstart

```

# Answer
> 2 votes
If you want to check the Drupal version then simplest is to run `drush status` from a drupal installation folder. That will tell you Drupal Version on the first line, no matter which installation profile you used to install it.

---
Tags: drush, distributions
---


# Question
Title: Default user relationships with the site admin
I am using the User Relationships module for my Drupal7 site. I have created a one way relationship with reciprocal by the name "Follower". So if User A can be followed by User B. Also, User A can follow User B. Now i set out in the process of creating a default relationship. I did that but it works only one way. I want that by default all user follow and are followed by the ADMIN. the default relationship that i created through the CMS works fine but it works only one way. I see that Admin is following the users but not vice-versa. Also, this happens only for new users of the site. I do not see old users having that default relationships. How can i achieve that? Any suggestions.

# Answer
I was able to achieve this with `rules` \+ `user relationship rules` modules.

**Export:**

```
{ "rules_follow" : {
    "LABEL" : "follow",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "user_relationships_rules", "rules" ],
    "ON" : [ "user_insert" ],
    "DO" : [
      { "user_relationships_rules_action_create_relationship" : {
          "relationship_type" : "1",
          "requester" : [ "account" ],
          "requestee" : "1",
          "approve" : 1
        }
      }
    ]
  }
}

```

**Rule Details:**
Event: *After saving a new user account*

Conditions: *None*

Action: *Request, create or approve relationships between users*

**Rule Settings:**
Relationship Type: *\[your defined relationship\] (follower)*

Requestor: (Data Selection Method) Data selector "account"

Requestee: (Direct input mode) "1" (or the user ID of your admin account)

Approve Relationship: TRUE
> 0 votes

---
Tags: 7, users
---


# Question
Title: How can I filter out specific words in a node body?
For example, suppose a user creates a node with body value "Hi everyone. GARBAGE VALUE This is my node." Upon submission, I want to be able to filter out "GARBAGE VALUE" and replace it with nothing (or have a replacement value) so that when the node is displayed, it only displays "Hi everyone. This is my node."

Is there any way to do this? Rules? (Rules is the only module that I have yet to figure out despite trying.)

# Answer
Apart from the Rules module,

* the Wordfilter module allows site administrators to filter certain words on all pages.
* the Phonetic module goes a step further by including the phonetic characteristics in the comparison as well as a list of profane words.
> 1 votes

# Answer
Both filters worked for me as of date of this posting, except Phonetic word filter did not catch similar words with same sound, different spelling. While they filter words in comments and node titles, they do not filter words in Statuses as a View. ALSO, from my testing, Wordfilter recognized the base word when used with -ing, -ed, Phonetic did not (you have to enter each specific word). This makes Wordfilter a better choice.
> 0 votes

---
Tags: 7, nodes, rules
---


title: Alter breadcrumbs

text:
# Question
Title: Alter breadcrumbs
I am looking around a way to alter my breadcrumb for a particular page,I am using tb\_sirate theme and menu\_breadcrumbs module. I have tried altering the breadcrumbs using mytheme\_breadcrumbs(), its working but I am not able to return it in way that it can match to breadcrumbs theme on the site. Thanks in advance.

# Answer
> 1 votes
This is code I put on my theme template file and it worked

```
function tb_sirate_breadcrumb($variables) {
  $breadcrumb = $variables['breadcrumb'];
  if ($breadcrumb[1] == 'Calendar') {
    $links[0] = l(t('Home'), '<front>');
    $links[1] = ('Events');
    drupal_set_breadcrumb($links);
  }
  $breadcrumb = drupal_get_breadcrumb();
  if (!empty(
      $breadcrumb)) {
    $crumbs = '<ol class="crumbs">';

    foreach (
    $breadcrumb as $value) {
      $crumbs .= '<li class="crumb">' . $value . '</li>';
    }
    $crumbs .= '</ol>';
  }
  return $crumbs;
}

```

---
Tags: breadcrumbs
---


# Question
Title: How can I change the default link to the email contact form?
I'm trying to change the default link generate by the email\_field module so It shows an image instead of the text (Contact person by email).

I went into the module and foun the part I need to change, but because I'm new to drupal and php I have no clue how to change it...

The code I think I need to override:

```
function email_field_formatter_view($object_type, $object, $field, $instance,    $langcode, $items, $display) {
  $element = array();
  switch ($display['type']) {

    case 'email_contact':
      $ids = entity_extract_ids($object_type, $object);
      foreach ($items as $delta => $item) {
        $element[$delta] = array('#markup' => l(t('Contact person by email'), 'email/' . $object_type . '/' . $ids[0] . '/' . $instance['field_name']));
        // Since email is always sent to first item's email, break after any email address found.
        break;
      }
      break;
  }
}

```

The contact person by email is the part I want to change to
'\< div class="email\_image"\>\< /div\>'

Anyone who can help with this? Or knows where I can find some help?

Thx up front.

# Answer
You have two options to solve your issue:

**CSS Option:** You can replace text with image using css, add the following code to your css file and make sure to replace field name accordingly

```
.field-name-field-custom .field-item a {
  display: block;
  text-indent: -99999em;
  background-image: url('../images/image_name.ext');
  background-position: left top;
  background-repeat: no-repeat;
}

```

**Note:** field-custom should be replaced with your email field

**Field Formate Option:** You can create a new field formate in a new module and then you can choose from **Field UI** the new formate that you created.

Implement the following code in a Drupal module.

```
/**
 * Implements hook_field_formatter_info().
 */
function mymodule_field_formatter_info() {
  return array(
    'email_contact_image' => array(
      'label' => t('Email contact form image link'),
      'description' => t('Display an image link to a contact form.'),
      'field types' => array('email'),
    ),
  );
}

/**
 * Implements hook_field_formatter_view().
 */
function mymodule_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();

  switch ($display['type']) {

    case 'email_contact_image':

      $ids = entity_extract_ids($entity_type, $entity);

      if ($ids[0] !== NULL) {
        foreach ($items as $delta => $item) {

          $img_vars = array(
            'path' => drupal_get_path('theme', 'THEME_NAME') . '/images/IMAGE_NAME.EXT',
            'alt' => t('Contact person by email'),
            'title' => t('Contact person by email'),
            'attributes' => array('class' => 'some-img', 'id' => 'my-img'),
          );
          $img = theme('image', $img_vars);

          $options['html'] = TRUE;

          $element[$delta]['#markup'] = l($img, 'email-contact/' . $entity_type . '/' . $ids[0] . '/' . $instance['field_name'], $options);
          // Since email is always sent to first item's email, break after any email address found.
          break;
        }
      }
      break;
  }

  return $element;
}

```

**Notes:**

* make sure to replace `mymodule` with your own module name
* make sure to replace `THEME_NAME` with your own theme name
* make sure to replace `IMAGE_NAME.EXT` with your own image name

Creating modules - tutorial
> 1 votes

---
Tags: 7, emails
---


# Question
Title: Add content to a render array in a content type from my custom module
I created a content type that is used to display a list of videos hosted on brightcove. I have a module that is setting a cookie for the anonymous user when they watch one. My end goal is to display a viewed/unviewed icon for the user on the list.

I have all the data I need in the cookie. I just need to create a module that reads the cookie data and edits the render array for the content type. The issue is I am not sure how to add new values to that content type's render array. Is there a hook I can use to get access to the specific content type to add a key/value for viewed/unviewed? This is for drupal 7.

Thanks for the help.

# Answer
`hook_node_view()` was made for exactly that:

> Act on a node that is being assembled before rendering.

e.g.

```
function MYMODULE_node_view($node, $view_mode, $langcode) {
  if ($node->type == 'my_type' && $view_mode == 'full') {
    if (in_array($node->nid, $_SESSION['viewed_videos'])) {
      $node->content['viewed'] = array(
        '#markup' => t('You have viewed this video'),
        '#weight' => 10,
      );
    }
  }
}

```
> 2 votes

---
Tags: 7, nodes
---


title: drupal 7 contextual filter views update

text:
# Question
Title: drupal 7 contextual filter views update
I updated views 3.0 to 3.7 and it broke a slideshow view that was setup with contextual filter to display certain content based off the url. Same setup just updated views if anyone can tell me why this does not work with the new views or how to make it work, would be most appreciated.

# Answer
> 0 votes
I was able to track the issue to a change made in views module that was committed with 3.1 release. Contextual links statement was changed from 'OR' to 'AND' causing issues with the setup that was run with version 3.0.

http://drupal.org/node/1451218#comment-5980636

---
Tags: views
---


title: Multiple Arguments with Views

text:
# Question
Title: Multiple Arguments with Views
I created a views page displaying "full posts" of any content type.

Next I gave the page URL to be "test/%"

Next I added a contextual filter for Nid

* Check "Specify validation criteria" below
* "validator" set to content
* and "Filter value format" i set to "node IDs separated by , or +"

Now in my preview I put "1+2+3" and I only get node 1. Node 2 and 3 dont show up.

site.com/test/1+2+3 also only gets node 1

How can I get multiple nodes on 1 page?

# Answer
> 2 votes
Did you check the '**Allow multiple values**' checkbox in the 'More' section of the contextual filter setup? The 'More' section is collapsed by default, so it's easy to miss...

You have to check that box:

---
Tags: views
---


title: Session Timeout module

text:
# Question
Title: Session Timeout module
What's the best module for a session timeout?

I simply want users to be automatically timed out after a period of inactivity.

The Automated Logout module looked like it could to the trick, but it seems like it does a lot more too. Also, I am using Drupal 7 and it's still in dev.

# Answer
> 6 votes
You have two options in the settings file that should allow you to configure the session timeout however you wish, `session.gc_maxlifetime` & `session.cookie_lifetime`.

```
/**
 * Set session lifetime (in seconds), i.e. the time from the user's last visit
 * to the active session may be deleted by the session garbage collector. When
 * a session is deleted, authenticated users are logged out, and the contents
 * of the user's $_SESSION variable is discarded.
 */
ini_set('session.gc_maxlifetime', 200000);

 /**
  * Set session cookie lifetime (in seconds), i.e. the time from the session is
  * created to the cookie expires, i.e. when the browser is expected to discard
  * the cookie. The value 0 means "until the browser is closed".
  */
ini_set('session.cookie_lifetime', 2000000);

```

---
Tags: 7, sessions, users
---


# Question
Title: Drupal gives error to admin, anonymous users can browse pages
Anonymous users can browse various pages, when logged in, it gives "The website encountered an unexpected error. Please try again later". I am using drupal 7 commerce. Before this error I installed drupal example modules and drupal commerce example modules. THe image is attached which shows the errors.

# Answer
The reason is that the error message only prints when an admin is logged in, you can disable that by going to Administer \> Site configuration \> Error reporting, anyway you can still fix the problem, by rebuilding your permissions, it mostly can cause by enabling permission dependent modules, like content access or something else.
> 0 votes

---
Tags: commerce
---


# Question
Title: Can users disable email notifications sent to them by Rules?
One of my Drupal sites has a bunch of Rules set up to send email notifications to various roles when certain things happen on the site (new content added, etc.)

Is it possible for one of the site users to change a setting in their profile so that they *won't* get sent these notification emails?

I know that in the user account profile, you can uncheck the box for the personal contact form - but does that have any effect on getting emails sent by the System or by Rules processes?

**Clarification**: I actually don't want users to be able to opt out. I'm trying to investigate if they have a way to do that because I don't want them to.

# Answer
> 4 votes
Unchecking the box for the contact form only affects the personal contact form provided by the **Contact** module (part of Core).

I added a similar feature (allow users to opt out to e-mails sent via rules) to a Drupal 7 site in the following manner.

First, I added a field (Boolean single on/off checkbox) labeled "Send me notifications" to the user account page.

Then, I made a couple rules to award a role *nomsg* upon checking the box and to remove the role upon unchecking the box.

After that, I created a rules component of type *condition* that checked to ensure that the user did NOT have the *nomsg* role. I then added that component to all rules that sent e-mails. This was a bit of a pain, because some of the rules that sent e-mails also did other things, so I had to break out the part about sending the e-mail (as another component) so that the other actions would be performed but the e-mail would not be sent if the user had the *nomsg* role.

---
Tags: users, rules, emails
---


title: Save a node from another site

text:
# Question
Title: Save a node from another site
I have a newspaper web based management system that allow users to manage articles and news and photo album using J2EE (Internal system to the newspaper)

I need to make a website using drupal 7 to this newspaper

I need to make a button in the J2EE system that will save a node in my site(plain text,Full html test,files like images and pdf)

So I need to make a webservice in my drupal site and call it from the J2EE

Is there any module that help me in this issue,if not how to customize it.

# Answer
> 4 votes
The Services module will definitely help you with that

> A standardized solution of integrating external applications with Drupal. Service callbacks may be used with multiple interfaces like REST, XMLRPC, JSON, JSON-RPC, SOAP, AMF, etc. This allows a Drupal site to provide web services via multiple interfaces while using the same callback code.

It has CRUD operations for nodes, files, users and plenty more. There's a video presentation available that introduces it properly, and there are loads of code samples on the web to get you started.

---
Tags: 7, services
---


# Question
Title: How to implement facebook feed which shows the latest facebook wall post
I would like to display latest facebook wall post on my website. I found the Facebook Pull module; but it doesn't work for me. I have add the appropriate app id and App Secret and nothing is showing up. Any ideas?

Do you know how I can accomplish it? I never have a similar problem with a twitter\_pull module which does the same but for the twitter.

# Answer
> 1 votes
Why not use the facebook like box plugin? If you're just looking for a widget like capability on your site, this is the easiest and pushes the heavy lifting on to Facebook's servers without any more modules or extra PHP:

http://developers.facebook.com/docs/reference/plugins/like-box/

Play around with the options, you probably just want to show the stream. There are other options below to customize the output of this as well.

# Answer
> 0 votes
I installed the Facebook Pull and it worked very well at my local. But when i pushed the code in the live website. The feed facebook didn't show up. I looked the log entries and find out there was the "Failed to fetch data from the Facebook Graph" error in the logs. I followed the http://drupal.org/node/1587598 patch and it worked well.

---
Tags: social-network
---


# Question
Title: Set blank vale as default for a select box using Drupal form API?
I'm building a form in a module using the Drupal Form API (Drupal 6) and have it mostly working, however I have a few required fields but don't know how to set a blank or null first selection option so the user will be forced to select an option. Here's an example of my code using my country select box:

```
$form['address']['country'] = array(
    '#type' => 'select',
    '#title' => 'Country of Residence',
    '#options' => get_country_form_array(),
    '#required' => true
);

```

Here's the get\_country\_form\_array() function:

```
function get_country_form_array() {

    $countries = variable_get('form_countries');

    $output[0] = 'Select a Country';

    foreach ($countries as $country) {

        $output[$country[0]] = $country[1];

    }

    return $output;

}

```

How do I add a blank first option to force a selection by the user?

# Answer
> 3 votes
redhatlab has the right answer. If it is not working as you'd expect just add a validate handler to check the value yourself:

```
function MYMODULE_form_function_name_validate($form, &$form_state) {
  if ($form_state['values']['country'] == 0) {
    form_set_error('country', t('Please select a country'));
  }
}

```

# Answer
> 4 votes
In Drupal 7, you could use the #empty\_option property, for which the default value is "- Select -" for a required field, and "- None -" for an optional field. The property adds the additional label as per the following cases:

* If `#required` is TRUE and there is no `#default_value`, an empty option is added to the select control to force the user to make an active choice.
* If `#empty_value` or `#empty_option` is set and `#required` is FALSE (default), an empty option is added to the select control, allowing the user to choose nothing.
* If none of `#required`, `#empty_value`, `#empty_option`, and `#default_value` are set, then no empty option is added to the select control. This leaves the control in a slightly illogical state, since all user agents automatically preselect the first available option. There's no way for the user to select nothing, and the user is also not forced to make an active decision.

The property is used only for "select" form fields.

# Answer
> 2 votes
You should use the default value (#default\_value)

```
$form['address']['country'] = array(
    '#type' => 'select',
    '#title' => 'Country of Residence',
    '#options' => get_country_form_array(),
    '#required' => true,
    '#default_value' => 0
);

```

Here is the part I missed the first time:

In your validation function for the form you will then do:

```
function name_yourform_validate($form, &$form_state) {
  if (($form_state['values']['country'] == '') || ($form_state['values']['country'] == 0)) {
    form_set_error('country', t('You must select a country.'));
  }
}

```

---
Tags: forms
---


# Question
Title: Is there any clean way to have the Drupal login form create a session for phpBB also?
I've made my peace with having two DB's and two sets of roles, permissions, etc. But I'd like to have just one login.

Is there a simple way to have the Drupal login throw a session cookie for phpBB with the same parameters as the drupal one?

# Answer
If what you want is a clean way to integrate phpBB with Drupal, I think phpBB Forum Integration is want you need.

This module will not only "embed" phpBB within a Drupal site (and synchronize account info, such as user names, roles, passwords, emails, signatures, and avatars, with only one login), but it also let phpBB topics be created from Drupal nodes.

The phpBB forum can be displayed in a full window, in a frame inside Drupal, or in a Drupal page.
> 1 votes

---
Tags: users, sessions
---


# Question
Title: How to group uploaded documents into folders?
I want to group my documents in sub folders... when i upload the document using core upload module, i want that those modules get categorised under different section and a user can see those and when he selects an optio then all the files under that folder gets displayed.

i am using drupal on shared web hosting.

# Answer
> 1 votes
In Drupal, this is probably easier to create a custom content type *Document*, to which you add a *file* field. You can then add a *taxonomy term reference* field targeting the included *Tags* vocabulary (in Drupal 7) and then tag the files however you like. Then, you can create views using the Views module to display the files however you like. This approach offers a lot of flexibility but will be very complicated to set up your first time.

Alternately, if you have a simple structure, you could create a custom content type *Group of documents* and attach a *file* field that allows for unlimited uploads. Then, you could create a node of the *Group of documents* content type for each page and upload the files that way.

I didn't describe a way to organize the documents into folders because Drupal doesn't really care about folder structure. If you really wanted to have a folder structure, it would be better to just upload them via SFTP and let users browse the directories without interfacing with Drupal at all.

---
Tags: files
---


# Question
Title: Is there a module for showing only posts in some defined date?
I would like to make a calendar addon for my website, which would look something similiar to http://www.nikerigarun.lv/ this (scroll it a bit downwards, on the right side). The funcionality would be to show only posts from some selected date, is there such a module for that and if there is, could you please recommend me one?

# Answer
> 1 votes
This is done with the Views module. Create a new view of content with a display type of 'block', and set it up as an unformatted list of teasers with links, then click 'Continue and edit'.

Add a filter on Content:Posted Day, and choose your conditions like 'is greater than' 'offset' '-10 days'.

You can then set any other views parameters to get what you want.

Save your view and go to **admin/structure/block** to find your block and place it where you want it.

# Answer
> 0 votes
There exists a project (named Calendar) that contains a module that will do this for you with far less work than Views alone. Note that its functionality os based upon both Views and Date, so you need to have those projects installed as well.

The calender module will allow you to set up a graphic calender (like the one you link to), rather than just a list of future events.

---
Tags: datetime
---


title: Views with Entity Reference

text:
# Question
Title: Views with Entity Reference
I'm not sure why this is difficult for me to get. It seems like it should be simple. I have a content type A and content type B. Content type B has an entity reference field to content type A. Content type B has an image field.

I want to display a view of type A, with all the images of a type B that reference it.

I've looked everywhere and it isn't making sense. Can someone please point me in the right direction?

EDITED: I figure it may help if I give a concept of what I'm trying to do. I have programs that I want to display. For each program I have, one or more sponsors donate to the program. When I display my view, I not only want to display my program content (content A), but also the logos of all the sponsors that donate to the program (content type B). Right now, for each logo, I get a duplicate fields for my programs (content A).

# Answer
> 5 votes
In your case i would use the EVA Field module in combination with Display Suite module.

The EVA field module provides an extra views display plugin (EVA Field Display) that allows you to attach a view dynamically to a node, user, term etc.

The Display Suite module works great with EVA and helps you by letting place the attached view any where you want within the node display layout.

Create a content view and add an EVA Field display. In the Entity Content Settings of this display select:

1. Node for Entity type
2. Content type A for Bundles
3. Leave Arguments as it is (id)

Then:

1. Add a relationship for the entity reference field you have on content type B referring to A
2. Add the fields you want from content type B.
3. Add filter for content type = content type B
4. Add a contextual filter Content nid with the relationship of the entity reference!
5. Go to query settings and check the Distinct setting.

Now what will happen is that for every node of type A an EVA field view display will be attached showing the corresponding fields of node type B. Using Display Suite you can place this attached view any where you want in the node layout.

Hope this helps.

# Answer
> 3 votes
The following instructions might help you to solve your issue:

* First add `Entity Reference: Referenced Entity` \- content type B field (sponsor) - from **Relationships menu**.
* Then add image field for content type B (sponsor) and select relationship from dropdown list - the relation you added in the first step.
* Edit Title field `Content: Title` and check `Exclude from display` and apply.
* Edit settings from **Format menu** and select `Content: Title` from `Grouping field Nr.1` dropdown and make sure to check `Use rendered output to group rows` and apply changes.

The above solution will eliminate content type A (programmes) duplication.

# Answer
> 1 votes
By using the rule module you could set up a view that when a page is viewed from Content A, it displays the images from Content B.

# Answer
> 0 votes
In views you have to add a relationship.

Create a view that shows content of type A.

Add a relationship, which will be for the entity reference field you have on content type A.

Then add a field to the view that is the image field from content type B and select the relationship you previously added in the settings for that field.

Let me know if you need further clarification.

---
Tags: 7, views, entities
---


# Question
Title: Will "features" be overwritten when there is a distribution update?
Example scenario:

1. I create a site using commerce\_kickstart 7x-2.0.
2. I modify some of the "Features"(ex. commerce\_kickstart\_user, commerce\_kickstart\_taxonomy) that are prepackaged with the distribution.

Question:

1. Will these "Features" be overwritten when an update comes, ex. commerce\_kickstart 7x-2.1 (Not really sure if there is such as a thing as a distro update. Tried to google, went to issue queues, IRCs to no avail)
2. If the answer to #1 is yes,how do you maintain your configurations to the "features" when an update comes? Should they be renamed and moved to "/sites/all/modules/my\_features"?

# Answer
Yes, they will be marked as overriden. The Features Override was designed for this use case, so try it and report back.
> 0 votes

---
Tags: commerce, distributions
---


title: is there api for After rate_save_vote?

text:
# Question
Title: is there api for After rate_save_vote?
I want do something after the eventAfterRate in php, and I have use the rate rules http://drupal.org/project/voting\_rules ,the result turn out not after,and the same as implement the hook\_rate\_widget\_insert. so is there api for After rate\_save\_vote?

# Answer
Rate relies on the Voting API module, which exposes `hook_votingapi_storage_add_vote()`:

> Save a vote in the database.

```
function hook_votingapi_storage_add_vote(&$vote) {
  _mongodb_votingapi_prepare_vote($criteria);
  mongodb_collection('votingapi_vote')->insert($vote);
}

```

I don't know of a Rate-specific hook but you might get somewhere using that one (all depends what you need to do I guess).
> 0 votes

---
Tags: rating
---


# Question
Title: need to show user firstname and lastname in search result page
I'm very new in drupal, and I have a custom user module where I need to show the user's first name and last name in the search result page. I used some of my code which is throwing a fatal error.

What is wrong with the code I am using?

```
function somik_user_byline($uid) {
  $cache = &drupal_static(__FUNCTION__, array());
  if (isset($cache[$uid])) {
    return $cache[$uid];
  }

  $account = user_load($uid);
  $byline = $account->name;

  $first_name = somik_user_profile_field_value($uid, 'field_firstname');
  $last_name = somik_user_profile_field_value($uid, 'field_lastname');

  if ($first_name && $last_name) {
    $byline = $first_name . ' ' . $last_name;
  }

  $cache[$uid] = $byline;

  return $byline;
}

```

# Answer
> 1 votes
For your error replace:

```
<?php print drupal_render(somik_user_byline($user->uid)) &nbsp .$info_split['date']; ?>

```

with

```
<?php print somik_user_byline($user->uid) . ' ' . $info_split['date']; ?>

```

For preprocessing you would use:

```
/**
 * Process variables for the search result template.
 */
function THEMENAME_preprocess_search_result(&$variables) {
  // Change variables here.
}

```

There is some more info here http://drupal.org/node/223430 It also links to some other useful related pages.

You need to clear the drupal cache when you add or remove a preprocess function.

**Edit:**

For your "Fatal error: Can't use function return value in write context"

It is because of this part:

```
if (!empty(somik_user_byline($user->uid))) {
  $info['user'] = somik_user_byline($user->uid);
}

```

Because you can't pass a function call into the empty() function like that. You need to give it a variable.

Because your somik\_user\_byline() function is always returning a string you can do this:

```
if ($name = somik_user_byline($user->uid)) {
  $info['user'] = name;
}

```

You can go even further than that still. Because your function always returns a non-empty string, you can just do this:

```
$info['user'] = somik_user_byline($user->uid);

```

Also, for it to be available in the template you have to add it to the $variables array.

For example, you are setting $info but to have it in the template you have to do

```
$variables['info'] = $info;

```

at the end and then $info will be available in your template file.

Also, in this case, $info is already full of other information to remember that this will overwrite whatever was alredy in $info from other modules.

If you want to keep the $info that is already there, but override the $info\['user'\] and $info\['date'\] parts, do this:

```
/**
 * Process the variables for search-result.tpl.php
 */
function somik_preprocess_search_result(&$variables) {
  $result = $variables['result'];

  // Override the user part of the info array.
  $variables['info_split']['user'] = somik_user_byline($result['node']->uid);
  // Override the date part of the info array.
  if (!empty($result['date'])) {
    $variables['info_split']['date'] = format_date($result['node']->created, 'short');
  }
  // Re-create the info string with the overridden data.
  $variables['info'] = implode(' - ', $info_split);
}

```

---
Tags: users
---


# Question
Title: Drupal views to display content updated today
For a drupal view, I want a filter such that in the block I can see Articles (created with a taxonomy term) either

Created/Posted today Updated today (might be created earlier) This is what I've done. I've added filters to the view:

Content: Has taxonomy term (= something) Content: Published (Yes) And contextual filters:

Content: Created day \[With default value to be Current Date\] Content: Updated day \[With default value to be Current Date\] With these settings I'm achieving my purpose of getting the posts which were created today, but the posts which were created earlier and updated today are not being picked.

# Answer
> 1 votes
For the filters all you should need is:

Content: Updated day \[With default value to be Current Date\]

Because you have the created date filter you are currently only getting nodes created today.

---
Tags: views
---


# Question
Title: Rules replacement pattern for image type field
I am using `Rules` and `HTML mail` module to send HTML email on various events. It is working fine, but I am getting problem in rendering image field(ie image) in email template.

I have field `field:cover-photo` which is of type image. This field appears under `Replacement Pattern` token section. But when I include it, in the email it shows

```
Property field_cover_photo

```

and not the image. Any idea how can I show image in email.

-- Many thanks for your time.

# Answer
Found the solution as follows:

To get the proper selector I switched to `Data Selection` mode.Then through hierarchy I got proper sector as `[comment:node:field-photo:file:url]`, which is URL of image. By using `img` tag, I am able to display image.
> 1 votes

---
Tags: 7, rules, tokens
---


# Question
Title: Show file field as thumbnail if file is an image?
I've added a field to comments to allow users to upload files. I want users to be able to upload different types of files, but if it's an image then show a thumbnail. Can this be done while just using 1 field?

# Answer
> 2 votes
All you need is writing your own display formatter for file fields. have a look at field\_example module to see where you should start:

first define your display formatter using hook\_field\_formatter\_info, here with `field types` you can specify that this display formatter is for file fields.

then all you need is implementing hook\_field\_formatter\_view, here you should output different `$element` based on `$item` extension.

after developing this tiny module, go to `comment display setting` in your content type page and select your new display formatter to rendering that field.

From field example module:

1. field\_example\_field\_formatter\_info
2. field\_example\_field\_formatter\_view

# Answer
> 2 votes
I could also create a template for the comment, or the field and then insert an "if".

# Answer
> 0 votes
I think your best candidate for this job is `hook_field_prepare_view()`. You can alter field's values just before they get to be displayed. Take a look at the docs here.

# Answer
> 0 votes
I found y'all's answers really helpful, but for my purposes, the custom\_formatters module seemed to work really well.

---
Tags: entities
---


# Question
Title: Why my Webform special token values not rendered correctly in D6?
I am trying to use "*Special Tokens*" in the Webform module (6.x-3.18) on Drupal 6. I'd like the data to populate a hidden field I've created with the email field on the same form.

Under default value for the hidden field I've tried using a number of different values including:

```
%post[submitted][email]<br />
%post[email]<br />
%post[submitted[email]]

```

None of this works. If I go edit the email field, it tells me my key is `email`. If I look at the name of the email field in the source code it's `submitted[email]`.

If anyone has any suggestions on what I'm doing wrong?

# Answer
> 1 votes
In case anyone comes across this, I finally found a thread confirming that Webform tokens in D6 do not support arrays, and I had to apply a patch for the functionality to work.

This is **NOT** a problem in D7

http://drupal.org/node/824606

Patch - http://drupal.org/files/nested\_tokens-824606-13.patch

---
Tags: 6, webforms, tokens
---


title: Adding options to View filter settings

text:
# Question
Title: Adding options to View filter settings
I want to add new option "Own Company" into "Options" select in View filter settings form: This is filter of entityreference field. Also I want to have opportunity alter views query with this value.

I tried with form\_alter but I can't save chosen value.

Also I wanted to write own views child class that will handle entityreference filter settings. But I can't find dafault handler in hook\_views\_data\_alter.

Also saw that views filter select in entityreference module is made with ctools plugins system. Filter settings form might be plugable but I can't manage to do it.

Has anybody altered views filter settings form?

# Answer
> 4 votes
1) Add new custom views filter handler that extends views\_handler\_filter\_in\_operator

```
class MY_MODULE_own_company_filter_handler extends views_handler_filter_in_operator {

  public function get_value_options() {
    $options = parent::get_value_options();
    $options['own'] = 'Own Company';
    $this->value_options = $options;

    return $this->value_options;
  }

  /**
   * Replaces "Own Company" value with real value.
   * Do query alter here or in query() function.
   */
  function pre_query() {
    parent::pre_query();

    // Check if "Own Company" was chosen.
    if (!empty($this->value['own'])) {

      // Unset "Own Company" 'own' value.
      unset($this->value['own']);

      // Get current "Own Company" value the way you like.
      $company_id = 100500; // Example value.

      // Set current "Own Company" value.
      $this->value[$company_id] = $company_id;
    }
  }

}

```

2) Implement hook\_views\_data\_alter() and add custom handler to all entityreference field filters

```
/**
 * Implements hook_views_data_alter().
 */
function MY_MODULE_views_data_alter(&$data) {
  // Loop all field filters.
  foreach ($data as $data_key => $data_field) {
    if (strpos($data_key, 'field_data_') !== FALSE) {

      // Get field name
      $field_name = str_replace('field_data_', '', $data_key);

      // Check if field filter is entity reference
      if (isset($data_field[$field_name . '_target_id']['filter']['handler'])) {
        if ($data_field[$field_name . '_target_id']['filter']['handler'] == 'views_handler_filter_in_operator') {

          // Name of custom handler class
          $custom = 'MY_MODULE_own_company_filter_handler';
          // Add custom handler
          $data[$data_key][$field_name . '_target_id']['filter']['handler'] = $custom;

        }
      }
    }
  }
}

```

# Answer
> -2 votes
What you might need is to create a "relationship" (http://gotdrupal.com/videos/drupal-views-relationships) with your user's profile and filter the user's "company" and have that match one of your company's taxonomy terms to get the same company results.

You might have to create a view's php field to get the result you want. (How to use Views PHP to rewrite results of a field?)

---
Tags: 7, views
---


# Question
Title: Backtracing an SQL error shown in drupal set message with no specifying information
I am using a feeds hook to email some information to workbench section users. I've been changing some of my code and suddently I'm getting a database error:

```
SQLSTATE[42000]: Syntax error or access violation:
1064 You have an error in your SQL syntax;
check the manual that corresponds to your MySQL
server version for the right syntax to use near '))' at line 2

```

This error doesn't show enough of the query to let me know which one it is, what line number or function it originates in, etc. I've tried putting a debug\_backtrace() in the core definition of the drupal\_set\_message() function but I did not find my functions in it, just batch functions. I also tried putting backtraces in the DatabaseStatementBase classes' execute() method, but that caused the site to output a bunch of junk information on the screen.

How can I backtrace this error or otherwise track it down? The only thing that occurs to me put error messages around each query I'm running to see where the actual error falls. Is this the best way?

# Answer
> 2 votes
turn on error reporting for php. turn on mysql query log and inspect new queries -- add a simple parameter you can lookup like `SELECT ..., 'IS-THIS-BROKEN-1' as debug_key` to easily find your quer(ies) in the mysql log file. ... Views offer such a debug parameter for views sql queries too ... my point is there are better ways to tackle this that strictly form your PHP code and drupal\_set\_message.

---
Tags: debugging
---


# Question
Title: how to set a webform field value in my custom module
drupal 7 webform 7-3.18

My webform has a hidden field used to store an unique id. This id is generate from custom logic.

my code is to set this field value. 'webform\_client\_form\_1' is my webform id

```
function webform_custom_form_webform_client_form_1_alter($form, $form_state, $form_id) {
  $form['submitted']['test_id']['#value'] = 'COURSE_ID-123456';
}

```

When the form is submitted and view the submission result and this hidden field value is empty

# Answer
Ok, try not to confuse Webform module stuff with core drupal FAPI stuff.

You cannot set `$form['submitted']['test_id']['#value'] = 'COURSE_ID-123456';` in the form\_alter because `$form` is not passed in by reference and the `submitted` key values is set after the form is `POST`ed to my knowledge.

So you're trying to put stuff into the form in the wrong time and place. If I was just using FAPI and not webform. I would not use a "hidden" form value (which isnt really *hidden* on the page), but use Form `build_args` or `$form_state['MYMODULE_temporary']` to hold my custom `course_id` in the FAPI form lifecycle so that the client never sees these values, but they are passed along through form validation and submission.

You can probably do the same technique I describe above and then implement hook\_webform\_submission\_insert(), or hook\_webform\_submission\_update() (if your form supports Drafts) to perform submission logic and look at your custom `course_id` stuff ...
> 2 votes

# Answer
For my webform alterations I use a rules module, Rules Forms Support. An example is that on form build I verify the user role and set a form element to hidden, so I have a field in the form only editable based on user role. I know there is also a webform rules module, but I have found the Rules Forms Support module to be more robust and have greater application than just modifying webforms. Rule actions can be used and even run or call the custom code to set the value at the proper step.
> 0 votes

---
Tags: webforms
---


title: How to alter node title link?

text:
# Question
Title: How to alter node title link?
I want alter `$node_url` in `node.tpl.php` inside a module not in `node.tpl.php`, which `hook` should I use?

# Answer
> 6 votes
This is done in `template_preprocess_node()` in node.module on line 1451 (http://api.drupal.org/api/drupal/modules%21node%21node.module/function/template\_preprocess\_node/7).

```
function template_preprocess_node(&$variables) {
  ...
  $variables['node_url']  = url($uri['path'], $uri['options']);
  ...

```

You could change it to anything else in your own module in `mymodule_preprocess_node()` function like so:

```
function mymodule_preprocess_node(&$variables) {
  $variables['node_url'] = 'some/other/path';
}

```

---
Tags: hooks
---


title: error while editing views

text:
# Question
Title: error while editing views
When I'm editing a view and I click on one of the fields to edit them I get a javascript error

Error: TypeError: c.curCSS is not a function Source File: http://drupal.mydomainname.ca/misc/ui/jquery.ui.position.min.js?v=1.8.7 Line: 13

When I click Apply or Cancel on the configuration dialog I get taken to a page with nothing but a JSON string on it at this url

http://drupal.mydomainname.ca/admin/structure/views/ajax/config-item/home\_page\_slider/block/field/field\_image

Anyone else have this error or know what might cause it?

# Answer
jQuery Update has some problems with v1.8.7 currently (related to the version of jQuery UI included); downgrading to v1.7 should fix the problem.

See these issues on D.o for more information:

The reason your View isn't working is simply that the Javascript error is preventing the relevant events from being attached to the elements. So when you click a link, instead of Views loading the JSON via AJAX and processing it, you're instead forwarded to the JSON page itself.
> 2 votes

---
Tags: views, entities, javascript, 8
---


title: WSoD on Combined Filter Search in Views

text:
# Question
Title: WSoD on Combined Filter Search in Views
I set up a view to search multiple fields of a user, and it works great when logged in as an admin, however when I am anonymous or any other user role I get this WSoD:

> Fatal error: Call to a member function ensure\_my\_table() on a non-object in /home/somerset/public\_html/sites/all/modules/views/handlers/views\_handler\_filter\_combine.inc on line 60

There are no access controls on the view, and any user can view a user just fine, so I'm not sure why this error is coming up.

EDIT: Here is the view

```
$view = new view();
$view->name = 'combined_search';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'users';
$view->human_name = 'Combined Search';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Search Businesses';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'better_exposed_filters';
$handler->display->display_options['exposed_form']['options']['submit_button'] = 'Search';
$handler->display->display_options['exposed_form']['options']['bef'] = array(
  'general' => array(
    'allow_secondary' => 0,
    'secondary_label' => 'Advanced options',
  ),
  'combine' => array(
    'more_options' => array(
      'is_secondary' => 0,
      'bef_filter_description' => '',
      'tokens' => array(
        'available' => array(
          0 => 'global_types',
        ),
      ),
    ),
  ),
);
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['style_options']['row_class'] = 'a-z-business-custom';
$handler->display->display_options['row_plugin'] = 'fields';
/* No results behavior: Global: Text area */
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['empty'] = TRUE;
$handler->display->display_options['empty']['area']['content'] = 'Sorry!  We couldn\'t find any businesses listed that matched your search criteria.  Alternatively, if you looking for a business category, you may use the business category search to the left of this page.  Once you find the business category you are looking for you can click through to see all businesses listed under said category.

If you believe that your business should show up in this search, please <a href="contact">contact</a> a site administrator.';
$handler->display->display_options['empty']['area']['format'] = 'filtered_html';
/* Field: User: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['label'] = '';
$handler->display->display_options['fields']['name']['alter']['max_length'] = '55';
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = FALSE;
$handler->display->display_options['fields']['name']['element_label_colon'] = FALSE;
/* Field: User: Business Address */
$handler->display->display_options['fields']['field_business_address']['id'] = 'field_business_address';
$handler->display->display_options['fields']['field_business_address']['table'] = 'field_data_field_business_address';
$handler->display->display_options['fields']['field_business_address']['field'] = 'field_business_address';
$handler->display->display_options['fields']['field_business_address']['label'] = '';
$handler->display->display_options['fields']['field_business_address']['exclude'] = TRUE;
$handler->display->display_options['fields']['field_business_address']['element_label_colon'] = FALSE;
/* Field: User: Business Tags */
$handler->display->display_options['fields']['field_business_tags']['id'] = 'field_business_tags';
$handler->display->display_options['fields']['field_business_tags']['table'] = 'field_data_field_business_tags';
$handler->display->display_options['fields']['field_business_tags']['field'] = 'field_business_tags';
$handler->display->display_options['fields']['field_business_tags']['label'] = '';
$handler->display->display_options['fields']['field_business_tags']['exclude'] = TRUE;
$handler->display->display_options['fields']['field_business_tags']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_business_tags']['delta_offset'] = '0';
/* Field: User: Business Type */
$handler->display->display_options['fields']['field_bus_type']['id'] = 'field_bus_type';
$handler->display->display_options['fields']['field_bus_type']['table'] = 'field_data_field_bus_type';
$handler->display->display_options['fields']['field_bus_type']['field'] = 'field_bus_type';
$handler->display->display_options['fields']['field_bus_type']['label'] = '';
$handler->display->display_options['fields']['field_bus_type']['alter']['make_link'] = TRUE;
$handler->display->display_options['fields']['field_bus_type']['alter']['path'] = 'business-types/[field_bus_type]';
$handler->display->display_options['fields']['field_bus_type']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_bus_type']['type'] = 'taxonomy_term_reference_plain';
/* Field: User: Description */
$handler->display->display_options['fields']['field_desc']['id'] = 'field_desc';
$handler->display->display_options['fields']['field_desc']['table'] = 'field_data_field_desc';
$handler->display->display_options['fields']['field_desc']['field'] = 'field_desc';
$handler->display->display_options['fields']['field_desc']['label'] = '';
$handler->display->display_options['fields']['field_desc']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_desc']['type'] = 'text_summary_or_trimmed';
$handler->display->display_options['fields']['field_desc']['settings'] = array(
  'trim_length' => '200',
);
/* Field: User: Municipality */
$handler->display->display_options['fields']['field_municipality']['id'] = 'field_municipality';
$handler->display->display_options['fields']['field_municipality']['table'] = 'field_data_field_municipality';
$handler->display->display_options['fields']['field_municipality']['field'] = 'field_municipality';
$handler->display->display_options['fields']['field_municipality']['label'] = '';
$handler->display->display_options['fields']['field_municipality']['exclude'] = TRUE;
$handler->display->display_options['fields']['field_municipality']['element_label_colon'] = FALSE;
/* Field: User: Business Name */
$handler->display->display_options['fields']['field_bus_name']['id'] = 'field_bus_name';
$handler->display->display_options['fields']['field_bus_name']['table'] = 'field_data_field_bus_name';
$handler->display->display_options['fields']['field_bus_name']['field'] = 'field_bus_name';
$handler->display->display_options['fields']['field_bus_name']['label'] = '';
$handler->display->display_options['fields']['field_bus_name']['exclude'] = TRUE;
$handler->display->display_options['fields']['field_bus_name']['element_label_colon'] = FALSE;
/* Sort criterion: User: Created date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'users';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: User: Active */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'users';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = '1';
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: User: Roles */
$handler->display->display_options['filters']['rid']['id'] = 'rid';
$handler->display->display_options['filters']['rid']['table'] = 'users_roles';
$handler->display->display_options['filters']['rid']['field'] = 'rid';
$handler->display->display_options['filters']['rid']['value'] = array(
  4 => '4',
  7 => '7',
);
/* Filter criterion: Global: Combine fields filter */
$handler->display->display_options['filters']['combine']['id'] = 'combine';
$handler->display->display_options['filters']['combine']['table'] = 'views';
$handler->display->display_options['filters']['combine']['field'] = 'combine';
$handler->display->display_options['filters']['combine']['operator'] = 'contains';
$handler->display->display_options['filters']['combine']['exposed'] = TRUE;
$handler->display->display_options['filters']['combine']['expose']['operator_id'] = 'combine_op';
$handler->display->display_options['filters']['combine']['expose']['label'] = 'Search Businesses';
$handler->display->display_options['filters']['combine']['expose']['operator'] = 'combine_op';
$handler->display->display_options['filters']['combine']['expose']['identifier'] = 'combine';
$handler->display->display_options['filters']['combine']['expose']['remember_roles'] = array(
  2 => '2',
  1 => '1',
  3 => '3',
  4 => '4',
  5 => '5',
  6 => '6',
  7 => '7',
);
$handler->display->display_options['filters']['combine']['group_info']['label'] = 'Combine fields filter';
$handler->display->display_options['filters']['combine']['group_info']['identifier'] = 'combine';
$handler->display->display_options['filters']['combine']['group_info']['default_group'] = '1';
$handler->display->display_options['filters']['combine']['group_info']['group_items'] = array(
  1 => array(
    'title' => 'Contains',
    'operator' => 'contains',
    'value' => 'value1',
  ),
  2 => array(
    'title' => 'Contains any word',
    'operator' => 'word',
    'value' => 'value2',
  ),
);
$handler->display->display_options['filters']['combine']['fields'] = array(
  'name' => 'name',
  'field_business_address' => 'field_business_address',
  'field_business_tags' => 'field_business_tags',
  'field_bus_type' => 'field_bus_type',
  'field_desc' => 'field_desc',
  'field_bus_email' => 'field_bus_email',
  'field_municipality' => 'field_municipality',
  'field_phonenum' => 'field_phonenum',
  'field_bus_name' => 'field_bus_name',
);

/* Display: Results Page */
$handler = $view->new_display('page', 'Results Page', 'page');
$handler->display->display_options['defaults']['use_ajax'] = FALSE;
$handler->display->display_options['use_ajax'] = TRUE;
$handler->display->display_options['exposed_block'] = TRUE;
$handler->display->display_options['path'] = 'combined-search';

/* Display: Search Form */
$handler = $view->new_display('block', 'Search Form', 'block');
$handler->display->display_options['defaults']['use_ajax'] = FALSE;
$handler->display->display_options['use_ajax'] = TRUE;
$handler->display->display_options['defaults']['pager'] = FALSE;
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';

```

# Answer
The issue was with a taxonomy I had attached to the combine filter. I'm not sure why this issue happened but I found a workaround.

I created relationships to all of the (4) taxonomy fields used for user accounts, then deleted the User: \[taxonomy term\] from fields and added the fields for Taxonomy term: Name for each of the relationships I created.

The search now works with fuzzy search as well.
> 2 votes

---
Tags: 7, views, wsod
---