# Question
Title: How do I set Views Bulk Operations Fieldset Collapsed by default?
Using VBO, I am trying to set the Operations Fieldset to collapsed by default. Is there a setting to do this? or a theme override that I can use per view?

# Answer
Use hook\_views\_bulk\_operations\_form\_alter()

```
<?php
function mymodule_views_bulk_operations_form_alter(&$form, &$form_state, $vbo) {

 if($form['#form_id'] =='views_form_block_id'){

  $form['operations_fieldset']['#collapsed'] = TRUE;

 }

}
?>

```
> 7 votes

# Answer
You can do this in a hook\_form\_alter():

```
<?php
mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'views_bulk_operations') { // inspect your form in your browser to get the actual ID; it's in a hidden element at the bottom of the form.
    $form['operations_fieldset']['#collapsed'] = TRUE;
  }
}
?>

```

This assumes the fieldset's name is "operations\_fieldset". You should install the devel module (drupal.org/project/devel) and then do a `dpm($form)` inside the `if()` statement in the code above to see what the form's elements are named.

More info on the 'fieldset' form element: http://api.drupal.org/api/drupal/developer!topics!forms\_api\_reference.html/7#fieldset
> 2 votes

# Answer
I had to use this to get this to work in 7.x-3.2

```
<?php
function mymodule_views_bulk_operations_form_alter(&$form, &$form_state, $vbo) {
  if($form['#form_id'] =='views_form_[view_machine_name]_[view_display_type]'){
    $form['select']['#collapsible'] = TRUE;
    $form['select']['#collapsed'] = TRUE;
  }
}
?>

```

If you want it to apply to all bulk operations forms then just remove the $form\['form\_id'\] condition.
> 1 votes

# Answer
For all who googled this with a similar question: We have an issue to change the fieldset to **un*\*collapsible in VBO which might need some help.

Until we have that i rolled a sandbox module for this, based on Ryan G's snippet, but incorporating the API changes which happened since then.
> 0 votes

---
Tags: views
---


title: Alternatives to Nodequeue?

text:
# Question
Title: Alternatives to Nodequeue?
Are there any other modules that can implement the same functionality as Nodequeues i.e, making a customized list of selected nodes? I think I might be having some problems which might be related to it's permissions (I'm not sure of it as I'm still novice at Drupal). Maybe it's because it is still in beta phase for D7, I don't know...

# Answer
All about that matter here.

Current options are:
> 7 votes

# Answer
You can use the flag module to do something similar, and if you combine it with Draggable views and Flag weights you can re-order them. Just define a flag for each node queue you want to use.
> 4 votes

# Answer
I have replaced NodeQueue usage with Entity Collection. It's both entity and storage backend agnostic, as well as plays well with exportability.
> 1 votes

# Answer
I would also like to add Entityqueue to the list as well.

> A rewrite of Nodequeue for Drupal 7 based on entities.
>
> The Entityqueue module allows users to create queues of any entity type. Each queue is implemented as an Entityreference field, that can hold a single entity type.
>
> For instance you can create a queue of:
>
> * Nodes
> * Users
> * Taxonomy Terms
>
> Entityqueue provides Views integration, by adding an Entityqueue relationship to your view, and adding a sort for Entityqueue position.
> 1 votes

---
Tags: nodes
---


title: Organic Groups Views Contextual Filters

text:
# Question
Title: Organic Groups Views Contextual Filters
We have a country based site that needs to have an unfiltered view of various content types and a filtered view per country. We have implemented the countries with Organic groups but can't seem to get the contextual filters to limit the view based on the OG name in the URL. Is there anyone that has done something like this with OG?

# Answer
Under **Relationships**, I choose "OG membership: OG membership from Node".

Then under **Contextual Filters**, I choose "OG membership: Group ID".

The last step is to select the Provide default value and choose "Type: Current OG group from context" under the **WHEN THE FILTER VALUE IS NOT IN THE URL** heading. Attached is a picture of what I mean.

Contextual Filter setup
> 6 votes

# Answer
This link helped me: http://drupaleasy.com/blogs/ultimike/2013/05/sneaky-previously-undocumented-views-feature

It says it's for overriding the title, but should still work for your scenario.
> 0 votes

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


title: Insert image tag in checkboxes list

text:
# Question
Title: Insert image tag in checkboxes list
A Form having a form element of term reference with checkboxes widget. I want to insert a image tag with each taxonomy term name,

For example here is the html of taxonomy term reference

`< div class="form-item form-type-checkbox
form-item-field-user-interest-und-24">
 < input type="checkbox" id="edit-field-user-interest-und-24"
name="field_user_interest[und][24]" value="24" checked="checked"
class="form-checkbox ajax-processed">
 < label class="option
like-taxonomy-term" for="edit-field-user-interest-und-24">-uejo
< /label>
< /div>`

so how can i insert image tag inside div tag so that its html become this

`< div class="form-item form-type-checkbox
form-item-field-user-interest-und-24">
 < input type="checkbox" id="edit-field-user-interest-und-24"
name="field_user_interest[und][24]" value="24" checked="checked"
class="form-checkbox ajax-processed">
 < label class="option
like-taxonomy-term" for="edit-field-user-interest-und-24">-uejo
< /label>
< img src="image=path" alt="image-text">
< /div>`

# Answer
> 4 votes
You should be able to add a prefix or suffix with the field. See Field Suffix in the Form API, So your code might be:

```
$form['copy'] = array(
'#type' =>'checkbox',
'#title' => t('my taxonomy term.'),
'#field_suffix' => '<img src="myimg.png" />',
);

```

You can use field\_prefix if you want it to come before.

# Answer
> 0 votes
I believe that the best option would be to use a custom module to perform a `hook_form_alter()` and add the image programmatically to the form array.

There are no exiting contrib modules that I am aware of that will do this for you, seeing as it is a very specific need that requires an individualized solution.

---
Tags: theming, forms, taxonomy-terms
---


title: Is multisite a good option?

text:
# Question
Title: Is multisite a good option?
I am a single developer making a good few sites in drupal. At the moment I have one site working, I will be using the same modules for the next few but different theming. Is multisite a good option even though wont be sharing any content? I just want to be able to manage the sites on the one laptop, the one installation if possible & save time downloading modules again and again. All of the sites will have different domains, none of them subsites. I have been trying to get this working for weeks but am in an awful fuzzle now. Any thoughts? I tried to post on drupal.org forums but couldnt even get that working. Any help welcome..

Regards Naoimi

# Answer
I don't think you want multisite. If you're concerned about environment spinup time, create a drush make file with the modules and settings you want. You can even generate one online.

You could also use a development environment like Pantheon or Kalabox or Acquia Dev Desktop, or another distribution to get started.
> 1 votes

---
Tags: multi-sites
---


title: Passing object in routing.yml

text:
# Question
Title: Passing object in routing.yml
I have an entity and when I try to pass the whole entity object, only the name is passed through the routing.

Here is the relevant code in routing.yml:

```
mymodule.myentity_info:
  path: '/admin/config/mymodule/myentity/{myentity}/info'
  defaults:
    _content: '\Drupal\mymodule\Controller\MyModuleController::info'
    _title: 'Myentity Info'
  options:
    parameters:
      myentity:
      type: entity:myentity
  requirements:
    _entity_create_access: 'mymodule_myentity'

```

After clicking the link, I get this error: `Trying to get property of non-object`

I've added an issue regarding this to my sandbox project: https://www.drupal.org/node/2301021

# Answer
> 6 votes
What you are looking for is now called upcasting, the handbook page is https://www.drupal.org/node/2122223

I do not think `options` is necessarily for entity upcasting. For example, check the `node.type_edit` in `core/modules/node/node.routing.yml` for a routing definition not using any `options` (or `user.admin_permission` in user).

As with your previous question, I wonder whether your entity class properly defines its storage controller? If you have a debugger, the parameter conversion happens in `core/lib/Drupal/Core/ParamConverter/EntityConverter.php`

---
Tags: entities, 8, routes
---


title: CAS-protected webform does not submit

text:
# Question
Title: CAS-protected webform does not submit
I have a form that was created using Webform 7.x-4.0-rc3. The completed form submits successfully, form values are stored correctly, notification emails are generated, and the confirmation page is displayed.

I want to ensure that only CAS-authenticated users can access this form. With CAS 7.x-1.4 installed on my site, I've updated the CAS configuration and added the form page's URL to the "Require CAS login for specific pages" list. Redirection to CAS and CAS authentication work as expected.

However, the completed form will not submit for a CAS-authenticated user. By dumping $form\_state during the execution of drupal\_build\_form(), I can see that after the user completes the form and submits, $form\_state contains none of the values of the completed form and drupal\_build\_form() treats it as a newly loaded form.

Somehow the interaction with the CAS server when the authenticated user submits is causing the form to be reinitialized, but I don't know where/how.

Anyone have suggestions for how to attack this? Thanks in advance....

# Answer
> 0 votes
It sounds like your relying on CAS to provide an access check to the URL path. Webform supports limiting access to a webform by drupal Role.

If your user has authenticated via CAS and is logged into the site simply limit the webform access to users with `Authenticated Users` or any non-Anonymous user role.

# Answer
> 0 votes
tenken, thanks for your answer. My error was simple: I had not enabled automatic account creation in the Drupal CAS module configuration. With this option disabled, the authenticated user was not actually logged in to the site and the form submission was treated as anonymous.

---
Tags: 7, webforms
---


# Question
Title: Adding an active menu trail to the main ul, in the html.tpl.php?
Is there an easy way to get the active menu trail in this nav ul? I don't really understand PHP yet, I'm still learning. I personally would have setup the menu in Drupal, not in the html.tpl.php.

```
 <ul>
  <? foreach($full_menu_items as $menu_item) : ?>
  <? if($menu_item['#original_link']['has_children'] == '1') : $belowMenu = $menu_item['#below'] ?>

  <li class="<? { echo "";  } ?>">
  <div><? echo $menu_item['#original_link']['link_title'] ?></div>
    <ul class="submenu">
       <? foreach($belowMenu as $sub_menu_item) : ?>
       <? if($sub_menu_item['#original_link']['link_path']): ?>
         <li><a href="<? echo $sub_menu_item['#original_link']['link_path']; ?>"><? echo $sub_menu_item['#original_link']['link_title']; ?></a></li>
       <? endif; ?>
       <? endforeach; ?>
    </ul>
   </li>
        <? else: ?>
   <? if($menu_item['#original_link']['link_path']): ?>
   <li><a href="<? echo $menu_item['#original_link']['link_path']; ?>"><? echo $menu_item['#original_link']['link_title']; ?></a></li>
   <? endif; ?>

   <? endif; ?>
   <? endforeach; ?>
 </ul>

```

# Answer
> 0 votes
This is what I was looking for:

```
      <?php
            $tree = menu_tree_all_data('menu-mobile-menu');
            menu_tree_add_active_path($tree);
            print drupal_render(menu_tree_output($tree));

        ?>

```

So much easier / nicer. And editable in Drupal, not the tpl files.

# Answer
> 0 votes
Use menu\_tree\_page\_data to get an array of the menu items. Set the trail accordingly there.

Example: http://brightplumbox.com/30Drupal7API/#/7/4

---
Tags: routes
---


title: Upload Nodes with Image Fields

text:
# Question
Title: Upload Nodes with Image Fields
I'm using jquery mobile and phonegap for a mobile app. I have uploaded an image file and received the fid but the subsequent request to create a node and attach the fid fails. The node is created although the image field is not filled in with the fid. Also the uploaded image in ../sites/default/files doesnot have dimensions(height and width).

Post the image:

```
var filedata = {
        "file":{
          "file":imageObj['base64s'][0],
          "filename":imageObj['names'][0],
          "filepath":"public://"+imageObj['names'][0],
          "mimeType":"image/"+imageObj['names'][0].split(".")[1],
          "filesize":  imageObj['sizes'][0]

        }
    };

$.ajax({
    url: localStorage.appurl+"/api/file.json",
    type: 'post',
    data: filedata,
    dataType: 'json',
    cache: false,
    headers: {
      'X-CSRF-Token': localStorage.usertoken
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
      console.log('error '+errorThrown);
      d.reject(errorThrown);
    },
    success: function (data) {
      d.resolve(data);

    }
  });

```

Create the node:

```
$.ajax({
url: localStorage.appurl+"/api/node.json",
type: 'post',
data: "node[title]=new node&node[type]=ftritem&node[field_ftritem_images[und][0][fid]=7895",
dataType: 'json',
heders: {
  'X-CSRF-Token': localStorage.usertoken
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
  console.log('error '+errorThrown);

},
success: function (data) {
console.log("Node created");

}
});

```

Im getting this error:

Notice: Undefined offset: 0 in image\_field\_widget\_form() (line 358 of /var/www/dt11/modules/image/image.field.inc).

Notice: Undefined offset: 0 in file\_field\_widget\_form() (line 526 of /var/www/dt11/modules/file/file.field.inc).

Has anyone faced this before ? Any suggestions are highly appreaciated.

# Answer
There is a problem in Drupal core. I made an issue for it here and a patch has been supplied, but it didn't work properly for me: https://www.drupal.org/node/1912458

I did get it to work by only doing part of what the patch does.

Find line 504 of modules/file/file.field.inc and change it from this:

```
if (($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta < $field['cardinality']) && empty($form_state['programmed'])) {

```

To this:

```
if (($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta < $field['cardinality'])) {

```

I don't know if this produces adverse side effects anywhere else, but it does allow services to be used in the way you are using it.
> 0 votes

---
Tags: services, javascript
---


title: Created a Block of 'Unrelated' Nodes

text:
# Question
Title: Created a Block of 'Unrelated' Nodes
There are plenty of articles on creating 'related content views', but what I need is a view of all content tagged with different terms of a specific taxonomy.

I've tried creating a view with the Taxonomy Term ID Contextual filter set to Exclude under 'More', but I'm still getting related content.

# Answer
> 0 votes
This sounds like the same question I asked here, and for which I got a "sorry, can't do" kind of answer:

How can I show a list of terms from a specific vocabulary that are not assigned to the current node

What you'd be asking SQL to do is check every term in the vocabulary to see whether it is assigned to the current node. The performance overhead of that is potentially huge (imagine a vocabulary with hundreds of terms, and a node with just one of those terms assigned).

---
Tags: taxonomy-terms
---


# Question
Title: How to set a phone number via entity_metadata_wrapper?
I am trying to update a user programmatically in Drupal 7.

User records have multiple custom fields, configured via admin interface #overlay=admin/config/people/accounts/fields

My code sets text and datetime fields fine, but fails to update a phone number field.

Error message:

```
EntityMetadataWrapperException: Unknown data property field_mobilephone.
in EntityStructureWrapper->getPropertyInfo()
(line 335 of /Applications/MAMP/htdocs/sites/all/modules/entity/includes/entity.wrapper.inc)

```

Code:

```
  $new_user = user_save(null, $fields);

  $obj = entity_metadata_wrapper('user', $new_user);
  $obj->field_firstname->set($_REQUEST['firstname']);
  $obj->field_lastname->set($_REQUEST['lastname']);
  $obj->field_mobilephone->set($_REQUEST['mobilephone']);

```

When I do `var_dump($obj)` I can see all configured text fields in the output, but not the phone number fields.

Field type is 'phone number', provided by the cck\_phone-7.x-1.x-dev module (I couldn't find any other place where it could come from).

So question is **how do I set phone number field via entity\_metadata\_wrapper?**

# Answer
> 0 votes
I got around this problem by using the following snippet just before the `user_save(..)` call:

```
$fields['field_mobilephone'][LANGUAGE_NONE][0]['number'] = $_REQUEST['mobilephone'];
$fields['field_mobilephone'][LANGUAGE_NONE][0]['country_codes'] = 'au';

```

This approach bypasses the entity\_metadata\_wrapper altogether. Pretty sure there's a cleaner way, but I'm not yet aware of it.

---
Tags: 7, entities
---


# Question
Title: Problem file to import not found or unreadable ../../variables/_colors.scss
I'm currently using Omega 4 with Sass, compass, breakpoint, singularity.

When I run the command drush omega-guard, I have the error below. Any body know what could be the problem.

It's like there is a problem with globbing.

I'am on Ubuntu 14.04

Thanks a lot

```
error sass/layouts/header/header.layout.scss (Line 1 of sass/variables/**/*: File to import not found or unreadable: ../../variables/_colors.scss.
    Load paths:
      /var/www/vhosts/nexera.linuxlocal.com/sites/all/themes/nexera/sass
      /home/beach/.rvm/gems/ruby-2.1.2/gems/compass-0.12.6/frameworks/blueprint/stylesheets
      /home/beach/.rvm/gems/ruby-2.1.2/gems/compass-0.12.6/frameworks/compass/stylesheets
      /home/beach/.rvm/gems/ruby-2.1.2/gems/compass-normalize-1.5/stylesheets
      /home/beach/.rvm/gems/ruby-2.1.2/gems/compass-rgbapng-0.2.1/lib/stylesheets
      /home/beach/.rvm/gems/ruby-2.1.2/gems/breakpoint-2.0.7/stylesheets
      /home/beach/.rvm/gems/ruby-2.1.2/gems/singularitygs-1.1.2/stylesheets
      /home/beach/.rvm/gems/ruby-2.1.2/gems/compass-blend-modes-0.0.2/stylesheets
      /home/beach/.rvm/gems/ruby-2.1.2/gems/color-schemer-0.2.8/stylesheets
      /home/beach/.rvm/gems/ruby-2.1.2/gems/toolkit-1.3.8/stylesheets
      /home/beach/.rvm/gems/ruby-2.1.2/gems/susy-1.0.9/sass
      /var/www/vhosts/nexera.linuxlocal.com/sites/all/themes/nexera/sass
      Compass::SpriteImporter
      Sass::Globbing::Importer)

```

# Answer
> 5 votes
Change gem 'sass-globbing' to gem 'sass-globbing', '1.1.0' in your Gemfile and then run bundle install

---
Tags: drush, theming
---


# Question
Title: Why is my cart empty after I click on the "add to cart" button?
I'm trying to use the Secure Pages module in conjunction with Ubercart. The module works fine for the most part. However, there is something wrong with the https that prevents an item from going into my cart the first time. Here is my problem in detail:

1. Start on a product page which is not using https.
2. Click on the "add to cart" button. I am redirected to https://www.example.com/cart. My cart is **empty**.
3. Navigate to any other "unsecured" page, like the product page I came from. **I receive a message stating that my item was added to my cart.**
4. Go back to https://www.example.com/cart and **I find an item in the cart.**
5. Resume shopping as normal without any further problems.

What is happening in step 2? Why is my item not added to the cart until I go to a different page first? Its worth noting that no errors were reported either in watchdog or other system logs.

I attempted to fix this problem by removing the **cart** page from the secure pages list. Is there a reason the cart page should be using https?

Additional notes:

* The old D6 / UC v.2 version of my site w/ Secure Pages worked without any problems.
* I have added **$conf\['https'\] = TRUE** to my settings.php
* Refreshing the cart page immediately after completing step 2 does **not** show any items in my cart.

# Answer
I had the same issue in drupal 7. I disabled secure pages module and used .htaccess file for https stuffs.
> 1 votes

---
Tags: 7, ubercart, ssl
---


# Question
Title: Drupal best way to render content type data and meta-data
I am new to Drupal and struggling on the best approach to choose, I have several questions which are all related to my approach.

Let say I have a content type "Rooms" and would like to create 2 pages: 1 for listing the rooms and one per room (let's call that one Room A), plus I would like to add some additionnal data for the page listing rooms. Of course I need menu item when being on page "Rooms" but still need the item to be active when on page Room A.

Finally, the page Rooms not only list the room's content type but also display some static blocks which both has and has no relationship to the Room content type.Eg: an image's banner with a small description.

After doing some research, I have found several approach to do this:

1. Have a taxonomy "Rooms" with no terms and in which I classify all my rooms and add additional field for data specific such as my banner picture. I then create a basic page which I theme to call my blocks and taxonomies. The menu active trail issue is realized by taxonomy-menu trail.

Pro: it works. Cons: the logic bothers me, the purpose of taxonomy is more like a tagging system rather. Therefore I have to tag my content's instance each per each

1. I create a new content type "Banner" in which I add new fields, an image, a description... Using Node Hierarchy menu, I create a parent relationship for a basic page to a room content type, on that basic page i display all my block...

So, OK the content type is not a page it's an abstract of fields, but what if I want to display in the most efficient way data that are on higher level of abstraction of the content type and that are specific to that content type ?

What's your opinion ?

# Answer
If I have understood well, here is what I would do:

* Create a content type "Room", with specific fields and configuration (I guess you already did that).
* Create several nodes of type "Room", one by actual room.
* Create a View (using Views module) to display a list of all my nodes of type "Room" (*I can tell you more about that if you need it*) and where you can access the rooms page automatically. Of course, you can create a menu item in the same time. Very easy.
* Create a custom static block with the banner, text, or whatever you want to be displayed on your View page.
* Configure the block to be displayed only on your View page (path/to/your/view).

This is how I would have do that if I had to. I don't know if there is a better way but it seems quite logic and simple to me.

I hope it was the answer you wanted!

EDIT: I just remember the active menu item thing. I did that once in a project, it is a bit tricky but I can explain to you my method.
> 0 votes

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


# Question
Title: Upload new item (node gallery) link not showing with a user of different permission - Drupal 7
I created a new content type named "Home" which is connected to node gallery. I created a new role named "Home only" and gave permission. When I logged in as a user with role of Home only, I am not able to get the "Upload new item" link. Did I miss any permission. Please give me a solution.

I gave all "Home" Node level permission, File Entity permission, Filter permission,View the administration theme permission, Use the administration pages and help permission.

Please note: I am getting the "Upload new item" link when I logged as administrator. Also plupload is using for the bulk upload.

When I logged as "Home only" level user, I getting all the links as in the above image except "Upload new items"

# Answer
Now it worked. Previously its was beta version of node gallery. Now I changed it into Node gallery-7.x-1.0. In the permission tab i had checked "Node Gallery API". In the case of beta version of node gallery these was not showing.
> 0 votes

---
Tags: users, media
---


# Question
Title: How to trim a rendered item before and after specific symbols
I've created a field where I store the URL to an image. I need to display the filename of the image without the part before the slash and without the file extension.

> http://some.url.com/folder/this/and/that/361.jpg

should be displayed as 361

> http://some.url.com/url/folder/this/and/that/1021.jpg

should be displayed as 1021

I know that this can be handled field--field-name-of-url.tpl.php file but I wasn't able to apply the solutions I've found correctly.

I tried the regex and explode method but I don't know how to insert it into the code below.

Thanks for any help.

```
<?php foreach ($items as $delta => $item) : ?>
    <?php print render($item); ?>
<?php endforeach; ?>

```

# Answer
> 1 votes
A tip from a friend got it working. Here the solution.

```
<?php foreach ($items as $delta => $item) : ?>
    <?php
     $file_extension = substr(render($item) , strrpos(render($item) , '.') +1);
     print basename(render($item), '.'.$file_extension);
    ?>
     </p>
<?php endforeach; ?>

```

---
Tags: uri, entities
---


# Question
Title: Get Post data of a view in inside a block
I am actualy tring to get the posted data from a views filter and display it inside a custom block.

This is what my code looks like for now

```
<?php
/**
 * Implements hook_block_info().
 */
function search_block_header_block_info(){
    $block['search_header'] = array(
        'info' => t('Search Header'),
        'cache' => DRUPAL_NO_CACHE,
    );
    return $block;
}

/**
 * Define what our block is going to look like.
 * Implements hook_block_view().
 */
function search_block_header_block_view($block_key){
    $block = array();

    if($block_key == 'search_header'){ //We only want to define the content of OUR block

        dsm($_POST);
        //This is the title of the block.
        $block['subject'] = t('Search Header');
    }

    return $block;
}

```

But for some reason the $\_POST variable is always empty. Someone got a hint for me how to get the posted data?

# Answer
Try

```
$view = views_get_current_view();
dsm($view->exposed_input);

```

instead $\_POST.
> 3 votes

# Answer
**Views** always user **GET** method to pass the parameter to filter the data. So if you are checking the data in custom blocks just try getting it by the use of `$_GET['key']`

Views always user params as **Querystring** so its not the right method to get the data i think.
> 0 votes

---
Tags: views, blocks
---


# Question
Title: pager is not working on update of Views 7.x-3.7 to Views 7.x-3.8
Hi i have recently update one of project and so views module also updated now views pagignation is not working (from views 7.x-3.7 to views 7.x-3.8 version) any help appreciated thanks.

# Answer
I recently had the same problem. Issue for me was Views 7.x-3.8 changes the file plugins/views\_plugin\_query\_default.inc to move the following code from the execute function to the query function.

I fixed it using the following patch:

https://www.drupal.org/node/2276165
> 0 votes

---
Tags: views, updating
---


title: Translate Drupal

text:
# Question
Title: Translate Drupal
I got a question about how to translate drupal to another language so everything on the navbar dashboard etc changes to a specify language that I choice Drupal to have. I dont want the content like articles and stuff to be translated ofcourse but the rest of all the built-in drupal modueles and stuff switches to another language set. I guess there is some moduele that can do this for me?

How do I make this possible?

thanks

# Answer
In addition to *Astha Chauhan* answer, *internationalization* module only provide functionality to translate front end content of the Drupal.

If you want to translate admin section of the Drupal, then you need to install Drupal in specific language.

Kindly find this link for more information.
> 3 votes

# Answer
Drupal provides a core module called translate that allows content to be translated into different languages. There is another module called **internationalization**. **internationalization** : This is a collection of modules to extend Drupal core multilingual capabilities and be able to build real life multilingual sites. Following is the link : https://drupal.org/project/i18n
> 2 votes

# Answer
Drupal 7 Core incorporated a series of modules designed to support multilingual websites but if you really want to build a Drupal 7 with multiple languages and open our website to the world then we need to add some contributed modules and configure correctly. I just published a very interesting post with my experience in the translation of Drupal 7: How to build your Drupal 7 multilingual website

Good luck!
> 0 votes

---
Tags: 7
---


# Question
Title: How get subscribe to user flag on a node
1. I have a node for example news
2. I have Message module installed
3. I've enabled the flag subscribe to user

I want people to be able to subscriber to a user. To get updates on thier latest post.

4. I want to add the subscriber user flag to the node template for

This is what flag module suggests to do

Placing a flag link on a page

```
$account = menu_get_object('user');
print flag_create_link('fools', $account->uid);

```

How would I add this to a node?

# Answer
You could create a block with a php filter or create a custom template for that node. You can also alter that node from from template.php

http://www.webomelette.com/altering-node-content-it%E2%80%99s-rendered-page-drupal-7
> 0 votes

---
Tags: flags, message-subscribe
---


title: creating a view of a gallery of images

text:
# Question
Title: creating a view of a gallery of images
I need to create a view of galleries of images.

The requirement is for a user to click on the menu item "albums". This then renders a view of a selected image from each of the galleries. Each gallery is made up of related images, each image is a content type which contains information about the image such as place taken description and category(this is the related field).

So the requirements are...

* Albums: Grid view of galleries using a selected image from each gallery.
* Galleries: Grid view of images including meta data (from image content type)

Clicking on each image in the gallery renders a colorbox.

When creating a gallery of images the user needs to be able to select which image is used as the displayed thumbnail in album view of galleries. This CANNOT be related to a date field or creation order. in other words a tickbox or something to be used to promote it to the gallery view. This image might be changed regularly so basing it on dates. etc is not feasable

We are talking a large number of images. they will initially be uploaded using the feeds importer + bulk media uploader (or ftp).

I have played with as many configurations as I can and cannot get the result I want.

The end users are not confident computer users so the system to add new images must be non complex. which is one of the reasons I am avoiding taxonomy as the category plus we could not get a taxonomy view to allow us to select an image as the promoted image. I also could not work out how to have taxonomy terms auto created as well. Which means I want people to be able to set the category by simply typing into the category field rather than first having to create a category and then select it from a drop down field.

One way I have considered is to make a gallery a content type and then embed into it a view of related images, The relationship would be on category. this of course is similar to pre-creating the taxonomy.

I hope this makes sense.

# Answer
> 0 votes
The Drupal Module Album Photos best suits your need.

# Answer
> 0 votes
How about Mediabox module the problem with this module is that it's in dev state but it have type with fields support where you can put Term reference field with auto completion for category creation also one Featured taxonomy field with a check box for which image to be featured in Album grid.

One problem with this module and large number of images is that it use quite annoying browser like interface for adding images which get cluttered quite fast also crop that I don't found a way to switch off.

---
Tags: taxonomy-terms, views, media
---


# Question
Title: How do you set the alt attribute with the Media module widget?
I've tried both 7.x-1/7.x-2 branches of the Media module and can't find a way to set the alt-attribute on a image field using the media-widget.

When I change to the image widget it's possible to set title/alt.

# Answer
> 2 votes
After one whole day of searching and patching without success I finally found out I only simply had to download and enable Token module to make Media correctly set images `alt` and `title` attributes when inserting images in CKEditor wysiwyg. I wonder since this is nowhere stated as an requirement. That's the bundle of modules it finally worked with:

Now I even can use the default view mode to display the `alt` or `title` attribute below the image to use it as an image caption.

# Answer
> 1 votes
There are two cases using the media file selector widget: in conjunction with *fieldS* and in conjunction with WYSIWYG editor image insert pop-up.

There are patches to the Media module for each of these that add alt/title text fields in appropriate places.

See http://drupal.org/node/1307054 and http://drupal.org/node/1343022 respectively.

# Answer
> 1 votes
Alt tags and title tags are now available in the 2.x-dev releases of the media module.

---
Tags: media
---


title: How to build custom breadcrumbs

text:
# Question
Title: How to build custom breadcrumbs
I have to build a breadcrumbs, In fack I only need to add a breacrumbs between the "home" and the "books breadcrumbs" to get something like this:

> home\>\>view-path\>\>book-breadcrumbs-with-deep

I have try with paths breadcrumbs, with hansel, and with custom breadcrumbs, I don't get nothing.

There is another module, or I should make my own module?

Thanks

Oskar

# Answer
> 1 votes
You can accomplish this with `hook_menu_breadcrumb_alter()`:

```
function mymodule_menu_breadcrumb_alter(&$active_trail, $item) {
  $home = $active_trail[0];

  $new = array(
    'title' => t('Some title'),
    'href' => 'internal/drupal/path',
    'link_path' => '',
    'localized_options' => array(),
    'type' => 0,
  );

  $active_trail = array_merge(array($home, $new), array_slice($active_trail, 1));
}

```

This is a fairly simplified example that creates a new breadcrumb item, and sticks it after the first entry. The `$item` parameter will be the router entry for the current page. If you want to use that, you need to `dpm()` it to see what is there. A more concrete example, which assumes that you are on a node page would be:

```
function mymodule_menu_breadcrumb_alter(&$active_trail, $item) {
  $home = $active_trail[0];

  if (arg(0) == 'search') {
    $active_trail = array($home);
  }
  else if (isset($item['load_functions'][1]) && !empty($item['map'][1]) && $item['load_functions'][1] == 'node_load') {
    $node = $item['map'][1];

    $new = array(
      'title' => $node->title,
      'href' => 'node/' . $node->nid,
      'link_path' => '',
      'localized_options' => array(),
      'type' => 0,
    );

    $active_trail = array_merge(array($home, $new), array_slice($active_trail, 1));
  }
}

```

# Answer
> 0 votes
Check out Crumbs module as well, it provides a plugin system so you can customize them to a high level.

There's an Example plugin in the documentation.

```
/**
 * Implements hook_crumbs_plugins()
 */
function mycrumbs_crumbs_plugins($api) {
  $api->monoPlugin('default');
}
class mycrumbs_CrumbsMonoPlugin_default implements crumbs_MonoPlugin {
  function describe($api) {
    $api->setTitle('Frontpage and classic theme area');
  }
  /**
   * Find a parent path, if the router path is node/%.
   *
   * @param $path
   *   The system path that we want to find a parent for.
   * @param $item
   *   The router item, as returned by menu_get_item(),
   *   with a few convenience additions.
   * @return
   *   System path or alias for the parent path.
   */
  function findParent__node_x($path, $item) {
    $node = $item['map'][1];
    $lang = $GLOBALS['language']->language;
    // This site has Organic Groups (Drupal 6) installed.
    if (!empty($node->og_groups)) {
      // Pick the first group nid.
      foreach ($node->og_groups as $gid) {
        if ($group = node_load($gid)) break;
      }
      // We have a node type "city_group" set up as an OG group type.
      if ($group && $group->type == 'city_group') {
        switch ($node->type) {
          case 'event':
          case 'group_event':
            return "node/$gid/events";
          case 'group_discussion':
            return "node/$gid/news";
        }
      }
    }
    // Some rules for other node types, which are not group posts.
    switch ($node->type) {
      case 'news':
        return 'news';
      case 'simplenews':
        return 'news-media/newsletters';
      case 'video':
        return 'news-media/video';
      case 'photo':
        return 'news-media/photo-library';
      case 'city_group':
        return 'city-groups/list';
    }
    // Use the generic findParent() method as a fallback.
    return $this->findParent($path, $item);
  }
  /**
   * Find a parent path, for arbitrary router paths.
   *
   * @param $path
   *   The system path that we want to find a parent for.
   * @param $item
   *   The router item, as returned by menu_get_item(),
   *   with a few convenience additions.
   */
  function findParent($path, $item) {
    switch ($item['alias']) {
      case 'news':
        return 'news-media';
      case 'og':
      case 'city-groups':
        // This will make a breadcrumb of
        // Home > Community > City groups > ...
        return 'community';
    }
  }
  /**
   * Determine a breadcrumb item's title, for a router path of "node".
   * Actually, we totally skip 'node'.
   *
   * @param $path
   *   The system path that we want to find a parent for.
   * @param $item
   *   The router item, as returned by menu_get_item(),
   *   with a few convenience additions.
   * @return
   *   A string to be used as the title, OR
   *   FALSE, to totally skip this item.
   */
  function findTitle__node($path, $item) {
    // Always skip 'node'
    // For instance, for node/123 "Some page", we don't want a breadcrumb of
    // Home > Node > Some page, but rather
    // Home > Some page
    return FALSE;
  }
  /**
   * The breadcrumb is finished, and we get a chance to alter it.
   *
   * We could use this method to skip or abbreviate some items, if the
   * breadcrumb gets too long.
   */
  function decorateBreadcrumb(&$breadcrumb) {
    // Do nothing.
  }
}

```

# Answer
> 0 votes
If you want to do this with Crumbs (7.x-2.\*):

Useful things to know:

* Book structures are menus.
* Book pages are nodes, usually (or always?) the bundle is "Book page".

Steps:

1. Install Crumbs.
2. Visit `admin/structure/crumbs/entity-parent`.

1. Set the path of the views page as the parent path for "Book page".
3. Visit `admin/structure/crumbs` (the weights configuration).

1. Make sure that `menu.hierarchy.MENU_NAME` and `menu.link_title.MENU_NAME` are enabled. MENU\_NAME should be the menu that contains the book hierarchy. Or just use the `menu.hierarchy.*` and `menu.link_title.*` wildcard plugins to have all menus enabled.
    2. Make sure that `crumbs.entityParent.node.book` (or a respective wildcard) is enabled. Hint: It probably already is enabled, without you doing anything!
    3. Make sure that the priority of `menu.link_title.MENU_NAME` comes before that of `crumbs.entityParent.node.book`. This is super important, because otherwise the entityParent plugin will dominate and steal the show.
4. Make sure that Crumbs can find a breadcrumb title for the views page. Usually Crumbs looks into the menu\_router table for a title or title callback, but Views often needs some extra babysitting. An easy solution is to create a regular menu link for the Views page, in whichever menu you prefer.
5. Visit `admin/structure/crumbs/debug` for troubleshooting. If you see the breadcrumb item crossed out, it means Crumbs was not able to find a title for that item.

# Answer
> 0 votes
Check Path Breadcrums \- I find it easiest and most useful for your task.

And here's some other breadcrumb modules comparison:
https://www.drupal.org/node/533448

# Answer
> -1 votes
My favorite method is to use the Custom Breadcrumbs module is for me the only one that takes into account all possibilities and is capable of generating a real Breadcrumb. I have a post explciando obtaining a real Breadcrumb for example if a node has multiple paths to reach it. Get a real breadcrumb, Drupal

Good luck!

---
Tags: 7, breadcrumbs
---


# Question
Title: CKEditor automatically making new paragraphs
When I'm writing some text with CKeditor and I press enter and want to write something on the next line, the editor automatically inserts the text on the new line into `<p> ... </p>` tags instead of only `<br/>`
.

I tried to correct it with editing the `config.js` file and adding the line `config.autoParagraph = false;` but without success.

Do you know where is the fault?

# Answer
> 8 votes
Out of the box, the CKEditor configuration does a `<p>` on enter and a `<br>` on shift + enter.

If you wish to change this, you can visit admin/settings/ckeditor/edit/\[profile\], and scroll down to the "Cleanup and output" section.

# Answer
> 5 votes
Answer above fix this if you have a CKEditor module, but if you use WYSIWYG module you don't have that option (at least for now).

Here is how to override these settings with a module in CKEeditor in Drupal 7:

```
function YOURMODULENAME_wysiwyg_editor_settings_alter(&$settings, $context) {
  if($context['profile']->editor == 'ckeditor') {
    $settings['enterMode'] = 2; //<br />
    $settings['shiftEnterMode'] = 1; //<p>
  }
}

```

For TinyMCE here Drupal 7 - How to change p to br in CKEditor and TinyMCE.

# Answer
> 2 votes
There is a reason why the paragraph is the default: usually it's semantically more correct to use a `<p>` tag. I recommend in most cases to stick to the default and (if you don't like the whitespace) remove the margin on paragraphs using CSS.

# Answer
> 2 votes
Just go to admin/settings/filters/list; uncheck "Line break" in all filters, and "Full HTML."

# Answer
> 1 votes
I found it easier to hardcode this. Open the file sites/all/libraries/ckeditor/ckeditor.js in Notepad++ Go to line 22 or search for shiftEnterMode

Change following:

```
enterMode:1,forceEnterMode:false,shiftEnterMode:2,

```

into:

```
enterMode:2,forceEnterMode:false,shiftEnterMode:1,

```

done!

---
Tags: wysiwyg
---


# Question
Title: Entity Translation: Translate breadcrumb
I'm having issues translating breadcrumb. Everything works, menu items, strings etc... a part from breadcrumb.

I've tried hook\_menu\_breadcrumb\_alter to reset the title with no success.

How can I translate breadcrumb?

# Answer
You need to add that string(those are not getting translated) into backend, using translate interface- http://example.com/admin/config/regional/translate/translate
> 0 votes

---
Tags: 7, breadcrumbs, i18n-l10n
---


# Question
Title: Is there a hook when a relation is created, updated or deleted?
I know how to use hooks like `hook_node_presave`. Is there also a hook to catch the deletion of a relation or the update of a relation? In the API I cannot find anything. Maybe there is a workaround?

Thanks.

# Answer
> 3 votes
Relations are themselves entities, so you can use the entity hooks:

and so on, checking the `$type` parameter to react only for the appropriate entity type(s).

There's a full list of available entity hooks in the system.api.php file.

---
Tags: hooks, entities
---


title: Programmatically add PDF file to user

text:
# Question
Title: Programmatically add PDF file to user
So using the 'file' module i have added a field to the user table called 'user\_files'. What i want to know if how can i programmatically add a file to the user, so that it is displayed on the users profile.

So far i am storing the file information locally and then targetting the database tables directly and inserting the data into them. This has been done correctly, but the file is not dispalying.

I am using file\_save\_data to store the file in the database. Then manually adding it to 'field\_data\_field\_user\_files', 'field\_revision\_field\_user\_files' and 'file\_usage' tables.

Is there a simpler way to get this to work?

# Answer
You first need to insert the file in the database, then assign it to your entity (a user in your case)

To insert file in the database say you have your file in a temp location. You can add it to the databse at the same time the file is moved to its final location:

```
// uid of user that to add the file.
$uid = $UID;

// Final file name
$filename = $FILENAME;

// Fieldname where to attach the file
$fieldname = $FIELDNAME;

// File temporary path.
$file_tmp_path = $FILE_TMP_PATH;

// Let's go!

// Load user object.
$account = user_load($uid);

// Gather file info.
$filesize  = filesize($file_tmp_path);
$mime_type = mime_content_type($file_tmp_path);

// Create file object.
$file = new stdClass;
$file->uid      = $uid;
$file->filename = <desired filename>;
$file->uri      = $file_tmp_path;
$file->filemime = $mime_type;
$file->filesize = $filesize;
$file->status   = FILE_STATUS_PERMANENT;

$destination .= '/' . $filename;

// Move to its final destination and add it to the database.
// file_move moves the file and is in charge of add the needed DB records.
$file = file_move($file, $destination, FILE_EXISTS_RENAME);

// Attach file to user.
$account->{$fieldname}[LANGUAGE_NONE][0]['fid'] = $file->fid;

$user_save($account);

```
> 2 votes

---
Tags: users, entities, files
---


title: Disabled messages still showing

text:
# Question
Title: Disabled messages still showing
I'm trying to use the Disable Messages Module to hide some messages. For example the message `Proposal has been updated.` (because I'm using a wizard and updates every step).

These are my configuration settings of the disable messages module:

I've cleared my cache but the message is still showing. Am I doing something wrong?

# Answer
It should be:

```
Proposal .* has been updated

```

and not

```
Proposal *. has been updated

```

What you want is

```
Proposal, space, any number of any characters, space, ...

```

But what you wrote is:

```
Proposal, any number of spaces, one of any character, space, ...

```
> 3 votes

---
Tags: nodes
---


# Question
Title: How to hide a field of a Views row if comments are closed?
I know there are some easy tricks to hide Views fields conditionally (catchword: hide if empty). None of them seems to work for me. Also `hook_views_pre_render()` or other preprocess approaches didn't work since they never touch the row in a way where I could have unset that certain field I'ld like to hide conditionally.

This is the setup I have to work with:

```
[field 1] hidden from display
[field 2] hidden from display
[field 3] hidden from display and rewritten to output <markup>[field 1][field 2]</markup>
[field 4] hidden from display
[field 5] rewritten to output <markup>[field 3][field 4]</markup>

```

I'ld like to unset `[field 3]` if comments of that row's nid are closed (`if ($node->comment != 2)`). I think maybe field handlers are the way to go, but I don't see how. I have to bind some .inc into my custom module, is that right? But which of these many .inc files is the one I have to work with and how would I alter it? Or are there other ways to achive what I need?

---

I think my main question is somewhere in the direction of "How to conditionally hide rewritten fields?" It seems really dificult to fetch these fields along the processing and unset them. Rebuildung the whole view would maybe bring me even more problems, while lots of css goes with the nested markup. **I think it would've been much better to have started without fields and with a view mode instead in the very beginning**.

# Answer
in admin panel of that view.. add Filter criteria and select "Content: Comment status"

and then click on apply and then choose closed option in options box

let me know if need any clarification...

Thanks Ashish Raj
> 0 votes

---
Tags: 7, views, comments
---


# Question
Title: Highlight View parent menu item on node page and rebuild breadcrumb
*If you are new to Drupal, as I am, you surely asked yourself once about "How can I highlight parent Views menu item even if I am on a child node? And how can I keep a correct breadcrumb if I use one?"... That's why I wanted to share a little clue in here.*

**My situation:**

I have a content-type named "Testimonial". I created a **View** for my testimonial's nodes, with a **menu item** "Témoignages" in a secondary menu on the left of my page (called "Ressources").

**First problem: the menu**

/!\ This menu **displays only on the pages whose menu item is present** in the menu. For example, "Marchés publics en Wallonie", "Aides publiques en Wallonie", "Témoignages" (= Testimonials), ...

When I am the the View page, with the list of my testimonial's nodes, the menu item is **highlighted automatically** by Drupal. Nice.

But when I click on a node and access the **full view page**, the "Ressources" menu disappears. This behaviour is normal for all other menu item's children pages. But I want to **make an exception** for the testimonials.

**Second problem: the breadcrumb**

Breadcrumb on Views page:

Breadcrumb on testimonials node page:

**My final question:**

How can I keep the menu block in testimonials node pages (only) and make the menu item "Témoignages" **highlighted**? And how can I keep a **correct breadcrumb** in the same time?

# Answer
To **display the** "Ressources" **menu** in a testimonial node page, Drupal **should believe** that we are actually on the "Témoignages" Views page. Plus, it will **highlight** automatically the good menu item.

But, we also need a correct breadcrumb. That's why we have to **save** in a variable the "**true nature of the page**" (a node) before letting know to Drupal that we are on a view.

That's that we do here:

```
function pwe_testimonial_node_view($node, $view_mode, $langcode) {
  // When we are on a Testimonial node page
  if($node->type == "testimonial" && $view_mode == "full") {
    // We save the true nature of the page
    $_SESSION['pwe_testimonial_active_trail'] = serialize(menu_get_active_trail());
    $_GET['pwe_node_id'] = $node->nid;
    // And set the active menu item as "Témoignages"
    menu_set_active_item("testimonial");
  } else {
    // If we are not on a Testimonial node page,
    // we unset the custom variable.
    if(isset($_SESSION['pwe_testimonial_active_trail'])) {
      unset($_SESSION['pwe_testimonial_active_trail']);
    }
  }
}

```

To rebuild the true breadcrumb, we use the variable saved in previous function.

```
function pwe_testimonial_menu_breadcrumb_alter(&$active_trail, $item) {
  if($item && $item['path'] == "testimonial") {
    if($_GET['pwe_node_id']) {
      if(isset($_SESSION['pwe_testimonial_active_trail'])) {
        unset($_SESSION['pwe_testimonial_active_trail']);
      }
    }
    if(isset($_SESSION['pwe_testimonial_active_trail'])) {
      $original_active_trail = unserialize($_SESSION['pwe_testimonial_active_trail']);
      if(is_array($original_active_trail)) {
        $total = count($active_trail);
        $active_trail[$total] = $item;
      }
    }
  }
}

```

*That's all. I hope this little Q&A sharing knowledge will help someone in the future.*
> 0 votes

---
Tags: 7, views, breadcrumbs, routes
---


# Question
Title: Views - using "admin/" in path gets me to the home page
I'm having an issue with the Views module. Let me say in advance that the site urls have been customized with the module "rename admin path" and the path to the administration section is www.site.com/gestione/ , using www.site.com/admin/ will get me a "page not found" error. I thought this was something worth telling. I want to make a view which as an administration layout and i have been told this can be achieved but using "admin/" ("gestione/" in my case) inside the path. So i put /gestione/my-archive as URL.

Now if i try to access the page i see the administration home page instead of the view. If i don't put any prefix (so that the url is www.site.com/my-archive) it works, but it has the normal front end layout, i have tried:

* "gestione/content/my-archive" brings me to the content section of the administration menu
* Any variation like "gestione/test/my-archive" still gets me to the administration home (likewise "gestione/content/test/my-archive" brings me to the content section)
* Giving no access restriction
* Anything that doesn't start with "gestione" will get me to the view but with front end layout
* using "admin/" will give me a page not found error
* Rebuilding the menu calling menu\_rebuild();
* Deleting the caches

EDIT: disabling the "rename admin path" and using /admin/my-archive did the job, but i wonder if there's any way to keep it working

# Answer
> 1 votes
Configure the view to have `/admin/my-archive` as the URL and then access it via `/gestione/my-archive`. *Rename Admin Paths* works using `hook_url_inbound_alter()` and `hook_url_outbound_alter()` which means that internally the path is still `admin/*`.

---
Tags: views, uri
---


# Question
Title: How to download directly to ~/.drush folder?
I've created a project that is basically a drush command with a starterkit folder. I noticed the make\_local project will but I haven't figured out how it does that.

I've tried the approach recommended in the answers and added a .info file and tried to hide the .profile extension by renaming it to .profile.starterkit. Drush still thinks I'm downloading a theme.

# Answer
There are three requirements:

1. Your project must have a .info file
2. Your project must have a project.drush.inc file
3. Your project must not have a project.module file or any sort of .profile file

If all three of these are true, then Drush will store the project in ~/.drush. If there is a module file or a .profile, then Drush will treat the project like a module or installation profile (usually storing it in sites/all/modules).

Your project was missing a .info file, but unfortunately, the existence of the profile file caused Drush to decide that your project was an installation profile, and Drush thinks that those do not belong in ~/.drush.

The user will have to specify --destination=$HOME/.drush, or move your project to the correct folder manually.
> 4 votes

---
Tags: drush
---


# Question
Title: Why are there so many settings.php files one in each folder or sub-directory?
I am Drupal newbie taking over a poorly documented D6 group of sites organized by sub-domains. In examining the dev.\[domain\].org/sites/ folder I discover folders: all, default, demo.\[domain\].org and \[customer\].\[domain\].org and each folder has its own settings.php?

For example, /default/settings.php allows me to configure-or-edit the 'site\_name' =\> and $db\_url and $base\_url. The $db\_url works.

while, /all/settings.php has a disabled # $base\_url and a disabled # 'site\_name' =\> yet an active $db\_url that is connecting to a 'mysql://\[detail\]' that may or may not be an active db.

I presume folders demo.\[domain\].org and \[customer\].\[domain\].org in the /sites/ folder are just legacy folders left by the previous coder/hacker of the settings.php used in the those sub-domains.

Your thoughts and answers will be gratefully consumed.

Thank you, Steve

# Answer
> 3 votes
Refer the multisite doc as Molot suggested. We don't know how your site(s) have set up, so you have to experiment it yourself.

> Q1: Why isn't there just one settings.php per sub-domain site?

There is. `sub.example.com` site's `settings.php` file is `sites/sub.example.com/settings.php`. The reason to have a whole folder is to make it possible for you to store files, modules, themes and libraries separately (`sites/sub.example.com/modules` will be only available to `sub.example.com` likewise.)

> Q2: What is the difference between /default/settings.php and /all/settings.php?

You should not have a `settings.php` file in `sites/all` folder. That folder is a special one that is used to store common files across all the sites, and the default modules/themes/libraries folder for the only site if it's not a multisite.

> Q3: And why are folders demo.\[domain\].org and \[customer\].\[domain\].org in the /sites/ folder? Perhaps they are just legacy folders left by the previous coder/hacker of the settings.php used in the those sub-domains.

If there are `demo.example.com` site, that site is *probably* using the settings.php inside to load the settings. You can however change this in the `sites/sites.php` file. Unless you override, `demo.example.com` site is using `sites/demo.example.com/settings.php`.

---
Tags: configuration
---


title: Ajax via Jquery and attach behaviors

text:
# Question
Title: Ajax via Jquery and attach behaviors
The Ajax framework is very nice but i want more complex effects. So I am trying to do the Ajax calls via Jquery. The goal here is to load nodes by clicking some links on the menu but the nodes contains an image which pop ups with a lightbox and also contains a from which submits via Ajax. For demo site i am using Drupal commerce. here is the demo to check out.

I am using Drupal.attachBehaviors(document); to re-attach the needed js scripts. The problem is that some of the behaviors are attached and some others are not. For example the first menu link 'Products' is a view and it uses ajax pagination but it loses this functionality but the image lightbox in this view does work. So i am little confuse here.

This is my code.

```
/*
 *  Implemets hook_menu()
 */

function myajax_menu() {
$items = array();

$items['myajax'] = array(
    'title' => 'Ajax',
    'page callback' => 'myajax_callback',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
);

$items['myajax/view'] = array(
    'title' => 'Ajax',
    'page callback' => 'myajax_view_callback',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
);

return $items;
}
/*
 *  Ajax handling
 */
function myajax_callback($nid = '') {
      $node = node_load($nid);
      $vnode = node_view($node);
      return theme('node',$vnode);
}

function myajax_view_callback($view = '') {
      print views_embed_view($view, 'default');
}

```

and my js file

```
(function ($) {

Drupal.behaviors.myajax = {
    attach: function(context,settings){
        $('#main div.column').before('<div id="loading">Loading...</div>');

        $('a.ajax_link', context).once().bind('click',function(e){
            $(this).addClass('ajaxafy');
            e.preventDefault();
            var url = $(this).attr('href').split('/');
            //console.log(settings);
            $('#loading').fadeIn();
            $.ajax({
               type: "POST",
               url: Drupal.settings.basePath + 'myajax/' + url[2],
               data: {'js':1}, // you can also pass block name and act more dynamicly
               success: function (response){
                  $('#loading').fadeOut()
                  $('#main #myajax', context).html(response)
              Drupal.attachBehaviors(document);

              },
            });
        });
        $('a.ajax_link_view',context).once().bind('click',function(e){
            e.preventDefault();
            var url = $(this).attr('href').split('/');
            $('#loading').fadeIn();
            $.ajax({
               type: "POST",
               url: Drupal.settings.basePath + 'myajax/view/' + url[1],
               data: {'js':1}, // you can also pass block name and act more dynamicly
               success: function (data){
                  $('#loading').fadeOut()
                   $('#main #myajax', context).html(data);
                   Drupal.attachBehaviors(document);
              },
            });

        });

    }
};

})(jQuery)

```

Alse the webform submits also using Ajax but it loses that behavior.

What i am missing here? Please check the demo to see what's going on. Thanks in advance.

# Answer
Must be:

```
Drupal.attachBehaviors($('#main'), context);

```
> -1 votes

---
Tags: 7, ajax, javascript
---


# Question
Title: Access denied: 'view published content' permission
When I look into admin/people/permissions: 'View published content' is checked for anonymous users.

Yet the following code:

```
function test_menu() {
  $items['test'] = array(
    'title' => 'Test',
    'access arguments' => 'view published content',
    'type' => MENU_NORMAL_ITEM,
  );
  return $items;
}

```

returns 'Accessed denied' when I navigate to /test as an anonymous user. I know I can do:

```
'access callback' => TRUE,

```

but the other code seems a lot neater. I've experienced this issue a few times before.

Thanks.

# Answer
> 0 votes
A quick look at node\_permissions makes me think you should be using 'access content' as your argument, not view published content', as the latter is the proper machine name for the permission.

---
Tags: routes
---


title: Search API with views -> Apply filters

text:
# Question
Title: Search API with views -> Apply filters
I have a website where i manage to create a database, display it with the views module and add a Search box with Search API. I followed this tutorial: http://webwash.net/tutorials/how-create-search-pages-using-views-drupal-7

I'm using a bundle filter in my Index. My page only shows and search content from a specific content type. On that content type i have a field "category" with 2 radio options.

What i want to do is be able to filter the search by that category: If i choose option A, when i type my search it will only search the content within that category.

It must be really easy but i just can't figure it out. You guys have any ideas?

Thank you so much in advance!

# Answer
> 1 votes
You need to add an exposed filter to the view for the category field. Under the advanced settings in views you can select to display filters as a block so that you can place it above the search block.

---
Tags: views, search
---


# Question
Title: Case difference of Usernames; how to login with Usernames regardless of case in Drupal 7
Quick question.

On my site, users have entered their username with capitalized case or mixed upper or lower cases during registration. Now when the Login, they forget that write everything lower cased and ofcourse that doesn't work making things difficult for me.

so my humble question is, how do I validate the login regardless of case?

Thanks a lot.

# Answer
> 1 votes
There are no modules that I know of at this time that provides this functionality. It can be done, however, by writing a custom module.

I suggest that you look at LoginToboggan as a model for how to write your own module. The basic flow is this:

1. LoginToboggan allows users to log in using either their username or email address. Drupal, by default, does not support logging in with an email address, so LT does a `hook_form_alter()` to add a function to the login form's `#validate`.
2. The Validate function, `logintoboggan_user_login_validate()` searches for an email address that matches the one provided by the user. If it is found, then LT provides the username to the form programmatically.
3. Because the username is provided during the `#validate` step, the form flow continues and processes the username which was retrieved by LT, and the user is logged in.

Your solution would follow a very similar flow, but instead of checking for an email address, you would check against username. The LT function uses a `LOWER()` SQL function to recognize differences in capitalization in the email; you will do the same, except with usernames.

One addition that you may have to make is that, if you allow users to register themselves on your site and pick their own usernames, you may need to ensure that the selected username does not collide with a capitalized version (e.g, Drupal may allow a username `mrawesome` and `MrAwesome` because they are different, but you should disallow the latter because they are viewed as equivalents within the confines of your system).

---
Tags: users
---


# Question
Title: How to send email to all members when a post is updated by user?
I am creating a rules to send an email when a (node with content type update) is updated
which has field\_og\_audience as field and it is placed on the groups page using advanced form block.
I want to send an email when node (with content type update) is updated by user then all
the members of the group(selected in the field\_og\_audience) should recieve an email.

# Answer
EVENT

**After saving new content**

CONDITIONS

Entity is group content

**Parameter: Entity: \[node\]**

ACTIONS

Get group members from group audience Parameter: Group content: \[node\] Provides variables: Fetch a List of group members (group\_members)

**Loop** **Parameter: List: \[group-members\]** **List item: Get list of group members and their email ids (list\_grp\_members\_emails)**

**Send mail Parameter: To: \[list-grp-members-emails:mail\], Subject: Notification: Content..., Message: Test**
> 1 votes

---
Tags: organic-groups
---


# Question
Title: Custom create account form included in a create content form
I am new to Drupal 7 ( 1 month ) and have to do a rather complex task.

I have a content type (lets call it MyContent) for which i tried to create a custom form (I imported the fields from the original add content form in my own custom module generated page) which contains, among other fields, an email field, and i need to add 1 more field called password. With these 2 fields , i want on form submit:

\*IF the email & password combination does not already exist

-\> first create a user account taking the email as username and password as password ,
-\> then create the content(disabled),
-\> then make the site visitor confirm his email to enable his account
-\> and after validation make the content viewable by all

\*IF the email&password combination exists then :

-\> create the content viewable

all of this by clicking one button. The general ideea is that i want visitors, who are not logged, to be able to create content but in the process , get a user account generated as well. Also if the visitor already has an account then the email&password will work as a validator for letting the user create more content.

Is it even posible? I saw that Drupal has a lot of configurable options for users but nothing close to such a crazy ideea.

# Answer
> 0 votes
All of this is possible, but you will need to write a bit more code for it to work.

First, I suggest you use LoginToboggan. LT provides a workflow for validating a user's email address which you can hook into either by code or perhaps with the Rules module. LT already has the framework for tracking if a user is verified or not. It will be up to you to write the code to create the user (not too hard) and to create the node as published or unpublished depending on the status of the user.

Second, you will have to decide what to do for verification (what if they enter the right email but wrong password?).

---
Tags: forms, users
---


title: Import a list of suscribers from Excel

text:
# Question
Title: Import a list of suscribers from Excel
I have a big problem with a database. I have a list of suscribers in an excel list with their names, phone and other info. I need to import that suscribers to my drupal website and use them for send them massive emails. How to do that? which newsletter module is better for use with my usecase?

# Answer
Try the feeds module, or migrate for importing the data. Whatever module you end up understanding best for newsletters, is what I recommend.

Your question leaves out various details: show email templates be editable by site moderators or users, opt-in or opt-out features for the newsletters. Are newsletters recurring, or sent on-demand ... etc.

I recommend looking at the various newsletter modules, Rules based modules and scheduler modules to see what fits your needs.

I find leveraging an existing solution, like mailchimp and other email services typically well worth the cost (personally).

As example I wrote custom code that looks at emails in an imported DB table and uses a server-side cron task to run a Drush command to send emails with my own custom business logic (recurring scheduled emails, if tasks are completed they no longer receive emails)... my solution is not for everyone.
> 1 votes

---
Tags: 7, database, importing-exporting, emails
---


title: Drupal duplicate alias for same node

text:
# Question
Title: Drupal duplicate alias for same node
Any of you guys know why drupal it's duplicating my url alias when save a new node?

```
$node->path = 'st.louis';
node_save($node);

```

But in my alias table I have st.luis and stlouis

# Answer
That might be because of Locale core module. I had the same problem, but when i disabled the Locale module the problem was gone.

You can observe the main cause of the problem. When you look into the duplicate url aliases you will find the difference between the original url alias and duplicate url alias. In the original url alias you will have `language = "` and whereas with new/duplicate url alias you will find `language = 'en'`.

Hope this answers your question.
> 1 votes

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


# Question
Title: URL alias for File field on a Content Type
I have a File field on one of my content types and I'd like a URL alias for downloading that file regardless of how many times the actual uploaded file has been updated. Any advice?

I've been looking into the Attachment Links module as it accurately describes what I want to do, but it seems it isn't actively being maintained. Is there a community best practice for this type of functionality before I run with Attachment Links?

# Answer
> 3 votes
Well attachment links module does exactly what you want, this module is still being maintained, the fact is that there is not a new stable release for this module, but the manteiners are solving issues in the issues queue, and they commit changes to the 7.x-1.x-dev download that version and you will see it works like a charm. Check also Upload replace module is good also use the 7.x-1.x-dev version of this module. Both modules are for the same purpose but they do it in a different way.

# Answer
> 3 votes
If you install/enable the File Entity module, it integrates with Pathauto. If you set a pattern like `file/[file:fid]`, then you should have a permanent URL.

Just keep in mind that File Entity can introduce some subtle changes with how files are handled, particularly with field formatters.

---
Tags: files, path-aliases
---


# Question
Title: Where does field help text get filtered?
Drupal 7 fields, by default, have a nice text box beneath them for Help Text. This is set up with `field_ui_field_edit_form()`:

```
$form['instance']['description'] = array(
  '#type' => 'textarea',
  '#title' => t('Help text'),
  '#default_value' => !empty($instance['description']) ? $instance['description'] : '',
  '#rows' => 5,
  '#description' => t('Instructions to present to the user below this field on the editing form.<br />Allowed HTML tags: @tags', array('@tags' => _field_filter_xss_display_allowed_tags())),
'#weight' => -5,
);

```

Widget forms then can use this when they actually get used, such as from `file_field_widget_form()`:

```
if (empty($element['#default_value']['fid'])) {
  $element['#description'] = theme('file_upload_help', array('description' => $element['#description'], 'upload_validators' => $element['#upload_validators']));
}

```

Which then get themed, such as with `theme_file_upload_help()`

```
if (strlen($description)) {
  $descriptions[] = $description;
}
if (isset($upload_validators['file_validate_size'])) {
  $descriptions[] = t('Files must be less than !size.', array('!size' => '<strong>' . format_size($upload_validators['file_validate_size'][0]) . '</strong>'));
}
if (isset($upload_validators['file_validate_extensions'])) {
  $descriptions[] = t('Allowed file types: !extensions.', array('!extensions' => '<strong>' . check_plain($upload_validators['file_validate_extensions'][0]) . '</strong>'));
}

```

The trusty eye will notice that this is user supplied text and it is not being filtered (oh noes!). Don't worry, it gets filtered somewhere (I actually tested this to be sure).

Where / how does this filtering happen?

# Answer
In `function field_default_form` in *field.form.inc* line 107

```
'#description' => field_filter_xss($instance['description']),

```
> 1 votes

---
Tags: entities, security
---


# Question
Title: How to use profile 2 to display user profile page with comments enabled?
I have Downloaded, Installed and enabled profile 2, profile 2 pages & profile 2 group access ( i have organic groups)

Then went to permissions View any profile (all users), View own profile (authe. , admin), Edit own profile (authe. , admin.)

After which i Went to Config \> People \> Account settings \> Manage Display \> Custom Display settings and checked user account.

Whats are the next steps that i should do, or are missing, that i should have done, inorder to enable user profile page along with default comments enabled on this page ?

# Answer
> 2 votes
Not sure what you mean by *default* comments, but I doubt you can use core comments with Profile2 entities. The comment module only works with nodes.

See this core issue for work being done in this area.

Check the Profile2 issue queue for potential workarounds for comments.

# Answer
> 2 votes
A nice workaround is to use Rules, Entity reference and Display Suite (or views). First, you create a new content type 'profile\_ref\_node\_type'. Add only comment fields and delete any unnesseccary fields.

You can now create a new node of the type upon creation of the profile via rules. Add the 'entity has field' condition to be able to access your field. As the action I've used my own PHP code, but you can probably use the standard rules as well. My PHP code for creation of the node and entity reference:

```
$node = new stdClass;
$node->type = 'profile_ref_node_type';
$node->title = 'Profile - [profile2:field-name]';
$node->uid = 1;
node_object_prepare($node);
node_save($node);

$profile2->field_node = array('und' => array(array('target_id' => $node->nid)));
profile2_save($profile2);

```

You then can use this entity reference with display suite to show only the comments on that node (make a new display type if you want to use multiple fields of your node).

# Answer
> 1 votes
I've done a lot of research and the best solution I've found is using the Flag Module. Version 7.3 of Flag is now fieldable. So you create an "add comment" flag and add a text field + whatever other fields you want to it. Then you can display the contents of the flags in a view. Very flexible, extendable and non-hack-y solution. Unfortunately this will only work in a use case where only one comment/message is needed (Unless you make a ton of flags).

# Answer
> 0 votes
You can use the rely module http://drupal.org/project/reply

Reply is a D7 answer to entity comments.

Reply is basically a fieldable entity so you can create a 'review', 'comment', 'forum post' or whatever you like by creating bundles and attaching fields to them. Such bundles can be attached to any fieldable entity by 'reply field'.

# Answer
> 0 votes
When I search the solution for comment on profile page, I entered this page many times, at last I found a solution, I used the Guestbook module

> Guestbook module provides a site guestbook and individual user guestbooks. Guestbook owners can delete and comment the guestbook entries. Avatars are shown if they are available.

what you need is only to add a uid in the code.

---
Tags: comments, users
---


# Question
Title: How can I take control of the rendering of a file entity when inlined in text?
There are excellent instructions for how to allow embedding Media into text fields here Setting up WYSIWYG and CKEditor to include Media Browser / Embed Media button.

Now I'm trying to control the output of that embedding process, specifically I'm trying to render a text field for a caption next to an image. I started out by adding a new view mode to the file entity with hook\_entity\_info\_alter, configured this View mode to display the correct fields, and thought that would output as expected.

However, this by itself does nothing unless "File display" settings are also added, and I can't seem to figure out how to make them respect field settings. I've done a fair amount of debugging and hacking by now, and can't get this right. I could fill the question with a great deal of more details, but given that I can't make heads or tails out of the problem, it's unlikely to be very useful.

The question How do I control the file appearance using File Entity? is definitely related, and possibly even a duplicate, but as this one concerns specifically inline media, it may be different enough that open this separate question.

# Answer
> 1 votes
Your best bet is http://drupal.org/sandbox/DevinCarlson/1823634 \- which is an add on to media, but I'm not certain whether or not it can also display fields that are attached to a file entity.

As per http://drupal.org/node/1792738 this functionality is planned to be rolled into the media module at some stage.

# Answer
> 0 votes
I'm not sure this is possible yet. See http://drupal.org/node/1421786 and http://drupal.org/node/1792738

# Answer
> 0 votes
I've dealt with this quite a bit (sometimes with varying degrees of success). Which version of Media are you using? 7.x-2.0-alpha3 includes Media WYSIWYG View Mode as a submodule, which allows you to select a view mode when inserting media into the WYSIWYG - so you can control the display however you like. For example, I have a view mode that includes caption fields, and I can select that when inserting an image.

I know it's only alpha, but many people have been using 2.x for a very long time - I've had it in production for over two years now, with no problems directly attributable to its not being an official release.

---
Tags: media, entities, files
---


title: How to remove block in colorbox?

text:
# Question
Title: How to remove block in colorbox?
I'm currently doing recruitment system by using drupal 7..
I want to reduce the user redirect activity, so i've installed the colorbox module and colorbox node module..
I have job vacancy list (in views) which i link the job vacancy (content:title) to the node. The colorbox work perfect which it can display all the job details..

My problem is the colobox also include all the "block" in my website..

My question is how i want to make the colorbox show only the job details?

Thank you in advance..

# Answer
Is the block appearing as part of the view, or just in the Colorbox? If it's just showing in the colorbox, and you go into Structure \> Blocks, you should see that "HR Admin" block listed - you can set it to show only on the pages where you want it to appear. You can read about the visibility settings in the Block documentation. If it is appearing in your view, you may have to give more details for troubleshooting.

This answer may help: How to disable a block on a certain view?
> 0 votes

---
Tags: nodes, javascript
---


title: Views Editing Section Missing

text:
# Question
Title: Views Editing Section Missing
I upgraded a site from D6 to D7 and am coming across an interesting error with being able to edit my existing views. My views are all listed, but when I click on the edit button to edit a view the whole configuration section is missing- all the edit page shows is:

> Breadcrumb
>
> Title of view
>
> Auto preview Preview with contextual filters: Separate contextual filter values with a "/". For example, 40/12/10. Update Preview

New views do have the configuration area. Any help or ideas on what I might use to search for a solution to someone else that might have had this issue would also be appreciated. I haven't been able to come up with the right search terms to help find the answer. Thanks!

# Answer
> 0 votes
It turns out the problem was that the views were content panes and I hadn't enabled content panes in the CTools module. As soon as I turned that on they worked fine again.

---
Tags: views
---


# Question
Title: Refresh two views with same exposed filter using ajax
I have a site with a map and a grid in the same page and they both have exposed filters enabled, yet I only have the exposed filter of the grid visible at the page. When the grid view is not using ajax, when the page refreshes all works well, yet I would like to use ajax to update the map and the grid with filtered results at the same time to improve the user experience.

Things that I have tried and that I have already discarded: \- Views Global Filter: I've tried this approach but it is kind of a mess since I have many fields to filter and sort with, and custom search preferences that I store in a session preferences key. And when I used it i had the impression that it was not possible to use with sorting preferences. \- views\_embed\_view: I've read that this may be the solution in some posts, but I don't understand yet what this call does and my site has a complex layout and I just cannot embed one view after another. \- Other stuff in a custom exposed filters submit function.

Ideally the solution would be to call an ajax refresh function from the custom submit function or to trigger it with javascript, when the update of the grid is triggered, it would be simple since the grid and the amp use the same arguments.

What I have thought what could be a hacky solution is to add the second exposed filter, to hide it with display:none, and then fill it with javascript and trigger the submit event whenever the visible filter of the grid is triggered. Nevertheless, if someone with proper expertise in Drupal can give me hint of how this should be properly accomplished it would be great!

# Answer
> 2 votes
ATTACHMENT is what you need!

Try using an "Attachment" in view, what you can do is create your View which can be either Content, User or Term View and just after that add an Attachment and attach is it the required view display, before or after that depends upon your requirement also don't forget to inherit contextual and exposed filter which should act as the key property here.

For a quick view purpose, I'm attaching a demo view exported code:

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

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Demo';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Contextual filter: Content: Author uid */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'node';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['default_action'] = 'default';
$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'user';
$handler->display->display_options['arguments']['uid']['default_argument_options']['user'] = FALSE;
$handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'page' => 'page',
);
/* Filter criterion: Content: Author uid */
$handler->display->display_options['filters']['uid']['id'] = 'uid';
$handler->display->display_options['filters']['uid']['table'] = 'node';
$handler->display->display_options['filters']['uid']['field'] = 'uid';
$handler->display->display_options['filters']['uid']['value'] = '';
$handler->display->display_options['filters']['uid']['exposed'] = TRUE;
$handler->display->display_options['filters']['uid']['expose']['operator_id'] = 'uid_op';
$handler->display->display_options['filters']['uid']['expose']['label'] = 'Author UID';
$handler->display->display_options['filters']['uid']['expose']['operator'] = 'uid_op';
$handler->display->display_options['filters']['uid']['expose']['identifier'] = 'uid';
$handler->display->display_options['filters']['uid']['expose']['remember_roles'] = array(
  2 => '2',
  1 => 0,
  3 => 0,
);

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'demo/%';

/* Display: Attachment */
$handler = $view->new_display('attachment', 'Attachment', 'attachment_1');
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Field: Content: Author uid */
$handler->display->display_options['fields']['uid']['id'] = 'uid';
$handler->display->display_options['fields']['uid']['table'] = 'node';
$handler->display->display_options['fields']['uid']['field'] = 'uid';
$handler->display->display_options['displays'] = array(
  'page' => 'page',
  'default' => 0,
);
$handler->display->display_options['attachment_position'] = 'after';
$handler->display->display_options['inherit_exposed_filters'] = TRUE;

```

---
Tags: ajax, views
---


title: private files are no longer private

text:
# Question
Title: private files are no longer private
I have created a new content type with an Image field, and I've set it to save in private directory. In my configuration \> File System, I have specified /sites/default/files/private as my private directory. File is saving to private directory as well. But when I open that private Image having url structure like /system/files/ in another browser. It shows up, It should not have shown in other browser. How can I make it private?

# Answer
Drupal should have created an `.htaccess` file in that directory with `Deny from All` per the File documentation. Check to see if this is the case. This post may also be helpful: Noob question about private files and Content Access.
> 2 votes

# Answer
The best way to make sure it is private, is to locate the *private* directory outside of the web root.

The path `/sites/default/files/private` looks like its relative to the web root. In file system terms it may be something like:

```
/var/www/htdocs/sites/default/files/private

```

(what is *before* "sites" depends on your Apace configuration, so this is just an example.)

To make it private, place it in a directory close to your *file system* root (above the *web* root).

For example:

```
/var/private

```

If for some reason you will have it below the web root, you need to use Apache directives to protect access to this directory (the file system permissions are not enough, because they only determine whether the web server user shall have access - the file system has no idea about whether the user trying to access the file through the web server user is a logged in Drupal user or just anonymous, and the web server user will be happy to serve it to the anonymous user unless told otherwise).

In other words, you need to have an `.htaccess` file in the *private* directory to instruct Apache to protect it. Drupal usually adds this file for you when you set up the private directory, so you should first check whether an `.htaccess` exists in the *private* directory, and whether it has the right content.

Its content should be as follows:

```
Deny from all

# Turn off all options we don't need.
Options None
Options +FollowSymLinks

# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
  # Override the handler again if we're run later in the evaluation list.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>

# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
  php_flag engine off
</IfModule>

```

If it exists, and has the right content, but does not work, then your Apace configuration is wrong. Make sure t Apache's `AllowOverride` are enabled for your Drupal site.
> 1 votes

# Answer
When using Private file mode, I usually enforce access control on those files with

`hook_file_download`

> Control access to private file downloads and specify HTTP headers.
>
> This hook allows modules enforce permissions on file downloads when the private file download method is selected. Modules can also provide headers to specify information like the file's name or MIME type.

For example:

```
/**
 * Implements hook_file_download
 */
function MODULE_file_download($uri) {

  // You can define your own permission with hook_permission
  if (!user_access('access content')) {
    // Access to the file is denied.
    return -1;
  }

}

```
> 0 votes

---
Tags: files
---


# Question
Title: How can I print the number of the current pager in Views template?
I have a node View with pager configured `Paged output, full pager`, `Items per page：30`

So the view lists only 30 nodes per page. Now I would like to print the number of the current page and the total number of pages on views template `page-my-view.tpl.php`.

For example, `"2 / 10"` when the current page is the 2nd one and the total number of the pages is 10.

How can I do this?

# Answer
> 0 votes
**Global: Result summary** is what you're looking for.

Simply add it into your HEADER or FOOTER wherever you need and then you're requirement is done.

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

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Demo';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Footer: Global: Result summary */
$handler->display->display_options['footer']['result']['id'] = 'result';
$handler->display->display_options['footer']['result']['table'] = 'views';
$handler->display->display_options['footer']['result']['field'] = 'result';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Contextual filter: Content: Author uid */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'node';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['default_action'] = 'default';
$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'user';
$handler->display->display_options['arguments']['uid']['default_argument_options']['user'] = FALSE;
$handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'page' => 'page',
);
/* Filter criterion: Content: Author uid */
$handler->display->display_options['filters']['uid']['id'] = 'uid';
$handler->display->display_options['filters']['uid']['table'] = 'node';
$handler->display->display_options['filters']['uid']['field'] = 'uid';
$handler->display->display_options['filters']['uid']['value'] = '';
$handler->display->display_options['filters']['uid']['exposed'] = TRUE;
$handler->display->display_options['filters']['uid']['expose']['operator_id'] = 'uid_op';
$handler->display->display_options['filters']['uid']['expose']['label'] = 'Author UID';
$handler->display->display_options['filters']['uid']['expose']['operator'] = 'uid_op';
$handler->display->display_options['filters']['uid']['expose']['identifier'] = 'uid';
$handler->display->display_options['filters']['uid']['expose']['remember_roles'] = array(
  2 => '2',
  1 => 0,
  3 => 0,
);

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'demo/%';

/* Display: Attachment */
$handler = $view->new_display('attachment', 'Attachment', 'attachment_1');
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Field: Content: Author uid */
$handler->display->display_options['fields']['uid']['id'] = 'uid';
$handler->display->display_options['fields']['uid']['table'] = 'node';
$handler->display->display_options['fields']['uid']['field'] = 'uid';
$handler->display->display_options['displays'] = array(
  'page' => 'page',
  'default' => 0,
);
$handler->display->display_options['attachment_position'] = 'after';
$handler->display->display_options['inherit_exposed_filters'] = TRUE;

```

---
Tags: views, 6, theming, database, paging
---