# Question
Title: Drush Make Non-existent project type on project metatags
I am attempting to stream line the drush module DL process and it works great. The Issue though is many modules are getting the error:

```
Non-existent project type  on project metatags

```

I attempted to google this but does not seem to be a known error. Here is a copy of my make file (shortened)

```
;Use modules for Drupal 7
core = 7.x

;Drush api 2
api = 2

;Meta Tags
;http://drupal.org/project/metatags
projects[metatags][subdir] = contrib

;Also does not work with this:
;Views
;http://drupal.org/project/views
projects[] = views

```

# Answer
That is correct the project metatags doesn't exist it's actually metatag. Also you need to specify a core version as well.

```
api = 2
core = 7.x
projects[drupal][version] = "7.21"

;Meta Tags
;http://drupal.org/project/metatags
projects[metatag][subdir] = contrib

;Views
;http://drupal.org/project/views
projects[] = views

```

Running the above I get a Drupal 7.21 install with sites/all/modules/views and sites/all/modules/contrib/metatag
> 1 votes

---
Tags: drush
---


# Question
Title: Ways to have lots of blocks on a site which is easy to manage
I am building a new site and the client has about 400 pages under about 5 main categories. Each of these 5 sub-categories has further sub-categories.

My client want to put a block onto each page which has unique content, which is editable.

Let's say that the block is pulling in the content type 'news'. This would be about 400 (ish) blocks - if done just through the blocks UI.

I know about context and view relationships (although not a great deal), but I was wondering if there was anyone out there who had thought on the very best way to approach this idea.

What ways are there to curate this content and make it easy for the client to find what they want to edit?

Is there a whay which has worked for you to go about this set-up, something that experience shows is a good idea, that I might not have thought of?

# Answer
You can use Nodeblock module \- create a content type named "block", and then you can manage edit permissions like with any other node, using modules you want. It'll also support fields, translations et cetera. You can use taxonomy to keep track of what is where.
> 1 votes

# Answer
You can Create a new field in your content type(lets assume TEST\_CONTENT) say `Extra Text` and set *FIELD TYPE* to 'Long Text And Summary'. Yow will need Panels and Pages module to be installed on your machine.

You can implement it using **node view** .If you don't know how to use it , then

* Go to Structure-\>Pages
* Enable `Node View "node_view"` (if not enabled)
* Edit it And add a new variant (link on top right side)
* Give it a title and check the Selection Rules checkbox and click on CREATE VARIANT button nad in Selection Rule Phase Select `Node:Bundle` from drop down field and click Add.
* Now Check the \`TEST\_CONTENT' Content type...
* Save and continue. Then Choose the layout you want for each node to be and Continue. Keep Continuing until u land on Panel Content phase.
* Now each region of your panel page on top left corner you will find a cogwheel . Click on it and click on add content.
* Select \`Node (content)' and form lsit on right select the field '(Extra Filed)'.
* Save and you are have your customised node view.

You can add any text for the specific node ..it is more easy to maintain than creating a block or snippet.

If You Have Custom panel page for each page of your website than you are left with no other choice than creating block for each page.
> 1 votes

# Answer
If u wish to add a static content to your site such as a block which would display same content for every page then you can use the **snippet module**.
> 0 votes

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


title: Views 3 fields as list

text:
# Question
Title: Views 3 fields as list
I am using Views 3 in Drupal 7 to show parent taxonomy terms using nested relationships.

This involves setting up a parent relationship, then a parent relationship of that parent, and then a parent relationship of *that* parent - this goes five levels deep and appears to be working well.

I have set the view to output the term name associated with each relationship, and with Views set to not render anything if the result is empty, I am being left with exactly what i need - a list of all (well, five levels right now) hierarchical parent terms. I have also set views to link each of these term names to their respective pages - and this is what is causing me problems...

Thing is, I want to see these fields as an unordered list. Setting the format option in Views to HTML list obviously sees all of my fields as part of the same result, and thus makes them the same list item.

The first thing I tried was to hide each field from display and rewrite everything using a custom text field:

```
<ul>
<li>[Term_Name_Level_1]</li>
<li>[Term_Name_Level_2]</li>
<li>[Term_Name_Level_3]</li>
<li>[Term_Name_Level_4]</li>
<li>[Term_Name_Level_5]</li>
</ul>

```

This works, but when I'm not five levels deep in the hierarchy (which is most of the time), I end up with empty li tags, as so:

*(I put periods in here to show the effect, as the blank list items don't show here otherwise)*

* .
* .
* .
* Grandparent term name
* Parent term name

The next thing I tried was to rewrite each individual term name field, adding li tags around each one

```
<li>[Term_Name_Level_1]</li>

```

then rewriting the output as follows

```
<ul>
    [Term_Name_Level_1]
    [Term_Name_Level_2]
    [Term_Name_Level_3]
    [Term_Name_Level_4]
    [Term_Name_Level_5]
</ul>

```

This almost worked, as if there is no result, the whole field is left out including the tags. The problem here is that the link to the term page is wrapping *around* the li tags, like so:

```
<ul>
<a href"#whatever"><li>Grandparent term name</li></a>
<a href"#whatever"><li>Parent term name</li></a>
</ul>

```

Thats obviously not what I need, so can anyone think of a way to get Views to output each field as a list item, but without printing empty tags when there is no result? I must say, I have a horrible feeling that I'm overlooking something!

Is there perhaps a way to get Views to output a raw link to each term page, so I can rewrite the lot? I see that there is a 'Taxonomy term: Term edit link' field available, but not a link to the actual term!

Thanks!

# Answer
The credit really goes to Alex Gill above for suggesting this, but as he didn't leave it as an answer (or give any details ;), I figured that I should.

In Views 3, the last option under 'Advanced' (the third column) is 'Theme: Information' - clicking this get you a whole bunch of override suggestions. In my case I created a new template file called 'views-view-fields--**parent-items**.tpl.php', with the '**parent-items**' part being the name of my view. You'll see already customised file names for your particular view under 'Theme: Information'.

In this file (placed in the root of your theme directory) I used conditionals to check if each field existed, before printing it out with the li tags inside those conditionals. See below:

```
<ul id="parent-items">
    <?php if (!empty($fields['name_5']->content)): ?>
        <li><?php print $fields['name_5']->content; ?></li>
    <?php endif; ?>
    <?php if (!empty($fields['name_4']->content)): ?>
        <li><?php print $fields['name_4']->content; ?></li>
    <?php endif; ?>
    <?php if (!empty($fields['name_3']->content)): ?>
        <li><?php print $fields['name_3']->content; ?></li>
    <?php endif; ?>
    <?php if (!empty($fields['name_2']->content)): ?>
        <li><?php print $fields['name_2']->content; ?></li>
    <?php endif; ?>
    <?php if (!empty($fields['name_1']->content)): ?>
        <li><?php print $fields['name_1']->content; ?></li>
    <?php endif; ?>
</ul>

```

\[name\_1\] to \[name\_5\] are my field names, which can be found under the replacement patterns section for each field.

In order to have this work well I also disabled all markup generated by views.

Thanks Alex for the idea, and Елин Й. for a pretty clever suggested workaround.
> 0 votes

# Answer
You can add the Term:ID and set the link to the term in 'rewrite results' as:

```
taxonomy/term/[tid]

```

If you want to keep the aliased URLs, you can use Global Redirect module.

> Once enabled, an alias provides a nice clean URL for a path on a site. However Drupal does not remove the old path (eg node/1234). The problem is that you now have two URLs representing the same content. This is dangerous territory for duplicate pages which can get you sandboxed by the search engines!
> 0 votes

---
Tags: views
---


title: Field Reference Module Problem

text:
# Question
Title: Field Reference Module Problem
I have created 2 content types :

1. Team (Fields: Title, Logo (Image Field)
2. Game (Date, Team "A", Team "B")

Created a Reference Field at Game content type to pull the logo of each team.

However, when I create a new View table format, everything displays fine, but at the frontpage where I get this message:

> Strict warning: Only variables should be passed by reference in \>field\_reference\_field\_formatter\_view() (line 316 of \>/Users/*****/sites/all/modules/field\_reference/field\_reference.module).

This is line 316 of views.module

```
$field_entity = !empty($item['entity_id']) ?

```

I can see that there's something about the fact that the Field Reference is pulling a .JPG file but there's no proper formatter in Views (default, teaser, etc),

Don't know how to correct this,(not a developer) any ideas?

# Answer
> 1 votes
The better option is that you should select a formatter for the image field so that your views work properly when displaying logo images on to it.

---
Tags: entities
---


# Question
Title: How to build Taxonomy Menu with Parents and terms based on node?
After prowling here and Google for a couple of weeks, and not finding the answer, I submit.

I need help assembling a Views-made block, in Drupal 7, that will display links to the pages of each term marked in the content node. I also need it to have a structure of:

Parent Term

* Term Link
* Term Link

Another Parent Term

* Term Link
* Term Link

So far, I cannot get the block to display any results, until I remove the Contextual Filters (that I read I'd need.) Does anyone have any guidance? I've installed/uninstalled, made/deleted more Views, Blocks, and Modules than I'd prefer to. I need for this one menu to take shape, before I can move ahead with development.

# Answer
Here's what I ended up having to do:

* create a new view of Taxonomy Terms, unsorted.
* Add Term: Name, & Vocab: Name as fields.
* Set format as HTML list, grouped by Vocab: Name.
* Add Taxonomy Term: Content with term relationship
* Add Content: Nid contextual filter

I then added a filter to exclude certain vocabularies, and finally, added a weight sorting for both term & vocab names.
> 1 votes

# Answer
Taxonomy Menu Module will help you to create a menu block for a taxonomy vocabulary. You Will Need Menu Module however.

Steps

* Create a Menu By going to `Structure->Menu->` Add a Menu (test\_menu), give it a title and and save.
* Now go to taxonomy and **edit the vocabulary** you want to transform to menu block.
* Under Description box , in **Taxonomy Menu Box** select the menu you want (here test\_menu) from the **dropdown textfield** and save the vocabulary settings.
* Now you can use this menu block wherever you want.
> 1 votes

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


# Question
Title: Upgrade from D6 cause unability to edit existing node
After upgrading my Drupal website from D6 to D7, I regularly get this error message that prevents me from being able to edit existing nodes:

> The website encountered an unexpected error. Please try again later.
>
> PDOException : SQLSTATE\[HY000\]: General error: 1366 Incorrect integer value: '' for column 'field\_galerie\_image\_vdl\_width' at row 1: INSERT INTO {field\_data\_field\_galerie\_image\_vdl} (entity\_type, entity\_id, revision\_id, bundle, delta, language, field\_galerie\_image\_vdl\_fid, field\_galerie\_image\_vdl\_alt, field\_galerie\_image\_vdl\_title, field\_galerie\_image\_vdl\_width, field\_galerie\_image\_vdl\_height) VALUES (:db\_insert\_placeholder\_0, :db\_insert\_placeholder\_1, :db\_insert\_placeholder\_2, :db\_insert\_placeholder\_3, :db\_insert\_placeholder\_4, :db\_insert\_placeholder\_5, :db\_insert\_placeholder\_6, :db\_insert\_placeholder\_7, :db\_insert\_placeholder\_8, :db\_insert\_placeholder\_9, :db\_insert\_placeholder\_10), (:db\_insert\_placeholder\_11, :db\_insert\_placeholder\_12, :db\_insert\_placeholder\_13, :db\_insert\_placeholder\_14, :db\_insert\_placeholder\_15, :db\_insert\_placeholder\_16, :db\_insert\_placeholder\_17, :db\_insert\_placeholder\_18, :db\_insert\_placeholder\_19, :db\_insert\_placeholder\_20, :db\_insert\_placeholder\_21), (:db\_insert\_placeholder\_22, :db\_insert\_placeholder\_23, :db\_insert\_placeholder\_24, :db\_insert\_placeholder\_25, :db\_insert\_placeholder\_26, :db\_insert\_placeholder\_27, :db\_insert\_placeholder\_28, :db\_insert\_placeholder\_29, :db\_insert\_placeholder\_30, :db\_insert\_placeholder\_31, :db\_insert\_placeholder\_32), (:db\_insert\_placeholder\_33, :db\_insert\_placeholder\_34, :db\_insert\_placeholder\_35, :db\_insert\_placeholder\_36, :db\_insert\_placeholder\_37, :db\_insert\_placeholder\_38, :db\_insert\_placeholder\_39, :db\_insert\_placeholder\_40, :db\_insert\_placeholder\_41, :db\_insert\_placeholder\_42, :db\_insert\_placeholder\_43); Array ( \[:db\_insert\_placeholder\_0\] =\> node \[:db\_insert\_placeholder\_1\] =\> 97 \[:db\_insert\_placeholder\_2\] =\> 98 \[:db\_insert\_placeholder\_3\] =\> contenu\_sortie\_action \[:db\_insert\_placeholder\_4\] =\> 0 \[:db\_insert\_placeholder\_5\] =\> und \[:db\_insert\_placeholder\_6\] =\> 251 \[:db\_insert\_placeholder\_7\] =\> \[:db\_insert\_placeholder\_8\] =\> \[:db\_insert\_placeholder\_9\] =\> \[:db\_insert\_placeholder\_10\] =\> \[:db\_insert\_placeholder\_11\] =\> node \[:db\_insert\_placeholder\_12\] =\> 97 \[:db\_insert\_placeholder\_13\] =\> 98 \[:db\_insert\_placeholder\_14\] =\> contenu\_sortie\_action \[:db\_insert\_placeholder\_15\] =\> 1 \[:db\_insert\_placeholder\_16\] =\> und \[:db\_insert\_placeholder\_17\] =\> 252 \[:db\_insert\_placeholder\_18\] =\> \[:db\_insert\_placeholder\_19\] =\> \[:db\_insert\_placeholder\_20\] =\> \[:db\_insert\_placeholder\_21\] =\> \[:db\_insert\_placeholder\_22\] =\> node \[:db\_insert\_placeholder\_23\] =\> 97 \[:db\_insert\_placeholder\_24\] =\> 98 \[:db\_insert\_placeholder\_25\] =\> contenu\_sortie\_action \[:db\_insert\_placeholder\_26\] =\> 2 \[:db\_insert\_placeholder\_27\] =\> und \[:db\_insert\_placeholder\_28\] =\> 253 \[:db\_insert\_placeholder\_29\] =\> \[:db\_insert\_placeholder\_30\] =\> \[:db\_insert\_placeholder\_31\] =\> \[:db\_insert\_placeholder\_32\] =\> \[:db\_insert\_placeholder\_33\] =\> node \[:db\_insert\_placeholder\_34\] =\> 97 \[:db\_insert\_placeholder\_35\] =\> 98 \[:db\_insert\_placeholder\_36\] =\> contenu\_sortie\_action \[:db\_insert\_placeholder\_37\] =\> 3 \[:db\_insert\_placeholder\_38\] =\> und \[:db\_insert\_placeholder\_39\] =\> 254 \[:db\_insert\_placeholder\_40\] =\> \[:db\_insert\_placeholder\_41\] =\> \[:db\_insert\_placeholder\_42\] =\> \[:db\_insert\_placeholder\_43\] =\> ) dans field\_sql\_storage\_field\_storage\_write() (ligne 451 dans /var/www/drupal7/modules/field/modules/field\_sql\_storage/field\_sql\_storage.module).

What can I do to fix this?

I also can't finalise my upgrade due to missing a widget in field type too - could these problems be linked?

# Answer
If there was changes in the fields you were using in the very nodes, that renders nodes unusable, you will need to export data from 6.x site to some more or less universal format, like csv or xml, and import it anew to 7.x

* Delete migrated data and it's content type
* Create new content type with new-style fields, that maps 1:1 to old node structure. If possible, keep names
* Export node data from original site (recreated from backup if needed), using Node Export, Views data export or similar tool
* Secure all the files referenced by nodes
* If needed, manually upload secured files to new version; see next step
* Import nodes using tool like Node Export or Feeds \- it may be required for files to be already uploaded, read the manual of your importing tool
> 1 votes

---
Tags: entities, upgrading
---


# Question
Title: How can I use UUID in a Views relationship?
Two content types: subscriptions and sites. Each site belongs to a subscription. I use the UUID module, since subscriptions and sites are synced from websites elsewhere. Each site has a field\_subscription\_uuid field to identify the subscription it belongs to. There can be multiple sites on each subscription.

I want to make a view that lists sites alongside some of the data from their subscription. I thought I would use the Equi Join module to relate a site's field\_subscription\_uuid to a subscription's uuid. However, Equi Join only lists custom fields (and body), not UUID.

Although I could create a new custom field for subscriptions and sync its own UUID to that field to make it visible to Equi Join, I would rather not because it would be redundant (since the UUID is already a column in the node table).

So I think I have to write a views relationship handler in order to bring a node's uuid into the scope of Views relationships, but I don't know where to start and the API documentation has only confused me more.

How can use a specific node type's UUID in a views relationship without storing the UUID in a custom field?

# Answer
I figured out how to do this. It doesn't require a custom relationship handler. In MYMODULE.views.inc:

```
/**
 * Implements hook_views_data_alter()
 */
function MYMODULE_views_data_alter(&$data) {
  // Add a relationship between the field_subscription_uuid field and node UUIDs
  $data['field_data_field_subscription_uuid']['field_subscription_uuid_value']['relationship'] = array(
    'title' => t('UUID'),
    'help' => t('Relationship for field_subscription_uuid to node UUID.'),
    'handler' => 'views_handler_relationship',
    'base' => 'node',
    'base field' => 'uuid',
    'label' => t('UUID'),
  );
}

```
> 1 votes

---
Tags: 7, views, entities
---


# Question
Title: How can a user join a group in Drupal Commons?
I'm using Drupal Commons (unfortunately 7.x-3.0-beta1).

In Drupal Commons, how can a user join a group?

Either my site has been customized out of all recognition or I simply can't see where a normal authenticated user goes to join a group.

# Answer
1. In your Drupal admin area, go to "Administration → Structure → Content types → Group → Manage Display → Default" (`/admin/structure/types/manage/group/display`).
2. Set column "Format" for field "Group" to "OG subscribe link".

Your groups will now display a "Subscribe to Group" link on the groups' pages. This only applies for users who have the privilege to request membership to a specific group (which can be set in both the global OG permissions, and can be overwritten per group).
> 4 votes

# Answer
From what I understand from the Acquia folks, the join functionality has been renamed to "Follow" in Commons 3. So, if you go to the groups tab, the groups listed should have a Follow button with a megaphone icon that a user can click.

I'm guessing you're aware, but just in case you're not, there is a non-beta version of Commons 3 out now. I had tried out one of the betas and the Follow button was there at the time, but I'm not sure when it was added or if I had beta1 or a more recent beta.
> 2 votes

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


# Question
Title: How to put site in 'Safe-Mode' to troubleshoot Drupal if site encounters problem?
If site goes caput. Quite a few modules have been installed. Site was running perfectly fine until you need to upgrade a few dozen modules now. (I have not been updating my drupal site for quite a few months - imagine how many modules needs updating!) Update was ran, site stopped working. I don't know where to start troubleshooting. Site would not even go to admin/structure pages. It just refuses to cooperate.

I feel there should be a way. Like, looking from the database itself what tables should I delete (should I delete module tables? Would this not entertain more problems?), or is there any specific tables I should look at only and safely delete the contents that should force Drupal to run in 'safe-mode'?

I guess there should be a safe-mode option for Drupal in cases like these but if none, what is the best course of action to put it into 'safe-mode'.

Notes:

# Answer
> 1 votes
First of all, I reccomend you install drush. It provides a ton of handy command line operations for Drupal that will allow you to do things if your site goes belly-up.

* You should troubleshoot by turning off modules with `drush
pm-disable`. Look in your error logs to see if any modules in particular are the culprit.
* You can also enable and disable modules in the database, instructions are here. You can also get some major issues if you move a module to another location and don't rebuild the module registry, which can be done with `drush rr`.
* Make a backup of your DB (and in general, ensure backups are made on a regular basis) before doing anything. Do NOT drop any tables or delete any rows if you don't know what you're doing!

When doing updates, I would advise that you update each module one at a time in a development version of your site, using `drush pm-update`. Once the module is updated, run `drush updatedb` and also `drush cc all`, then check around the site quickly to make sure no major errors have occured.

Generally it's best to do core, then security updates, then version updates. It's also worth checking the version jump (especially with important modules such as Features, or Context) and making sure there are no drastic changes. As an example, Features 2 recently changed the way it stored field settings and it requires some clean up operations that will have to be done manually.

So take great care when updating modules!

---
Tags: 7, debugging
---


# Question
Title: Module: See Last Modified Articles And Submitted Articles
I would like to be able to see who did what and what articles were submitted, possibly on the admin dashboard - is there any module that you would recommend?

# Answer
What you're describing is pretty much available by default. If there's specific changes you need, you should create a View that matches what you need.
> 0 votes

---
Tags: 7
---


# Question
Title: Allow User Role To Schedule Content As Different User
I am creating a "submitter" user role which should be allowed to post articles as different users - what permission do I need to set for this on the "Permission" page under "People" to grant access to the "author" field?

If thats not possible is there a module for it?

# Answer
That would be *Administer Content*. Be careful with this, because the permission provides a lot more than simply control over the node Author identity.

The alternative would be the Masquerade module, which would allow the user to pretend they were a different user, and post content as that user. A little more involved for the posting user, but safer for your site.
> 0 votes

# Answer
Override Node Options module is what you need :)

> The Override Node Options module allows permissions to be set to each field within the Authoring information and Publishing options field sets on the node form. It also allows selected field sets to be set as collapsed and / or collapsible."
> 0 votes

---
Tags: users
---


# Question
Title: Multiple nodes in one slide using views slideshow or another module
I have a slideshow using views\_slideshow which displays the latest post from 4 different content types, I need the slide to show multiple contents (from different content types) in one slide, when you click next there should be another slide containing 4 nodes.

This image might explain you the scenario!

# Answer
The only thing I can think of is to use like Relation to tie these things together using a relation as `Slideshow Content` and then a field tacked onto the relation as `slide number`.

You should be able to then have any number of content types -- relate them to your slideshow and define the ordering as needed that content.

To ease the generation of relating (linking) things these additional relation modules may help:

Relation Add

> Small block that allows the user to add an appropriate relation from an entity page to any other appropriate entities, with a generic autocomplete for each endpoint, and relation fields.

Relation Autoconnect

> Module allows to setup invisible widget to Relation Dummy Field. This widget loads information (entity type and ID) about another entity from arguments in the path and create relation between determined and newly created entity.
>
> For example, you can use path "node/add/story/node/22" to connect new story content with node number 22.

Relation Select

> This module provides a field widget for creating & editing relations.
>
> The selection interface is based on views. Use exposed filters to search for entities, & select items from the view output displayed as a clickable drop down list.

So the idea is you have all your content on the backend -- related via a Relation and its field to grab it for a Views Slideshow later. Some of these modules attempt to make creating that (meta-)relation with your slideshow content easier.

You might be able to use like Arrange Fields or FieldGroup to make a tab for "slideshow properies" for each of your content types that shows the Relation info in the node edit form.
> 1 votes

---
Tags: 7, nodes, javascript, views
---


# Question
Title: JSON URL access restriction within Drupal
I am using Drupanium in Drupal which generates JSON that can be assessed through a URL. The URL in turn is parsed by the app to show data.

Now the problem is that this URL can be publicly assessed by anyone too and anyone can see all the details. The app, on the other hand, shows the same data to the restrictive users.

My question is that how can I restrict anyone who opens the URL through a browser whilst also allowing the app to assess the data through the same URL?

The URL looks like this:-

http://site.com/section/allowed-users-in-the-list.json

Many Thanks.

# Answer
Simple answer is - you need to move credentials check and permission check to your Drupal. If app on a person's computer can see all the data, no matter what you do that person can see all the data just as well. So, in Drupal only allow certain role access to that path, and then only populate results with the data user should see.
> 0 votes

---
Tags: uri, 8
---


# Question
Title: How would I add a section header sub-image based on path in Drupal?
A client has asked me to enter a graphic header (really a sub heading) on a site. This sub-heading graphic would fit nicely, side aligned into the `header` or `leader` region inside our subtheme based on Adaptive Theme.

I'm having a hard time figuring out *how* to best approach this.

**1. Do I use Context based on Path?** That is should I detect the path in Context and use one reaction to place an image into the `header` or `leader` region. I'm assuming I'd have to code about 12 HTML blocks. Though this doesn't exactly sit right with me.

**2. Use CSS logic** Since I insert the first path level into the body class, should I add a div to the header region called `#sub-graphic` and use the following CSS logic:

```
body.sub-section-alpha #sub-graphic {background-image: url('image-alpha.jpg');}
body.sub-section-beta #sub-graphic {background-image: url('image-beta.jpg');}

```

**3. Other, better option** Am I not seeing a simpler way.

Caveat: I'd prefer a non-php solution but I am comfortable inside theme functions.

# Answer
> 1 votes
The simplest solution that Drupal provides. You can create 2 blocks with images. Than set visability on different pages. This is it.

---
Tags: 7, theming
---


# Question
Title: How to get taxonomy contextual filters working by name for users?
I have users sorted by taxonomy. I created a page, added a field to a contextual filter and it works, but by ID only. I want user friendly paths, so I need it to work by name. All solutions I've seen was for nodes, where contextual filter is `Taxonomy:`. There is no `Taxonomy:` filters category for users, i need to use `User: field_name` and I can't get it to work.

# Answer
You should just be able to add the Taxonomy field you associated with the user as a relationship, and then filter on that.
> 1 votes

---
Tags: views, taxonomy-terms, users
---


# Question
Title: How to give a particular role, the right to register new user
We have been targeted by spam bot, and decided to set the option "Who can register new user" as "Administrator only". So far so good.

I would like to let another role (Webmaster) create users as he wishes.

In the permissions settings, I checked the checkbox for "Administer users", but I feel like the option "Administrator only" in the account parameter is overwritting this.

Anyone has an idea of how to do this?

# Answer
> 1 votes
I couldn't get why it's a problem, you are already there, just simply create a role "Webmaster" if you dont have one already, and give this role the same permission "Administer Users" too. but if you only want to give specific permission such as ONLY creating users you might need Administer Users by Role module

> This module allows site builders to set up fine-grained permissions for allowing users to edit and delete other users — more specific than Drupal Core's all-or-nothing 'administer users' permission. It also provides and enforces a 'create users' permission.
>
> To use this module:
>
> Create a role for the users who you'd like to be able to create/edit/delete other users Give that new role the 'administer users' permission and give it the desired Administer Users by Role permissions If the user-being-edited has multiple roles, the user-doing-the-editing must have permission to edit ALL of the user-being-edited's roles.

---
Tags: users
---


# Question
Title: How can I have a view reset when an exposed title filter is emptied?
I have a view that simply lists content. I have one exposed filter "Title" for users to filter content that "contains" and text they insert. I have set the exposed filter to Autosubmit as they type with ajax turned on. The problem is that if the user deletes what they have added to the exposed title filter, the view isn't reset. It stills shows the results of their previous submission. I can of course add a reset button but is there any way to have the view reset itself when the exposed title filter is emptied by the user?

# Answer
You would need to add jQuery to listen on the textfield change event, or similar. If value is empty then set location to current path without querystring. YMMV
> 0 votes

---
Tags: views
---


# Question
Title: How do I unset/hide certain fields from being indexed by the core search module?
If a content type has additional text fields, search core automatically indexes them because search core extracts all text from the result of `node_view()`

I can easily add extra index data via `MODULE_node_update_index( $node )`. This particular hook argument, `$node`, is passed by value and not by reference which means I can't unset certain items.

I hook into `node_view`, and alter it there but I don't want to change the output of the node normally, only when it's being indexed.

# Answer
> 11 votes
Goto the **Manage Display** page for each content type (eg, admin/structure/types/manage/page/display).

Click on the tab for **Custom Display Settings**.

You will see the view modes that your system knows about. Tick **Search Index** and save.

You can now configure which fields get indexed from the tab for that new display mode (eg admin/structure/types/manage/page/display/search\_index)

Dump the search index from **Configuration -\> Search -\> Search Settings** ( admin/config/search/settings), and cron runs will re-index everything. Or, do a `drush -y search-reindex; drush -y search-index` from the command line.

Start reading from `node_update_index()` which is invoked from `search_cron()`, and you will eventually see a `node_view($node, 'search_index');`, which is how that display mode gets used.

---
Tags: 7, hooks, search
---


title: drupal_is_front div changer

text:
# Question
Title: drupal_is_front div changer
I'm trying to find out how I can use drupal\_is\_front in order to remove the content\_side DIV and rename the content\_main DIV (for use with responsive design)

# Answer
Actually there is no function (built into core, at least) called `drupal_is_front()`. I believe what you're looking for is `drupal_is_front_page()` and in your case you could use it like this:

```
<div id="content_<?php if (drupal_is_front_page()): print 'main'; else: print 'something_else'; endif; ?>">
  ....
</div>

```

Or

```
<?php
if (drupal_is_front_page()) {
  $divid = 'content_main';
}
else {
  $divid = 'content_something_else';
}
?>
  <div id="<?php print $divid; ?>">
    ....
  </div>

```

I think it's also worth mentioning that if you're applying the code to a template file, you should also be able to use the variable `$is_front` in place of the function `drupal_is_front_page()`. The difference might be minuscule, but using a variable rather than a function should save you a *little* bit of overhead on your server.
> 3 votes

---
Tags: 7, theming
---


# Question
Title: How to make a rule for limiting one product per cart
Can anyone help me? I want to know how to make a rule for limiting one product per cart. I found rule for limiting qty only but not order item.

I found this with code Drupal Commerce Shopping cart limit But I want to do it with rule ...

# Answer
> 6 votes
Yes, to restrict to one product per order, add a rule:

* Event: before add product to cart,
* Action: remove all products from cart.

The effect is existing products are removed and only the latest selected product is added to the cart.

---
Tags: rules, commerce
---


# Question
Title: Drupal Twitter widget not showing tweets
Hi i am working on drupal site And i have noticed Twitter profile widget is no more working and its showing an empty space in the tweets block. I checked developer pane i have found following notices.

TWITTER WIDGET: The Twitter API v1.0 is deprecated, and this widget has ceased functioning. widget.js:1

TWITTER WIDGET: You can replace it with a new, upgraded widget from https://twitter.com/settings/widgets/new/user?screen\_name=people\_10 widget.js:1

TWITTER WIDGET: For more information on alternative Twitter tools, see https://dev.twitter.com/docs/twitter-for-websites

Do you have any suggestions to overcome this issue ?

# Answer
> 1 votes
You did not provide enough information. Which module? Which version of Drupal? If you're on Drupal 7 and you're using the Twitter module, you must carefully follow the documented installation procedure, documented here.

# Answer
> 0 votes
Twitter is no longer supporting API V1.0 .Those who use API v1.0 should move to embedded timelines option.

You can create your twitter widget here

Reference link

---
Tags: social-network
---


# Question
Title: Field added to user profile does not appear in database?
Drupal 7 provides the ability to add custom fields to the user profile through admin/config/people/accounts/fields.

I have added a *firstname* field. It appears on the registration page but in the database the field is not added. Where it is stored?

# Answer
> 2 votes
The additional fields are stored in a separate table like field\_data\_field\_first.

# Answer
> 0 votes
When the field is added, a new table is created. In Drupal 6 fields might be added as columns to the main table, but in Drupal 7 that is never the case.

---
Tags: 7, users
---


# Question
Title: How to configure view filter to search on the basis of two conditions
I have created a view for users which is having filters: Username,Email,Company and Country. I am also using views bulk operation with these filters.

I can search any record on the basis of above fields but the problem is to search the record on two conditions.

For Example: I want to search on the basis of email: I want the record of those users whose accounts are neither in gmail nor in yahoo.

# Answer
> 0 votes
You can add filters twice. So, to avoid getting gmail or yahoo, you can first add a NOT gmail e-mail filter, and then add a second NOT yahoo filter.

This is not a great way to do it if you have an extremely large number of requirements, but if you only have a few, then it should be fine.

---
Tags: views
---


# Question
Title: add same class to book and it's child pages
I have book node with assigned article nodes as child pages. On certain books I want to be able to use different theming. Using context I can print additional css class on book page according to taxonomy. Is it somehow possible that the class can be passed to all child pages as well? I can not figure out some easy solution. The only way I can think of would be to mark child nodes too. Any ideas? Thank you.

# Answer
One easy way I can think of if it's only about CSS, you can use `body` tag classes, it has different classes based on the nodes.
> 0 votes

# Answer
You could do this in two ways :

1. If you give each individual child nodes , individual class name.
2. You could use the nth child property to the nodes in the CSS part.

**nth child property** could be added as

```
p:nth-child(2){
       background:#ff0000;
}

```
> 0 votes

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


# Question
Title: PHP Fatal error: Call to undefined function chdir()
I tried to copy my site to a new sever and since id did that, I get an *HTTP-Fehler 500 (Internal Server Error):* on certain pages. The log files are reporting:

```
PHP Fatal error:  Call to undefined function chdir() in /var/customers/webs/something/includes/bootstrap.inc on line 3384
PHP Fatal error:  Call to undefined function max() in /var/customers/webs/something/includes/lock.inc on line 106

```

I cleared all caches many times with:

```
drush cc all

```

and also flushed the cache tables directly with MySQL commands. I disabled APC. I don't think, that this is a problem with the server, because it serves well for other Durpal sites.

EDIT: Here are my php.ini and htaccess.

# Answer
`chdir()` and `max()` are built in functions that always exists in PHP. They are in no plugin, just a core. Even in safe mode both should be defined.

There is one way to disable them and make them non-existent from the script's point of view. `disable_functions` section in php.ini does the trick. Usually it is used for safety, like this:

```
disable_functions=exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source

```

and whilst I can see some illusionary\* safety in disabling `chdir()`, disabling `max()` must have been a mistake. Note that on some configurations you can alter ini settings in `.htaccess` and via `ini_set()` too.

\*Illusionary due to the same reasons that made Safe Mode deprecated.
> 2 votes

---
Tags: bootstrapping
---


title: basic theming question on user module

text:
# Question
Title: basic theming question on user module
I would like to ask a very simple (for you probably!) question on theming/layout:

By default the user module displayes the "username" + "password" vertically. I want to display these 2 fields horizontally.

To do so:

-It is the css that I have to modify, right? -Do i have to modify the user.css or the css of my theme? -Any ideas on how do I modify it, or what is the piece of code I have to alter?

Thank you.

# Answer
1. Yes you have to modify the **css** file for the changes to be reflected,but the **change should not be** made in the **core** css files.
2. You can replace any of the core css settings by entering the **specific id's and classes's** of the elements which you would like to **change** into a custom **css file** in your theme's folder.
3. It will **override** the **individual css** settings of that element.
4. Make certain that the file is **identified** as a stylesheet in the **info** file for the theme .(**include the custom css file which you have created in your site's theme's folder in the .info file**)
> 1 votes

# Answer
You can extend Omega Theme and override the css in your `global.css` file. So you will have a new theme and core files are intact.

All you need to install is Omega Theme. And the By going to `Appearence` you can create a new theme and override the css files.
> 1 votes

# Answer
You should add the styling to your theme's css file. Never edit the core files, always override them with your theme files.
> 0 votes

# Answer
If you are using a custom theme follow the steps to modify the CSS

1. goto path var/www/ursite/sites/all/themes/your\_theme/css
2. here add file global.css
3. write the modified css in global.css file.
4. save the global .css file

in order to pre-test the changes use chromo web tool , if you are using google chrome .
> 0 votes

---
Tags: theming
---


title: Recreate search api tables

text:
# Question
Title: Recreate search api tables
When use search\_api, module automatic create more table: search\_api\_db\_article\_title,search\_api\_db\_article\_body,... But I accidentally lost these tables ==\> search\_api can't index. How to get back to the table? I run cron, updatedb but nothing happen :(

# Answer
> 0 votes
Two ways are avaliable:

1. Recreate from nightly or hourly backup. This is preferred way to solve issues like yours.
2. Disable module, uninstall it, and then enable it again. Will be as good as new. To keep configuration:
    1. Export configuration search index to Features.
    2. Disable modules search\_api, search\_api\_db,...
    3. Enable modules again =\> tables will be recreate.

---
Tags: search
---


# Question
Title: How does a user subscribe to a group with GCC?
I have the Groups, Communities and Co (GCC) module installed \[7.x-1.0-beta2\] but I cannot find a way for an authenticated user to subscribe themselves to a group. I have moved the 'GCC Subscription block' so that it's in the sidebar but whatever I do it's still not visible to any user. Has anyone else run into this, probably very simple, issue and found a solution?

# Answer
> When you add the GCC Subscription block to the sidebar, It will not show. The only time it shows up is if a user is subscribed to a group. And then the block shows up with the unsubscribe button.

That's not true.

Here are the basic steps to make the subscription block work :

1. Enable GCC, GCC Context Detection, GCC Node, GCC Block
2. Go to admin/config/gcc/permissions and make sure NON MEMBER has the "Subscribe" permission
3. Go to admin/config/gcc/context, check everything and save.
4. Place the GCC Subscription block where you want.
5. Create a group.
6. Go to your group page with another user and you will see the subscription block
> 1 votes

---
Tags: blocks
---


title: Moving an existing site to Mongo DB

text:
# Question
Title: Moving an existing site to Mongo DB
How hard is it to move a live site to mongoDB when its traffic hits high? Is it easy to built a Drupal site on it? How is the learning curve for a developer who is quite comfortable with Drupal7 and php.

# Answer
I assume you're going to use the mongoDB module. This doesn't move the ENTIRE database over, just parts of it, like cache, blocks, watchdog, etc.

This works well because mongo, or any "document" oriented database is not great at relations. So you can move the data that is not very relational into mongoDB easily.

Mongo itself is cake. Easy to install, easy to understand. It's simply "JSON" data. If you don't know JSON, read up on it now. Already, many parts of Drupal's data are stored as JSON inside text fields in a regular SQL database such as MySQL.

I'd re-iterate that you probably don't want to move EVERYTHING over, like the nodes, taxonomy, etc. Those things are highly relational. Also, the mongoDB module doesn't support those for that reason.

Installation of the module is pretty straight forward and happens in settings.php. See the mongo module readme file for more info.
> 7 votes

# Answer
Fields on a live site can be migrated with drush to mongodb as per chx's post here https://drupal.org/node/1653202
> 2 votes

---
Tags: 7, migrations, database
---


# Question
Title: Migrate existing content types to MongoDB
I have a "Company" content type that has about 30 fields that I'd like to migrate over to MongoDB (field\_sql\_storage to mongodb\_field\_storage).

Would anyone know of a great way to do this?

I have about 150,000 nodes and it's starting to get slow in MySQL.

Thanks!

# Answer
Sure - you want to use the Migrate module to map your fields from a datasource (ex. CSV file) into your new MongoDB. Moshe has a post on this, more related to performance of his method for Amazon RDS but there is an example module that extends the Migrate API to pull the data from a CSV file into his MongoDB database. The relevant include file is here (maybe a little to long to include on stackoverflow?).

To get your data out of the content-type into a csv dump, I would recommend using Views Data Export.
> 3 votes

# Answer
Drupal's mongodb module has built in support for migrating fields. Here is a detailed post by chx on how to migrate fields on a live site with drush to mongodb https://drupal.org/node/1653202
> 2 votes

---
Tags: entities, database, migrations
---


# Question
Title: How to display the replies count of the each user comments with show/hide option in node view page in Drupal 7?
Now, I am having comments section like this in node view page.

```
  Comment 1
    comment 11
    comment 12
  Comment 2
  Comment 3
    comment 31
    comment 32
    comment 33

```

But, I would to show this with show/hide option for replied comments with replies count. like below

```
  Comment 1
    show/hide 2 replies
    ------------------
    | comment 11     |
    | comment 12     |
    ------------------
  Comment 2
  Comment 3
    show/hide  3 replies
    ---------------
    |  comment 31 |
    |  comment 32 |
    |  comment 33 |
    ---------------

```

# Answer
I tried to solve your problem . The best way to solve this is to create a new **CUSTOM MODULE**. \- Create a new folder in Your `sites/all/modules` folder `custom_module` name could be anything.

* In folder create two files `custom_module.info` and `custom_module.module` and a folder `js` . In that folder create a *.js* file `custom_module.js` .
* So now you .js file will be located at `sites/all/modules/custom/js/custom_module.js` . Now Go to `custom_module` folder and in **custom\_module.info** file add the lines of code..

```
name = Custom_module
description = Displays total count of replies to a comment and add display toggler to the replies of the comment.
core = '7.x'
version = '7.x-1.x'
dependencies[] = comment

```
* Now in your **custom\_module.module** file

```
<?php
drupal_add_js(drupal_get_path('module','custom_module') '/js/custom.js');
function custom_module_preprocess_comment(&$variables) {
  $query = db_query('SELECT COUNT(*) FROM comment WHERE pid = :cid', array(':cid' => $variables['id'])) ;
  $result = $query->fetchField();
  $variables['content']['links']['comment']['#links']['comment-reply']['title'] = 'reply </a> <span>('.$result.')</span> <span id="show-hide">Show</span>';
}

```
* So what the module did is fetched the total no of replies of a comment from the database and appended them to reply link.
* A Simple jQuery file will get you what you wanted. Edit your `js/custom_module.js` file **custom\_module.js** file

```
(jQuery)(document).ready( function() {
  jQuery('div.indented').css('display', 'none');
  (jQuery)('div.comment .comment-text ul li.comment-reply span').click( function() {
    if(jQuery('show-hide').html()=='Show') {
      jQuery('show-hide').html()='Hide';
      (jQuery)(this).parents("div.comment").next().slideToggle();
    }
    else {
      jQuery('show-hide').html()='Show';
      (jQuery)(this).parents("div.comment").next().slideToggle();
    }
  });
})(jQuery);

```
* Click On Show in Comments and it will toggle . I have also added a screenshot..

**SHOW** .

**HIDE**
> 6 votes

---
Tags: 7, comments
---


# Question
Title: ajax form link how to call form function with parameters
Is there a good way to use ajax link in form, to call ajax callback function?

I have form elements and i would like to add link, that would call form creation function with some paramaters, so i can change the form accordingly.

The same as form select, which on change submit's form and sends values ...

thanks guys!

# Answer
> 1 votes
There is no `'#type' => 'link'` form element, and `markup` does not have `#ajax` property. So you are down to buttons and images. You can style them to look like a links. Problem is, button will trigger form validation no matter you want it or no.

---
Tags: forms, ajax, navigation
---


# Question
Title: Multisite with some shared content and some different content
I need to create 7 magazine sites with different themes but some content should be shared (like some common pages, some pictures etc).

There should be a common control panel for all websitea so that my customer can upload data on all websites from the same panel. The same content is required because the customer will upload articles on one and it should publish on all site.

I have already setup two demo site with different database on one hosting place and single Drupal installation.

# Answer
You don't really want a multi-site at all by the sounds of it. You're looking for Domain Access

> The Domain Access project is a suite of modules that provide tools for running a group of affiliated sites from one Drupal installation and a single shared database. The module allows you to share users, content, and configurations across a group of sites such as:
>
> * example.com
> * one.example.com
> * two.example.com
> * my.example.com
> * thisexample.com \<-- can use any domain string
> * example.com:3000 \<-- treats non-standard ports as unique

In fact, the ORIGINAL use case for Domain Access was for magazine sites (from the documentation), so it should fit your needs perfectly!
> 3 votes

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


# Question
Title: Overwrite file_directory_temp function without touching the core?
I need to modify the `file_directory_temp()` function, but I can't touch the core.

My drupal-site runs in Microsoft Azure Cloud and I need to exclude all temp files from drupal-root into a absolute location.

I basically want to prefix the value from `variable_get('file_temporary_path')` with an absolute file-path: `"C:\temp" + "\sites\default\tmp"`

Because the absolute part of the path is a dynamic value, which depends on environment and is returned by function `Microsoft_WindowsAzure_RoleEnvironment::getLocalResource('Temp')` it can't be stored in database, due to changing enviroment.

**In a nutshell:**

I need `file_directory_temp()` function to return:

```
$temporary_directory = Microsoft_WindowsAzure_RoleEnvironment::getLocalResource('Temp') . variable_get('file_temporary_path', NULL);

```

instead of:

```
$temporary_directory = variable_get('file_temporary_path', NULL);

```

The prefix is dynamic and can't be stored in database, due to changing enviroment setup.

# Answer
Code for variable\_get() is:

```
function variable_get($name, $default = NULL) {
  global $conf;
  return isset($conf[$name]) ? $conf[$name] : $default;
}

```

So **if value is constant during one page call** you need to set:

```
global $conf;
$conf['file_temporary_path'] = Microsoft_WindowsAzure_RoleEnvironment::getLocalResource('Temp') . $conf['file_temporary_path'];

```

**If value can change for each request**, you need a more bold move. And PHP 5.2.0 or later.

```
class TempClass {
  private $path;
  public function __construct($path) {
    $this->path = $path;
  }
  public function __toString() {
    return Microsoft_WindowsAzure_RoleEnvironment::getLocalResource('Temp') . $this->path;
  }
}
global $conf;
$conf['file_temporary_path'] = new TempClass($conf['file_temporary_path']);

```

That way you'll have an object, that will be converted to string on each use, and on that conversion will retrieve current value from Microsoft\_WindowsAzure\_RoleEnvironment class.

**Where to put it?**

Best place for it seems to be a hook\_boot(). You need to make sure your `hook_boot()` is called first. To get your module to run first, use hook\_module\_implements\_alter() or easier and less reliable way - Modules weight module.

If you don't care about the value provided via UI, you can (maybe should) put it in `settings.php` instead, and substitute reads from $conf\['file\_temporary\_path'\] with hard-coded value. You don't need to use `global` in `settings.php`.

**Conflict with UI**

When you open form to edit `file_temporary_path`, you will see value with Azure's prefix string already prepended. That's not what you want there, as multiple saves would prepend it multiple times. Use `hook_form_alter()` to change default value to one obtained directly from the database, or, if you hardcoded it in `settings.php`, to set it to hardcoded string and disable field.
> 4 votes

---
Tags: 7, files
---


# Question
Title: Clear input field after click without attach any external script
Are there any helper functions contained in **Drupal core or Ctools** to perform popular tasks such as clearing input field after an event occurs ? I know how to do it using external **js** (javascript) file, but I was wondering whether an alternative way for this exists or not ?

# Answer
I doubt it, that would be re-inventing the wheel IMO...what you're describing is pretty much what jQuery is for. Consider this code, which is a basic representation of what you're trying to do:

```
$(function() {
  $('#some-element').bind('someEvent', function() {
    $('#some-other-element').val('');
  });
});

```

That's only 3 meaningful lines of code, and is so trivial that writing a function to wrap around it would be counter-intuitive. The resulting code would end up being equally or more verbose, and all it would do is basically pass parameters blindly to a jQuery function.

Don't forget if you want to invoke any Javascript at all you're going to need an external JS file (or at the very least inline code). I would suggest using the above 3 lines in that external/inline JS would be preferable to using any sort of wrapper function (even if one does exist).
> 4 votes

# Answer
With reference to your question 'Clear input field after click without attach any external script', possibly this will work ::

1. Consider the url http://campusdiaries.com/
2. Here, consider Email & School/College/Org fields on home page (for registration)

Here, we have used below form elements ::

'#attributes' =\>array('placeholder' =\> t('Email')) '#attributes' =\>array('placeholder' =\> t('School/College/Org'))

Here, input field gets cleaned on mouse down.

Hope it helps.
> 0 votes

---
Tags: 7, ajax, chaos-tool-suite
---


# Question
Title: How to override taxonomy page with users view?
When I enable provided views, it works all right. But for one taxonomy dictionary (let's name it *dictionaryname*), I want to display users in that taxonomy, not nodes. So I disabled default view again and then:

* I created "show users" view with path `taxonomy/term/%` and it fails to replace taxonomy page.
* Then I changed path to `dictionaryname/%` \- as path alias is set. But it fails as well.
* I changed path to `aaa/%` and it works, so I know view on it's own works. It just fails to override default pages.

Any idea what am I doing wrong? And how can I get `dictionaryname/%` path to work? It looks like Drupal's router give original term pages precedence over my view.

# Answer
As per reviewing `taxonomy_menu` function, you need to replace path `taxonomy/term/%` with `taxonomy/term/%taxonomy_term` in "show users" view.

If you want to use path alias, set view path like this: `dictionaryname/%taxonomy_term`

Also, check Taxonomy and Views modules weights, make sure Views module weight is higher than Taxonomy module.
> 1 votes

# Answer
With reference to your question, here is a scenario that should help :: (This implementation was done for D6. It will also work for D7 with some changes)

// Say, module name is 'common\_operations'

1. Invoke hook\_menu\_alter

```

    //Overwriting term page display
    if (isset($items['taxonomy/term/%'])) {
      $items['taxonomy/term/%']['title'] = '';// Give title you need
      $items['taxonomy/term/%']['page callback'] = 'common_operations_taxonomy_page_display_callback';
      $items['taxonomy/term/%']['page arguments'] = array(2);
      $items['taxonomy/term/%']['access arguments'] = array('access content');
    }

```
1. Defines 'common\_operations\_taxonomy\_page\_display\_callback'
```

function common_operations_taxonomy_page_display_callback($tid){
  $term = taxonomy_get_term($tid);
  switch($term->vid) {
    case 1: //Blog Tags vocab.
      $blog_tags  = '';
      ............................
    return $blog_tags;
    case 2: //Issues vocab.
      $issues  = '';
      ............................
    return $issues;
    case 3: //Tags vocab.
      $tags  = '';
      ............................
    return $tags;
    default:
      // Returns the default term page provided by taxonomy module.
      module_load_include('inc', 'taxonomy', 'taxonomy.pages');
    return taxonomy_term_page($tid);
  }
}

```
2. Here, Blog Tags, Issues, Tags are different vocabularies. So, whatever changes we need for different vocabulary term details pages, we can take care off independently.

Hope it helps.
> 0 votes

---
Tags: views, taxonomy-terms, users
---


title: Drush shell command not finding module

text:
# Question
Title: Drush shell command not finding module
I am using drush 5.7 and in my command line I can type:

```
drush dl wysiwyg

```

Works great but whenever I create a shell command with several downloads, or even just one download, it throws an error "No release history was found for the requested project"

Very confused and bizarre on why this would be happenning?

Test.sh

```
#!/bin/bash
#WYSIWYG
#http://drupal.org/project/wysiwyg
drush dl wysiwyg

```

# Answer
Use cd to go to the right directory, you can later comment it out. If you have multisite, you have sites/default renamed or using multisite you have to go to that directory for the drush to work.
> 1 votes

# Answer
I'd skip making a shell command to get multiple modules and use a drush make file instead.

> What is a makefile?
>
> A makefile is a macro for installing Drupal. It contains a list of files that can be fetched using the power of drush, the command line tool for administering Drupal.
>
> Using this generator you can specify different Drupal core distributions, modules, themes, and external libraries like jQuery or WYSIWYG editors.
>
> The end result is a small text file containing the DNA for a specific Drupal setup — YOUR perfect setup!

*(taken from the What section of drushmake.me)*

You can use the service as drushmake.me to generate the make file without having to type it all out yourself if it's relatively simple :)

As an example of what a make file can look like, check here. It's old, and I've not updated it in ages but you'll get the idea.

There's also a pretty concise overview of make files here.
> 0 votes

---
Tags: drush
---


# Question
Title: Permission to control revisions without giving full content access in D6
I want users belonging to my 'editor' role to be able to create/revert etc revisions. To do this, as far as I can tell, I have to check the 'administer nodes' option in admin/user/permissions

However this seems to give editors the ability to create any content type (seems to override the specific content type permissions). I want editors to be able to create only certain content type (under node/add).

Is there a way to enable the node revision setting but restrict the content types that can be created?

Drupal 6.

# Answer
You should try using the Workbench module.

> Workbench provides overall improvements for managing content that Drupal does not provide out of the box. Workbench gives us three important solutions:
> 1 votes

# Answer
The best approach for this I guess is trying Revisioning module

> Revisioning is a module for the configuration of workflows to create, moderate and publish content revisions.

on the other hand, for problem with restricting to only a certain content type, you should use Content Access module to achieve that.

> This module allows you to manage permissions for content types by role and author. It allows you to specifiy custom view, edit and delete permissions for each content type. Optionally you can enable per content access settings, so you can customize the access for each content node.
> 1 votes

---
Tags: 6, users
---


# Question
Title: is the Mollom free plan suitable for a site with 300 hits p/m?
I'm looking for the right module to prevent spam. So far I think that the best mollom but I don't fully understand if it is free.

I their website: www.mollom.com they says that `Mollom Free is our most basic spam filtering service, which we make available for free to sites with limited post volumes.`

but also that the free plan is for `Personal blog`.

Let say I can implement it in a restaurant website which get 300 visits a month. Can I use the free plan?

# Answer
> 2 votes
Yes you can use it on a website with 300 visits a month. However it will only allow 50 correct CAPTCHAs in a day but will stop unlimited spam posts.

# Answer
> 1 votes
Mollom **module** for Drupal is free. Mollom **service** is another story, and you need to ask their customer support about it.

---
Tags: advertising
---


# Question
Title: Set default value of field in a field group
I have had no luck trying to set the value of a field in a field group. I can see in the array that the default value has changed but the change does not show up in the viewed form. This is the same whether I place the code in form\_alter or after\_build.

If the field is not in the field group, the changed value is visible in the viewed form.

This is the code I'm testing:

```
<?php

/**
* Modify CCK form elements on the example node form.
*/
function test_after_build($form, &$form_state) {

// $form['field_collection']['und'][0]['value']['#default_value'] = t('Smithfield');

 dsm($form);  // pretty print array using Krumo to messages

  return $form;
}

/**
 * Implementation of hook_form_alter().
 */
function test_form_alter(&$form, &$form_state, $form_id) {

  if ($form_id == 'test_record_node_form')  {

 // target a specific form
  drupal_set_message("Form ID is : " . $form_id);

  $form['field_collection']['und'][0]['value']['#default_value'] = t('Smithfield');

    // Add an after_build function to process when everything's complete.
    $form['#after_build'][] = 'test_after_build';

   dsm($form);  // pretty print array using Krumo to messages

  }

}
?>

```

I don't know what I need to add to this to make it work. Help appreciated.

# Answer
> 0 votes
I was able to spend some more time on this and figured out that the field group was not where I should be changing the value in the form.

I am using the field group multiple module so the value is not being set at the field or the field group. If using devel, look for something like 'fgm\_node\_YOURNODE\_form\_group\_YOURGROUPNAME' where YOURNODE will be the name of your content type and YOURGROUPNAME will be the name you gave to your field group. I'm assuming 'fgm' is short for field group multiple.

You will have to travese 'fgm\_node\_YOURNODE\_form\_group\_YOURGROUPNAME' to find the specific field within the field group multiple that you want to set the default value.

Example:

```
$form['fgm_node_YOURNODE_form_group_YOURGROUPNAME']['fields']['items'][0][field_YOURFIELD']['und'][0]['value']['#default_value'] = t('Some text');

```

My form alter code works now.

---
Tags: 7, entities
---


# Question
Title: Is there a drupal 7 equivalent to the Country Ban module?
I'm wondering if anyone has a Drupal specific solution for blocking entire countries from accessing your server. My company only does business in the US so there's no point in having other countries accessing my site.

For Drupal 6, there is the Country Ban module. Is there a Drupal 7 was to do this?

# Answer
> 1 votes
this module may help you : Smart IP ,,,,

> Overview Smart IP identify visitor's geographical location (longitude/latitude), country, region, city and postal code based on the IP address of the user. These information will be stored at session variable ($\_SESSION) with array key 'smart\_ip' and Drupal $user-\>data object with array key 'geoip\_location' of the user but optionally it can be disabled (by role) .....

---
Tags: 7, advertising
---


# Question
Title: Adding missing Input Formats after Minimal Install
After a minimal install (v7.22) I've only got the 'plain text' input format and am missing the 'filtered HTML' and 'full HTML' formats. Is there a way to have just the missing formats installed or do I need to manually add them? If I have to manually fill in the details where can I get the information them as after searching I cannot find any details on this.

# Answer
> 4 votes
If you want to set them up exactly as they were in the default installation profile, you can just copy the code from `/profiles/standard/standard.install` and run it somewhere (e.g. at `/devel/php` with the Devel module installed):

```
// Add text formats.
$filtered_html_format = array(
  'format' => 'filtered_html',
  'name' => 'Filtered HTML',
  'weight' => 0,
  'filters' => array(
    // URL filter.
    'filter_url' => array(
      'weight' => 0,
      'status' => 1,
    ),
    // HTML filter.
    'filter_html' => array(
      'weight' => 1,
      'status' => 1,
    ),
    // Line break filter.
    'filter_autop' => array(
      'weight' => 2,
      'status' => 1,
    ),
    // HTML corrector filter.
    'filter_htmlcorrector' => array(
      'weight' => 10,
      'status' => 1,
    ),
  ),
);
$filtered_html_format = (object) $filtered_html_format;
filter_format_save($filtered_html_format);

$full_html_format = array(
  'format' => 'full_html',
  'name' => 'Full HTML',
  'weight' => 1,
  'filters' => array(
    // URL filter.
    'filter_url' => array(
      'weight' => 0,
      'status' => 1,
    ),
    // Line break filter.
    'filter_autop' => array(
      'weight' => 1,
      'status' => 1,
    ),
    // HTML corrector filter.
    'filter_htmlcorrector' => array(
      'weight' => 10,
      'status' => 1,
    ),
  ),
);
$full_html_format = (object) $full_html_format;
filter_format_save($full_html_format);

```

---
Tags: input-formats
---


# Question
Title: How to pass the query string used to access a page in a link in a views content pane?
**On a views content pane that shows a list of taxonomy terms, is there any way to simply rewrite all the term links such that the query string in the URL with which the page was accessed is appended?**

I'm using Drupal 7 with Views 3 and Panels 3. I have a views content pane displayed in Panels shows a list of countries. Clicking a country goes to the country's term page (countries are taxonomy terms), which shows all of the users registered in that country (again via Panels overriding the taxonomy term pages). These term pages (also made with views and contextual filters) accept query strings for exposed filters such as \`?friendship=1'.

What I would like to do is link to the location-based search from other pages on the site and pass values to the term page view via the query string. However, since I don't know what country the user will want to search, I have to link to the Panel that shows the list of countries. However, since the views content pane displayed in this panel shows terms by aggregation, the query string is not passed when a user clicks one of the links.

# Answer
If I understand the question, you need to tell views to pass the url path to the content pane (views \> pane settings \> use panel path).
> 0 votes

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


title: popup after contact form submit

text:
# Question
Title: popup after contact form submit
we want the "message sent" message that comes out after you submit the sitewide contact form to come out in a popup instead of in a div on the front page. How can I achieve that?

I have googled everywhere and asked questions on drupal.org but no one has answered me.

# Answer
You can use Better Messages module

> Better Messages is a very simple module that provides "Popup-like" Drupal messages.
>
> Better Messages intends to let you control where and how you want to see your Drupal messages! Combine different animations and override better\_messages.tpl.php to create your custom look.
> 2 votes

---
Tags: emails
---


# Question
Title: Uploaded images broken with secure site turned on
Images I upload through CCK appear broken, the path they are referenced to is blocked with secure site. When I view the image I am taken to the secure site login page, once I enter my login info I can view the image. But I am already logged in. The strange thing is sometimes one of these uploaded images is visible. Uploaded images have the following url structure.

All permissions are set correctly and only these images are blocked by Secure Site.

/sites/default/files/imagecache/142x142/imagefield\_default\_images/def\_expert\_4.png

/sites/default/files/imagecache/142x142/def\_expert\_4\_19.png

sometimes one url works sometimes the other

# Answer
This is because of Imagecache functionality, first URL is your actual size image, the second is your Imagecached image, Imagecache creates seperate image sizes depend on your image-styles that you defined so it can loads the proper image when you print it.

about the login issue, it must be because of your Secure Site module configuration
> 0 votes

---
Tags: 6
---


title: How do I enable CORS?

text:
# Question
Title: How do I enable CORS?
I want to use services 3 module to create node of a content type in my Drupal 6 website.

I have enabled Services 3 module and configured the Rest Server properly. But when I make a post call to it, the browser converts the POST method into OPTIONS and hence the response that is received is http 411 error. Further more, there is an error in that console about Access-control-allow-origin. This clearly means that this is a CORS issue.

I searched for a way to enable CORS in Drupal 6 and found out that we can enable CORS by adding headers in the .htaccess file. I added the following lines to .htaccess file :

> Header set Access-Control-Allow-Origin "\*" env=IS\_CORS
>
> Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
>
> Header add Access-Control-Allow-Headers "x-requested-with"

Is this the correct way to enable CORS in Drupal 6 site?

Thanks in advance. Please try to guide me through this. I am sure many people must have faced this situation, but I am currently not able to find nice solution to this.

# Answer
Doing this in an .htaccess should be OK.

Doing it in the Apache config for the host (main httpd.conf, include for the vhost, etc) is better. When you upgrade Drupal, the .htaccess will be nuked. Also, .htaccess is interpreted for every single access; Apache config (including Includes) is compiled when Apache starts.

You can also use `drupal_set_header()`. You just need to use the right hook for your situation (not terribly familiar with the Services hooks).

```
drupal_set_header('Access-Control-Allow-Origin: "*" IS_CORS');
drupal_set_header('Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS');
drupal_set_header('Access-Control-Allow-Headers: x-requested-with');

```

You may also want to check out the H5BP Server Configs project. I use bits and pieces of this as Apache includes for my virtual hosts, and I am pretty sure they have some good CORS rules.
> 2 votes

---
Tags: 6, services
---


# Question
Title: Is "settings" needed in hook_field_widget_info()?
hook\_field\_formatter\_info() and hook\_field\_widget\_info return an array containing a "settings" index. I want to know when is it used. What happens if it is empty, or just omitted?

My formatter and widget for my custom field **does** have settings. It's just that during widget/formatter definition the settings are not known yet.

# Answer
> 2 votes
If the hooks your module implements don't set that array index, the function invoking them will set them to an empty array. See \_field\_info\_collate\_types().

```
  foreach (module_implements('field_widget_info') as $module) {
    $widget_types = (array) module_invoke($module, 'field_widget_info');
    foreach ($widget_types as $name => $widget_info) {
      // Provide defaults.
      $widget_info += array(
        'settings' => array(),
      );
      $info['widget types'][$name] = $widget_info;
      $info['widget types'][$name]['module'] = $module;
    }
  }

```

```
  foreach (module_implements('field_formatter_info') as $module) {
    $formatter_types = (array) module_invoke($module, 'field_formatter_info');
    foreach ($formatter_types as $name => $formatter_info) {
      // Provide defaults.
      $formatter_info += array(
        'settings' => array(),
      );
      $info['formatter types'][$name] = $formatter_info;
      $info['formatter types'][$name]['module'] = $module;
    }
  }

```

It is then up to the module implementing those hooks, and any related one, to correctly handle the values for that array index, even in the case another module changes it to a value the module is not expecting.

---
Tags: entities
---


title: Views and node references

text:
# Question
Title: Views and node references
I have 3 content types. Town, Hotel and Price. Hotel has a node-reference to Town, Price has a node reference to Hotel.

I'm trying to create a block view to use one the Town node page displaying a list of Hotel nodes in that town, together with the lowest Price (field\_price of the Price node).

Is something like that achievable with views? I did manage to get a list of all hotels in a town by using a contextual filter, but I can't seem to get the additional step of getting the prices in the view.

A custom module would obviously be an option, but if it's possible with views, I would prefer that solution.

# Answer
> 1 votes
You cannot create a relationship from Hotel to Price. You have to go the other way.

Create a block view of Price. Configure a Relationship on the node reference to Hotel (`field_hotel`), and make it required. Add `Content:field_price` (not using relationship) and `Content:Title` (using the relationship) to your display, Add a sort on `field_price` (Ascending).

To limit the display to the Town, create a Contextual filter on `field_town`, have it use the relationship, and set it to *Provide default value:Content ID from URL*.

Configure your block to display on the Town content type, and you are done.

---
Tags: nodes, views
---


# Question
Title: Code running in one theme but not the other
I am using the Mobile Theme module to switch between my themes, in my primary theme's page-front template I have some PHP code including a select statement, it queries tables created by a contributed module. The code works fine in my primary theme but in the mobile theme, the PHP returns nothing. What could cause this change from one Theme's page-front to another? None of this code relies on template.php, but I copied that over in case.

# Answer
> 0 votes
Themes are highly cached. That's a reason why you should avoid logic in them if only you can. And if you have to, put it in template.php, not .tpl files. Probable reason of query not executed is that template got cached and Drupal sees no reason to evaluate files again. You could force it to, probably, but it would be a huge performance killer.

Move your queries to contrib module, and query-based logic to template.php and you'll be good.

---
Tags: 6
---


# Question
Title: Apache Solr Indexing data of custom Table
I am using Apache Solr in a Drupal 6.22 website. The version of Solr is 3.6.2 and using apachesolr-6.x-1.8 module with it. Solr indexed all the node based contents well. But I want to have a custom table indexed. This table shows some promotional data to the website and has ~531,067 data. The schema is below,

```

+-------------+--------------+------+-----+-------------------+----------------+
| Field       | Type         | Null | Key | Default           | Extra          |
+-------------+--------------+------+-----+-------------------+----------------+
| topic_id    | int(11)      | NO   | PRI | NULL              | auto_increment |
| subject_id  | int(11)      | NO   | MUL | NULL              |                |
| title       | varchar(255) | NO   |     | NULL              |                |
| created     | timestamp    | NO   |     | CURRENT_TIMESTAMP |                |
| reply_count | int(11)      | NO   |     | NULL              |                |
| view_count  | int(11)      | NO   |     | NULL              |                |
+-------------+--------------+------+-----+-------------------+----------------+

```

How can I index that table in Solr and how can I add the schemas to schema.xml in Solr? As I have seen the HOOKS in Exposed Solr Hooks (6.x-1.x) for developers, and it seems that using `hook_apachesolr_update_index(&$document, $node)` will do the trick but I want to be sure on this.

Please provide me some idea on this. Thanks in advance.

# Answer
I believe this issue has the information your looking for you have to modify the ApacheSolr schema file to include your custom fields. And tell Solr with an update hook where your data is .... importing that much data could be difficult.

An even better resource may be this blog post from Acquia: Using Apache Solr to Index Custom Data.

Sorry, I wont be able to code up any examples. I dont have Solr installed now, and dont have that much free time.

Both these example links are for D6.
> 1 votes

# Answer
In D6 you will need to register your custom data as a new node type hook\_node\_info() and supply at least a hook\_form(). After a clear cache you should see the custom node type listed in the content types list.

From there you should be able to use `hook_apachesolr_update_index()` to add in the non-standard node fields to the index.
> 0 votes

---
Tags: 6, search
---


title: Webform + reCaptcha - still lot of SPAM

text:
# Question
Title: Webform + reCaptcha - still lot of SPAM
Few months ago I installed reCaptcha module to use with webform. It worked perfectly: I can't submit form if I didn't provide correct captcha code. It worked even if I disable JavaScript. Problem is that I still get a lot of SPAM submissions from this webform. How this can be possible? Drupal version: 6.27. Webform version: 3.18.

# Answer
There is really no silver bullet that can be used to completely stop spam. Spam can only be minimized.

Spam entered by human beings will still always get through -- and there are more and more human being spam farms out there.

The best solution that I have found is to work with Mollom rather than ReCaptcha.

Just as @Bisonbleu mentioned in the comment. Another module you can make use of is the honeypot module

> Honeypot uses both the honeypot and timestamp methods of deterring spam bots from completing forms on your Drupal site (read more here). These methods are effective against many spam bots, and are not as intrusive as CAPTCHAs or other methods which punish the user.
> 4 votes

# Answer
I recently changed to Confident CAPTCHA. It was a straight forward drupal implementation and my users like it.
> -1 votes

---
Tags: 6, webforms, security, advertising, captcha
---


# Question
Title: problem in enabling Commerce 2CheckOut module
I have added 2CheckOut module to drupal 7, then go to drupal admin and modules page to enable it, the module tell me it needs Commerce\_paymen as required module "Requires: Commerce\_payment (missing)".

So, how can I find this module "Commerce\_payment" I searched it out but without luck.

this what i got in modules page: Commerce 2CheckOut 7.x-1.x-dev Payment using 2checkout Requires: Commerce\_payment (missing), Rules (disabled), Entity tokens (enabled), Entity API (enabled)

# Answer
The `commerce_payment` module is bundled with Drupal Commerce. Please feel free to contact 2Checkout tech support at techsupport@2co.com for assistance with your integration.
> 1 votes

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


# Question
Title: How can I view what causes a page to load slow?
i currently have the devel module on and i'm trying to figure out why my site is slow. I get the following info line:

Page execution time was 4661.1 ms. Memory used at: devel\_boot()=3.27 MB, devel\_shutdown()=65.39 MB, PHP peak=70 MB.

Is there a way to view why my page is taking 4661 ms to load? Here's a view of what the page is loading:

# Answer
Yes you can figure out which function(s) spends more time in the execution by using a profiling module, then you can optimize that particular function(s)

Below are the available profiling modules in Drupal 7(AFAIK),

Personally I used XHProf and it helped us lot to improve the performance.

> XHProf is a hierarchical profiler for PHP. It reports function-level call counts and inclusive and exclusive metrics such as wall (elapsed) time, CPU time and memory usage. A function's profile can be broken down by callers or callees. The raw data collection component is implemented in C as a PHP Zend extension called xhprof. XHProf has a simple HTML based user interface (written in PHP). The browser based UI for viewing profiler results makes it easy to view results or to share results with peers. A callgraph image view is also supported.

In addition to this you can also look into Performance Logging and Monitoring module which was removed from Devel.
> 7 votes

# Answer
You could turn on the devel mysql log to see which queries are taking too long to execute. You can also turn on the mysql slow query log in your mysql `my.cnf` file.

I suspect you are using views for this page. If that's the case, check the views filters. Try to add proper filtering on index columns from the node table. Or any other index column. In addition to that, check to see you have mysql cache enabled.
> 2 votes

# Answer
While Drupal supports a number of awesome profiling tools, such as XHProf –which is being used by the Twig team to insure the new theme system is performant– there are also some online graphing tools you use to instantly see what your page load waterfall looks like.

Pingdom is one that gives you a visual display of all loaded assets and how long they took to render.

For example, here's Pingdom's waterfall graph of the page you are reading now:

http://tools.pingdom.com/fpt/#!/hmCRv/https://drupal.stackexchange.com/questions/76227/how-can-i-view-what-causes-a-page-to-load-slow

--

Also, after I posted this answer I couldn't help noticing you are in New York. Come to NYC Camp next month and learn how to performance tune Drupal: http://nyccamp.org
> 1 votes

---
Tags: 7, performance, database
---


# Question
Title: populating a webform select list from a view?
I have a webform in D7 where I want the user to select a value from a dropdown list. These values I want to be dynamically updated from a view. How can I do this?

I found the webform viewreference module, but it's D6. There is a d7 port that someone made using coder, but, like author notes, I get an error when I try to view the form with the view reference webform component.

Are there any solutions out there?

# Answer
Take a look at the sandbox project Webform Views Select.

> This module will let you populate a webform select component with data from a view.
> 4 votes

# Answer
You need to write your own module with a .js file. You have to make a rfi form for that and through you js file take the values.

Suppose on your site you have to select a country and based on that country different values like course, SiteID,AccountID and campaignID need to be selected.

**In .js file you have to do:**

```
(function ($) {
  Drupal.behaviors.highwire_article_nav = {
    attach: function (context, settings) {
      var campus_settings = $.parseJSON(Drupal.settings.settings_campus.campus_data);
      $('select#edit-submitted-occupation').find('option').remove();
      $('select#edit-submitted-occupation').append($('<option>', {
        value: '- Select -',
        text : '- Select -'
      }));
      $('select#edit-submitted-country').change(function(e){
          var campus = $(this).val().toLowerCase();
          var campus_config = campus_settings[campus];
          var campus_courses = campus_config.courses
          $('[name="submitted[siteid]"]').attr('value', campus_config.siteID);
          $('[name="submitted[campaignid]"]').attr('value', campus_config.campaignID);
          $('[name="submitted[accountid]"]').attr('value', campus_config.accountID);
        $('select#edit-submitted-occupation').find('option').remove();
          $.each(campus_courses, function(index) {
            $('select#edit-submitted-occupation').append($('<option>', {
            value: campus_courses[index],
            text : campus_courses[index]
          }));
        });
      });
    }
  }
}(jQuery));

```

**In the rfi form give the values like** :

```
{"country_name":{"course_name":{"0":"Course_name_1","1":"Course_name_2"},"campaignID":"value_of_campaign_ID" , "siteID":"value_of_site_ID" ,"accountID":"value_of_account_ID"}} and so on.

```
> 1 votes

# Answer
EVA might work for that, however I haven't used it in this scenario.
> -1 votes

---
Tags: views, webforms
---


title: Custom Atom feeds using Views

text:
# Question
Title: Custom Atom feeds using Views
I'm wondering if there's a way to make a view render an Atom feed with custom fields, that would output something similar to this:

```
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" ... xml:lang="en-US">
   <title type="text">my atom feed</title>
   <subtitle type="text">my atom feed subtitle</subtitle>
   <id>the feed's url</id>
   <rights type="text">some copyright</rights>
   <updated>2013-06-14T02:29:00Z</updated>
   <author>
      <name>me</name>
   </author>
   <generator>my feed generator</generator>
   <link rel="alternate" type="text/html" href="my site's url" />
   <link rel="self" href="the feed's url" />
   <my:field1>value1</my:field1>
   <entry type="my_type_1">
      <id>an article's url</id>
      <title type="html">article title</title>
      <summary type="html">article summary</summary>
      <published>2013-06-14T01:16:00Z</published>
      <updated>2013-06-14T01:47:40Z</updated>
      <author>
         <name>someone</name>
         <uri>the guy's bio page url</uri>
      </author>
      <content type="html">full body content in <strong>html</strong></content>
      <my:numeric_field>2</my:numeric_field>
      <my:yet_another_custom_field>hi there</my:yet_another_custom_field>
   </entry>
   <entry> ... </entry>
</feed>

```

The views\_rss module can do stuff like this (in fact, I've already accomplished a lot using its hooks to define the fields, and field formatters to do stuff like `<author><name>name taken from a user reference field in the node</name><uri>the user's url</uri></author>`, but I can't find a similar module that provides the same functionality for Atom feeds.

Is there such a module out there? I've tried atom and views\_atom without success. If not, how hard would it be to implement it? I guess this would involve making a "views plugin", with which I'm not really familiar.

# Answer
You don't need a module to do that. You can use `.tpl` files to wrap rows in `<entry>` tags, fields in their tags and so on. It may be a bit less intuitive and more exhausting at first, but in the long run you will get exactly what you ask for, without compromises modules call for.
> 1 votes

---
Tags: 7, views, feeds
---


# Question
Title: Drupal 7 ajax button added via ajax callback
I have an issue with this ajax callback in a form. Here is the callback:

```
function mymodule_add_more_callback($form, $form_state) {

$commands = array();

$current_id = $form_state['number_fieldsets'] - 1;

$id = 'node_group_custom_' . $current_id;

$fs = drupal_render($form['custom_fieldset'][$current_id]);

$commands[] = ajax_command_append(".vertical-tabs .vertical-tabs-panes", $fs);

$commands[] = array(
    'command' => 'enable_tab',
    'id' => $id,
    'id_li' => 'vertical_tabs_li_' . $current_id,
    'current_id' => $current_id,
);

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

```

}

**enable\_tab** is a custom ajax command that works fine.

**$fs** is a fieldset that contains a few form elements.

**$fs** also contains another ajax button that is intended to remove the corresponding fieldset via Ajax

```
$form['custom_fieldset'][$i]['remove'] = array(
'#type' => 'submit',
'#value' => 'x',
'#limit_validation_errors' => array(),
'#attributes' => array(
    'title' => t('Remove section'),
    //'class'   => array('remove_section'),
    'style' => 'cursor:pointer',
    'id'    => 'remove_section_' . $i,
),
'#ajax' => array(
    'callback' => 'mymodule_remove_section',
    'wrapper' => 'names-fieldset-wrapper',
)

```

);

The problem is that the **remove** ajax button does not work as expected. It should trigger this callback **mymodule\_remove\_section** but it is just reloading the page. I assume this is happening bcause it is added with **ajax\_command\_append**. Is there any solution to add ajax buttons with ajax\_command\_append called from another ajax callback?

EDIT

I'm passing a html string - `$fs = drupal_render($form['custom_fieldset'][$current_id]);` that obviously does not have the ajax event attached. Is there any other alternative? For example to pass the `$form['custom_fieldset'][$i]['remove']` button instead of rendered html source along with my custom command?

# Answer
I found the answer here.

I was because of the id of my button.
> 1 votes

---
Tags: ajax
---


# Question
Title: How do I migrate the basic page content to another site?
I have nearly 250 basic pages content and I want to migrate the same content to another Drupal website. I tried using the Backup and Migrate module, but it doesn't work well. How can I do this?

# Answer
> 2 votes
You could check the **Migrate Module** for this.

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

For more details about the module you could go through the README.txt of this module.

# Answer
> 2 votes
As far as I understand from your short question, you want to export only some content to another Drupal installation. In this case Backup and Migrate module will not do any good for you, because it is mainly designed for backing up migrating at database level.

Node Export will allow you to export and import nodes to another Drupal installation.

> Using this module you can save yourself a lot of time setting up new websites that have similar nodes to websites you've already made, migrating nodes to new Drupal versions, or between development/staging/production sites.

---
Tags: 7, backups
---


# Question
Title: How to prevent users from uploading the same file (image) multiple times?
I have a content type, Image, which allows users to add an image using Drupal 7's built-in image field. I would like to automatically prevent users from adding the exact same image (same filename, same size) if possible. Is there any way to prevent duplicate file uploads?

# Answer
There is now a module for this, the File Hash module. Many thanks to Jimajamma for outlining his approach, which allowed me to find this module via Google.

As shown in this thread, the module can currently be used to disable duplicate file uploads globally.
> 3 votes

# Answer
In pseudo/quick code, this is how I would approach it. In a custom module...

1. Create a table in the db, with two columns, fid and md5.
2. Each time you create a file, check if the md5() of whatever you consider unique is in that db, eg:

a. select fid from TABLE where md5 = ab3783ea6c83bcd9383eef778

b. if fid then oops, there already appears to be file blah blah blah

c. otherwise
3. Store that file's fid and md5() in that table.

You could put all this logic in the validation hook when you are creating the image content. You could even set up roles that are able to override it, etc.

Now, to the md5()ing of things.

1. Filename is easily changed and I don't think it is really sent to drupal anyway--but instead crafted there after the fact--so do you really want to use it?
2. Content of the file might be a better approach.

So, md5 could be populated with a quick md5\_file(PATHTOFILE).

Now, let's say you wanted to have an option of doing this system wide or per user, eg, you don't want one user uploading multiple copies of one image or you want to have only one exact image uploaded systemwide.

Just add another column uid to the table above and check it as well, eg:

select fid from TABLE where md5 = ... and uid = $user-\>uid

Anyway, these are just my quick thoughts after the morning's first espresso here in D6land. Maybe D7 has some of this already built into it and I am once again reinventing that wheel :)
> 5 votes

---
Tags: media, nodes
---


# Question
Title: Uploading images so that they are searchable
How would I go about uploading images so that they are searchable, and so that the search results are actually displaying the image thumbnails?

How difficult would it be to integrate this search into the site search?

# Answer
Surest way to make the **images themselves** searchable, is to order Google Search Appliance. It will index them for you, not only data from texts around them, but also the very images themselves. You can easily connect it to Drupal using Google Search Appliance module. It's issue queue claims it supports thumbnails, and if it does not support images yet, it should be relatively easy to add it, especially with Google support you need to buy to get GSA.
> 0 votes

# Answer
To include image data in the core search index, you perhaps could implement hook\_search\_info and hook\_search\_index to add the custom image field text attributes (alt, title text etc..) to the search index.

You can then theme the output of the search results by overriding search-result.tpl.php or using hook\_preprocess\_search\_result to add the image thumbnail.

Further core Search API docs here
> 1 votes

# Answer
If you wish to search by name then you could use the Apache Solr Attachments module which would search the file by its name and if you wish to search by image you should use integrate with Google Search and for more details you could see the answer of Mołot.
> 0 votes

---
Tags: media, search
---


# Question
Title: How to list nodes with at least one field empty?
Is there any module or built-in function to check if all the node fields are filled with some values, and list nodes that fails this check?

EDIT: In short, I just want to get the list of nodes having any of their field empty.

# Answer
Use Views module.

Create a view, then add a filters `Content: field_name (empty)` \- one for each field. Change operator from `AND` to `OR` and done, you have a list of nodes with at least one field empty.
> 2 votes

---
Tags: 7, entities
---


# Question
Title: How to allow user registration and allow them to upload videos?
I am creating a video sharing website like youtube, dailymotion etc. So I need to allow registered users to upload videos when they come to their profile on my website.

I have already setup a media content type with images and video options.

How can I allow users to create it?

# Answer
> 1 votes
If you have to upload a Youtube video in your website, there is the Youtube field module which enables you to upload videos from Youtube by putting the link in the field.

If you want to upload a video from any site use the Media module for this.

> The YouTube field module provides a simple field that allows you to add a youtube video to a content type, user, or any entity.
>
> Display types include:
>
> * YouTube videos of various sizes.
> * YouTube thumbnails with image styles.
>
> This module is a lightweight alternative to Media or Embedded Media Field, if you're looking for a way to add video fields from more than one provider, you may want to consider looking into either of those two modules.

> The Media module provides an extensible framework for managing files and multimedia assets, regardless of whether they are hosted on your own site or a 3rd party site - it is commonly referred to as a 'file browser to the internet'.
>
> Media is a drop-in replacement for the Drupal core upload field with a unified User Interface where editors and administrators can upload, manage, and reuse files and multimedia assets. Any files uploaded before Media was enabled will automatically take advantage of the many of the features it comes with.

# Answer
> 0 votes
Simply allow users register on your site, give permissions to the authenticated users to allow them create contents of the content type you created on the permissions page **admin/people/permissions**. The permission should be under category Node and would look like this

> Your content type name: Create new content

And on your navigation block, if they have permission a link to create that content type would show up

# Answer
> 0 votes
First you need to set up permission to upload node of that content type and edit own content for authenticated user (admin/people/permissions)

Then create a user, login and try to upload a couple of videos.

Then use Views to create a list of content of that content type for that user. Views Documentantion

---
Tags: files
---


title: Making 100's events in one go

text:
# Question
Title: Making 100's events in one go
I am maintaining a calendar for a website where events can be listed in. This year is finishing, which means that soon there will be hundreds of events that need to be put in the calendar for next year. Is there a better way of doing this than manually clicking new page for every event? Ideally I would like to be able to fill a dozen events or so in one go.

# Answer
> 2 votes
If your events are nodes, write them into XML or CSV file. Then, you will be able to use Feeds module to import them in one file upload.

Next time ask the person that makes papers / pdf for you to also send you digital source data she's using.

---
Tags: datetime
---