title: drush sql-dump gives warning

text:
# Question
Title: drush sql-dump gives warning
When I ran `drush sql-dump --result-file`, it came back with a warning and a success message.

```
system(): Cannot execute a blank command exec.inc:36                 [warning]
Database dump saved to                                               [success]
/my/homedir/drush-backups/unknown/20150113014628/_20150113_014628.sql

```

However, I checked inside the directory and no `.sql` backup file can be found. I have also read this issue, but I am not using drush aliases.

How can I fix this and backup my database using the command line?

# Answer
> 2 votes
I was following the docs, which told me to execute the command in my 'From your Drupal directory', so I executed the command on my Drupal installation root directory.

I have a multi-site set up, and running it inside my site directory `/sites/mysite/` worked.

---
Tags: drush, database, backups
---


# Question
Title: How to show loader image before popup screen of color box module in drupal 7
I used color-box module in my current drupal project for showing user details in popup after click user image. It will take some time to show details so I want to show loader images before this. I tried to override this using drupal.behaviors but cannot get proper output. If any idea how to handle this situation then please help me for same.

Thank you.

# Answer
Hope this will help you,

* You can use Colorbox Callbacks

+ **onOpen** : Callback that fires right before Colorbox begins to open
    + **onComplete** : Callback that fires right after loaded content is displayed
```
jQuery.colorbox({
........
  onOpen:function(){
    //show loader
  }
  onComplete:function(){
   //hide loader
  }
});
```
> 1 votes

# Answer
by default colorbox shows a default loader depending on the theme you select, you can always change that image via css
> 0 votes

# Answer
You can use `$("#cboxLoadingOverlay")` since it will be hidden after colorboxContent is loaded

```
 onOpen: function() {
                $("#cboxLoadingOverlay").html("<img width='128' src='/images/loaders/ajax-loader.gif' alt='Loading....'/>")
    }

```
> 0 votes

# Answer
You should try this.

```
fastIframe: false

```
> -1 votes

---
Tags: javascript
---


# Question
Title: Is there a way to make node titles longer?
I am importing data which has some very long title fields in academic journals. Is there a way to lengthen the `title` property? Perhaps to 1000 characters?

# Answer
> 6 votes
A simple "I'm feeling lucky" on a google search for "drupal node title length" gives:

Title Length

> This module increases maximum length of node titles to 8000 characters.

# Answer
> 2 votes
Perhaps consider having another field. Title length is set in core and is restricted by a database field, I think it would be less work to have your own field and render it appropriately.

---
Tags: 7, nodes
---


# Question
Title: Can you set an image that is part of a custom content type as the background image in a view?
Hoping someone can help me. I have a custom content type that contains a bunch of fields with one of them being an image field. I'd like to have the view display the image field as the background and the rest of the fields to overlay that image as text.

Can anyone make any recommendations on the best approach here?

Any guidance would be appreciated.

# Answer
> 0 votes
Set all of your field to hidden, then add a Global: Custom text field (not hidden). In that field you add all of your fields back via the replacement patterns, making sure to wrap them in divs (or appropriate tags) with appropriate classes, and that your image is contained in the outer div. something like this:

```
<div class="image-wrapper">
  [image]
  <h2 class="title">[title]</h2>
</div>

```

Then apply CSS to get the overlay effect to your liking. Text Blocks Over Image

---
Tags: views, nodes, media
---


# Question
Title: How to create a view of Users and use uid field with Display Suite view mode
I have been able to create a view of Users with format of Fields. I added user fields, and and found the UID field as well which I can use to link a field to the user's profile page.

However, I prefer to output views with the Content format and create a view mode for the view. For users, there is no Content format, and I assume the equivalent is User format.

However, when I created my display mode on the user profile and set it to a display suite layout, I found that there is no UID field (I did see Username, but that wont help). Does display suite not provide us this field?

# Answer
Just as it does not provide a nid field for nodes, so it does not provide a uid field for users.

For format in your view you can also show 'Display Suite' which will open up more ds-goodness.

To show the uid you need to add a ds code field. it is best used with the token module installed as well.

Add the token \[user:uid\] as the field value.

The field will now become available for display suite to use. You could also use html in the code field, and for instance use the \[user:uid\] token to create a link, as in:

```
<a href="user/"[user:uid]">[user:name]</a>

```

Also note that you do not need to display the primary identifier of an entity (uid for users) in order to use it in views relationships. As users is the base table it will already be available.
> 1 votes

---
Tags: users, display-suite
---


# Question
Title: Error while creating view for FullCalendar
I've installed the FullCalendar module in a Drupal 7.28 installation (a clean sandbox with nothing except dependencies for FullCalendar).

Following the instructions here, I'm trying to create a view for the calendar, but when I try to add a field (*Content: Post date*, as it shows in the instructions), upon clicking Apply, I get set to: /admin/structure/views/ajax/add-item/calendar\_view\_test\_/page/field with a screen full of junk

```
[{"command":"settings","settings":{"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"seven","theme_token":"Jzga71J3eqY_4IiPQChia5Z0N-jWV9v4QLfKNnXuKpw"},"CTools":{"dependent":{"edit-options-label":{"values":{"edit-options-custom-label":[1]},"num":1,"type":"hide"},"edit-options-element-label-colon":{"values":{"edit-options-custom-label":[1]},"num":1,"type":"hide"},"edit-options-custom-date-format":{"values":{"edit-options-date-format":["custom","raw time ago","time ago","today time ago","raw time hence","time hence","raw time span","time span","raw time span","inverse time span","time span"]},"num":1,"type":"hide"},"edit-options-second-date-format":{"values":{"edit-options-date-format":["today time ago"]},"num":1,"type":"hide"},"edit-options-second-date-format-custom":{"values":{"edit-options-second-date-format":["custom"]},"num":1,"type":"hide"},"edit-options-timezone":{"values":{"edit-options-date-format":["custom","long","medium","short"]},"num":1,"type":"hide"},"edit-options-element-type":{"values":{"edit-options-element-type-enable":[1]},"num":1,"type":"hide"},"edit-options-element-class-enable":{"values":{"edit-options-element-type-enable":[1]},"num":1,"type":"hide"},"edit-options-element-class":{"values":{"edit-options-element-class-enable":[1],"edit-options-element-type-enable":[1]},"num":2,"type":"hide"},"edit-options-element-label-type":{"values":{"edit-options-element-label-type-enable":[1]},"num":1,"type":"hide"},"edit-options-element-label-class-enable":{"values":{"edit-options-element-label-type-enable":[1]},"num":1,"type":"hide"},"edit-options-element-label-class":{"values":{"edit-options-element-label-class-enable":[1],"edit-options-element-label-type-enable":[1]},"num":2,"type":"hide"},"edit-options-element-wrapper-type":{"values":{"edit-options-element-wrapper-type-enable":[1]},"num":1,"type":"hide"},"edit-options-element-wrapper-class-enable":{"values":{"edit-options-element-wrapper-type-enable":[1]},"num":1,"type":"hide"},"edit-options-element-wrapper-class":{"values":{"edit-options-element-wrapper-class-enable":[1],"edit-options-element-wrapper-type-enable":[1]},"num":2,"type":"hide"},"edit-options-alter-text":{"values":{"edit-options-alter-alter-text":[1]},"num":1,"type":"hide"},"edit-options-alter-path":{"values":{"edit-options-alter-make-link":[1]},"num":1,"type":"hide"},"edit-options-alter-absolute":{"values":{"edit-options-alter-make-link":[1]},"num":1,"type":"hide"},"edit-options-alter-replace-spaces":{"values":{"edit-options-alter-make-link":[1]},"num":1,"type":"hide"},"edit-options-alter-external":{"values":{"edit-options-alter-make-link":[1]},"num":1,"type":"hide"},"edit-options-alter-path-case":{"values":{"edit-options-alter-make-link":[1]},"num":1,"type":"hide"},"edit-options-alter-link-class":{"values":{"edit-options-alter-make-link":[1]},"num":1,"type":"hide"},"edit-options-alter-alt":{"values":{"edit-options-alter-make-link":[1]},"num":1,"type":"hide"},"edit-options-alter-rel":{"values":{"edit-options-alter-make-link":[1]},"num":1,"type":"hide"},"edit-options-alter-prefix":{"values":{"edit-options-alter-make-link":[1]},"num":1,"type":"hide"},"edit-options-alter-suffix":{"values":{"edit-options-alter-make-link":[1]},"num":1,"type":"hide"},"edit-options-alter-target":{"values":{"edit-options-alter-make-link":[1]},"num":1,"type":"hide"},"edit-options-alter-help":{"values":{"edit-options-alter-make-link":[1],"edit-options-alter-alter-text":[1],"edit-options-alter-more-link":[1]},"num":1,"type":"hide"},"edit-options-alter-max-length":{"values":{"edit-options-alter-trim":[1]},"num":1,"type":"hide"},"edit-options-alter-word-boundary":{"values":{"edit-options-alter-trim":[1]},"num":1,"type":"hide"},"edit-options-alter-ellipsis":{"values":{"edit-options-alter-trim":[1]},"num":1,"type":"hide"},"edit-options-alter-more-link":{"values":{"edit-options-alter-trim":[1]},"num":1,"type":"hide"},"edit-options-alter-more-link-text":{"values":{"edit-options-alter-trim":[1],"edit-options-alter-more-link":[1]},"num":2,"type":"hide"},"edit-options-alter-more-link-path":{"values":{"edit-options-alter-trim":[1],"edit-options-alter-more-link":[1]},"num":2,"type":"hide"},"edit-options-alter-html":{"values":{"edit-options-alter-trim":[1]},"num":1,"type":"hide"},"edit-options-alter-preserve-tags":{"values":{"edit-options-alter-strip-tags":[1]},"num":1,"type":"hide"}}},"states":{"#edit-options-second-date-format-custom":{"visible":{"#edit-options-date-format":{"value":"today time ago"},"#edit-options-second-date-format":{"value":"custom"}}}}},"merge":true},{"command":"viewsSetForm","output":"\u003Cform action=\u0022\/admin\/structure\/views\/ajax\/add-item\/calendar_view_test_\/page\/field\u0022 method=\u0022post\u0022 id=\u0022views-ui-config-item-form\u0022 accept-charset=\u0022UTF-8\u0022\u003E\u003Cdiv\u003E\u003Cdiv class=\u0022views-override clearfix container-inline\u0022\u003E\u003Cdiv class=\u0022form-item form-type-select form-item-override-dropdown\u0022\u003E\n  \u003Clabel for=\u0022edit-override-dropdown\u0022\u003EFor \u003C\/label\u003E\n \u003Cselect id=\u0022edit-override-dropdown\u0022 name=\u0022override[dropdown]\u0022 class=\u0022form-select\u0022\u003E\u003Coption value=\u0022default\u0022\u003EAll displays\u003C\/option\u003E\u003Coption value=\u0022page\u0022\u003EThis page (override)\u003C\/option\u003E\u003C\/select\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\u003Cdiv class=\u0022scroll form-wrapper\u0022 id=\u0022edit-options\u0022\u003E\u003Cdiv class=\u0022form-item description form-wrapper\u0022 id=\u0022edit-options-form-description\u0022\u003EThe date the content was posted.\u003C\/div\u003E\u003Cdiv class=\u0022form-item form-type-checkbox form-item-options-custom-label\u0022\u003E\n \u003Cinput

```

Anyone know the cause of the error?

# Answer
So, when I said I was "following the instructions" that turned out to be not entirely true. I just discovered that I was using a 2.x version of the library, despite the warning to not. Once I downgraded to a 1.x version, everything worked as advertised.
> 0 votes

# Answer
There is obviously issues with this module. Install jQuery update, set it to 1.10. Create the view, then save it without the date. Add the date and now it works. However, views does not like jQuery 1.10 (or 1.9) and to prevent other issues you have to fall back to jQuery 1.8. Hence you are now in a catch-22. Solution - post an issue in the queue or use another calendar module.
> 0 votes

---
Tags: views, javascript
---


title: Prevent form fields changes

text:
# Question
Title: Prevent form fields changes
I have custom field on theme settings. I get default\_value for that field from .info file and that's OK. I change the value of that field and submit the form and get a changed value but I do not want it. I want, after submitting form the value of that field will be changed but in that field the value will be showing the default\_value from .info file. How could I do that.

# Answer
> 0 votes
If I've understood right you should implement next steps to achieve your goal:

1. Take a look at drupal\_parse\_info\_file() function to get a value from .info file.
2. Alter your form and set appropriate value to `#default_value` property whithin your field.

---
Tags: forms
---


# Question
Title: Profile 2, update separate database on submit?
I want to know where and how to plug/hook into profile 2, so that when the user updates a specific profile ("new\_profile"), that this then fires off a chunk of custom php code. The event must only be fired off IF validation passes. Which leads me to believe that I can't really just add another submit handler.

How would I be able to fire off this "second update" to a seperate database, if I only want to hook into the part after validation has passed?

# Answer
> 1 votes
Every module which exposes hooks are documented in module \*.api.php file. In your case it's just hook\_profile2\_update .

```
/**
* Respond to a profile being updated.
*
* This hook is invoked after the profile has been updated in the database.
*
* @param $profile
*   The $profile that is being updated.
*
* @see hook_entity_update()
*/
function hook_profile2_update($profile) {
  db_update('mytable')
    ->fields(array('extra' => $profile->extra))
    ->condition('pid', $profile->pid)
    ->execute();
}

```

Refer http://cgit.drupalcode.org/profile2/tree/profile2.api.php for more details.

---
Tags: users
---


# Question
Title: Get config variable value in hook_block_list_alter
works I have added a new field to block configuration settings by using the function `hook_form_FORM_ID_alter`. I used submit handler to save the variable `$form['#submit'][] = mymodule_submit` (as block\_save function was not called). Its all done till here

Now I am trying to alter the block list based on the condition set in the config field `enable_conectivity`

```
function mymodule_block_list_alter(&$blocks) {

    foreach ($blocks as $key => $block) {
       $enable_conectivity =??//How to get the varibale value
        if($enable_conectivity) {
            $blocks[$key]->visibility = BLOCK_CUSTOM_DISABLED;
        }
    }
}

```

I tried to call function hook\_block\_view it is not called instead hook\_block\_view\_alter works.

---

### Issue:Saving is affecting all the blocks

```
function mymodule_submit($form, &$form_state) {
     variable_set('url_to_check', $form_state['values']['url_to_check']);
     variable_set('enable_check', $form_state['values']['enable_check']);
}

```

hook\_form\_FORM\_ID\_alter()

```
$form['visibility']['mycustom'] = array(
  '#type' => 'fieldset',
  '#title' => t('ConnectCheck'),
  '#collapsible' => TRUE,
  '#collapsed' => TRUE,
  '#group' => 'visibility',
 '#weight' => 20,
);
$form['visibility']['mycustom']['enable_check'] = array(
  '#type' => 'checkbox',
  '#title' => t('Show block only when user can connect to internet'),
  '#default_value' => variable_get('enable_check', FALSE),
);
$form['visibility']['mycustom']['url_to_check'] = array(
   '#type' => 'textfield',
   '#title' => t('Url to check'),
   '#maxlength' => 90,
   '#default_value' => variable_get('url_to_check', 'www.google.com'),
   '#states' => array(
     'visible' => array(
        'input[name="enable_check"]' => array('checked' => TRUE),
    ),
  ),
);

```

I am trying to disable the block which requires to connect internet. It should disable to only those user who do not have internet access.

# Answer
> 1 votes
Assuming you've set the variable using the `variable_set()` function, you can get the value using the `variable_get()` function.

From the docs:

> Returns a persistent variable.
>
> Case-sensitivity of the variable\_\* functions depends on the database collation used. To avoid problems, always use lower case for persistent variable names.

In your case the `foreach` loop would become :

```
foreach ($blocks as $key => $block) {
  $enable_conectivity = variable_get('enable_conectivity', TRUE); // Default value of `TRUE` is returned if the variable is not set.
  if($enable_conectivity) {
    $blocks[$key]->visibility = BLOCK_CUSTOM_DISABLED;
  }
}

```

---
Tags: blocks
---


# Question
Title: How to avoid duplicate entries when changing the text inside t() function in Drupal 7
I am using t() function in modules and templates. But when I need to correct the original English text, I find that I have two rows in the database (I manage it through i18n translating interface manager). One is the original text and the other the corrected one. I delete the old one and translate the new one. Is this the standard procedure? Could there be a better way of translating, for example with a module based on numerical ID or something to avoid duplicate or obsolete strings?

# Answer
> 0 votes
I think there is not a better way, because all those strings are stored/returned in the database as the code is being read out.

I think there is no way to know if they are actually exists in code to be used or not.

# Answer
> 0 votes
Thanks for your reply. I find the method very strange, but in any case an ID method would be rather difficult to handle. Maybe a mixed approach - ID with English string, so you do not change the ID but the string is changed instead. I remember doing something similar in a custom translation manager for a proprietary E-learning platform and it was very easy to translate, including a system to automatically show translation pending strings both in the database and in the pages themselves (graphically). But it was all in raw PHP, nothing to do with Drupal.

# Answer
> 0 votes
Well, I remind that we entered the strings via admin first, and then with the returned ID we wrote the code. In that way it is better to manage, and you can add a keyword to the parameters of the code in order to remember which string the ID refers to.

---
Tags: i18n-l10n
---


title: Error during Taxonomy CSV import

text:
# Question
Title: Error during Taxonomy CSV import
I am using the Taxonomy CSV import/export module to import and export taxonomy from my local installation to a fresh install on the staging. I export it on local, and import it using the same settings on staging. However, for each entry it imports, it throws an error:

> Notice: Undefined variable: format in \_taxonomy\_csv\_vocabulary\_import\_process() (line 421 of /var/www/vhosts/example.com/drupal-7.34/sites/all/modules/taxonomy\_csv/import/taxonomy\_csv.import.api.inc).

However, the import is successful. Does anyone else encounter this? Is is safe to ignore it?

# Answer
This notice is a known issue. You can solve it by implementing one of these patches: https://www.drupal.org/node/1535942 or https://www.drupal.org/node/2196065

If you do not know how to apply a patch, follow these instructions: https://www.drupal.org/patch/apply
> 3 votes

---
Tags: 7, taxonomy-terms, migrations, importing-exporting
---


# Question
Title: I want to add a field in drupal commerce products by default like commerce_price?
I want to add some default fields whenever new product types are added like we have for commerce\_price field in drupal commerce.
I already have a field\_abc\_attribute(widget is select list and field type is
option\_set\_reference) added which in one of the product type
I was checking through hook\_fields\_extra\_fields() function but it did not create new fields on How can I achieve it?

```
function custom_module_field_info() {
  drupal_set_message('jsdfsdfsdfsd');
  return array(
    'field_product_attribute_val' => array(
      'label' => t('Product Attributes'),
      'description' => t('This field product attributes.'),
      'settings' => array(),
      'instance_settings' => array(),
      'default_widget' => 'commerce_option_set_reference_select_list',
      'default_formatter' => 'commerce_option_set_reference_form',
 //     'property_type' => '',
   //   'property_callbacks' => array('commerce_price_property_info_callback'),
     // 'default_token_formatter' => 'commerce_price_formatted_amount'
    ),
  );
}

function commerce_module_field_extra_fields() {
  $extra = array();
  drupal_set_message('nerer');
  foreach (commerce_product_types() as $type => $product_type) {
    $extra['commerce_product'][$type] = array(
      'form' => array(
                      'field_product_attribute_val' => array(
                                     'label' => t('Product Attribute For Vendor'),
                                     'description' => t('Product Attribute Field For Vendor form element'),
                                     'weight' => -10,
                      ),
      ),

      'display' => array(
        'field_product_attribute_val' => array(
          'label' => t('product attribute vendor extra'),
          'description' => t('The product attribute vendor extra of the product'),
          //      'theme' => 'commerce_product_sku',
          'weight' => -10,
        ),
      ),
    );
  }
  return $extras;
}

```

# Answer
The hook you're trying to use is unrelated to Field API fields, unfortunately. You should look at the commerce\_product.module and commerce\_product\_ui.module files to see how I did it in core for the default price field. Either on module enable or when a new product type is created via the UI, I call the commerce\_product\_type\_configure() function that in turn adds the default price field to the product type. You'll want a similar function that you can invoke when a module is enabled or on hook\_commerce\_product\_type\_insert() to add your custom fields.
> 3 votes

---
Tags: 7, commerce
---


title: Double Wide Views Table

text:
# Question
Title: Double Wide Views Table
I have a table listing that shows the Item # and a View/Print/Download link to open a PDF datasheet in a new tab. Right now I have like 3 or 4 in the system but in time I will have like 700-800 of them and the columns take up less than half the width of the page and although I have been looking I can't find a way to create two columns

I don't care whether the data goes

```
CH098 View     CH099 View
CH100 View     CH101 View
CH102 View     CH103 View

```

or

```
CH098 View     CH101 View
CH099 View     CH102 View
CH100 View     CH103 View

```

Does anyone know if there is a module for views that I missed that can do this?

# Answer
Since you're using *Views*, you've got everything you need. You just need to set the Display Format to Grid, and set it to Show Fields, as in the following example from editing a view.

And to display more than one field in each Grid "cell", you will need to add a `Global: Custom Text` field to combine the fields for display. (Change the *Content: Title* and *Content: Link* fields used in these example to your fields.)

See the Image of *Custom Text Settings* (below) for an example of how to combine the fields. The Replacement patterns shows the fields available to be combined.

In the settings for each field, set *Content: Title* and *Content: Link* fields to be excluded from display, and set the *Global: Custom text* to NOT be excluded.

Oh, yeah... these images are from Views 3.x.

**View settings:**

Click the `Settings` link next to 'Grid' to set the 'Number of columns'. You can also set the display Alignment to Horizontal or Vertical.

**Grid settings:**

**Global Custom Text selection:**

**Custom Text Settings:**
> 0 votes

---
Tags: views
---


# Question
Title: Can we add a new column to field collection in edit form?
I created a topic before with this question, but i write another to be more exact on what i want to do. I have an entity with several field collections and in this field collections, several fields (text, checkbox, entity ref...). When i open the form in **EDIT** mode, i want to add a new column to my field collection and in this column i would add a simple link to go to another page. So in my other topic we told me to use "link" module but it's not working on EDIT form but just in VIEW mode. So i searched how to add a column programmatically in drupal. I tried in my HOOK\_form\_alter to alter the form but i can't...

I can add a new column with jQuery i think but that won't be the best solution.

Someone got an idea ?

Thanks

# Answer
> 0 votes
It sounds like hook\_form\_alter is the way to go.

See this for more information

See both answers because i think that waht you want to do is just add another tab at the end of the node edit form for just a link to another page.

You can always check the form api for more information

---
Tags: forms
---


# Question
Title: Linking to a php site located in a subdirectory of the Drupal site
So I've taken part in a very interesting Drupal project that has a multilingual Drupal 7 site and three sub-sites (all using the same domain) in sub-directories of the main Drupal site. So it's kind of like this:

```
http://example.com <- main Drupal site
http://example.com/site1 <- php site that doesn't use Drupal
http://example.com/site2 <- php site that doesn't use Drupal
http://example.com/site3 <- php site that doesn't use Drupal

```

Now I can create relative links to these sites on the Drupal site by adding links like

```
<a href="site1">Site 1</a>

```

And that works when I'm on the homepage, but since this is a multilingual site, any other page I go on uses a language prefix on the URI like this:

```
http://example.com/en/contact

```

If I try to click on the Site 1 link I made above while on the contact page, it takes me to:

```
http://example.com/en/site1

```

and displays a 404 error.

Currently, the site uses hard-coded absolute links to get around this issue, but it's becoming a real pain to use this in our local and testing environments and I've been asked to remove the absolute urls from these links.

I've tried a few different things like using Token Filter with \[site:url\]/site1, but it still tries to add the language prefix and gives me the same 404 error. I thought of trying to use a module to look for these specific links and set them accordingly, but I can't think of an efficient way of doing it. Other ideas like using JavaScript to edit the links after the page loads or redirecting to the right page just smell so bad I don't want to try them.

Any ideas on how I can create links to these sub-directories without hard-coding them?

# Answer
> 0 votes
Well, I ended up going the JavaScript approach. I don't know how to get around using absolute links to the subsites without doing something pretty hacky, so I created a module that adds a javascript file when NOT in the production environment. The javascript searches all links for hrefs with the production domain and changes them to use the current page's domain.

Hence, in production the module does nothing, but in any other environment it replaces the absolute links.

Not optimal, but a workable solution for my case...

---
Tags: i18n-l10n, navigation, subsites
---


# Question
Title: Are there any Drupal 7 modules for creating organizational charts?
Are there any Drupal 7 modules for creating organizational charts? So far I have only seen one for Drupal 6.

Any solution you might have used to incorporate organizational charts in Drupal 7 will be appreciated.

# Answer
> 2 votes
The Google Charts module for Drupal 7 now has support for organizational charts.

# Answer
> 0 votes
Views Org Chart module for drupal 7 is good for building organizational charts. Various relations can be established and also support of custom queries!\[Sample Output Of Google Organization Chart\]. https://www.drupal.org/project/views\_org\_chart

---
Tags: 7, charts
---


# Question
Title: How to get a field with a relationship in a view
I have a design where a `car` belongs to a `brand` and let's say a brand belongs to a`category`, using entity reference module I was able to display the brand in the car view, but I don't know how to display the category, I tried to set the relationship but it does not seem to work.

# Answer
Follow this steps:

1. Add a relationship of `brand` to the view. This will get you to display the properties and fields of the `brand` entity.
2. Add another relationship for the `brand` field which references to the `category` entity using the entity reference field. This relationship should use the previous relationship (like nested relationships).
3. Now you should be able to display the properties and fields of the `category` entity as well.

**Note:** I've written this generically; it should work for any type of entities (e.g. Nodes, Users, Files, Taxonomy, etc.)
> 2 votes

---
Tags: views, entities
---


# Question
Title: Load single value from multiple value image field in View
I am trying to load a single value from a multiple value image field in View. I am adding the field with a restriction to print only a single file. I am also filtering by delta(=0). Check the settings in the attachment.

However the view is loading all images attached to the field. How can I load only the 1st one?

# Answer
Try to delete the delta field. You only need the content field and the restriction on the display values (like you did on the screenshot).
> 1 votes

# Answer
I think should be using agregation and unique option at query options inside advanced tab
> -2 votes

---
Tags: views, entities
---


title: display node's field in <table>

text:
# Question
Title: display node's field in <table>
Is it possible to display a node's field in a table? Is there any module providing it?

For example I have a node "English idioms" which has a field named: "Idiom" and "Explanation". I would like to put them both in a (table-\>tr-\>td - each).

At the moment I have these fields in div's with classes but I would like to avoid it if it's possible.

Kind regards.

# Answer
> 3 votes
You could use field\_group nad field\_group\_table

> Fieldgroup will, as the name implies, group fields together. All fieldable entities will have the possibility to add groups to wrap their fields together. Fieldgroup comes with default HTML wrappers like vertical tabs, horizontal tabs, accordions, fieldsets or div wrappers.

---
Tags: 7, nodes, theming
---


# Question
Title: Only a view filters in exposed filter block
I have a view with 7 exposed filters in an exposed filters block.

But I only want to have 2 filters in the exposed form block. All 7 filters I want to have on the views page.

Is there another solution then display: none?

# Answer
You could copy the view for your second use case and only make the 2 needed filters exposed and expose that as a block.
> 1 votes

# Answer
1. Create a new page display, this will copy all the fields and filters from the 'master' display.
2. Click on the filter you want to remove from the block display.
3. Select "This block (override)" from the top.
4. Click remove.

Refer the screenshot:

**NOTE:** I took the snapshot for the filter "This page (override)". In your case please make sure you select "This block (override) instead.
> 0 votes

---
Tags: views
---


# Question
Title: Views load the whole entity even though they only need 3 fields
I am using Views to fetch the 3 fields of a specific entity. However, this leads to the view to make a full load of the entity and all the images included in it, even though they are not displayed. This leads to loading 20 images per entity instead of 1!. How can I hook into the process and modify this. I tried almost all view's and entity's hooks but nothing seems to have an effect. Any ideas?

# Answer
> 1 votes
Are these custom entities or from a module? If they are custom you could try to override the 'query' or 'load' function in the entity controller class (defined in hook\_entity\_info() ). If it is from a contributed module, there isn't anything you can do without altering the module code.

Also please note that the actual images are only loaded when the browser requests them over http via an tag, the entity loads the fields over SQL. Agreed, this creates some overhead. But I guess you would hardly notice the difference when a few fields less are loaded.

---
Tags: views, entities
---


title: Add rows inside added row

text:
# Question
Title: Add rows inside added row
I'm trying to create content type which can be used to add Workouts. Content type has fields: Exercise, Set and Reps.

First user chooses Exercise (this is autocomplete field). Then he can add Set(s) to thise exercise (unlimited amount of sets can be added). Every Set should be added by clicking Add new row. For every set user can add reps.

Then User can add second Exercise and sets and reps to it. Etc.

See picture:

I have tried to use Multifield -module, but it does not allow multifield inside multifield.

Any suggestions how to achieve this kind of functionality?

# Answer
Install Field collection module.

Create a field of type field\_collection inside your content type with unlimited values.

Then in your field collection create a field or group of fields with unlimited values.
> 1 votes

# Answer
Have you tried Field collection module?
> 1 votes

---
Tags: 7, entities
---


# Question
Title: How can I overwrite uploaded file via Filefield?
By default in Drupal 7, if I upload image.jpg via a file field in my node, save the node and then edit that same node and re-upload image.jpg, it will name it image\_0.jpg.

I want to replace the image uploaded so I will only ever have image.jpg. How can I do this?

# Answer
As a technical exercise...programatically speaking, you would need to replace the element's `#value_callback`, currently `file_managed_file_value()`, with a custom one.

Your custom callback would invoke another custom function, a rewritten version of `file_managed_file_save_upload()`, which would then invoke `file_save_upload()` with `FILE_EXISTS_REPLACE` as the 4th parameter, as opposed to the current value of `FILE_EXISTS_RENAME`.

Real-world, you don't want to do this. As soon as someone uploads an image to a different node, it will obviously overwrite the existing one called image.jpg, and that new image will be used in place of the existing one for all other nodes.

That's why the renaming functionality exists in the first place; to avoid global collisions.
> 3 votes

---
Tags: nodes, entities, files
---


# Question
Title: Views Slideshow - How to add link on Pager that can link to original page?
Views Slideshow on Drupal 7 has a feature that can “Activate Slide and Pause on Pager Hover”. How can I add link on Pager, so when click, it actually link Pager to original piece of content?

# Answer
> 1 votes
I found out it actually can be very simple in Views setting.

1. add a "**Content:Path**" field. Set this "**Exclude from display**" and check "**Use absolute link**" on Rewrite results.
2. add another field that use for pager. I use "Content: pagericon" as my example .
3. Set this Pager field exclude from display and insert "**\[path\]**" as **Link path** Replacement patterns on "**Output this field as a link**".
4. back to the Format settings for Slideshow. Check the "**Pager**" under Top or bottom Widgets with "**Pager fields**", and check a field that use for pager. (I use "Content: pagericon" as my example)

# Answer
> 1 votes
Having a look at the views slideshow code it seems that all the sections of the views slideshow are easily themed.

In the views slideshow module there is a themes folder with template files that can be overridden.

Though there is not a template file for the pager, instead there is a function in the file `views_slideshow.theme.inc`. The function you are interested in is probably `theme_views_slideshow_pager_widget_render($vars)` and this can be overwritten.

In your themes template.php copy and paste this function and rename it to `MYTHEME_views_slideshow_pager_widget_render($vars)`, (replacing MYTHEME with the name of your theme).

You should then be able to modify it in any way you like.

---
Tags: navigation, paging, views
---


# Question
Title: How to make taxonomy terms link to an external site?
I am using the Lexicon module to automatically insert links to a vocabulary with information about words in the lexicon.

But the vocabularies I am using are owned and hosted by a completely different organisation, which means that hosting the information on my website would result in duplicated and outdated information. Therefore I need to link my terms in the taxonomy to an external site (instead of this website).

I tried using the Redirect module but it doesn't manage tokens to external websites.

My question: how to make my taxonomy terms link to an external site?

# Answer
> 1 votes
Solving this issue for me required three modules:

Link module: Creates a link field for external links. Module page Lexicon: A module that look for keywords and allow you to set up a lexicon that automatically link keywords to a page explaining them. Module page. Field Redirection: A module that allow you to create pages that automatically redirect the user to a different page. Module page.

1. Install the modules and activate them.
2. Go to Manage fields of the vocabulary you wish to use for external links (structure--\>taxonomy--\>\[your vocabulary\]--\> Manage fields). Add a link field to the vocabulary and set it's format to "redirect" (this is described in the documentation of the Field Redirection module).
3. Go to Manage display and hide all other fields (also according to FR module instructions).
4. Now it is time to set up the Vocabulary. Go to configuration--\>system--\>lexicon settings. Under the General tab, check "Link terms to the taxonomy term page" and uncheck the options that will make several terms appear on the same page (field redirection will otherwise always redirect to the link associated with the first term on the page).
5. Link targets are edited for each term in the taxonomy and you add the URL in the "Link" field of each term.

Lexicon is the module you interact with to make the links appear as you want them and any issues will probably be caused by improper setup of the Lexicon. Links/Redirect Field are a small add on that transport users to external websites instead of the lexicon page created by the Lexicon module.

---
Tags: taxonomy-terms, redirection
---


# Question
Title: Delete multiple images at once from a node
I'm having an image field with option set as UNLIMITED to accept infinite images, basically deleting images in single manner is possible, but how it can be possible to delete multiple images at once from a particular node?

I've tried it by applying some logics using Views Bulk Operations and also using Editable Views, but nothing worked for me.

Any suggestion on this?

# Answer
I'm a little surprised there's nothing available to empty out a field, but in its absence you can just write your own action for VBO. Contrived (and most likely incomplete) example:

```
function MYMODULE_action_info() {
  return array(
    'MYMODULE_delete_images' => array(
      'type' => 'node',
      'triggers' => array('any'),
      'label' => t('Remove all images'),
      'behavior' => array('changes_property'),
      'configurable' => FALSE,
      'vbo_configurable' => FALSE,

    ),
  );
}

function MYMODULE_delete_images_action($entity, $context) {
  // Pick up pre-batch config entered by user.
  $foo = $context['foo'];

  // Remove all field vals. Using 'changes_property' behavior in the
  // info hook will trigger the entity to be saved, so no need
  // to do so manually.
  $entity->field_FOO[LANGUAGE_NONE] = array();
}

function MYMODULE_delete_images_action_form($context, &$form_state) {
  // Some custom context for the batch op.
  $form['foo'] = array(
    '#type' => 'textfield',
    '#title' => t('Some option'),
  );
}

function MYMODULE_delete_images_action_form_validate($form, &$form_state) {
  // Validate the submission.
  if (bar($form_state['values']['foo'])) {
    form_set_error('foo', t('Blah'));
  }
}

function MYMODULE_delete_images_action_form_submit($form, &$form_state) {
  // Ensure submitted values are passed through to the action callback.
  return array(
    'foo' => $form_state['values']['foo'],
  );
}

```

Obviously you could extend the pre-batch form to allow for a choice of which field to empty, and even make this generic to all field types with a little effort.
> 1 votes

---
Tags: 7, nodes, media
---


# Question
Title: Delete field and related data (field_delete_field, field_delete_instance)
I want to delete field from my Content Type using hook\_update and wondering how to do it in most correct way.

I know that my field is only on 1 Content Type (page).

Here is my current solution.

```
function site_deployment_update_7001() {
  $fieldname = 'field_landing_page';

  if ($field = field_info_instance('node', $fieldname, 'page')) {
      field_delete_instance($field);
  }

  if ($field = field_info_field($fieldname)) {
    field_delete_field($field);
  }
}

```

However I'm a bit confused if I need to do field\_delete\_field after field\_delete\_instance. It's because on Drupal.org says that field\_delete\_instance doing field\_delete\_field as well (with condition: condition count($field\['bundles'\]) == 0). I'm wondering about this condition, in what cases it is 0?

https://api.drupal.org/api/drupal/modules!field!field.crud.inc/function/field\_delete\_instance/7

```
function field_delete_instance($instance, $field_cleanup = TRUE) {
  // Mark the field instance for deletion.
  db_update('field_config_instance')->fields(array('deleted' => 1))->condition('field_name', $instance['field_name'])->condition('entity_type', $instance['entity_type'])->condition('bundle', $instance['bundle'])->execute();

  // Clear the cache.
  field_cache_clear();

  // Mark instance data for deletion.
  $field = field_info_field($instance['field_name']);
  module_invoke($field['storage']['module'], 'field_storage_delete_instance', $instance);

  // Let modules react to the deletion of the instance.
  module_invoke_all('field_delete_instance', $instance);

  // Delete the field itself if we just deleted its last instance.
  if ($field_cleanup && count($field['bundles']) == 0) {
    field_delete_field($field['field_name']);
  }
}

```

Please advise what are the best approach to delete field. Thanks!

# Answer
> 3 votes
As fields can be attachted to differents bundles

field\_delete\_instance deletes the field itself only when there no more bundles using it. maybe see field\_info\_field and this comment from field\_delete\_instance to clarify

So if in

```
 if ($field = field_info_instance('node', $fieldname, 'page')) {
   field_delete_instance($field);
 }

```

Applies and delete the last instance then in

```
  if ($field = field_info_field($fieldname)) {
    field_delete_field($field);
  }

```

Should be null and wont execute field\_delete\_field($field);

---
Tags: entities
---


# Question
Title: Reduce the amount of information returned from standard service actions
I have a Drupal 7 Services that my frontend call when I want to get (for example) all comments of node XYZ. All works, but I want to reduce informations that this call return (yes, from the backend). For example "hostname, mail, changed, registered\_name, signature" are all data that I don't want to return back. Other example: if I call "user/X" service path it return "password, mail" and other informations that I consider private.

So, how can I intercept and remove this data before that service module send it back to the caller?

# Answer
For user objects specifically there's `hook_services_account_object_alter()`, e.g.

```
function MYMODULE_services_account_object_alter($account) {
  unset($account->mail);
}

```

For other entity/resource types there's `hook_services_request_postprocess_alter()`, e.g.

```
function MYMODULE_services_request_postprocess_alter($controller, $args, &$result) {
  // Manipulate $result till your heart's content.
}

```
> 2 votes

---
Tags: 7, services
---


# Question
Title: admin only can log from a certain country
I want that the admin user to only be able to log in from a certain country, and that the other users that are not administrators will be able to log in from every country.

# Answer
I would use the Smart IP module (https://www.drupal.org/project/smart\_ip), you can add an extra validation on the login form that checks the country (https://api.drupal.org/api/drupal/modules!node!node.api.php/function/hook\_validate/7).

You should check if the username exists on validation, when it exists you can check it's role and when it's the administrator role you make sure only users with the IP of your selected country can log in as admins.

There might be easier ways.
> 1 votes

---
Tags: users, security
---


# Question
Title: How do I export a site without it's Node data?
I have a site with very high volumes of data (1000+ nodes per day * 3+ years and growing each day). When we need to create a development snapshot of this database it takes FOREVER to import it.

**I know this is a long shot, but is there a way to export this database without our node data? Specifically which tables can we excise?**

I know as we add more and more custom modules, more and more things will break when we do something like this. But let's say we are just using Drupal 6 core modules with CCK. Would it be possible then? If not, what would we break by doing this and could breaking it be fixed?

# Answer
Could you just export the db in a typical fashion? Via PHPmyadmin or command line?

Also, Backup and Migrate lets you choose to export table structure without data.
> 3 votes

# Answer
I actually discovered AN answer to my problem. But I won't give myself the check, because it doesn't answer the core question of "What tables can I lose if I don't care about node content?".

We found a way to copy the binary data itself. Wasn't much documentation on this method though. It DOES require you have root on the box you are working on though. Specifically what we do is:

```
# /etc/init.d/mysql stop
# cd /var/lib/mysql
# tar -czf mydb.tgz mydb
# /etc/init.d/mysql start

```

This creates a backup of the binary data itself. Then we move that tar over to our dev box and do:

```
# mysql -u root -p
> CREATE DATABASE mydb;
> QUIT;
# /etc/init.d/mysql stop
# cd /var/lib/mysql
# rm -r mydb
# tar -xzf mydb.tgz
# /etc/init.d/mysql start

```

The database won't know the difference. This GREATLY speeds up the time it takes to move very large databases from one box to another.

Hope this helps someone else. But I definitely still want an answer to the original question. Thanks to everyone who is helping!
> 0 votes

# Answer
Here is Entity relationship diagram might be helpful
https://drupal.org/node/1785994
Drupal 7 core tables:
https://www.drupal.org/node/2360815
> 0 votes

---
Tags: nodes, database, importing-exporting
---


# Question
Title: SearchApiException while retrieving config files of Solr server solr_server server
SearchAPI in Drupal7 with Apache Solr on Jetty was working ok in Windows, however when I moved the installation to Linux, I'm getting this exception in Drupal log:

**SearchApiException while retrieving config files of Solr server solr\_server server: "0" Status: Request failed: Permission denied in SearchApiSolrConnection-\>checkResponse() (line 536 of .../search\_api\_solr/includes/solr\_connection.inc).**

I can see that Apache Solr is accessible in Linux by the link: `http://localhost:8983/solr/#/~cores/drupal7`

But not accessible by Drupal Search API for the Solar service URI: `http://localhost:8983/solr/drupal7`

With the same links everything worked well in Windows. I'm not sure what permission is missing in Linux and would appreciate any insight on this.

# Answer
I found this question when I started with the same problem (in my case a Debian server we manage vs a RedHat we don't) and did not see the answer (due to how short it was). After a lot of digging I realized the problem was SELinux (which is the same given the answer I now see above).

The main reason for the puzzle was that the requests did work from command line ("wget -O - {your SOLR ping URL}" worked just fine). But we learned from a Drupal thread (https://www.drupal.org/node/1473368) that recommended to test if SELinux was running:

* sestatus
* getsebool -a | grep httpd

The reason for it to fail normally is that "httpd\_can\_network\_connect" is off. You can set it on by doing: setsebool httpd\_can\_network\_connect=1

By the way what point us in the right direction was trying to use the same API call drupal\_http\_request() on a different module. We enabled/used Aggregator to pull an RSS feed (which worked), but our call to the SOLR ping show result "-13 Permission denied" on the log.

Hope this helps as a shortcut for the next person with this issue!
> 0 votes

---
Tags: search
---


# Question
Title: How to render a field collection without default divs?
I want to output a field collection using `dl`, `dt` and `dd` tags. The collection has two fields - `field_heading` and `field_text`. I want each field\_heading to be a dt, each `field_text` to be a `dd` and to wrap the whole set in a `dl`.

I have achieved this by overriding `field--my-collection--my-content-type.tpl.php` and the `field--my-field.tpl.php` for the heading and text fields.

The problem is, a `div` is being generated on each item in the field collection (by the field collection module I believe). (`div class="field-collection-view clearfix view-mode-full"`) This div wraps the heading and text elements together. The div is therefore inserted inside the `dl` but before the `dt`. This is a problem because the `dt` needs to be a direct child of the `dl`.

Is there a way to render the field collection without this div?

**field--my-collection--my-content-type.tpl.php**

```
<dl class = 'accordion'>
<?php foreach ($items as $delta => $item){ ?>
    <?php print render($item); ?>
<?php } ?>
</dl>

```

**field--field-heading.tpl.php**

```
<dt>
<?php foreach ($items as $delta => $item){
    print render($item);
} ?>
</dt>

```

**field--field-text.tpl.php**

```
<dd>
<?php foreach ($items as $delta => $item){
    print render($item);
} ?>
</dd>

```

# Answer
> 8 votes
You need to override theme\_field\_collection\_view theme function in your template.php .

# Answer
> 1 votes
Create a file "field-collection-view.tpl.php" which you put in your theme folder

Content of the file: `<?php
 print $element['#children'];
?>`

If you'd want it to output exactly what it does now (I know that you don't), you'd have this content:

`<?php
 print '<div' . drupal_attributes($element['#attributes']) . '>' . $element['#children'] . '</div>';
?>`

---
Tags: 7, theming, entities
---


# Question
Title: How can I show selected items without exposed filters?
I have a views which contains block and page view with exposed filter with my categories/taxonomy.

This is a beginner page for my users, so I just want to Show some items before they apply any filter. For this issue; I can add a checkbox to my content-type 'this is important'

Examples: 3 node added: 1,2,3. Node2 is important and needs to Show it without applying filters or like that. If a filter applyed, other node1 and 3 will be shown.

I'm using Drupal7 and latest version of Views, CCK etc. Best regards.

# Answer
> 0 votes
Alternatively can you use "`Promoted to front page`" under "`Publishing options`" while adding content. This content will be the contents you need as important and will be visible to users.

Below that your view with exposed filter will be shown. In View "`Filter criteria`" you can `ADD` "`Content: Promoted to front page`" option to show the non promoted contents, and also exposed filters.

You can apply this logic in your content type also, if you need specific fields such as "Mark as Important", give it some Boolean value and select it in filter criteria as mentioned above. If not can be added from "`Contextual filters`".

---
Tags: views
---


# Question
Title: How to avoid script being injected into costum blocks?
I have a custom block in which I put iframe and javascript ads. I noticed that recently they are being exploited so that attackers add some script to them (i.e on custom block table). I use Full html on the blocks to be able to insert iframe and script code of the ads. All these made me feel very insecure about Drupal so I appreciate your solution to secure my site.

# Answer
> 0 votes
So if your admin account had it's password changed, I would be willing to bet the hackers gained access to your admin account somehow.

Might want to think about beefing up your passwords, for both your admin account and the box.

You definitely should make sure your Drupal install is up to date. If "Drupal Core update status" isn't "up to date" at /admin/reports/status you should look to update core. If there is ever a security vulnerability found in core, it's normally fixed very quickly and rolled out in a new version, so you should keep your core up to date.

As for ways to make your blocks more secure, one thing you might want to try is to actually move the block from being controlled by the admin to being controlled by code.

You can write a little custom module that will create blocks. You'll want to be familiar with hook\_block\_info and hook\_block\_view. Another upside to moving blocks into code is that it will increase their portability.

Also, as another general security note, you might want to take a look at Security Review, which will help point out any security flaws you might have on your site.

---
Tags: 7, blocks
---


# Question
Title: Suggested way to setup drupal to handle multiple subsites / subdomains?
Looking for some examples of folks successfully using Drupal on multiple subdomains. Is there a good way to go about using a single drupal install to manage multiple subsites like so:

* Siteone.domain.com
* Sitetwo.domain.com
* Sitethree.domain.com

Etc….

All of these subsites have separate information, but some of it could be related here and there, so having it available to each subsite would be a benefit... thinking Entities here I suppose. One database and one core to update would be ideal. Any issues with setting it up? Problems with content types or entities?

I've seen:

# Answer
> 1 votes
Have you considered using the multisite setup?

> This is particularly useful for managing the code since each upgrade only needs to be done once. Each site will have its own database and its own configuration settings, so each site will have its own content, settings, enabled modules, and enabled theme. However, the sites are sharing a code base and web document root, so there may be security concerns with multiple administrators

I've used this for setting up one codebase and then creating multisite installs of the codebase for clients who want similar websites. Multisites can be done as either subdomains (ie subdomain.domain.com) or subsites (ie domain.com/subsite). Each multisite install has its own database, and can have its own modules or theme even, but if there is core functionality you can put it in the root codebase and it will be shared across all multisites.

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


# Question
Title: Create and pre-populate a mutiple value field in field collection on new node with ajax call
This question is in the same area as a previous I asked (How to create (& pre-populate) multiple “field collection” fields on an ajax call), but with the extra level of complexity that I'm trying to alter a multiple value field **inside** the field collection.

**The Problem**

I want to add a number of field instances to a multiple value field, inside a field collection when creating a node using an ajax call.

In order to create and pre-populate a multiple value field collection, you need to change the following value in the AJAX callback and then rebuild the form.

```
$form_state['field']['--machine-name-of-field-collection--'][LANGUAGE_NONE]['items_count'] = x;

```

However inside a field collection in `$form_state`, there is no field information, only entity information. So while I can change `item_count` for the field collection I can't alter it for any of the fields inside it.

The entity also doesn't seem to be fully created because it's on a brand new node so I can't load it and edit it.

Has anyone encountered this before? How do you work with fields inside entities on forms?

# Answer
Ok so I didn't manage to solve this directly, but I did accomplish my intent behind this quesion.

The intent behind this was to pre-populate a field collection from another node on a node create form with an ajax call.

I'm still not sure how you alter the fields in a field collection on a form and I'll leave this question open in case anyone knows, however if you're looking to pre-populate field collections onto a node, then this blog post has an answer:

http://drupal.cocomore.com/blog/field-collections-exposed

And I posted an example using ajax to do this in an answer to this question (where I think it's more relevant): How to create (& pre-populate) multiple “field collection” fields on an ajax call
> 0 votes

---
Tags: 7, entities, ajax
---


title: Automatize user accounts

text:
# Question
Title: Automatize user accounts
I have a database with x users. I would like to add those accounts on my drupal database without having to recreate them one by one.

I would like to do a script mike that but i'm not really sure it would work out :

```
username = select name from mybase;
pw = select password from mybase;
mail = select mail from mybase;

drush ucrt username --mail=mail --password=pw

```

Obviously it would be a loop for every user, but i just wanted to share the idea. First of all, is it possible to do this in shell ? The database is in another server, i'm not sure i can connect and take bake information (maybe using ssh ?) Also the password is hashed in the other database, won't it generate a bad password (by hashing a hashed password). Even so, this point is not a problem, i can reinitialize their password to their login.

# Answer
> 1 votes
You can achieve this with the Migrate module. As it has a 'destination' class that deals with User imports for you.

The easiest way is to import into your database and use the 'MigrateSourceSQL' class as your 'source.

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

# Answer
> 0 votes
With https://www.drupal.org/project/user\_import you can import users from a CSV file.

Export the users in phpMyAdmin, MySQL workbench, or whatever you are using to manage the database (take a look at 'SELECT * INTO OUTFILE' if it's a lot of users).

---
Tags: users, database
---


# Question
Title: Add mail to user register with user_external_login_register
I'm creating a module that should add an external authentication server, and I'm using user\_external\_login\_register function.

The problem is that the user created with this functions does not have a "mail" attribute, and also if I try to user\_load it, the mail attribute is not present. Why?

Is there a way to add it or I've to create user in the ordinary way, by code?

I could add it on hook\_user\_insert, but the mail address is a response from a web services, called before the hook.

# Answer
> 0 votes
The function user\_save is called in user\_external\_login\_register, so you could just use hook\_user\_insert to add the info you need.

---
Tags: users
---


# Question
Title: Open login form in popup iframe? Using Colobox module?
I have the login form block in my header. I removed it and in its place to put a 'login' link.

When clicking the link I'd like a popup (iframe or inline content) to show up. When the form is submitted the popup should close and then return and refresh the parent page.

I think the colorbox module is the right module to do this but I think that my request must be a frequently request and maybe there is an easier way to do this?

Thanks

# Answer
I can confirm that the http://drupal.org/project/colorbox module is one of the easiest (and most supported) ways to have a lightbox for the login form.

There is also other benefits like being able to load AJAX content in the lightbox as well using 'colorbox-load'
> 7 votes

# Answer
You must try the Popups API (Ajax Dialogs) module.

> API for building modal ajax dialogs. Its focus is on putting forms inside of ajax popup dialogs. Current example can present pages as popups (of the lightbox type). This is amazingly useful for things like confirmation pages. And the best part is it can be applied retroactively to a page without needing to modify the generating module, and (of course) it degrades gracefully.
> 1 votes

# Answer
There is nice Ajax Login/Register module, which demo site is here: http://ajax-register.drupalace.ru/

In the demo Ajax Login/Register uses standard Ctools modal theme but you can customize it as you want.
> 1 votes

# Answer
if people are going to carry on reading this this link appears to be worth a look:

Is loading an OpenID Provider in an iframe a bad idea if the provider and RP are on the same domain?
> 0 votes

# Answer
Recommending Modal Forms -- it only depends on CTools, and it's a pretty popular module.
> 0 votes

---
Tags: users
---


# Question
Title: I need a starting pointo to write a Views Form handler to show a Bulk Operation view field in each row instead of a single button?
I have a view with a VBO field to execute a bulk operation (Get Vouchers) over nodes.

Each row has a radiobutton (I need a single selection), once you select a node you click the button "Get Vouchers" to execute the bulk operation. So far so good.

I need to show a button "Get Vouchers" in each row instead like you see in the capture below.

As Bojan Zivanovic said I need to write a Views Form handler but I need starting pointo to write it.

# Answer
VBO doesn't support that. Furthermore, in that case you probably don't even need VBO, just write a custom Views Form handler that shows the button in each row.
> 0 votes

# Answer
There may be a work around to skip coding. You may try using ButtonField module. It may call the needed rule. You will just need to add one more field to your content type and view.

Latter you may control button's visibility in node display via default content display options or utilizing context module for more advanced usability.
> 0 votes

# Answer
Any field in Views can be made into a link to another page. No need for VBO or any other module. Use the `Rewrite Results` option that is included in every field's configuration form.

The following example shows how to make a simple link to another page (using the HTML anchor (a) tag), with an href attribute that points to the desired page.

If your `Get Voucher` button just redirects to the desired voucher, then this may do the trick. Use the `Replacement Patterns` to choose the field(s) you need to build the link.

>
> 0 votes

---
Tags: views
---


# Question
Title: how to create a view that filters on different fields depending on the content type
How can I create a view that contains events and news and filters on the event date if the content is event, and the expiration date if the content is news?

I dont see where to choose both simultaneously in the filter criteria.

# Answer
You can go to 'Filter Criteria' and hit the triangle next to 'Add'. Select 'and/or, rearange' and you can change to OR instead of AND as well as add groups.
> 2 votes

# Answer
The business logic you are asking for is usually accomplished by 2 sql queries. You will want to use 2 `Views Attachments` or an sql `union` of 2 views results to generate the resultset you want from a visitors selected criteria. There are modules to join 2 views, or views attachments is a functionality of Views (core).

For the UI to appear as you want (a single Date selection widget) shared across the 2 Views you want to create a single Views Global Filter to use between these 2 Views (your site may require additional global filters, but thats up to you).

From the project page:

> Use Views Global Filter on sites that feature multiple Views. You want the views to be driven by the same filter selection, for instance a country, a date range, a search term or even proximity to a post code. These views may be on the same page or scattered across several pages on your site, however you want to offer the visitor the convenience of setting the filter for all these views only once, for instance when they first land on your site. Views Global Filter implements the picked once, operates site-wide (POOS) principle. This means you can place anywhere on your site a selection widget (drop-down, check boxes etc) to globally filter all or some of your views. When the user picks a value from the global selector, the value is invisibly passed as a contextual filter to whatever views you like, even when these reside across multiple pages. This avoids you having to duplicate filters and avoids the visitor having to re-select their choice as they go from page to page.
> 0 votes

---
Tags: views
---


# Question
Title: How can I modify the code in taxonomy feature to include terms
I have created a feature to export my taxonomy vocabulary. How can I programatically modify it to add the terms as well ?

# Answer
> 1 votes
Features can't export (and import) terms without "extension". You could use UUID Features:

> The UUID Features Integration module provides a mechanism for exporting content (nodes, taxonomy, fields) into a features module.

# Answer
> 1 votes
I always find https://www.drupal.org/project/deploy to be a reliable module to send content from one Drupal site to another. This also keeps content out of your version control.

---
Tags: features
---


title: Panopoly with no views

text:
# Question
Title: Panopoly with no views
I've just installed Panopoly 1.14 and I can't add views to my panels.

I create the view block normally without any problem; I can see the view, inside the block section, but when I try to create or edit the panel, I can't see views at all in the left side of the add-content screen where it should be.

I checked the permissions and I have all the administrative ones. What am I missing?

# Answer
> -1 votes
Go to admin/structure/panels/settings and check *Make all views available as panes*.

---
Tags: views, distributions
---


title: Configuring Modules in Install Profile

text:
# Question
Title: Configuring Modules in Install Profile
I'm working on an install profile which brings in various modules and I was curious about the proper (or popular) convention for setting global variables Right now I have two different ways of doing this:

1. In my settings.php file I set some variables directly in the $conf array:

> $conf\['var'\] = 'setting';
2. In the install function of my profile I set some variables using variable\_set:

> variable\_set('var', 'setting');

I recognize that the first one will permanently retain the setting until the php file is altered, while the other can be changed at any time.

Is there any popular opinion/convention on the method of setting these variables(in the context of using an install profile)?

Thanks!

# Answer
> 3 votes
In general using `hook_install` or `hook_enable` or a `hook_update` function in a module is prefered over hardcoding the value in `settings.php` of your drupal site.

Another option is to use the Configuration module or Features to encapsulate your database configuration to `code` to be enabled on the drupal website.

# Answer
> 2 votes
I am using settings.php for settings that are different in otherwise identical sites (staging, dev, production), so that I don't have to change the settings in the database when I sync the sites.

Some modules override database variables with settings in settings.php, like search api override.

Since settings.php is often the only site specific file, it is a handy place for making the rest of the site portable.

For an installation profile, I would set variables using variable\_set.

---
Tags: 7, distributions, drush
---


# Question
Title: Installing demo content via module.install file with Migrate module
I'm trying to import content on installation of my feature, but it's not happening. If I enable the migrate\_ui module and go and manually execute the import, then it imports fine.

The code below is from my module.install file, which was originally taken from the restaurant\_event feature of the Restaurant Distribution.

```
/**
 * Implements hook_enable().
 */
function parcel_event_demo_enable() {
  Migration::registerMigration('ParcelEventMigrateEvent');
}

/**
 * Implements hook_disable().
 */
function parcel_event_demo_disable() {
  Migration::deregisterMigration('ParcelEventMigrateEvent');
}

```

# Answer
> 0 votes
Ok, I now understand that registering a migration is only registering it, not importing it, you still have to process the import. I now call the `_panopoly_core_import_demo_content` function which executes `$migration->processImport();`

```
<?php

/**
 * @file
 * Installation file for Parcel Event Demo
 */

/**
 * Implements hook_enable().
 */
function parcel_event_demo_enable() {
  Migration::registerMigration('ParcelEventMigrateEvent');
  _panopoly_core_import_demo_content(array('ParcelEventMigrateEvent'));
}

/**
 * Implements hook_disable().
 */
function parcel_event_demo_disable() {
  _panopoly_core_rollback_demo_content(array('ParcelEventMigrateEvent'));
  Migration::deregisterMigration('ParcelEventMigrateEvent');
}

```

---
Tags: migrations, features
---


# Question
Title: Feeds with multiple Entity References per node?
I have been racking my brains on how I can import a massive database I have collected into my Drupal website.

I have collected the below data for over 3000 players so manually uploading is not an option.

Can anyone help?

**Player Content Type**

Player, Position(Term Reference)

**Season Content Type**

Season, Appearance, Substitute, Appearances, Tries, Yellow Cards, Red Cards, Club (Term Reference)

Each Player would have multiple seasons worth of data assigning to them, relating to previous seasons.

I cannot see a way in Feeds to implement this, I have tried with Entity Reference, but cannot see how I can add multiple Seasons to the same player through Feeds.

Here is some sample data.

Player - John Smith, Position - Flanker

Season - 2013/2014, Apps - 22, Subs - 10, Tries - 2, YC - 3, RC - 0, Club - York RFC

Season - 2012/2013, Apps - 12, Subs - 1, Tries - 0, YC - 0, RC - 0, Club - Leeds RFC

I have some experience with Feeds, but not when using Entity References and the community does'nt really have anything that fits my bill.

If there is a better way to structure the data then I am open to suggestions as this is just the way I logically can work it out. I just ideally do not want to have multiple fields assigned to each player in one content type like 2013\_apps, 2013\_tries, 2012\_apps, 2012\_tries etc which would be the easy route...

Thanks

Craig

# Answer
To my knowledge the solution you are looking for is not available directly through published modules.

You can find the beginning of the answering you are looking for at

http://clikfocus.com/blog/drupal-developer-tip-multiple-entity-references-using-feeds-importer

1. Create a custom target callback for your field importer. The targets array is keyed by the name of the target so it is necessary to differentiate your custom handler from the standard field handler for that entity reference field.

function my\_module\_feeds\_processor\_targets\_alter() {

```
  foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {
    $info = field_info_field($name);

    if ($info['type'] == 'entityreference') {
      $targets[$name .':custom_handler'] = array (link is external)(
        'name'        => check_plain($instance['label'] .t(' (Import multiple values into multi-instance field')),
        'callback'    => 'my_module_set_target_entity_reference',
        'description' => t(''),
      );
    }
  }
}

```
> 1 votes

---
Tags: feeds, entities
---


title: Theme Templates

text:
# Question
Title: Theme Templates
I don't have extensive knowledge of Drupal so I'm hoping I can get this question answered. Is it possible to coerce Drupal into loading a template based on a portion of a URL? For example, if a URL were constructed as http://example.com/cities/ where could be the name of any state. Is it possible to get Drupal to load a 'cities' template and ignore the name of the state? The template would deal with the name of the state and populate the page from a database that Drupal was not aware of.

# Answer
The question depends on whether you are using nodes, or want to create a custom output for your page.

If it is a custom output, then your steps will be as follows:

1. implement hook\_menu to register your new path
2. register a theme function (backed by a template) that will populate your page.
3. create the template that will print the html and data to your page
4. In your module's callback function, you read the data from your custom database, then populate a render array that takes as '#theme' key your newly registered theme, passing in the variables you read in from the database as additional theme params. You then return that render array. Optionally, you can just call theme() on your registered theme and return the resultant string.

API docs to look at:

1. hook\_menu
2. hook\_theme
> 0 votes

# Answer
First of all, you are trying to load cities in a template from a database. This isn't what templates are meant for and will even be impossible in Drupal 8.

Getting data should be done by modules. Only the layout (html, css, ...) should be in the templates.

I think the easiest way to do what you need is creating a taxonomy vocabulary 'States' (https://www.drupal.org/node/23405). Then create a content type 'Cities'(https://www.drupal.org/node/774728). Add a term reference field to your content type and be sure to select 'States' as vocabulary. Now you can create cities and 'tag' them with a state. Drupal will automatically make a page for every state with all the tagged cities.
> 2 votes

---
Tags: theming
---


# Question
Title: Content not displaying formatting - removes HTML despite settings
On any content I create the formatting shows in the WYSIWIG editor but does not show up on the rendered page. I have tried to put it into each filter format ( Full HTML, Filtered HTML, Plain text ) with no change. So to make it really clear what is happening: I create and article with the body set as

```
<span>Test Content</span>
<p>More test Content</p>

```

or

```
Test Content

More test Content

```

and save it. Upon viewing the rendered page at the node url all of my content is pushed together and the HTML tags are gone completely when viewed in the inspector

```
Test ContentMore test Content

```

Would be what I get out. The weird thing is that if I go into the editor for the content the HTML tags and/or line-breaks are still there.

url of node with issue:

http://cafemam.b.fgqa.net/node/3575

# Answer
> 1 votes
If text format is correct and filters are correct, verify that the display format of your both content types (`Article` & `Basic Page`) is not set to `Plain text` but `Default` (or `Summary or trimmed`, ...).

It is under `Structure` \> `Content Types` \> `Basic page` | `Article` \> `Manage Display` \> `Body` field (format column).

# Answer
> 0 votes
* (although mentioned) Make sure the "Text format" for the node body is set to "Full HTML"
* After that, make sure the cache is clear when viewing the saved node.
* You could also check the "Full HTML" text format here: **admin/config/content/formats/full\_html** to make sure you have access and it has the correct input filters assigned.

That should do it.

# Answer
> 0 votes
I ran into this on our new Drupal 7 install. The default of "Filtered HTML" has a very limited set of tags, including a limitation on h1..h6, which prevents headings from being displayed correctly.

# Answer
> 0 votes
You need to make it clear that the tags you don't want stripped are allowed content in the CKEditor WYSIWYG editor.

To set these variables, navigate to *Configuration → Content authoring → CKEditor* and then press edit for the profile you want to configure. Expand *Advanced options*, and type the JavaScript directly into the textfield Custom JavaScript configuration as shown in the screen shot below (disregard the first line unless you also want to set custom `format_tags`);

Below is an example (I don't allow `h1` because Drupal uses it for page headings).

**PS**: If you Google this, you'll often see the following JavaScript suggested to "fix" the disappering tags problem:

```
config.allowedContent = true;

```

Yes, it will fix the problem of tags disappearing. But it will *also* make all sorts of content allowed - which is a gaping security hole in your site if you allow untrusted users to create and edit content. Don't use this quick "fix". Use the solution that uses the `extraAllowedContent` directive to spell out exactly what shall be allowed (and allow only safe content).

# Answer
> 0 votes
There is a quick fix if you need to get the page up right away but are struggling to have the tags stay.

Select your page and edit - I am assuming you are not filtering the HTML which strips even the most basic elements by default.

1. Select the "Source" Button
2. Edit the HTML
3. Save (do not go back to view the result in the editor)

Now you can test your page from your site - the code should work. The problem is that every time you "Edit" the page the code will be removed.

I was hoping that Configuration/CKeditor/(edit full profile)/security/Full HTML -Configure ..... option would allow me to set a security group that would be able to do anything but I have not been able to get that to work.

I agree with the security concern of allowing all sorts of tags to be embedded but what if you want to load scripts? Still new to Drupal so I am open to ideas.

---
Tags: nodes, theming
---


title: ckedittor automcalliy convert <

text:
# Question
Title: ckedittor automcalliy convert <
When I copy a link and put into CKeditor (drupal)

`<iframe width="420" height="315" src="//www.youtube.com/embed/q4Rgh5JNWf4" frameborder="0" allowfullscreen></iframe>`

After I switch back `plain text` it changed to be like this:

`<p><iframe width="420" height="315" src="//www.youtube.com/embed/q4Rgh5JNWf4" frameborder="0" allowfullscreen></iframe></p>`

How can I solve this?

# Answer
> 1 votes
First put your text format to `Plain Text` mode and then paste your `<iframe>` code on the editor, now you switch back to "Full HTML" or "Filtered HTML" mode (for which your text editor is set to display).

Hope this is what you are looking for. Hope this helps. :)

# Answer
> 0 votes
Click 'Source' on CkEditor menu and paste the HTML code in source of the CK Editor and make sure to put Text Format in Full HTML mode.

---
Tags: wysiwyg
---


# Question
Title: How to migrate users from old drupal d6 site to new drupal 7 site?
I need to migrate users from drupal 6(old site) to drupal 7(new site) alongwith User Profile from Profile module

I am looking at documentation given in migrate module as follows:

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

> On Subsequent pages at After adding new migrations, or making changes to the arguments of previously-registered migrations, if you want them to be recognized by Migrate, you need to:
>
> Clear the Drupal cache, so any new classes are added to the Drupal cache registry. Perform the registration, either with drush migrate-register or by visiting admin/content/migrate/configure and clicking the "Register statically-defined classes" button.

I have created migrate\_xyz.info ,migrate\_xyz.module and migrate\_xyz.migrate.inc files As mentioned above when I move to admin/content/migrate/configure i get a blank screen

Is this the right way to go for migrating users from drupal 6 to drupal 7? Or should I use some other module like migrate\_d2d

# Answer
> 1 votes
Check this article . It describes how to use migrate module and it's API. Code from this article:

First of all we need to create module by adding folder with name my\_migration adding my\_migration.info and my\_migration.module files. So lets start, code below will have a lot of comments:

```
//my_migration.info file

name = "User Migrate"
 description = "Migration of data from Drupal 6 to Drupal 7"
 package = "Custom Migrate"
 core = 7.x
 dependencies[] = migrate
 dependencies[] = migrate_extras
 dependencies[] = field
 dependencies[] = file
 dependencies[] = text
 dependencies[] = path
 dependencies[] = taxonomy

 files[] = includes/users.inc

//my_migration.module file
// this file can be empty but we will define some constants
<!--?php /*
 * Define some constants to use in class
 */
define("SOURCE_DATABASE", 'd6_latest'); // Put drupal 6 db name you should also add settings to settings.php
define("CONNECT_NAME", 'migrate');// name of connection to drupal 6 db in settings.php
define('SOURCE_TERM_GARDEN_CAT', 3); // When we will migrate terms we will use it.
define('SOURCE_URL', 'http://path_to_drupal6.site');
define('MIGRATE67_SITE_DIRECTORY', 'public://');

//my_migrate_migrate.inc you should name this file as module_name_migrate.inc
// if not your migration won't be autoloaded.
<?php

/**
 * Implements hook_migrate_api().
 */
function my_migrate_migrate_api() {
  $api = array(
    'api' =?--> 2,
    'migrations' => array(
      'MfUserMigrate' => array('class_name' => 'MfUserMigrate'),
    ),
  );

  return $api;
}

//my_migration/users.inc

<!--?php /**
 * User migration class to migrate users.
 */
class UserMigrate extends Migration {
  public function __construct() {
    parent::__construct(MigrateGroup::getInstance('UserMigrate'));
    // Select fields from the Drupal 6 user table.
    $query = Database::getConnection('default', CONNECT_NAME)
      -?-->select('users', 'u')
      ->fields('u', array('uid', 'name', 'pass', 'mail', 'created', 'access',
        'login', 'status', 'picture', 'init'));
    // This is supposed to get roles not sure how.
    $source_fields = array(
      'uid' => t('User ID'),
      'roles' => t('The set of roles assigned to a user.'),
    );
    // Set source and destination.
    $this->source = new MigrateSourceSQL($query, $source_fields);
    $this->destination = new MigrateDestinationUser(array('md5_passwords' => TRUE));
    // Set up database maping.
    $this->map = new MigrateSQLMap($this->machineName,
      array(
        'uid' => array(
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'description' => 'D6 Unique User ID',
          'alias' => 'u',
        )
      ),
      MigrateDestinationUser::getKeySchema()
    );
    // Add simple field mappings
    $this->addFieldMapping('is_new')
      ->defaultValue(TRUE);
    $this->addFieldMapping('uid', 'id_to_preserve');
    $this->addFieldMapping('name', 'name')->dedupe('users', 'name');
    $this->addFieldMapping('pass', 'pass');
    $this->addFieldMapping('mail', 'mail')->dedupe('users', 'mail');
    $this->addFieldMapping('language')->defaultValue('');
    $this->addFieldMapping('theme')->defaultValue('');
    $this->addFieldMapping('signature')->defaultValue('');
    $this->addFieldMapping('signature_format')->defaultValue('filtered_html');
    $this->addFieldMapping('created', 'created');
    $this->addFieldMapping('access', 'access');
    $this->addFieldMapping('login', 'login');
    $this->addFieldMapping('status', 'status');
    $this->addFieldMapping('picture')->defaultValue(0);
    $this->addFieldMapping('init', 'init');
    $this->addFieldMapping('timezone')->defaultValue(NULL);
    $this->addFieldMapping('roles', 'roles');
  }
  // Set up Roles.
  // massage the user roles before saving
  public function prepareRow($current_row) {
    $source_id = $current_row->uid;
    $query = Database::getConnection('default', CONNECT_NAME)
      ->select('users_roles', 'r')
      ->fields('r', array('uid', 'rid'))
      ->havingCondition('r.uid', $source_id, '=');
    $results = $query->execute();
    // add the anonymous role for everyone
    $roles = array('1' => '1');
    foreach ($results as $row) {
      // adjust the old to new role id's
      // Editors (rid 7) need role id 4
      if ($row->rid == 7) {
        $roles['4'] = '4';
      }
      elseif ($row->rid == 4) {
        // producer from 4 to 5
        $roles['5'] = '5';
      }
      elseif ($row->rid == 5) {
        // blogger from 5 to 6
        $roles['6'] = '6';
      }
      elseif ($row->rid == 8) {
        // freelancer 8 to 7
        $roles['7'] = '7';
      }
      else {
        // Collaboraters are role id 5 in both old and new dbs
        $roles[$row->rid] = $row->rid;
      }
    }
    $current_row->roles = $roles;
    return TRUE;
  }
} // close the ourUserMigration class

```

---
Tags: migrations
---


title: How do I translate quicktab headings?

text:
# Question
Title: How do I translate quicktab headings?
I am a newcomer to Drupal. I am developing a website with multilingual support and I have translated most of the contents, blocks etc. but wasn't able to translate the Quicktab tab title.

I am using i18n, languageicons and languagedropdown modules for this purpose. How do I translate Quicktab tab title?

# Answer
> 3 votes
1. Ensure you have downloaded (if needed) and enabled the 'Locale', 'Internationalization', 'String translation' modules
2. Go to Configurations \> Translate Interface \> Strings (Tab) (`admin/config/regional/translate/i18n_string`)
3. Check the 'Quicktabs' checkbox under the 'Select text groups' heading, and click 'Refresh strings'
4. Go to the page where it the quick tabs is and refresh it a few times (normally, you **WOULDN'T** need to do this, but for me, if I didn't and it's not cached, it doesn't work)
5. Go back to Configuration \> Translate Interface \> Translate (Tab) (`admin/config/regional/translate/translate`) , and search, using the 'String contains' input box, for ***one of the tab titles***. I.e. if your tab titles are 'Apples', 'Oranges' and 'Pears', search for 'Apples'.
6. You should be able to see an entry. Click 'edit' and translate away!

# Answer
> 0 votes
In Drupal 7, you can achieve it by using **LOCALE module**

Steps

* After installing and configuring **Locale module** go to *admin/config/regional/translate/translate*
* Search for your **TAB heading** by clicking **FILTER** button and translate it to your corresponding language by editing it.

Note :

If the TAB heading is render using t() function, then only you can able to find the string and translate it.

---
Tags: i18n-l10n, blocks
---


# Question
Title: Drupal Content Updates Not Visible to Public Without Login Attempt
New to Drupal picking up an existing prototype site design from another newbie.

Installed version = 7.28

Whenever I make any updates to contents or even site name and tagline, as Administrator I see the updates listed as "published".

If I log out and reload the web page, it does not display any of my updates, until I click the user login button on the homepage. (The button was part of the existing Homepage design.) It does not matter whether the login attempt authenticated or not, the web page would refresh and the updated content loads and displays correctly. However, without the login attempt, the site content remains at the revision before the last update, same behavior whether browsing in Firefox or IE.

The permissions for viewing contents is enabled for Administrator, Authenticated User, and Anonymous User. The Drupal site seems to treat an unauthenticated log in attempt to be an Anonymous User. What about when the site URL is entered in the browser, and the public is viewing the site? What is the "role" of the viewer of the site before a login attempt is made?

Where is the site content being pulled from to display in browser when the site URL is first loaded?

Where is the site content being pulled from after a login attempt?

Thanks for any help to point me in the right direction to debug this!

# Answer
> 1 votes
> The Drupal site seems to treat an unauthenticated log in attempt to be an Anonymous User

Correct; an anonymous user *is* unauthenticated.

> What is the "role" of the viewer of the site before a login attempt is made?

"anonymous user"

> Where is the site content being pulled from to display in browser when the site URL is first loaded?

Either the database or your cache store.

> Where is the site content being pulled from after a login attempt?

Ditto - database or cache, depending on your setup, whether caches have been primed for the particular cache id, etc.

It sounds like you simply have page caching enabled for anonymous users. Clear Drupal's caches and see if the problem persists.

---
Tags: users
---


# Question
Title: Drupal 7 Megamenu Construction Using Views in Menu and a menu module?
Currently I need to construct a responsive Megamenu and so far I have narrowed down that I need **menu\_views** (https://www.drupal.org/project/menu\_views) to output the megamenu items as each dropdown will contain a bunch of recent nodes relating to the sub menu items.

I've been using **responsive\_menu** for my menu, but apparently its not compatible with **menu\_views** as it doesnt output the views in the menu.

It's either I code this responsive menu from scratch, but I rather not if there is a solution for this already that can get me more than 50% of the way there.

Now my question is, what menu modules would make it compatible with "menu\_views"? Or maybe another solution all together. I know about tb\_megamenu, but that module seems to have alot of bloat with bootstrap built right into it.

# Answer
> 0 votes
I would try the Superfish module. The Menu Views module page states it should be compatible with the current stable release of Superfish.

Superfish is also responsive out-of-the-box (based on user agent or window width).

---
Tags: 7, routes, navigation
---


# Question
Title: How can I build a subscription product selling system with drupal commerce
I'm creating an Drupal commerce website, I want to sell subscription to internet via satellite service. Sincerely I'm confused and I don't know what modules I should to use for this kind of product.

# Answer
> 0 votes
After days of trying modules and searching, I found this module Commerce License:

> Provides a framework for selling access to local or remote resources.
>
> In practice, this means that there’s a license entity, usually created during order checkout, that holds information about accessing the purchased resource, and it has a status and an optional expiration date. This allows selling access to anything from files to node types, or perhaps ZenDesk tickets and accounts on remote sites, all using a common API, while always having a record of the purchased access for the benefit of both the store administrator and the customer.

And a helpful explanation in this screecast:Tech Talks - Commerce License .

# Answer
> 0 votes
Check Commerce subscription products module.

> Features
>
> * Sell subscriptions via products.
> * Administers can view and customize the subscription validity per user if they have necessary field permissions.
> * There are two "rule sets" (Subscription starts, Subscription ends) that make customizing the subscription easy, e.g. one could easily add rules for granting/removing a user role.
> * Subscriptions expire automatically once the validity time is reached thanks to the Rules Scheduler (requires cron to function).
> * Views integration, as the subscription validity date is implemented as account field.
> * Custom notifications like "Warning: Subscription expires in 2 weeks" can be easily configured using Rules and the Rules Scheduler.

---
Tags: commerce, notifications
---


# Question
Title: Is there any way to check user activation link has been sent
I have created user by profile-2 module with some certain roles,Initially user is in block state,there is one user manager that approved this user and send activation link by email.so how to check activation link already sent or not. if link already sent then need not send again. For this Is there any module or custom code. Please help me if anybody knows this.

# Answer
> 1 votes
* Use **Mail Logger** module. It simply logs all outgoing emails into a database table.
* You can view the logged emails by going to the `Reports -> Outgoing` Mail log entries page.

---
Tags: users
---


title: How to create simple 'subsites'?

text:
# Question
Title: How to create simple 'subsites'?
I am creating a site for a company, which has multiple departments. Each department shall have a departments (sub/branch) site. Within each department site, there will be users of different roles, such as editors, approvers, administrators etc. - each only allowed to edit content in its own branch site.

Apart from this permission, everything else will be the same - they will share the same theme and templates, content types, modules, workflow logic etc. *Only the permissions need to be different*

**How to create these simple 'subsites'?**

Here are the options in my head right now:

1. Using Organic Groups - a very steep learning curve (many settings) and seems like overkill
2. Subsites - requires additional databases, and installs
3. My idea - 1) Create a vocabulary containing all departments. 2) Create a content type for each content that will appear on any of the department sites. In the content type, have a field which allows the user to select the department (from taxonomy) to publish this under. However, I'd have to limit so that the user can only select the departments they are under

I am inexperienced and so do not know the potential pitfalls of choosing any of the options, anyone can give me some pointers?

# Answer
Have a look at the domain access module.

I think it is what you're looking for.
> 0 votes

---
Tags: taxonomy-terms, nodes, users, organic-groups, subsites
---


# Question
Title: What to do when there are defined constans in a module and you need to change it
I have installed a module. In the module there are no configuration options. In the code of the .module, there is a cache time which is set to 20 minutes, in a constant. I need to refresh the data printed by the module with a cache of less than a minute (say seconds). The only solution I have found is to manually change the code and put a value define ('THIS\_MODULE\_CACHE\_LENGTH', 0.1); //-- cache for 6 seconds. Is there another way of doing? Is it a bad designed module? (I do not mention the name if that is the reason). Please advice, because I am worried that with an upgrade to the module I will obviously loose the performance and will recover that excesive 20 minutes times (the module is for content which can upgrade very frenquently, so I do not understand the 20 minutes). Thanks!!

# Answer
> Is there another way of doing?

Depends where it's used. If the use is hardcoded into a function that doesn't offer any altering, then no, there's no other way other than a hack to change it.

Constants are constant, if they could be changed then they wouldn't be constant any more; if someone has used a constant they should have had a very good reason for doing so. So it's up to you to decide whether you trust the knowledge and design decision of the author. If you don't, don't use the module. Or change it to what you know is correct or reasonable.

At the very least, open an issue to ask the maintainer why they've hardcoded that value. There may have been a very good reason.
> 1 votes

---
Tags: 7
---


title: Access Denied for password reset page

text:
# Question
Title: Access Denied for password reset page
I am trying to redirect user to edit profile page after accessing the password reset link, code looks like

```
function mymodule_reset_menu_alter(&$items) {
  // Drupal's default behavior is to show the user a log-in form before
  // their user profile.  We replace this item to skip the uneccesary step.
  $items['user/reset/%/%/%'] = array(
    'title' => 'Account settings',
    'access callback' => 'simple_pass_reset_pass_reset_access',
    'access arguments' => array(2, 3, 4),
    'page callback' => 'test',
    'page arguments' => array(2, 3, 4),
    'type' => MENU_CALLBACK,
  );

}

function test($uid, $timestamp, $hashed_pass, $option = NULL) {
  global $user;
  // Show the user edit form instead of silly one-time login form.
  $account = user_load($uid);
  $user = $account;
  $token = drupal_random_key();
  $_SESSION['pass_reset_' . $user->uid] = $token;
  drupal_goto('user/' . $user->uid . '/edit', array('query' => array('pass-reset-token' => $token)));
 }

```

while test() is callback for menu 'user/reset/%/%/%'.

The issue is when the user access the link for first time user gets "Access Denied" for second time user successfully redirects to edit profile page with password reset option. I think issue must be in the way the token is generated as it is the only thing which changes, but have no clue on how to fix this.

# Answer
> 4 votes
Drupal has an option to just login using the user reset link. When you add */login* after the reset link the user is logged in directly and redirected to their their profile page.

# Answer
> 1 votes
After new information, what I have done:

1. installed simple\_pass\_reset module and enabled it.
2. putted your code in my custom module.
3. generated reset link for the user, something like this user/reset/1/1421238775/nyUMDVFKAizcXsjVFNsZQcUdh6Y3CG9TdbEzFaZnyJQ/login
4. this link redirected me to user/1/edit?pass-reset-token=Nock8yzQbSa8Sp8EC2JwtjPzDwv3vwPiGAyPyp0l\_os

it works because drupal have default behavior when we add /login to reset link, it won't redirect without it

---

After some investigation

it will work like this without /login if:
\- disable simple pass reset module
\- change code

```
function adyax_ajax_menu_alter(&$items) {
  // Drupal's default behavior is to show the user a log-in form before
  // their user profile.  We replace this item to skip the uneccesary step.
  $items['user/reset/%/%/%'] = array(
    'title' => 'Account settings',
    'page callback' => 'test',
    'page arguments' => array(2, 3, 4),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
}

function test($uid, $timestamp, $hashed_pass, $option = NULL) {
  global $user;
  // Show the user edit form instead of silly one-time login form.
  $account = user_load($uid);
  $user = $account;
  user_login_finalize();
  $token = drupal_random_key();
  $_SESSION['pass_reset_' . $user->uid] = $token;
  drupal_goto('user/' . $user->uid . '/edit', array('query' => array('pass-reset-token' => $token)));
}

```

---
Tags: 7, users
---