# Question
Title: Add classes to quick tabs and nested tabs within quick tabs
How can I add custom css classes to quick tabs and nested tabs within quick tabs?

# Answer
> 4 votes
Have you read this issue. Try to apply the patch by using `git apply` command line :

```
$ git apply --directory=path/to/module-dir/ add-custom-class-656330-6.patch

```

If you don't use git, add this line in the `theme_qt_quicktabs_tabset` function near the **`line 589`** on the `quicktabs.module` file and the function will become :

```
<?php
function theme_qt_quicktabs_tabset($vars) {
   if ($key == $vars['tabset']['#options']['active']) {
     $item['class'] = array('active');
   }
   $item['class'][] = drupal_html_class($tab['#title']);# new line added by the patch
   $item['data'] = drupal_render($tab);
   $variables['items'][] = $item;
 }
?>

```

of course **WITHOUT** the `<?php ?>` tags

After that you have the title in class attributes :

**Example :**

* tab title =\> given tab title
* automatic tab class =\> given\_tab\_title

Wish helps :)

# Answer
> 0 votes
Another option is the Block Class module. After enabling, you can add a class when configuring the block for the quicktabs instance, as well as any blocks included in your quicktabs instance.

---
Tags: 7, blocks
---


title: Rules sending email to profile2 users

text:
# Question
Title: Rules sending email to profile2 users
I am new to drupal. I have installed profile2 module and created one profile named as "Travel Agency". Now I want to send different mail to this user when he/she registered with my site as "Travel Agency". so I have created a Rule for this and it is working it is sending a separate mail which has been setted for the Profile2 user or Travel Agency users.

**My rule information is as follows:**

Event: After saving a new profile

Condition: Data Comparison .. Selected data: profile2:type equals Travel Agency

Action: send e-mail

The problem is that along with this email it is also sending the email which has been sent to user when he/she registered as Normal user with my site.

Please guide me on this. Thanks for the answers in advanced.

# Answer
You could go to admin/config/people/accounts and uncheck "Require e-mail verification when a visitor creates an account." Then create a new email rule for users who are not "Travel Agency". If you still need to require e-mail verification before the user logs in then check out the Mail Control module.
> 1 votes

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


title: Wrapping embedded images with a div

text:
# Question
Title: Wrapping embedded images with a div
When embedding an image in CKEditor on Drupal 7 any styles or alignment are applied directly to the image itself e.g.

```
<img src="..." style="float: left; width: 90px; height: 150px" />

```

However this doesn't allow for a great deal of CSS control over the appearance for the image because the inline styles override CSS.

How can I do the following 2 things:

1. Automatically wrap the image in a div and apply classes to this instead of the img element
2. For alignment use classes (e.g. 'image-left', 'image-right' etc.) instead of inline styles

So the above example would instead be rendered as:

```
<div class="image-left">
    <img src="..." styles="width: 90px; height: 150px" />
</div>

```

# Answer
Instead of adding a wrapper div, you could use !important.

```
img {
    float: left !important;
    height: 150px !important;
    width: 90px !important;
}

```

This would override the style added in CKEDITOR. You could do the same for alignment using classes, adding them directly to the image through CKEDITOR.
> 2 votes

---
Tags: media, wysiwyg
---


# Question
Title: Dynamic Views Pages - How to add in meta tags to these generated pages?
I have 1000s of dynamically generated views pages using contentual filters. I want to be able to take certain keywords from these generated pages and add them to the on page meta tags. Currently I do not have any metatags on these pages. Is there a module that can add such a functionality that can inject it into a view?

If there is no such module, do you think the best way would be to create a custom tpl just for these dynamic pages and output these keywords on the html.tpl.php template?

# Answer
The metatag module comes with 'metatag views'. Enabling this module you with have a metatag settings on the metatag config page (admin/config/search/metatags).

I am not sure what meta tags you are referring to but I will give you an example.

I am using the view that overrides the default taxonomy term pages. To set the description meta tag for this view I put '\[view:description\]\[current-page:url:args:value:1\]' into the metatag setting for views.

If you are worried about the keyword metatag I would not bother as they ont seem to impact seo anymore, and I don't know of an easy way to set this dynamically for views.

You may also want to check out the metatag views overview module which has a confusing description but may help you.

Also, take a look in the file 'metatag.api.php' in the metatag module for something that you could use.
> 2 votes

---
Tags: theming, views, meta-tags
---


title: jcarousel not working on block?

text:
# Question
Title: jcarousel not working on block?
1) Place this module directory in your modules folder (this will usually be "sites/all/modules/").

2) Enable the module within your Drupal site at Administer -\> Site Building -\> Modules (admin/build/modules).

I have installed jcarousel module as shown in the above steps. After that I have create a new views (block) and then added format jcarousel On the settings I have added auto scroll after 2 seconds But it does not scroll at all Also previous and next button when clicked does work

What am I missing?

# Answer
> 0 votes
**Works by me but only with jQuery version 1.8 and lower.**

The above comment worked like charm!!! I had jquery 1.10 so i downgraded it to jquery 1.8

---
Tags: 7, blocks, javascript
---


# Question
Title: Can I use hook_uc_add_to_cart to ask for a yes/no confirmation before adding to cart?
For certain products in my ubercart catalog, I need to show a legal disclaimer before actually adding them to the cart. I was thinking to use hook\_uc\_add\_to\_cart for this, because it allows me to return a message in the result array :

http://api.ubercart.me/api/drupal/ubercart!uc\_cart!uc\_cart.api.php/function/hook\_uc\_add\_to\_cart/7

I could return a html enriched message holding the anchor to the final cart addition, in case the legal notice is read and confirmed.

For example : How do I translate this submit input form to a query string like alternative ?

```
<input class="node-add-to-cart form-submit" type="submit" id="edit-submit-144" name="op" value="Add to cart">

```

As an alternative I could ask the 'shopper' to hit this submit a second time as confirmation.

Then: To bypass the hook a second time, I could add a confirmed Boolean into the `$data` array which is returning into this hook as 3th parameter.

If I add this Boolean into the $data as a new key-\>value pair, will it be available again in the next submission ?

# Answer
> 0 votes
I was able to solve this issue using the first answer on this stackoverflow question : https://stackoverflow.com/questions/10490253/how-to-save-a-session-variable-in-drupal-7

In general: Drupal's static $\_SESSION array variable allows to store key=\>value pairs between different node pages, in my case the same page.

My code snippet inside uc\_product\_minmax\_uc\_add\_to\_cart hook :

```
    if (!empty($disclaimer)) {

        $confirmed = lists_session("s_key");

        if(! $confirmed) {

            $message[] = t($disclaimer, array('@qty' => $minmax->pmin_multiple, '!item' => $node->title));
            $result[] = array(
                'success' => FALSE,
                'message' => theme_item_list(array('items' => $message, 'title' => t('Read this note from medical department before confirming your reservation :'),
                'type' => 'ul', 'attributes' => array())),
                'silent'  => FALSE,
            );
            lists_session("s_key", TRUE);
        }
    }

```

---
Tags: forms, javascript, notifications
---


# Question
Title: Unknown top and bottom padding in panels
I'm using the panels module in drupal 7. I'm having some problem with the css in panels. I've removed the top and bottom padding in my custom css but there still appears to be some padding. How can I remove it? I have give the id "leftpane" and made the following CSS

```
#leftpane {
    margin: 0px;
    padding:0px 20px;
    background:#17532E;
    border-radius:17px;
    float: left;
    }

```

How do I remove the unknown top and bottom padding?

# Answer
# leftpane {

```
margin: 0px;
padding:0px 20px !important;
background:#17532E;
border-radius:17px;
float: left;
}

```

Add !important rule to override existing padding
> 0 votes

---
Tags: 7, panels, theming
---


# Question
Title: Duplicate Results in View with OG Relationship
I have a view that uses the OG Relationship "OG membership: Group Content (node) from OG membership", and this relationship is causing duplicates when a person has more than one group assigned to them.

If I use aggregation settings along with checking the distinct checkbox in the query settings, the duplicates disappear. (Oddly enough, I needed to use BOTH aggregation and "Distinct".)

However, I want the ALL Content Titles for the related Group (which is why I needed the relationship).

I even tried the Views Distinct module, but after fumbling around with it, it either shows one Content Title from the group or all Content Titles from all groups.

All of this behavior leads me to believe there's an issue with OG relationships because there's no way to aggregate the content titles that I can find.

Am I looking at a views hook to fix the issue?

# Answer
Okay, so I *believe* I traced the issue to a problem with Entity Reference Relationships in Views, and posted a bug.

However, I was able to solve the duplicate issue AND get the results I wanted (all titles from related groups) by taking a different approach in the View.

Instead of `hook_query_alter()` or `hook_views_pre_render()`, I just wound up adding the field that reference the groups, setting the Formatter to "Label", and checking the "Link label to referenced entity." This produced a comma-separated list of groups linked to the group page (exactly what I wanted).
> 0 votes

---
Tags: 7, organic-groups, views
---


# Question
Title: How to make a content type field unique per user
I want a date field to be unique per user so they can't add two nodes with the same date. I have **Unique Field** installed. Unfortunatly, they don't offer user scope.

Anyone know how to achieve this?

# Answer
I would like to thank Scorchio for pointing me in the right direction. I managed to achieve what I wanted putting this code in a custom module :

```
function node_calendar_form_alter(&$form, &$form_state, $form_id) //alter the form
{
  if($form_id == 'training_node_form') //specify form with form id
  {
    $form['#validate'][] = 'my_custom_validate_function'; //declare a custom validation function
  }

}

function my_custom_validate_function($form, &$form_state)
{
    global $user; //because I needed the uid
    $query = new EntityFieldQuery();
    $dates_array = array(); //this will contain the dates to check for

    $query
    ->entityCondition('entity_type', 'node', '=')
    ->propertyCondition('type', 'training')
    ->propertyCondition('uid', $user->uid); //my query, checks for content type and current uid

    $trainings_query = $query->execute();

    if ($trainings_query) { //if query is successful
       $session_nodes = node_load_multiple(array_keys($trainings_query['node'])); //load the nodes
       foreach ($session_nodes as $training) {
           array_push($dates_array, substr($training->field_training_date['und'][0]['value'], 0, -9)); //push the dates in $dates_array after trimming the 00:00:00
       }
    }
    if (in_array(substr($form_state['values']['field_training_date']['und']['0']['value'], 0, -9), $dates_array)) { //if the date is already used
       form_set_error('field_training_date', t("Vous avez déjà un entrainement pour cette date. Veuillez modifier l'entrainement ou pour éviter de la duplication de contenu.")); //throw in error
    }
}

```

I commented my code for anyone who would like to do something like this in the future.
> 0 votes

# Answer
I don't know the Unique Field module, but I have a suggestion instead.

Create a little utility module which alters the node form of that node type and adds a *custom validation*. That validation could check for anything on the form, date inclusive.

In the Drupal 6 days it worked like this. I hope this is enough for a starting point. \[Also, reading the book Pro Drupal 7 Development can help you a lot if you haven't written a module yet.\]
> 1 votes

# Answer
The Drupal module https://drupal.org/project/field\_validation does this. Just add a "Unique values" validator to the field and set the scope to "entity" or "bundle". There is then an option for "Per user" uniqueness across the field.
> 0 votes

# Answer
The user scope functionality you are asking for is available in Unique Field Module by default. There is an option called **"Choose whether values must be unique individually or in combination"**. Select **"The combination of values from the specified fields must be unique"** option. And for the fields select your required field (date field in your case) along with the **author field**.
> 0 votes

---
Tags: 7, entities, users, datetime
---


# Question
Title: "Promote to front page" to other than front page
Is it possible to push node summaries (teaser text) onto pages other than the "Front Page"? I see the option "Promoted to front page" but is there a workaround for promoting them to sub-pages as well?

# Answer
> 9 votes
"Promoted to front page" can be used as a views filter. So you could create views based on that (so it displays node teasers that have a certain taxonomy and are "Promoted to front page").

Another simple way to mimic "Promoted to front page" is to add a taxonomy select field to your content types, and then the taxonomy pages would display the specified content.

Does this answer your question?

# Answer
> 6 votes
Alternative to mtro's answer (which is correct), I find it also useful to use the "flags" module. http://drupal.org/project/flag

Create a flag like "promote to sub-page" then create a "sub-page" view which selects nodes with that flag.

# Answer
> 2 votes
Besides, you can also use Rules module.

With Rules, you can specify the condition and action on a node is prompted to front.

# Answer
> 1 votes
you could also use a Boolean field as a simple checkbox and then filter Views on that.

---
Tags: nodes, 7
---


# Question
Title: Trying to replicate a view with no success
I'm currently working on my drupal site and I have trouble replicating one view. This is the view I'm talking about.

I have replicated the drop down menu, the search bar "with the exception of a placeholder" and the list of episodes as well, but I'm having trouble replicating something where it autoselects/autodefaults the dropdown menu item based on the show name. (represented by the red arrow) I have tried everything, contextual filters, remember options, but nothing works.

Can you help me, I'm at loss of words here as to how to replicate it? Your help would be gratefully appreciated.

# Answer
> 0 votes
When you say, "autoselects/autodefaults the dropdown menu item based on the show name," what are you trying to do, exactly? What show name you are trying to auto-select? Is this view capable of showing shows with other show names? If so, and say you have ten shows in that list, which one do you want to be the default?

Are you trying to have links to that same view from different places in the site and you want a link on the Tech Guy page to automatically filter the Tech Guy shows, and a link on the Fictional Mister Podcast page to automatically filter to the Fictional Mister Podcast shows?

---
Tags: views, navigation
---


# Question
Title: Create a drupal 6 views slideshow from a single content type that has both, image and video fields
I need a little direction. I've created a content type that has both, images and videos attached to a node. I need to create a single frame slideshow that riffles through the mixed media. Currently, I'm using the Embedded Media Field as well as the ImageField to upload the content. I'd like to keep that within the same content type if possible. For the most part, the slideshow is working, yet it displays both fields together. I want a single slide per media type. I've excluded one type, but adding the field programmatically has been a little challenging.

# Answer
The only way I've been able to somewhat achieve this is by creating individual nodes for the video and image content. I then use views to filter for both types. Clumsy for the content editor, but I guess it works.
> 0 votes

---
Tags: 6, media, views
---


title: Drupal database: how to join 2 tables?

text:
# Question
Title: Drupal database: how to join 2 tables?
Currently I'm learning drupal database command as I'm pretty new to Drupal, I'm more familiar with mysqli api. I want to check the role of user before they are logged in to the system, the role table maps `rid` with a role (for example 1 - admin, 2 - author, etc.), the `users` table and `users_roles` table are linked by `uid`, which is unique. The role i want to verify before user login to the system has rid (role id) = 2. This is what I have so far, but it doesn't really work:

```
function is_author($name) {
$query = db_select('users_roles');
$query->join('users', 'users_roles.uid = users.uid'); // JOIN users_roles with users
$query->fields('users_roles', array('rid')) // SELLECT the field rid from users_roles
    ->fields('users', array('name')) // SELLECT the field name from users
    ->condition('users.name', ':name');

$result = $query->execute();

while ($record = $result->fetchAssoc()) {
    if ($record == 2) {
        break;
    }else{
        return false;
    }
}
return true;

```

}

This is the users and users\_roles table:

table `users`:

```
uid | name | pass | .....

1 | Michael | (encrypted password)

2 | Ted | (encrypted password)

3 | Mark | (encrypted password)

```

Table `users_roles`:

```
uid | rid

1 | 2

2 | 3

```

Please help!! Thanks in advanced!

# Answer
> 1 votes
To check user role before login you need to create a validate function for login. You can put this code in template.php of your theme or in custom module file. e.g my custom module name is **MYMODULE**.

```
<?php

/**
* Implements hook_form_alter().
*/
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'user_login') {
$form['#validate'][] = 'MYMODULE_user_login_validate';
}
}

/**
* Additional handler for user_login form validate.
*/
function MYMODULE_user_login_validate($form, &$form_state) {
  // check user role here by the function mentioned abve
   $name = $form_state['values']['name'];
   $user = user_load_by_name($name);
   $role = array_key_exists(2, $user->roles);
   // do something
}

```

Hope it will help you.

# Answer
> 0 votes
If you are trying to filter based on a rid, you should make it a condition.

```
$query = db_select('users_roles');
$query->join('users', 'users_roles.uid = users.uid'); // JOIN users_roles with users
$query->fields('users_roles', array('rid')) // SELLECT the field rid from users_roles
    ->fields('users', array('name')) // SELLECT the field name from users
    ->condition('rid', 2)
    ->condition('users.name', ':name');

```

That would only return you the users who have role 2 and have the name of $name.

However, you have the user's name already. If you are trying to determine whether or not the specified user has the specified role, use Drupal to help you with that. I understand you want to learn better how to do queries, but it looks like what you really want is:

```
function is_author($name) {
  $user = user_load_by_name($name);
  return array_key_exists(2, $user->roles);
}

```

---
Tags: database
---


# Question
Title: Form generated from form cache displays, but missing name and value attributes
I'm having a problem displaying a cached multi-step form in a custom module which generates custom entities.

1. After two steps, the form posts to an external URL (action changed with hook\_form\_form\_id\_alter).
2. If the external URL returns errors, the form is pulled from cache with form\_get\_cache() and displayed using drupal\_render().
3. Form displays okay, but field elements are missing name and value attributes.
4. Printing the form object retrieved from cache shows expected values (#entity, fields, and user input associated with fields).

```
  $form_state = array(
    'submitted' => FALSE,
    'rebuild' => FALSE,
    'cache' => TRUE,
  );

  $form = form_get_cache($form_build_id, $form_state);

  $output = drupal_render($form);

```

I suspect that I need to rebuild $form\_state input/values or am missing a form rebuild step.

# Answer
Figured it out. Use form\_get\_cache() to get the cached entity, throw that into $form\_state, and then use drupal\_build\_form() to put it together again.

```
    $form_state = array(
        'submitted' => FALSE,
        'rebuild' => FALSE,
        'cache' => TRUE,
    );

    // Pull the entity object from cache.
    $cached_form = form_get_cache($form_build_id, $form_state);
    $myentity = $cached_form['#entity'];

    $form_state['myentity'] = $myentity;
    $output = drupal_build_form('myentity_form', $form_state);

```
> 0 votes

---
Tags: forms, caching, theming
---


# Question
Title: Different user form for registration and edit
I'm trying to make different forms layout for user registration and user edit account: \- User Registration: Display it paginated, like a wizard. \- User edit: Display it in only one page.

I can use FieldGroup Multipage field to make a paginated user registration form. But it affects the edit page too.

There's some module that can accomplish this?

Any help would be appreciated!

# Answer
the multistep registration module will help you with this I think. Together with the profile2 module. Those 2 modules will help you with the multi step registration part. For the user edit page you should check the checkbox in the profile2 preferences where it says use a seperate page for editting user profiles
> 1 votes

---
Tags: users, forms
---


title: Check if path exist

text:
# Question
Title: Check if path exist
I want add export link in some place if current path plus '/export' exists. But can't understand how check such urls. The problem is when path exists with less number of arguments `drupal_valid_path()` returns TRUE. For example I have path 'reports' but don't have path 'reports/export'. I check paths like this:

```
$export_path = current_path() . '/export';
if (drupal_valid_path($export_path)) {
    $export_options = drupal_get_query_parameters();
    $link_options = array(
       'attributes' => array(
            'class' => array('open'),
            'target' => '_blank',
        ),
        'query' => $export_options,
    );
    $vars['print_links'] = l('', $export_path, $link_options);
}

```

How do I need check paths?

# Answer
Solve this problem by addng code above.

```
$exposed_args_count = count(explode('/', $export_path));
$menu_item = menu_get_item($export_path);
if (($menu_item['number_parts'] == $exposed_args_count) && drupal_valid_path($export_path)) {

```
> 2 votes

# Answer
You can check it simply using **arg()** function. e.g you have path as `www.example.com/testpage/export`

```
$export_path = arg(0)."/".arg(1);
//$export_path will print its as 'testpage/export'

```

So you can use the `if` condition as

```
if ($export_path=='testpage/export')) {

//Your data export code

}

```
> 0 votes

---
Tags: uri
---


title: Undefined variable "hide_site_name"

text:
# Question
Title: Undefined variable "hide_site_name"
I am having great difficulty in trying to create my own theme. The errors that persist are:

> Notice: Undefined variable: hide\_site\_name in include() (line 98 of C:\wamp\www\drupal7\sites\all\themes\ppro8\templates\page.tpl.php).
> Notice: Undefined variable: hide\_site\_name in include() (line 108 of C:\wamp\www\drupal7\sites\all\themes\ppro8\templates\page.tpl.php).

I copied all files from the bartik theme into /sites/all/themes/myTheme/, and did the following:

1. I changed bartik.info into myTheme.info, and 'name = bartik' to 'name = myTheme'.
2. I replaced all occurrences of 'bartik' in templates.php to 'myTheme' (search and replace with notepad++). Up to this stage, the error still shows, so I tried the following as well:
    * I replaced all occurrences of 'bartik' in all files in the folder 'myTheme'

However, none of the above steps could remove the errors.

Could anyone please shed some light on this issue?

# Answer
> 0 votes
I had exactly the same problem here and complete system cache clearing helped me out.

> Configuration -\> Development -\> Performance -\> Clear all caches.

That solved the problem for me.

See: Undefined variable: hide\_site\_name in include() while change theme

# Answer
> 0 votes
I know that this question asked before 2 years ago. today only I came up with this problem.

I've pasted:

```
$hide_site_name = theme_get_setting('toggle_name') ? FALSE : TRUE;

```

at the second line of `page.tpl.php` and that solved my problem.

---
Tags: theming
---


# Question
Title: entityFieldQuery not returning term references - not in field_data but are in field_revision
So, I'm pretty new to drupal(7) - any help here greatly appreciated.

What I'm trying to do is use entityFieldQuery to return a list of nodes that have a given term in them.

I have a field, "field\_crafts", where crafts is a term reference, and points to a specific vocabulary. I also have a 'tags' field.

If I use fieldCondition('field\_tags', 'tid', $n), the entityFieldQuery works fine, and returns all nodes with the given tag.

But if I do the very same thing on field\_crafts instead, it returns no results.

I've poked around in my database, and it appears that field\_data\_field\_tags table has data in it, but the field\_data\_field\_crafts does not. However, the field\_revision\_field\_crafts table does. And when I load up the node in the UI, it does indeed remember which terms I have ticked in the list of checkboxes.

So, what's going on here? I imagine that if the crafts data were just to appear in the data table, the query would work fine. Why isn't it, and is there anything I can do?

Thanks!

# Answer
So, I figured out what was going on -- I was using the 'moderation' plugin and so all the changes I was making were secretly getting marked as 'draft' despite me making the changes as an admin. Doh.
> 0 votes

---
Tags: 7, taxonomy-terms, database
---


# Question
Title: How to display flags to anonymous users and redirect to login after clicking a flag?
I want to display flag to anonymous user and upon clicking the user should be redirected to register/login page.

I found one answer to this problem in the question about "How to display a flag to anonymous users?".

I tried this solution but did not work, may be I did not put the code in correct place?

I am using Bartik as my template and I put the code in `node.tpl.php`.

Any suggestions?

# Answer
> 2 votes
Maybe the Flag anonymous module is what are you looking for.

# Answer
> -1 votes
Why not just use the Session API module.

> The Session API is a very simple set of functions that extend the core sessions workings, allowing data to be stored and associated with a user's session.
>
> There is no need to install this module unless you are instructed to do so by another module.
>
> Currently this module is used by
>
> Flag DrupalChat Mozilla Persona Session Favorites Domain User Default The Sign-Up Problem

---
Tags: flags
---


# Question
Title: Path (alias) does not work after migration, nor Content view
I'm using the migrate (7.x-2.x-dev) module to import a node(s) from static HTMLs to Drupal 7, and I want to set the path the same as the original directory/filename. I have defined in my migration class as follows,

```
$this->addFieldMapping('path', 'filename');
$this->addFieldMapping('pathauto')->defaultValue(0);

```

and it seems to be working - when I open the imported node in the **edit** mode, I see the correct path in the **path** field, and the **Generate automatic URL alias** checkbox is unchecked.

However, the path is not working. Say, when the path is set to be `info/legacy.html`, and the node is 21,

```
http://localhost/node/21

```

is fine, whereas

```
http://localhost/info/legacy.html

```

returns *404 (Page not found)*.

In fact, the node is not listed in the Content page `/admin/content` either. I found the node number (21 in this case) by browsing directly the SQL database (the entry of the node in the database looks no different from other nodes).

Everything else looks fine, I mean, all the fields related to the node are imported as I intend. But the above-mentioned 2 points are weird...

Why is it so, and how can I achieve the above? Any idea?

# Answer
> 0 votes
Actually, I have just found out it was due to the i18n setting of the node and site. The language of the node was set to be ja (Japanese), correctly. Probably because of that,

```
http://localhost/info/legacy.html

```

does not work (HTTP 404), but

```
http://localhost/ja/info/legacy.html

```

does display the node imported.

Similarly, the Content manager does not display the node in the default-language mode (English) `/admin/content`, however it does display the newly imported node in Japanese `/ja/admin/content`. I should note I allow all the *URL* (Path prefix), *Session*, *User*, *Browser* in the language configuration (`/admin/config/regional/language/configure`) in my environment.

My browser's HTTP request, when I test, is

```
"Accept-language": ja

```

So, I expected when I opened

```
http://localhost/info/legacy.html

```

it would open the node in Japanese, following the browser's request, as opposed to 404, but it does not, apparently.

Hmm, I guess it is likely my understanding of the i18n handling in Drupal is not sufficient. Anyway, I think this can be solved with the redirection module in Drupal, after investigating and finding out how to set it up during migration. I didn't want the default URI to be something like `node/21`, but if it is `ja/info/legacy.html`, I am fine with it, as long as the redirection works.

**\[Edit: 2014-10-06\]**
I have figured out why. In my i18n setting of Drupal, URI-path-prefix is checked and is given the highest priority, where English is default with its language-code for path-prefix being undefined. Hence,

```
http://localhost/info/legacy.html

```

is the English version of the content, which does not exist. When I define the language-code of English (en) for path-prefix, then the access to the URI brings up the Japanese version, if my browser's preferred language is Japanese (and the i18n of the site is configured to accept the browser's preferred language at the lowest priority), because the URI is not any more specific for the English version.

Another note is the redirection module works only when redirecting to a node URI \[or path without the language-code prefix (added on 2014-10-11)\]. The redirection to, for example,
`/ja/info/legacy.html`
does not work well, as it can bring up the path of

```
http://localhost/ja/ja/info/legacy.html

```

in some cases.

**\[Edit: 2014-10-11\]**
The whole point (and much more) is covered and summarised in the document published at drupal.org: https://www.drupal.org/node/2354755

---
Tags: nodes, migrations, path-aliases
---


# Question
Title: How to set defined image weight in Drupal
I just now noticed this:

My uploaded image for article has more weight in kb as my uploaded original image;

I have set my GD toolkit image quality to 100% because I am compressing images myself as I wish (in IrfanView) ...

So, my original image is of dimensions: 549 X 803 **58.1 kb**

In webpage I see image of dimensions: 328 X 480 and **113.73 kb !!!**

* I expect the image to be of my defined weight ; or even smaller , if the size is smaller; but not larger....

# Answer
> 0 votes
If you've set the quality to 100% it's likely that that is why it's resulting in a larger file size. You may be setting it to a higher quality compression than the original photo had. You should try to find a balance between compression quality and image size that results in page load speeds you find preferable. However, if there aren't multiple images on this page, that might be an okay file size.

# Answer
> 0 votes
It is because the GD library is basically creating a new image from the pixels it is given from your uploaded image. It does not care about the compression that you used.

If the original image is never actually viewed on your site, you should upload the image at the best quality you can which will give the image library a better image to recreate.

Then , as pizzasynthesis says, choose the quality setting that you want.

---
Tags: media
---


# Question
Title: Reset button is not working after previewing the webform
Reset button is not working after previewing the webform. Means when we click on preview button on webform, then on edit button of webform and then if we click on reset button. it does not work at all. What could be the reason, kindly suggest any solution? My code is as follows :

```
 function mymodule_form_alter(&$form, &$form_state, $form_id) {

  switch ($form_id) {

    case 'webform_client_form_XYZ':
        $form['submitted']['reset'] = array(
            '#type' => 'button',
            '#value' => t('Reset'),
            '#weight' => 100,
            '#validate' => array(),
            '#attributes' => array('onclick' => 'this.form.reset(); return false;'),
        );
   }

```

# Answer
> 1 votes
Your code works as designed - resets form to a state it was at page load. After preview state JavaScript resets to is set to what user entered. That's not a Drupal issue, that's just how JavaScript and browsers works. **Browser simply does not have that data any more** \- HTTP is a stateless protocol even if we work around it every day and don't even consciously notice that we do.

If you want that button to do something else, you need to use Drupal's AJAX and obtain values you want to reset to from the server directly. Alternatively, you can attach custom submit handler to that button, one that would not really submit anything, but clear data from `$form_state['input']` and trigger form reappearing.

# Answer
> 0 votes
This code work for all webforms in drupal 7:

```
<?php

function form_reset_form_alter(&$form, $form_state, $form_id)
{

if (strpos($form_id, 'webform_client_form_') === 0) {
 $form['actions']['reset'] = array(
  '#type' => 'button',
  '#value' => t('Reset'),
  '#weight' => 100,
  '#validate' => array(),
  '#attributes' => array('onclick' => 'this.form.reset(); return false;'),
  );
 }
}

```

---
Tags: webforms, entities
---


# Question
Title: How do I keep the trail for the breadcrumbs till the specific nodes?
When I create a new node and I assign a tag to it, I can view it from the corresponding taxonomy page. The breadcrumbs seem to follow the trail normally

```
Home>>category>>subcategory

```

until the very leaf node, at which point it indicates only

```
Home>>node

```

Why so? How do I keep the breadcrumb trail from collapsing?

# Answer
Breadcrumbs can sometimes be a bit confusing. In my experience the breadcrumb never behaves 100% as you would want it to behave, if you use it as it comes 'out of the box'.

Luckily also other people got annoyed be the standard breadcrumb (mis-)behaviour so over the years a sea of breadcrumb related modules found its way to drupals module collection. Here is an overview / comparison with some 10-15 modules listed. Maybe *Breadcrumbs by Path* could suit your needs…
> 1 votes

---
Tags: taxonomy-terms
---


# Question
Title: theming user profile with "User Field Privacy" - but no "Privacy" available
My setup is like this: multiple additional user fields (not using profile2) and the module "User Field Privacy" is enabled.

I am currently theming user profile pages through a preprocess function and the corresponding user-profile.tpl.php… Now I have some fields that should be visible to some roles, but hidden to others. I trigger this through the module "User Field Privacy". Looking for variables in the devel dump does not bring anything for "User Field Privacy" .

```
 [field_telefon] => Array
         (
           [und] => Array
              (
                [0] => Array
                   (
                     [value] => +01 234 567 890
                     [format] =>
                     [safe_value] => +01 234 567 890
                    )

               )

          )

```

When not theming through preprocess and .tpl, everything is fine – the fields marked *hidden* are actually hidden from regular and anonymous users, but shown to users with the appropriate permission.

How/where can I find the "marker" or "flag" for the User Field Privacy setting ?

Any pointers, hints and tips welcome!

# Answer
update/solved: I did solve my problem now with very basic measurements: for each field I wanted to have a 'privat option' for, I added an extra checkbox field ("public/private"). This setup just works fine no need to have "User Field Privacy" installed – at least for me. Hope this might help somebody some day.
> 0 votes

---
Tags: entities, users
---


# Question
Title: using hook_form_alter on a same form from 2 different modules
How will a predefined form behave if we have two different forms that implement hook\_form\_alter?

I would explain my question by an example, because currently I got a crash on it:

I have a predefined user\_login form in user.module

I created two new blocks called author\_login and creator\_login. Each of these module using the form user\_login and adding new validating properties for each form by using function hook\_form\_alter().

The new validating properties are:

* For author\_login block: if user doesn't have author role, user will not be logged into system, error: "you don't have author role"
* For creator\_login block: if user doesn't have creator role, user will not be logged into system, error: "you don't have creator role"

But the problem is: the new login block I created works fine if only one of two modules is enable. If I enable both modules, no user cannot log in to the system through these module.

For example, I have both modules enabled, I go to author\_login block and log an user named Mark, who has role Author, to the system, an error message displayed: "the user Mark doesn't have creator role". And similar to creator\_login block.

Why does this happen? I thought that the hook\_form\_alter will alter different properties to each new module we created, make each new form works **separately**. But from this case I encountered, it seem like the user\_login form validate all new properties that I added by using hook\_form\_alter. And how can I avoid this as I want these two form to work separately?

# Answer
> 0 votes
It sounds like you're altering the same form to provide the additional validation so it is expected that both the author and creator validation checks will be carried out when both modules are enabled.

If you want to continue using the same form for both blocks then I would suggest wrapping the code within your validation callbacks to check which form you are currently validating.

---
Tags: blocks, users, forms
---


# Question
Title: Stop send email attempt when cron is run
I just took over a drupal 7 site and when cron is run I get the follow error SMTP Error: Could not connect to SMTP host WD mail: Error sending e-mail (from ???????? to ???????)

I know the previous developer turned some feature/function on that will send an email each time a cron job is run. Does anyone know how or where to turn this off?

I have checked in the admin-\> cron, but there are no settings there to adjust.

Thank you in advance.

# Answer
It's likely defined as a hook\_cron implementation in a custom module. Trying searching through your codebase for "\_cron" to see what you can find. If you install Elysia Cron you should be able to get a full list of all cron jobs and could disable any jobs you don't way run.
> 0 votes

---
Tags: cron
---


# Question
Title: How do I put registration form in panel in Drupal 7
I would like to know how to put a registration form or any other form to make a new content type in panels. I know the first thing to do is to put the registration form in a block. How can I do that?

# Answer
```
fucntion YOURMODULE_block_view($delta = ''){
  switch($delta){
    case 'YOURBLOCKNAME':
    $block['content'] = drupal_get_form('user_registration_form');
    break;
  }
}

```

Or if you want to theme the block first, then register a theme hook in YOURMODULE\_theme().

```
function YOURMODULE_theme(){
  $return['custom_user_reg']= array(
    'render element' => 'form',
    'arguments'=> array('form'=> null),
    'template' => 'templates/form--user-registration',
  );
  return $return;
}

function YOURMODULE_block_view($delta = ''){
  switch($delta){
    case 'YOURBLOCKNAME':
    $form = drupal_get_form('user_registration_form');
    $block['content'] = theme('custom_user_reg', array('form'=>$form));
 }

```

Then in form--user-registration.tpl.php:

```
print render($form['email']);
print render($form['name']);
print drupal_render_children($form);

```

Of course you can add as much html in your tpl file as you want/need.
> 1 votes

# Answer
Form generic answer: There is no completely generic way to do this for "any form", because there is no way, for example, to query a form about the arguments it requires. So for "any form", you need custom code.

While you're on the right path, putting the form into a block and then block into a page, really serves no purpose. What you want is a content type, and there's a fairly complete example in What are Ctools plugin (content type, access, etc), and how does one create them?.

Form specific answer: Contextual administration actually happens to provide the user registration form as a content type, so you need no custom code at all.
> 0 votes

---
Tags: forms, blocks, panels, users
---


title: validation of text box and checkbox

text:
# Question
Title: validation of text box and checkbox
I am trying to validate the form. I have one hidden textbox and one check box group.

* field\_institute\_event - represents checkbox group.
* posted\_student\_list - represents hidden text box.

If both are empty then I want to display error message. How to do that??

I am trying following code:

```
if((empty($form_state['values']['field_institute_event']['und'][0]['entity']->field_institute_event_group[LANGUAGE_NONE]))
        &&
        (empty($form_state['values']['posted_student_list']['und'][0]['entity']->field_institute_event_group[LANGUAGE_NONE])) ) {
  form_set_error('field_institute_event_group',t('Please Post to atleast one group'));
}

```

# Answer
> 1 votes
```
if((empty($form_state['values']['field_institute_event']){
form_set_error('field_institute_event', t('YOURMESSAGE'));
}

```

That should do it. If you want to validate on empty value on a required element. You could also add the '#required' =\> true on your form element.

---
Tags: 7, forms
---


# Question
Title: admin theme changes to default at editing page, Themekey module
Using the ThemeKey module, I have changed the theme of user role (EDITOR) to Administration theme. So, when the user of this role logs in, he gets admin theme.

It works find but when he edit something the theme changes back to default. I want to have admin theme, even at editing pages for this user role. Please suggest.

# Answer
> 0 votes
I found the solution for this. I had to deselect the administration theme when editing or creating content, in admin/appearance.

---
Tags: theme-negotiation
---


# Question
Title: ubercart 2 with smtp - sending unformatted emails
Recently I had to switch sending emails to be sent using smtp. https://www.drupal.org/project/smtp The problem is that all system emails are sent ok regarding formatting. All emails sent by ubercart are unforatted and basically unreadable.
Any idea how is it possible to fix that? Thank you

# Answer
> 0 votes
I tried phpmailer module https://www.drupal.org/project/phpmailer and all messages (even created by ubercart) are displayed as formatted to end users.

---
Tags: 6, ubercart, emails
---


# Question
Title: Cannot change Drush version from 6.1.0 to 7.0
I am trying to update my version of Drush to include the Omega commands. For this I think I need 7.0. I have run `composer global require drush/drush:7.0.0-alpha5` and this installs the package but when I check `drush version` it still says `Drush Version : 6.1.0` How do I change my version of Drush to 7.0?

# Answer
I found a way to do this using `brew install --HEAD drush` followed by `brew switch drush HEAD` The full article where I found this is here, under **Installing Drush 7.x dev**
> 0 votes

---
Tags: drush
---


# Question
Title: Drupal installation not working/ what is .htaccess
I have a lamp server and using drupal. The is on Ubuntu server 14.04. My drupal version is drupal 8.0.0 alpha 15. I followed this guide to install both: http://youtube.com/watch?v=zsPc\_Tb8bI8

The problem is that I am running it on a server version, so there is no ui. No browser access in Ubuntu server. I can access my webserver via my host machine of the VM, by typing: 192.168.1.5 This bring up the default apache page of Ubuntu. When I do 192.168.1.5/drupal, I gives me an error (404 error). I already tried to set the www-data:www-data permission via chown, but this didn't work. Also, while browsing for answers I came across .htaccess file. I remember copying it somewhere, shown in the video. Where should I have copied it and what does it do?

My final(real) question: how do I access the drupal installation from another computer(not localhost). Do I need to set somethi ng in the apche conf? Also, what is .htaccess

# Answer
> 0 votes
in response to your "real" question, a quick search can broadly answer that, but basically it is configuration file to control access of locations on an Apache Web Server.

---
Tags: installation, .htaccess, files
---


# Question
Title: Send email from non system email address using Drupal API
From what should be a non-trivial task, I find this very confusing. My requirement is to send HTML email upon webform submission. Here is what I have now.

If `from` address is set as domain email address (info@domain.com) that is set as system's email address, set via Admin \>\> Configuration \>\> System, the email was sent as non HTML email. This is strange, because I dpm the email content before executing drupal\_mail, and it shows up as properly formatted HTML. I could tolerate this for now. Here comes the trivial part.

If `from` address is set as non-domain email address, such as info.domain@gmail.com, the email sent, never reached the recipients, but is logged as sent (I use mail\_logger module) under appropriate email key. I have checked spam folder but it is not there either.

My question is, does drupal 7 require the `from` email address to be that of the same domain or set as system email? (I would have expect a failed message and is logged into mail\_logger)

Any suggestions would help.

# Answer
This happens becouse Gmail seems to block these messages as they are often used for spoofing. Using the SMTP mailer plugin https://www.drupal.org/project/smtp and authenticating using your info.domain@gmail.com should solve the problem.
> 2 votes

# Answer
Its not necessary to have `from` address of the same domain but its recommended to have so. If you are using some other domain email address and if the mail server is properly configured than also it should send an email, although it may go in the spam folder. If the mails are not getting sent at all than check the error logs of mail on server, from there you can get the exact issue.

By default, Webform sends email in plain text. To send email in HTML format in an easy way you may use the Mime Mail module:

* It permits users to receive HTML email and can be used by other modules. The mail functionality accepts an HTML message body, mime-endcodes it and sends it.
* If the HTML has embedded graphics, these graphics are MIME-encoded and included as a message attachment.
* Adopts your site's style by automatically including your theme's stylesheet files in a themeable HTML message format
* If the recipient's preference is available and they prefer plaintext, the HTML will be converted to plain text and sent as-is. Otherwise, the email will be sent in themeable HTML with a plaintext alternative.
* Allows you to theme messages with a specific mailkey.
* Converts CSS styles into inline style attributes.
* Provides simple system actions and Rules actions to send HTML email with embedded images and attachments.

Though its not necessary to use the `Mime mail` module for sending the mails in HTML format, but it provides the easy way to do so. However if you want to do it through custom module than check this: How to send HTML email
> 1 votes

# Answer
try this function drupal\_mail() Example code:

```
drupal_mail('system', 'mail', 'to@example.com', language_default(), array(
  'context' => array(
    'subject' => 'Test e-mail',
    'message' => '
      <p>Lorem <a href="http://google.com">ipsum dolor sit amet</a>, consectetuer <b>adipiscing</b> elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
      <p>Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
      <p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
    ',
  ),
  'from@example.com',
));

```
> 1 votes

---
Tags: 7, emails
---


title: Views Results - Display specific user

text:
# Question
Title: Views Results - Display specific user
I have created a view based off the webform submission data. So if \[Mary\] has submitted five forms, and \[Julie\] has submitted three and \[Steve\] has submitted 8-- When they look at my results page, I only want julie to see her rows/submission info, Mary should only see her five rows and steve his 8.

The users are authenticated users so they have to login to complete the form and I capture their user and other personal info and of course to access the results page they must me authenticated as well.

I thought getting the submission data layed out in the view was going to be the hard part. I want the user to click on a link to "previous submissions" and when the results page opens, only their rows appear. I know the query will be return all the rows where the userID matches the userID of the currently logged in user.

I'm thinking this is hard because I am using webform submission data versus typical views of regular content.

Any help ?

# Answer
> 2 votes
On your view:

* Create the relationship "Webform Submissions: User" and require it
* Create the contextual filter "User: uid" and select the relationship you created at the top and select "provide Default Value" under "When the value is NOT in the URL"
* Save

And you're done!

If you have the the contextual filter already you must delete it and create it again.

# Answer
> 1 votes
Doesn't sound any different to displaying content as long as you can access the uid you have stored in 'filters'.

Set up a *relationship* from the data you wish to display to the person who created the data and then make a filter for 'author uid' (or similar) = 'current user uid'. You will probably need to use tokens for the right side of that equation.

---
Tags: views, webforms
---


title: Get thumbnail image URL for Video

text:
# Question
Title: Get thumbnail image URL for Video
I've got a Video field and the Video Thumbnail is uploaded by the user.

I've got a View which is generating JSON (with the views\_datasource extension). I want to include the image url to the Video Thumbnail has one of the fields in my JSON. I've set the formatter on this field to be "Video Thumbnail":

However, the value shown in my JSON output is the url to the original video and not to the Thumbnail image.

So, I tried enabling Rewriting on that field in the Views configuration. I used the `[field_video-thumbnail]` token to try to get the URL of the Thumbnail image...

but what I get in my JSON is the fid of the Image and not the URL of the image.

```
  "node" : {
    "title" : "Test 6",
    "body" : "<p>test</p>\n",
    "field_image" : null,
    "path" : "/blog/test-6",
    "created" : "Monday, November, 2012",
    "field_video" : "38"
  }

```

How can I get the Image Thumbnail URL?

# Answer
You can use php views, add php field and put this code (change the video field name to yours) in output part

```
<?php
$file=file_load($data->field_field_video[0]['raw']['thumbnail']);
print file_create_url($file->uri);
?>

```
> 1 votes

# Answer
You are looking for the Image URL Formatter module.
> 2 votes

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


# Question
Title: How to call hook in template.php after login from any user in drupal 7?
I am using below code to get the user login gender information & store in SESSION, I want to call below code after login, I already try this hook `function bartik_user_login(&$edit, $account) {}`but its not working. Please help. Thanks

```
if (user_is_logged_in())
{
global $user;
    $uid = user_load($user->uid);
    $profile_main = profile2_load_by_user($uid, 'main');
    $field_iam = field_get_items('profile2',$profile_main,'field_i_am_field');
    $_SESSION['i_am']=$field_iam[0][value];
    echo $_SESSION['i_am'];
}

```

# Answer
You should use preprocess function. For example -

```
function yourtheme_preprocess_user_login(&$vars) {
  $vars['intro_text'] = t('This is my awesome login form');
}

```

The general flow is:

theme($hook, $var) \>\> preprocess functions \>\> process functions \>\> finally either goto template.php or call theme function \>\> return output as string

therefore, template.php or theme function call is the final destination, no hook runs after template.php
> 2 votes

# Answer
You should use this hook in a custom module. You should also not tamper with core code as the Bartik theme directly. Also take a look at this:

How do I save session data for the anonymous users?
> 2 votes

---
Tags: theming, hooks
---


# Question
Title: Import a custom field type record and relate it to a node
I've created a module for a custom field type which selects images from cloudinary.

Is there a way to dynamically add entries as part of an import script? I've tried updating the database directly, but this is not ideal as it does not store any relations.

There is an answer for something similar, however I want to relate mine to an existing node. Is it possible with Node Export? If not, what am I doing wrong here:

My schema:

```
function cloudinary_field_schema() {

    $columns = array(
        'publicID' => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE),
        'title' => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE),
        'caption' => array('type' => 'text', 'size' => 'big', 'not null' => FALSE),
        'url' => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE),
        'credit' => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE),
        'keywords' => array('type' => 'text', 'size' => 'big', 'not null' => FALSE),
        'description' => array('type' => 'text', 'size' => 'big', 'not null' => FALSE),
        'primaryImage' => array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE)
    );

    return array(
        'columns' => $columns
    );

}

```

My hook menu contains this:

```
function cloudinary_menu() {
    $items['cloudinary/add'] = array(
        'access callback' => TRUE,
        'page callback'  => 'add_image'
    );
}

```

And bad practice importer:

```
function add_image () {

  $new_image = array();

  //get post
  $entity_id = $_POST['entity_id'];
  $publicID = $_POST["publicID"];
  $url = $_POST["url"];
  $title = $_POST["title"];
  $caption  = $_POST["caption"];
  $description = $_POST["description"];
  $keywords = $_POST["keywords"];
  $credit = $_POST["credit"];
  $primaryImage = $_POST["primaryImage"];

  //validate
  $entity_id = htmlspecialchars( $entity_id );
  $publicID = htmlspecialchars($publicID);
  $url = htmlspecialchars($url);
  $title = htmlspecialchars($title);
  $caption = htmlspecialchars($caption);
  $description = htmlspecialchars($description);
  $keywords = htmlspecialchars($keywords);
  $credit = htmlspecialchars($credit);
  $primaryImage = htmlspecialchars($primaryImage);

  //add to new image
  $new_image["entity_id"] = intval($entity_id);
  $new_image["field_cloudinary_publicID"] = $publicID;
  $new_image["field_cloudinary_url"] = $url;
  $new_image["field_cloudinary_title"] = $title;
  $new_image["field_cloudinary_caption "] = $caption;
  $new_image["field_cloudinary_description"] = $description;
  $new_image["field_cloudinary_keywords"] = $keywords;
  $new_image["field_cloudinary_credit"] = $credit;
  $new_image["field_cloudinary_primaryImage"] = $primaryImage;
  $new_image["delta"] = 0;

  //establish if this is a valid node using entity_id
  $result = db_query('SELECT * FROM {node} n WHERE n.nid = :nid', array(':nid' => $new_image["entity_id"]));

  //if it is, update cloudinary
  if($result->rowCount() > 0) {
    $r = $result->fetchAssoc();
    $new_image["entity_type"] = "node";
    $new_image["bundle"] = $r["type"];
    $insert_id = db_insert('field_data_field_cloudinary')->fields($new_image)->execute();
    drupal_json_output($insert_id);
  } else {
    drupal_json_output(false);
  }

    drupal_exit();
}

```

I'm very new to Drupal so struggle a lot with this stuff! Any help greatly appreciated!

# Answer
Just to double check: You have a content type with fields for your images from cloudinary, and you have nodes that already exist in your site that you need to get the data from Cloudinary into your node?

It looks like your looking up nodes through a query by the entity id (nid). Instead of doing that I would simply just load the node object by the `node_load` function (like `node_load($entity_id)`. You should be able to then assign the value of cloudinary fields in the node (it's gonna be something like `$node->FIELD_NAME['und'][0]['value'])`. Once you have all your custom fields inputed, just use `node_save($node)`.
> 3 votes

# Answer
If you are not that familiar with Drupal try the data module. It will give you the possibility to add a custom table (custom entity) with the possibility to add fields to that new entity. So you will be able to store your custom data and create an entityreference field to the node you wanna reference.
> 1 votes

---
Tags: 7, nodes, importing-exporting, services
---


title: Importing nodes directly into database

text:
# Question
Title: Importing nodes directly into database
I have created a custom content type and fields.

i want to import data into content type.

best solution for import data ?

i can export of database for example .CSV .XML

i don't know best solution for import data into drupal

# Answer
Just use Node Export.

1. Create one example node from your content-type
2. Export it to e.g. CSV
3. add your other nodes
4. re-import CSV
> 2 votes

# Answer
Use the feeds module it has CSV importer which works well. If you need to transform the data consider using the migrate module which is more time consuming but gives more flexibility
> 1 votes

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


title: Associate an user to a taxonomy term

text:
# Question
Title: Associate an user to a taxonomy term
I'd like to associate an user to a taxonomy term. I create users in a process import managed by rules.

I didn't found a solution with an existing module so I try to develop mine. I've also installed Entity reference module but I feel confused.

I've added a field\_user in my taxonomy term fields management.I've added a field\_conventions in my user field management.

I do not understand how to associate one or many terms to an user with rules.

I found User Terms module but unfortunately only for a Drupal 6.x

# Answer
> 3 votes
User profiles are fieldable in Drupal 7, you can add a taxonomy field already, with nothing but core. You don't need Entity Reference or any other modules, you can simply add field\_taxonomy to your user. Sure, it is a bit opposite to "add users to terms" you described, but later, if you need it for Views etc, it doesn't matter which way it was created - there is a connection between user and term, and you can use it.

---
Tags: taxonomy-terms, rules, users
---


# Question
Title: How to hide or remove field set on user profile page
I have user relationship installed. When i enable the user relationship node access module, the "Share content" field set appears on my user profile.

Is there a way to hide, remove or change the weight of the field set as I do not like the position it occupies on my user profile?

Thank you.

# Answer
> 2 votes
You can hide, change weight of any form element by help of form\_alter().

You will have to create a small module for it with any name like - **myModule**.

Put .info file in there & a .module file. Declare the information of the module. Enable the module.

Use my given hook & see what is available in form by DPM(You will need devel module to use this).

Write some thing like this

```
function myModule_form_alter(&$form, &$form_state, $form_id){
  dpm($form);
}

```

When you will visit the form you will get output of `$form` variable, where you can find `$form_id` to use to put in condition & the element which you are looking to remove or change properties.

Then you will have to put your logic in the function to have this working according to your need. Like see, how you can remove description from name/password field at login form --

```
function myModule_form_alter(&$form, &$form_state, $form_id){
  if($form['#id'] == 'user-login'){
    $form['name']['#description'] = t('');
    $form['pass']['#description'] = t('');
  }
}

```

This is not the exact solution you are looking for, but this is the way you can do it from yourself. I hope this help..

# Answer
> 0 votes
To add up to RajeevK's answer, you can always of course hide or change the appearance of form elements using CSS in your theme. Be careful that hiding form elements with CSS means that a user could still post data in the hidden elements if he would so wish to, so plan accordingly.

---
Tags: users
---


title: No data showing in tableselect

text:
# Question
Title: No data showing in tableselect
This is a very weird one...

I am building a table using

```
'#type' => 'tableselect'

```

I have

```
$header = array('date', 'name', 'email', 'location', 'time');

```

and

```
$options[$result2[$i]['id']] = array(
    'date' => gmdate("d / m / Y", $result2[$i]['timestamp']),
    'name' => $result2[$i]['name'],
    'email' => $result2[$i]['email'],
    'location' => $str_location,
    'time' => $str_time,
);

```

then I am building the table like this...

```
    $form['table_' . $n] = array(
        '#type' => 'tableselect',
        '#header' => $header,
        '#options' => $options,
        '#prefix' => '<div class="course_requests"><h1>' . $record1->name . '</h1>',
        '#suffix' => '</div>',
    );

```

The problem is this: The rows are showing.... *but with no data in them*!

I can output the `$options` array and it contains the data I want to see in the table. I have cleared the cache as mentioned here

Any clues as to why there are the correct rows with the correct columns but with no data?

# Answer
> 0 votes
Ahhhh!

Just as I posted this I discovered that my $header was malformed!!

```
$header = array('date', 'name', 'email', 'location', 'time');

```

should have been

```
$header = array('date' => 'Date', 'name' => 'Name', 'email' => 'Email', 'location' => 'Location', 'time' => 'Time');

```

Phew!

---
Tags: forms
---


# Question
Title: i am getting "Error generating image." Files permission is 777 and gd library is installed
I had installed gd library and also given 755 permission to the files but i am getting 500 - error generating issue in my drupal

My site URL is http://vestcom.ca/dev/

One of example URL of error is http://vestcom.ca/dev/?q=sites/default/files/styles/cardealer-car-mini-thumbnail/public/property-photos/IMG\_1373.JPG&itok=\_DfNUQVW

If anybody have any idea about how do i debug this or how can i get image then please let me know.

# Answer
Check your image toolkit (URI /admin/config/media/image-toolkit). You must see like this
> 1 votes

---
Tags: 7, media
---


# Question
Title: How to translate the description, and abstract metatag for the front page in a multilanguage site?
I am using the metatag module. In admin/config/search/metatags I am controlling my metatags for my front page using Global:Front page. Here it is my configuration

How can I translate these metatags for other language. I can use tokens for the title but I don’t know how to translate the description, and abstract metatag.

Any solution for this?

# Answer
> 3 votes
My solution was to install and enable the Translation table module. Then follow these steps

1. go to admin/config/regional/translate/translate
2. then filter by metatag and it will show all the metatags that you can translate.

That’s what it worked for me. If you have better solution please add it.

# Answer
> 1 votes
Solution 1: https://drupal.stackexchange.com/a/104829/21602

Solution 2: You can use views to generate front page. To use metateg in views you need to activate metateg views submodule. 7.x-1.1 version of metateg needs to apply patch https://www.drupal.org/node/1986032 for suupport i18n or use 7.x-1.x-dev version.

# Answer
> 0 votes
I use the context module to add meta tags in different languages to any page.

Create a context and select 'Require all conditions' Add 2 conditions: path and language Add 1 reaction: metatag

Configure conditions and reaction

---
Tags: 7, i18n-l10n, meta-tags
---


# Question
Title: How to attach browser-specific stylesheets in D8?
In D7 it's possible to attach a css file based on browser sniffing, like this:

```
drupal_add_css(
  $path_to_css,
  array(
    'browsers' => array(
      'IE' => 'lte IE 9',
      '!IE' => FALSE
    )
  )
);

```

Drupal 8 does away with `drupal_add_css` in favour of `#attached => array('css' => array( $path_to_css ))` but how, in that situation, can you achieve the same thing.

(Nb. I'm not actually using D8 yet, but where things can be done the D8 way in D7, I'm adopting them to ease the learning curve to come!)

# Answer
> 2 votes
I think this'll do it in Drupal 7, it should be the same for Drupal 8:

```
$build['#attached']['css'][] = array(
  'type' => 'file',
  'data' => $path_to_css,
  'options' => array(
    'browsers' => array(
      'IE' => 'lte IE 9',
      '!IE' => FALSE,
    ),
  ),
 );

```

---
Tags: 8, theming
---


# Question
Title: Can I use panels (page_manager?) to layout create/edit forms pages for arbitraty entity?
I am new to panels and display suite both and trying to figure my way around those modules.

In "Display Suite" with "Display Suite Forms" you get an extensive list of all entities and bundles and can override any of the create/edit form layout.

In "Page Manager" I see only *'node add form'*, *'node edit form'* and *'user edit form'* context out of the box. Is there a way to generalize it and use "Panels" functionality with other entities on the site like Display Suite does it? I mean, without writing code.

What I want is to take existing entity, say 'commerce\_customer\_profile' and automatically have its 'X edit form' and 'X add form' contexts available in Panels. Or something equivalent.

# Answer
> 1 votes
> I am new to panels and display suite both and trying to figure my way around those modules.

My preference is to use to Panels (or technically, Page manager) to control *Context*, that is, *What* to display *Where*.

Separately from that, you can use Display suite, or a recent favorite, Slate, for controlling rendering, or *How* things are displayed.

Allowing Page manager to render complete view modes instead of individual fields allows for much smarter caching most of the time, which can be a *big* performance gain.

If you're comfortable with code, Slate is significantly faster than Display Suite, for another large performance gain.

> In "Display Suite" with "Display Suite Forms" you get an extensive list of all entities and bundles and can override any of the create/edit form layout.
>
> In "Page Manager" I see only 'node add form', 'node edit form' and 'user edit form' context out of the box. Is there a way to generalize it and use "Panels" functionality with other entities on the site like Display Suite does it? I mean, without writing code.

'node add form', 'node edit form' and 'user edit form' are displayed as they are because the UI originates from D6, when there were no entities. The entire UI really needs a rewrite to be entity generic, but I don't know about anyone working on that.

> What I want is to take existing entity, say 'commerce\_customer\_profile' and automatically have its 'X edit form' and 'X add form' contexts available in Panels. Or something equivalent.

Panels/Page manager has an entity generic `context`, but I think Display suite has deeper integration with entities.

You can bind any entity to a page as a context by creating a new `Page`, giving it a argument, for example `%commerce_customer_profile` and map it to the relevant underlying entity type.

To be fair though, I'm not sure this works for edit forms, I haven't had a reason to try that I can think off. If it doesn't, I can think of two things to do.

1. Implement a task handler. This is probably not trivial, but would allow full integration into Page manager. Could be contributed back to Ctools.
2. Use Page manager existing pages to take over the rendering of the existing edit forms. Using this module is likely a good option specifically for edit pages, as you should rarely be using Panels directly to tear up a form anyway; that can cause unintended data loss.

Because Display suite and Panels are often seen as some form of competitors (which I think is wrong), it's worth noticing that the author of PM Existing pages is also the author of Display suite.

---
Tags: panels, display-suite
---


# Question
Title: how to send multiple attachments with drupal_mail_system
I can programmatically send emails with an attachment with problem. But after searching I can not seem to find the solution of how to attach multiple files. Does any one have the code to this.

Here's the working code I have for sending email.

```
$mail = variable_get('site_mail', '');  // sets the site wide email address

      $my_module = 'Email Application';
      $my_mail_token = microtime();
      $from = $sender;
      $message = array(
        'id' => $my_module,
        'to' => $app_email,
        'subject' => $subject,
        'body' => $body,
        'headers' => array(
          'From' => $from,
          'Sender' => $from,
          'Return-Path' => $from,
  ),
  );

$message['attachments'][] = drupal_realpath($attachment_path);

$system = drupal_mail_system($my_module, $my_mail_token);

```

# Answer
> 1 votes
You're using `$messages['attachments']` as an array, so presumably just add another item to the array:

```
$message['attachments'][] = drupal_realpath($attachment_path);
$message['attachments'][] = drupal_realpath($another_path);
$message['attachments'][] = drupal_realpath($yet_another_path);

```

# Answer
> 1 votes
My working Drupal 7 solution with module MimeMail without invoking hook\_mail():

```
// Load attachments.
$file1 = file_load($fid1);
$file2 = file_load($fid2);

$to = 'something@email.com';
$from = 'something@email.com';
$subject = 'Invoice ' . $file->filename;

$module = 'mimemail';
$token = time();

$message = array(
  'id' => $module . '_' . $token,
  'to' => $to,
  'subject' => $subject,
  'body' => array('something text...'),
  'headers' => array(
    'From' => $from,
    'Sender' => $from,
    'Return-Path' => $from,
    'MIME-Version' => '1.0',
    'Content-Type' => 'text/html; charset=UTF-8',
  ),
  'params' => array(
    'attachments' => array(
      0 => array(
        'path' => file_stream_wrapper_get_instance_by_uri($file1->uri)->realpath(),
        'filecontent' => file_get_contents($file1->uri),
        'filename' => $file1->filename,
        'mime' => $file1->filemime,
        'encoding' => 'base64',
        'disposition' => 'attachment',
        'list' => TRUE,
      ),
      1 => array(
        'path' => file_stream_wrapper_get_instance_by_uri($file2->uri)->realpath(),
        'filecontent' => file_get_contents($file2->uri),
        'filename' => $file2->filename,
        'mime' => $file2->filemime,
        'encoding' => 'base64',
        'disposition' => 'attachment',
        'list' => TRUE,
      ),
    ),
  ),
);

$system = drupal_mail_system($module, $token);
$message = $system->format($message);

if ($system->mail($message)) {
  return TRUE;
}
else {
  return FALSE;
}

```

---
Tags: emails
---


# Question
Title: Product display and taxonomy term ID filter (with depth)
I have a view for nodes that show my products by product reference field. All of these products tagged with "Catalog" vocabulary. I have added a reference to the field\_product in the view.

Is there any way to use contextual filter «**has taxonomy term ID (with depth)**» for this view?

# Answer
At the moment there is no easy/correct way of doing things as far as I know.

You could try to:

use Commerce Taxonomy Reference (sandbox project). Excerpt from the page:

> If you want to add the Contextual Filter 'has taxonomy term ID (with depth) to a Commerce Product View this module will accomplish that.

This does what you need, but I can't get it to work: there are some versions mismatching etc.

**OR**

You could move the Taxonomy Reference field away from the Commerce Product to the Product Display node (content type) and use the normal filter (Content: has taxonomy term ID (with depth)).
> 0 votes

# Answer
* Clone the default view called "taxonomy term" and start from there.
* Add a relationship to your product, and save.
* Add fields as you like.
> 1 votes

# Answer
Use the Taxonomy Entity Index module

This creates a more complete taxonomy index for all entity types, and provides useful Views filters.

Note: if installing on a site with existing content, you need to rebuild the index from the Configuration page before it'll work.
> 0 votes

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


title: Rules erases the last value inserted

text:
# Question
Title: Rules erases the last value inserted
i've an import module built with Rules which imports my users. An user can have one or many conventions. I manage these conventions with taxonomy. Conventions are store in my user fields, 'Number of values' under Field settings as 'Unlimited' My point is, i cannot add many conventions to an user, only the last convention keep in store. This is how i did:

```
{ "rules_updatepartenaireslistbatch" : {
    "LABEL" : "UpdatePartenairesListBatch",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "wsclient", "rules_conditional" ],
    "ACTION SET" : [
      { "data_create" : {
          "USING" : {
            "type" : "wsclient_ws_applicam_partenaire_FiltresPartenaire",
            "param_codePartenaire" : [ "" ],
            "param_complet" : 0,
            "param_conventions" : [ "" ],
            "param_raisonSociale" : [ "" ],
            "param_statutCode" : [ "" ],
            "param_typesAttribut" : [ "" ],
            "param_ville" : [ "" ],
            "param_top" : "20"
          },
          "PROVIDE" : { "data_created" : { "data_filtrepartenaire" : "Created data" } }
        }
      },
      { "data_create" : {
          "USING" : {
            "type" : "wsclient_ws_applicam_partenaire_GetListePartenaires",
            "param_numSite" : "1058",
            "param_filtres" : [ "data-filtrepartenaire" ]
          },
          "PROVIDE" : { "data_created" : { "data_getlistpartenaire" : "Created data" } }
        }
      },
      { "wsclient_ws_applicam_partenaire_GetListePartenaires" : {
          "USING" : { "param_parameters" : [ "data-getlistpartenaire" ] },
          "PROVIDE" : { "result" : { "result_list_partenaire" : "GetListePartenairesResponse" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "result-list-partenaire:GetListePartenairesResult" ] },
          "ITEM" : { "partenaire_item" : "Current list item" },
          "DO" : [
            { "data_convert" : {
                "USING" : { "type" : "text", "value" : [ "partenaire-item:id" ] },
                "PROVIDE" : { "conversion_result" : { "string_id" : "Conversion result" } }
              }
            },
            { "entity_query" : {
                "USING" : {
                  "type" : "user",
                  "property" : "name",
                  "value" : "PART_[string-id:value]",
                  "limit" : "1"
                },
                "PROVIDE" : { "entity_fetched" : { "part_fetched" : "Fetched entity" } }
              }
            },
            { "CONDITIONAL" : [
                {
                  "IF" : { "data_is_empty" : { "data" : [ "part-fetched:0" ] } },
                  "DO" : [
                    { "entity_create" : {
                        "USING" : {
                          "type" : "user",
                          "param_name" : "PART_[string-id:value]",
                          "param_mail" : "PART_[string-id:value]@here.invalid"
                        },
                        "PROVIDE" : { "entity_created" : { "entity_part" : "Created entity" } }
                      }
                    },
                    { "entity_save" : { "data" : [ "entity-part" ], "immediate" : 1 } },
                    { "user_add_role" : { "account" : [ "entity-part" ], "roles" : { "value" : { "5" : "5" } } } },
                    { "user_unblock" : { "account" : [ "entity-part" ] } }
                  ]
                },
                { "ELSE" : [
                    { "variable_add" : {
                        "USING" : { "type" : "user", "value" : [ "part-fetched:0" ] },
                        "PROVIDE" : { "variable_added" : { "entity_part" : "Added variable" } }
                      }
                    }
                  ]
                }
              ]
            },
            { "LOOP" : {
                "USING" : { "list" : [ "partenaire-item:conventions" ] },
                "ITEM" : { "convention" : "Current list item" },
                "DO" : [
                  { "entity_query" : {
                      "USING" : {
                        "type" : "taxonomy_term",
                        "property" : "name",
                        "value" : [ "convention:libelle" ],
                        "limit" : "1"
                      },
                      "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
                    }
                  },
                  { "CONDITIONAL" : [
                      {
                        "IF" : { "data_is_empty" : { "data" : [ "entity-fetched" ] } },
                        "DO" : [
                          { "entity_create" : {
                              "USING" : {
                                "type" : "taxonomy_term",
                                "param_name" : [ "convention:libelle" ],
                                "param_vocabulary" : "conventions"
                              },
                              "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
                            }
                          },
                          { "entity_save" : { "data" : [ "entity-created" ], "immediate" : 1 } }
                        ]
                      },
                      { "ELSE" : [
                          { "variable_add" : {
                              "USING" : { "type" : "taxonomy_term", "value" : [ "entity-fetched:0" ] },
                              "PROVIDE" : { "variable_added" : { "entity_created" : "Added variable" } }
                            }
                          }
                        ]
                      }
                    ]
                  },
                  { "data_set" : {
                      "data" : [ "entity-part:field-conventions:0" ],
                      "value" : [ "entity-created" ]
                    }
                  },
                  { "entity_save" : { "data" : [ "entity-part" ], "immediate" : 1 } },
                  { "drupal_message" : { "message" : [ "entity-created:name" ] } }
                ]
              }
            },
            { "component_rules_update_partenaire" : { "user" : [ "entity-part" ], "partenaire" : [ "partenaire-item" ] } }
          ]
        }
      }
    ]
  }
}

```

The aim is simple. \- I get all users from a webservice \- I do a loop on users \- I loop on user conventions \- if convention doesn't exist as taxonomy term, i create it \- else, I had the taxonomy term in a variable \- I use a "set\_data" to add the convention to the user

Ex: one of my user has "SPORT" and "CINEMA" in conventions. Only "CINEMA" is stored.

# Answer
Check if the Taxonomy user field (Convention) allows multiple values.

1. Go to Admin \> Configuration \> People \> Account Settings \> Manage Fields
2. Edit the Term Reference field (in your case, Convention)
3. Set 'Number of values' under Field settings as 'Unlimited' or 2 or as desired
4. Save
5. Execute the rule and check

Hope this helps.

Regards, Supriya Rajgopal
> 1 votes

# Answer
Resolved ! I had simply to replace the data set by "Add an item to a list". So i had each convention in my loop in the user's convention list.
> 0 votes

---
Tags: rules
---


title: Getting error after install drupal8?

text:
# Question
Title: Getting error after install drupal8?
I have installed drupal 8 .

During installation i am getting the below error

```
Drupal requires you to enable the PHP extensions in the following list (see the <a href="http://drupal.org/requirements">system requirements page</a> for more information):<div class="item-list"><ul><li>fileinfo</li></ul></div>

```

Which i have solved by uncommenting "extension=php\_fileinfo.dll" in php.ini file.

But after successfully installation i am getting connection reset issue like url is not found.

I know d8 is not stable version.

Still some users working/posting issue.

How they able to work on it?

Please suggest is there any alternative link to download d8.

Thank you.

# Answer
> Still some users working/posting issue. How they able to work on it?

They have set up a working web server, installed Drupal core files and a database, and configured a vhost for it. Once you've got your web server working you'll be able to work on it too. That should be your focus; check your web server error logs and fix everything that it says is wrong.

> is there any alternative link to download d8.

There might be, but why would you want to get it from somewhere other than the official Drupal repository? You wouldn't be able to trust that it was up-to-date or that integrity had been maintained with the official release (without manually checking, obviously, but that seems pointless).
> 2 votes

# Answer
Make sure you are using PHP 5.4 or higher per the System Requirements.
> 0 votes

---
Tags: installation, 8
---


# Question
Title: How do I make a block title output as a link?
I have a couple of Views block displays that are being shown inside of Panels content panes. I am trying to get the block titles to be links to overview (static) pages. The devel\_themer module suggested that I make a template file named `panels-pane--block--views-case-studies-block-block.tpl.php` ("Case Studies Block" is the block name.)

When I try to load the page now, I get errors about undefined variables (block\_html\_id, block).

I think this probably has something to do with Panels and Views templates clashing, maybe? I'm still getting my feet wet with theming/overrides. Any suggestions?

# Answer
> 1 votes
Got it! And the answer doesn't involve other modules or theming at all!

If you go into the pane settings for the block, in the Panels settings (node template) there is a checkbox labeled, "Link title to view". By itself, this didn't actually make a link at all. However, if you go back into the same settings dialog, there is another field, down at the bottom, labeled, "Override URL". If you specify the path there, then it will correctly output the block title as a link!

# Answer
> 5 votes
You can simply edit your View, and set the title of your view to this:

```
<a href="/mylink">My Link</a>

```

Click on Apply and then Save your view.

# Answer
> 0 votes
Would the Block Title Link module not provide your answer? Details from its project page:

> Have you ever needed to make a block title a link? This module makes it easy. Block Title Link creates a link field on the Block Admin page. It works by overriding the $block-\>subject variable and changes it to a link.

Might need to undo some of your custom theme code, but seems to do the job you're looking for.

---
Tags: views, theming, panels
---


# Question
Title: Hooks Alter not called in Template.php for
I run into strange thing today. I have some custom hook declared in a custom module as following:

```
drupal_alter('strange_thing', $shared_var, $vars);

```

then in template file(template.php) I got the function:

```
function THEME_strange_thing_alter(&$shared_var, $vars){
    //do something with $shared_var
}

```

The THEME\_strange\_thing\_alter() is called if i have unchecked " Use the administration theme when editing or creating content" in the admin/appearance in the "Administration Theme" section, but it is not otherwise.

To satisfy curiosity, I moved all the logic from tempalate.php into custom module/.module file and it works like expected...the hooks are called not matter if the box is checked or unchecked for " Use the administration theme when editing or creating content"

It would be great that the hooks work in template.php no matter if there is some box checked or unchecked in the UI. Is there way to make it so? Thank You

# Answer
> 4 votes
Hooks are only invoked for enabled modules, and the *current* theme. So code in template.php for theme1 won't be used when theme2 is active (unless theme2 is a subtheme of theme1, thanks @greggles).

The reason is obvious when you think about it: if you've explicitly said you want one theme on a certain page, code from another theme shouldn't be allowed to interfere. It could cause all sorts of problems.

If you have code that should run independently of the theme that's being used to display the page, the proper (and only) place to put it is in a module.

---
Tags: hooks, theming
---


# Question
Title: Highlight current user in multiple user reference field on /user page
I am displaying a block on all /user pages, that will show all upcoming events, and the staff that have been assigned to certain roles at that event.

For example...

**Manager:** Jake

**Bar Staff:** Mike, Fred, Jim

**Sound Tech:** James, Bill

What I want to achieve, is for every instance of a users name to be highlighted in that view, if they are logged in. So, go to Bills user page, and all "Bill" entries have an "active" class applied to them. Then, go to Mikes user page, and all "Mike" entries are given the "active" class etc.

Usually, I would name a template field for the view **field views-view-field--field-manager.tpl.php** and do a comparison with the current user page title, which is the current users name...

```
<?php

$title = drupal_get_title();

if ($title == $output) {
  $class = "active";
}

?>

<span class="<?php if(isset($class)) { print $class; } ?>"><?php print $output; ?></span>

```

But this is affecting the whole field, which is no good when you have multiple users referenced in the field.

Is there a way to target individual multiple results in a field with a tpl file?

# Answer
> 1 votes
This was actually much easier than I anticipated.

Of course, by default, every user name is a link, and for the user name to be highlighted on each users page, it meant that the link could automatically be given an active class as the current page.

Problem solved.

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


# Question
Title: Display event on click of Date with drupal fullcalendar module
i have made a event calendar with fullcalendar module.

Now what i need is that when a user clicks on the date box for example 9-sept he should be send to a custom url with the full date in the URL.

And i need to highlight the date boxes with colors based on my event type.

Any clues ?

thanks

# Answer
> 2 votes
Have you done this with the Drupal Full Calendar **Views** module?

If yes, then its quite simple...

1. Add another field for "event date" and format the date in the format you wish to use in the url , e.g., Y-M-D , then hide that field using "exclude from display".
2. In the field you want to have as the link, click re-write results.
3. Enter the path you wish to link to, using the event date pattern rewrite pattern you created in step 1. Your url should look like `<a href="/events/[event-date]">Link</a>`

As for highlighting the colour depending on event type, create another field for "node:type", and use that in the same rewrite results field as above, so your rewrite field is...

```
<a class="[node-type]" href="/events/[event-date]">Link</a>

```

Which will render out as...

```
<a class="event" href="/events/2014-06-24">Link</a>

```

Then in CSS, declare classes for your node type, for example...

```
.event {background:red}

```

---
Tags: datetime, javascript
---


# Question
Title: Node reference - limit so node can only be referenced once
I have two nodes 'Runner' and 'Buddy'. I'm using node reference to create a select list of buddies on the runner node.

The Idea is that every runner only has one unique buddy and two runners don't end up with the same buddy.

When editing the runner the buddy select list shows all buddies, I would like it only to show buddies that don't have a runner.

How would I achieve this?

# Answer
> 1 votes
Node reference (for Drupal 6) and Entity Reference (for Drupal 7) fields can be configured to use a View to show the available choices.

So, first create a View that shows all buddies that are not related to a runner. Then configure the field that points to the buddy to use that View.

To construct that View you may use the Corresponding Node References. It syncs the node reference between two node types which have a nodereference to each other. WIth this module your View only has to list buddies that have no runner related. This module is for Durpal 6 (I'm guessing your are using Drupal 6), but there's a similar one for D7.

---
Tags: nodes
---