# Question
Title: Preprocessing a front page block causes errors on other pages: why?
I'm currently working through self-set tasks to learn Views and pre-processing in Drupal 7. I've created an unformatted view which creates a list of images (which are linked to a content-type but it seems if I replace the fields in view with node:type then I get a link to the node page which is not what I'm after) to place them in a block. I've placed the block into the highlight region and have written a views-view-fields--image.tpl.php file to output the list into various unordered list formats which are then transformed by jCarousel or the featureList jQuery plug-ins.

On top of this, I've created a page--front.tpl.php file to restyle the front page and it appears to work in that the CSS, js and HTML are working correctly and the carousel and lists appear & work in the defined block.

However when I leave the front page to another page where the view should not appear, I get the following error:

> Notice: Undefined property: stdClass::$\_field\_data in iaintest\_preprocess\_views\_view\_fields() (line 10 of /Applications/XAMPP/xamppfiles/htdocs/drupal/sites/all/themes/iaintest/template.php).

To pre-process the list that the view outputs, I've written the following pre-process code:

```
function iaintest_preprocess_views_view_fields (&$variables) {
  if (!$variables['view']->result[0]->_field_data) {
    // Line 10 where the error occurs.
  }
  else {
    drupal_add_css(path_to_theme() . '/jcarousel/skins/tango/skin.css');
    drupal_add_css(path_to_theme() . '/featureList.css');
    $js = "
      jQuery.noConflict();
      jQuery(document).ready(function(){
      jQuery('#mycarousel').jcarousel();

      jQuery.featureList(
        jQuery('#tabs li a'),
        jQuery('#output li'), {
          start_item: 1
        }
      );
    });";

    drupal_add_js($js, 'inline');
    $items = array();

    foreach ($variables['view']->result as $key => $vars) {
      foreach ($variables['view']->result[0]->_field_data['nid']['entity']->field_images['und'] as $k => $v) {
        $variables['carousel'][] = array(
          'uri' => $v['uri'],
          'alt' => $v['alt'],
          'title' => $v['title']
        );
      }
    }
  }
}

```

I have tried using `drupal_is_front_page()` or `$variable['is_front'] === TRUE` to limit this part of the preprocessing to the front page, which is the only place where the original view appears.

Is this possible at all, or have I misunderstood anything?

# Answer
> 1 votes
Try:

```
<?php
if (isset($variables['view']->result[0]->_field_data)) {
//
?>

```

Instead of your weird if/else construct. Not really sure what you are trying to accomplish with that code, so there might be a better way to check if you want to execute it or not.

# Answer
> 1 votes
To make a summary of what you are experiencing:

* Your preprocess function is invoked for a view template, which is used only on the front page.
* When you visit the front page, you don't get any message error, but you see an error message in the page you visit right after.
* You are wondering why the error message doesn't appear in the front page, but it is shown in the other pages.

What happens is that:

* Drupal intercept the PHP warning and, if set to show the error/warning messages, calls drupal\_set\_message() to show it.
* `drupal_set_message()` save the error message in a session variable.
* As the page has been already output, the error messages are not displayed; they are displayed when the next page is rendered.

In other words, the error is caused by the function being invoked for the front page, but the error message is shown in the next page being output.

To explain in details what happen when PHP raises an error, drupal\_bootstrap(), the function that is invoked to boot Drupal, calls \_drupal\_bootstrap\_configuration(), which sets \_drupal\_error\_handler() as PHP error handler. `_drupal_error_handler()` calls \_drupal\_error\_handler\_real(), which then calls \_drupal\_log\_error(), the function that then calls `drupal_set_message()`.

---
Tags: 7, theming
---


# Question
Title: The theme is broken when I enable the "Optimize CSS files" option
The theme I made is broken, when I enable the "Optimize CSS files" option. I have cleared the cache, but the theme still doesn't work. With Firefox and Internet Explorer it is OK, but with Google Chrome is not OK at all.
How can I fix this?

# Answer
> 4 votes
I have that in all my CSS files, and it works fine in Chrome.

try:

* converting the CSS file to UTF-8 (if it's not)
* removing any multiline comments

/\* This is a

multi-line comment. \*/

---
Tags: 7, theming
---


# Question
Title: Add comments to Webform Submission pages
We use webforms for a variety of purposes such as feedback questionnaires, contact forms and request forms.

For the request forms we would like to attach comments on the submission page. This is so after the form has been submitted the User and admins can communicate on the follow up from the Request.

From what I understand the submissions pages are unique and only viewable to users who submitted them OR admins.

Anyone have any idea how I could attach unique comment forms to these submissions individually so that only the User who submitted the form and the admins can comment? Would this require a module or is this something which can be a theme override in template.php?

# Answer
> 1 votes
You would need to create a module for this. It doesn't need to be complex though. But you need a place to store the comments and some code to add the form and handle form submissions.

If you wanted to make something a little bit fancy, you could notify users when new comment on submissions are made.

---
Tags: 7, hooks, comments, webforms
---


# Question
Title: usage of theme_more_link in zen template.php
I have tried to change the text in the 'Read more' link by putting:

```
function myzen_more_link($url, $title) {
  watchdog("template.php","myzen_more_link");
  return '<div class="more-link">' .
    t('<a href="@link" title="@title">( more ... )</a>',
    array('@link' => check_url($url),
    '@title' => $title)) . '</div>';
}

```

In the template.php in my zen subtheme folder but it does not appear to work.

Almost all of the discussions I have seen about formatting the "more\_link" concentrate on its placement. Can anyone tell me why this theme override does not take effect?

# Answer
> 1 votes
What you have done should work. Have you remembered to clear cache?

# Answer
> 0 votes
First you should to declare onw theme element 'more\_link'

```
function mymodule_theme(){
  return array(
    'more_link' => array(
      'arguments' => array('url' => NULL, 'title' => NULL)
    )
  );
}

function mymodule_more_link($url, $title) {
  watchdog("template.php","myzen_more_link");
  return '<div class="more-link">' .
    t('<a href="@link" title="@title">( more ... )</a>',
    array('@link' => check_url($url),
    '@title' => $title)) . '</div>';
}

```

---
Tags: 7, theming
---


title: Select an image from a directory

text:
# Question
Title: Select an image from a directory
How do I select an image from a directory of images uploaded with the image field, in the same way done in Joomla?

# Answer
Your best option would be to use the combination of Filefield Sources and IMCE, but unfortunately, the first isn't ready for D7 yet.
> 4 votes

---
Tags: 7, media
---


# Question
Title: Adding Node-Fields to query with db_select();
I am building a query using `db_select();` Now I need to sort my result by a field that a added using fields. Is there some nicer way than to join field\_data\_field\_fieldname, and revision?

I was hoping for something like `$query->addFieldData("field_foo", "myfoo");` so i can simply `$query->orderBy('myfoo', 'asc');`

I am also wondering why there is no example in the API that joins node-fields.

# Answer
To my knowledge, `db_select()` isn't aware of entities or fields (fields, in the context of field that are added to nodes etc.)

I imagine you'd need to do the joins to field tables yourself. I found a little example from dbtng\_example--dbtng\_example.module, but as per my hunch and comments below - `EntityFieldQuery` is actually the only correct way to do this. Fields can define their own storage which would completely break your db\_select, so...

**With a bit of a performance hit (which is negligible for most) you really should do it the Drupal 7 way...**

Drupal 7 now has Fields in core, and with that came the EntityFieldQuery which is a querying class for finding entities (like nodes, terms, etc) by their properties (like published status) or fields (like field\_page\_photo or any other fields you add via UI or otherwise)

*or from API:*

> This class allows finding entities based on entity properties (for example, node-\>changed), field values, and generic entity meta data (bundle, entity type, entity id, and revision ID).

Some good examples and discussion here:

What's the proper use of EntityFieldQuery?

and I find myself referencing Do we need an EntityFieldQuery example? as well.
> 4 votes

---
Tags: 7, entities, database
---


# Question
Title: How to write a view of a user signed up nodes?
There is a content-type (event) with signup enabled. I want to show, on a user profile, the events this user has already signed up. I am having several frustrations with the signup relations and arguments. Is this possible with the current 2.x release?

# Answer
There is a default view called signup\_current\_signups that provides this functionality out of the box.
> 2 votes

---
Tags: 7, views, users
---


# Question
Title: Is there a modules "wish list" anywhere?
I'm new to Drupal, and right now my job consists mainly of site-building. But I'm a PHP developer, and I'd like to get into module development. The problem is, anything I could think of to do has most likely already been done! Is there any kind of wish list maintained somewhere (on drupal.org) of modules that people wish would be written?

# Answer
> 8 votes
Check out the Contributed Module Ideas group on groups.drupal.org.

The Google Summer of Code group can also be a good source of inspiration. Some of the ideas may not be big enough to sustain a student for the entire summer, so they don't get picked up otherwise.

---
Tags: 7
---


# Question
Title: Field api - taking responsibility over a field display
I am writing a Drupal module that deals with the taxonomy terms, which are (as I understand) fields, taxonomy vocabulary , which are as I understand entities. My module should take over the taxonomy term field and vocabulary entity for mirror language display, meaning that once my user is in X language, he will see the X language value of the term/vocabulary name/description.

Looking at the i18n\_taxonomy module code I can see that it implements many fields related functions (`i18n_taxonomy_field_attach_view_alter()`, `i18n_taxonomy_field_formatter_view()`, `i18n_taxonomy_field_formatter_info()`, etc). My questions are:

* Once I need to to take over a display of a field, how can I do it?
* What functions should my module implement for displaying the fields on menus, widgets, plain view, etc?
* Same question, only for the vocabulary: is there any difference?
* I have spent my time googling this subject, but I have not really found a good reference. Can anyone refer me to one?

# Answer
> 1 votes
Fields are displayed through formatters (you can have multiple ones, and then you chose which one you want when adding the field to a content type, or any bundle of an entity). So, hook\_field\_formatter\_info() and hook\_field\_formatter\_view(). Open the core image module: modules/image/image.field.inc in your Drupal install, and use that as an example.

You can use hook\_field\_formatter\_info\_alter() to add formatters to existing field types (not declared by your mpdule).

---
Tags: 7, entities
---


title: How do I limit content type per role?

text:
# Question
Title: How do I limit content type per role?
I am running a Drupal 5 site with number of roles. Is there a way to assign limits per role? E.g. Authenticated user could upload 10 documents, whilst Paid user could upload 100 documents. Your help is much appreciated.

# Answer
The NodeFamily module will allow setting a maximum number of nodes that can be created per user. However it doesn't provide per role maximum number settings.
> 1 votes

---
Tags: nodes, users, 5
---


title: What format are CCK dates stored in?

text:
# Question
Title: What format are CCK dates stored in?
In what format are CCK dates stored? If it stores dates in the database using a timestamp string instead of a native MySQL datetime format, what implications does that have in regards to storing dates before the unix epoch? Would it mean that CCK date fields would not be able to store something happening in year 1939, for example?

# Answer
Date module provides three different formats, read about them here: Difference between date, datetime, and datestamp
> 4 votes

# Answer
Answering my last question based on @tim.plunkett links:

**Would it mean that CCK date fields would not be able to store something happening in year 1939, for example?**

It would depend on what format you chose for the storing the data of the CCK field. If you use Datestamp (Unix Timestamp), then no, you won't be able to store dates before the Unix epoch. If you need to do that, go for Date (ISO Date), or better Datetime, which represents stores data in MySQL's native date format, and allows to store dates before the Unix epoch.
> 0 votes

---
Tags: 7, entities, datetime, database
---


# Question
Title: How to generate a list of which Features are enabled in which Spaces?
I'm running a Drupal 6.x site with Organic Groups, Features, and Spaces, and I'm interested in generating a list of which Spaces have which Features enabled. Preferably a table, with Spaces along the Y axis, and Features along the X axis.

Any ideas regarding how to generate this? I can generate a list of Group Spaces using Views, but can't find a field for the enabled Features.

# Answer
> 2 votes
Features are modules, and Views 3.x can make listings of enabled modules. But as explained in How to make a Feature available only to certain Spaces?, this is not possible, since modules are enabled site-wide.

# Answer
> 0 votes
I don't think there's a field to be able to do this with a view. Mainly because the data is stored in a serialized object.

But the query you want to use would be something like this.

```
db_query("SELECT * FROM {spaces_overrides} WHERE object_type = 'variable' and object_id = 'spaces_features'");

```

Once you get those results the features for that specific space is going to be in the value column. Is going to be a serialized array so you will have to unserialized it.

The value is going to be a key =\> value array of feature\_name =\> status.

Sadly you're going to have to build the page and the table yourself. But this should be enough to get the data that you want.

Also you're going to have do a lookup for the for the ID to get the proper group name.

Sorry the solutions is not as simple but this should work.

---
Tags: views, 6, organic-groups, features
---


# Question
Title: Single SQL query to pull recent two nodes from each node type
As mentioned in the title, I was wondering how this can be achieved with single SQL query. All I need is the node ID from node table that matches the given criteria.

# Answer
> 4 votes
```
$node_types = node_get_types(); // or create own object of node types
$query = $types = array();

foreach($node_types AS $type){
  $query[] = "(SELECT node.* FROM {node} node WHERE node.status <> 0 AND node.type = '%s' ORDER BY node.nid DESC LIMIT 2)";
  $types[] = $type->type;
}

$query = implode(' UNION ', $query);
$result = db_query($query, $types);

$items = '';
while($row = db_fetch_object($result)){
  $items[] = l($row->title, 'node/'. $row->nid);
}

print theme_item_list($items);

```

Execute time: 0.002s

# Answer
> 0 votes
This is possible with views, using attachments. However it will not be a single SQL query.

It will however be easier to maintain (as it uses the views GUI) going forward (especially if you have multiple developers in your team).

---
Tags: 7, nodes, database
---


# Question
Title: How do I create a new Group after installing OG?
I downloaded the Organic Groups module for my drupal 7 account. I moved it to my sites/all directory and was able to see it in the Drupal settings where I checked off all of the Organic Groups sections and the Locale. However when I go to Create/Add Content I don't see the option to create a Group. Did I do something wrong? Has anyone else seen this problem before?

# Answer
You have to do it in the content type. Go to a content type you would like to use as a group and you will see a fieldset Organic groups

Also check your permissions, you will have permissions for creating the content types and for administering og
> 2 votes

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


# Question
Title: Where can i try searching the module "File_styles"?
I have installed the media module for drupal 7 but it requests me the installation of a module I cannot find File\_Styles. Where can I searching this module?

# Answer
> 4 votes
File Styles is a module that is part of the Styles project.

---
Tags: 7
---


# Question
Title: How to create and set a new menu block in some content region, programmatically
I want to create a new menu programmatically add for him some elements and the activate it in some content region as a block.

How can I do this programmatically?

I know how to add for an existing menu new elements, but I don't know how to create a new menu.

# Answer
You save the menu using `menu_save`:

```
$menu = array(
  'menu_name' => '',
  'title' => '',
  'description' => '',
);
menu_save($menu);

```

I'm not sure if there is an api function to activate a block, but it can be done, by inserting a row in the blocks table. You need to know the module, delta, theme and region. For menus, the menu module will create one with the delta being the menu\_name.

So with the above you could do something like this:

```
$menu_block = array(
  'module' => 'menu',
  'delta' => $menu['menu_name'],
  'theme' => '', // Either get the active theme or you can do it for all themes
  'region' => 'content', // Where you want to place it, theme dependant
  'status' => 1,
);

```

So while you can do it, you probably want to make this theme specific, or do this in an install profile, where you know which theme should be the active one etc.
> 3 votes

# Answer
I had a similar question a few days ago. You can make the menu as you normally would in a module using hook\_menu and then create the new menu using the hook\_install

```
 $items['devel/cache/clear'] = array(
  'title' => 'Empty cache',
  'page callback' => 'devel_cache_clear',
  'description' => 'Clear the CSS cache and all database cache tables which store page, node, theme and variable caches.',
  'access arguments' => array('access devel information'),
  'menu_name' => 'devel',
);

```

Custom module with its own menu?
> 0 votes

---
Tags: routes, blocks, nodes
---


# Question
Title: Download Update's fail (Unix File Permissions on /tmp directory)
When I goto `admin/reports/updates/update` select all and then hit the "Download these updates" I get the following error message

> The specified file `temporary://filewq3Nao` could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log. `http://ftp.drupal.org/files/projects/ctools-7.x-1.0-alpha4.tar.gz` could not be saved to `temporary://update-cache/ctools-7.x-1.0-alpha4.tar.gz.`

File System Settings can be found here: `admin/config/media/file-system`

`/tmp` is setup with `777` and I get NO errors on this page. I attempted to create a `/tmp2` with `777` and that directory would fail the security checks. I am on shared hosting. There are directories in `/tmp` called `analog`, `awstats`, `cpbandwidth`, `webalizer`, `webalizerftp` which I assume are CPannel utilities:)

# Answer
> 1 votes
You probably have your own tmp directory, which is not /tmp but /some/path/to/your/directory/tmp. You wouldn't be allowed to create /tmp2 for sure :)

To find that out, go to admin/reports/status/php and look for \_SERVER\["DOCUMENT\_ROOT"\], that will tell you where Drupal is located and from there, you should be able to build the path to your tmp directory.

Then set the temporary directory to that.

# Answer
> 1 votes
Made a directory under "tmp" and had to use "~/tmp/drupal". Found this in some obscure part of the world

---
Tags: 7, files, updating
---


title: How do I achieve 2 level tabs?

text:
# Question
Title: How do I achieve 2 level tabs?
Drupal 6 had an easy way to do this, but D7 doesn't.
I asked this question on the drupal.org forums, and I didn't get answer. Am I asking too much? I just want 2 level tabbed main menu where I can have full control over the link styling.

Bottom line, I want to extract each individual link (and sub link) from the main menu and theme them individually.

# Answer
If you have a theme that supports the output of primary and secondary links in the way you describe (Bartik, the default theme for Drupal 7 does, but it doesn't have the secondary nav below the primary, but rather in the upper right of the header), you can accomplish this by setting the secondary menu to be the same as the main menu. Navigate to admin/build/menu/settings to make this selection.

You can further customize this behavior using the Menu Block module.
> 3 votes

---
Tags: 6, routes
---


title: What are the contextual links?

text:
# Question
Title: What are the contextual links?
Drupal 7 defines the "use contextual links" permission. Which links are defined as contextual links?

# Answer
In Drupal 7, some modules supply contextual links that allow privileged users to quickly perform tasks that are related to regions of the page without navigating to the Admin Dashboard. For example, when you hover your mouse over a block or node, links are displayed that allow you to make changes to the block or node.

According to drupal.org.
> 7 votes

---
Tags: 7, navigation
---


# Question
Title: What is the equivalent of drupal_set_content()?
I am searching for something equivalent of `drupal_set_content()` for Drupal 7, to assign a block to a region. Do you have any idea?

# Answer
The equivalent of `drupal_set_content()` is drupal\_add\_region\_content().

> Adds content to a specified region.
>
> ### Parameters
>
> `$region`: Page region the content is added to.
>
> `$data`: Content to be added.

Notice there was a bug in Drupal that didn't allow this function to work, since `drupal_region_content()` was not properly called. (See Content added via drupal\_add\_region\_content() is not added to pages.) It has been fixed on March 2015; if you are using any version earlier than 7.36, `drupal_add_region_content()` will not work.
> 3 votes

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


# Question
Title: Show the view result only when users enter a value for the exposed fields
I want that a view shows its result only when users enter a value in the exposed form fields. Is there a way I can get this done?

I am using AJAX, and the view is displayed as block. Most of the options I tried don't work because of this.

# Answer
For each of your fields, in your view, you have the option `Hide if empty`. Select it to not display anything for the field if it is empty. Note that the field label may still be displayed. Check style or row style settings to hide labels for empty fields.
> 2 votes

# Answer
Because you run views for drupal7 there is already a build in solution.

Therefore change the "Exposed form style:" to "Input required" That's all you need.

Yeah pluggable systems!
> 2 votes

---
Tags: 7, views
---


# Question
Title: How to make Drupal 6 search result URL have ".html" at the end?
I want the search result URL become

```
http://www.site.com/search/node/Search for something.html
http://www.site.com/search/node/cars.html

```

I've looked into `custom_url_rewrite_outbound()` but there is not much I can understand

# Answer
> 1 votes
custom\_url\_rewrite\_outbound() is not the only function you need to place in settings.php; you need also custom\_url\_rewrite\_inbound(), which converts back the URL to the one known by Drupal.

For those functions, you can use code similar to the following one:

```
function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
  if (preg_match('|^search/([^/]+)/(.+)|', $path, $matches)) {
    $path = 'search/' . $matches[1] . '/' . $matches[2] . '.html';
  }
}

function custom_url_rewrite_inbound(&$result, $path, $path_language) {
  if (preg_match('|^search/([^/]+)/(.+)\.html$|', $path, $matches)) {
    $result = 'search/' . $matches[1] . '/' . $matches[2];
  }
}

```

---
Tags: 6, search, uri
---


title: module for ajax username checker

text:
# Question
Title: module for ajax username checker
Is there a D7 module to do an Ajax based test if a username is available, in the same way done on https://en.wordpress.com/signup/?

# Answer
A quick search with "drupal ajax username checker" points me to the Username originality AJAX check module. There is a dev version available for 7.

Some more details about this module (from its project page):

> This very simple module allows visitors to check username originality quickly using AJAX request during registration (completing registration form). This makes registration process more convenient as you don't need to submit your registration form to find out whether this username is already taken or not. This module is sensible to standard Drupal username validation as well as Access Rules validation.
>
> username\_check module provides two ways of user name checking:
>
> 1. Manual (5.x and 6.x) — a "Check availability" button appears on the form and a visitor can press it to verify whether his name is available or not.
> 2. Automatic — check is performed automatically when you finish typing and on leaving username field.
> 2 votes

---
Tags: 7, users, ajax
---


# Question
Title: When posting OG content, how to choose only from Content Author's Groups?
When a user is editing/creating a node, there is a field where the user can choose what groups to post the content to. I want this field to list only groups the user is actually a member of. Is there a setting for this? If there isn't, what is the best way to code this?

# Answer
The default is to provide all groups you have access. An administrator account that has access to all the groups would get a list with all the groups. This happens, for example, with the user #1.

The only way to avoid that is not using an administrator account.
> 3 votes

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


title: views Relationships and argument?

text:
# Question
Title: views Relationships and argument?
What are the relationships and arguments in Views? How do I use them? I have read some tutorials, but still don't know how to use them. Can someone explain them more clearly? Thank you.

# Answer
Relationships are the way Views expresses SQL joins. For example, when viewing a node, you can add a relationship to it's author, pulling in even more data.

Arguments have been renamed "Contextual Filters" in Views 7.x-3.x, which is a better name. Basically, it's a filter that gets its input from the the page, either by the page's URL or the node or user being viewed, etc.
> 10 votes

# Answer
Arguments (or, as mentioned, Contextual Filters) are an incredibly powerful tool in making views context aware. Aside from using the current node, taxonomy term, path, etc. to filter your data, you can use Views arguments in conjunction with the Panels module to create really complex page layouts. The degree to which you can do this with just Views varies based on what you want, though.

Let's say you want a user who goes to /category/books/ to see all nodes or content type 'book', but when he opens /category/malbum/, he should see all nodes of content type 'album' (or tagged with taxonomy term 'album', for example). Without Contextual Filters, you'd have to create two separate views. But if you add the path, taxonomy term, or whatever else you use to mark a node as 'book' as an argument, you can create a single view that does all this AND that accomodate future categories.

With relationships it gets even better. Every book/album has an 'author'. If you want to add, say, the age of the author to the view, you can't do this without relationships, as 'age' is part of an author node, not the book node. In this case you create a relationship, and then you can add the 'age' field from the author content type, as if it was a field in your book node.

The specifics of how to do these things are explained in a number articles and videos, but conceptually I hope this will help you understand it a bit better.
> 8 votes

---
Tags: 7, views
---


# Question
Title: Filename for the front page template file
How can I I create a theme for the front page only?

I only want to change what is in the content area and leave the rest as it is on the page.tpl.php template file.

# Answer
In Drupal 7, you need two dashes in your filename; try page--front.tpl.php.
> 8 votes

---
Tags: 7
---


title: Displaying node translations

text:
# Question
Title: Displaying node translations
I have enabled several languages on my site and the following modules has been installed: Locale & Content translation.
I have created a simple page in English and have added several translations for this node. Now when I view node on separate page it's displaying in language which is selected in language switcher block.
But if I view node on front-page (/node) or on taxonomy page (taxonomy/term/%) all translations of this node has been shown.
Is it possible to disable displaying other translations for all pages?

# Answer
You can use Views, which comes with a front page view you can modify to make it show only nodes for a specific language, and a view for taxonomy/term/%. For taxonomy terms, it is not so straight, as Drupal associates a language to nodes, but not taxonomy terms; it still is possible to show only the nodes associated with the selected taxonomy term, and which are written in a specific language.

If you install the development snapshot of Views (7.x-3.x-dev), some settings have been renamed; the one that you should change is "filter criteria."
> 1 votes

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


title: Multiple primary keys

text:
# Question
Title: Multiple primary keys
I have defined a new content type, `statetype` and a CCK field, `state`.
I need to use the CCK field as primary key in this table because I have another table and I need use that field as foreign key. (This code and table is not Drupal and i wrote it myself, but it uses a Drupal table.) I should change state field to primary key in the "statetype" table but Drupal already defines `vid` as primary key. Is there any problem if I define multiple primary keys (`vid`, `state`) or if I remove `vid` as primary key?

# Answer
> 0 votes
A database table can have at most one primary key, but it can have multiple unique keys.
Replacing the primary key in that table is not a good idea, because Drupal code rely on the fact the primary key is `vid`. You cannot set any field as primary key: it must a field that contains unique values for each row; if the field you choose can have the same value for multiple rows, then it's not a candidate for primary key.

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


title: Seperate admin page for each role

text:
# Question
Title: Seperate admin page for each role
I have on my website several roles and each of these roles have different levels of responsibility. How can I create a separate administration page for each role or access level?

# Answer
> 4 votes
There's a number of ways you can accomplish this, here's a few off the top of my head (in no particular order):

* Create a normal page node and use Node Privacy by Role, a module which allows you fine-grain access control on a per-node basis using roles.
* Use Views to create an admin page and limit the access using Views's "Access Restrictions."
* Use Panels to create an admin panel and limit the access using Panel's "Access Restrictions" (very similar to Views).
* Use Contexts, create an admin Context and display the content conditionally.

Basically, there is no best or worst way, it all depends on how your current site is set up. For example if you are already using Panels, it might make sense to go that route, etc.

Personally, I would use a mixture of Contexts and Views!

# Answer
> 2 votes
I think you can use the Views and Panels modules for this.

---
Tags: 7, users
---


# Question
Title: Does leaving the Views UI module enabled affect performance?
I noticed that the "Disable Developer Modules" link in the Administration Menu module disabled the Views UI module. I'm under the impression that the purpose of disabling the developer modules is to reduce performance impacts. But I didn't think the Views UI module would have an affect on performance. Does leaving Views UI enabled in production have any performance impact? Is there any other reason to disable this module on a production site?

# Answer
Every enabled module affect performance, just for the fact they are loaded, and parsed from PHP. views\_ui.module, in the branch 6.x-3.x-dev of Views, is 10355 bytes.
There are then hooks that are invoked from Drupal, even if you are not using anything from the Views UI module, such as views\_ui\_help(), views\_ui\_menu(), views\_ui\_theme(), or views\_ui\_library\_alter().

Another reason to disable unused modules is avoiding possible security issues.
> 11 votes

---
Tags: views, performance
---


# Question
Title: Sending mail to an adress specified in a node creation form with an CCK email field with Rules
I'm using a node creation form open to anonymous users to register volunteers for an event, and I want to redirect them to a thank you page, and send them an email when they register.

I'm using Rules to detect the submission of a volunteer node, and trigger a redirect to the thank you page, but I cannot figure out how to send a mail to the address specified in the form submitted.

# Answer
> 2 votes
As long as you have the Rules module and the Token module installed, it should be a pretty straightforward.

1) Create a rule that responds to the event "After saving new content"

2) Add an action to that rule "Send a mail to an arbitrary mail address" (from the System section)

3) Use a token for the Recipient field. As long as there is a CCK field for the email address, there will be a token provided for it. It will be listed in "Token replacement patterns."

---
Tags: 7, entities, rules
---


title: Title used for pages

text:
# Question
Title: Title used for pages
I have installed Drupal 6.19 and 6.20; in Drupal 6.19, I can see the page title like "site title|page title", but in Drupal 6.20 the page title "site title".

How can I add the node title to the page title in Drupal 6.19?
I didn't use Page Title in Drupal 6.19, nor did I in Drupal 6.20.

# Answer
> 2 votes
In the template.php of the theme add the following code.

```
function phptemplate_preprocess_page(&$vars) {
  $title = $vars['title'];
  $site_name = $vars['site_name'];

  $vars['head_title'] = implode(' - ', array($site_name, $title));
}

```

Verify the `$head_title` variable is present in page.tpl.php.

---
Tags: nodes
---


# Question
Title: How do you change the LDAP DN for a user?
We are using LDAP integration on a Drupal 6 system (with the "LDAP authentication" module).

During initial log-in, the user account will be created and the DN (Distinguished Name) for that user will be set automatically.

Now, due to some structural changes, the DN for some users will change slightly.

Is it possible to somehow change the DN that is used by Drupal, or to force some kind of "re-authentication" of Drupal Usernames with the Active Directory? Or do I have to edit the ldap\_dn in the database?

# Answer
> 4 votes
If memory serves me the DN will get auto updated next time they log in. No editing necessary.

---
Tags: 6, users, authentication-authorization
---


# Question
Title: How do I control user generated contents published state?
I want to allow users to submit the content to my site, but the content must be first approved, and then it can be published.

Someone told me to write a module, but I don't know which steps to follow.

1. Let the current user see the content that it is published by him, which is still not approved.
2. In addition, create a form to allow the current user to edit the node.

Does anyone know how to write such module?

# Answer
> 3 votes
There is a module for that™: Workflow module!

> The workflow module allows the creation and assignment of arbitrary workflows to Drupal node types. Workflows are made up of workflow states. For example, a workflow with the states Draft, Review, and Published could be assigned to the Story node type.

In your case you only need to workflow states: review and approved/public.

# Answer
> 3 votes
I think you should be using Views, Workflow and possibly Rules.

With Workflow you can create a "review" state; this will then have to be reviewed before a publisher can make it viewable as published content. The workflow module comes with Workflow summary which can show all the articles which need to be reviewed. You can use Views to change it to only allow users to see their own content.

Rules always comes in handy, it helps to unpublish/publish nodes depending on workflow states.

---
Tags: 7, workflows
---


title: Drupal 7 and Open ID

text:
# Question
Title: Drupal 7 and Open ID
How does this Open ID module work in Drupal 7? I would expect something more or less the way StackOverflow and all these StackExchange websites work: you pick up your logging provider, like Google or Facebook, by clicking one of them. If you aren't currently logged in in their service, you are redirected to their logging interface, fulfill username and password and you are redirected back to the parent website and already recognized. It looks like the OpenID module does not work this way. You have to paste an Open ID URL or something... Is there a module that does the process exactlys as in the Stack Exchange websites, or more or less the same? Because I think the process implemented in this website is absolutely fantastic: quick and comprehensive, Dummies proof. Or I am afraid I am behaving like the Dummy myself if the Drupal Open ID module works this way. I have been experimenting with it in my localhost and it requires me to paste an OpenId URL. Thanks for any help clearing this...

# Answer
> 4 votes
Yes, OpenID always works with an URL, which is your identifier.

I think what you are looking for is the Janrain Engage module: http://drupal.org/project/rpx. This provides a similar workflow and UI like the one you know from StackOverflow.

# Answer
> 3 votes
The OpenID Selector module is another option for creating something similar to the StackExchange **login** process. Unfortunately, it doesn't yet support registration via OpenID, the way StackExchange does.

Some more details about this module (from its project page):

> This module integrates Javascript OpenID Selector with Drupal's OpenID client.
>
> This module substitutes Drupal's default OpenID form with Javascript OpenID Selector widget, so users do not even need to know what OpenID URL is.
>
> Javascript OpenID Selector widget is very widely used. For example, it is in use at SourceForge and StackOverflow.

---
Tags: 7, users, authentication-authorization
---


title: Questions about theming a node

text:
# Question
Title: Questions about theming a node
I am theming a specific node type in Drupal 7. I have named my file `node--mynodetypename.tpl.php`. Everything is fine and I can override the default node template; the issue is that I want to do very slight changes to the regular node template, basically the way the DIVs are structured. I get into trouble trying to replicate the original layout. I have installed the Content Templates module, and I am getting the variable names from there. I am not using it because it has some bugs in the current version.

1. How can I add the comments block to the end of my content type? I just want the ordinary comments engine placed in there, but it disappeared with my new layout. Contemplate does not provide the variable to make all that comments block appear.
2. Is there a correct way to publish the URL of an image? Contemplate provides me with this `$node->field_image['pt-br'][0]['filename']` for the raw image file, but then I have to manually fulfill all the folder structure; it also gives me this `$node->field_image['pt-br'][0]['uri']`. It presents the folder structure above the image file, more or less like `public://images/folder1/folder2/filename.JPG`.
Is there some kind of function I should call that would build the entire image URL for me?
3. I have created a piped list of countries as a select list. In my layout, I would like to show the name of the country, but the variable generated in contemplate `$node->field_country['pt-br'][0]['value']` only holds the country code; I would like to get the name of the country.
How can I do that?

# Answer
> 2 votes
Take a look at the default node.tpl.php. You'll notice that they render the content with `render($content)`.

I've never used Contemplate, but if you install the devel module you can then use the `dpm()` function to take a look at the variables in detail. Try `dpm($content)`, and you see all the content that you can render, or even use the hide function to remove content. For example, you can use `hide($content['links])` prior to `render($content)` and the links will not be rendered; you can display comments with `render($content['comments']);`. Don't forget to print the value returned by `render()`, as `render()` returns the HTML markup used to render the element passed as argument to the function.

You can easily render the image field with `render($content['your_image_field'])`.
If you are using the Countries module, then you can control what it is displayed in the content types display on admin/structure/types/manage/your-content-type/display, and simply render it like you do with the rest of your content.

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


# Question
Title: How can I protect the account of the first user, and not allow administration users to alter it?
I want to not allow users with the permission to administer users to alter the account for the first registered user (the one created during the installation of Drupal).
I also want to not allow them to view the user profile for that user.

Is there a module that allows this?

# Answer
> 3 votes
The User Protect module should suite your use case.

> This module allows fine-grained access control of user administrators, by providing various editing protection for users. The protections can be specific to a user, or applied to all users in a role.
>
> *Note: User Protect has a complicated configuration — please take the time to read the very extensive module help before using it!*
>
> The following protections are supported:
>
> * username
> * e-mail address
> * password
> * status changes
> * roles
> * deletion
> * OpenID identities
> * all edits (any accessed via user/X/edit)
>
> When a protection is enabled for a specified user (or the protection is enabled because the user belongs to a role that has the protection), it prevents the editing operation in question that anyone might try to perform on the user—unless an administrator who is permitted to bypass the protection is editing the specified user. The module will protectfields by disabling them at user/X/edit.
>
> User administrators may be configured to bypass specified protections, on either a global or per-administrator basis.
>
> These protections are valid both when trying to edit the user directly from their user/X/edit page, or using the mass user editing operations.
>
> The module also provides protection at the paths user/X/edit and user/X/delete, should anyone try to visit those paths directly.
>
> *Note: this module is compatible with the RoleAssign module.*

---
Tags: 7, users
---


title: How do I overwrite the page?

text:
# Question
Title: How do I overwrite the page?
I used the CCK module to create a content type that has three fields (title, description, and body). I want to overwrite two pages: one is where there is a "create content" navigation located on the left page; the other one is where I click on "Create page" and which displays the form page.

# Answer
> 1 votes
To alter a node edit from, you need to create a custom module that implements hook\_form\_alter(), using code similar to the following one:

```
function mymodule_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) {
    $node = $form['#node'];
    // ...
    // @todo Add the code you need.
    // ...
  }
}

```

For examples of actual implementations of `hook_form_alter()` that alter the node edit form, see book\_form\_alter(), locale\_form\_alter() (which alters also other forms), menu\_form\_alter(), path\_form\_alter(), and taxonomy\_form\_alter().

---
Tags: 7
---


# Question
Title: How to design a page created using Views
I have created a page with help of the Views module, and it is perfectly doing the job.
I need to design the page on my own.

How can I do this?

# Answer
> 7 votes
The easiest way to style a page generated by views is to simply edit the CSS.

If you need more control over the markup generated you can use Semantic Views to clean up and improve the generated HTML.

Another simple solution is to manually add a template: there's a "Theme" section in the Views UI (just above where you set the Path and Menu Item). There you can select the best template to use (`views-view--YOURVIEWNAME--page-1.tpl.php` or something similar) and copy & paste the default template code.

Then, create a file with the same name in your Templates directory (`views-view--YOURVIEWNAME--page-1.tpl.php` or something similar) and past the code there. You can now edit the template as if it were any other!

If it isn't getting recognized by the View, don't forget to go back to the "Theme" section in Views UI and click "Rescan template files" to make sure it's found!

# Answer
> 3 votes
A simple way is to style view fields with CSS.
Another way is to click on "Theme information" in the style setting block of the edit view page. You can use the listed names create your own theme, and copy the created file to your theme folder. Click on "Rescan template files" in the theme Information menu. Now your theme is applied for the view. Check also How to quickly theme a view?

# Answer
> 3 votes
Make sure you check out modules like Display suite & Node display. With these modules you can layout a node for all standard build modes (full, teaser, etc) and create your custom build mode; then, you can drag and drop node fields into node regions. In your views, choose display suite when selecting your row style. Each node in your view will be rendered according to the layout you've created in Display suite.

# Answer
> 3 votes
We can able to design the page by following doings:

1. **Administer-\>Site Building-\>Views**
2. Choose **Theme:Information** from **Basic Settings**.
3. Click on **Row Style output**.
4. A set of code will generate. **Copy the code and paste with the file name generated at the first line of the code and have the file in your current theme folder**.
5. Now design the page as you like.

---
Tags: 7, views
---


title: How to add OG to the menu?

text:
# Question
Title: How to add OG to the menu?
I have Organic Groups installed within Drupal 7 and I am attempting to get the groups to display in the menu. For all authenticated users I want the group(s) they belong to show up in the menu (could be the user menu).

**Addition:**

The picture below shows how far I have gotten. This is within the edit view window. The closest window shoes the fields that can be added. The only group-specific fields I found are `Group: Group permissions` and `Group: Group user roles` and for the filter there aren't any group-specific choices. Is there some roundabout way to add them or a specific permission I may be missing. I have given my administrator (currently logged in) all of the permissions listed for the groups.

# Answer
> 2 votes
Do you need this in an existing menu?

Personally I would do this with Views. If you have it installed try the below.

1. Create a new view
2. Add a Block Display
3. Set Access to Authenticated Users
4. Change the Basic Settings \> Style to "Table"
5. Add Fields for Node Title & Organic Group Post count
6. Add Filters for Organic Group Member "True"

This will now display a table with the titles and a "new" post count. You can make it look more like a traditional menu by changing the view settings further.

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


title: How do I set up the Workflow module?

text:
# Question
Title: How do I set up the Workflow module?
My site has an administrator role (editor), and I want to allow the anonymous users to submit articles in my site; the node they create must be approved by editor users, before to be published. I have been told to use the Workflow module; I installed the module, and set it, but I didn't obtain what I wanted.

These are the steps I followed:

* I created a workflow which is named "teststory", and added the "approve" state, which is applied only to the "story" content type.
* I edited the workflow, which is then shown as

```
   from/to     approve
   (creation)  checked the author and authenticated user
   approve     nothing

```
* Under the "access control" approve part, I allowed the authenticated user to view, edit, and delete the posts that are in this state.

# Answer
It looks like you have only one state (*approve*). You really want to have at least two. Try adding *draft*. Configure the workflow so that on creation the node goes to the *draft* state. This should work:

```
From / To     draft      approved
(creation)    author         -
draft                    editor
approved        -

```
> 2 votes

# Answer
It sounds like you are half way there, you should only need to either setup actions or use the Rules contrib Module...

Some tips for setting up Workflow:

1. If you encounter problems getting a module to work as expected, read the readme.txt file in the Module folder
2. For setting up Worflows, use 2 browsers (one logged into your site as the editor and the other as an anonymous user), this way you can quickly test to see if everything is working correctly and compare the editors displayed for each role.
3. You need to decide if you want to use the core actions or the contrib module Rules. Personally I prefer Rules. Once you have chosen you make it so that when a workflow state changes to "x" Drupal automatically publishes the content.
> 0 votes

---
Tags: 7, workflows
---


title: Overlay arguments

text:
# Question
Title: Overlay arguments
I'm using Organic Groups and I'm giving users a link to create content for the current group. I do this by giving the path `node/add/grouptype?gids_node[]=1891`.

This works fine, as the group is set by default. However, I can't get this to work on the overlay: `node/1962#overlay=node/add/grouptype?gids_node[]=1961` makes the overlay not appear at all and `node/1961?gids_node[]=1961#overlay=node/add/grouptype` shows the overlay, but I don't think the argument is passed correctly.

Do you have any idea? I can't find any documentation on this.

# Answer
> 0 votes
Okay, turns out it had nothing to do with overlay and had to do with correctly using `l()` function. If you want to add a query/arguments to a link using `l` function, you need to give a query argument to it. For example:

`print l("Add page", "node/add/grouptype", array('query' => array('gids_node[]' => $group->etid)));`

Otherwise, the ? will be encoded to %3F

---
Tags: 7, organic-groups, modal-dialogs
---


title: Register and pay online

text:
# Question
Title: Register and pay online
I would like our website can register right. Such registration is: After the user fields to fill out the registration page to enter paid. If payment was successful record in the user database is placed.

These payments are: When users get paid by the banks a record is submitted to my site. This must be paid to confirm a few fields of this record to send back to the bank.

# Answer
I think you might want to read this: http://drupaleasy.com/blogs/ultimike/2009/03/event-registration-ubercart

It's a walk through of setting up an "event registration" system in Drupal - however, that is really just a web site that:

```
1) presents introduction information about a product or service
2) After a customer clicks "Add to cart", presents the customer with a form to complete of
   needed info for that product/service
3) if the customer's credit/debit transaction is successful, the customer's purchase is
   identified as "valid" and your web site does whatever you offered in the way of
   product/service for your customer.

```

This is achieved with Ubercart, Ubercart's Conditional Actions, and some minor tweaking fully explained in the link above.
> 2 votes

# Answer
You can use Ubercart Event Registration. This creates an Ubercart product class which is also a webform. You can then create one of these for each type of subscription. Ubercart already has functionality for creating the user on purchase. You would just want to add some logic to assign a certain role to the user when payment's verified (as otherwise you could cancel the payment but the user account will still have been created).
> 0 votes

---
Tags: 7, users, commerce
---


# Question
Title: Hook for module activation and deactivation
I am trying to execute a function in my module when the module is activated or deactivated by the user. It seems that there is a hook for this in Drupal 7, but not in Drupal 6. It is possible to do this with a workaround in Drupal 6?

# Answer
The docs say that `hook_enable()` and `hook_disable()` are for versions 5-7.
> 4 votes

---
Tags: 7, hooks
---


title: How do I update a module manually?

text:
# Question
Title: How do I update a module manually?
I need to update my Views module in Drupal 7. Drupal won't do it automatically. It says the download is not available.

I have downloaded the new version manually, but when I try to install it via 'add new module', the message is 'views is already installed'. How do I update the module?

# Answer
> 13 votes
Updating a module is usually two steps:

1. Replace the files with the new version you downloaded, for example via FTP.
2. Run update.php (it is not always needed, but run it to check if updates are needed).

When updating, it can be a good idea to try the update on a local development environment to check that nothing breaks, and do a backup before the live update. Some updates are minor and won't need this.

Views, which stores a lot of configuration in the database and has recently undergone major changes, is one of those modules where you usually want to test it out before upgrading.

# Answer
> 3 votes
I think you'll find everything you need from at the following links:

IMO, the most important step is: don't forget to always backup your database before any changes.

---
Tags: updating
---


# Question
Title: Which are the steps to make Locale language switcher block appear at selected area?
After this question on which module to use to handle interface translation I was expecting the setup of Locale to be pretty straightforward. I guess it is not.

Well, my backend and navigation menus got translated right away but the main objective (as you can see by reading the other question) was to allow any user to change language as needed.

So the goal is to setup the language switcher block in order that it is available to everyone.
Steps performed:

* Enable module Locale
* Setup language switcher block to appear at some area
* Configured block to appear to all roles on every page
* Added a new language and imported the .po file
* Checked all locale permissions (except anonymous user -\> translation)

Am I missing something?

# Answer
You need to set the language negotiation.
> 2 votes

# Answer
I think the block only appears on pages which have translated content
> 0 votes

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


title: How to programmatically edit a field?

text:
# Question
Title: How to programmatically edit a field?
I have a type node called flat, a field called latitude. I want to update the value of this field in a module each time the node is updated.

I try to use the hook\_node\_update() but nothing happens :

```
function flat_node_update($node){
    print_r($node);
    return $node;
}

```

Do you have the answer?

# Answer
> 6 votes
hook\_node\_update() is called *after* the node has been updated.

You want hook\_node\_presave() instead. If the nid is not empty, it is an update.

---
Tags: 7, entities
---


title: Manage events among users

text:
# Question
Title: Manage events among users
I'm creating a community site where users should be able to create events and participate in other users events. I guess there are some options, but which modules do you think would work as candidates for building such a site?

# Answer
It should be pretty simple by creating a content type (for example, *Events*), with the date fields implemented by the Date module and use the Signup module for users to RSVP. For the calendar, there are at least two modules.

Both the modules have a Drupal8/9 release.
> 2 votes

---
Tags: 7
---


title: Drupal queue / update module

text:
# Question
Title: Drupal queue / update module
I have a Drupal 7 site and the queue table has over 4K records. They are primarily for the "update\_fetch\_tasks" queue. Is the queue table by nature a temporary place holder?

I would like to clean it out and see if it fixes some issues that I am experiencing with the update module. I've done some digging on the queue module and from what I can tell is that proper usage is to claim the queue items and when you are done with them you should delete them. So it seems odd that a core module is leaving records in the queue.

Is there any harm in removing records from the queue?

# Answer
> 5 votes
That table is used by the BatchQueue class; on the top of the page I linked there is the following note:

> Stale items from failed batches are cleaned from the {queue} table on cron using the 'created' date.

For some reason, in your case they are not being deleted during cron tasks; probably cron tasks are not enabled in your site, and the setting that allows cron tasks to be executed through JavaScript is not selected.
In any case, once batch operations are completed (which means also when the updates have been completed), it is safe to delete those database rows.

---
Tags: 7, updating, queue
---


title: node_delete() is not deleting nodes

text:
# Question
Title: node_delete() is not deleting nodes
I'm trying to use a drush function to flush out all of the drealty module's nodes in my drupal 6 install. However, something is causing a memory leak and the nodes are not being deleted after node\_delete is called. What can I do?

Here is the memory exhausted error:

```
drush rets-flush
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in /home/directory/public_html/sites/all/modules/filefield/field_file.inc on line 300
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: Allowed memory size of 134217728 bytes exhausted (tried to
allocate 71 bytes) in
/home/directory/public_html/sites/all/modules/filefield/field_file.inc,
line 300

```

Here is the drush rets-flush function:

```
function drush_drealty_rets_flush() {
  set_time_limit(0);

  $result = db_query("SELECT nid FROM {node} WHERE type = 'drealty_property' OR type = 'drealty_agent' OR type = 'drealty_office' OR type = 'drealty_open_house'", $conid);

  $count = 0;
  while ($nid = db_fetch_object($result)) {
    node_delete($nid->nid);
    drush_log(dt('Deleting node id: @nid. ', array('@nid' => $nid->nid)));
    $count++;
  }
  drush_log(dt('Deleted @count nodes', array('@count' => $count)), 'success');
}

```

There are about 5000 records total.

# Answer
You may find that you still run out of memory if you have enough nodes of the drealty type. This is because `node_delete()` calls `node_load()`, and that adds each node to a static cache. If you run into this, simply call `node_load(NULL, NULL, TRUE)` once every 50 - 100 iterations.
> 2 votes

# Answer
Found the answer myself. I had to run drush as admin:

```
drush -u admin rets-flush

```

I thought drush ran as admin automatically, but I guess not.
> 2 votes

---
Tags: 6, nodes, drush
---


# Question
Title: How can you allow an unregistered user to change languages?
I have no clue to which is the Drupal way of allowing any user (registered or not) to change the website language.

The way I need it to work is to allow any user to click on their preferred language flag and just change the interface language.

What modules should I look into?
Is there any function I should be calling when clicking the flag?

Any link to something resembling a walktrough is also appreciated.

# Answer
If it's just the interface you'd like to translate, then I think you can get by with Locale (a core module). If you want content translation (and many other things) you can use i18n. The project page for i18n gives you plenty of links to follow for other projects and documentation.
> 3 votes

# Answer
You will probably also want to look at the Language Icons module, which provides the flags. Some details about this module (from its project page):

> This module provides icons for language links, both for the Language switcher block and (optionally) for node links. It is a spin-off from Internationalization (i18n) package.
>
> As basic multilingual support is now built into Drupal 6 core, it doesn't depend anymore on any other contributed module. This module will work as simple add-in for Drupal 6.
>
> However, for a fully enabled multilingual site, the Internationalization package is recommended.

Setup is very important with localization. I suggest that you start -- preferably on a test site -- by setting Language negotiation to "Path prefix only" and Content selection mode to "Mixed current language (if available) or default language (if not) and language neutral"
> 1 votes

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


# Question
Title: How do I edit a complex entity via dynamically loaded AJAX-forms?
I have a "profile" entity with a field "education" (to get started). That field contains various input fields that describe the "education". At the moment I have "institution" and "year". I created that field with the Field API in a dedicated module and attached it to my "profile" entity (currently this is a profile2 bundle). The entity form works as expected, the "education" field widget is included and I can add multiple "education" entries. I can view my entity and the fields get formatted, and I can edit my entity and the form widgets get rendered.

```
--profile entity
----education field
------education a
--------institution a
--------year a
------education b
--------institution b
--------year b

```

But I do not like the all or nothing approach here. There are going to be many different fields and I want to display the "profile" entity with various "edit" and "add new entry" buttons, which should load the specified field form widget via AJAX. The profile page on xing.com is a good example of what I am trying to achieve.

Is this possible with the fields form widget and Field API alone, or do I have to implement the ajax callback via a menu hook, which returns a form with the needed input fields? Can I even use my "education" field in that scenario or do I have to work with the entity API and database API?

# Answer
> 1 votes
The forms that FieldAPI can build for you automatically are useful but not terribly flexible. If you're interested in building out a really dynamic form, you're probably better off creating your own from scratch and simply creating/saving the entity programmatically once the finished form is submitted.

# Answer
> 0 votes
Have you looked at the Examples module? They have sample code for Ajax forms, using the FormAPI.

# Answer
> 0 votes
I have successfully made a hierarchical select with ajax on a profile2 form used in registration.

```
// implementation of hook_form_FORM_ID_alter()
function impact_registration_form_profile2_edit_library_registration_form_alter(&$form, &$form_state) {
$form['profile_library_registration']['field_library_reg_state']['und']['#options'] = _impact_registration_library_states();
$form['profile_library_registration']['field_library_reg_state']['und']['#ajax'] = array(
                          'callback' => 'impact_registration_state_change_callback',
                          'wrapper' => 'name-select',
                        );
        $selected = isset($form_state['values']['profile_library_registration']['field_library_reg_state']['und'][0]['value']) ? $form_state['values']['profile_library_registration']['field_library_reg_state']['und'][0]['value'] : '';
    $form['profile_library_registration']['field_library_reg_system']['und']['#options'] = _impact_registration_library_names($selected);
    $form['profile_library_registration']['field_library_reg_system']['und']['#prefix'] = "<div id='name-select'>";
    $form['profile_library_registration']['field_library_reg_system']['und']['#suffix'] = "</div>";
        }
    function impact_registration_state_change_callback(&$form, $form_state) {
    return $form['profile_library_registration']['field_library_reg_system']['und'];
            }

```

When I select `field_library_reg_state`, AJAX returns `field_library_reg_system`, with a default value based on `field_library_reg_state`'s value in `$form_state`. This is all adapted from the ajax example. Now, what isn't working for me is adding an additional ajax call on `field_library_reg_system` so that it pre-populates a text box. The documentation for doing this is non existent, I don't understand how profile2 and entity forms work differently than regular forms in drupal. Which array elements are we supposed to target for the wrapper and callback?

---
Tags: 7, entities
---


# Question
Title: How to convert image URLs in Drupal node's fields while rendering?
I have developed a new CCK module using Plupload where users can drag and upload images using native HTML5 apis. Since, I do not know how to drag images directly inside CKEditor, what I am doing is that after images are uploaded using plupload's jQuery widget, I show an image instead of a filename from where users can drag that image inside a CKEditor. Its a 2-step drag-n-drop process.

Now, when I drag & drop images into a CKEditor using Chrome, CKEditor generates following code

```
<p>
    <img src="http://myportal/sites/myportal/files/plupload/p15sjkcj2c1o3koe3hsp19761ep14.jpg" /></p>

```

When I do similar action using Firefox/Safari, CKEditor generates following code

```
<p>
    <img src="../../sites/myportal/files/plupload/p15sjle1js11r5289aibk0m1n7q3.jpg" /></p>

```

Problem is depending on from where I am viewing the node (views, panel etc), images sometimes shows up and sometime not, because they point to location starting with ../../ and not with http://myportal/.

So, how do I make sure that when Drupal is generating node's view, "../../sites/myportal/files/plupload/p15sjle1js11r5289aibk0m1n7q3.jpg" is expanded or converted to "http://myportal/sites/myportal/files/plupload/p15sjkcj2c1o3koe3hsp19761ep14.jpg"

One way I can do this is using jQuery to find all `<img>` tags with a word 'plupload' in their src attribute , and then changing that attribute with full URL. But, it will slow down display a lot. Any other ideas using Drupal module or custom coding?

# Answer
You can probably accomplish that with a custom filter involving a regular expression using either Flexfilter or Custom filter.
> 1 votes

---
Tags: 7, views, nodes, uri, media
---


# Question
Title: I need to unset terms from the drop down
I'm writing a module to unset taxonomy terms using D6 `hook_form_alter()`. The object is to only present the current user terms which they have created themselves.

The trouble is that I don't know which variables to alter. I'm thinking it should be something like `$form['taxonomy']['2']['#options']`, but I cannot see a path in a DSM `print_r($form)`.

I have gone through hierarchical\_select.module again and again, but can't work out whether I need to be amending the results of `$storage`, `$elements`, `#names`, `$hsid` or any of the other variables; I am not sure about which hook to use too.

I just need to know how to apply the results of this `db_query()` in my custom module code which you can see on http://pastebin.com/RbwKB0rt.

Can anybody please help?

# Answer
I think I need more information.

In general, I believe you set the `#default_value` on your dependent form element to be the parent element, and also set the `#ajax` callback and wrapper on the parent. Check out the Ajax example and the form API reference.
> 1 votes

---
Tags: 7
---


title: Picture field in user table

text:
# Question
Title: Picture field in user table
I can see the picture field in the user table, and it seems the field accepts a picture address. I want to allow users to upload their picture to the site.

Is there any module or code to use this field?

# Answer
> 5 votes
Check the user account settings in page `admin/user/settings`, the option for changing user picture is "Picture support."

# Answer
> 5 votes
User pictures, the pictures associated with a user account, are handled from the User module.
You need to enable their support with the "Picture support" option you find in admin/user/settings.

The support works if the directory for the files has been correctly set, and Drupal has the permission to write files in that directory; the path reported in "Picture image path" must exists.

---
Tags: 7
---


title: How to use Views to obtain this?

text:
# Question
Title: How to use Views to obtain this?
I want to use the Views module to obtain the number of comments associated to a node, and show it as "1 comment," "5 comments."
How do I do this?

# Answer
> 2 votes
Checkout the Views Group By module, this will do it. Here is a quote about it (from the module's project page):

> ... enriches Views2 functionality with SQL Grouping and Aggregation capabilities.
>
> A new field group: SQL Aggregation is added, in Views, once you install the module. The field group has one available field: SQL Aggregation: Group By Fields. The field allows to configure many aspects of "group by" SQL clause and "count()" fields.

---
Tags: 7, views
---


# Question
Title: Is there a way to consume external web services and show results in Views?
I have an external web service, which can be accessed using a HTTP call (with parameters passed as query string), and that returns the result in XML format.

I would like to use Drupal to access that web service (with the desired parameters), and display the result using Views.

These are a sample query and the result obtained from the web service I am using.

Query: http://localhost/query.php?cy=in&q=abcd&cat=22
Result:

```
<?xml version="1.0"?>
<results>
<Jobs>
    <Job ID="111">
        <Title>Test one</Title>
        <Summary>Test one summary</Summary>
        <DateUpdated Date="2011-04-04 18:03:00">4/4/2011</DateUpdated>
        <Location>
            <Country>India</Country>
            <City>Delhi</City>
        </Location>
        <CompanyName>Test Company</CompanyName>
    </Job>
    <Job ID="222">
        <Title>Test two</Title>
        <Summary>Test two summary</Summary>
        <DateUpdated Date="2011-04-04 18:03:00">4/4/2011</DateUpdated>
        <Location>
            <Country>India</Country>
            <City>Chennai</City>
        </Location>
        <CompanyName>Test company</CompanyName>
    </Job>
</Jobs>
</results>

```

# Answer
The advised solutions are based on getting the data into the database first, then showing it in Views.

An alternative is querying the service directly from Views, by using a custom query backend. Checkout http://drupal.org/node/958270 for links to custom backends which you can use as an example for writing your own (it's not a lot of work)
> 4 votes

# Answer
The Feeds module can pull in content and turn it into nodes. Feeds XPath Parser will allow you to parse the xml file and map tags to fields. You can then use Views to display the content as normal.
> 3 votes

# Answer
I'm sure there's a more elegant solution out there, but I've done this in the past with twitter feeds and it works just fine. Here's my take on it:

* Create a content type to store your results and set up fields as necessary to match the content you will be consuming
* Create a module that implements hook\_cron() and periodically consumes the web service and stores results as nodes

The second step can be achieved by programatically creating the node instances:

```
$node = new stdClass();
$node->title = 'title';
$node->my_custom_field['und'][0]['value'] = 'my custom value';
// fill all your other fields
node_save($node);

```
* The best way to avoid duplication when creating the nodes programatically would be to compare the ID (or timestamp, or whatever) of the web service's results to the most recent entry in the database:

```
SELECT fdfpi.field_picture_id_value FROM field_data_field_picture_id fdfpi INNER JOIN node n ON fdfpi.entity_id = n.nid AND fdfpi.entity_type = 'node' WHERE n.type = 'picture' ORDER BY n.created DESC LIMIT 1

```

The above example can seem kinda confusing but its not really: I created a content type "picture" that has a custom field "picture\_id". Its just a manual way to retrieve the ID for the most recently created node of that type.

* So now that you have a specific content type that you automatically populate on cron time... profit! You can use Views to display the data any which way you please because its in the form of regular ol' Drupal nodes! :)

Hope this helps!
> 1 votes

---
Tags: 7, views
---


title: Problems with Media gallery

text:
# Question
Title: Problems with Media gallery
I am using the media-gallery module to create dynamic galleries for a site.
I have a problem when I edit a node; I get the following error:

> Notice: Undefined index: media\_gallery\_format in locale\_field\_node\_form\_submit() (linea 405)

I have read Undefined indexes in locale\_field\_node\_form\_submit(), but I didn't resolve the problem. The issue report suggests that the error depends from a local language, and that I should change one line in media-gallery.module, but I don't understand where that line is, and how to change the code.

Can anybody help me?

# Answer
The solution reported in the issue report is to replace every occurrence of `unset($form[$id])` with `$form[$id] = array('#language' => NULL)` in all the module file; you just search for the first string, and you replace it with the second string. The module file is media\_gallery.module.
Who suggests the fix doesn't report in which line you find `unset($form[$id])` because you probably find more occurrences of that string, and the user doesn't want to make a list of all the lines containing that string. It is also useless to make such list, as an editor can easily make a search and replace for the strings listed in the issue report.
> 2 votes

---
Tags: 7, media
---


title: Wildcards in dynamically generated menu

text:
# Question
Title: Wildcards in dynamically generated menu
I'm working on a custom module, and I'm building menu items using entries in a database. These are being cached, and the database is only really updated about once a month.

I'm having an issue getting wildcards to work with this menu.

Here's my menu structure that WORKS:

```
$dbconn = dbConnect();
$query = "SELECT TOP 3 id, title FROM table";
$q = mssql_query($query, $dbconn);
while($r = mssql_fetch_assoc($q)) {
    $title = $r['title'];
    $items[$title] = array(
        'title' => $r['title'],
        'description' => 'Page for ' . $r['title'],
        'page callback' => 'programs_page',
        'access callback' => TRUE,
        'type' => MENU_NORMAL_ITEM,
    );
}
mssql_close($dbconn);

```

But the moment I add the % into the array key, the menu items just disappear, like so:

```
$items[$title . "/%"];

```

Any suggestions on why drupal is tripping up on this? Even if I tack the ."/%" onto the $title variable, it doesn't work.

# Answer
There is no need to add wilcard placeholders after your last path element. Anything tacked onto the end of the URL will be passed to the callback as arguments automatically.

If the example you give above, if someone goes to `$title/arbitrary/arguments`, then 'arbitrary' and 'arguments' will be passed as arguments to your page callback:

`programs_page('arbitrary', 'arguments');`

If you want arguments in the middle of your path, you can specify them with a % sign, or if you would like to automatically load and pass an object to your page callback, you can use wildcard loaders.
> 2 votes

---
Tags: 7, routes
---


title: how to overwrite the views output?

text:
# Question
Title: how to overwrite the views output?
I used Views with 6 fields. I want to overwrite the output for 4 fields, and add "more \>\>" under one fields output, and make the "more" link to the node. I know that creating 4 template files will get that, but creating 4 template files is too boring.

Is there a way to overwrite the 4 fields in one file? If I can, could you make me an example?

# Answer
or you can simply add a views field 'Node:Link' - you can set the text in the options of that field.

If you want to add this field to other fields, choose the 'rewrite output' option of those fields, and place the token of that current field + the token of the 'node:link' field in the output area.

Make sure you check the 'exclude from display' option for the 'node:link' field and set the field first in the field order, so the token is made available
> 3 votes

# Answer
Rather than using a tpl file, you can rewrite the field. For that, just configure the field and check *Rewrite the output of this field*. You can use any fields that occur prior to that one in your rewrite (details are under *Replacement patterns*) and HTML. If a field you need doesn't exist, just add it and exclude it from display (and move it to before the field you want to modify).

This method can get pretty cumbersome pretty fast, and isn't as nice for themers or source control as a tpl file.
> 1 votes

---
Tags: 7, views
---


# Question
Title: Can you make the hook_menu() item title different from the page title?
I'm building a menu with hook\_menu().

When you're building the array for this you specify a title, which is then passed to the page you call and becomes the page title. It's also the menu item's displayed name.

```
$items['somewhere/something'] = array(
 'title' => 'Something',
 'description' => 'something else',
);

```

This would generate a menu link called "Something", and the page title would be the same. Is there a way to make the menu item's name one thing, but pass along a different title for the page?

I know I can use `drupal_set_title()` in the actual `hook_page()` function, but I'd have to perform an additional database pull to make that happen in this case, and I'd rather not do that.

# Answer
No there's no way to do it with hook\_menu().

The simplest way is what you suggested, using drupal\_set\_title() and the most efficient is what **dobeerman** suggested above: use phptemplate\_preprocess\_page() and alter $vars accordingly.

Honestly though, I would just use drupal\_set\_title() even if there is that extra db call you mentioned (unconfirmed). This is a tiny optimization and if performance is important to you, you should have some caching mechanism in place (Varnish, Boost, etc) and this extra call won't make a difference!
> 6 votes

# Answer
To set a different title for the page (the one used in the `<title>` tag), you have two possibilities:

* In your module, implement `MODULE_preprocess_page()`and use it to alter the value of `$variables['head_title']`. The documentation page for template\_preprocess\_page() reports which values are available in the `$variables` array.
* Install the Page Title module, which allows you change the title set for a page. It allows you to execute a PHP snippet to set the page title, and it also uses tokens.

Using drupal\_set\_title(), you don't set just the page title or the title visible in the title bar; you set both, as reported in the documentation.

> Set the title of the current page, for display on the page and in the title bar.
>
> Parameters
>
> $title
> Optional string value to assign to the page title; or if set to NULL (default), leaves the current title unchanged.
>
> Return value
>
> The updated title of the current page.
> 1 votes

---
Tags: 7, routes, hooks
---


title: Display referenced node field in view

text:
# Question
Title: Display referenced node field in view
I have a view made up of nodes that include node reference fields. I would like to pull in a field from each of the nodes being referenced for display in my view.

I know that is a little confusing so let me give you an example.

* My ***food*** content type contains the name of a food and the number of calories it has.
* My ***diary*** content type contains a date and a node reference that accepts ***food*** nodes.
* My view displays your ***diary*** nodes.
* I would like to display the calories for each ***food*** item that is being referenced by ***diary***
* I would like to add the calories using views\_calc (or something else).

The way I see it there are two ways to do this - either add a calories field to my ***diary*** content type that automatically pulls from the node that is being referenced, thus making it available to my view. The other option is for views to be able to pull in fields (sub-fields?) from a node reference field.

I don't know if either option is possible or, if it is, how I would go about doing it. Any help would be greatly appreciated.

Edit: Relationships will allow me to pull in the fields I need, so now I just need a way to add them. Views\_calc does not support calculations on relationship fields.

# Answer
> 3 votes
Shouldn't be too hard with a Views Relationship.

As you've mentioned, your View should show content (nodes). Here are the rough settings, as I see it:

* Filters: Published or Admin; Content Type: Diary
* Display: Fields
* Relationships: Content-food nodereference field
* Fields: Food (no reference...from the diary content type); calories (from the referenced food field)

That should about do it. I usually have to tweak Views relationships a bit to get them to work perfectly, so it's a bit tough for me to get it exactly right without seeing your content.

Best, Scott

# Answer
> 1 votes
I outlined my solution for getting this to work with views\_calc here: http://drupal.org/node/416670#comment-4313730.

# Answer
> 0 votes
If you want more control over what gets pulled in without using a relationship, try Views Field View

It allows you to embed a view as a field within another view. Arguments pass from the outside view to the embedded view.

I've found this useful when trying to create a view that displays fields from a node\_referenced node.

Kim

---
Tags: views, entities, nodes
---


title: Why can't I output it?

text:
# Question
Title: Why can't I output it?
```
stdClass Object(
  [nid] => 98
  .......
  [title] => hello world!
  [body] =>
  ........
  [field_img] => Array(
    [0] => Array(
      [fid] => 200
      [list] => 1
      [data] => Array(
        [alt] =>
        [title] =>
      )

      [uid] => 1
      [filename] => coupon.jpg
      [filepath] => sites/default/files/coupon_0.jpg
      [filemime] => image/jpeg
      [filesize] => 4434
      [status] => 1
      [timestamp] => 1302080050
      [nid] => 98
      [view] =>  **the image**
      ......
    )
  )
)

```

Supposing the object is `$test`, `echo $test->field_img[0]["timestamp"]` in `views-view-fields.tpl.php` outputs `1302080050`, but `echo $test->field_img[0]["nid"]` and `echo $test->field_img[0]["view"]` don't output anything; I can't print 98 and the image. `print_r($test->field_img[0])` doesn't print the node ID and `view`? Why?

# Answer
> 3 votes
In Views template files you have access to the following objects:

* `$row`
* `$fields['field_my_field_value']->row`
* `$fields['field_my_file_value']->content`

You do not have access to multiple image objects in your case. You should call an external function to retrieve data for each item.

```
$arg = (object) array(
  'type' => $fields['type']->raw,
  'vid' => $fields['vid']->raw,
);
$files = filefield_get_node_files($arg);

foreach ($files as $file) {
  print theme('imagecache', 'preview_body', $file['filepath']);
}

```

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


title: Adding a span tag to main menu items

text:
# Question
Title: Adding a span tag to main menu items
> **Possible Duplicate:**
> How do I insert a \<span\> \</span\> tag inside the \<a\> \</a\> tag on my main menu

I tried the code found in How do I insert a \<span\> \</span\> tag inside the \<a\> \</a\> tag on my main menu, and I have a problem with it: while it does add the span tags, it also strips out the main menu's unordered list and classes.

How do I add the span tags **inside** the main menu links while also keeping the unordered list and the list menu classes?

# Answer
Try this, http://api.drupal.org/api/drupal/includes--theme.inc/function/theme\_links/7:

```
function THEMENAME_links__system_MENUNAME_menu($variables) {
  $output = '';
  foreach ($variables['links'] as $link) {
    $output .= l('<li' . drupal_attributes(array('class' => $class)) . '>' .'<span>'. check_plain($link['title']) .'</span>' . '</li>', $link['href'], $link);
  }
  return $output;
}

```

Is the `<li>` inside the `<a>`?
> 1 votes

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


title: Node:Link token in views

text:
# Question
Title: Node:Link token in views
I want to change the text shown for the Node:Link field, which by default is "View". How can I change it?

# Answer
> 6 votes
You can change the the text in view, in the settings of the field "Node:link"

---
Tags: 7, views, tokens
---


# Question
Title: Adding Facebook Like-button to the User menu in the top-right corner
Do you think there is a way to make a Facebook Like-button appear in the **User menu** of Drupal 7, right besides the **My Profile** and **Logout** links?

**UPDATE:** I'd like to add the button for my site and the **User menu** seems to be the best place.

# Answer
As an alternative to adding the like-button in the actual link items, maybe you should consider add it via a block or similar above/below your menu.

Checkout the Facebook social plugins integration module.
> 1 votes

---
Tags: 7, routes
---


title: How do I add an image to blogs?

text:
# Question
Title: How do I add an image to blogs?
May you give me few hints on how to enable adding 1 optional image to each blog entry?

I've enabled Blog and Image modules and registered users can create and comment on them.

What is the next step?

# Answer
* Go to "Manage Fields" link for the Blog content type (/admin/structure/types/manage/blog/fields) and **add a new field**:
* Name it whatever you want ("blog\_picture" or something) and for the **Field Type** select "Image"
* Click "save", pick a default image if you want and click "save field settings"
* On the next screen **do not** tick "Required", make any other changes you want and click "save settings"
* Done!
> 3 votes

---
Tags: 7, entities, media
---


# Question
Title: Drupal 6.x vs 7.x for Multiple Domains and LDAP
We're looking at using Drupal for our public sites, which will have:

* multiple primary domains
* multiple sub-domains

We will need to allow our users

* to authenticate against LDAP
* to get different roles per site
* to share content across primary and sub-domains.

Looking at the modules that are stable and under active development, 6.2x looks better than 7; of course 7 is very new. If we go with 6.2 now, we'll have to upgrade to 7 later; if we go with 7 now, we won't have all the functionality that exists in 6.2, specifically LDAP.

How would you address this situation of 6.2 vs 7.x? If you came across this situation, how did you make the decisions? What risks did you weigh? What direction did you go in?

# Answer
This one is easy: go with 6.2.x!

Despite being new and exciting and all of that, Drupal 7 still is very lacking in the stable contrib department. Also, despite the huge number of modules that adopted the D7X pledge, a lot of important and frequently-used modules still don't have stable versions (ahem, Views! say what you want - "beta" and "dev" are not stable enough for enterprise purposes)

Drupal 7 also introduced some API changes that, despite not being huge, still mean that there's a small new learning curve to developing Drupal 7 modules.

Drupal 6, on the other hand, is more than stable and has plentiful offerings for modules including LDAP integration and anything else you might need. Since it's been around for a couple years now, there's no shortage of experienced developers who can aid in implementing the site and developing custom modules.

As far as *having* to upgrade to Drupal 7 eventually, despite it being a valid point in deciding which version to use, who said you **have** to be running the latest version? As far as I know enterprises take longer than most to adopt new technologies.

Quite frankly, developing for Drupal 7 (specially large and mission-critical software) is a lot more expensive and complicated at the moment than using Drupal 6 and I would strongly advice against it for at least 3-6 months to wait and see how contrib modules will react and see how it will be adopted in general by the community.
> 2 votes

---
Tags: authentication-authorization
---


# Question
Title: Correct way of formatting dates for output in node theming
I am theming a node where I need to show the created date. Since Drupal stores it as timestamp, what is the best method to retrieve it? I have found this post: http://drupal.org/node/101993. But the problem is that whe using this...

```
<?php
print date("D, j M, Y \a\\t G:i", $node->changed);
?>

```

... it delivers me the content in English. My portal default language is Portuguese. Is there a Drupal function that will deliver the timestamp as a regular date that takes into account the user's selected language? And that maybe takes into account the preformatted dates set in the portal configuration? Thank you.

# Answer
> 6 votes
Instead of date(), try using format\_date()

It has an otional last parameter `$langcode` that tells it what language code to use for the date.

---
Tags: 7, datetime
---


# Question
Title: Good looking contributed themes for Drupal 6
I am looking for good looking contributed themes fro Drupal 6. Drupal.org is filled with themes, although several of them lack support even for the most used modules (taxonomy, search, comment) and many are table based or written through bad and horrible practices.

What I would like to see are modern themes with great typography, grids, good coding practices, based on starter themes, making good use of CSS3 features, supporting other modules. I know it's hard to see a theme with all of those qualities, but try to match at least *two* of these.

# Answer
> 1 votes
While not definitive, looking at the list sorted by number of installs is probably a good place to start regarding coding standards, and wide support.

Further filtering this list using some of your keywords like 'starter', 'css3', 'html5', etc should help you find what you are looking for.

---
Tags: 6, theming
---


# Question
Title: Remove nodes individually from Solr Search index
I know you can choose which content types to exclude. However, is there a way of removing specific nodes from the Solr index?

# Answer
> 0 votes
Not sure if you've run across this module yet as it is a recent addition to drupal.org but it looks like it's right up your alley.

Apache solr exclude

# Answer
> 2 votes
That's exactly what I wrote the module for. There's a release now and I moved the module to Apache Solr Node Exclude because I botched the project creation the first time.

---
Tags: 7, search
---


# Question
Title: Best way to optimize for authenticated user performance?
The keyword here is **authenticated**!

Currently (as far as I know) the de-facto ways to optimize for anonymous access are through static page caches (varnish/squid/boost).

However, as far as I know this doesn't seem to do much good in a scenario where most of your users are authenticated.

Besides the obvious APC, Memcache and throwing money at hardware, what is the best way to performance tune a high-traffic site with mostly authenticated users?

For example: drupal.org, social networks, communities, etc.

I'm more interested in Drupal 6 at the moment so I guess MongoDB doens't apply for now...

# Answer
Every site is different, thus it will require different tricks to get it working. Here are the ones I use for our sites for logged in performance.

If you REALLY want to know what is causing the slow code, get a cache grind of your site. What all contributes to drupal page execution time?

edit: Looks like the 7.x version of Auth Cache is starting to be developed. Haven't used it but something to look into.
> 13 votes

# Answer
Install Authenticated User Page Caching (Authcache) and Easy authcache and write your custom plugins for easy authcache. Plugins makes some parts of the page to get with ajax. so big part of page will be cached and a changing parts will be got with ajax. You can use varnish and other proxies to cache such pages.
> 4 votes

# Answer
Profile your slow pages with XHProf. Thats the best tool around for showing which functions are slow. The other helpful tool is the slow query log of mysql.
> 3 votes

# Answer
Drupal.org is really running on Pressflow 6, and using Varnish; the content is served using a load balancer, and the database engine is probably MariaDB.

If you have a site that is similar to Drupal.org for the number of registered users, and for the number of nodes, then you should verify if you can use Pressflow; verifying if you can use MariaDB instead of MySQL is probably the next step.
> 2 votes

---
Tags: 6, caching, performance
---


# Question
Title: Problem between Organic Groups and Articles/Pages?
I am currently working within Drupal 7 and I have all of the Views and Organic Groups modules enabled. Currently when I create a new article or page on my site it appears fine on the front page of the website. Yet when I click to view/edit the article/page I am unable to see the body of the article/page even though I can see it on the front page.

When I disable the module Organic Groups Field Access I am able to see the body of the article/page at the front page, view and edit screens.

Is there some way to keep the module Organic Groups Field Access and still be able to see the body?

# Answer
> 1 votes
I had this problem too. It turns out the current 'stable' version of Organic Groups is not so stable. This along with some other annoying bugs are fixed in the development version of OG. Give that a try :-)

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


# Question
Title: What WYSIWYG editor allows me to select styles from a dropdown 'out the box'?
I have installed the WYSIWYG module in Drupal 7 and have tried it with CKEditor and TinyMCE. I want users to pick styles from the template css when editing, but here appears to be a bug with the WYSIWYG module (drupal.org/node/1069356) that prevents the style dropdown from working. CKeditor seems to have a similar issue (drupal.org/node/746524), although there does seem to be a patch for this. I am not confident enough to deply the patch though.

Is there a WYSIWYG editor that is able to do this successfully out the box?

# Answer
CK Editor is the best in my opinion, and it should provide this option out of the box - it is a shame about the bug. In Drupal 6 I use drop down styles for all the line stuff and templates for including more complex block level elements such as jQuery show/hides. I really cant recommend enough how well it works. I suggest that you try the patch before ditching ck editor and seeking an alternative...

Drupal 7 is still pretty new so you will encounter small issues such as you describe, if you are dealing with bleeding edge this is something you have got to expect... otherwise use Drupal 6
> 4 votes

---
Tags: wysiwyg
---