# Question
Title: Drush: Listing all modules installed on multiple servers
I have many servers installed on the same network, and I want to check them all to see if they need updates. This requires me to login to each server and run `drush up` and check the results.

Can someone suggest a better way to do this, maybe a script or something similar?

# Answer
You can add Drush Aliases for each site, and then add an alias containing all your sites.

Then:

$ drush @allsites up
> 2 votes

# Answer
First step: upgrade to drush-5.x-dev. Next, make one alias file per site called SITENAME.aliases.drushrc.inc, placing each in a valid location for aliases. Inside each of these, define your alias for your live site in a consistent way:

```
$aliases['live'] = array(
  'uri' => ...
  'root' => ...
);

```

In drush-5.x-dev, any operation on the special group alias `@live` will execute on all aliases named "live", so you can just do this:

drush @live --no pm-updatecode

That will give you a nice report tagged with the name of each of your live sites. On Drush 4 (or Drush 5), you can also explicitly define an alias list:

```
$aliases['all-live'] = array(
  'site-list' => '@site1.live', '@site2.live'
);

```

The usage of this alias would then be the same as before:

drush @all-live --no pm-updatecode

In order for this to work seamlessly, you will also need to set up ssh keys on your remote systems so that Drush can connect without a password. There's a lot of good documentation on how to do this, such as http://www.debian.org/devel/passwordlessssh. Also, the drush-extras project has a Drush command that will help push public keys to remote servers.
> 1 votes

---
Tags: 6, drush
---


# Question
Title: Is it possible to use a view as a field in another view?
I have two views. First one is an unformatted view from a content type, and second one is a table view of most viewed from the same content type. Now I want to show both of these views in a page without using panel module. Is there any way to attach these views? thanks.

# Answer
> 1 votes
The title of your question and the body of your question seem different to me.

To use the results of a view as a field in another view, you would use Views Field View.

To display two views at the same time, make one a page display and the other an attachment display attached to the page display.

---
Tags: views
---


# Question
Title: I am looking for suggestions on how to implement banner ads utilizing google type ads (or someone else)
In order to help pay for our drupal 6 website we need to be able to derive some revenue from banner ads. I am looking for suggestions on how to implement banner ads utilizing google type ads (or someone else) so that the ads display within a predefined rectangle and if the users clicks on an ad (which takes them to a new tab/page) it gives our company some revenue.

# Answer
> 1 votes
The most common ad network is Adsense. You will have to sign up for an account and then you can install the Adsense module which will manage your ads for you.

Beware however, this isn't a get rich quick type situation. Making money of Adsense requires a high volume of traffic.

---
Tags: advertising
---


# Question
Title: When using the Omega Responsive theme, IE7 and IE8 load all stylesheets
When I view a site that I'm currently working on in IE7 or IE8, there are tons of conflicting styles. The normal stylesheet is not taking precedence over the global and narrow stylesheets which is causing problems for the layout of the site. I have aggregated both css and js to see if this was an issue with the amount of files IE will load, to no avail. I have patched the omega-mediaqueries.js with the omega-ie7 patch, this did not resolve the issue either.

I'm at a loss and I'm under the gun for time. Has anyone else encountered this issue? How can I make sure that the normal stylesheet takes precedence over the other stylesheets?

# Answer
Omega does not support responsive layouts for IE 8 & below. You will need to add respond.js or a similar javascript to your theme in order to make up for IE 8 & below's lack of support for CSS media queries.

There is an Omega issue on drupal.org related to this topic with more detailed information.
> 4 votes

---
Tags: theming
---


# Question
Title: Understanding Recruiter profile in detail
I am trying to learn installation profiles. So i took up recruiter installation profile and trying to exploit it to learn.

I found the code like in the .profile file

```
<?php
// $Id: standard.profile,v 1.2 2010/07/22 16:16:42 dries Exp $

/**
 * Implements hook_form_FORM_ID_alter().
 *
 * Allows the profile to alter the site configuration form.
 */
function recruiter_form_install_configure_form_alter(&$form, $form_state) {
  // Pre-populate the site name with the server name.
  $form['site_information']['site_name']['#default_value'] = t('eq-Recruiter');
}

/**
 * Implements of hook_install_tasks().
 */
function recruiter_install_tasks() {
  $tasks = array(
    'recruiter_import_vocabularies_batch' => array(
      'display_name' => st('Import terms'),
      'display' => TRUE,
      'type' => 'batch',
      'run' => INSTALL_TASK_RUN_IF_NOT_COMPLETED,
    ),
  );
  return $tasks;
}

/**
 * Defines batch op for importing
 */
function recruiter_import_vocabularies_batch() {
  $batch = array(
    'operations' => array(
      array('recruiter_import_vocabularies', array()),
    ),
    'finished' => 'recruiter_import_vocabularies_finished',
    'title' => t('Import terms'),
    'init_message' => t('Starting import.'),
    'progress_message' => t('Processed @current out of @total.'),
    'error_message' => t('Example Batch has encountered an error.'),
  );
  return $batch;
}

/**
 * Import batch operation for vocs
 */
function recruiter_import_vocabularies(&$context) {
  if (!isset($context['sandbox']['progress'])) {
    $vocs = taxonomy_vocabulary_load_multiple(FALSE);
    $context['sandbox']['progress'] = 0;
    $context['sandbox']['current_node'] = 0;
    $context['sandbox']['max'] = count($vocs);
    $context['sandbox']['vocs'] = $vocs;
  }

```

Here i saw code like `$vocs = taxonomy_vocabulary_load_multiple(FALSE);` He is just saying FALSE here. Does it now require any parameters? If no how is it fetching the values?

# Answer
> 1 votes
```
taxonomy_vocabulary_load_multiple(FALSE)

```

will load *all* vocabularies. If you wanted a specific one you'd pass in the relevant id instead.

---
Tags: 7, distributions
---


title: Views and Lists

text:
# Question
Title: Views and Lists
I would like to create a list with edit and delete buttons/links for each line.
How can I do that in drupal 7.7 ?
I know list can be created with Views module, but can I have buttons/links in the view list ?

# Answer
> 1 votes
Edit and Delete links are available to be displayed in Views. They can be added to the Views output under the Fields options.

# Answer
> 0 votes
You can also switch your views format to "Content" (or "Display Suite" if you use this) instead of "Fields". The fields and informations which are provided there, are then configured on the view mode or the tab "Manage Display" on your content type. With this switch you get also the contextual links for each entry on the view / list like edit or delete.

If you switch to this, i would recommend you to use the "Display suite" module for even more possibilities on how your content type looks in different situations. Very powerful.

# Answer
> 0 votes
Also, to expand on what @sheena\_d said, you could add a custom text field to your view and custom write additional links if the edit/submit links aren't what your looking for.

---
Tags: 7, views
---


# Question
Title: Drupal Commons site has no style after installation
Drupal Commons site has no style after installing it: It looks like campus-24.com.

Note the JavaScript and CSS files are in:

* /home/vhost/WWW/campus-24.com/sites/default/files/js
* /home/vhost/WWW/campus-24.com/sites/default/files/css
* /home/vhost/WWW/campus-24.com/sites/default/files/imagecache
* /home/vhost/WWW/campus-24.com/sites/default/files/ctools
* /home/vhost/WWW/campus-24.com/sites/default/files/pictures

All the folders are empty. During the installation, I noticed warnings about too many files open.

I heard about the "css\_1acaad3d96ebad99fc9b6ef9d4ee4.css" file: This is called an automatic generated file that compress all CSS styles used as to improve speed and help not overloading rendering. What if this file is missing in my folder? Does my site than have to look like the above mentioned site? I have not seen the following options: This is due to the fact in the performance administrative section (admin/settings/performance), in "Bandwidth optimizations" you have "Optimize CSS files" and "Optimize JavaScript files" enabled. These settings are normally very usefull for production (live) sites; for testing and customizing your Drupal Commons installation, it is better to disable them, and to have CSS and JavaScript development support with tools like Firebug.

**Notes:**

* I have not seen where I can switch the options.
* The original .htaccess file was changed by my server admin. I guess that I (and that means the site admin, my friend) miss, and have forgotten, an important option.

Now I found out how to see some overviews, and made a big step ahead; I have landed in the View activity\_log\_stream, displaying items of type Activity Log.

I need some recommendations to figure out how to get some styles in the page.

```
$view = new view;
$view->name = 'activity_log_stream';
$view->description = 'Displays activity streams.';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'activity_log_messages';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
  'message' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'exclude' => 0,
    'id' => 'message',
    'table' => 'activity_log_messages',
    'field' => 'message',
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'last_updated' => array(
    'order' => 'DESC',
    'granularity' => 'second',
    'id' => 'last_updated',
    'table' => 'activity_log_messages',
    'field' => 'last_updated',
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'stream_owner_type' => array(
    'default_action' => 'ignore',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '',
    'breadcrumb' => '',
    'default_argument_type' => 'activity_log_default_stream_owner_type',
    'default_argument' => '',
    'validate_type' => 'activity_log_validate_stream_owner_type',
    'validate_fail' => 'not found',
    'glossary' => 0,
    'limit' => '0',
    'case' => 'none',
    'path_case' => 'none',
    'transform_dash' => 0,
    'id' => 'stream_owner_type',
    'table' => 'activity_log_messages',
    'field' => 'stream_owner_type',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_fixed' => '',
    'default_argument_user' => 0,
    'default_argument_activity_log_stream_owner_type' => 'user',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'page' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '1' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_php' => '',
  ),
  'stream_owner_id' => array(
    'default_action' => 'ignore',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '',
    'breadcrumb' => '',
    'default_argument_type' => 'current_user',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'break_phrase' => 0,
    'not' => 0,
    'include' => array(
      'og' => 0,
      'ur' => 0,
    ),
    'id' => 'stream_owner_id',
    'table' => 'activity_log_messages',
    'field' => 'stream_owner_id',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_fixed' => '',
    'default_argument_user' => 0,
    'default_argument_activity_log_stream_owner_type' => 'user',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'page' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '1' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_php' => '',
  ),
));
$handler->override_option('filters', array(
  'display_type' => array(
    'operator' => '=',
    'value' => 'web',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'display_type',
    'table' => 'activity_log_templates',
    'field' => 'display_type',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'perm',
  'perm' => 'view all activity messages',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('empty', 'There are no visible status updates.');
$handler->override_option('empty_format', '1');
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 20);
$handler->override_option('use_pager', '1');
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'activities');
$handler->override_option('menu', array(
  'type' => 'normal',
  'title' => 'Activity stream',
  'description' => 'Displays activity streams.',
  'weight' => '0',
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler = $view->new_display('page', 'Page', 'page_2');
$handler->override_option('path', '');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));

```

**Update:** On a quick step I did toggle the CSS-aggregation, and switched it off.

Just have a closer look at this, here:

> Your lack of styles on the site is due to inadequate file permissions on your server. Your site is unable to save the auto-generated compressed CSS file, thus there is no style information to be displayed. Installing a different theme would do nothing to fix this situation. If you cannot manage to get the proper files permissions set up, you may try disabling CSS aggregation by navigating to Administration -\> Site Configuration -\> Performance, and **toggling off the CSS aggregation** setting, then clicking the save button. This will have a negative impact on the site's performance (speed of loading pages, etc.) and I would strongly recommend that you fix the underlying issue (file permissions) permanently before launching a live site so that you can re-enable CSS aggregation!

See the very first result of configuring accordingly.

See the very same issue described here. The suggestion is to convert some files to UTF-8, but which specific files should I need to change to UTF-8?

# Answer
I can't tell you what the problem is, but there are some things you can do to debug this. First things that come to my mind are:

1. Check the status report (/admin/reports/status) and recent log messages (/admin/reports/dblog) to see if everything is OK. You may find that the file system is not writable; in that case, modify the permissions on your file folder (on Linux it's usually `chmod -R 777 sites/default/files`).
2. If you think it's caused by the .htaccess file, try if replacing the original .htaccess solves the problem. If it does, apply the needed changes one by one and see when it breaks.
3. Check the PHP/Apache error logs (assuming that you're on a Apache web server) for clues.
> 3 votes

---
Tags: 7, theming
---


# Question
Title: Imagefield submit breaks when I move it in the DOM
I've got a fairly straightforward "user profile" content type. The design of the edit page for this content type has the Imagefield file uploader/thumbnail preview in the right sidebar rather than in the main content area.

I've tried several different methods to get this to work out, and none of them have yet worked. The one I'd like to use is to grab the form-field wrapper with jQuery, and then append it to the right-sidebar region. Like this -

```
$('#profile-pic-ahah-wrapper').appendTo('.region-sidebar-right .section');

```

For some reason, this renders the submit button on that form field totally unresponsive. It's still there, it still shows up when I tinker with it in Firebug, but it doesn't respond to clicks or hovers at all. I'm stumped for now, except that I guess this has something to do with it being AHAH?

Thanks in advance.

# Answer
So the problem turned out to be two things. My approach with picking up the imagefield with `appendTo()` and moving it to the sidebar was failing because I was actually moving the form element outside of the form to which it belonged. So that was never going to work.

The other approach that I had tried was just setting `position:absolute` on the element and moving it over to the sidebar. This worked fine until I interacted with the element, either removing an existing picture or uploading a picture, and then it disappeared from the screen completely. Someone else dug into it with me and found that the element that I was moving - `#edit-field-profile-pic-0-ahah-wrapper` \- had another element nested inside it with this exact same `id`. Whenever I interacted with the element, this other element would pick up the css and zoom another 800px to the right and off my screen.

So the lesson here is that there's a bug in the filefield module - http://drupal.org/node/815206

The problem was solved by using JS to add another class to the element I was trying to target in the first place. Problem solved in 5 minutes (and 2 days).
> 0 votes

# Answer
I think you need a clone() in there to move the event handlers along with it. Check out http://api.jquery.com/clone/ and see if that helps.
> 0 votes

---
Tags: 6, javascript, media
---


# Question
Title: Trying to use EntityFieldQuery to find all nodes with a node reference field not set
After some searching the closest code snippet I've found is:

```
->fieldCondition('field_name_ref', 'nid', 'NULL', '!=');

```

This will find everything where the node reference is not null. But if I change the `!=` to `=` it returns nothing. I've tried all the combinations of values I can think of:

* Passing in `NULL` instead of `'NULL'`.
* Passing in `array()`
* Trying `1, "<"`
* `"", "CONTAINS"`
* `"", "="`
* `0, "="`

Plus a few more, just trying all the combinations I can think of.

How can I pull this off?

# Answer
As crazy as it might sound, you can't. Normally you'd use the `IS NULL` operator to do this but it is apparently not supported by EntityFieldQuery:

EntityFieldQuery does not support isNull or isNotNull

Also I think the EntityFieldQuery internally uses `INNER JOIN`, rather than `LEFT JOIN` so records that don't have a value in your condition table would be excluded from the query results anyway. The issue has been reported several times:
> 7 votes

# Answer
For a workaround I added a custom tag to the query and then I used `hook_query_TAG_alter()`, see #1157006 at drupal.org for more details.
> 5 votes

---
Tags: entities
---


# Question
Title: Flagging content via email notification using Rules, Flags and Drupal 7
I'm using the Flag module to allow authors to approve (or flag) certain types of content that anonymous users upload.

Everything is working well, but I would like to extend the approval feature so it can be done using a notification email as well. I can trigger an email without issue using the Rules module, but I would like to embed the non-ajax version of the flag link to simplify the approval process.

Is it possible to retrieve and send a 'flag' link via email using only the Flag and Rules module? Otherwise, what would be the best way to go about allowing users to flag content via automated notification emails?

# Answer
As far as I know, the Flags module in Drupal 7 has full Rules support since several months, but only in the -dev version, so have you tried something never than the beta?

This ought to be enough to accomplish what you ask for, but I may misunderstand where you are having problems with the integration.
> 1 votes

---
Tags: 7, rules, flags
---


# Question
Title: How to port vertical tabs functionality for custom node module to Drupal 7?
I have a custom module (written for Drupal 6) which defines a new content type. In Drupal 6 I have used several fieldsets and Vertical Tabs module to have the custom node form more clearly laid out. It looked like this

```
$form['event'] = array(
    '#type' => 'fieldset',
    '#title' =>  t('Event'),
    '#weight' => -2,
);

```

While porting that module to Drupal 7, I altered that section to use the now-in-core functionality to

```
M$form['event'] = array(
    '#type' => 'fieldset',
    '#title' =>  t('Event'),
    '#weight' => -2,
    '#group' => 'vt_event',
    '#collapsed' => true,
    '#collapsible' => true,
);
$form['vt_event'] = array(
    '#type' => 'vertical_tabs',
);

```

This indeed works just fine, when converting up to three fieldsets to the new structure. However, my form is more complex and I need at least five additional fieldsets. But as soon as I convert the fourth fieldset to enable it for vertical tabs, I suddenly get 500 server errors.

**Does anyone have any idea why this is happening?** It's always the fourth fieldset when it breaks the site and it's regardless which fieldset is the fourth (I tried to enable three other fieldsets first, but again it breaks on the fourth one which worked before).

# Answer
> 0 votes
While driving me nuts yesterday, I started over again today and cleaned up the module a bit. During that I tried to add another vertical tab again (#4) and this time it worked. By accident, I did re-use a group name and by this I finally was getting fully aware of how this is intended to work.

My mistake was to create a form element of type "vertical\_tabs" for *each* first-level fieldset. But it is sufficient to only have on "vertical\_tabs" form element and assign all fieldsets to that group (they actually are grouped then).

So, everything is fine with my code above but the last three lines are only required once.

---
Tags: 7, forms
---


# Question
Title: When should I add a new tpl.php file, and when should I implement a theme function?
Two part question, both highly related.

1. Can *all* templates be implemented both as a function in template.php, *and* as a separate tpl.php file?
2. In the cases where you can do both, are there advantages to either of the approaches?

# Answer
There are two types of theming something (`theme('function', $args);`)

## **Functions**

The call to `theme` will result in a theme function being called: `theme_foo` with the arguments which will return the HTML string to be outputted. These can be overwritten by creating `THEME_NAME_foo` function in `template.php`

## **Templates**

For template theme functions two things happens, `preprocess_foo` functions are called which will populate variables for the template. These can not be overwritten, but new ones can be added, as the alter an array which will contain all the variables used in the template by reference. The template file itself can be overwritten, by create a file withe the proper name. With use of suggestions, some can take precedence over others in certain cases. (`node-forum.tpl.php` used for forum type nodes vs `node.tpl.php` used for all nodes if no better match exists.)

## **Answer**

So in short, it depends on the definition of the theme function if you should use

* a template and/or preprocess function
* a theme function

But there is never a case where you can use a mix of these.

So

1. No, no template file can be implemented as a theme function.
2. No, you can never use both a theme function and a template, but you can use a preprocess function and a template.
> 4 votes

---
Tags: theming
---


# Question
Title: How to store multiple values in a profile field (specific to each users)?
I have a profile filed called **Amount** corresponding to each users, and I want to store multiple values in the profile field **Amount**. Bu using the custom module, the value of **Amount** is to be inserted on each registration (or it can be inserted any time by a cron program).

For example User **Williams** has Value 100 in his **Amount** field. This is not a single value, it may be

```
Time    Amount
-------+------
Hour 1 :  10
Hour 2 :  30
Hour 3 :  20
Hour 4 :  35
Hour 5 :   5
============
Total  : 100

```

I want to display the total amount and individual amount by exact time.

How to do it?

# Answer
> 4 votes
You might be best installing content profile as this will allow you to use cck, when creating the profile field **amount** you can set it to unlimited which would allow you to store multiple values in an array for a single field.

The **total** would be another dynamic field which is calculated by adding the values from the **amount** array each time they are changed via a hook

To add the field to a content profile, follow the below steps:

1. Edit the profile content type
2. Go to manage fields
3. Add a new "text field
4. Fill in field details
5. On this page you will see a "number of values" option, choose "unlimited"

You can update content profile fields as below, just put it in a custom module or something:

```
//load current user
global $user;
//find the users content profile
$uid = $user->uid;
$node = content_profile_load(profile,$uid);
$pid = $node->nid;
$node = node_load($pid);
//update the field AMOUNT
$node->field_AMOUNT[0]['value'] = $var1;
$node->field_AMOUNT[1]['value'] = $var2;
//do the same for the TOTAL with calculations
$node->field_TOTAL[0]['value'] = $var1 + $var2;
//save the content profile node
node_save($node);

```

# Answer
> 0 votes
You need to create a new profile type in "drupal/module/profile.module" that is called "total."

---
Tags: 6, users
---


title: Bulk replace certain text in nodes

text:
# Question
Title: Bulk replace certain text in nodes
I have a website on Drupal 6 which is being re-branded. The theme is not a problem. However, the website has hundreds of nodes, most of which have references to the original company name.

Is there a way which I can replace every instance of a piece of text with another in a content type. I'm assuming there's not a proper Drupal way of doing this but I wondered if anyone had achieved this somehow. Possibly by querying the database directly to find and replace the text.

Is it just the node table I'd need to query or is there somewhere else which may be hiding bits of text input by the user? Things like taxonomy aren't used on the site, just basic nodes and views as far as I'm aware.

Presumably it'd be something along the lines of:

```
UPDATE `node` SET `column` = replace(`column`, 'Old Company', 'New Company')

```

# Answer
> 6 votes
Always search the contrib modules before rolling your own solution; a quick search for 'Drupal find and replace' turned up the Scanner module:

The module has a stable release and looks to do what you need. As always make backups of your database before utilizing modules that alter your data.

# Answer
> 0 votes
Depending on the configuration of the site you'll be looking to replace text in the following places, using an sql query like you have:

* 'body' column from the 'node\_revisions' table for the body of the nodes
* 'field\_fieldname\_value' column from the 'content\_type\_name' table for single value CCK fields which are not shared by content types
* 'field\_name\_value' column from the 'content\_field\_name' table for multi valued CCK fields or single value fields shared by content types

Bottom line is: if you're not using CCK, look in 'node\_revisions'. If you're using CCK look in 'node\_revisions' and the 'content\_type\_\*' and 'content\_field\_\*' tables.

Also, after you do the replace, clear the cache to see the changes. Either from admin or truncate the 'cache\_\*' tables.

---
Tags: nodes, 6
---


# Question
Title: Implementing Area 51 with Acquia Commons?
I'm probably going to use Acquia Commons to put together a site for communities, and I understand that it's set up as installed to have administrators create the groups and subgroups. However, I'd like users to be able to petition for new groups (and subgroups?) to be created in a process something like Stack Exchange's own Area 51, though perhaps without the following phase.

How would I go about implementing that sort of thing on the current release of Commons? It's based on Drupal 6 until more modules are ported to D7.

# Answer
Here's a simple solution:

* Create a content type, say 'proposal', that any user can add for the petition group (with title as group name and body for reason).
* Users can comment on nodes of that type so they can discuss the proposal.
* Create a view to show nodes of type 'propsal' and enable filtering, sorting etc.
* Use the Votingapi module and one of the voting widgets (like vote up/down) to allow people to vote on the node.

For the creation of the groups, you can either:

* Do it manually, monitoring when a proposal gets a specified number of votes.
* Use the Rules module to do it automatically.
> 4 votes

---
Tags: 6, organic-groups
---


# Question
Title: how to make an automatic download button?
I have a Content type with a file field. I want to add another field (download button) which when users click on that, they would be able to download the file (uploaded in file field), and show file field as a simple preview image or even hidden it.
Is there any module to do this(1:create a button with custom css through cck and 2: automatically link the file path to download button), or any other ways?

# Answer
> 4 votes
The generic file output of the file field is pretty close to what you are asking. It creates a link with a icon showing the file type and links to the file (download, unless the browser understands the file, like an image would be displayed in the browser instead of being downloaded)

You could with theming/css alter the appearance if you so please.

If you want force download, you have to modify the headers sent to the browser. You can use the File Force Download if this is your goal (Thanks for the tip @nicoz). It seems to be using field formatters, which functions much like the generic file display possible with file fields.

---
Tags: entities, files, navigation
---


# Question
Title: Email webform results - only filled fields
Is there a way to email the webform results with only the filled (NOT empty) fields I don´t want all the fields to be mandatory and 80% of my long long form will be optional and it´s very wierd looking to have all those fields listed in the results, if the fields remain empty

# Answer
You could alter the webform email template to check for submission results before outputting them.

The documentation for utilizing the template is here:

http://drupal.org/node/1337488

Look under the Heading 'Using a webform email template'.
> 1 votes

---
Tags: entities, webforms, emails
---


# Question
Title: Block level configuration not available in reaction part of context
I am new to context. I just want to disable a block for a particular URL. But i don't get block level configuration in reaction part of context. Anything else i have to do for it ?

# Answer
In your original context that adds the block you can negate a path by using a Tilde along with your path (in the context condition).

```
e.g. ~your-path

```
> 3 votes

---
Tags: 7
---


# Question
Title: CCK select list and default values from array without writing custom module
For my CCK select list options, I did:

```
//just making up firstName field to simplify example
$sql = "SELECT uid,firstName FROM users";
db_query($sql);
while($row = db_fetch_object($result)) {
  $uids[$row->uid] = $row->firstName;
}
return $uids;

```

This returns something like:

```
'1' => 'joe'
'2' => 'bob'
'3' => 'sarah'

```

Now in CCK, how do I programmatically set the the logged in user's id to be the default selected from the select list? Furthermore, CCK's example of a default return value makes no sense to me:

```
return array(
  0 => array('value' => value for value),
  // You'll usually want to stop here. Provide more values
  // if you want your 'default value' to be multi-valued:
  1 => array('value' => value for value),
  2 => ...
);

```

I know I can do this with hook\_form\_alter, but I am trying this WITHOUT writing any custom module so I can learn CCK and make it easy for my future devs.

# Answer
How about this:

```
global $user;
return array(
  0 => array( 'value' => $user->uid )
);

```
> 2 votes

# Answer
What CCK is looking for is a keyed array as you COULD have multiple values selected/selectable for the field, but in this case I am thinking you have only one, or the '0'th value. Thus, if all you are looking for is the current user id, you could return it this way as the default value:

```
global $user;
$vu=array('value' => $user->uid);

return array(0 => $vu);

```
> 1 votes

---
Tags: 6, entities
---


# Question
Title: How to make a custom page.tpl.php file for a views page?
I have made two pages, one for my sites Terms of Service and a second for a secondary add content page. I made both in views with a custom text field. I would like to have a custom page.tpl.php file for these pages so they can better match my theme. How would I do this? Also, If anyone has a better way for me to make a TOS page, I would appreciate the insight. I will be making a page describing my privacy policy as well as few other things and I want to make sure Im doing this in the most efficient way. Thanks.

# Answer
> 3 votes
I agree with sheena\_d's advice above -- it sounds like what you are trying to accomplish could much more easily be accomplished by using simple pages. That said, here is one way you could do this using views overrides in your template.php theme file.

What you're after is this command:

```
$variables['template_files'][] = "your-new-view.page.tpl.php";

```

but you need to get Drupal to hook into this somehow. One way to do this is with a views preprocess function, added to your template.php file:

```
function <your-theme-name>_preprocess_views_view__<your-view-name>(&$variables) {
    $variables['template_files'][] = "your-new-view.page.tpl.php";
}

```

You would need to replicate this function for however many views you want to override the page.tpl.php file for.

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


# Question
Title: How to use in a view an argument like gids[0]=
I have a custom content type that is associated to groups. When I create a new item, the URL is /node/add/content\_type?gids\[0\]=xxx, where xxx is the node id of the organic group whose this content will be associated. One of the field of this content type is a user reference. I wanted that this reference is restricted to only members of this group. This should be accomplished easily using "select list" as the widget for the user\_reference field and selecting a view which returns just the members of the group as the "View used to select the users:". og\_members views seems perfect, but unfortunately it works with urls like /xxx and not ?gids\[0\]=xxx. I googled a lot and tried several things, even create a new view from scratch, without success. Any help would be appreciated...

# Answer
> 1 votes
Try Views Arguments Extras that lets you set URL params (gid\[0\], in this case) as arguments. You can also "push" arguments to the View at the User-Reference field's settings page. You just need to return the URL param to the View. You must configure the View accordingly.

```
return $_GET['gid[0]'];

```

# Answer
> 0 votes
You will want to use the Views Module, but it has a learning curve (well worth studying!). Try the video series at Nodeone.se called Taming the Beast. You will emerge as a guru of Viewdom.

Also, there is a closely related question here to look at.

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


# Question
Title: Scheduler module- How is the check for publishing done?
I just installed the scheduler module and now I was wondering how the check for publising/unpublishing is done. Is it done by a cron task or is a database query executed at every page load or perhaps something else?

# Answer
It is executed by the cron. The cron triggers a query to check wether something should be published. It is a bit contraintuitive though. If your cron runs every hour and you want something published on 22:35 and it is past that time it will be actually published the next time your cron runs. So if your cron runs at 22:30 and 23:30 the publish will be at 23:30.
> 6 votes

# Answer
The scheduler run as described by reptilex. When it runs, it registers a record in the wathdog table so you can have a look there to be sure everything worked fine.

However this is not very friendly. There's a better way to check this using an undocumented hook of scheduler: `hook_scheduler_api()`.
With this you can write some hook code like this.

```
function mymodule_scheduler_api($node, $action) {
  if ($action == 'publish') {
    $message = 'The content ' . $node->title . ' has been published';
    //Send an email with $message.
    //...
  }
}

```
> 2 votes

---
Tags: 7
---


# Question
Title: Is there a safer way to make preprocess changes?
I recently made changes to template and node.tpl files for my theme. Is there a recommended way of implementing preprocess changes as to not hard code them into these files (in case of theme updates) or am I going to have to re-code them after theme udpates?

# Answer
In an ideal world, you would create a sub-theme off of your master theme. For example, most people don't use the Omega or Zen themes directly; rather they use the starter kit which is included as the basis for the sub-theme.

The sub-theme will inherit features from the base theme, but allow you to customize as needed. When the base theme gets updated, the sub-theme doesn't get touched.

Whether you can retrofit your theme to actually be a sub-theme depends on your situation, but I suspect it is possible.
> 4 votes

---
Tags: 7, theming
---


# Question
Title: Popular Content with statistics module incorrect
So I wrote a custom module for displaying popular nodes, that is based on the buzzworthy module, but with a few tweaks. Buzzworthy has dependencies with the core statistics module.

The results are inaccurate, because when I compare with google analytics, GA yields different results. I know that GA has a latency issue, so it's like comparing apples and oranges, but another reason I know the list that my custom module displays is incorrect, is because it shows a blog post having waaaaaay more page views than it does normally.

Has anybody else had trouble with the accuracy produced by the statistics module? Is there a reason why my counts are incorrect?

# Answer
> 1 votes
There are many reasons the counts from different web counters are off (I had a former boss drive me nuts with that back in 1998 ...):

* statistics module increments page counts on every reload
* when a page is cached it might not increase the statistics counter, depending on the caching used. GA does increase because it's based on browser page loads
* GA doesn't increase when bots are visiting your site (because they don't execute javascript)

I usually rely on GA for my business reports and just use statistics to show counts for my users.

You could also use the Google Analytics module to import GA numbers back into Drupal.

---
Tags: nodes
---


# Question
Title: D6: Create a new template for a specific url of node type page
I'm trying to create a completely different template for a page I have set up at:

http://www.example.com/my\_page

I thought I just added a new node tpl page (node-my\_page.tpl.php), but that doesn't appear to be working. What's the trick?

# Answer
`node-my_page.tpl.php` wont work without additional code. `page-my_page.tpl.php` will in case `my_page` is the system path (node and page templates are not the same thing though). If it's an alias you should find out the system path and create the template file using that. For example if the system path is `node/5` you'd create `page-node-5.tpl.php`.

If simple template suggestions aren't quite enough you can use the code snippets I added below to make things work (copy to your theme template file).

Different page template:

```
function mytheme_preprocess_page(&$variables) {
  if (arg(0) == 'my_page') {
    $variables['template_file'] = 'page-my_page';
  }
}

```

Different node (content part of a page) template:

```
function mytheme_preprocess_node(&$variables) {
  if (arg(0) == 'my_page') {
    $variables['template_file'] = 'node-my_page';
  }
}

```

Note that if `my_page` is not the system path, but only the alias you should use the system path (`node/5` in this example) instead:

```
if ($_GET['q'] == 'node/5') {
  // ...
}

```

Or let Drupal get the alias for you:

```
$alias = drupal_get_path_alias($_GET['q']);
if ($alias == 'my_page') {
  // ...
}

```

You can find more information and additional examples here.
> 1 votes

# Answer
What you're looking for are template suggestions. If you want to change the page layout (regions, general html) use template suggestions for page.tpl.php. OTOH, if you want to change the node layout (the .node div and whatever is within), use template suggestion for node.tpl.php.
> 3 votes

---
Tags: 6, theming
---


title: A way to let themes hook into modules?

text:
# Question
Title: A way to let themes hook into modules?
I'm working on a module which works as an adapter between Drupal and a framework which sends e-mails.

The framework supports inline image attachments, meaning that those images can be carried in the actual message and displayed in the recipients e-mail client without having to download those images from an external location.

I'm thinking that users of this module would be interested in having their e-mails themed so that they reflect the look and feel of the sending website. This is right now done through an 'email.tpl.php' file which the module requests the theming system to theme e-mails with.

Consider a themer/designer that works on theming e-mails. That person then figures out that it would be a good idea to have an inline image attached in e-mails - say a logo. However, how does the designer (via theme functions) tell the module to include one or more pictures which are required by the theme?

I had hoped that my module could make a hook available which other modules and themes could implement, but it appears that only modules can implent hooks. This, at least, applies when using module\_invoke\_all().

My question is thus; is there a way to let any theme provide feedback to a module similar to how other modules can interact with each other via hooks?

# Answer
> 1 votes
If you want to pass *data* into the module, then you don't want to do it at the theme level. The theme layer should be all about output, not data. Try solving it with a fielded entity, templating through a text field with full HTML filter and adding CSS through another field. Images could then be added with a file field.

---
Tags: hooks
---


# Question
Title: How can I use the logged in user's group ID as a contextual filter in Views?
I have Views, Context and OG installed on Drupal 7.

One of the default views is OG User Groups (/user-groups.) It is a **content view** that shows the user which groups they belong to.

I'm trying to create something similar, as a block (and therefore cannot use URL arguments.) I want a **user view** that shows all of the users from the logged in user's group.

In Views, it would make sense that I get the user ID from the logged in user as a contextual filter and then perhaps pass it as an entity ID (etid) to get the group ID (gid). But no matter what I do I cannot make a view that allows this to happen.

Does anyone know I can get the group ID from the current logged in user to use in this view?

https://i.stack.imgur.com/xU2zi.png

# Answer
> 2 votes
Once you enable OG Context, that comes with Organic Groups module, you can clone the og\_members view since it does almost what you want: it shows members from *one* group.

The OG Context module allows the "OG membership: Group gid" contextual filter to have a default value set to "Current OG Group from context". Nice, but we need members from all of the current use groups. So change the default value to "User ID from logged in user" to pass in the current user as the default argument. Then check the "Specify validation criteria" checkbox and choose PHP Code.

```
// let's see if there is a logged in user
if ($argument) {
  // og_get_entity_groups() returns the logged in user groups
  $groups = og_get_entity_groups();
  // setting $handler->argument changes the argument value
  $handler->argument = implode('+', $groups);
  // you have to return TRUE, else nothing works
  return TRUE;
}
// this will run if $argument is 0, for anonymous users
else return FALSE;

```

The "Action to take if filter value does not validate" should be "hide view": no block is shown if there is no logged in user. Expanding the "More" fieldset should be a "Allow multiple values" checkbox. Check it: that's why we imploded the groups array in the argument validation — this way we can pass several groups as arguments.

# Answer
> 0 votes
You can use the URL, but you have to tell the block to do so. 1. Create a contextual filter and go to the section `When the filter value is NOT available`, and select `Provide Default Value` checkbox. 2. For Type, select `Provide raw value from URL` 3. Tell the filter which segment of the path you wish it to use.

I have not tried views with OG, but if you set your format to filters, you can expose any fields associated with the view. If you do not see what you are looking for in the list, use the relationships form in the `Advanced` section of the view form to access the fields you need. (You may need to ask anther question when you get into relationships.)

# Answer
> 0 votes
If you add a relationship n the advanced column and select Content:Author, you can then add a field (column 1) for the User ID (UID).

With the UID exposed, check back in relationships to see if the Group is now accessible. (Sorry, I am not certain how OG handles this info so I can not answer specifically here).

Please, let me know if this works.

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


# Question
Title: I need to control access to a Views-generated JSON feed with OAuth
I'm looking for a way to control access to a Views-generated JSON feed via OAuth, so individual users from a partner site can authorize access to certain of their profile data for use by the partner.

At this point, it seems clear that I need to use the services module with its attendant OAuth authentication to create a server that can hand over JSON. Is there some way I can use views to drive a server?

# Answer
> 0 votes
With the services and services\_views modules, it's possible to repurpose any view into a service with OAuth authentication.

From my testbed, here's what the URL for the service looks like:

```
http://services.localhost:8082/sample_endpoint/views/tracker.json

```

where "sample\_endpoint" is the name of the endpoint, "tracker" is the name of the view being provided as a service, and ".json" is the format for the returned content.

---
Tags: views, 6, authentication-authorization
---


# Question
Title: drupal multilingual frontpages different templates
I am building multilingual site using 3 languages. English is default and 2 other used wit prefixes. www.example.com/fr/.../cs/

I would like to create custom landing page on www.example.com using different template than other landing pages with prefixes.

So www.example.com (which is English language) would only be plain page (custom template) with links to www.example.om/fr (with default template page) and to www.example.com/cs (default template)

Would be something like this possible?

Thank you

# Answer
> 1 votes
Create a custom template file for the English landing page first (for example: `page-customfront.tpl.php`) then add the following code into your theme template.php file:

```
function mytheme_preprocess_page(&$variables) {
  global $language;
  if (drupal_is_front_page() && $language->language == 'en') {
    $variables['template_file'] = 'page-customfront';
  }
}

```

This should do the trick (assuming English will remain the default language with no prefix). Don't forget to switch out `mytheme` in the function name with your actual theme name.

As for the language links you could use the following code:

```
<?php
$langs = language_list();
foreach ($langs as $lang) {
  if ($lang->enabled) {
    if ($lang->language == 'en') continue;
    print l($lang->native, '<front>', array('language' => $lang));
  }
}
?>

```

This should go into `page-customfront.tpl.php` in the place where you want the links to appear. If you are familiar with creating custom modules or don't mind learning it would probably be preferable to turn this code into a function, add it your module file, enable the module and then just call the function from `page-customfront.tpl.php`.

---
Tags: 6, theming
---


title: Image Insert and Theming

text:
# Question
Title: Image Insert and Theming
When you have have an image field on a content type, and use the Insert button to place it into the body, do you get a chance to theme it in Drupal 7? theme\_image doesn't seem to get called, and I am not seeing anything the the API refernce. I know this is JS functionality on the edit page, but there could be ways to still theme it. Thanks.

Edit for clarification:

When you use Insert to get images into the body, just the image gets inserted and the theme system gets bypassed. If you use the image as a field, then all modules get a chance to theme it. This results in inconsistent image usage on a site.

For example, if I use an image as a field, the RDF module will tack on some metadata and my custom theme\_image will do its thing. When I use Insert with the same image, just the plain image gets put in.

On previous projects, I have added some javascript to the theme to fix these discrepancies, but the code needs to be adjusted each time something changes with how images get themed. Ideally, I am searching for a method to allow images-as-fields and image-inserted-into-body to be themed the same way, without resorting to Javascript or manually editing the images in the body. If this isn't built-in functionality, I may try to patch the Insert module to allow it.

# Answer
I will assume you are referring to using the Insert module.

Once you have inserted an item into a node field (most likely the body), it then becomes a simple string of text within that field and is processed as such. There is no longer anything linking it to the image field that you used to upload it, and no way to hook onto it and perform any programatic changes. The only "theming" that can be done to the image at this point is CSS changes.

You could potentially add optional styles for the images via your WYSIWYG's configuration or you could use the Image Resize Filter module to allow the node editor to change the size of the image and/or create a link to the full-size image.

If you could give some details about what exactly you are wanting to do to that images that have been added via the Insert module, there might be another solution someone can suggest.
> 2 votes

---
Tags: 7, theming, media
---


# Question
Title: The development snapshot of Drupal causes error on my server
After having terrible errors with Drupal commons, I decided to install the standard version Drupal developing snapshot (from January 12th).

The original .htaccess was not acceptable; in other words, with the original .htaccess file, it does not show a site at all. I could not see the installation-site at all.

I replaced the .htaccess file with a hacked one.

After the installation I got the following results:

* the final site was blank (http://www.linux-board.com/install.php?profile=minimal&locale=en&op=start&id=1)
* after accessing to basic-site - linux-board.com i see the following error messages:

> Warning: opendir(modules/simpletest/tests/themes/test\_theme) \[function.opendir\]: failed to open dir: Too many open files in file\_scan\_directory() (line 2034 of /home/vhost/WWW/linux-board.com/includes/file.inc).
> Warning: opendir(modules/field/modules/list/tests) \[function.opendir\]: failed to open dir: Too many open files in file\_scan\_directory() (line 2034 of /home/vhost/WWW/linux-board.com/includes/file.inc).
> Warning: opendir(modules/update/tests/themes/update\_test\_subtheme) \[function.opendir\]: failed to open dir: Too many open files in file\_scan\_directory() (line 2034 of /home/vhost/WWW/linux-board.com/includes/file.inc).
> Warning: opendir(modules/update/tests/themes/update\_test\_basetheme) \[function.opendir\]: failed to open dir: Too many open files in file\_scan\_directory() (line 2034 of /home/vhost/WWW/linux-board.com/includes/file.inc).
> Warning: opendir(modules/block/tests/themes/block\_test\_theme) \[function.opendir\]: failed to open dir: Too many open files in file\_scan\_directory() (line 2034 of /home/vhost/WWW/linux-board.com/includes/file.inc).
> Warning: opendir(modules/simpletest/tests/themes/test\_theme) \[function.opendir\]: failed to open dir: Too many open files in file\_scan\_directory() (line 2034 of /home/vhost/WWW/linux-board.com/includes/file.inc).
> Warning: opendir(modules/field/modules/list/tests) \[function.opendir\]: failed to open dir: Too many open files in file\_scan\_directory() (line 2034 of /home/vhost/WWW/linux-board.com/includes/file.inc).
> Warning: opendir(modules/update/tests/themes/update\_test\_subtheme) \[function.opendir\]: failed to open dir: Too many open files in file\_scan\_directory() (line 2034 of /home/vhost/WWW/linux-board.com/includes/file.inc).
> Warning: opendir(modules/update/tests/themes/update\_test\_basetheme) \[function.opendir\]: failed to open dir: Too many open files in file\_scan\_directory() (line 2034 of /home/vhost/WWW/linux-board.com/includes/file.inc).
> Warning: opendir(modules/block/tests/themes/block\_test\_theme) \[function.opendir\]: failed to open dir: Too many open files in file\_scan\_directory() (line 2034 of /home/vhost/WWW/linux-board.com/includes/file.inc).

Can I patch Drupal to go round the too many files open issue, or do I have to upgrade the server, which is six years old?

PS: The information about the server are the following one:

* Web server: Apache/1.3.41 (Unix) mod\_gzip/1.3.26.1a mod\_throttle/3.1.2 mod\_ssl/2.8.31 OpenSSL/0.9.8a
    + PHP 5.3.8
    + PHP register global: disabled
    + PHP extensions: enabled
    + Database support: enabled
    + PHP memory limit: 64M

I guess that the file handlers of Apache could be set up to a higher limit.

# Answer
1. Apache 1.3, is considered deprecated. The very first thing I would try, is upgrading to a 2.\* version, preferably 2.2, and try installing again with the standard .htaccess file. Given the enormous amount of apache servers running Drupal, the standard file *should* work.
2. What is the output of "cat /proc/sys/fs/file-nr"? That's useful for tracking down the to many open files issue, which likely is a server wide issue, and not really Drupal related.
3. While all patches to the 7 branch of core *should* pass all tests, it could be that you have stumbled on a broken commit. Why do you install -dev? Install 7.10 instead.
> 1 votes

---
Tags: installation
---


title: Permit a user to create new accounts

text:
# Question
Title: Permit a user to create new accounts
I am looking for a way to allow one type of users to create a second type of users.

Can anyone advise me on how to do this?

I am using the profile module but creating a profile does not create a corresponding user who owns the profile.

# Answer
> 1 votes
Use the Role Delegation module.

> This module allows site administrators to grant some roles the authority to assign selected roles to users, without them needing the administer permissions permission.
>
> For each role, Role Delegation provides a new assign ROLE role permission to allow the assignment of that role.
>
> The module also adds an assign all roles permission. Enabling this permission for a role is a convenient way to allow the assignment of any other role without having to check all the assign ROLE role permissions in the Permissions page.
>
> If an administrator has the administer users permission, a role assignment widget gets displayed in the account creation or editing form, and bulk add/remove role operations become available on the user administration page. Otherwise, if s/he has at least the access user profiles permission, the module adds its own Roles tab to the user profile so that roles can be assigned.

# Answer
> 0 votes
In Drupal 7, go to `admin/people/permissions` and way down at the bottom under 'Users,' there is an option for 'Administer users.' Pretty sure it's similar in D6. The pattern would be to create a new group, with a name like 'Officer' and give officers this power.

The super ultra mega downside to this is that any user with this power can delete user 1. So don't do it. :-) I suggest an invitation system instead: http://drupal.org/project/invite.

---
Tags: users
---


# Question
Title: Allow users to edit their own content and admin-generated content
On Drupal 6, how can I let registered users edit their own content and also allow them to edit an already existing admin content (just one content type) and then when saved, the user takes ownership of that node?

# Answer
> 1 votes
You can give the 'Authenticated user' role permission to 'Edit any `<content type>` content'. If you configure that content type to create a new revision by default, the user will be registered as the author of that revision (and if you don't give them the 'Administer nodes' permission, they can't uncheck the option to make a new revision). The original author of the node will however still be listed. I can't think of an easy way to change that automatically. But the users can already edit all nodes of that type anyway, so it would only be relevant if you use the node author for some listing or so - in that case, you can probably use Rules to do assign latest revision author as node author.

Edit: OK, so in that case this doesn't help. You can investigate if something along these lines works (I haven't done something like this so I'm not sure it's possible without coding):

* Setup a condition for Rules with Context Rules, something like 'Node author is "admin"'.
* Create a Rules action using Content Access to set 'Per node access control' if that Context condition is triggered.

---
Tags: nodes, users
---


# Question
Title: How to add custom user fields to the Author Pane
I have a custom field for all my users called "Twitter URL," I would like to add a link in the author pane that will go to the "Twitter URL that my users set.

I would like to add a tagg like:

```
<a href="<?php print $twitter_id; ?>">Twitter</a>

```

within the author pane block.

here is the author\_pane.tpl.php:

```
<?php

/**
 * @file
 * Theme implementation to display information about a given user.

 * Since the user is the author of a post or of a profile page, the user is
 * referred to as "author" below.

 * Available variables (core modules):
 * - $account: The entire user object for the author.
 * - $picture: Themed user picture for the author.
 *   See author-pane-user-picture.tpl.php.
 * - $account_name: Themed user name for the author.
 * - $account_id: User ID number for the author.
 *
 * - $joined: Date the post author joined the site. (Uses shortdate format)
 * - $joined_ago: Time since the author registered in the format "TIME ago"
 *
 * - $online_status_class: "author-offline" or "author-online".
 * - $online_status: Translated text "Online" or "Offline"
 * - $last_active: Time since author was last active. eg: "5 days 3 hours"
 *
 * - $contact: Linked translated text "Contact user".
 *
 * - $profile - Profile object from core Profile module.
 *     Usage: $profile['category']['field_name']['#value']
 *     Example: <?php print $profile['Personal info']['profile_name']['#value']; ?>

 * Available variables (contributed modules):
 * - $facebook_status: Status, including username, from the Facebook-style
 *   Statuses module.
 * - $facebook_status_status: Status from the Facebook-style Statuses module.
 *
 * - $privatemsg: Linked translated text "Send private message" provided by
 *   the Privatemsg module.
 *
 * - $user_badges: Badges from User Badges module.
 *
 * - $userpoints_points: Author's total number of points from all categories.
 * - $userpoints_categories: Array holding each category and the points for
 *   that category. Both provided by the User Points module.
 *
 * - $user_stats_posts: Number of posts from the User Stats module.
 * - $user_stats_ip: IP address from the User Stats module.
 *
 * - $user_title: Title from the User Titles module.
 * - $user_title_image: Image version of title from User Titles module. This is
 *   not shown by default. If you want to show images instead of titles, change
 *   all instances of the variable in the code below.
 *
 * - $og_groups: Linked list of Organic Groups that the author is a member of.
 *
 * - $location_user_location: User location as reported by the Location module.
 *
 * - $fasttoggle_block_author: Link to toggle the author blocked/unblocked.
 *
 * - $troll_ban_author: Link to ban author via the Troll module.

 * Not working as of this writing but kept for future compatability:
 * - $user_relationships_api: Linked text "Add to <relationship>" or
 *   "Remove from <relationship>".
 * - $flag_friend: Linked text. Actual text depends on module settings.

 */
?>

<?php
  // This bit of debugging info will show the full path to and name of this
  // template file to make it easier to figure out which template is
  // controlling which author pane.
  if (!empty($show_template_location)) {
    print __FILE__;
  }
?>

<div class="author-pane">
 <div class="author-pane-inner">
    <?php /* General section */ ?>
    <div class="author-pane-section author-pane-general">
      <?php /* Account name */ ?>
      <div class="author-pane-line author-name">
        <?php print $account_name; ?>
      </div>

      <?php /* User picture / avatar (has div in variable) */ ?>
      <?php if (!empty($picture)): ?>
        <?php print $picture; ?>
      <?php endif; ?>

      <?php /* Online status */ ?>
      <?php if (!empty($online_status)): ?>
        <div class="author-pane-line <?php print $online_status_class ?>">
           <?php print $online_status; ?>
        </div>
      <?php endif; ?>

      <?php /* Last active */ ?>
      <?php if (!empty($last_active)): ?>
        <div class="author-pane-line">
           <span class="author-pane-label"><?php print t('Last seen'); ?>:</span> <?php print t('!time ago', array('!time' => $last_active)); ?>
        </div>
      <?php endif; ?>

      <?php /* User title */ ?>
      <?php if (!empty($user_title)): ?>
        <div class="author-pane-line author-title">
          <span class="author-pane-label"><?php print t('Title'); ?>:</span> <?php print $user_title; ?>
        </div>
      <?php endif; ?>

      <?php /* User badges */ ?>
      <?php if (!empty($user_badges)): ?>
        <div class="author-pane-line author-badges">
          <?php print $user_badges; ?>
        </div>
      <?php endif; ?>

      <?php /* Location */ ?>
      <?php if (!empty($location_user_location)): ?>
        <div class="author-pane-line author-location">
          <?php print $location_user_location;  ?>
        </div>
      <?php endif; ?>

      <?php /* Joined */ ?>
      <?php if (!empty($joined)): ?>
        <div class="author-pane-line author-joined">
          <span class="author-pane-label"><?php print t('Joined'); ?>:</span> <?php print $joined; ?>
        </div>
      <?php endif; ?>

      <?php /* Posts */ ?>
      <?php if (isset($user_stats_posts)): ?>
        <div class="author-pane-line author-posts">
          <span class="author-pane-label"><?php print t('Posts'); ?>:</span> <?php print $user_stats_posts; ?>
        </div>
      <?php endif; ?>

      <?php /* Points */ ?>
      <?php if (isset($userpoints_points)): ?>
        <div class="author-pane-line author-points">
          <span class="author-pane-label"><?php print t('!Points', userpoints_translation()); ?></span>: <?php print $userpoints_points; ?>
        </div>
      <?php endif; ?>
    </div>

    <?php /* Contact section */ ?>
    <div class="author-pane-section author-pane-contact">
      <?php /* Contact / Email */ ?>
      <?php if (!empty($contact)): ?>
        <div class="author-pane-line author-pane-link-line author-contact">
          <?php print $contact; ?>
        </div>
      <?php endif; ?>

      <?php /* Private message */ ?>
      <?php if (!empty($privatemsg)): ?>
        <div class="author-pane-line author-pane-link-line author-privatemsg">
          <?php print $privatemsg; ?>
        </div>
      <?php endif; ?>

      <?php /* User relationships */ ?>
      <?php if (!empty($user_relationships_api)): ?>
        <div class="author-pane-line author-pane-link-line author-user-relationship">
          <?php print $user_relationships_api; ?>
        </div>
      <?php endif; ?>

      <?php /* Flag friend */ ?>
      <?php if (!empty($flag_friend)): ?>
        <div class="author-pane-line author-pane-link-line author-flag-friend">
          <?php print $flag_friend; ?>
        </div>
      <?php endif; ?>
    </div>

    <?php /* Admin section */ ?>
    <div class="author-pane-section author-pane-admin">
      <?php /* IP */ ?>
      <?php if (!empty($user_stats_ip)): ?>
        <div class="author-pane-line author-ip">
          <span class="author-pane-label"><?php print t('IP'); ?>:</span> <?php print $user_stats_ip; ?>
        </div>
      <?php endif; ?>

     <?php /* Fasttoggle block */ ?>
     <?php if (!empty($fasttoggle_block_author)): ?>
        <div class="author-fasttoggle-block"><?php print $fasttoggle_block_author; ?></div>
      <?php endif; ?>

     <?php /* Troll ban */ ?>
      <?php if (!empty($troll_ban_author)): ?>
        <div class="author-pane-line author-troll-ban"><?php print $troll_ban_author; ?></div>
      <?php endif; ?>
    </div>
  </div>
</div>

```

# Answer
> 0 votes
I did a `var_dump()` on `$account` and then just went in and found exactly where the variables I needed were stored within `$account`. I then just print them out with print inside the proper HTML tags I needed.

# Answer
> 1 votes
Look at this answer. Display suite module is the easiest way. https://drupal.stackexchange.com/a/19120/4067

---
Tags: 7, entities, blocks, users
---


# Question
Title: How do you get the nid from an entity id?
I've got a field collection attached to a node. Given the entity ID of a given instance of that collection, how do I obtain the nid to which it's associated?

When using entity\_load, the nid for some reason is a protected property, so I can't access it. I must be missing something.

Update: using node\_load on this entity ID returns false.

# Answer
> 4 votes
It's important to understand that if all you have is the id of *any* entity, then there is no way to load a specific entity with that id. Since entity\_id's are not unique across entity-types, it is necessary to know both the entity type, **and** the entity id.

See Developers need an $entity-\>entity\_type property for a discussion on changing this for D7, as well as info about how this will be likely be handled in D8.

On the other hand, as pointed out in a different answer, if you already know that the entity id is a node id, then you can call an entity specific load function like `node_load($nid)`. Since most entities will have such a load function to support named arguments, such a "shortcut" function will be almost universally available.

Examples: node\_load(), taxonomy\_term\_load(), commerce\_product\_load().

# Answer
> 3 votes
In this example Classroom is a content type (entity) with a field called `field_students`. `field_students` is a node reference field, and it references nodes (entities) of content type Student.

```
// Get all the Student items attached to a field.
$studets = field_get_items('node', $classroom, 'field_students');

// Get the node id of the Student entity in the first field entry.
$student_nid = $studets[0]['nid'];

// Create a full object (node) representation of the student.
$student_obj = node_load($student_nid);

```

---
Tags: 7, entities, nodes
---


# Question
Title: How would I have got blog and news pages to list articles/blogposts, how do I edit?
I have a 'blog' page that lists blog posts and a 'news/events' page that lists articles.

I cannot remember how they got there, if they were automatically generated. I think I had to do something at least for the articles page, but I cannot find anything about why mysite.com/news lists all the articles and how mysite.com/blog lists blog posts. I've looked through structure and content and views and don't see where this is coming from and I have no hover in the admin interface to edit the whole page (just individual posts). These pages seem not to have any titles set, either.

The main concern here is in the menu right now they are absolute links and I want to be dynamic, relative paths.. but I don't know what to put for that. I also need to make sure they properly get an 'active' state in the menu, which currently they do not!

# Answer
In Drupal 7, go to /admin/structure/menu/manage/ to manage your menus. Select "Main Menu" as that will probably be your primary navigation.

Click +Add Link. For both Blog and News, set the appropriate name in the "Title" field.

For path, set the Blog path to "blog" or for News you can set it to "home" to retrieve articles promoted to the front page, or something like "news" if you have a specific page with a path set to that for those articles to be displayed on.
> 1 votes

---
Tags: 7, nodes
---


title: Commerce Kikstart rules how to

text:
# Question
Title: Commerce Kikstart rules how to
I'm trying to make a subscription product with "Commerce subscription products" module, so I've stuck here, on how to edit rule for subscription to last for 30 days, that is the first, part, second is, is there some good tutorial on rules, in drupal 7 ?

# Answer
It's hard to say, what your problem with Commerce subscription products is, without more detail.

Randy Fay have made a lot of screen casts about Commerce which also include configuration about Rules. You might be able to find a more better tutorial on Rules, but Randy does a really good job on stepping through different tasks in Commerce. There isn't a screen cast about subscriptions, but you should be able to get a lot of help from some of these anyways.
> 1 votes

# Answer
The Rules Framework simply explained in its entirety is well presented by Johan Falk here.

I recommend any of these tutorials highly.
> 0 votes

---
Tags: commerce, rules, notifications
---


# Question
Title: Importing large flat-file data sources with Drupal 7 with Views 3 integration
My goal is to produce a fast, reliable and automated method for accessing *read-only* data contained in several very large flat-file data sources (CSVs, Fixed Width and XML docs) using Drupal 7 that can be queried against using the Views 3 module. I would prefer to use already available modules, but building a custom module is also an option.

To help rule out modules and methods not suited for the task, here are the stats on the files I'm working with:

* Yearly Import: 8,500,000 line CSV file. (Purged and reloaded yearly. Has primary key.)
* Weekly Import: 350,000 line fixed width file. (Purged and reloaded weekly. **No primary key**.)
* Hourly Import: 3,400 line CSV file. (Would like to update and sync as often as possible, but no more than every 20 min. Has primary key)
* Daily Import: 200 item XML file. (Purged and reloaded daily. Has primary key)

*Converting between the three formats is not an issue and can be done if it will improve import performance or allow better tools to be made available. (AWK for Fixed Width to CSV, etc.) Retrieval and conversion automation is easy via cron and sh scripts, but still need to automate the Drupal 7 integration. The use of custom tables is also possible as long as vews can reference the data using relationships.*

What would be the best practice to accomplish this type of data integration with Drupal 7? Also, am I leaving out any important details regarding the data or what I'm trying to accomplish?

---

Here are a few projects I'm currently looking at to find a solution. I would like to expand on this to help others decide which route to take when working with larger data imports.

**Importing data into nodes:**

* **Feeds** (Currently Alpha for D7)

Feeds will import the data reliably. Speed is reasonable for the smaller data sources but is too slow for the 300k+ tables.

Automation available using cron and Job Scheduler (Currently Alpha for D7).

Not having an index or unique key available in the source data is making this difficult to use. It is faster than feeds, but still slow to import the very large tables.

Automation is available via drush and cron.

**Custom Tables Instead of Nodes**

The Data module looks very promising, but is very buggy for D7 at the moment. The automation and import speed requirements would be easily met using data, but reliability is lacking. The views integration (link is for D6) looks very promising.

Added this for reference. There is no D7 candidate at this point, but could serve as a starting point for a custom module.

Added this for reference. This seems to have been absorbed by Table Wizard in Drupal 6. Again, added only for reference.

Seems to require Table Wizard (D6 only) for Views integration. Added for reference, but doesn't meet Views requirement.

---

@MPD - Added "Custom Tables" as a possible solution, and expanded modules. Thank you for this addition.

# Answer
> 8 votes
My gut tell me that this plan will make your servers catch on fire...

Seriously, if you are churning that much data, then I think you need to keep the data in an external datasource and then integrate it with Drupal.

My initial thought would to use two databases for the external data, so that you can do the weekly import w/o disturbing things too much. In other words, get database A up and running, and then import into B. When the import is done, make B the live source. Then wipe and import into A.

I have done a lot of integration of external datasources into Drupal, and it really isn't that hard. I gave an overview in Transition plan for PHP5 abomination to Drupal. That was for Drupal 6, but the same thing basically applies to Drupal 7. Essentially, you simulate what CCK / Fields API does with your own interface.

Not having a UUID for the weekly database really throws a wrench in the works, though. That part requires a lot of though, more that can be provided in a Q/A forum like this.

If you really do want to go down the import route, I would bail on Feeds and Migrate and write your own import script. Basically, you do the initial bookstrap process from index.php, query your datasource, make your nodes, and then save them. Programmatically making nodes is easy.

The best way to start out with this is to make a node with the UI, then print\_r it, and replicate the object with code in your import script. Taxonomy, files, and noderefs, are hard parts, but you just need to get familiar with these portions of the API to build up these object properties. Once you have a valid node object, then you can just do a node\_save(). Make sure you set a very large limit with set\_time\_limit() so your script runs.

EDIT BELOW TO ADDRESS CLARIFICATION/EXPANSION:

Personally, we stopped using the contrib module based approaches for data imports a while ago. They do work mostly well, but we just ended up spending way too much time fighting them and decided the cost/benefit was too low.

If you really need the data in Drupal proper, then my opinion about a custom import script hasn't changed. One of the modules you reference could be used as a starting point for how to build the node objects, then just loop through your data build nodes and save them. If you have a PK, you can easily add in logic to search the database and node\_load(), modify, and save. An import script is really only a few hours work if you know the Drupal API.

If views integration is a key (and it sound like it is based on the edit) and you want to do the external tables approach, then your best option is do do a custom module and implement hook\_views\_data to get your data into views. More than likely, you will custom module anyway to support your datasource, so adding this hook shouldn't be that much more work. The TW and Data modules should have some example to get you going.

Personally, though, I have never found the views integration with external data to be really worthwhile. In the cases where I have considered it, the data was just too "different" to work well with a views based approach. I just end up using the method I described in the "abomination" link above.

# Answer
> 2 votes
I think a node based (or even entity based) approach will burn out your server with millions of node. Besides, looking at your hourly import, that means your'll make a node\_save() at least once a second. That's too much for Drupal and cause a performance problem.

The reason behind that is for those content, you won't need any hook mechanism, you won't need pathauto (but you can manually create alias, it's much cheaper than pathauto), you won't need fields... Write a simple "INSERT" query is 100x faster than node\_save() or entity\_save().

1/ IMHO the best option is a custom table and a custom module for your data import, then write Views handlers for Drupal integration.

2/ The database cache is invalidated during the hourly import. If it takes too much time, you can think about a replication. In the easiest form, create two identical tables, use the first one, import to the second, switch your Drupal configuration to use the second table, sync the 2nd table to the 1st (then optionally switch back to the first). Another solution is in your custom import script, prepare and group the INSERT/UPDATE queries, then only send it at the end in one transaction to reduce the database write time.

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


# Question
Title: How do I make drupal check for similar content?
Im using drupal 7 and Im looking for a solution or a module that when a user goes to submit a piece of content they are presented with a "similar content already submitted" list after they enter a title or more specifically a link. I want to reduce similar or duplicate nodes on my site. I currently use the link module and I allow users to submit links to my site. Occasionally a user will submit a link that has already been submitted by someone else and I want to help alleviate that. Thanks.

# Answer
Use the Unique Field module and select your link field as the unique field.
> 1 votes

---
Tags: 7, nodes, navigation
---


# Question
Title: How to override/implement a module's hook
Is there a possible to override a module's hook? What I want is, write a `search__query_alter()` hook to restrict search results. But to achive this, I should write the hook in built-in module **search**'s .module file.

This way, I'm hacking into core drupal files, which must be bad. Is there a way to write the hook for another module in my **theme**'s `template.php` file or somewhere else, not touching the core drupal files? When I write `search_query_alter()` in my theme's `template.php` file it simply doesn't work.

From my question, you may understand I'm very new to Drupal! Thank you for helping.

# Answer
> 6 votes
You must create a custom module and add a custom hook function to it. The function name will be `modulename_query_alter ()`. Drupal maintains a list of all included hooks by searching the enabled modules for functions following that pattern.

Instructions for creating one are here. This is the basic means for introducing custom behaviors to your site. The hook system is discussed here and you should look at using the hook\_query\_alter function here.

This will get you started and no doubt lead to further questions.

# Answer
> 2 votes
You can override hooks, or use hooks to add data by creating a small custom module. Start here on how to create modules: http://drupal.org/node/361112

Basically then you add:

```
function MYMODULE_query_alter () {
  //put your code here
}

```

Where MYMODULE is the name of your custom module.

---
Tags: hooks
---


# Question
Title: How can I convert HTML entities imported from CSV via Feeds in to readable characters?
This relates to a prior question - How can I convert character entities to display as 'normal' characters in Drupal?

It looks as if the CSV file itself is imported via Feeds, so I assume that it's Feeds that should 'parse' the HTML entities and convert them in to readable characters (Unicode?).

Is there some sort of extension or patch available for Feeds that can help me to do this?

# Answer
Feeds Tamper allows you to html decode your feeds content before nodes are saved.
> 1 votes

---
Tags: 6, nodes, feeds, importing-exporting
---


# Question
Title: How can I include standard bits of text in a node, depending on the node location or a particular term?
I have a product page that is mostly original content, however I would like to include a block of text that is included on similar nodes. Eg, I have several pages for hotels in London, so I would like to include a block of text called 'About London', which then carries a couple of paragraphs about London.

I assume that this could be made to happen based on the node's Location or for a particular term attached to the node, but I don't know the best way forward with what I'm trying to do.

# Answer
If you create a new content type, say "Location Description", you could add a node reference field into your hotel content type referencing the respective location node.
> 1 votes

# Answer
You can also use a "location" vocabulary and create a term reference from the node to the location.
> 1 votes

---
Tags: taxonomy-terms, nodes, location
---


# Question
Title: “Realname” module is not creating “pretty URLs” for new users?
I’m working on a site which I’ve taken over the development from a former employee. He has installed the module **realname** which, as I understand, should enable the function that a user URL is not the cryptic ID but the users first+last name, so the URL might look something like this: www.mydomain.com/user/firstname-lastname

It work for most of the users but I’ve discovered that some of the users (especially new users) still uses the ID in the URL, so it become something like www.mydomain.com/user/eyyrdctxeec and that mess a lot of things up.

I’m suspecting that it might has something to do with the module and it only “recalculate” the names in some time interval, maybe by the CRON jobs. But I want it to create that member URL when a new user has signed up to the page.

Has anyone experienced that before and might have a solution? As I said, it isn’t me that has initially created this site so I don’t have a clear overview if the original developer have done some customization or other configuration – I’ve search to solve the problem but with no luck.

Any help or suggestions would be appreciated.

Sincere
\- Mestika

# Answer
congratulations on inheriting someone else's work, it was really well documented, right? ;-)

All joking aside, the realname module is used to display alternate names instead of the username.

To get the /user/firstname-lastname urls you would use the pathauto module and configure the "pattern" accordingly. Instead of "user/..." you might want to use the "member/..." to keep things a bit separated. I bet pathauto is already used on your site.

Just change the pattern, delete all user paths and re-create them in a batch.

I also suggest you check all the additionally installed modules and read up on what they are supposed to do. No worries, you'll learn quickly, just use this site a lot. And try to improve your "accept rate" a bit to get more answers ;-)
> 5 votes

---
Tags: 7, uri, cron, users
---


# Question
Title: Print mailing address labels from a view
We have a site built with Drupal Commerce and are looking for a way to print address labels from a view

So far I have been able to make a grid view of addresses and use the printer friendly version module to create a print view, but i can't seem to get the CSS right to line up the labels correctly.

I have seen this module for Drupal 6 - http://drupal.org/project/mailing\_label, but nothing for Drupal 7. I was wondering if someone had any insight.

Thanks.

# Answer
Our warehouse team needed the ability to print address labels on the Avery 5163 template for every Commerce Order that is set to the status as Pending

I consider this to be a jury rig more than a Drupalish answer, but it got us through just the same.

Here is how we did it.

We created a page with a table view that shows all orders that are pending.

We created a view of Commerce Profiles that showed only the customer addresses in a grid format.

We used the Printer, e-mail and PDF versions module to create printer friendly versions of the views Here is the module - http://drupal.org/project/print

We altered the print.css file in the modules folder so that the address labels lined up with the template. (Later we ended up adding print.css file in our theme to override the one in the module folder and protect it from updates – Here are the instructions on how to add a style sheet - http://drupal.org/node/171209)

We created an html button in the header of view of pending Commerce Orders. It linked to the print version of the address label view. (you can add the word print before any relative url to get it’s print view)

We altered the browser settings of the guys at our warehouse to exclude all the extra information that comes when the browser prints – Here are some instructions – http://lifehacker.com/5603815/how-can-i-get-rid-of-the-url-and-other-text-when-i-print-from-web-pages

We also altered the margins in the browser.

We will be looking for a better solution as time and money for work permits , but I thought that someone else might find our experience helpful
> 3 votes

---
Tags: commerce
---


# Question
Title: Is it beneficial to export views and store it as a module?
So in an attempt to further optimize my app, I thought it would be wise if I store the Views in a module using the export tool.

Are there any advantages to gain by doing this?

Thanks!

# Answer
> 4 votes
The biggest benefit is that you can have your views stored in a version control system like Git or SVN. I maybe mistaken but I don't think there are really performance benefits on doing this.

Some documentation to help you out: http://views-help.doc.logrus.com/help/views/api-default-views

---
Tags: views
---


# Question
Title: No content types showing under 'Add content'
When I click "Add content," I get the following message:

> You have not created any content types yet. Go to the content type creation page to add a new content type.

However, under content types it lists all my content types (page, article, blog, etc). What could be causing this sort of miscommunication? The only change I made recently was moving the "Add content" link from one menu to another, but that shouldn't have affected the actual behaviour of node/add. (I did it using the admin interface as well; I didn't do any PHP editing of any sort.)

This is my recent log messages since the last content I added (edited out repeats and page not found errors):

```
cron    12/29/2011 - 13:02  Cron run completed. Anonymous (not verified)
php 12/29/2011 - 10:42  Notice: Undefined index: path in menu_edit_item...  admin
php 12/29/2011 - 10:42  Notice: Undefined index: path in menu_edit_item...  admin
user    12/29/2011 - 10:35  Session opened for admin.   admin
cron    12/29/2011 - 10:02  Cron run completed. Anonymous (not verified)
cron    12/29/2011 - 01:20  Cron run completed. Anonymous (not verified)
content 12/29/2011 - 00:37  page: updated Mentoring Program.    admin
content 12/29/2011 - 00:34  page: added Mentoring Program.  admin

```

Only change to any files was a small change to pages.tpl.php regarding rendering of page titles; and I haven't installed any modules since it last worked.

# Answer
I found this :
http://drupal.org/node/997444
it seems like it's a very strange behaviour.

Basically I guess Drupal looks at that specific main menu to see what types of content can be created by users, so if even if you move all the options to a different menu none will be available.

I had to re-add the add-content link to the administration menu and re-check all the submenu items, then set it to `display:none;` and add the '***Add content***' link to the user menu again.
> 5 votes

# Answer
Shot in the dark...permissions? I've hunted around for hours for a bug only to realise that I didn't actually have the permissions to perform the task in question.
> 1 votes

---
Tags: nodes
---


# Question
Title: Managing Drupal Core in Git for Aegir Platforms
We've started developing a platform to deploy sites with using Drupal 7.2. The platform is managed in git. However, as we do not touch core, what is the best place to managed core?

Should core also be in git on its own repo? Or should the dev team update core as they develop the platforms, and push core with the platform?

Thanks!

# Answer
> 1 votes
We're now looking at a "git branching model that works" , and "Drupal deployments & workflows with version control, drush\_make, and Aegir"

# Answer
> 4 votes
Our current (simplified) practice at work:

* Pull down the drupal core git repo http://drupalcode.org/project/drupal.git/
* Add upstream to your local project that tracks the above repo
* When a new version of drupal is released, fetch the drupal repo and merge the appropriate tag

e.g.

```
cd /var/www/your-platform/
git fetch upstream
git merge 7.7

```

# Answer
> 1 votes
Note that you can automate away a lot of the pain of the 'migrate to new platform' model in Aegir ( see http://mig5.net/node/342 ).

And you can batch-migrate sites from the frontend by using the 'Migrate' task in the *platform* (not site) node to also speed things up from the frontend if your sites all sharing the one platform.

Yes, old platforms can accumulate with no sites on them. However these can be deleted with the 'Delete' task in the frontend, and I hope to expand on automating that from the CLI too soon.

---
Tags: version-control, aegir, 7
---


# Question
Title: List of D7 contrib modules that create and use custom tables with full Views 3 support
I'm trying to understand how to properly use Drupal 7 and Views 3 to retrieve data from a completely customized MySQL table.

There are several tutorials for Views 2 and Drupal 6 (Scratching The Itch: MyWeather being a great example) but very little for Drupal 7 and Views 3.

I would like to compile a list of Drupal 7 Contributed modules that:

1. Define there own, custom tables.
2. Store data in those tables (no nodes).
3. Query those table using the Views 3 API.

It would be very useful as a developer new to Drupal 7 and Views 3 to see live examples of modules that implement functions like hook\_views\_api and hook\_views\_data.

# Answer
Maillog is a small module which gives you a good example to learn from.
> 2 votes

# Answer
You should take a look at Data & Feeds or Table Wizard & Importer.
> 2 votes

# Answer
There appear to be several questions here.

For a good tutorial series on Views3 go to nodeone.se and views the "Taming the Beast" video series.

Since virtually everything in a Drupal site is stored in the database, Views is a UI for sql queries, and thee are so many modules, it may be difficult to compile a comprehensive list! I've not seen one listed anywhere, perhaps another answerer has. If you search for views using the relevancy setting at drupal.org/projects/modules you will get a long list of related modules that extend or use views. Certainly key modules such as rule, panels, some modules in ctools, Organic Groups do. Modules such as relations and relationships and similar modules do as well.

If you select the tag for hooks from your question tags, you will find a couple links relating to hooks at Drupal. If you look at the code for views you will find examples of implementing and calling hooks.
> 1 votes

---
Tags: 7, views, hooks, database
---


# Question
Title: JavaScript and CSS settings fail unexpectedly: The files were not created
> **Possible Duplicate:**
> Drupal Commons site has no style after installation

See the Drupal Commons site running on boysday.org

well how to start. i am new to drupal and I have serious flaws during the installation; Tried it dozens of times.I get warnings about too many files open. Somebody gave me the advice to do the adjustments in the administrative section (admin/settings/performance).

On "Bandwidth optimizations," the option "Optimize CSS files" and "Optimize JavaSript files" were enabled. I have tried to switch off; for testing and customize my Drupal Commons install it's better to disable as to have CSS and JavaScript development support with tools like "Firebug" using Firefox.

I tried to do so, and got back a very interesting message.

> Performance
>
> The file could not be created.
> The file could not be created.

Can this be caused by the fact the folders in /home/vhost/WWW/mysite/sites/default/files were all owned by the wwwrun user? What can I do?

There are no pictures, and no CSS. Is there any right or permission problem?

> warning: array\_map() \[function.array-map\]: Argument #2 should be an array in /home/vhost/WWW/mysite/modules/system/system.module on line 1020.
> warning: array\_keys() expects parameter 1 to be array, null given in /home/vhost/WWW/mysite/includes/theme.inc on line 1832.
> warning: Invalid argument supplied for foreach() in /home/vhost/WWW/mysite/includes/theme.inc on line 1832.

# Answer
> 0 votes
As you already suggested, this is most likely a file permission problem. Make sure the entire directory under sites\default\files is writable by the apache user, often this is called www-data.

To get you going maybe download XAMPP for your platform and get your first Drupal installation working locally.

---
Tags: javascript, theming, 7
---