# Question
Title: Is there a module that can replace tabbed menus with contextual links?
The tabbed menus at the top of node with entries like `View`, `Edit`, `Outline` takes too much space for my liking. In my case I also use the Node Clone module which also takes up more space because it uses an action link.

Is there a module to hide the tabbed menu and expand it on demand, or change it to contextual links? I have seen a few examples but they all seem to require changes to existing theme files or modules. Is there one implemented as standalone module?

# Answer
The Custom Contextual Links module does this https://drupal.org/project/ccl

Jeff Eaton gives a good overview of this module https://www.lullabot.com/blog/article/module-monday-custom-contextual-links

Alternatively, you could theme the existing menu to be styled like contextual links since both use an unordered list, just different css classes that trigger style and javascript behavior. To do so you could either use a custom module to add the css classes necessary or add your own css rules.
> 2 votes

# Answer
https://www.drupal.org/project/contextual\_tabs seems to be for you.

For the clone action, you could use the patch from here: https://www.drupal.org/node/1252702

There's also the module node\_clone\_tab, which turns the clone action into a tab. But i don't know if this works together with contextual\_tabs.
> 0 votes

---
Tags: routes, navigation
---


title: URL rewrite problem

text:
# Question
Title: URL rewrite problem
I face a problem with *URL rewrite* in views. In the *Re-Write Results* section I choose "*Output this field as a link*" and provide the following link path;

`node/[nid]&month=[field_month]`

(nid is the node id, field\_month is a date field with a special format of 'Y-m')

The relevant *URL* should be something like this `node/39&month=2012-02`.

The problem is that *Drupal* encodes the *URL* and in response I receive

`node/39%26month%3D2012-02`, which is unusable. I use *Drupal 7.12* and *views 7.x-3.1*.

Any suggestions how can I overcome this?

# Answer
See @MotoTribe's / @Ashlar's comment for a clue. `node/1/&foo=bar` is not a valid URL. An unescaped `&` character is only legal in the query portion of the URL, but not the path part. The path and query are separated by the `?` character and since your URL doesn't have a `?`, the `&` must be in the path part of your URL. As a result, views automatically escapes it for you.

I suspect you just want `node/[nid]?foo=bar`. In that case, views will NOT escape the `?` or `=`.

The `&` character is only used to separate queries when more than one appear in the query section of the URL.
> 1 votes

---
Tags: 7, views, uri
---


# Question
Title: Rewrite Results -> Output as Link: How do I get this to work?
Ok, so I have a table in my database that I am outputting by using a combination of the **data module** to bring in a table from my database and the **views module** so it can be displayed. The page with the view can be seen at http://apollo.tbc.iit.edu/~spaceweather/?q=distribute-data.

I want to enable the column fileSymlink to output as a link.

Below is an example of what the table looks like.

In order to try to enable the links in the last column:

1. Go to edit view
2. Click on the column in the fields section that corresponds to that column (i.e., fileSymlink)
3. Open the drop down "Rewrite Results"
4. Check to enable "Output this field as a link"

There is then a text form I need to fill out and I'm unsure what to put there. The text in the column is the link. For example if someone clicked on the text in the column DownloadData/cases/grid108/297/txt/channel\_dataout\_2013\_297\_0100.log, it would take them to apollo.tbc.iit.edu/~spaceweather/DownloadData/cases/grid108/297/txt/channel\_dataout\_2013\_297\_0100.log.

Am I doing this correctly, or should I be actually storing the HTML in the columns and having views render HTML instead?

I'm not set on one way of doing this, if there is any better way. Any suggestion is very appreciated.

# Answer
Don't the instructions for the link field tell you that you can use tokens in the URL? I do not have a view with a text field handy, but here is a screenshot from a view where I make a custom link for the title field:

Scroll down to the Replacement Tokens and expand that field. One of the options should be something like `[field_fileSymLink]`. Then you should be able to use something like `http://apollo.tbc.iit.edu/~spaceweather/[field_fileSymLink]` or maybe just `/[field_fileSymLink]`.
> 2 votes

# Answer
For those who are wondering why the hell nothing happens, just uncheck `Link this field to its taxonomy term page`.
> 1 votes

---
Tags: 7, views, navigation
---


title: Adding prefix/suffix HTML to View field

text:
# Question
Title: Adding prefix/suffix HTML to View field
I have a view that renders its contents as three fields, and based on the layout markup I received from our Front-end developer, two of these fields need to be wrapped in a container div so they can be floated as a column, with the first field and its encapsulating div serving as one column in itself.

However, I can't think of any way to theme these fields without creating a tpl.php, unless there's a prefix/suffix setting inside the Views setting i'm not seeing, and if not, what are my options for theming the field output?

The output generated is printed below.

```
<div class="item-list article-list">
  <li class="views-row views-row-3 views-row-odd clearfix">
    <!-- Row 1 (article img -->
    <div class="views-field views-field-field-image">
      <div class="field-content">
        <div class="image-container image-only-box fl-lt">
          <a href="/node/129"><img typeof="foaf:Image" src=
          "placehold.it/100x100"
          width="100" height="100" alt="" /></a>
        </div>
      </div>
    </div>

    <!-- This would mark the beginning of Row 2 -->
    <div class="views-field views-field-field-article-type">
      <div class="field-content">
        <h3><a href="/taxonomy/term/18" typeof="skos:Concept" property=
        "rdfs:label skos:prefLabel" datatype="">Health</a></h3>
      </div>
    </div>

    <div class="views-field views-field-title">
      <span class="field-content"><a href="/node/129"></a></span>

      <p><span class="field-content">Donec consequat sem urna, quis posuere felis
      tincidunt sit amet ongue vestibulum</span></p>
    </div>
    <!-- End of Row 2 -->
  </li>
</ul>

```

# Answer
> 3 votes
Check this Post to learn about re-writing results in views

* Add a new field called *global:text* in views and Choose Exclude from display in all the other fields you use
* Now edit *global:text* and check **rewrite result** to add your mark-up there

# Answer
> 0 votes
You can combine fields by setting output none in the views field itself. Then in the field below it, switch rewriting on and combine the token values from both fields. If you want to assign a class, you can edit the wrappers for the field.

---
Tags: 7, views
---


# Question
Title: How would I clear values in ajax loaded select options?
http://pastebin.com/TX2UiJGZ

I have 3 select drop-downs, selecting a value in the first populates the second using ajax, selecting the second populates the third. However when I change the value of the first select it doesn't reset the second (If I already chose the first and the second drop down initially).

**Method**

* Choose an option from the first
* This populates the second select with options A, B and C
* If I change the first one it won't reset the value if that value existed on the first option
* So if our first option called A, B and C and we change the first drop-down to something else but it calls C, D and E; if C was selected in the second drop-down it doesn't reset since it existed in both ajax calls, this then doesn't load in the third select unless you select a different option in the second select.

Basically what I need is to reset the second and third select whenever the first changes.

# Answer
> 0 votes
**SOLVED**

```
/**
 * The ajax call to return data for the printer model select.
 * @return array             An array of settings.
 */
function first_ajax_callback(&$form, &$form_state) {
  // Reset conditional select values.
  $form['field_printer_model_value']['#value'] = array('All' => 'Select Printer Model');
  $form['field_printer_type_tid']['#value'] = array('All' => 'Select Device Type');

  // $commands = array();
  $commands[] = ajax_command_replace("#second_dropdown", drupal_render($form['field_printer_type_tid']));
  $commands[] = ajax_command_replace("#third_dropdown", drupal_render($form['field_printer_model_value']));

  return array('#type' => 'ajax', '#commands' => $commands);
}

```

In the above call I set the #value of the selects I want to reset. These lines properly reset two later dependent selects:

```
$form['field_printer_model_value']['#value'] = array('All' => 'Select Printer Model');
$form['field_printer_type_tid']['#value'] = array('All' => 'Select Device Type');

```

---
Tags: 7, hooks
---


# Question
Title: Adding a "processed" flag to a Drupal Webform, that admins can use to indicate whether or not they've dealt with a particular submission?
We're using a Drupal Webform to accept customer requests for a free "kit" that we will mail them.

This works fine on the submission side, but we'd like a simple way to look at the submissions and tell which ones have been fulfilled, and which have not.

So far, I haven't been able to come up with a field that is visible *and* editable by administrators viewing the results, but not also shown to the customer when they are filling it out.

I realize I could put a checkbox on the form for "fulfilled", and then hide it from the customer with CSS... but I'm hoping there's a better way. Is there?

# Answer
> 1 votes
We have a similar thing where two fields are marked as Private and these are only seen by admins.

We also only allow authenticated users to submit these type of forms.

---
Tags: webforms
---


title: Getting a field's value from an entity

text:
# Question
Title: Getting a field's value from an entity
What I have installed on my site is the Entity API and Entityform modules. The Entityform module allows me to create forms that any user can submit and the forms fields are available for me to use in views, similar to how a content type would work.

Normally to pull a field's value from a node into my template with php I'd do the following:

```
<?php echo $node->field_name[$node->language][0]['value']; ?>

```

However this does not work with entityforms/entities.

Does anybody know of a way to do this for a field within an entityform? Some people have suggested to use devel and the dpm() function but I have no idea how to use those either.

Some specific examples on how I can get this field's value would really help me a lot.

# Answer
> 14 votes
Have you tried accessing the values with entity\_metadata\_wrapper?

```
$entityform_id = 12; // entity form id
$entityform = entityform_load($entityform_id);
$entityform_wrapper = entity_metadata_wrapper('entityform', $entityform);
// Access fields with $entityform_wrapper->field_name->value() or ->field_name->raw()
drupal_set_message($entityform_wrapper->field_my_field->value()); // for example

```

# Answer
> 8 votes
Without using the Entity API module, to get the value of a field associated with an entity, you use field\_get\_items(); you just pass the entity type, the entity object, and the field name.

For example, to get the body of a comment, you use the following code.

```
if ($items = field_get_items('comment', $comment, 'comment_body')) {
  // ...
}

```

To get the body of a node, you could use the following code.

```
if ($items = field_get_items('node', $node, 'body')) {
  // ...
}

```

The entity object is the object returned from entity\_load(), or a specific load function for that entity, such as node\_load(), comment\_load(), or taxonomy\_term\_load(). In Drupal 8, those functions are wrappers for `entity_load()`.

If you want to show the content of the field, then you should use field\_view\_field().

# Answer
> 0 votes
You normally can get at $node properties because you or some code you're using is calling node\_load() beforehand.

You need to fully load an entity before you can get at it's properties.

Use entity\_load() http://api.drupal.org/api/drupal/includes%21common.inc/function/entity\_load/7

Then you'll actually have a loaded entity object that you can get at the fields of.

Using dpm() is the same as any other function, you just need to install the devel module.

So, do something like this:

```
<?php
$entity = entity_load('myEntityType', $entity_id);
dpm($entity);
?>

```

# Answer
> 0 votes
Try:

```
$value= field_get_items('entityform', $entityform, 'field_myfieldname');
print '<p>the value is: '.$value.'</p>';

```

This should print the value of the field.

If it's an array try this:

```
$values = field_get_items('entityform', $entityform, 'field_myfieldname');
$value = $values[0]['value'];
print '<p>the value is: '.$value.'</p>';

```

Remember that this is the raw output and, depending on where the value comes from, you may have to sanitise the value manually here.

See: function field\_get\_items

# Answer
> 0 votes
Place this inside one of your modules and go to the form's page and you will find the info you are looking for.

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

  dpm($form);

}

```

# Answer
> -1 votes
Rather than using dpm and installing that module I use:

```
print_r('<pre>');
print_r($node);
print_r('</pre>');

```

Hopefully this will help you dig down to the value.

---
Tags: 7, entities
---


# Question
Title: Load view with ajax and contextual/exposed filters
I am trying to access content, that is provided via and can be filtered via a view. I want to load this content dynamically with Ajax. My problem now is, that I can access the view without problems using the following ajax-call:

```
$.ajax({
    url: Drupal.settings.basePath + 'views/ajax',
    type: 'post',
    data: {
        view_name: 'search',
        view_display_id: 'block_1',
        filterName: value
    },
        success: function(data,jqxhr) {
            $("#ajax-test").html(data)
            console.log(data[1])
        },
        error: function(error) {
            console.log(error)
        }
    });

```

This works fine, but it ignores the value of filterName (Which corresponds to the according input in the view form). Unfortunately using Better Exposed Filters and Links is not an option since I need to access many filters at once.

Also building an URL like so:

```
$.get(Drupal.settings.basePath + 'views/ajax/search/block_1/', "filterName[0]=filterValue" ,resultFunction);

```

did not work for me. Thanks ahead for any pointers!

# Answer
If you call a `display_id` of `block_1` the block does not have the `exposed_form` created to be evaluated by default in Views (views blocks cant have exposed forms out of the box) -- so your AJAX views calls knows nothing about any exposed form.

You need to either call a Views `Page` url where the exposed form is set on the page. Or, you need to use Views hooks to create/attach the exposed form to the View when your Ajax call is made.
> 0 votes

---
Tags: ajax, search, views
---


title: GoDaddy Application vs Manual Install

text:
# Question
Title: GoDaddy Application vs Manual Install
I would like to setup a Drupal site with my existing GoDaddy Hosting Plan.

Do you recommend using the Drupal Application (provided by GoDaddy) or installing Drupal (core) manually into the hosting account? Why?

# Answer
> 2 votes
Assuming this is what you are talking about Godaddy Application for Drupal

I would highly suggest to install Drupal on your own. That version is two releases behind with Drupal 7.34 addressing another recently found security issue with HTTPS websites.

---
Tags: installation
---


# Question
Title: Drupal commerce WPS , if user not go back to the site after paypal payment?
this is the problem. The payment used in my site is WPS (With Paypal Business account) so user switch from my site to Paypal site to pay order in cart.

BUT

If User close paypal site after paypal message "Payment complete" and NOT go back in site, the status order stay on "Checkout: Complete". Drupal Commerce has no way of knowing that payment is complete so not send order email and decrease stock.

Is there a way to get around this problem?

I work with drupal commerce kickstart 2 (+ stock module)

Ty for your reply :)

# Answer
I was experiencing a similar problem - no confirmation emails etc.

Apparently what was causing the problem for me was that I had created a custom Rule that fired "When an ordered is first paid in full" and updated the order status to "Completed." This custom Rule triggered after the user used PayPal WPS to complete payment. I did this to avoid the confusion of having the default status "Pending" after the the PayPal payment was successful.

For some reason, having this custom Rule there prevented all the Rules that use the trigger "Completing the checkout process" to trigger (these default rules include all the notification emails among other things).

See this posting here for a few cases of other people who ran into this problem: https://drupalcommerce.org/discussions/1150/resolved-completing-checkout-process-not-firing

This issue was resolved (in my case) by just getting rid of the custom Rule.

I'm wondering if this is causing the problem for you too.
> 1 votes

# Answer
Usually payment processing companies display a message that the customer should not close the window and wait for him/her to be redirected to the merchant site. Paypal should display this in your case. Please ask them to do it, every other payment processing company does it.
> 0 votes

# Answer
What you're describing doesn't sound correct to me. PayPal Payments Standard does display a link back to your store, but it isn't required for a customer to click it for any processing to happen for the payment on the Drupal side. Additionally, PayPal really doesn't do much to encourage a customer to click that link - I'd be at least half of customers won't be coming back by your shop after submitting payment unless they're different than mine. : )

What sounds fishy, though, is that your orders remain in "Checkout: Complete". Technically, they should be remaining in "Checkout: Payment", because that's the status they're in when the user redirects to PayPal. However, the IPN must be coming through and triggering some order status change, which is followed by the IPN listener simulating moving the order to the next page, "Checkout: Complete." You need to look into what rules you have operating on when a payment is received in full for an order, because the IPN triggers that whether the customers comes back to the site or not. You are probably changing an order status and it is getting set back somehow.
> 0 votes

# Answer
I have a similar problem. I'm using drupal-commerce but not kickstart. Most of the time, Paypal WPS is working as expected. Though, Sometimes I receive a payment from a customer but the order does not move to "checkout complete". The surprizing part is that when I look to the recorded carts in the admin part ("/admin/commerce/orders/carts"), selecting the corresponding cart, looking to the "Payment" tab of that cart, the payment has been recorded in the database with the result message "The payment has completed.".

Shortly speaking, I have a cart with valid payment in my database but the order is not completed and the stock does not decrease.

Have you checked if the payment is registered in the corresponding cart ? Any idea about what is happening ?
> 0 votes

---
Tags: commerce, payment-gateways
---


# Question
Title: Decoupling from Ubuntu/Debian package management
I'd like to decouple my Drupal 7 installation from the OS package management.

This is because Ubuntu's current LTS version (14.04) has Drupal 7.26, imported from the Debian packages at the time of release - it's now fixed at that version and they won't move to a later one.

Some security fixes have been backported, but not necessarily all. This is mostly due to policy issues with regards to software versions within the Ubuntu project, so the best solution is to reinstall my Drupal instance so that it's not under the control of the package management system.

I've been looking for information on this for a few days now, and can't find much of use.

I have the Backup and Migrate module, so can use that. I also have drush installed (albeit, ironically, via package management).

I can't get drush to update Drupal at all. My experience here (remembering back to Drupal 6) is that the Ubuntu package management has set some kind of flag that means Drupal doesn't check for updates for itself, only for modules & themes. "sudo drush up drupal" results in "specified project not found" for the drupal project.

Drush is updating modules and themes OK, just not core - so I believe I can probably install via drush.

My current plan is this:

1. Perform a backup (drush bam-backup)
2. Stop apache (service apache2 stop)
3. Remove the packaged version of Drupal (apt-get remove drupal7)
4. Install Drupal (drush dl drupal)
5. Restart apache (service apache2 start)
6. Restore the backup (drush bam-restore)

Does this look OK? Will I need to do anything between steps 4 & 6 (like set up the website system again)? Or am I approaching this the wrong way entirely?

# Answer
> 1 votes
If the site were mine I would first test the database against a new installation before I destroyed the old site.

I have never used the bam module so I do not know a lot about that. What I would do is dump the DB (drush sql-dump \> site.tld.data.sql or something like that). Restore that backup to a new database and install the latest release of Drupal 7 and attach that to the restored database. With the new code base you will need to run drush updb to get all the SQL updates to your older database. The issue you are really going to face is modules. How have you installed modules for your existing site? Manually? If you have just copy your sites/all/modules (or wherever they may be) to the test Drupal instance.

Of course you could do all of this locally on a dev machine without touching your site if you have that setup (Linux Desktop?).

After I got a warm fuzzy with the database being OK to run on a manually installed Drupal you could then attack your site and replicate the process. Again I am unfamiliar with the BAM module.

---
Tags: 7, drush, installation, upgrading
---


# Question
Title: Media module browser iframe opens with wrong domain
I have a site that is accessible from a subdomain and www. and when accessing from the subdomain the media module's file browser for file uploads/library opens using the wrong domain and so it fails due to security risks for cross domain iframe access. All I get is a white empty box in the modal. On the main site with www. it works fine.

I'm sure this is a fairly common problem, but I'm unable to find anything.

Anyone able to offer some help?

# Answer
This ended up being caused by a custom module we had on the site that performed url inbound and outbound alters to direct certain node types, paths etc. to certain domains. All we needed to do was add an exception to the handling for media paths.
> 0 votes

---
Tags: 7, media
---


# Question
Title: Using Drupal 7 & Omega 3.x - Page Titles + Edit Tabs are not showing up on node content types!
It seems that my page titles and the edit tabs have disappeared. I'm currently using omega 3.x and drupal 7. However the weird thing is that its showing up one content type, but not on others. I even created a new content type and it still doesnt show up. I also disabled the theme and enabled the default seven theme as the main one and it does show up. So it is in fact omega's subtheme that is causing the issue when i enable it.

# Answer
> 1 votes
it seems that it is a bug in omega. https://www.drupal.org/node/1906744 -- this took quite awhile to figure it out! The culprit was actually the "main content" block not being enabled on the blocks page. This was because I was primarily using context in positioning my blocks and left the default blocks page empty by not assigning anything. It seems that the theme has to detect the "main content" block in order to show the tabs. So the fix is just assigning the "main content" block back into the content region.

---
Tags: blocks, theming, 7
---


title: Site structure - nodes and blocks

text:
# Question
Title: Site structure - nodes and blocks
I'm new to drupal and I try to understand the structure of it.

Let's assume I want to do the following regardless of the existence of a module doing this concrete job – just to understand the structure and best practices.

What I need is a calendar module. This calendar should be displayed on an own page. So I think I must provide a special calendar content type, don't I? Then I want to display the next 3 events as a list on a front page. Here, I guess, I must provide a special block, which is only visible on the defined front page?

Is this the standard way of doing it?

# Answer
Your question is hard to answer because there are calendar modules. How those modules are implemented could vary infinitely.

Drupal being so flexible you could pose this question to 10 people and get 10 different answers and they would all work!

If I were to have this problem I would look for a calendar module that would expose the data it may contain to Views so I could do anything I wanted with the data. That would mean that the calendar module would use the Entity framework to save it's data which is the best way of doing things in Drupal.

The display of the calendar more than likely would not be a content type, it could be content you could insert into a content type using tokens or something like that or it may supply you a page and path to the calendar view or multiple paths. Again I go back to you could pose this question to 10 people and get 10 answers.

This may not answer your question. But your question is rather hard to answer without specifics in regards to modules.
> 0 votes

# Answer
To create an Event and calendar, please watch this video which shows step by step guide on how to create Events with Calendar. This is very nice video tutorial with steps.

Also, look into this https://www.drupal.org/node/1250714 and follow steps from this.

Yes, you are right, you have to create view block. Define View block into related region on front page.

This is how your view block will look for latest 3 events list on your front page.

You can also style that view by going into Chrome Dev Tool. Find element's ID that you wanted to change and give style to that element. Save that style to your CSS.

I hope this will helpful to you.

Thanks!
> 0 votes

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


# Question
Title: Can't seem to edit page title in og/users/%/add_user
In our what should be titled "Add Users", both `H1` and `title` both contain the value "Home". I have even tried to overide with another module's `hook_menu_alter`.

```
function hook_menu_alter(&$items) {
   $items['og/users/%node/add_user']['#title'] = t('test');
}

```

Page.tpl.php is untouched:

```
<?php if ($title && !$is_front): ?>
   <h1 class="title"><?php print $title; ?></h1>
<?php endif; ?>

```

Any idea of other areas I should try?

# Answer
This is what helped me in this particular situation, but I'd be open to mark another answer correct if anyone had a better option inside of a `hook_form_alter()`.

```
// Force Title on the Add Users OG form.
if ($form['#id'] == 'og-add-users') {
    drupal_set_title('Add Users');
}

```
> 0 votes

---
Tags: 7, routes, organic-groups
---


title: Every user is logged in as admin user

text:
# Question
Title: Every user is logged in as admin user
I have a weird problem with my new Drupal 7 site. This is also my first Drupal site.

* I have now two users: admin1 (has admin rights) & user1
* at first, when I logged with admin1, everything was fine
* when I logged in as user1, on the hovering admin panel it says that the logged in user is admin1, and this user has admin rights although they don't show on the DB. If content is added by user1, the creator is admin1
* I added user2 with no admin rights. Everything went fine until I logged out user2: now the admin1 do not seem to have admin rights anymore but the user2 has them
* I tried to disable nginx caching and it seems that it's off, but the problem still remains
* Earlier, my site was on LAMP-stack without problems. At least not similar to this. Apache needs too much memory so I switched to LEMP-stack, and this problem arised. So, I assume the problem is somewhere on my nginx-configuration.
* All this time, on the database, only admin1 actually have the admin rights

I am using the 7.34 core but the same problem existed with 7.33 as well. The site is hosted on DigitalOcean on a server using Ubuntu 14.04 x64. The webserver is nginx 1.4.6-1ubuntu3.1

# Answer
> 0 votes
@kalabro Actually, it was Drupal problem, but in my own code, not in the core or some module. As a Drupal newbie, I had used "global $user" at a template file to show the current logged in user's username on the menubar... When I removed this, problem was solved.

# Answer
> -1 votes
As a workaround, you could use the Auto Assign Role module.

# Answer
> -1 votes
This issue is only because other **users of your Drupal 7 site will have same permissions as the administrator is assigned with**.

See the values stored in **role** and **role\_permission** tables in your Drupal database.

Check if the `rid` value is assigned with similar `permission` values in the **role\_permission** table.\[Also take care of the `module` field if many exist\]

If so, this would be because of the reason that the users' roles are created with extra permissions other than:

```
access content
post comments
skip comment approval
use text format

```

-which are the default permissions assigned to the authenticated user.

All you can do now is either manually edit the table values\[not suggested by the community\] or use a module to update the user permissions for each roles.

Thank you.

---
Tags: 7, users
---


# Question
Title: Changing the $from email in D6 contact_mail_user_submit()
```
// Send the e-mail in the requested user language.
  drupal_mail('contact', 'user_mail', $to, user_preferred_language($account), $values, $**from**);

```

I wish to change the `$from` email to `"do-not-reply@domain.com"` to accommodate our email configuration.

`$from` is defined as `$user->mail [here in the function][1]` and I can't figure out how to override this via `MODULE_form_contact_mail_user_alter`.

# Answer
You can implement `hook_mail_alter()` to do that, e.g.:

```
function MYMODULE_mail_alter(&$message) {
  if ($message['id'] == 'contact_user_mail') {
    $message['from'] = 'do-not-reply@domain.com';
  }
}

```
> 0 votes

---
Tags: 6, emails
---


# Question
Title: How to create an rss.xml feed on my Drupal 7 site?
I would like to set up an RSS feed on a new site, but having never done this before I am unsure of where to start.

I've got an rss icon on my page and I would like to create a http://demo.drupalizing.com/corporateclean/rss.xml equivalent which is available on this demo site:

http://demo.drupalizing.com/?theme=corporateclean

How do I do this?

# Answer
You said you're using the views module, so yes -- very doable:

1. Go to `admin/structure/views/add`.
2. Give the view a name (required), add any (basic) additional configuration options you might want, and then under *Create a page*, select *Include an RSS feed*.
3. Give the RSS feed a path (you'll see the box).
4. *Continue & edit*, configure the view like normal, then save.
> 7 votes

# Answer
Sometimes you still get the error when doing step #4. If that's the case for you, don't do step #3 and then do step #4. Once you are inside the view, create a view display and modify your field setting when you add them.
> 0 votes

---
Tags: feeds
---


# Question
Title: Is it possible to have i18n without l10n?
What I mean by this is: Is it possible to have translated content\* without having a translated interface? Can we make the interface always be in English, even if I am translating content into Spanish?

* I'm use Entity Translation, but I imagine that this question would apply equally to i18n module.

# Answer
> 0 votes
You can switch to the preferred interface language in your user profile.

# Answer
> 0 votes
You could set English as the default language and hide the section mentioned by Volker in the user profile (hook\_form\_alter for example or by CSS).

Then in the Language -\> Detection and selection screen (admin/config/regional/language/configure), set User as the first detection and selection method and for example URL as the second choice. This way anonymous users will follow the URL indication but the authenticated users will get the language defined in their language settings which should be the default language.

---
Tags: i18n-l10n
---


# Question
Title: CSS Mime Type transferred as Zip in Chrome - 15 second delay
Resource interpreted as Stylesheet but transferred with MIME type application/x-gzip: "http://www.energyjustice.net/modules/system/system.base.css?m7sb47".

I turned off the CSS aggregate and compress option, and emptied the Chrome browser cache. So I'm not sure why I'm still getting this?

If there is nothing in the cache, this error causes Chrome to have a 15 second delay in transferring the system.base.css file. Firefox works fine.

Drupal 7.14 Apache/1.3.41 (Unix) with mod\_gzip/1.3.26.1a Chrome 20.0.1132.57

It looks like mod\_headers is installed.

# Answer
This is a TOTAL shot in the dark here, but:

1) are you running "Avast!" ?

2) If you load your site and look at network traffic (e.g. "Net" panel in Firebug), are there any 304 responses from the server?
> 1 votes

# Answer
In one of our projects, I found that someone had set zlib.output\_compression=On in PHP.INI and this caused chrome and firefox to produce the same problem you are facing.

Turning it back to off solved the issue (but the surprising thing is that InternetExplorer users did not face this issue in the duration when chrome was complaining)
> 0 votes

---
Tags: files
---


# Question
Title: How to import Profile2 users with taxonomy terms using Feeds?
I need to migrate a user-database into a new drupal system that uses Profile2 user profiles. The Drupal user profile contains fields like "gender", which are Term references (field type). This reference points to a Vocabulary, in which the genders are stored. Now I have a CSV file containing all users from the old database, and a Feeds importer. The importer is setup straight forward and all "value"-fields (surname, lastname, etc.) are working, but the term reference fields are not filled. How do I setup the importer correctly?

I tried to use the gender name (male/female) and even tried the respective term-IDs (`tid`). The first try results in an error message (wrong input format something), the second one does not produce error outputs but leaves the term reference fields blank as well. I also tried the "Entity Field Query finder" tamper plugin, but without success.

Am I missing something? Or is this import to complex for the Feeds plugin?

# Answer
> 1 votes
In the feeds reference importer\>mapping click the button under "Search taxonomy terms by: Term name" on the term reference mapping you're wishing to search and click the check box, then save.

---
Tags: migrations, users, taxonomy-terms, feeds
---


title: add link in Colorbox caption

text:
# Question
Title: add link in Colorbox caption
In my gallery, what i write as image title is the caption of my image and that is great. Now I would like to add a link (external url) to my caption, how can i do that? I already try to write normal url and html a tag but is always ignored.

I see two option in Colorbox configuration related some link, i play a bit with that but I didn't really understand what i'm supposed to do with that

How did you do?

**EDIT: Add screenshots step by step adding link for title**

My Colorbox gallery is placed in custom 'Photo Gallery' Content type. Here there are a list of images with Alt and Title. This images are automatically grouped thanks another view "Gallery Photo" which display the first image and then thanks to colorbox open all the other inside it as a gallery.

http://loungesquatt.com/drupal734

# Answer
You need to do it with JQUERY,there is another way as patching colorbox,but by default color box dont support link as title

```
   $('#cboxTitle').html('<a href="yourlink.com">title</a>');

```
> 0 votes

# Answer
Follow the steps given in this tutorial and then add one extra field as shown in below snapshot.

Give your external link to this field as shown below

Final step would be to use **replacement pattern** for this field in **colorbox trigger** caption field along with the title.

**Sample output:**

I have tested it and its working.
> 0 votes

---
Tags: navigation, javascript
---


# Question
Title: Is there a way to group different taxonomy/content type in a single Select List (in a View)?
I have different content types, each content type has its own taxonomy terms - see screenshot.

* International News
|--- Diplomacy
|--- War
-National News
|--- Economy
|--- Politics
-Entertainment
|--- Movies
|--- Theater
-Sports
|--- Football
|--- BasketBall

I built a view that, by default, lists all the content from the different content types/taxonomy terms and i wanted to add a select list that will allow the visitor to filter through content and get the nodes they're interested in (Football for example)

As you can see in the screenshot i have a filtering select lists block with a select list for each Content Type. Is it possible to have a single select list that groups all the content types and their taxonomy terms ?

If that's not possible. How can i reset the filters each time a filtering occurs. Right now, if i select *Politics* for example, the filtering is done and in the results we only get nodes that are tagged with that term which is exactely what it's supposed to do but on the resulting page, the filters do not reset themselves
If i select another taxonomy term, the first term i chose (Politics) stays on so unless there are nodes that are tagged with both terms, no nodes appear in the results page.

Any help is welcome

Thanks

# Answer
You can follow this using below step:

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

---
Tags: 7, views
---


# Question
Title: How can we sort view result, depend on cookie set or not
I have created a view to display slideshow from specific content type.

Now I have a condition that if visitor is new then slideshow will sort according to custom field "*slider order*". And if user visited already then slideshow will sort according to post date.

I have tried this from "`hook_views_query_alter`" but I want this to be done from view only.

I applied some custom sorting in views but not working (actually I have no idea about custom sorting in views)

Please let me know the conditions.

*Fields:* `title, description, Image`

*Filter:* `content type= slider`

*Sorting:* `Post date (desc)` \[here I need your help\]

# Answer
> 0 votes
* For any field you want to pull a value from a Cookie you add an exposed filter, here I add a contextual filter for the field, here a node-\>title:
* Then we configure the filter to pull a value from the URL. If none is provided we define how to find the value via PHP code. This is the secret to pulling the value from a $\_COOKIE value.

* Then we supply a blurb of code to read the Cookie value:

---
Tags: 7, views
---


title: views paging dropdown

text:
# Question
Title: views paging dropdown
I need something like a drop down pager for a view with many pages. Either drop down with all pages listed, or maybe more fancy like this one here:

http://www.zeit.de/2014/18/sextourismus-ostafrika/seite-5

(Scroll down to the comments part. Hovering the comments-pager pops up a grid with page-numbers)

Is there a module for that or an easy way to build it myself? I didn't find a solution.

# Answer
For now I didn't find any module for this but you can achieve this by playing around with pager **CSS**. Just like drop down menus. **Pager** also has an unordered list with **ul** and **li**. I tried it and somehow I was able to show pager as a grid on hovering it and it was working. You have to do some more in it to achieve exactly what you want.

Here I have given you a rough idea and I think this will help you.
> 0 votes

---
Tags: views, paging
---


# Question
Title: Copy content of one node into different content type
Does anybody know how to copy a content of one node from one content type into different content type?

Content type A -\> Content type B

I would like to copy the contents from the fields of content type A similar to content type B and set it as default for content type B, but I would let users to edit the field. I can't do **node clone** because content type B has more fields than content type A and also each content has a different URL aliases.

I tried entity reference prepopulate but it doesn't meet my needs. Also tried cross clone but I'm loosing my brain because I can't get it to work by rules, no instruction.

Are there any available module I can use? if you have any other suggestions please be nice to a beginner. :)

Thank you very much!!

# Answer
The Node Clone and Node Convert was almost perfect, but it did not support my needs perfectly.

I found Entity Reference Autofill. This module is way more simple and it allows me to get the content from 1 content type and be copied to another type of content instantly and be able to edit it all in one click.
> 1 votes

# Answer
You may be interested in Node Convert module:

> Node Convert adds a menu tab "Convert" on the node view page, i.e. node/1/convert, which gives the ability to convert the node from its current node type to another node type. The module provides the means to transfer all the field values of the current node type into fields on the destination node type, or discard them.

Of course this does not clone, but you can use node clone to create a clone of the A content type, and then convert said clone to content type B.
> 4 votes

---
Tags: nodes
---


# Question
Title: Build a form with multiple choice answers (multiple submit buttons) and validation
Requirements:

1. User navigates to path "new-problem" and is presented with a math problem and multiple choice answers, one of which is correct.
2. There is one submit button per choice
3. If the user clicks a wrong choice, we record that to the database and the same problem is shown again (user gets another chance)
4. If the user clicks the right choice, we record that to the database and a new problem is shown.

I haven't been able to coax Drupal to accomplish this thus far. I'm sure the problem involves how the form is/isn't rebuilt. I believe this to be related to Submitting a form rebuilds (expensive) page upon submit

I tried using a validation function and `form_set_error()` when the user chose a wrong choice, but the form kept being rebuilt from scratch with a new problem (instead of the same problem). I tried setting `$form_state['rebuild'] = TRUE` to no avail.

The code below works *except* for the first time. When a user navigates to "new-problem", he is shown the form. Upon clicking an incorrect choice's submit button, the "incorrect" status message is shown, but a new problem is shown. Thereafter, clicking an incorrect choice correctly shows the"incorrect" status message and the problem he got wrong.

**hook\_menu()**

```
function dfm_menu() {
  $items['new-problem'] = array(
    'page callback' => 'dfm_new_problem_page',
    'access callback' => TRUE,
  );

  return $items;
}

```

**menu callback**

```
function dfm_new_problem_page() {
  $node = dfm_get_new_problem(); // Returns a "problem" node

  return drupal_get_form('dfm_problem_form', $node);
}

```

**form builder**

```
function dfm_problem_form($form, &$form_state, $node) {
  $form['#nid'] = $node->nid;
  $form['#correct_choice'] = $node->field_correct_choice[LANGUAGE_NONE][0]['value'];

  $problem = $node->field_problem_mathml[LANGUAGE_NONE][0];

  $form['problem'] = array(
    '#prefix' => '<div class="problem-mathml">',
    '#markup' => check_markup($problem['value'], $problem['format']),
    '#suffix' => '</div>',
  );

  $i = 0;

  // One submit button per choice
  foreach ($node->field_choice_mathml[LANGUAGE_NONE] as $choice) {
    $correct = ($i == $form['#correct_choice']); // TRUE if this choice is the correct choice

    $form['choices'][$i] = array(
      'button' => array(
        '#type' => 'submit',
        '#value' => t('This one!'),
        '#submit' => $correct ? array('dfm_problem_form_submit_correct') : array('dfm_problem_form_submit_incorrect'),
      ),
      'mathml' => array(
        '#markup' => check_markup($choice['value'], $choice['format']),
      ),
    );

    $i++;
  }

  return $form;
}

```

**incorrect submission handler**

```
function dfm_problem_form_submit_incorrect($form, &$form_state) {
  // Create a new answer node to record the incorrect answer
  dfm_record_answer($form['#nid'], $form['#correct_choice']);

  drupal_set_message(t('Incorrect'), 'error');
  $form_state['rebuild'] = TRUE;
}

```

**correct submission handler**

```
function dfm_problem_form_submit_correct($form, &$form_state) {
  // Create a new answer node to record the correct answer
  dfm_record_answer($form['#nid'], $form['#correct_choice']);

  drupal_set_message(t('You got the last problem right!'));
}

```

Thanks for your time!

# Answer
> 1 votes
I recommend using one of these two modules and adjusting them according to your needs.

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

https://www.drupal.org/project/field\_quiz

The Field Quiz module provides a simple field that can be used as a simple quiz or multiple choice questions. It provides a field with a textfield and an checkbox combined. If added to a content type the editor of the node can enter multiple answers in the textfields and determine which answers are correct.

# Answer
> 0 votes
you can check if `$form_state['values']['choices'][$i]` is set then `$form['choices'][$i]['#disabled'] = true`;'

---
Tags: 7, forms
---


# Question
Title: How can I create a panel/page/view that shows a list of nodes, and on the other side of the screen details about that node?
Below is the generally layout of what I want to do. A list of nodes/items of a fixed content type with a custom view on the other side.

---

On the left hand side we see a list of nodes, shown as squiggles. One is selected (highlighted with a red border).
On the right hand side we see the details of this node: The Title, The Description and so on.

---

I've looked into Views and Panels. I think what I want is a View that is specific to the listed content type. And then to include that in a panel that has the list?

I've tried several times but gotten mixed up in what I need to do.

Is there a ***simple*** non-video (blocked at work) guide to doing this sort of thing?

All the examples I've seen either use pure `php` or make too many assumptions about knowledge of drupal.

# Answer
I don't know of any Drupal Contrib Master-Detail views modules. Views Megarow comes close, so check it out.

You can use Panels and Page Manager (part of CTools) if you don't mind a page reload to update the detail view.

1. To start, install Panels, Page Manager (part of CTools), and Views content panes (part of CTools).
2. Select a path that you want your master-detail view on: I choose `detail-view` for this example.
3. Create a view that lists your content titles (master display only). Add field nid to this view, set its display to none, and move it to above title field. Alter title field settings by removing 'link this field to the original piece of content', and rewrite results on this title field by selecting 'Output this field as a link', and enter `detail-display/[nid]`

4. Create a second view similar to first (view of nodes, master display). Add a 'Content Pane' display to this view. As this view will display fields for a single node only, add the fields you want to display. Then add a contextual filter of nid, and hide the content when the filter is not available. Now comes the important part. Click on 'Edit' next to 'Argument input' in the middle pane of the views UI. Select 'From Panel Argument' for the list box 'Content: Nid Source', then select 'First' from Panel argument.

5. Add a custom page (admin/structure/pages/add). Add your desired path (ie detail-display). Select Panel as the variant. Next screen of wizard choose a two-column layout.
6. When you get to the UI page where you select the content for the left and right side, do this.

a. For left panel, select 'Add content'. Select 'View Panes', and select the view pane that you created first (ie the one that lists all the titles).

b. For the right panel, select 'Add content', then select 'View Panes', and select the view pane that you created second (ie the one that lists detail for one node only).

7. Update and save the panel, and you are good to go.
> 5 votes

# Answer
Look into the Finder module in addition to creating a View Page.

From the Finder module project description:

> Typically Finder is used for these purposes:
>
> * As a search tool to find a group of nodes or users.
> * As a way to navigate to a specific node or user page that matches criteria.
> * As an alternative to exposed filters for a Views module display.
>
> Specific example uses of Finder:
>
> * An autocomplete search on node titles in order to find a node.
> * **A select list of all the possible values for a particular content field in order to get a list of corresponding nodes.**
> * Multiple groups of radio buttons and checkboxes with taxonomy terms to find nodes that match all the selected terms.
> * An autocomplete search on usernames in order to go to a user profile.
> * A multi-step wizard form to whittle down a pool of potential results by asking questions on one step that will reduce the possible answers on the next step.

Finder should be able to pick and choice, or filter, what shows up in the that Select list.
> 1 votes

---
Tags: 7, views, panels
---


# Question
Title: how to save a field created by using hooks in database
I added fields mobile no,landline no, using the below code to the form which i created with webform module. when i fill the fields along with two added fields and submit them .i cannot find the two added field in results.how can i make them appear in results.

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

if($form_id == 'webform_client_form_2') {
  $form['mobile no'] = array(
  '#type' => 'fieldset',
  '#title' => t('mobile no'),
  '#collapsible' => TRUE,
  '#weight' => 30,
);
$form['mobile no']['text'] = array(
  '#type' => 'textfield',
  '#description' => t('This is a test to see the form_alter hook in action1.'),
);

$form['text'] = array(
  '#type' => 'textfield',
  '#description' => t('This is a test to see the form_alter hook in action.'),
  '#title' => t('land line no'),
  '#weight' => 10,
);
}
}

```

# Answer
> -1 votes
*first create submit button*

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

```

*when you create submit it calls this function and feilds submitted or updated to your database*

```
function form_try_form_submit($form, &$form_state)
            {
                echo '<pre>';
                var_dump($form_state['values']);
                echo '</pre>';
                $insert=db_insert('DB')
                ->fields
                (
                    array
                    (
                        'phone' => $form_state['values']['phone']
                                 )
                 )
            }

```

---
Tags: hooks
---


title: Add menu item in hook form submit

text:
# Question
Title: Add menu item in hook form submit
I have an entity, when i submit this entity i want to add the new entity created in a menu as a link. But in this menu i have a tree links so i don't know how to put my link in a specific tree. I saw the "mlid" and the "plid", i think "mlid" is the id of the menu and the "plid" is the id of the mother link.

So if I want to add a new item, what do I need to do? Do I get the ID of the parent link? Do I need to use `menu_link_save()`? How do I construct my new link?

This is the code I am using.

```
$menu_intervenant_loaded = menu_load_links('menu-intervenant-project'. $idProject);

foreach ($menu_intervenant_loaded as $menu_item) {
  $menutitle = str_replace(" ","+", $menu_item['link_title']);
  $mlid = $menu_item['mlid'];
  $link = menu_link_load($mlid);
  $haschildren = $menu_item['has_children'];
  if ($menutitle == "Entreprises") {
    //The parent link: here is where I need to create my link.
    $item = array(
        'title' => 'Montitre',
        'access' => TRUE,
        'link_path' => 'encore un test',
        'link_title' => 'Mon titre qui fonctionne pas',
        'plid' => $mlid,
        'customized' => 1,
        'external' => 1,
    );

    menu_link_save($item);
  }
}

```

EDIT : With this code the link appear when i debug my menu before submit, but doesn't appear in my administration and front-end where the menu is placed..

# Answer
Value of `plid` is the menu link id of the item you want your new item to be a child of (=**parent id**).

To create your link, simply use something like:

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

```
> 0 votes

---
Tags: routes, navigation, forms
---


title: How to redirect user after login

text:
# Question
Title: How to redirect user after login
I created my site's homepage using panels(disable blocks regions)and there i placed the user login block. When a user is logged in through the block he is redirected to the homepage while if the user use user/login page he is redirected to his profile. Can i make the login through the block redirect also to the user profile?

# Answer
> 4 votes
Take a look at the Login Destination and the LoginToboggan modules. They should do what you want.
The first module allows you to customize the destination to which a user is redirected after logging in, registering to the site (7.x), using a one-time login link or logging out (7.x). The destination can be an internal page or an external URL. It is possible to specify certain conditions like referring pages, or user roles, and make the destination depend upon them. You may use PHP snippets to provide custom conditions and destinations. It is also possible to keep users on the currently visited page after logging in or out.

# Answer
> 1 votes
Rules is probably a better method in this scenario IMHO; however here's another way for the record.

```
/**
 * Implements hook_form_FORM_ID_alter().
 *
 */

function mycustommodule_form_user_register_form_alter(&$form, &$form_state, $form_id) {
  $path = current_path();

    // Add recruiter specific fields.
    if ( $path == 'user/login') {

      $form['#submit'][] = 'mycustommodule_new_register_submit';
    }

}

function mycustommodule_new_register_submit($form, &$form_state) {

$form_state['redirect'] = 'user';

}

```

# Answer
> 0 votes
You can use **Rules** module. It gives you ability to add rule for particular condition. You can write your rule to redirect after successful login.

# Answer
> 0 votes
I have the same proplem, And its solved with me by change #action like this:

```
  if($form_id == 'user_login_block'){
      global $base_path, $language;
      $lang = $language->language;
      $form['#action'] = $base_path."$lang?destination=user";
      $form_state['rebuild']  = TRUE;
  }

```

I hope this help

---
Tags: blocks, users
---


# Question
Title: Feeds creates duplicate content each time cron runs
I have created a custom feed importer but each time it runs it creates the same content again. How can I make it only create the content once?

# Answer
> 8 votes
In order to update existing nodes, Feeds needs a unique ID to match the source item with the target node. Otherwise, Feeds cannot know which node to update, so it just creates a new one.

When configuring the mapping for your feed importer, choose a unique field in the source, map it to the 'GUID' target and check the 'unique target' checkbox.

# Answer
> 1 votes
Use the Unique field module to assure that nodes with fields you specify as unique cannot be saved twice. Here is an excerpt about it from the module's project page:

> ... performs additional validation when a node is created or updated by a user to require that a node's title, author, language, and CCK fields are unique within a given context.
>
> Without this module, Drupal and CCK do not prevent multiple nodes from having the same title or the same value in a certain field.
>
> For example, if you have a content type with a date field and there should only be one node per date, you could use this module to prevent a node from being saved with a date already used in another node.

# Answer
> 0 votes
There is a setting under *admin/structure/feeds/{importer name}* \>\> Basic settings \>\> settings \>\> **Periodic import** , you have to turn this off in order to avoid recreation of previously imported content.

---
Tags: 7, feeds
---


# Question
Title: Drupal 7 same token showing twice in token available admin page
I have a simple question to understand if I made a mistake (during my migration from Drupal 6 or so ...).

In admin page, when I can use token in fields, in "Browse available tokens." popup I'm seeing same token twice, once with "\_", once with "-"

Eg :

```
Nom [current-user:field_last_name]  Texte field.
Nom [current-user:field-last-name]  Field "field_last_name".

```

(here the real field machine name is "`field_last_name`")

Did I miss something ? Tokens are working good but I don't know is this behaviour is normal ?

Regards.

# Answer
> 0 votes
This is normal behavior and nothing wrong.

The token with '\_' gets generated by 'token' module, and the second with '-' gets generated by 'Entity API' module (entity tokens).

Any one can be used.

---
Tags: tokens
---


# Question
Title: How to print custom text on search no result with search-results.tpl.php?
I want to print custom text if there is no result on search.

I'm using custom `search-result.tpl.php` and `search-results.tpl.php`.

My search-results.tpl.php is that:

```
     <?php if ($search_results): ?>
      <h2><?php print t($search_totals);?></h2>
      <div class="view-content">
        <table class="views-table cols-4 search-results <?php print $module; ?>-results table table-striped">
.../* my results style here */
        <tbody>
            <?php print $search_results; ?>
        </tbody>
        </table>
      </div>
      <?php print $pager; ?>

    <?php else : ?>
      <h2><?php print t('Your search yielded no results');?></h2>
      <?php print search_help('search#noresults', drupal_help_arg()); ?>
    <?php endif; ?>

```

It works correctly if there are search results but if there is no result it doesn't print **anything** although there is the `<?php else : ?>` part.

**How can I print custom text if there is no result?**

# Answer
The core Drupal search module uses several template files that dictate both how search results are displayed, and what's displayed when there are *no* search results.

If you're already using a custom theme on your Drupal site, the best way to customize those would be to copy and paste the entire 'search-results.tpl.php' file from the search/ module folder into your own custom theme subfolder.

Open that file up for editing and you'll see the following at the bottom:

```
<?php else : ?>
  <h2><?php print t('Your search yielded no results');?></h2>
  <?php print search_help('search#noresults', drupal_help_arg()); ?>
<?php endif; ?>

```

This is what's displayed if search results are not found (thus the 'else')... Modify the text to be anything you want here. The second line, which calls the search\_help() function is the one that displays the search suggestions. Feel free to replace that too....

And as always, before you can see your changes, you'll probably need to clear cache!
> 2 votes

---
Tags: 7, search
---


# Question
Title: Access denied occurs after translate menu link
I want to translate my menu, I have installed internationalization, variable and locale modules but on my menu items when I click on translate :

An access Denied page is displayed :

What am I doing wrong?

\[EDIT\] Log :

# Answer
You need to make sure the menu is translatable. Do this by clicking on the "Edit Menu" option and clicking on "*Translate and Localize. Menu items with language will allow translations. Menu items without language will be localized.*"

The click "Save".

The path would be as follows: ***site***/admin/structure/menu/manage/***menu\_id***/edit
> 29 votes

# Answer
you must first assign a language other than the default "language neutral" to the existing menu items (click edit for the menu item). Once a source language has been assigned, the translate link should work.
> 4 votes

# Answer
do you need to enable the option in admin/structure/menu/manage/main-menu/edit

you have three option choose the middle one...

i hope i help you!
> 0 votes

# Answer
When you have entered the menu item via the **menu import**, if you have selected **language undefined** during the import process for the new menu items, then trying to translate those menu items results in access denied.

If you **re-edit** those menu items, then you can translate them.

This works for the menu option "Translate and Localize. Menu items with language will allow translations. Menu items without language will be localized."
> 0 votes

---
Tags: routes, i18n-l10n
---


title: How can i limit hours in date field?

text:
# Question
Title: How can i limit hours in date field?
I have a reservation form with entityForm and i want to limit hours in date field.
like it begins 3:00 till 9:00 .
i've searched a lot and use Date Restrictions module but i couldn't do this .
Any idea would be appreciate it ?

# Answer
Keeping your date field, I don't know an easy way. But if you take a look at https://www.drupal.org/project/office\_hours, it would create a new field allowing custom hours. Maybe combining both fields you could do the trick.
> 0 votes

---
Tags: datetime
---


# Question
Title: Global php view for conditional profile image
I have tried to configure a view for a user listing. In this view only few fields from the user entity will be shown. In the user entity I have a boolean variable. If the boolean variable is TRUE ("1") the real profile image should be shown, otherwise the default image for all users should be shown.

In order to implement it I have added a views field of type `Global: PHP`. In the field's code I wrote:

```
$file = file_load($row->picture);
if(isset($row->field_primum) ) {
if($row->field_primum == "1") {
print theme('image', array('path' => $file->uri));
else ($row->field_primum == "2") {
print(<a  src="/sites/all/themes/test_them/images/anonymous.jpg" height="42" width="42"></a>);
}
}
}

```

However it runs only on the first user and not for all users in the display. Do you have any idea why?

Thanks zanet

# Answer
> 0 votes
It's possibly the result of syntax errors.

This is where you can see the benefits of well formatted code.

If you format your code like this it becomes more obvious that you have errors in your code (I assume $row-\>picture actually is a file ID):

```
$file = file_load($row->picture);
if (isset($row->field_primum)) {
  if ($row->field_primum == "1") {
    print theme('image', array('path' => $file->uri));
    else ($row->field_primum == "2") {
      print(<a src="/sites/all/themes/test_them/images/anonymous.jpg" height="42" width="42"></a>);
    }
  }
}

```

Problems I can see now are:

1. There you can see that the else actually has no if statement because it is inside the second if statement.
2. The else also shouldn't have the condition. If it needs the condition then use elseif.
3. You mention that the field you are using is a boolean field, in which case the values will be 0 & 1, not 1 & 2.
4. The second print statement should be printing a string so the string should be wrapped in quotes.
5. You are incorrectly using the a tag to print an image. You should use an img tag for images and an a tag for links.

I would think it should be more like this:

```
if (isset($row->field_primum)) {
  if ($row->field_primum) {
    $file = file_load($row->picture);
    print theme('image', array('path' => $file->uri));
  }
  else {
    print('<img src="/sites/all/themes/test_them/images/anonymous.jpg" height="42" width="42" />');
  }
}

```

Note that I also moved the file\_load() call inside the if statements because there is no need to load it if you aren't using it.

---
Tags: views
---


title: Override preexisting rules

text:
# Question
Title: Override preexisting rules
Currently, changes are replicated by hands (and rules exports) from dev to a test stage available to the customers. There is actually no live site.

We are going to use the Features module and `hook_update_N()` in order to deploy the live site.

I wonder what will hapen if I add a feature including some rules already existing on the test stage (created by hand before I got assigned on this project).

Will the rules be overwritten? Will I get errors? I read that updating features files actually updates the rules (or whatever is inside the feature).

# Answer
> 1 votes
If you are using Features module in Drupal 7 to deploy the rules. You will get an overriden or needs review flag in the Features UI when you attempt to turn the feature on. Features will see the existing code and it will not attempt to change it. Features is designed so that things done through the Admin UI of Drupal are not overriden unless you force Features to do so via a manual review of the feature.

To save yourself a lot of headache later on in the project I would suggest removing the rules before you install the Feature. Maintain configuration control with Features so that you know if you look at the Features admin page and a feature you have is showing as "overriden" or "needs review" then you have a problem on your website or someone has changed a part of the website. I personally have a website with about 20 features, all of them never say "overridden" or "needs review" if they do then I know another admin has done something that potentially should not have done.

# Answer
> 0 votes
If these are reaction rules, you don't need to override anything. You can create new rules for the same events and disable the existing ones.

If they are components, you should be able to use Features Override to override the already defined rules. Caveat: I have not actually used this module on a project recently.

---
Tags: features, deployment
---


# Question
Title: Field Group Conditional State does not work after upgrade
After recent upgrade of fieldgroup module, the conditional state visibility for field group does not work now.

Please find the previous code that used to work:

```
function ji_custom_field_group_build_pre_render_alter(&$element) {

  //BioChemistry
  if(isset($element['group_tr_biochemistry'])){
    $element['group_tr_biochemistry']['#states'] = array(
      'visible' => array(
        ':input[name="field_tr_test_ref[und]"]' => array('value' => 12),
      ),
    );
  }

  //CBC
  if(isset($element['group_tr_cbc'])){
    $element['group_tr_cbc']['#states'] = array(
      'visible' => array(
        ':input[name="field_tr_test_ref[und]"]' => array('value' => 15),
      ),
    );
  }
}

```

However this does not work after the upgrade. I get an PHP notice instead:

> Notice: Undefined index: #id in drupal\_process\_states() (line 4651 of /srv/www/www.example.com/public\_html/includes/common.inc).

Do let me know the workaround possible. Thanks.

# Answer
Searched for some time. Tried different options. Finally reverted to older version 1.3 and it worked just fine :)

This was the bug which has not been addressed in the dev version as of now: https://www.drupal.org/node/2283245

Thanks.
> 2 votes

# Answer
I fixed this bug by downgrade field group module from 7.x-1.4 to 7.x-1.3

step by step

1. disable field group module.
2. delete field group module folder from server.
3. install module from http://ftp.drupal.org/files/projects/field\_group-7.x-1.3.tar.gz
4. enable module again.
5. run update.php

It's works for me.
> 1 votes

# Answer
Or you can define ids for your groups :

It will fix the message as the JS error.
> 0 votes

---
Tags: javascript
---


# Question
Title: reference a view page with entity reference
I have an entity reference field for referencing and rendering a teaser display of nodes.

I would like to be able to include a View page in the list. I this possible in some way?

# Answer
View Reference Module makes it possible

> Defines a field type View reference which creates a relationship to a Views display and allows the view to be displayed as the content of the field.

**OR**

Entityreference View Widget Module is another solution

> This module provides an advanced Entity Reference widget that uses a view embedded in a modal dialog for selecting items.
>
> In the Field UI for the Entity Reference field select "View" as the widget

* Edit your Content Type or Entity
* Add or Edit the field with "Entity Reference"
* Next make sure your "field" - "widget type" is set to "View"

**Check for the following "field" settings in your content type field:**

* "View": make sure you select your "Entity Reference View Widget"
* Pass selected entity ids to view
> 0 votes

---
Tags: views, entities
---


title: Show weight on the content screen

text:
# Question
Title: Show weight on the content screen
Is is possible to show the weight select box on admin/content, rather than having to go into the node to edit it?

# Answer
> 0 votes
Weight Module Provides it : Read Documentation

> On the Content administration page (Administration » Content), there will be a "Weight" column containing a selector box to set the weight of any node with a content type that has been weight enabled.

And Here is a Comparison of Node/Entity Ordering Modules

* To enable Weight for a content type, go to Administration » Structure » Content types and select the content type you want to enable Weight for. Select the Weight vertical tab, choose your desired settings, and click the Save button.

* Now in `admin/content` you could see weight column

---
Tags: views, nodes
---


# Question
Title: Sharing only one content type between 2 websites
I have 2 websites set on the same drupal 7.32 instance. There are completely different, with different databases. But I need to show some content from website1 in website2.

I just need to get a list of nodes from the database for website1 with one specific type and list some details about them in website2.

I know I can get all the nodes with a certain type like this:

```
$nodes = node_load_multiple(array(), array('type' => 'node_type_here'));

```

But this (obviously) works within the same site.

Any tips on how I can get them on a different site?

# Answer
> 1 votes
If you are trying to share content between sites, you may want to look at the deploy module....

> The Deploy module is designed to allow users to easily stage content from one Drupal site to another. Deploy automatically manages dependencies between entities (like node references). It is designed to have a rich API which can be easily extended to be used in a variety of content staging situations.

To share a Content Type between sites, look into features:

> The features module enables the capture and management of features in Drupal. A feature is a collection of Drupal entities which taken together satisfy a certain use-case.
>
> Features provides a UI and API for taking different site building components from modules with exportables and bundling them together in a single feature module. A feature module is like any other Drupal module except that it declares its components (e.g. views, contexts, CCK fields, etc.) in its .info file so that it can be checked, updated, or reverted programmatically.

Alternatively if you're only trying to share a *list of things*, what about using RSS feeds from Website 1 and using the Feeds Module to pull it into Website 2?

> Import or aggregate data as nodes, users, taxonomy terms or simple database records.
>
> One-off imports and periodic aggregation of content Import or aggregate RSS/Atom feeds Import or aggregate CSV files Import or aggregate OPML files PubSubHubbub support Create nodes, users, taxonomy terms or simple database records from import Extensible to import any other kind of content Granular mapping of input elements to Drupal content elements Exportable configurations Batched import for large files

Also as mentioned in the comments the Migrate Module is worth a look.

> The migrate module provides a flexible framework for migrating content into Drupal from other sources (e.g., when converting a web site from another CMS to Drupal). Out-of-the-box, support for creating core Drupal objects such as nodes, users, files, terms, and comments are included - it can easily be extended for migrating other kinds of content. Content is imported and rolled back using a bundled web interface (Migrate UI module) or included Drush commands (strongly recommended).

---
Tags: 7, nodes, multi-sites
---


# Question
Title: View page as default page for content type
This could be a noob question but i am really not able to understand how to achieve this. I have several content types and custom detail page i.e view page for each content type. So each time i add/edit/update/search a content type say news or something, it redirects me to default node page but i don't want that. I want it to redirect to the view page i have created.

There is a module called Rules, which helped me to redirect to that page after adding/updating content, but it has some redirection errors which results in server ended unexpectedly error. Also in search the default page shows up as node page not my custom view page.

How do i do this, so that my custom view page becomes the default page for my content type. Please help..?

# Answer
> 1 votes
There are a couple of ways to do this.

One is to edit your node template file and field order so that the default node view is how you want it to look.

Another, if you prefer to create a view, is to do so and use a module like Internal Nodes or Page Manager (part of ctools) to redirect to the view.

# Answer
> 1 votes
If you don't want the node information to ever be visible to the user, I would suggest something like this:

* create the content type as normal, under manage display set the label and field to hidden. This will ensure that the content itself does not show. This will essentially create an empty page
* build a content view, as a block using the content type for reference.
* using a contextual filter to retrieve the node information, you can build the view to show the information in the format you want.
* under structure-blocks, set that view to only display in the main content area of that specific content type

This will allow the view to show while hiding the original content, without the need for redirects - a little more SEO friendly, and faster to render.

# Answer
> 0 votes
You can use eva field module, what is does is, it makes "the output of a View to be attached to the content of any Drupal entity".

So you can show a view in manage field options in the content type. Also you might want to use contexual filter for getting nid's which would make view more dynamic, as said by @Geoff.

# Answer
> 0 votes
This sounds like a job for Page Manager (part of CTools), and specifically it's HTTP redirect variant.

Look at Johan Falk's series on Page manager, specifically this one: Learn Page manager! Part 2: Introduction and more

And if you do decide on Page Manager, then please give @Darvanen the credit as I only now saw that he also mentions it.

---
Tags: views, 7, nodes, redirection
---


# Question
Title: How to print $item separately, with different content, in views-view-grid?
I am trying to create an image gallery, using Views 3 for Drupal 7. A brief overview of what I did:
\- Create custom content type for photo gallery (title and image fields
\- Create View for the gallery page
\- Set format to "Grid", and show to "Fields" \- Added field: "Content: Photo" (preview image style) \- Added field: "Content: Photo" (thumbnail image style)

As you can see, I have two fields with the same field so that I can have two differently sizes of each image. What I need to do, is print these images in two different places in my template.

This is my `views-view-grid--gallery.tpl.php`:

```
<table>
  <?php foreach ($rows as $row_number => $columns): ?>
    <tr>
      <?php foreach ($columns as $column_number => $item): ?>
        <td>
          <?php print $item; ?>
        </td>
      <?php endforeach; ?>
    </tr>
  <?php endforeach; ?>
</table>

```

I want to be able to do something like this:

```
<table>
  <tr>
    <?php // foreach ?>
      <td>
        <?php // print preview image ?>
      </td>
  </tr>
</table>

<div class="thumbnails">
  <?php // foreach ?>
    <?php // print thumbnail image ?>
</div>

```

I have tried a multitude of things, but I can only make `$item` print either one of the images, or both of the images. Since only the final, HTML-formatted image is returned, I can't figure out how it is possible to split it up.

Thanks much in advance!

# Answer
> 1 votes
Anyone still looking for this, that's how I did it:

First I've created a simple view with a block to show just the fields that I needed on top (let's call it view-top), striped all default elements and classes to make it clean and easier to work (not really necessary to clean it). In OP's case would be the miniature for the gallery.

Then I've made my main view with the fields that I wanted on bottom (let's call it view-bottom). In OP's case would be the full sized images. In the header of this view I've added a "Global: Visualization area" and called my view-top.

This way I had two views, one embedded in the other, and with a bit of Drupal's behaviors I've made the click logic.

---
Tags: 7, views
---


# Question
Title: After Drupal 7.32 should sql injection attempts create PDOExceptions?
I have the Logging and Alerts module installed on a few of my sites. Yesterday I noticed a series of notification emails with the following data. These produced `PDOException` exceptions and so far as I can tell were unsuccessful at doing anything malicious.

This site was patched hours after SA-CORE-2014-005 was announced on 2014-Oct-15.

I simply want verification that these types of SQL injection attacks create PDOExceptions in Drupal, vs stripping the offending key/values from the injection attempt. Prior to the patch I wasn't receiving any such errors.

```
Email Title from LoggingAlerts module:
[] Error: PDOException: SQLSTATE[42000]: Syntax error or access...

Email Message Body:
admin@site.com  Mon, Nov 17, 2014 at 11:04 AM
To: admin@site.com
Site: https://site.com
Severity: Error (3)
Timestamp: 20141117 11:04:35
Type: php
IP Address: 128.xxx.xxx.xxx
Request URI: https://site.com/?q=user/login
Referrer URI:
User: Anonymous (0)
Link:
Message:
PDOException: 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 ' 'test' AND status =
1' at line 1: SELECT * FROM {users} WHERE name = :name_0, :name_1 AND status
= 1; Array
(
[:name_0] => test3
[:name_1] => test
)
in user_login_authenticate_validate() (line 2149 of
/var/www/mysite/htdocs/modules/user/user.module).
$_SERVER => Array
(
[HTTP_HOST] => site.com
[HTTP_X_REAL_IP] => 198.101.235.xxx
[HTTP_X_FORWARDED_FOR] =>

... lots of more lines of email output ...

```

# Answer
As per this answer -- Drupal throws a PDOException on sql injection attempts as of Drupal 7.32: https://drupal.stackexchange.com/a/133820/3279

From the testing module:

```
/**
+   * Test SQL injection via database query array arguments.
+   */
+  public function testArrayArgumentsSQLInjection() {
+    // Attempt SQL injection and verify that it does not work.
+    $condition = array(
+      "1 ;INSERT INTO {test} SET name = 'test12345678'; -- " => '',
+      '1' => '',
+    );
+    try {
+      db_query("SELECT * FROM {test} WHERE name = :name", array(':name' => $condition))->fetchObject();
+      $this->fail('SQL injection attempt via array arguments should result in a PDOException.');
+    }
+    catch (PDOException $e) {
+      $this->pass('SQL injection attempt via array arguments should result in a PDOException.');
+    }
+
+    // Test that the insert query that was used in the SQL injection attempt did
+    // not result in a row being inserted in the database.
+    $result = db_select('test')
+      ->condition('name', 'test12345678')
+      ->countQuery()
+      ->execute()
+      ->fetchField();
+    $this->assertFalse($result, 'SQL injection attempt did not result in a row being inserted in the database table.');
+  }
+

```
> 1 votes

# Answer
It is my understanding that in theory, yes, a compromised site from the particular vulnerability could lead to such behaviour. As Drupal.org recommends, in such cases you should treat your site as compromised and all next actions should be the appropriate for this case.

The fact that you patched the site shortly after the announcement, as you mentioned, is very important. As far as I have seen, most attacks are coming from scripts and it has not come to my attention any automated attack that would cause such behaviour (to my experience of course). This again is not reassuring, just a thought on the possibility for the nasty thing to have happened.

Apart from the obvious actions (see links below), I would definititely take a good look of the code that doesn't behave nicely. Also a good tool is always diff comparing to clean code. I would as well take a good look in the db. Last, there might also be a possibility that some contributed module has got issues with 7.32 or maybe anything else that might have been updated.

Drupal SA-CORE-2014-005 - How to tell if my server / sites were compromised?

https://www.drupal.org/drupalsa05FAQ
> 1 votes

---
Tags: 7, security
---


# Question
Title: How to add unique identifier to each submission?
In short, I am trying to figure out how to add a custom and unique identifier to each submission from the Webform module.

Example: User fills out the Webform and submits. User then receives an email (email is captured from email field in Webform) confirming their submission and providing them with a Unique Identifier (ABC-14-001).

I know Webform asks what number to start the next submission (and I'm assuming this is considered the "SID"). If I am to utilize the SID, I need to be able to append the custom "ABC-14" prefix to each submission's SID.

I'm not very familiar with hooks (sorry for the ignorance), but I understand that hooks might be the only way, or at least most effective way, to accomplish this?

**Update** Thanks all who responded! I have a working solution right now with this module:

`function identifier_webform_submission_presave($node, &$submission)
{
 $component_id = 23; //that's your hidden field
 $submission->data[$component_id][0] = 'Text to be inserted';
}`

# Answer
You want to use `hook_webform_submission_presave` to record your special key. I would create a `hidden` textfield in the Webform that is optional so the value can be set by your PHP code upon submission.

For a basically full working example see Webform Issue #1964080.

To create your special value such as `AB-001-12345` you just make a php function that creates a random string, or a string to your specifications:

```
function generate_special_submission_key() {
  $length = 10;
  $str = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
  return $str;
}

```
> 0 votes

# Answer
Correct. You would have to write a hook\_form\_alter() on that web form to populate a hidden field with the tracking information you want to add.

Here is an example of a form alter I did on a webform to populate data in a hidden field based on a query string from the URL

```
/**
 * Implement hook_form_alter().
 */
function ss_customization_module_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'webform_client_form_103') {
    $nid = 0;
    if (isset($_GET['cp']) && !empty($_GET['cp'])) {
      $ss_custom_cp_id = check_plain($_GET['cp']);
      $results = db_query('SELECT node.nid AS nid, \'node\' AS field_data_field_email_node_entity_type, \'node\' AS field_data_field_content_certpro_ltext_biog_node_entity_type
      FROM
      {node} node
      LEFT JOIN {field_data_field_int_sort} field_data_field_int_sort ON node.nid = field_data_field_int_sort.entity_id AND (field_data_field_int_sort.entity_type = \'node\' AND field_data_field_int_sort.deleted = \'0\')
      WHERE (( (node.status = \'1\') AND (node.type IN  (\'certified_professional\')) AND (field_data_field_int_sort.field_int_sort_value = :ssid) ))
      LIMIT 1 OFFSET 0', array(':ssid' => $ss_custom_cp_id));
      while ($row = $results->fetchAll(PDO::FETCH_ASSOC)) {
        $nid = $row[0]['nid'];
      }
      if ($ss_custom_cp_node = node_load($nid)) {
        //kpr($ss_custom_cp_node); //Use this if you need to see what is in the CP node for data
        $email = check_plain($ss_custom_cp_node->field_email[$ss_custom_cp_node->language]['0']['email']);
        $tphone = check_plain($ss_custom_cp_node->field_content_certpro_tphone[$ss_custom_cp_node->language]['0']['safe_value']);
        $full_name = check_plain($ss_custom_cp_node->title);
        $form['submitted']['cp_email_addr']['#default_value'] = $email;
        $form['submitted']['cp_full_name']['#default_value'] = $full_name;
        $form['submitted']['cp_telephone']['#default_value'] = $tphone;
      }
    }
  }
}

```

What happens here is I take data from the query string of the URL (?cp=XXX) and pull data out of the database based on that number and add it to hidden fields ('cp\_email\_addr', 'cp\_full\_name', 'cp\_telephone' are all hidden fields in the form that the user does not see). When submitted all of this data is then available via the Webform tools.

You could also do this based on the path that you are loading for the webform, it does not have to be a query string. You could use the $arg array to compare the path and make your own custom submission ID's based off of that path. You could then flow that data into a hidden field on the form.

Very important. Note how I clean the input from the query string using check\_plain. This prevents XSS attacks because I know this data should be just text with no markup contained in it. I also use check\_plain again to clean input going into the form.
> 0 votes

---
Tags: hooks, webforms
---


# Question
Title: Use another language than "default" as standard
We're currently building a rather large website that will be release in swedish initially, but other languages later on. For this reason we've built everything in english and then translated everything to swedish. For the release, only swedish should be accessible. This is where the problem begins.

-We don't want / can't use language URL prefixes for different reasons (PURL clashes, uglyness, won't need once the site is available in more than one language)

-We can't use Swedish as default language because that will break all of the translations (string translations will then consider swedish as the original language). Since everything from fields, labels, content types, help text etc. are in english originally this is not an option.

-We can use browser detection, but that isn't really fool-proof and doesn't cover all cases. A lot of users in sweden use english as browser language.

-We could use IP location, as an addition to the above, but it's not fool proof either.

What we would really need is to use Swedish as the default language but somehow use english as the language of origin. Is this possible somehow?

# Answer
> 6 votes
Drupal 7?

The language negotiation is extendable, you just need to implement hook\_language\_negotiation\_info(). In there, you can do whatever you want, like always default to swedish for now. It also looks like you can limit to what languages you can switch to, I am not sure how that exactly works, though.

Not sure what to do once you add more languages, but you could for example call other negotiation callbacks in yours and fallback to swedish if it not one of the languages you want displayed.

# Answer
> 2 votes
This question is old, but I think that this answer could be still useful to someone. A module with this functionality now esists, you can find it here: https://drupal.org/project/fallback\_language\_negotation

I'm a developer, but I don't know enough Drupal to write modules and implement hooks. I badly needed this functionality, but I couldn't do it by myself.

That module it's also very simple, so it's good for beginners to understand how to write modules.

# Answer
> 0 votes
Maybe you are missing some information (might not matter now, 3 years hence), but to me it seems straightforward: use URL detection, and configure the detector to use domains, then set your site' domain for Swedish, and a prefix for English. That way, it will always default to Swedish because it matches your domain, and never to English, because it doesn't care about prefixes (you are, however forced to enter either prefix or domain in the language config).

An alternative might be to alter the URL language negotiator in core, this can be done via hook\_language\_negotiation\_info\_alter(). There seems to be very little documentation on this, but I've used it with success to implement some similar logic in a custom module.

---
Tags: i18n-l10n
---


# Question
Title: Alias not working for a non default language
When I create a node in a non default language, I set an alias. After the node is saved, however, all internal links (e.g. menus) do not use the alias; they all use the node/\[nid\] link type, and when I navigate to the alias it returns the "page not found" error.

Aliases work fine for the nodes using the default language, and for language neutral nodes.

I enabled the Locale and the Content translation modules.

# Answer
> 4 votes
By default url alias created manually or by Pathauto works only for the language of the node.

But you could make it work for all languages ina few simple steps:

* go to the page "admin/config/search/path",
* find required url alias and click "edit"
* select "All languages" in "Language" field and save

That's all, now this url alias will be active despite of what language has the user.

If manual change is not an option, you can:

* try to use "neutral\_paths" module (though it is in a sandbox mode)
* create simple module that wil do the same

Module forces url aliases to be language neutral, it works both for pathtauto and manual path aliases:

```
<?php
/**
 * Implements hook_path_insert().
 */
function MYMODULE_path_insert($path) {
    _MYMODULE_path_language_fix($path['pid']);
}
/**
 * Implements hook_path_update().
 */
function MYMODULE_path_update($path) {
    _MYMODULE_path_language_fix($path['pid']);
}
/**
 * Fixing a given path id.
 */
function _MYMODULE_path_language_fix($pid) {
    db_update('url_alias')
        ->fields(array('language' => LANGUAGE_NONE))
        ->condition('pid', $pid)
        ->execute();
}
?>

```

If you already have lot of existing content with not correct languhae for aliases, then run this code

```
<?php
function _neutral_paths_set_all_to_neutral($type) {
    $num_updated = db_update('url_alias')
        ->fields(array('language' => LANGUAGE_NONE))
        ->condition('language', LANGUAGE_NONE, '!=')
        ->condition('source', $type . '/%', 'LIKE')
        ->execute();
    if ($num_updated > 0) {
        drupal_set_message(t('@num aliases were reset to language neutral', array('@num' => $num_updated)));
    }
    else {
        drupal_set_message(t('No aliases were updated.') . $type);
    }
}
_neutral_paths_set_all_to_neutral('node');
?>

```

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


# Question
Title: I cannot specify sender's address when sending email through rules
Drupal ignores the "senders email" parameter when I send emails via rules.
I cannot even specify the "sender's email field" directly, putting directly the address like "sender@drupalsite.com" - the mail gets always sent from the default website address. (My goal is to get the email from a taxonomy term proper to a commerce billing - which I can access properly).
I tried both regular and HTML mail.
What can be the source of the problem?

# Answer
Jeeeez, it was just the configuration of the mail server on my local development machine... Everything worked as it should on the drupal side.
> 0 votes

---
Tags: rules, emails
---


title: Use feature as module?

text:
# Question
Title: Use feature as module?
Does anyone have experience with using a feature as a module? The usage I am talking about is strictly placing hooks inside the .module file. Can that trigger any sort of bug?

# Answer
> 4 votes
Of course, you can use a feature like a "normal" module.

Feature use .module file only for include a file, so after this include you could add your custom code. And obviously you can add more files, directories, etc.

It's a great way to avoid to create too many modules.

# Answer
> 1 votes
I've used a feature as a "normal" module without any problems. I've found it very convenient.

---
Tags: hooks, features
---


# Question
Title: Role to edit user profiels but not administer accounts
As far as i can tell drupal allows me to make a user role able to edit other user profiles(edit the profile fields) only if the role they have includes "Administer users."

When this is set a role can see the edit tab on all profile pages and make edits to other user profiles. Good we want that. But this also allows the user to administer accounts as well(add/remove accounts). Bad, we want that restricted so that only account admins can add/remove accounts. We want a role for a "lower tier" user to be able to edit profile fields as needed, but not administer accounts.

I use the Fields Permissions module to control access to fields. Works great, allows that different user roles can or can not see and/or edit different fields for other users. This lets us to have internal use only fields on our user profiles that only appropriate staff can access. But this is not controlling if a user has the ability to edit user profiles or not. Just what specific fields in user profiles can be seen or edited IF the user already has the rights to edit other user profiles first. That is still controlled with the "Administer users" setting, which seems to only give the rights for account administration as well as profile editing all in one.

Can we separate the rights to edit user profiles from administering user accounts, allowing for a role that can edit user profiles but not administer accounts?

Thanks for any help on this one.

# Answer
> 1 votes
This looks like it should do the trick :

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

> This module allows site builders to set up fine-grained permissions for allowing "sub-admin" users to edit and delete other users — more specific than Drupal Core's all-or-nothing 'administer users' permission. It also provides and enforces a 'create users' permission.

The normal *administer users* permission is split out into *create*, **edit** and *cancel* users per role.

---
Tags: entities, users
---


# Question
Title: How can I format the content in horizontal tabular form?
I'm using Drupal 7 and below you can see an example of what I want to achieve. Basically I have a specific content type that I want to display as seen in the image.

On the left I want to list some fields of my content type and on the right some content elements. Basically it's a horizontal table. Also I would like to be able to format each row individually.

I already know that I could do it with the Panels module by creating a variant in the Node Page with a selection rule for my content type and by then adding the nodes manually to a Panel Page.

But that doesn't feel like the most elegant solution. Isn't there a possibility to arrange the content in a view as I want to do it? What approaches would you suggest me?

# Answer
> 1 votes
Do you really care to have tables in the semantic meaning of it? I mean, you can just print your fields to divs and use float: left for the 3 content elements and for the labels print it manually on a div on the header.

Might not be the most elegant solution but will work and be easier than making it with panels...

The best way to do it would be to print First Field: Label | Line 1 | Line 2 | Line 3 Second Field: Label | Line 1 | Line 2 | Line 3 But that's not how Views works.

You could also retrieve all the information in a custom module and then manage it however you want. But then, you wouldn't need to use Views module...

# Answer
> 1 votes
If these nodes are also going to be viewed as full pages else where then you could use a the teaser view mode, a simple view and some CSS.

* Create a new view of display format teaser.
* Filter to return these nodes by their nid's.
* Use CSS to `display:inline-block` on the `.node` or `<article>`
* Configure the fields you want in the teaser view mode setting in manage display for this node type.

---
Tags: views, panels
---