# Question
Title: User account and Commerce addressfield bug
I found out that when I enter a "Full name" in the commerce shipping and billing address information, the \[user:name\] value will be changed to the "Full name" entered.

As you can see the user name in the first picture is different from the value of the \[user:name\] token.

However, when I enter a different "Full name" for subsequent orders, or change the username it doesn't modify the value of the \[user:name\] token.

Is there a way to stop the commerce shipping and billing to modify the \[user:name\] token or to change the value of the token manually?

Thank you for your help.

# Answer
> 0 votes
I've got the answer!

Go to profiles\commerce\_kickstart\modules\commerce\_kickstart\commerce\_kickstart\_user and comment out

```
function commerce_kickstart_user_username_alter(&$name, $account) {
  if (module_exists('commerce_addressbook')) {
    $billing_profile_id = commerce_addressbook_get_default_profile_id($account->uid, 'billing');
    if ($billing_profile_id) {
      $billing_profile = commerce_customer_profile_load($billing_profile_id);
      $name = $billing_profile->commerce_customer_address[LANGUAGE_NONE][0]['name_line'];
    }
  }
}

```

and everything goes back to normal!

# Answer
> 0 votes
I modified the user.tokens.inc file by changing $user\['name'\] to $user\['login-name'\] and commented out a line and this seemed to fix the problem of the tokens, as the token isn't modified by the username value in $account.

```
case 'login-name':
//$name = format_username($account);
$replacements[$original] = $sanitize ? check_plain($name) : $name;
break;

```

However, as you can see, I still haven't solved the problem of the the username field in $account is being modified by commerce shipping and billing. The result is the same whether I set the field to "Full name" or "First name" and "Last name". Inspecting the addressfield module, I can't find the part where it modifies the $account username.

---
Tags: tokens, commerce
---


# Question
Title: How to build drupal-twitter bot like the one on drupal.org
I'm really impressed by this bot: drupal8changes which gets changes from http://drupal.org/list-changes/drupal and posts it on to Twitter. I think it might be something like, when a new node is created of D8Changes content-type, then post it on to twitter. Isn't it awesome? I want to know how that could be implemented? Not just limited to twitter, but for Facebook, Google+ etc.

# Answer
> 2 votes
You can achieve this by using Twitter & Oauth module. You will have to create a twitter app & use Consumer key, Consumer secret to connect to your twitter account.

You will have to choose a content type for tweet & yeah don't forget to enabled import option on twitter account.

---
Tags: 7
---


# Question
Title: Filter nodes by date ( excluding year ) show upcoming/previous based on today
i have content type called Race. This races happens every year so i want to have a page that show latest 5 upcoming races and past 5 races.

Is there a way that i can disable year in date api when adding a new race so that only month and day are taken for reference?

And not really sure how to setup views to filter this?

# Answer
> 1 votes
I am not sure how you are displaying your date, but if it is 'post date' then in Views on the lower left column choose 'Sort Criteria' and search for date. I will have multiple granularity and you can choose to filter by month.

If you have a text field where you manually type the date associated with the content, then you can use the 'Sort Criteria' and sort by that specific field in 'ascending' or 'descending' order.

If you want to keep the 5 newest and the older separate, you might need to create two different blocks and display them next to each other.

Finally you can do a 'Filter Criteria' by date and select a range of' 'Is greater than or equal to' a specific time period. For example from today to 5 months ago will only display content created within that month period, and anything beyond 5 months will not be displayed.

---
Tags: views, datetime
---


# Question
Title: Is there any Menu Module to show thumb image, content tile when mouse over on menu item
I want to create a main menu bar for my drupal blog, like shown in image

>

Means, when i mouse over on the menu item, it should show, node thumb image, content title.

is there any modules available to do this. I tried in google to find like this modules, no luck. Please any one give suggestion how to do this.

# Answer
> 1 votes
This can be done using Views Module and MaxiMenu.

Edit: you might also need the Menu Views Module and potentially Nice Menus Module to achieve the perfect style you want.

I have not tested this but a Coworker built a client's dropdown menu with images this way, So i know it is possible. I just personally haven't done it =-)

I hope this gets you close!

# Answer
> 0 votes
Consider to use the Menu Minipanels module:

> A system for building "megamenu" -style (explanation) dropdown menus using Mini Panels, which provides tremendous flexibility in what can be displayed.
> ...
> There are two main reasons why minipanels are used:
>
> 1. Usability: once an initial learning curve is gotten past the module becomes very easy to use.
> 2. Flexibility: there is a tremendous amount of configuration available via minipanels and almost anything can be added to one - views, blocks, nodes, other menus, and even raw PHP code if the PHP Filter is enabled. Further, there are multiple layouts available and more can be easily built. Further, each minipanel can be customized differently, as can be seen from some of the example sites below.

---
Tags: routes
---


# Question
Title: How to use Views Isotope in Commerce Kickstart?
I want to do the same as what is shown in the video about the Views Isotope module, but within Commerce Kickstart (CK).

Gareth Hall, shows us how to drupal 7. I've done the same for CK, but I can not get that purpose, that is, not filtered. I click on the tags and does not give any effect or filter.

I thought it might not be compatible with CK or perhaps is making a conflict with some jQuery or something out there.

Please any suggestions?

**Update**:

* I installed the module View Isotope
* I activated "Isotope Example" and "Views Isotope" modules
* I created two views (and filter for content) as explained in the video.
* I have also used the version "Isotope Example", for that I have added content in "tags" and "articles".

And still the same. does not filter anything.

Now, also I have since only a new version of Drupal 7 (without CK). For this I needed to install/activate other modules, such as: Features (enabled), Image (enabled), File (enabled), Field (enabled), Field SQL storage (enabled), Taxonomy (enabled), Options (enabled), Views (enabled ), Chaos tools (enabled), Views Isotope (enabled), jQuery Update (enabled), Libraries (on)

And still the drawback.

I am convinced that something is missing but I do not know why.

Any help?

# Answer
Views Isotope works fine with Drupal commerce. (I'm using it now =-)

Make sure you have the isotope .js file in the correct location within libraries: sites/all/libraries/jquery.isotope/jquery.isotope.min.js

also when creating the View make sure (as the above video briefly covers) that the 'Taxonomy Term: Name' in the Views Isotope filter block has the 'link this field to its taxonomy page' option turned off (5:25 time in the YouTube tutorial you posted). If it is on the links wont work.

And of course as video stresses in the main Isotope View, make sure the last field in the list is the taxonomy field that is linked to the header block. IF you need to display that taxonomy also create two fields in the view and make sure one of them is last with the correct CSS overwrite styling as the video tutorial states.

Oh and lastly, make sure your Views' Ajax option in the advanced tab is turned off. It conflicts with Isotope and wont work.
> 2 votes

# Answer
Try to solve some :) Adding to "sites / all / libraries", A Script. Isotope js (I found out there ...) and leave it like this: "besiege / all / libraries / jquery.isotope / jquery.isotope.min.js" This is perfect just for drupal 7 version. (the one I installed)

But I still have problems with Kickstart commerce for more than try, That not filter me anything ... I now search for, how to install new libraries for CK?. But I do not find something positive.

I will continue investigating.
> 0 votes

---
Tags: views, commerce
---


# Question
Title: Get node author's real name in views or convert username
I currently have a content view that displays a list of nodes for a blog. I would like to display the node authors real name (John Smith) at the top, but currently I am only able to display their username (john\_smith) by creating a relationship to Content: Author and then adding User: Name.

How can I grab some fields from the node authors user profile?

The fields I need are $field\_first\_name, $field\_last\_name, $field\_position.

FYI: I realize that there are modules that might be able to fix this problem such as Real Name, but I am hoping to do this without it.

# Answer
> 2 votes
If you don't use any special modules and you have simply added fields to the user acount (on /admin/config/people/accounts/fields then you should be able to add those fields in the Views UI. Just like you do it with all other fields, except that you use the author relationship that you have already created.

---
Tags: 7, views, theming
---


# Question
Title: How do I dynamically change the $GLOBAL['base_path'] variable?
Example scenario:

All authenticated users should see `/members/` at the beginning of each URL path, and all anonymous users should see `/guests/` at the beginning of each URL path.

So if an anonymous user were to visit `example.com/node` they'd be redirected to `example.com/guests/node`, and once they logged in they'd be redirected to `example.com/members/node`.

I'm sure this is not impossible because using a multilingual site allows for paths to be negotiated by prefix only, but I can't seem to figure out how to go about it.

Here are some of the things I've tried (some of which have been out of desparation):

Example 1:

```
function mymodule_init() {
  if (user_is_logged_in()) {
    $GLOBALS['base_path'] = '/members/';
  }
  else {
    $GLOBALS['base_path'] = '/guests/';
  }
}

```

Example 2:

```
function mymodule_init() {
  $prefix_default = 'guests/';
  if (user_is_logged_in()) {
    $prefix_default = 'members/';
  }
  $get_q = isset($_GET['q']) ? $prefix_default . $_GET['q'] : $prefix_default;
  $args = explode('/', $get_q);
  $prefix = array_shift($args);
  $args_new = array();
  if (!empty($args)) {
    foreach ($args as $arg) {
      if ($arg != $prefix) {
        $args_new[] = $arg;
      }
    }
  }
  $GLOBALS['base_path'] = '/' . $prefix_default;
  $_GET['q'] = implode('/', $args_new);
}

```

Example 3:

```
function custom_url_rewrite_inbound(&$result, $path, $path_language) {
  global $user;
  if (!$user->uid || !isset($user->status) || empty($user->status)) {
    // Allow access to front page only, or guests/* paths, or even user/* paths
    if (($path != 'node') && ((!preg_match('|^guests([/]?.*)|', $path)) && (!preg_match('|^user([/]?.*)|', $path)))) {
      $result = 'user';
    }
  }
}

```

Any input would be most appreciated. Thanks!

# Answer
> 2 votes
I don't think base path is what you need here. Once the user's page is loading it is too late to change their URL, unless you redirect them them to the /members or /guests url with drupal\_goto().

Base path is also not what you need because base path is telling drupal where your files are in the web root, so changing the $base\_path global is likely just going to break your site unless your files are in /var/www/yoursite/members and /var/www/yoursite/guests (I'm assuming your web server setup here for the paths).

The main thing here is that you need to make sure your users are actually hitting the paths www.example.com/members/path and www.example.com/guests/path and then you have to make drupal handle those paths appropriately or you will just get page not found errors.

This is how the drupal multilingual (locale) system works. It rewrites urls that appear on the page to point to www.example.com/langcode/path so the user is actually navigating to those pages. If there is no langcode part drupal just assumes the default language.

In drupal 6 this is ingrained into the url() function, which calls language\_url\_rewrite(). In drupal 7 the local module has an implementation of hook\_url\_outbound\_ater() (local\_url\_outbound\_alter()).

You could replicate this by implementing custom\_url\_rewrite\_outbound() (read the docs for that, it is not a normal hook). Or use the url alter module and implement its hook\_url\_outbound\_alter() hook.

That's not all though, because users are going to paths like www.example.com/langcode/path those paths have to be valid drupal menu system paths or else drupal won't know that functions to call for that given page.

For the multilingual system drupal core handles this in the bootstrap phase, before any menu handling has happened.

See \_drupal\_bootstrap(), which for the DRUPAL\_BOOTSTRAP\_LANGUAGE phase calls drupal\_init\_language(), which in turn calls language\_initialize().

language\_initialize() has code in it that detects the language from the url and then removes that language portion of the url from the $\_GET\['q'\] variable so everything from then on just sees www.example.com/path and the page loads as normal.

If you were to use this same approach for your path then the system would try to load the menu item for www.example.com/members/path and it would likely not exist and you would get page not found errors.

However you could the also add an implementation of hook\_boot() that does something similar to language\_initialize() and save a global variable of your user type (member or guest) and then removes that part of the url from $\_GET\['q'\] before the menu handler runs.

From then the $\_GET\['q'\] variable doesn't have your user type anymore but you will be able to use the user type global you created from your other custom code if you need to.

This system relies on there being a default user type for when guests or members are not present (which can easily happen, for example the user can just type in the url manually instead of clicking one of your altered links).

So your system would have to assume the user type or work it out in some other way (easy because you have user\_is\_logged\_in() or global $user to determine the user type). It just means in these cases the user doesn't get to see that url scheme you want with the user type in it.

As you can see this is a complex requirement and the solution doesn't have 100% coverage so i it was me I would reconsider doing this at all.

Alternatively you may be able to just have a members area, full of pages like views and nodes that do really have urls like /members/something, but not change the url for the whole site (although I'm just making assumptions on your requirements now).

---
Tags: 6, uri
---


# Question
Title: How can I validate a fieldset or any other kind of group in drupal Form API?
I want to create a survey witch contains a couple of questions for every group. For example: I have a group about dogs with 5 difference question (every question has 3 options) and I have a group about cats with difference quetions. Now I want to validate by group. for example making it require to answer at lease two quetions on each group. How Can I do it?

# Answer
You could do it with custom code by implementing hook\_form\_alter() and then adding a custom validation function and checking for the relevant field values (I don't know anything about your form so I'm not going to write any code).

Or, you can use the field validation module, which allows you to configure via the drupal UI, extra field validation requirements.

It is a very flexible module and a couple of its validation options are:

* Require some of several fields (in the field validation extras sub-module).
* Require at least one of several fields

There are many more options so it would be worth playing with it to see if you can achieve what you want.
> 2 votes

---
Tags: forms
---


title: How to get monthly node view count?

text:
# Question
Title: How to get monthly node view count?
I have a site where we want to send out information to "owners" of certain pages to tell the users how many page views the page got in the last month.

I think this could done 2 ways:

1. A module that keeps the a monthly count of page views. I have looked at Statistics Counter module but it seems to simple. It resets as soon as the new month starts. So if I wanted to send information for the last month it would lost as soons as the next month started. Any other modules that keep this information for past months? Or maybe I should just write a very simple module that would write the old month count to a history table before it gets reset.
2. Let Google analytics handle this. Either through custom code or a module query Google analytics with path, and date range. Is there module does this already?

Other ideas on how to do this?

Thanks for any help on this

# Answer
I haven't tried this yet, but https://drupal.org/project/google\_analytics\_sync might get you part of the way there.
> 1 votes

# Answer
Try this module https://drupal.org/project/nodeviewcount, it allows to count node views for each user and you can get statistics for different periods
> 0 votes

# Answer
I had to do something similar, but I just wrote a little code to talk to the Google Analytics API via the nice PHP wrapper provided by Google.

Then in a module, I made a little JSON callback that talked to the API, pulled the GA data for the page, and then massaged it a little so it would produce pretty charts on the front-end for the user.

Here's some sample code to get you started: https://gist.github.com/jmk1ng/9442895

Honestly, you're better off just writing something simple like this yourself. Whatever module you find to accomplish this is just going to either bloat your database with view tracking.
> 0 votes

---
Tags: nodes, google-analytics
---


# Question
Title: Is it safe to protect the images only with a watermark image style?
I'm building a website for selling stock photography and I'm looking for a way to protect the images. Here's what I'm using right now:

* Imagecache Actions to watermark photos
* Private file system for uploading all images
* The images are displayed on the front only through image styles with watermarking.

Question: is this enough and are there any ways users could bypass this (e.g. by directly trying to access certain image style)?

Thanks!

# Answer
This is probably not as secure as you would like it to be. Basically if a user has access to view the image they can view any derivative image (image style), so long as they can work out the url to that derivative.

There is a module image style access that allows you to set up access rules per image style.

That should give you the extra protection you need.
> 3 votes

---
Tags: 7, commerce, media
---


# Question
Title: How to set alias url for image address in a content type?
I added an image field for a content type and its directory is `/content_type_image`. it works correctly but when I add a content to this content type the uploaded image url on the website is `www.mysite.com/sites/all/ ....` I mean it is clear where this image is in the server directory. Is there anyway to set an alias url for files and images in order to hide such urls?

# Answer
You could set your fields to use the private file system. For more information see Working with files in Drupal 7.

With the private file system, the path to files is of the form

www.example.com/system/files/path/to/file.png

The path /system/files is a drupal url, not an actual directory on your file system.

For your drupal file setting you set the path of the private file system to something like /sites/default/files/private so your images are on the server at sites/default/files/private/content\_type\_image

So the path to the image will be

www.example.com/system/files/content\_type\_image/path/to/file.png

then when a user hits that url the drupal callback for the system/files will check access control and then load the image from

/sites/default/files/private/content\_type\_image/path/to/file.png

Using the private file system also means if someone doesn't have access to the content the image is attached to then they cannot browse directly to that file if they can work out the path (and google can't index it) and it means that if you are using revisioning, users cannot see files attached to old revisions of your content, whcih they can with the public file system.

This is probably the best solution you'll get for stopping users from knowing the location of your files and also from accessing files they shouldn't be allowed to.
> 2 votes

---
Tags: files, uri, media
---


# Question
Title: Statistics module not effect with Services module
I created a Services Views, I added a **Statistics field**(total view) to the Views.

Then I try to use the browser to visit the node through RESTful api, like this url: `http://daxuebao.local:8083/api/node/61`

But, when I try to visit the Service Views, the Statistics field not effect, It still zero.

How to make Services support Statistics?

# Answer
Statistics increments hits in `hook_exit` i.e:

`statistics_exit`

It's normally called as part of `drupal_exit` in `drupal_page_footer`

In any case, `statistics_exit` for the node counter actually checks

```
if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == NULL) {}

```

That won't be true on an api request URL.

You might need to implement

`hook_services_request_postprocess_alter`

check the node request and make the stats increment call yourself.

Something like:

```
/**
 * Alter results of the services call.
 *
 * @param $controller
 *   Controller definition
 * @param array $args
 *   Arguments passed to services callback
 * @param array $result
 *   Array of results that can be altered
 *
 * @see services_controller_execute()
 * @see services.runtime.inc
 */
function MODULE_services_request_postprocess_alter($controller, $args, &$result) {
  // Increment hit count for node view api requests.
  $nid = $result->nid; // May need to confirm this is the node id.
  if($controller['callback'] == '_node_resource_retrieve'){
    // See statistics_exit()
    if (variable_get('statistics_count_content_views', 0)) {
      // A node has been requested, so update the node's counters.
      db_merge('node_counter')->key(array('nid' => $nid))->fields(array(
        'daycount' => 1,
        'totalcount' => 1,
        'timestamp' => REQUEST_TIME,
      ))->expression('daycount', 'daycount + 1')->expression('totalcount', 'totalcount + 1')->execute();
    }
  }
}

```
> 2 votes

---
Tags: services, nodes
---


# Question
Title: global static variable to be accessed in comment.tpl.php, node.tpl.php and in page.tpl.php
I wanted to show some ads inside the content (node, comments) and body. I decided to add them using the template by adding some lines to comment.tpl.php, node.tpl.php and page.tpl.php

for example in comment.tpl.php I have:

```
print render($content);
if($id%3 == 1){
  echo "<iframe width='720' height='80' src='#####'></iframe>";
}

```

**I think this is a good way of adding ads**

Now that the ad code is repeated in these 3 files, I want to use a Global static variable so that the ad code can be placed in one place and can be access from these 3 tpl.php files

Can somebody please point me how to do it? Or an alternative Method of achieving it?

# Answer
> 2 votes
You can use preprocess functions to add template variables in Drupal.

For example, you could use a generic preprocess function like

`hook_preprocess`

And add your variable there.

It will then be available in all the other template files.

---
Tags: theming, comments
---


# Question
Title: How do I use hook_form_alter() to add CSS classes to a custom input field in user_register_form?
I want to add a CSS class to the input element of a custom field in my user\_register\_form.

This is the field markup.

```
<div class="field-type-text field-name-field-personal-best field-widget-text-textfield form-wrapper"
 id="edit-field-personal-best">
<div id="field-personal-best-add-more-wrapper">
    <div class="form-item form-type-textfield form-item-field-personal-best-und-0-value">
        <label for="edit-field-personal-best-und-0-value">Personal Best </label>
        <input class="text-full form-text" id="edit-field-personal-best-und-0-value"
               name="field_personal_best[und][0][value]" value="" size="60" maxlength="255" type="text">
    </div>
</div>

```

This is my implementation of `hook_form_alter()`, which doesn't work. Changing the submit button works, but adding a CSS class to that input element doesn't.

```
function em_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'user_register_form') {
    $form['actions']['submit']['#value'] = t('GO!'); // Change the text on the submit button
    $form['edit-field-personal-best']['#attributes']['class'][] = 'timepicker hasDatepicker';
}}

```

How can I achieve this?

# Answer
Looks like you're trying to use the HTML ID of the element you're interested in as the identifier in PHP - not quite how it works.

For a field API field, that will look more like:

```
$form['field_personal_best'][LANGUAGE_NONE][0]['value']['#attributes']['class'][] = 'foo';

```

Your mileage will probably vary there, have a read of Why is hook\_form\_alter() so messy? for some relevant information, and make sure you have the Devel module installed to help with debugging (`dpm($form)` will tell you pretty much everything you need to know).
> 3 votes

---
Tags: forms
---


# Question
Title: How to use ip to visit AcquiaDevDesktop's site?
I want to visit drupal site through 'Local area network'.

For example, my server ip address is `192.168.0.1`, My drupal site is `http://daxuebao.local:8083/`

I try to use `192.168.0.1:8083/daxuebao.local`, `192.168.0.1:8083/daxuebao`. But can not be visited.

# Answer
Ok, i get it. I installed Acquia Dev Desktop and tried it out. This is what I think is what has happened and what the problem is:

You installed Acquia Dev Desktop and entered parameters about the default site that comes with Acquia (this is required during installation - so this must have happened). This site is what you reach when you from another computer enter 192.168.0.1

You created the daxuebao site via Acquia Dev Desktop application and entered "Sitename" as daxueabao and you did not enter a "URL Path" so the result is that "Site Path" then becomes "daxuebao.localhost:8083". This means that the Apache software in Acquia Dev Desktop will examine every request it receives and determine if it should go to (a) the default site or (b) the daxuebao site.

*The problem* is that the daxuebao site is local and that your client computers on the LAN does not know where "daxuebao.localhost:8083" points... the have no knowledge of what IP number that corresponds to and if you enter just 192.168.0.1 the Apache software will determine that to be a request for the default site. The only site that is not local is the default site.

There are basically 3 different ways of solving this problem (which one depends on your need):

Solution 1: add a DNS record to the local DNS if you have one (I don't think you do) or

Solution 2: add a DNS record to the hosts file of all of your client computers (see more at www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/ ) or

Solution 3: move site duxuebao to the default site so that Apache servers that codebase and data instead. *Make sure you backup files and database before you do it*. I can tell you exactly how to do it if you tell me what operating system you are using.

---

Added in response to comments: I would do it like this:

Oh, by the way. Acquia Dev Desktop works out of the box on port 8082 and not 8083, just to be sure here, you're not working with multiple installations of Acquia Dev Desktop? If not then:

1 Backup the daxuebao site:

1.1 Open the Acquia Dev Desktop control panel

1.2 Click the Settings button

1.3 Click the Sites tab

1.4 Highlight the daxuebao site

1.5 Click Export button, select "to file"-option to download a copy to your Desktop.

1.6 Backup done (files and data)

2 Backup the default site:

Note: Do this just to be sure.

2.1 Open the Acquia Dev Desktop control panel

2.2 Click the Settings button

2.3 Click the Sites tab

2.4 Highlight the localhost site

2.5 Click Export button, select "to file"-option to download the export to somewhere.

3 Replace the default site FILES with the daxuebao site FILES:

We cannot use the Acquia Dev Desktop import feature here unfortunately because the default site is reserverd/protected. We need to do the copying manually of files (step 3) and data (step 4):

3.1 Stop servers in Acquia Dev Desktop from it's control panel

3.2 Delete all files in /Users/YOUR-COMPUTER-USER-NAME/Sites/acquia-drupal/sites/default

3.3 Copy all files in /Users/YOUR-COMPUTER-USER-NAME/Sites/acquia-drupal/sites/daxuebao.localhost to /Users/YOUR-COMPUTER-USER-NAME/Sites/acquia-drupal/sites/default

3.4 Start servers in Acquia Dev Desktop from it's control panel

3.5 File copy complete.

4 Replace the default site DATA with the daxuebao site DATA:

Both sites default site and daxuebao are now using the same database. That's not good because if you delete the daxuebao site then the data will disappear. So we need to copy the data from database daxuebao to the acquia default database.

4.1 Extract the files downloaded int step 1.5 on the desktop ( it will extract to /Users/YOUR-COMPUTER-USER-NAME/Desktop/daxuebao.localhost ). This folder contains data and files.

4.2 Go to the In the Acquia Dev Desktop controlpanel click button "Manage my database" and a browserwindows with phpMyAdmin will appear.

4.3 Select the database acquia\_drupal in left part of the window. In the right part of the window all tables in the database will appear.

4.4 Go to the bottom of the page in the right part of the window and select "check all" and

4.5 delete the tables by using the dropdown to the immediate right labeled "With selected:" and select "Drop".

4.6 Confirm deletion.

4.7 Now, we're going to import the data from the daxuebao site

4.8 Click on the tab "Import" at the top of the right hand window.

4.9 Click button "Choose file".

4.10 Navigate and select the datafile daxuebao.sql thats in the /Users/YOUR-COMPUTER-USER-NAME/Desktop/daxuebao.localhost directory.

4.11 Click button "Go"

4.12 Data copy complete.

5 Change settings-file for default site to look at correct database table

5.1 Open settings.php in /Users/YOUR-COMPUTER-USER-NAME/Sites/acquia-drupal/sites/default directory

5.2 Change `$base_url = 'http://daxuebao.localhost:8082';` to `$base_url = 'http://localhost:8082';`

5.3 Change `$db_url = 'mysqli://drupaluser@127.0.0.1:33066/daxuebao';` to `$db_url = 'mysqli://drupaluser@127.0.0.1:33066/acquia_drupal';`

5.4 Change 'database' =\> 'daxuebao', to 'database' =\> 'acquia\_drupal',

5.5 Verify by going to the site from your local computer

5.6 Verify by going to 192.168.0.1:8083 from another computer within the LAN

5.7 If all looks fine then your default site in Acquia Dev Desktop is now using it's own database "acquia\_drupal". You can now safeley delete the daxuebao site from your Acquia Dev Desktop controlpanel.

BR / Fredrik
> 1 votes

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


# Question
Title: drupal commerce separate shipping for different products
We have a drupalcommerce website through which we sale

* iptv box
* qwerty key board

on adding first product it adds 15 dollars( base rate ) + 5 dollars per item in cart, so if we have 1 item in cart the shipping is 20 dollar but if we have 2 products the shipping will be 25 dollars and so on.

problem is, we want to setup separate shipping rate for qwerty key board if there is only a qwerty key board alone in cart the shipping must be 5 dollars.

I hope this can be done through shipping rules

# Answer
You can add a shipping service dedicated for for qwerty key board and similar items and a shipping calculation that checks for a certain product in the cart. Use: Event: Calculating a shipping rate Condition: order contain a particular product. Action:Add a rate for a shipping service to an order and select the shipping service that is dedicated for qwerty key board and similar items.

It may be easier for you to clone one of the existing shipping rate calculation and edit as needed.
> 1 votes

# Answer
This video shows how to set up seperate shipping costs per line item http://www.youtube.com/watch?v=g3zQ3OMxUdQ&feature=youtu.be
> 0 votes

---
Tags: commerce
---


# Question
Title: Using theme hook suggestions for webform confirmation page
I've been trying for the last couple of hours and failing to use theme\_hook\_suggestions for custom webform confirmation templates. I want all webforms on a specific content type to use a particular confirmation page template.

So I've got the following in webform\_confirmation.preprocess.inc (I'm using Omega4 which puts preprocess functions into include files):

```
function foeomega_preprocess_webform_confirmation(&$vars) {

  $vars['theme_hook_suggestions'][] = 'webform_confirmation__' . $vars['node']->type;
  ...
}

```

Then I have 2 template files:

* webform-confirmation.tpl.php = The generic one I want to override
* webform-confirmation--myspecialnode.tpl.php = The new one I want to use instead

No matter how many times I 'drush cc all'/'drush cc theme-register' the suggestion template is never picked up :(

However, I did get the suggestion to work if I commented out the following in webform.module file:

```
function webform_theme() {

...

  'webform_form' => array(
  'render element' => 'form',
  'template' => 'templates/webform-form',
  // I COMMENTED THIS OUT: 'pattern' => 'webform_form_[0-9]+',
),

...

}

```

Leading me to believe that pattern and suggestions are not compatible - however I can't find any information on this by Googling - can anyone confirm/deny?

Thinking that 'pattern' and 'theme\_hook\_suggestions' don't mix, I tried implementing the following in my template.php file:

```
function foeomega_theme_registry_alter(&$theme_registry) {
  if($theme_registry['webform_confirmation']['pattern']) {
    unset($theme_registry['webform_confirmation']['pattern']);
  }
}

```

This did seem to remove it from the registry, but alas, the generic template file was still being used (after make 'drush cc ...' commands...).

Any ideas? I'd really like to have nice content-type specific confirmation pages?

Many thanks, Chris :)

# Answer
> 0 votes
I think your problem is due to the use of `$vars['theme_hook_suggestion']` (no trailing s) by webform. This value overrides any that you could put in the $vars\['theme\_hook\_suggestions'\] array

I was having the same problem, I just unset this `$vars['theme_hook_suggestion']` and my others suggestions in `$vars['theme_hook_suggestions']` have been used.

**Note: `$vars['theme_hook_suggestion']` is a string NOT an array**

# Answer
> 0 votes
Yeah the problem as you pointed out is the "pattern" in the webform\_theme() function. It won't allow you to make any theme\_hook\_suggestions.

There's some talk about it in this issue: https://drupal.org/node/1891220

But they seem to be very stubborn about even changing the pattern to a proper theme\_hook\_suggestions, let alone running both single and double underscores in the pattern to match the Drupal Way.

Luckily the site I'm working on isn't that big, so I copied the module to a custom modules folder and commented out the pattern line, and then created a `THEME_preprocess_webform_`... function to give me proper suggestions since I needed to work off a field in the node so that I didn't have to worry about future forms created by the site owner and needing to create one template per webform node.

---
Tags: 7, webforms
---


# Question
Title: Change jQuery version with hook_form_alter
How do I change the jQuery version used for a form with a specific form ID?

# Answer
> 2 votes
What you would like to achieve is loading another version of jQery in your form page. You need to understand the way hook system works. `hook_js_alter()` is defined as:

> "Perform necessary alterations to the JavaScript before it is presented on the page."

You can use the above hook to change jQuery version. `hook_form_alter()` is defined as:

> Perform alterations before a form is rendered.

So, first action is `hook_js_alter()` and second action is `hook_form_alter()`. You cannot change jQuery version with the second hook, but you can use the following code.

```
function mymodule_js_alter(&$javascript) {
  if ($_GET['q'] == "node/add/page") {
     // Swap out jQuery to use an updated version of the library.
  $javascript['misc/jquery.js']['data'] = drupal_get_path('module', 'jquery_update') . '/jquery.js';
  }
}

```

For more information on using newer versions of jQuery you can refer the Drupal.org article which explains how to add Newer versions selectively using various methods.

---
Tags: hooks, javascript, forms
---


# Question
Title: Chosen working on one select but not other selects
I'm facing a strange problem with the Chosen module. I've have 3 term-reference fields added to a content-type.

While editing & adding any nodes of this content-type, Chosen UI interface is applied & working with all 3 fields.

Now, I created a view and exposed the filters for all these three term-reference fields. In the view, Chosen UI interface is applied only to one field and not applied to the rest.

In the settings of chosen module (admin/config/user-interface/chosen) `Apply Chosen to the following elements` is set to `select`

These are the Drupal settings outputed by Drupal into javascript:

```
"chosen":{
  "selector":"select",
  "minimum_single":"20",
  "minimum_multiple":"20",
  "minimum_width":"300",
  "search_contains":true,
  "disable_search":false,
  "disable_search_threshold":"Never Apply",
  "placeholder_text_multiple":"Choose some options",
  "placeholder_text_single":"Choose an option",
  "no_results_text":"No results match",
  "multiple":{
     "field_tags_tid[]":true,
     "field_working_area_tid":false,
     "field_published_in_tid[]":true
  },
  "max_selected_options":{
     "field_tags_tid[]":false,
     "field_working_area_tid":false,
     "field_published_in_tid[]":false
  }
   }
}

```

What might be the problem? How can I rectify it?

**EDIT:** Here is something interesting. When I manually enter `jQuery('select').chosen()` into the browser console, then other two exposed filters (select elements) which were not rendered as Chosen UI elements are now rendered.

Any idea, about what might be wrong with it?

# Answer
> 6 votes
It looks like you have a 'Minimum number of options' setting of 20. I'm guessing the ones that don't display have less than 20 available options. Try setting this to 'always apply' on the Chosen settings form (admin/config/user-interface/chosen).

---
Tags: views, 7
---


# Question
Title: Wrapp every form item select with div, excluding label
im trying to wrap form item with

I had success with hook\_from\_alter and #prefix #suffix that is wrapping whole element with div like this:

I used this hook:

```
function em_form_alter(&$form, &$form_state, $form_id){
if ($form_id == 'user_register_form') {
    $form['field_gender'][LANGUAGE_NONE]['#prefix'] = '<div class="custom-select">';
    $form['field_gender'][LANGUAGE_NONE]['#sufix'] = '</div">';
}
}

```

And i got this.

```
<div class="custom-select">
<div class="form-item form-type-select form-item-field-gender-und">
    <label for="edit-field-gender-und">Gender</label>
    <select id="edit-field-gender-und" name="field_gender[und]" class="form-select required">
        <option value="_none">- Select a value -</option>
        <option value="1">Male</option>
        <option value="2">Female</option>
    </select>
</div>

```

But what i need to accomplish is this:

```
<div class="form-item form-type-select form-item-field-gender-und">
<label for="edit-field-gender-und">Gender</label>
<div class="custom-select">
    <select id="edit-field-gender-und" name="field_gender[und]" class="form-select required">
        <option value="_none">- Select a value -</option>
        <option value="1">Male</option>
        <option value="2">Female</option>
    </select>
</div>

```

And i would like to have this on every select on whole website, so maybe hook\_form\_alter isn\`t so good idea?

# Answer
This theme function should do what you need.

```
function mytheme_select($variables) {
  $element = $variables['element'];
  element_set_attributes($element, array('id', 'name', 'size'));
  _form_set_class($element, array('form-select'));

  return '<div class="custom-select"><select' . drupal_attributes($element['#attributes']) . '>' . form_select_options($element) . '</select></div>';
}

```
> 2 votes

---
Tags: forms
---


# Question
Title: listing page in breadcrumb of single item
how to make listing page created by views in the breadcrumb of single item of specific content type like so:

Home \>\> Activities: (created by views) Home \>\> Activities \>\> item page: (desired breadcrumb)

# Answer
(EDIT)
Drupal core will build breadcrumbs based on the menu structure. So if you manage to create a menu link for each of your activities, then Drupal core has you covered (see the answer by General Redneck).
If you don't want a new menu link per activity node, then you can use Path breadcrumbs or Crumbs, see below.
(/EDIT)

There are different modules that can help you with breadcrumbs, and I am sure more than one of them can help with this particular issue.

One of them is Crumbs. If you choose this, here are some steps for configuration (after enabling the module):

1. Go to `admin/structure/crumbs/entity-parent`, and specify the views page as the parent path for the node type of your choice.
2. On `admin/structure/menu`, edit the main menu (or another menu), create an item that links to the views page, and give it a title like "Activities". (\*)
3. On `admin/structure/crumbs`, make sure that the `menu.link_title.main-menu` and `menu.hierarchy.main-menu` are enabled. Or just enable `menu.*`.
(enabling means to move those lines up into the "Enabled" section with drag+drop)
4. To see what going on behind the scenes, you can visit `admin/structure/crumbs/debug`.

(\*) Creating the menu item is one option you have so that Crumbs can determine a title for the breadcrumb item that points to the activities view. There are other ways, but this is the most straightforward, and you probably want to create this menu link anyway.
> 1 votes

# Answer
Here's the Old School way of doing it.

I'm assuming that this view is showing a content type called Activities and the view will be at `/activities` and all the activities (the nodes) the view is showing need to be at `/activities/some-activity-title` `/activities/some-other-activity-title` etc...

Have a view named Activities. In the view settings set up Add this to your "Main Menu" menu in the root.

Install PathAuto and set up the template for activities to be `activities/[node:title]` over at admin/config/search/path/patterns

Then set up your content type to always add a menu item to the Main Menu -\> Activities section *I did this with articles*:

After that, you will need to edit your theme to show the current page or add a module to do so. See Show current page on Drupal 7 breadcrumb

When it's all said and done... you will have a breacrumb with what you wanted. This is it without the current theme or module fix.
> 1 votes

---
Tags: views, breadcrumbs
---


# Question
Title: flexslider keeps crashing when i try to change settings
I have used all the latest Flex Slider modules and library, I have created a View, with format of slideshow, the Slideshow Type is defaulting to Flexslider, and I'm using the default Optionset.

I have the title of the slide and the image being displayed. everything works as expected in terms of it being responsive, however, if I edit the View, then click Settings under Format, and then either click Save or Cancel, I get a few pages of rubbish displayed (see below) can anyone help?

> \[{"command":"settings","settings":{"basePath":"/rltc/","pathPrefix":"","ajaxPageState":{"theme":"seven","theme\_token":"l\_FB7jWDCmNamBi4J7kqnOrggLfAI3b3oWvjYgjabko"},"states":{"#edit-style-options-flexslider-views-slideshow":{"visible":{":input\[name=\u0022style\_options\[slideshow\_type\]\u0022\]":{"value":"flexslider\_views\_slideshow"}}},"#edit-style-options-views-slideshow-cycle-timeout":{"visible":{":input\[name=\u0022style\_options\[views\_slideshow\_cycle\]\[transition\_advanced\]\u0022\]":{"checked":true}}},"#edit-style-options-views-slideshow-cycle-speed":{"visible":{":input\[name=\u0022style\_options\[views\_slideshow\_cycle\]\[transition\_advanced\]\u0022\]":{"checked":true}}},"#edit-style-options-views-slideshow-cycle-delay":{"visible":{":input\[name=\u0022style\_options\[views\_slideshow\_cycle\]\[transition\_advanced\]\u0022\]":{"checked":true}}},"#edit-style-options-views-slideshow-cycle-sync":{"visible":{":input\[name=\u0022style\_options\[views\_slideshow\_cycle\]\[transition\_advanced\]\u0022\]":{"checked":true}}},"#edit-style-options-views-slideshow-cycle-random":{"visible":{":input\[name=\u0022style\_options\[views\_slideshow\_cycle\]\[transition\_advanced\]\u0022\]":{"checked":true}}},"#edit-style-options-views-slideshow-cycle-start-paused":{"visible":{":input\[name=\u0022style\_options\[views\_slideshow\_cycle\]\[action\_advanced\]\u0022\]":{"checked":true}}},"#edit-style-options-views-slideshow-cycle-remember-slide":{"visible":{":input\[name=\u0022style\_options\[views\_slideshow\_cycle\]\[action\_advanced\]\u0022\]":{"checked":true}}},"#edit-style-options-views-slideshow-cycle-remember-slide-days":{"visible":{":input\[name=\u0022style\_options\[views\_slideshow\_cycle\]\[action\_advanced\]\u0022\]":{"checked":true},":input\[name=\u0022style\_options\[views\_slideshow\_cycle\]\[remember\_slide\]\u0022\]":{"checked":true}}},"#edit-style-options-views-slideshow-cycle-pause-in-middle":{"visible":{":input\[name=\u0022style\_options\[views\_slideshow\_cycle\]\[transition\_advanced\]\u0022\]":{"checked":true}}},"#edit-style-options-views-slideshow-cycle-pause-when-hidden":{"visible":{":input\[name=\u0022style\_options\[views\_slideshow\_cycle\]\[action\_advanced\]\u0022\]":{"checked":true}}},"#edit-style-options-views-slideshow-cycle-pause-when-hidden-type":{"visible":{":input\[name=\u0022style\_options\[views\_slideshow\_cycle\]\[action\_advanced\]\u0022\]":{"checked":true},":input\[name=\u0022style\_options\[views\_slideshow\_cycle\]\[pause\_when\_hidden\]\u0022\]":{"checked":true}}},"#edit-style-options-views-slideshow-cycle-nowrap":{"visible":{":input\[name=\u0022style\_options\[views\_slideshow\_cycle\]\[action\_advanced\]\u0022\]":{"checked":true}}},"#edit-style-options-views-slideshow-cycle-fixed-height":{"vis

# Answer
> 0 votes
I have managed to resolve this, I managed to find it on google here : JQuery Update breaks Views UI .

Basically if you go into your jquery Update module, click configure, then change it from 1.8 to 1.7 it works

---
Tags: javascript
---


title: How alter page content before printing?

text:
# Question
Title: How alter page content before printing?
In my project, I am using "Printer-friendly pages" module in order to add print button to my project.

for example when a user is in "checkout/5/review" page, print module create a page with "print/checkout/5/review" address.

this process works fine but I want to alter the created page for printing "print/checkout/5/review"

I tested `hook_page_alter` but it doesn't work.

# Answer
The print friendly module uses the theme system to output your print friendly page. So you need to do this on theme layer using a preprocess function. Use `THEMNAME_preprocess_page` or `THEMENAME_preprocess_print` in your template.php. Check the `theme_hook_suggestions` for more options. From the module

```
 $variables['theme_hook_suggestions'] = array();
 187   $variables['theme_hook_suggestions'][] = "print__node__{$type}";
 188   $variables['theme_hook_suggestions'][] = "print__node__{$type}__{$nid}";
 189   $variables['theme_hook_suggestions'][] = "print__{$format}";
 190   $variables['theme_hook_suggestions'][] = "print__{$format}__node__{$type}";
 191   $variables['theme_hook_suggestions'][] = "print__{$format}__node__{$type}__{$nid}";

```
> 2 votes

---
Tags: theming, hooks
---


# Question
Title: Views Infinite Scroll content doubles up at end of scrolling
I have a View, with Views Infinite Scrolling. It seems to be working fine, except when I hit the end, the content doubles up.

One interesting thing is they are nodes rendered with Display Suite. These nodes have an image. When I hit the bottom and the duplicate nodes display, they are missing the image. If I go into Firebug, or resize my browser, they display.

How can I fix this behavior?

I'm running Views 3, jQuery 1.8, and Views Infinite Scroll 7.x-1.1+0-dev.

# Answer
After going through the code, I see it is because they don't handle the Responsive Grid Views extension, which I am using. I just hid the duplicate items with CSS for now, and I'll go back and submit a patch to the maintainer later.
> 0 votes

---
Tags: 7, views
---


# Question
Title: Drupal Apache Solr How to process all the results and not only 10?
I have a Drupal 7 website with apache solr search engine, and i want to access to all the results via my custom module before it is displayed, so i used this hook hook\_apachesolr\_process\_results and as it says in it description

> This is invoked by apachesolr\_search.module for the whole resultset returned in a search.

and that works good as long as your results are less then 10, but if your results are more then 10 results, then this hook will only process 10 by 10 (and 10 is the number of results that are returned in search page by default) so it only process the results that are currently displayed in the current page.

my question is there is a way to access all the results and not only the 10 results that are displayed in the current page?

Thanks in Advance

# Answer
In fact, Solr returns 10 results by default but you can tell him to return more with the `rows` parameter :

> The `rows` parameter specify the maximum number of documents from the complete result set to return to the client for every request.

You can overwrite the default by implementing `hook_apachesolr_query_alter()` in your custom module. e.g :

```
function hook_apachesolr_query_alter($query) {
  $query->replaceParam('rows', '1000'); // Note that high value increases response time
}

```

Maybe you can do the same from the apachesolr configuration page but I'm not sure (can't check right now). Hope this helps.
> 0 votes

# Answer
You can both preprocess, https://api.drupal.org/api/drupal/modules!search!search.pages.inc/function/template\_preprocess\_search\_results/7 and https://api.drupal.org/api/drupal/modules%21search%21search.pages.inc/function/template\_preprocess\_search\_result/7, and theme search results (even with solr), with search-results.tpl.php and search-result.tpl.php
> 0 votes

---
Tags: 7, search
---


# Question
Title: How to force login before submitting webform?
Drupal 7.17, Webform 7.x-3.18 : I'm presenting a webform that anyone can fill out, but upon submit, if the user is anonymous, or not logged in/authenticated, I want to force a redirect to the login page (with a callback to the redirect of the webform). In other words, they must register or login in prior to submitting data in that webform.

So far, I've tried Rules to no avail. If (content type is Webform), and Site User Role is Anonymous, then Page Redirect to \[site-url: login\].

I suspect a webform relies on the Form API, but maybe forcing login at the submit handler might work (webform api?), but how do I get a callback to the form redirect within that submit handler?

I noticed Confirm Form - http://api.drupal.org/api/drupal/modules%21system%21system.module/function/confirm\_form/7, but we're not confirming, it's more of a validation?

Keep in mind, I want the anonymous user to see the form, so using content access or limit visibility of form by role won't necessarily work. Thanks in advance for any advice!

# Answer
Webforms were once their own beast in Drupal, that's slowly changing. They have a ton of webform\_hooks. You want to try to:

* Intercept the submission
* redirect to login if anonymous, save webform node id (save populated submission values to $\_SESSION?)
* redirect to webform node id
* re-populate form (?)

Look at maybe hook\_webform\_submission\_presave and do your intercept, redirects (using `drupal_goto()` to interrupt the final save() submission?) from there.

**EDIT**

You can try a hook\_form\_alter() and include your own `#validate` method as well into the chain of form validators, instead of the presave hook. But, I figure if it validates and is about save() -- nab that, login then redirect and populate valid data ... approach it as you wish.
> 1 votes

# Answer
Here is a simple example, you would place this in a custom module:

```
function hook_webform_submission_presave($node, $submission) {
  //test is user is anon
  if (user_is_anonymous()) {
    //tell user what is going on
    drupal_set_message("Please register before submitting form");
    //redirect to registration page, with path to send back to form when done
    drupal_goto('user/register', array('query'=>drupal_get_destination()) );
  }
}

```

Here are docs for hook\_webform\_submission\_presave(), and webform.api.php within the webform module is also a great resource.

It seems to preserve form data with select components, but not 100% on that.
> 3 votes

---
Tags: webforms
---


title: Adding font-awesome to Omega 4 subtheme

text:
# Question
Title: Adding font-awesome to Omega 4 subtheme
I want to use font-awesome in an Omega 4 subtheme. I added this line to `Gemfile`:

```
  gem 'font-awesome-sass'

```

and tried to import it in `subtheme.styles.scss` with:

```
@import "font-awesome-sass";

```

But I get this error after running `compass compile`:

```
"Syntax error: File to import not found or unreadable: font-awesome-sass.

```

I also tried `@import "font-awesome-sass.css"` with no error, but no new stylesheet file is added to the subtheme pages.

Any suggestion?

# Answer
> 2 votes
Adding it to the Gemfile alone doesn't install the library. The Gemfile is used by a program called Bundler that manages your Ruby gems for you. You need to make sure you have this installed with `sudo gem install bundler` and then run `bundle install` where the Gemfile is located (your theme directory).

Alternatively you could just install font-awesome-sass yourself with `sudo gem install font-awesome-sass`.

---
Tags: 7, theming
---


title: Mollom module blocks non-spam content

text:
# Question
Title: Mollom module blocks non-spam content
I am building a site using Drupal 7 and the Mollom module

Mollom really helps me to block spam on my site. Even spam bot that succeed on passing the captcha module and register to my site, never post any content on my site - so that's great!

But, the problem is when a quality user try to write relevant good content in the site - Mollom is "unsure" and shows the user a captcha to validate that he is a human. This is a quality content without any spam words (e.g. "Viagra").

I tried writing by myself good content as an authenticated user, Mollom was "unsure" and showed me the captcha after I tried to save. I tired it again few times, and always mollom display the capatcha after I am trying to save.

1. Is there any way to make Mollom less strict? Am I missing something in the settings?
2. Can I use also the Honeypot module together with Mollom (and even remove mollom)?

# Answer
I have used very successfully used honeypot and Mollom together with very positive effects.

I am not sure about lowering the sensitivity of Mollom however or improving its ability to recognise a quality post. I can only assume they have increase the strictness to ensure they maintain there high number of correctly classified ham messages. for more information check out: https://mollom.com/blog/spam-vs-ham
> 0 votes

---
Tags: advertising
---


# Question
Title: Localhost configuration and problem with file permissions
Whenever I work on my local machine I am almost always experiencing problems related to file permissions settings, and since I guess they may be related with my local machine configuration I would like to explain how did I configure it in order to get advice on how to configure it properly (Since my knowledge on server configuration is quite limted and I am far from being a sysadmin).

My local machine is using ubuntu as OS and I installed php5, php5-mysql, mysql-server, apache2 and phpmyadmin separately using ubuntu's packages. The only custom configuration I made is that I don't place the websites in `etc/apache2/www` folder as default but on a specific folder at my home partition `~/www` . In order to make this settings work I have to do follow this steps:

1. I edit `/etc/apache2/sites-enabled/000-default` as to point to that folder by replacing `/var/www` with the path to `~/www`
2. Restart apache (`sudo /etc/init.d/apache2 restart`)
3. Create a symlink inside `~/www` which points to `/usr/share/phpmyadmin` (`# ln -s /usr/share/phpmyadmin /home/carlos/www/phpmyadmin` )

This configuration has the following benefits which are quite important to me:

1. I can keep my code safe whenever I install a new ubuntu release (this is, every six months) yet at the same time I can format / partition without losing any data.
2. I don't need extra permissions (sudo) every time I want to edit any file (which is often, since it's my development environment), update modules and so on.

However, it also has some drawbacks like the ones I mentioned with file permissions, and I think they are related to the fact that the owner of the files and folders is not www-data user but my own user.

Is there any way to prevent problems with file permissions but also preventing having to place the files in `etc/apache2/www` folder?

# Answer
> 1 votes
The web server must have a properly configured file structure to operate. The files should be placed under /var/www or /usr/local, not under /home. The /etc directory is for system and configuration files, not web data files.

There should be no reason for you to format the root partition when maintaining a system, but if you insist on doing so, put /var /usr and /home on a separate drive, and mount them under the root during boot. That way you will not lose any data.

If you are so desperate to ease the editing, work as root and learn to be careful. But make sure the files are under the correct group and owner for the web server to operate.

# Answer
> 1 votes
I've got solution for localhost (Linux Mint) test Apache server (only for local tests).

You need change user and group for Apache to local username (greg as example).

/etc/apache2/envvars:

export APACHE\_RUN\_USER=greg

export APACHE\_RUN\_GROUP=greg

Restart Apache.

# Answer
> 1 votes
Apache *shouldn't* be able to write to any files or directories without you explicitly allowing it to be changing ownership or permissions where required e.g. sites/default/files. On a publicly accessible site anything else would be a huge security risk.

Some people like to run apache as their own user locally for convenience but IMO it's better to be aware of which directories need write permissions so you can replicate them on your production environment.

# Answer
> 0 votes
One possible answer that I found to solve problems with drupal using this configuration is to change owner and group for `sites/default` folder to `www-data` in this way there won't be any problem when drupal wants to create image-styles, cache css or js, create temporal files, attach files... which are the common problems that I found, yet, on the other hand I will be able to edit files without sudo permissions and being able to format / at my wish without losing anything.

---
Tags: files
---


title: Drupal Commerce Custom Sizes

text:
# Question
Title: Drupal Commerce Custom Sizes
I am creating a Drupal Commerce website to sale Custom Stitched Thobes in which I need to get the Measurement from the customers. I am unable to understand where & how should I add fields to take the measurements for the product he adds to cart.

Actually the idea is to offer some standard sizes like S,M,L or XL in case he don't want the standard sizes he can select Custom in Sizes Drop down, which will show up custom size text fields.

I was looking for a straight forward way to add **text fields** in **Product Type** through manage fields and check **Enable this field to function as an attribute field on Add to Cart forms.** so those fields can be appeared on add to cart form but unfortunately this option is not available for text fields.

# Answer
> 0 votes
Correct - the way the attributes system works, it requires you to define a SKU for every possible combination - depending on how many measurements options you have, it could be infinite. Instead you should look into line item fields that allow a customer to associate unstructured data with a product when it is added to the cart. This could accommodate both your fixed and variable sizes.

---
Tags: entities, commerce
---


# Question
Title: How to make changes to the database schema?
I am trying to follow edits made in a php file to patch a module and the instructions just say "In your database schema add this", which I could do if I knew where to find the file. When I look up drupal database schema it shows a map which doesn't help me to find the file. What do they mean exactly by in your database schema and how can I access this file in terminal? Is it by editing a table in the database?

I can find the other file alright to edit in /includes/database/mysql/schema.inc file but just not the specific module one.

The instructions for this vchess module patch are here

# Answer
That particular instruction looks like it is suggesting you make the change in hook\_schema() in the .install file.

To make the corresponding change in your own mysql database you would need to log into the mysql terminal and change the field "turns" in the 'vchess\_games' table, adding the enum values of 'w' and 'b' to that ENUM field.

However it may be simpler to disable and uninstall the module, make the change to your vchess install file then re-enable the module. This decision should be based in how much data you already have in you vchess\_games table though.
> 0 votes

# Answer
Your database schema literally just means the structure of your database. It sounds like you're being instructed to manually make a change to this e.g. to add a column, which you could do in something like PHPmyadmin.

Normally a module's database schema is managed in its .install file. The initial schema is defined in `hook_schema()` and any changes are automated with `hook_update_N()`, but it sounds like you're being asked to make manual changes instead. Be careful!
> 1 votes

---
Tags: database, version-control
---


# Question
Title: CSS changes to .menu .leaf affect main-menu AND admin shortcut menu in Drupal 7
I'm using drupal 7 and have created the subtheme of omega using drush omega-wizard. I'm using compass to watch for changes to the scss files and it's +/- behaving as I'd expect. My problem occurs when I try to style the main-menu with something like:

```
.menu .leaf {
    width: 30px;
}

```

The restyling works but it also affects the admin's shortcut menu which uses .menu .leaf. Is there a setting in the config that I've missed, should I be targeting the menu in another way. How do I not affect the shortcut menu when styling the main-menu?

Any help would be greatly appreciated. Thanks, Steve

# Answer
> 0 votes
You need to make your CSS more specific so that it only applies to menu items on your main menu. You can do this by prefixing the CSS rule with the class of its container e.g.

```
.block--system-main-menu .menu .leaf. {
    width: 30px;
}

```

---
Tags: theming
---


# Question
Title: Categorised Multiple File uploads within a page in Drupal 7
I have a situation where I have to upload multiple files within categories. This can be explained by the following picture.

As you can see I need to upload multiple files, but also need to categorize them. Each category has different files and even though below picture shows the same name of the files, they are not shared. How can I do it in Drupal 7. Any idea?

Thanks

# Answer
Assuming you want all of these attached to one node and the categories need to be dynamic, I'd use field collections where each category is a field collection item which has a title field and a multi value file field.
> 1 votes

---
Tags: views, nodes, files
---


# Question
Title: Apache Solr Search Integtation and the Default Drupal Search Form
Apache Solr Search Integtation (apachesolr module) is dependent on the core Search module. I set this up at https://www.test.epcsite.com/search/content. I also setup display suite so that I can theme my search results.

I have a couple questions:

1. The Default Search form uses Drupal core search. If you go to https://www.test.epcsite.com/search it redirects to https://www.test.epcsite.com/search/content, I don't quite know why. I would like it to stay on "/search".
2. apachesolor setup a url at /search/site, which puts a tab on the search form. Clicking on the tab takes you to another search form, but it won't use Display Suite to theme the results. The tab itself is confusing and it would be nice to get rid of it.
3. Going to https://www.test.epcsite.com/search/content displays "Your search yielded no results" but I haven't run the search yet. How do I customize this message not to show? How do I customize the message so that it says what I want.

# Answer
> 1 votes
I'm assuming Drupal 7.

1. This is a limitation of the way core Search is implemented in D7. Try the Custom Search module; it can somehow change the way search paths are handled, although I have not used it.
2. One tab would be for core search, and the other for Apache Solr search. Go to `/admin/config/search/settings` and disable all search modules except Apache Solr, and also set it as default. Now the only available search path will be the one set up at `/admin/config/search/apachesolr/search-pages`.
3. I cannot replicate this on my Apache Solr & Drupal 7 setup. In general, to change strings that are hard coded into modules, use the String Overrides module.

---
Tags: search, display-suite
---


# Question
Title: How can I exclude links to untranslated pages from Google search results?
I have a multilingual site (English and Japanese). Japanese is the default language. Some pages have been translated into English and some have not.

I am using the XML Sitemap and i18n Modules as well as Translation Redirect (one of the i18n submodules).

For pages that are not translated into English, both the "English" and Japanese versions are appearing in Google search results-- even though there is no English version! (Both links appear like this:

* www.mysite.com/en/node/29
* www.mysite.com/ja/pathauto-url

I have two sitemaps (Japanese and English) made with the XML Sitemap module. The pages that have not been translated into English are still listed in the English site map, so I assume this is how Google found the pages.

How can I deal with this?

Is it possible to remove untranslated pages from the sitemap of the relevant language? Or is it possible to automatically redirect all untranslated pages to the default language?

# Answer
> 1 votes
When using i18n xml sitemap, and when you have a menu set to be included in a sitemap (using xmlsitemap menu), even if that menu is set to display only for one language (localized to Japanese or English in my case using i18n\_menu), it will still get added to the sitemap for both languages.

So, in this case, one solution is to avoid using xmlsitemap\_menu and instead use xmlsitemap\_node and add the node links individually.

Painful but it works.

---
Tags: i18n-l10n, xml-sitemap
---


title: taxonomy_select_nodes put order promote

text:
# Question
Title: taxonomy_select_nodes put order promote
I tried to make order by promote when I call taxonomy\_select\_nodes. Like this:

`$node= taxonomy_select_nodes(163, TRUE,10,array('t.promote' => 'DESC','t.created' => 'DESC'));`

But I got an error! Is there any solution? Thanks

# Answer
> 0 votes
The function you are using

taxonomy\_select\_nodes($tid, $pager = TRUE, $limit = FALSE, $order = array('t.sticky' =\> 'DESC', 't.created' =\> 'DESC'))

And Parameters

$tid: The term ID.

$pager: Boolean to indicate whether a pager should be used.

$limit: Integer. The maximum number of nodes to find. Set to FALSE for no limit.

$order: An array of fields and directions.

In your case we can see you are joining field 't.promote' it seems like the field not present, please review you code once and follow the stranded format like https://api.drupal.org/api/drupal/modules!taxonomy!taxonomy.module/function/taxonomy\_select\_nodes/7

---
Tags: 7, taxonomy-terms, nodes
---


title: Translate admin settings

text:
# Question
Title: Translate admin settings
I am writing a module configuration page for a module. Is there a way to make variables submitted and saved by system\_settings\_form translatable?

# Answer
> 0 votes
I think there are two issues you have to think about...

1. Is the item you are saving in the variable used for calculations?
2. Is the item you are saving going to be displayed?

Note there is actually a variable translation module located in Localization Module, but it seems you would need to ask for these for each language supported.

In the case of #1, code may be require this variable to be a specific value. This will make it to whether you need to keep a record of all the available translated values of this item that can be entered and compared against.

In the case of #2, you could simply wrap a t() around the variable setting it up for translation, but if it is something like a text field, this will have to be done after one figures out what the item is... Select fields and others would be no problem as you have a *finite* number of possibilities.

With all that said, if the item is a free-formed text field, I would just allow your user to type in a different value for this item for each language he has enabled using the Variable Localization module.

# Answer
> 0 votes
You need to install Variable translation module. implement hook\_variable\_info where you define your variables.

Navigate to admin/config/regional/i18n/variable and make it multilingual.

---
Tags: forms, i18n-l10n
---


# Question
Title: How to know what is slowing down my drupal site
My site is still in early stages of development and the page load is getting slower day by day. Even though i really think twice before installing a module for something and try to get it done with jQuery.

Is there a way to know "What Exactly (A module or my theme templates) is slowing down the site ?".

thanks

# Answer
you can install devel module and enable show queries so you can look at what queries run your website.Find out havy query and try to optimize.
> 2 votes

---
Tags: 7, performance
---


title: entity_metadata_wrapper question

text:
# Question
Title: entity_metadata_wrapper question
I'm using this piece of code to programmatically alter a node field:

```
    $node_wrapper = entity_metadata_wrapper('node', 93);
    $node_wrapper->field_field4->set("text");
    $node_wrapper->save();

```

This code works when I'm testing with **hook\_init**: Eg:

```
    function cust_init()
    {
        $node_wrapper = entity_metadata_wrapper('node', 93);
        $node_wrapper->field_field4->set("text");
        $node_wrapper->save();
    }

```

But it does not work when being called via hook\_node\_update or hook\_node\_presave or from a form submit handler. For example, after running this code:

```
function cust_node_update($node)
{
        $node_wrapper = entity_metadata_wrapper('node', $node->nid);
        $node_wrapper->field_field4->set("hello");
        $node_wrapper->save();
}

```

I'm expecting to see a change in my node, but I don't.

Is the hook\_node\_update the right place where this code should be added? What I need to do is to update a field of a node after a node is being updated.

Thank You.

# Answer
> 3 votes
The difference between `hook_init()` and `hook_node_update()`/`hook_node_presave()` is that the node is already in progress of being saved when either of the last hooks are invoked.

Notice how the argument to `cust_node_update($node)` in your non-working example is a $node object. In fact, it's a **reference** to the very node object *about to be saved*. This is important because only the data actually in that node object will be passed on to the database.

Your first line calls `entity_metadata_wrapper()` with the id of that node to create an object oriented wrapper around it. The problem here is that since you're only passing the id of the node, `entity_metadata_wrapper()` has no choice but to fetch **a copy** of that node from the database (or perhaps a cache, but that is irrelevant to the discussion). This newly fetched and wrapped node will be an entirely new object representing the same node, with *no connection* to the node reference passed to `hook_node_update()` or `hook_node_presave()`. Altering this new node object has no effect whatsoever on the node object already in progress of being saved. Both objects represent the same node data, but the one you fetched from the database and wrapped with an object oriented interface is a copy of the original node data.

Calling `$node_wrapper->save()`, `node_save()` or `entity_save()` inside `hook_node_update()` or `hook_node_presave()` **is a bad idea** because it tells Drupal to save the node already in progress of being saved, which would again invoke those hooks - but this time with a reference to the node object you fetched from the database. Your hook implementation will then again fetch a new object representing the same node from the database, before it has actually been updated, wrap it in an object and try to save it. Endless recursion is a fact and you're likely to suffer the White Screen of Death.

## So, how do we fix this?

Jupiter's answer is on the right track, but it also works with `hook_node_update()` if that's what you want to use. Calling `entity_metadata_wrapper()` and passing in the entire node to be wrapped will let the wrapper reference and alter the actual node object instance you pass in - containing all the latest information - instead of loading a copy from the database.

Calling `$node_wrapper->save()` would still trigger a recursion (this time without creating node copies), but you don't need to care about actually saving things because you're acting on the node reference passed to the hook implementation, which is the very same object Drupal will store in the database once the hook implementation has returned and a few extra tasks have been performed.

There's at least one gotcha when using `entity_metadata_wrapper()` in these hooks though, depending on whether other modules use the same hooks - or one invoked later than the one you implemented - to reorganize the node structure into a form that can be saved to the database more easily. The node may, in other words, be structured differently compared to when it's loaded using `node_load()` or `entity_load()`, depending on which modules you use. The easiest way to find out the structure of the node being saved is to use Devel module's `dpm($node, 'node to be saved');` and inspect the structure before actually attempting to modify it.

# Answer
> 1 votes
I have found that hook\_node\_presave() is more useful when setting node values with a wrapper.

This works for me:

```
function X_node_presave($node) {
  $wrapper = entity_metadata_wrapper('node', $node);
  $wrapper->field_name->set(VALUES);
}

```

No need to call anything else.

# Answer
> 0 votes
I'm not sure, but it looks like that updates hooks retrieves $node by reference (& - symbol, Im not so good in english :)). You update node via wrapper, but forget to update $node variable. So, after each update hooks will be executed, $node will be saved second time.

Try to do not use metadata wrapper in node hooks, instead of this use `$node->field_field4[LANGUAGE_NONE][0]['value'] = 'text';`.

**UPD**:

You can try overload node object after wrapper save() execution.

```
$node_wrapper->save();
$node = $node_wrapper->value();

```

And there is also some feature with cache by node\_update(). ;)

# Answer
> 0 votes
I fixed the problem using **field\_attach\_update** function.

`$raw_collection = $node_wrapper->field_additional_sections[$i]->value();`

````
...

//perform the field updates

field_attach_update('field_collection_item', $raw_collection);

//overwrite the node object

$node = $node_wrapper->value();

````

---
Tags: entities
---


# Question
Title: Drupal Forms API how to get degree sign onto submit button
I'd like to have a submit button with "°C" value on it. But when I just copy paste the degree sign, I get an empty value. When I try HTML code for degree sign (`°`) it is escaped so I get `°`C.

This is my submit button element in my hook\_form function:

```
$form['wrapper']['F'] = array(
    '#type' => 'submit',
    '#name' => 'F',
    '#value' => '°F',
    //'#value' => '° F',
    //'#value' => '° F',
    '#attributes' => array('id' => 'fahrenheit-button'),
    '#weight' => 20,
  );

```

Any ideas? Thanks, Tomas

# Answer
Buttons in Drupal by default are being generated by the `theme_button()` theme function which uses `drupal_attributes()` to handle all of the button's attributes which *always* escapes an attribute's value using `check_plain()`.

Visit api.drupal.org/api/drupal/includes%21form.inc/function/theme\_button/7 for the `theme_button()` function and click under the Code section on a function name to see what it does.

I think there are two possibilities:

1. You write your own implementation of `theme_button()`: copy the original function, paste it into your `template.php` file and rename it to something like `YOUR_THEME_button()`;
2. Or just use the bare unicode character as you did in your question. I read at stackoverflow.com/q/3627720/328272 that this does not work on Windows XP, but I successfully tested it on IE7 and IE8 on XP using browserstack.com.
> 0 votes

# Answer
```
<input type="submit" value="°C" />

```

This website is useful for converting characters: http://rishida.net/tools/conversion/
> -1 votes

---
Tags: forms
---


# Question
Title: How can I stop ckeditor from adding <p> </p> in front of pasted word content?
When I paste from word using the word clipboard button I get a blank paragraph inserted before the word content.

Can anyone tell me the way to prevent or fix this?

# Answer
Upgrading to ckeditor 4 solved this issue for me. I am using wysiwyg 7.x-2.2 and CKEditor 4.0.0.769.
> 3 votes

# Answer
Check out the patch available at:

https://drupal.org/node/550428#comment-7107518

Haven't tried it yet myself, but will tomorrow...
> 0 votes

# Answer
I added

config.fillEmptyBlocks = false;

to the ckeditor settings, seems to work.
> 0 votes

---
Tags: 7, nodes, wysiwyg
---


# Question
Title: How to create Drupal Articles Thumbnails and display it on homepage
I would like to know what is the BEST WAY to generate thumbnails in drupal? I need to create a semi news style website in Drupal that requires me to GENERATE THUMBNAILS AUTOMATICALLY from Articles I created. I attached a sample website screenshot from a similar website I am trying to imitate.

Is there a Good Drupal module can you recommend? or much better a Drupal function I can insert in PAGE.TPL.PHP to generate thumbnails from my articles or posts and display it in the front page?

Thank you in advance sirs.

# Answer
> 0 votes
You can view module for your display

1. Go to structure -\> views -\> add new view
2. Checked -\> create block
3. Set the required fields based on image
4. Click save button
5. Check If block is exist or not in Structure -\> Block
6. If block exist that block Drag particular region .
7. Click "configure" and set specified page

And also float:left used to article body summary is displayed in left side

# Answer
> 0 votes
You can use Views module to achieve above...

For more details visit documentation page of views module.

---
Tags: 7
---


# Question
Title: How can I link one drupal View field (an image) to a QuickTab?
Im trying to link each image field of my view to a quicktab that I created. This is my view

>

and this is how it looks

>

As you see I already tried to put the url link and rewrite the stuff, I put content and nothing to the image (the part of the landing), I even tried to put it as an external link, but it never recognize it as a link.

>

# Answer
I got it! What I did:

1. Create 2 different content types for each image.
2. Then I did add each one as a field.
3. Then I played with Filter criteria, adding a taxonomy term previously in my content type.

4. Then I did rewrite the results of each field (each image) to land to the page that I wanted.
5. Finally I did create the basic pages inserting in each one the Quicktabs that I needed.

And voilá! that was all :D

Thanks
> 0 votes

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


title: Editing Panels in Admin Theme

text:
# Question
Title: Editing Panels in Admin Theme
I would like to edit my Panels (Panel Layout and Panel Content) in the administration theme, however when I click on the tab to go to panel layout (node/%node/panel\_layout), it always opens in my default theme.

Is there a way to have it use my admin theme for panels?

# Answer
> 4 votes
You could write a small custom module and use `hook_admin_paths()`:

```
function MYMODULE_admin_paths() {
  return array(
    'node/*/panel_layout' => TRUE
  );
}

```

This will instruct Drupal to treat paths that match the pattern as admin pages, including rendering them with the admin theme.

# Answer
> 0 votes
Please install "Pahe Theme" module, add admin theme in it and then add node/\*/panel\_layout\* path in it.

---
Tags: panels
---


title: Custom breadcrumb on user profile page

text:
# Question
Title: Custom breadcrumb on user profile page
I am using profile2 module for my User profiles.

Now breadcrumbs on user profile pages are:

> Home \> Username

I need breadcrumbs to be like this:

> Home \> Custom page \> Custom profile2 field

How can I change it? Thanks for your replies.

# Answer
> 1 votes
You can use Path Breadcrumbs module. This module helps you to create breadcrumbs for any page with any selection rules and load any entity from the URL.

If this module is not satisfy your requirements, then visit Comparison of Breadcrumb Customizing modules to get more information.

# Answer
> 1 votes
In Drupal 7 you can use **MYTHEME\_breadcrumb** function in **template.php** file, if you don't want to use any contributed modules.

```

    /**
     * Preprocess function to customizing the breadcrumbs
     * @param type $variables
     * @return string
     */
    function MYTHEME_breadcrumb($variables) {
        $breadcrumb = $variables['breadcrumb']; //get the breadcrumb
        if (!empty($breadcrumb)) {
            if (arg(0) == 'user' && is_numeric(arg(1))) {//Check your condition based on your requirement for user profile
                $breadcrumb[] = l('Custom page text', 'Custom page link');
                $breadcrumb[] = t('Custom profile2 field text');
                //$breadcrumb[] = l('Custom profile2 field text', 'Custom profile2 field link');//if you want link use this
            }
            $output .= '<nav class="breadcrumb">' . implode(' » ', $breadcrumb) . '</nav>';
            return $output;
        }
    }

```

# Answer
> 0 votes
Answer similar to https://drupal.stackexchange.com/a/106057/2974, using Crumbs.

After installing the module:

1. Go to `admin/structure/crumbs/entity-parent/user`, and specify the views page as the parent path for 'authenticated user' (this will cover other roles too, because every user is authenticated).
2. On `admin/structure/menu`, edit the main menu (or another menu), create an item that links to the views page, and give it a title like "List of users". (\*)
3. On `admin/structure/crumbs`, make sure that the `menu.link_title.main-menu` and `menu.hierarchy.main-menu` are enabled. Or just enable `menu.*`.
(enabling means to move those lines up into the "Enabled" section with drag+drop)
4. To see what going on behind the scenes, you can visit `admin/structure/crumbs/debug`.

EDIT: This might not get you the modified title for the last breadcrumb item. If you want that, you can use hook\_crumbs\_plugins() or hook\_menu\_breadcrumb\_alter() to change that part. Maybe this should be covered in a separate question, "How to to change the title of a breadcrumb item in Crumbs programmatically?".

Note: It could be that in your particular case, Path breadcrumbs is the easier option, as it allows to do all via the UI. Crumbs might improve on that in the future, but for now it is what it is.

# Answer
> 0 votes
You can use yourtheme\_breadcrumb hook to change breadcrumb for specific use case. Look at https://api.drupal.org/api/drupal/includes!theme.inc/function/theme\_breadcrumb/7

---
Tags: 7, users, breadcrumbs
---


title: Print random part of body

text:
# Question
Title: Print random part of body
I'd like to print (in Views - custom/PHP field) random part of body of a node, as a kind of teaser, different with every print.

Any ideas? Thanks! :\]

Szy.

# Answer
> 2 votes
here you go: :)

```
$length = 50;

// strip html tags from body
$body = strip_tags($data->body);

// check that the body's actually longer than your snippet length
if (strlen($body) <= $length) {
  return $body;
}
else {

  // find a random starting point between the beginning and 50 chars from the end
  $max = strlen($body) - $length;
  $start = rand(0, $max);

  // set ellipsis variables
  $prefix = $start ? '...' : '';
  $suffix = ($start == $max) ? '' : '...';

  return $prefix . substr($body, $start, $length) . $suffix;
}

```

---
Tags: 7, nodes
---


# Question
Title: create a field that display value from an other one?
I'll try to give a clearfull explanation of my question... but it's an hard one to explain, and my english is not really good... but let's try and I hope someone could help me. :)

I have a site running with Drupal 7

In this site I have an event calendar (with date)

And the entity registration module.

The point is:

When my user create a multiple event date I get a display like this:

> ```
>  event 1 - date_of_event_1
>  event 2 - date_of_event_2
>  event 3 - date_of_event_3
>
>  event description
>
>  registration form:
>
>  name:
>  e-mail:
>
> ```

What I want is to be able to have a field in my registration form like that:

> ```
> Choose your date: date_of_event_1 []  |  date_of_event_2 []
> ([] = some check boxes)
>
> ```

So I search for a module that allow my form to display a field referencing my dates...

I can easily display my dates values on a view. So I think there is a way to use the same filter on a field?

I've made some researches but I didn't find anything.

Maybe someone heard about something like that?

Thanks for reading!

Just adding some informations:

I have some hopes with the field-reference module...

But here the problem is my registration form is an other type of content and it's display in the related node by using a field "registration" (that came with the module)

So field reference doesn't find my date value in my form because it's not really in the same content. :(

# Answer
I'm not sure this is suited to your needs but maybe the entity reference module might be able to help you :

> Provides a field type that can reference arbitrary entities:
>
> A generic entity reference field Four widgets:
> Two implemented on top of the Options module (Select and Radios/Checkboxes),
> Two autocomplete widgets (one with one text field per entry, one tag-style with comma-separated entries in the same text field)
> Two formatters:
> A "Label" formatter, with optional link that displays the label of the referenced entity (the node title, the user name, etc.)
> A "Rendered entity" formatter, that renders the references entity using a configurable view mode Integration with Views (for both forward and backward references)
> Integration with Entity Metadata (and as a consequence with Search API and the like) Integration with Devel generate Integration with Feeds and Migrate (\>= 2.3) for painless data import This modules depends on Entity API and CTools.
> 0 votes

---
Tags: entities, nodes
---


# Question
Title: Taxonomy Access Control module - don't display term instead of disabling it
I'm using Taxonomy Access Control module to manage allowed categories of content user can create/edit. I want to change default behaviour of this module which disables term which user cannot assign ("black" in this example) but still displays it. I know, it can be hidden via CSS or removed via JS, but I want to remove it on the module level.

# Answer
> 0 votes
There is an issue in the issue queue regarding (https://drupal.org/node/1209154) this where the maintainer has given some options for a potential fix and has tried a few options out, however there is still no proper fix for the problem.

The module already handles the back end and not allowing users to submit those values, the disabling is really only for visual reasons, so removing via js is a viable solution in this case.

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


# Question
Title: How to save the image of a node to the custom directory programmatically?
I have a cck image field and I have the "uploads" directory in the files folder.

I want the images of these nodes are saved to the directory with the name of the node id and then the image file. Suppose if the node id is 4 then the image should be saved to the following directory.

```
files/uploads/4/filename

```

the directory with the name of "4" should be created programmatically.

Which hook should I use for this and how to achieve this? Any one who have some idea?

# Answer
> 2 votes
You have to use following module https://drupal.org/project/filefield\_paths . then you can add tokens for it .

# Answer
> 1 votes
You should use File (Field) Paths which supports Drupal 7..

Project page says

> The File (Field) Paths module extends the default functionality of Drupal's core Upload module, the FileField module and many other File Upload modules by adding the ability to use node tokens in destination paths and filenames.
>
> In simple terms, File (Field) Paths allows you to automatically sort and rename your uploaded files using token based replacement patterns to maintain a nice clean filesystem.

# Answer
> 0 votes
You can use the Upload path module:

> After operating for some time, a website may build up thousands of files in inside the files folder. This uploadpath module allows you to keep the files in the files folder neatly organized in subfolders. It can also allow you to automatically rename uploaded files based on file description or node title.

The module uses the Token module for specifying path patterns. It is relatively a small module and you can take a look at its code to get a hint of how it achieves this.

---
Tags: 7, media
---


title: Default terms based on user role

text:
# Question
Title: Default terms based on user role
I have Node with taxonomy terms. Example

* Term A
* Term B
* Term C

and user role like this

* Role 1
* Role 2
* Role 3

Using Taxonomy Access Control(TAC) I can limit Role 1 can add all terms, Role 2 only add Term B, Role 3 only add term C.

With CSS I can hide disabled options, so when Role 3 want to add content. ex: Role 3 will only see Term C.

But how can I make Term C autofilled when Role 3 want to add. Right now Role 3 must choose or fill two options, nothing and Term C.

Any ideas?

# Answer
> 1 votes
There might be better ways to do it, but this what I did in my case.

1. In hook\_form\_alter loop through the '#options' for this field.
2. Store every item in a new array skipping the one you don't want as options for this field. (in my case it was the item at index 0 with value 'N/A').
3. Assign this new array of options as '#options' for the field.

Worked for me.

---
Tags: 7, nodes, forms, users, taxonomy-terms
---