# Question
Title: Theme the landing page after saving new content
I have a content type **Testimonials** and like any other type, it gets displayed after you save it. Is it possible to theme that page into something that says **Your Testimonial has been saved!** instead of displaying the data? I only need this for this specific content type.

**EDIT**: @googletorp Am I doing this correctly? I placed this code in my custom module *enchance.module* (activated) but I'm still getting the same page: the full version of the published testimonial instead of being redirected to `<front>`.

```
function enchance_form_alter(&$form, &$form_state, $form_id) {
    //dpm($form);
    if ($form_id == 'edit-testimonials-node-form') {
        $form['#submit'][] = 'testimonials_redirect_success';
    }
}

function testimonials_redirect_success(&$form, &$form_state) {
  // Use the drupal_set_message solution.
  drupal_set_message(t('Your Testimonial has been saved!'));
  // Redirect to custom page solution
  $form_state['redirect'] = '<front>';
}

// I'm not being redirected to <front>

```

# Answer
with `hook_form_alter` you could for the form for the node type add a submit handler that will redirect to a custom page. Alternatively you could use `drupal_set_message`.

```
function module_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'the form id for the node form') {
    $form['#submit'][] = 'my_custom_submit_handler';
  }
}

function my_custom_submit_handler(&$form, &$form_state) {
  // Use the drupal_set_message solution.
  drupal_set_message(t('Your Testimonial has been saved!'));
  // Redirect to custom page solution
  $form_state['redirect'] = 'url/to/page';
}

```
> 3 votes

# Answer
The problem with your code is that you are using the wrong form ID. The form ID is normally the name of the function that build the form; it cannot contain characters that a function name cannot contain, such as hyphens.

With Drupal 7, you can implement hook\_form\_BASE\_FORM\_ID\_alter(), and your code would become similar to the following one:

```
function enchance_form_node_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#node']->type == 'custom') { // Replace 'custom' with the content type ID.
    $form['#submit'][] = 'enhance_redirect_success';
  }
}

function enhance_redirect_success(&$form, &$form_state) {
  drupal_set_message(t('Your Testimonial has been saved!'));
  $form_state['redirect'] = '<front>';
}

```

Taking the assumption that the submission handler was implemented in enhance.module, I used `enhance_redirect_success()`, as the function of a module needs to be prefixed by the module name, with the exception of "private" functions that are prefixed by an underscore and the module name, and the theme functions that are prefixed by "theme\_" and the module name.
If there is a module that implements `testimonials_redirect_success()`, and you want to use that function, then you replace "enhance\_redirect\_success" with "testimonials\_redirect\_success."
> 0 votes

---
Tags: 7, nodes
---


# Question
Title: Member list with Demographic Data - is there a module or how do I build a View?
I want to be able to do a Member Directory page that when clicked, displays a sortable view of Users, including First name, Last name, etc.

Is there a module for this or how do I build a View?

# Answer
> 2 votes
Creating a view of type user will allow you to extracts necessary user and profile fields to list in you view.

* Go to `admin/build/views`then click on`Add`.
* Define view name, description, tag and select view type as `user`.
* Add you display type `page` or `block`
* Alter/Override views settings
* Add fields, the list can expand
* Select view's format style as table, and configure this style for fields to sortable.

For demography point of view there are few date specific fields like created, last login.

This list can grow depending on module extending user entity e.g. profile

---
Tags: views, users
---


# Question
Title: How to enable users to add content only from some pages (and only once) in  Drupal 7
i currently need to implement this use case in drupal.

We have two different type of users: registered users and moderators.

I need to do the following:

* registered users can add only one particular content type: videoCV (no help needed on this subject)
* registered users can add this content only from a pre-definite page called "Create you Video CV" (the page is accessible in the main menu) and only once
* moderators can add contents wherever they want.

so i need on these points:

1. how to limit to registered users the possibility to add content only on one page?I mean have the link add new content only on that page? (and also change that link so that it reads add your videoCV
2. how to limit users so that they can add just one content?

any help is appreciated, i think i can solve point number 1 withouth particular coding, but i think i need to create a custom module for point number 2, that is no problem!

# Answer
Content Profile module usually bounds the users to create exactly one node of some content type that has been marked as Content Profile.

May this help you in this regard.
> 1 votes

---
Tags: 7, nodes, users
---


title: Drupal site Instant Messaging

text:
# Question
Title: Drupal site Instant Messaging
I am trying to find a module or a standalone solution that I can turn into a module that will allow me to have an instant messaging system like Facebook does on a Drupal site that I am working on. I have never setup a chat system before.

My particular requirements are rather stringent. It needs to be a solution where we host the chatting server (if one is needed separate from the website itself). It must use the site's login state (can't use an external system at all, that means no GTalk, Yahoo IM, or AIM). It also must be able to handle up to 1,000 users at any given time.

I have looked through the Drupal community and I tried the DXMPP module, but it requires Jquery UI 1.8 and that doesn't work with all of the other things that my site uses (such as Homebox). We do have a Jabber server already setup and ready to go.

Does anyone have any thoughts or options here? Thanks!

# Answer
> 2 votes
Other modules that provides chat room are

* DrupalChat does not require an additional server component/server. This ease installation but can become a performance issue as PHP/Apahce are not a good fit to efficiently server chat-like application. If scalability is an issue, it supports a more robust solution based on Ape's Ajax Push Engine. The module description implies that the module allow other backend to be written.
* Drupal Strophe provides XMPP chat integration in Drupal. It only supports the ejabberd server.
* Chat Room doesnt require an additional server component/server. The author is working on a Node.JS integration module aimed to be used by the D7 version of Chat Room to solve the scalability issue.

# Answer
> 2 votes
Also, there is an Instant Messenger module for D6 - http://drupal.org/project/im (although only dev version available).

Generally, the idea of basing it on node.js sounds to be the best choice. I have done something similar in the past (though it was for a Zend Framework site, not Drupal one) - done a chat very similar to Facebook's one (combined with system/new events notifications) based on node.js (http://nodejs.org/) and Socket.IO (http://socket.io/).

Have a look at following examples:

---
Tags: ajax, javascript
---


# Question
Title: Automatically turning a profile to unpublished if membership is unpaid and v.v
I am creating a website for a society, where members pay an annual fee. When members pay for the first time (through ubercart and 2checkout), they automatically receive a user role that enables them to create a member profile. I have set the membership to end a year after they have paid. I have also set up an e-mail reminder to be sent to the member, a week before, reminding them to renew their membership.

I've been playing with rules and relationships in views, unsuccessfully, to answer the following two questions, so I hope someone here has advice.

* How do I automatically render the member profile invisible to other members once the payment due date has passed?
* Is it possible to automatically render the same invisible profile visible should they renew their membership by paying and if so, how?

# Answer
> 1 votes
> How do I automatically render the member profile invisible to other members once the payment due date has passed?

By blocking the user you can stop access on expired user.

> Is it possible to automatically render the same invisible profile visible should they renew their membership by paying and if so, how?

For making it automatic so that a user can activate its account himself, you have to write a custom interface for that. (e.g. A block user tries to login, redirect to a page for user to enter his email address, then process his/her payment against his identity and unblock user)

```
$user = user_load('mail'=>$email);
user_save($user, array('status' => 1));

```

# Answer
> 1 votes
I suggest you take a look at the Ubercart Recurring Payments and Subscriptions module; it sounds like you are homebrewing what they've already got working and a community of users battle-testing the logic: http://drupal.org/project/uc\_recurring

---
Tags: users, rules
---


# Question
Title: Does get_defined_vars() show variables defined in variable_set()?
I'm using Drupal 6, and I'm having problems retrieving a set of variables I set with `variable_set()` using `variable_get()`. I'm doing a `dpr(get_defined_vars())` to see what's defined, and I don't see my variables; I see only the arrays `$form` and `$form_state` (this is inside `hook_submit()`).

Does `get_defined_vars()` show all the variables defined via `variable_get()`/`variable_set()`? I would just like to see a list of all of them. I just need to see if they've been set correctly, and troubleshoot why I can't retrieve them.

# Answer
get\_defined\_vars is a PHP function, not a Drupal function. It basically shows you all variables that are in scope.

Drupal variables set by variable\_set are not automatically within scope.

Variables are stored in `global $conf;` but I don't recall if non-variables are also stored here.

If you install the Devel Module there is a page for viewing and editing variables.

EDIT:

Curiosity got to me. The variable editor in the Devel Module queries the `{variable}` table and not `global $conf;` to build the form of all available variables, so that suggests that is the proper way to do it.
> 6 votes

# Answer
What you set with `variable_set()` are called "Drupal variables," or "persistent variables." They are not PHP variables, and `get_defined_vars()` doesn't return them.

During bootstrap, the content of the "variables" table is copied into the global variable `$conf` that contains also values set in settings.php, such as the string overrides.

```
$conf['locale_custom_strings_en'] = array(
  'forum'      => 'Discussion board',
  '@count min' => '@count minutes',
);

```

If you want to verify which Drupal variables are set, then you can use the global variable `$conf`, but I would suggest to do it only for debugging purposes, and not in code that you publicly distribute or use outside a test site.
> 1 votes

---
Tags: 6, configuration
---


title: Form Submission Problem

text:
# Question
Title: Form Submission Problem
I've a form...

```
function modulename_myform($form, &$form_state)
{
        $form['my_ta'] = array(
            '#type' => 'textarea',
            '#resizable' => FALSE,
        );
        $form['my_submit'] = array(
            '#type' => 'submit',
            '#input' => TRUE,
            '#value' => 'Submit',
            '#name' => 'sub_1',
            '#button_type' => 'submit',
        );
        return $form;
}

```

My form couldn't submit any data... So I tried doing two variants...

```
/* Form Submit */
function modulename_myform_submit($form, &$form_state)
{
    drupal_set_message('Submitted Value @name',array('@name'=>$form_state['values']['my_ta']));
}

```

Output : Doesn't print anything and says value is null at that location...

```
/* Form Submit */
function modulename_myform_submit($form, &$form_state)
{
    drupal_set_message(t('Submitting values: @values', array('@values' => var_export($form_state['values']['my_ta'], TRUE))));
}

```

Output : Prints the Dump with proper values...

Why is that? It should be giving me the text entered in my\_ta right? Please help me...

# Answer
the first attempt doesn't contain `t()` function in set message function... hence it's failing...
> 2 votes

# Answer
The 1st would not work as it is neither default and nor explicitly defined against `#submit`. For first to work:

```
$form['#submit'] = array('modulename_myform_submit')

```

The 2nd should work.

If still it is not getting submitted then make sure the form is properly rendered and processes by `drupal_get_form()`
> -1 votes

---
Tags: forms
---


title: Views Row Style - Fields vs. Teaser?

text:
# Question
Title: Views Row Style - Fields vs. Teaser?
What is better for performance in views, using fields or a teaser view? Assuming you would be adding all fields necessary for it to look just like the teaser.

# Answer
The fields option is generally faster, because it performs only 1 database query (2 if there's a pager in use). The teaser display requires a node\_load(), which causes numerous hooks to fire and many more queries.
> 0 votes

---
Tags: views, 6
---


# Question
Title: Views and Panels Newbie... Maybe simple...Hope its simple
I have a simple view that does not page. It contains about 50 records (three fields each). When I import the view into column one of the panel page, it displays the entire contents. I wish to equally divide the content into the two columns.

I have done this before in PHP. I have the code to do this in PHP. But this is D, so,...

I tried to mock up the effect, to get a look at the output, by placing the same view in the second column. But Panels apparently did not do another query. The second column was blank.

Any ideas why the view would not copy into the second column, or how I might achieve my goal to divide the query into two columns using Views and Panels the Drupal way?

# Answer
> 1 votes
I think you would not need panels for two column.

There are two ways I know:

1. Quick way: You can choose a styling format as grid and define columns as 2
2. Long way: A View listing can be shown in two columns by styling and template overriding.

---
Tags: views, panels
---


title: Sorting content list alphabetically

text:
# Question
Title: Sorting content list alphabetically
Is there any way to sort Drupal's content list in the admin area alphabetically by title? I am using Drupal 6.

# Answer
A simple solution is to override the default content list or to create an alternative one using Views and VBO.

With views it's easy to create sortable tables. I believe a view of the content listing is already predefined in either VBO or Views.
> 2 votes

---
Tags: nodes
---


# Question
Title:  ob_start(), ob_get_contents()  do not work in preprocess functions?
I tried to catch some HTML output in preprocess function with `ob_start()` and `ob_get_contents()`, but the output seems to slip through them. Is **output\_buffering** maybe disabled in Drupal?

This is the pseudo code from `mytheme_preprocess_page()`:

```
ob_start(); ?>
<div id="block">
    <span>This is block</span>
</div>
<?php $vars['my_block'] = ob_get_contents();

```

When I do this, I get the `<div>` output directly and not dumped to `$vars['my_block']`, as one would expect. My guess is that output buffering is, for some reasons, disabled. I am wondering if that is the case and why.

# Answer
> 1 votes
I think nothing is left on buffer in Drupal. After evaluating each template the rendered output is preserved as value and passed to outer level template. In this scheme Drupal might be getting buffered content and clearing it across each template.

That is why you should look for variables in that scope.

---
Tags: theming
---


# Question
Title: How to fix display problems with CKEditor?
I have installed CKEditor 3.6.0.6, I have enabled some buttons as in image:

CKEditor 3.6.0.6 in full size browser

However when I resize the browser smaller than the buttons zones, here is how is looking:

How can I brake CKEditor buttons to be displayed on multiple lines ? And why this behavior of CKEditor?

My browser Chrome 12.0.742.100. In Firefox 5 is the same problem.

# Answer
CK Editor supports to manage toolbars. In toolbars you can manage Buttons. See the guide.
> 2 votes

---
Tags: 7, wysiwyg, theming
---


title: Multiple forms on single page?

text:
# Question
Title: Multiple forms on single page?
Is it possible to put multiple forms on a single page?

I am trying to make a coupon offer page. I wanted to have two forms for two different offers on each side of a page. Each form has a text field for the coupon code and its own submit button. The first form works okay; however the second form's hidden values seem to be overridden by the first form's.

I'm using hook\_alter to alter the second form to make it different, but it still has the same form\_id as the first. Is this what's causing my problems, or do I need to look/think somewhere else?

The two forms have the same values for "form\_id" and "form\_token," but different values for "form\_build\_id."

# Answer
> 8 votes
If you want to add the same form multiple times, you need to implement hook\_forms(). See node\_forms() for an example.

This allows to use different form\_id's, which all point to the same form builder function. For example, you can use `yourmodule_some_form_$i` and then use hook\_forms() to point these to `yourmodule_some_form`.

See http://www.mohitsharma.net/content/how-show-same-form-multiple-time-page for an example

# Answer
> -1 votes
You can have more than one form in the same page; see what done by node\_admin\_content(), which uses the following code:

```
function node_admin_content($form_state) {
  if (isset($form_state['values']['operation']) && $form_state['values']['operation'] == 'delete') {
    return node_multiple_delete_confirm($form_state, array_filter($form_state['values']['nodes']));
  }
  $form = node_filter_form();

  $form['#theme'] = 'node_filter_form';
  $form['admin']  = node_admin_nodes();

  return $form;
}

```

Leaving out the first IF-statement, the function is adding two different forms that have their own submission handlers.

The problem is with the form fields that are repeated twice. The following array structure would create problems when the form array is flattened, as there would be two "coupon" fields.

```
$form['first form']['coupon'] = array(
  '#type' => 'textfield',
  '#title' => t('Coupon'),
  '#default_value' => variable_get('mymodule_coupon'),
  '#size' => 60,
  '#maxlength' => 128,
  '#required' => TRUE,
);

$form['second form']['coupon'] = array(
  '#type' => 'textfield',
  '#title' => t('Coupon'),
  '#default_value' => variable_get('mymodule_coupon'),
  '#size' => 60,
  '#maxlength' => 128,
  '#required' => TRUE,
);

```

Without to see the code being used, I could think that using a page callback that calls drupal\_get\_form() is probably the easier way, in your case.

```
$output = drupal_get_form("form identifier") . drupal_get_form("form identifier");

```

I tried using the following code in Drupal 6.

```
module_load_include('inc', 'path', 'path.admin');
$output = drupal_get_form('path_admin_form') . drupal_get_form('path_admin_form');

```

The content of `$output` for the two form was the following one (I removed the output for the single form fields).

```
<form action="/dr61/devel/php"  accept-charset="UTF-8" method="post" id="path-admin-form-1">
<div><div class="form-item" id="edit-language-1-wrapper">

<input type="submit" name="op" id="edit-submit" value="Create new alias"  class="form-submit" />
<input type="hidden" name="form_build_id" id="form-4eb9304baac34f292901ca23d925ff03" value="form-4eb9304baac34f292901ca23d925ff03"  />
<input type="hidden" name="form_token" id="edit-path-admin-form-form-token" value="cd429a06b84e381eb82ef04cd5033eeb"  />
<input type="hidden" name="form_id" id="edit-path-admin-form" value="path_admin_form"  />

```

```
<form action="/dr61/devel/php"  accept-charset="UTF-8" method="post" id="path-admin-form-1">
<div><div class="form-item" id="edit-language-1-wrapper">

<input type="submit" name="op" id="edit-submit-1" value="Create new alias"  class="form-submit" />
<input type="hidden" name="form_build_id" id="form-fb363c7ca6d88f71d98e86f8a69b0379" value="form-fb363c7ca6d88f71d98e86f8a69b0379"  />
<input type="hidden" name="form_token" id="edit-path-admin-form-form-token-1" value="cd429a06b84e381eb82ef04cd5033eeb"  />
<input type="hidden" name="form_id" id="edit-path-admin-form-1" value="path_admin_form"  />

```

There is not a conflict between the HTML ID assigned to the same form field, and the value for "form\_build\_id" (or "form\_token") is different in the two forms.

The implementation of `hook_form_alter()` used to alter the form should be able to understand in which case to alter the form, or both the forms would show the same fields.

From the point of view of the user experience, I am not sure that showing two different forms with their own submission buttons is the best way to do what you are trying to achieve.
I would think that using a form that shows different fields basing on the values set for other fields would be better. For example, the form could have a selector for the type of the coupon, and would shown different form fields basing on the coupon type selected.

---
Tags: 6, forms
---


# Question
Title: Suggestion tpl help for NiceMenu markup?
I'm using NiceMenus to display my taxonomy tree. Since I chose no parent menu, the module displays the root items as separate hoverable menu "tiles", which is OK. They are however `<li>` items enclosed in one `<ul>`. Due to styling/layout issues, what I want is that each of the tiles have individual parent `<ul>`.

So instead of having:

```
<ul>
 <li>root item 1</li>
 <li>root item 2</li>
 <li>root item 3</li>
</ul>

```

I want:

```
<ul>
 <li>root item 1</li>
</ul>
<ul>
 <li>root item 2</li>
</ul>
<ul>
 <li>root item 3</li>
</ul>

```

and then I'll be able to easily absolutely position each `<ul>`.

So the question is presumably a piece of cake for you guys: how to change the markup - probably using a suggestion technique... Should I override the block? How should I name the tpl file so to force my markup?

Thanks, Artur

# Answer
> 0 votes
Why can't you just position your li's absolutely? Generally, you should be able to position li's the same way as separate ul's using CSS.

Anyway though, to answer your question, have a look here: Customize Drupal 6 Nice\_Menus Output

(Ok, you're asking for D7, but the general idea should be the same/very similar.)

---
Tags: 7, routes, blocks, theming
---


# Question
Title: Views: Access CCK image delta for each image link
I have a view that for each row, outputs the first 3 images of a CCK image field.

I would like to be able to Output a different link for each image in the format `node/[nid]?image=[delta]`

I don't mind writing a token for this purpose, although I'm not sure how I'd access the delta number in the first place, other that some convoluted loop that just increments and resets a static variable, and even then, would that even work or is there some sort of token caching that would break even that approach?

# Answer
Depending on the views version you use, you have different options to render a multiple values field and the fields themselves.

The easiest thing in this case would be to create a special field formatter for the images. Field formatters are almost exactly same for both Drupal 6 and 7 and is what you could call a theme function for fields. In that theme function you would be able to handle the different deltas, as you will have that variable accessible.

* This post explains a bit about field formatters.
* This post explains how to create a field formatter (D6).
> 2 votes

---
Tags: views, media
---


title: Ctools include ajax

text:
# Question
Title: Ctools include ajax
What is the best way of include ctools\_include('ajax'); into a page already defined by another module?

I'm trying to use ctools ajax framework to replace content (similar to how the ctools example hello world works).

I've tried to integrate the ctools hello world example into my existing code but it looks like none of the setup is run. When clicking on the the link it forwards to the menu link defined rather than changing the content.

EDIT:

I've used ctools\_include('ajax') on the following hooks (all hooks confirmed correct by added debug to them):

* nodeapi (alter)
* preprocess node

This is my `hook_nodeapi('alter')` code, which inserts the text as per the example module.

```
ctools_include('ajax');

$links =array();
$links[] = ctools_ajax_text_button(t('Hello world!'), "defs/nojs/test", t('Replace text with "hello world"'));
$node->body .= theme('item_list', $links, t('Actions'));
$node->body .= theme('ctools_ajax_sample_container', '<h1>' . t('Sample Content') . '</h1>');

```

This is my menu item.

```
 $items['defs/%ctools_js/test'] = array(
    'page callback' => 'br_defintions_funkyajax',
    'access arguments' => array('access content'),
    'page arguments' => array(1),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );

```

This is my callback function from the menu item.

```
function br_defintions_funkyajax($js = NULL) {
  $output = '<h1>' . t('Hello World') . '</h1>';
  if ($js) {
    ctools_include('ajax');
    $commands = array();
    $commands[] = ctools_ajax_command_html('#ctools-sample', $output);
    ctools_ajax_render($commands); // this function exits.
  }
  else {
    return $output;
  }
}

```

# Answer
> 1 votes
Can't you just do

```
  ctools_include('ajax');

```

At the start of your existing code.

Ctools should put classes in your code which are fairly easy to spot.

*Edit*

Thanks for the code. I'm not sure what it is it could be one of a couple of things, but may be neither.

you are using $op 'alter' in hook\_nodeapi, this is quite a late stage hook, and it is possible that add\_js doesn't work then. 'view' may be a better $op for you to use.

Also you are using theme 'ctools\_ajax\_sample\_container' this is part of the ctools\_sample module. Do you have that module installed.

It is also possible that you have a js error somewhere else which is knocking out the ctools js functionality. Check any errors you have with firebug.

---
Tags: 6, javascript, ajax, chaos-tool-suite
---


title: Multiple Teasers

text:
# Question
Title: Multiple Teasers
My goal is to have three views of a teaser.

Why different teasers? I have a blog and I'm displaying teasers of the blog entries in different ways because my pages have different layouts for the content.

Here's what my node-blog.tpl.php file looks like

```
<?php if(isset($node->teaser) && $node->teaser != ''): ?>
    <?php if ($is_front): ?>
        my code for the teaser on homepage
    <?php elseif ?>

        This is where I need help, I'm trying to have two different teaser views on the same page.

    <?php else: ?>
        all other teasers for blog will have this code
    <?php endif; ?>
<?php else: ?>
    this is the code for the actually blog page.
<?php endif; ?>

```

If this code didn't help, I'm trying to have it setup like this: Front page = Teaser 1 Blog page (featured) = Teaser 2 Blog page (lower section) = Teaser 3

I would normally create a new view but I'd like to have the code "unformatted" with my custom teaser code.

# Answer
The Display Suite Module will allow you to create more custom build modes/view modes. So you can have teaser, teaser-foo, teaser-bar...
> 3 votes

# Answer
View can be used to define multiple layouts of a single type of content with different displays.

In different teasers you might be using different different content information (fields), different length of text, different styles and orientations.

Add three or more displays (for each teaser), Manage your fields for each. Make sure to override settings which are different among displays. User theme information to select a suitable and most relevant to your display.

You can easily manage different displays (of block type) in regions.
> 0 votes

---
Tags: views, nodes
---


title: Node alias with taxonomy term

text:
# Question
Title: Node alias with taxonomy term
I have the content type 'machine' that uses two vocabularies (producer, category). I would like to create node alias like \[language\]/machines/\[producer-name\]/\[title-raw\]; \[producer-name\] is from the vocabulary.

Could anybody give me any advice?

# Answer
The Token module provides very simple and limited taxonomy options. It will only provide the top most term of the top most vocabulary by weight.

The simplest solution will be to use a module like this: http://drupal.org/project/taxonomy\_token

It will allow you to configure custom tokens for exactly the term/vocab you need.
> 2 votes

# Answer
Is `[termpath-raw]` what you're after?

The token is described as:

> As \[term-raw\], but including its supercategories separated by /. **Warning**: Token value contains raw user input.
> 1 votes

---
Tags: 6, taxonomy-terms, path-aliases
---


title: losing CCK custom field when saving

text:
# Question
Title: losing CCK custom field when saving
I have installed varnish load balancer on my pressflow 6.22 website.
i have some custom fields created by CCK.
the original server is X and i have added another server Y to make this load balancer.
now, when the editors try to create any node when they were directed to server Y, they lost all custom fields when they save. however, when they are directed to original server (X), everything goes fine with them!!
anyone faced such case? any idea about the reason or how can i fix it?
**\** EDIT \****
i have checked in the DB and found that the image path has been saved normally, but when i make node\_load, it didn't show this field. also when view or edit this node, the image is not shown as well!!
any idea is highly appreciated
Thanks for your help

# Answer
> 1 votes
Thanks 32i for your suggestion, i have managed my problem already. it was a result of cache. when i flush all caches i get the content normally.
finally i found out the memcache is the caching level behind this problem, simply i excluded authenticated users from being served by memcache and this fixed my problem

---
Tags: entities
---


# Question
Title: How to override "Who's online" block theme without any change to "Who's new" theme
In user module, "Who's online" and "Who's new" blocks both use the `user_list` theme function. How can I change the markup of *Who's online* without any effect on *Who's new*'s block markup?

# Answer
Since they both use the same theme function it gets more complicated.

The only real choice you have to alter the markup of the one block, but not the other, is to `template_preprocess_block` or templates for the blocks. The problem is that by this point the markup for the actual block content has already been created, which means that you would either have to recreate the markup, or use some pattern matching to alter the created markup. Both of which is not really desirable.

Another option would be to create the block yourself like the user module does but alter the markup that is created.
> 1 votes

---
Tags: 7, theming
---


title: Complicated views layout

text:
# Question
Title: Complicated views layout
I need to display part of the exposed form in my page's sidebar, and the rest of the form and content in the `$content` area. There's really no good way that I can find to do this. I sort of got it to show up in a way by making a "block" view with "exposed form" set and then trying to only show the part that i needed through .tpl files. The problem is that then, when the submit button is clicked (the submit button is in the `$content` area), then the filters that are in the sidebar are not taken into account.

Ideas?

# Answer
You are facing the limitations og HTML itself. All of the form fields has to be in the same form to make it work. If you split them up in two forms it will not work as the browser will see it as two different forms.

A workaround would be to render the entire form both places, hide unwanted fields with CSS and use JavaScript to sync values between the forms.
> 1 votes

---
Tags: blocks, views, theming
---


title: Can the overlay be used as a popup?

text:
# Question
Title: Can the overlay be used as a popup?
In Drupal 6 there was the Modal Frame API which made it to Drupal 7 core. However, I'm not sure how leverage the Overlay independent of being an administration screen. Is there any information about this?

# Answer
> 3 votes
Well, actually yes - overlay might be used too if needed. I have just done a quick write-up on this: http://zgadzaj.com/how-to-open-standard-content-pages-in-drupal-7s-administrative-overlay

# Answer
> 2 votes
No. However, core also contains jQuery UI Dialog, so you can use that (Views and Media both use it)

# Answer
> 2 votes
This tutorial might help: How to Add a jQuery UI Dialog to Drupal 7. The Simple Dialog module might prove useful too.

---
Tags: 7, modal-dialogs
---


# Question
Title: Styling two views using the same template file?
I have two views that are pretty similar so I want them to use the same template file. However, in views I can only select templates that have a name unique to that view meaning two views can't use the same template. How can I accomplish this?

# Answer
If your views are same or similar then manage both of views as one using multiple views displays. For each display settings and configuration can be overridden. Template can be shared among displays of a single view.

The other a little bit bad way, can be to create a single template file and then include that template to your views templates.
> 1 votes

---
Tags: views, 6
---


# Question
Title: Make multiple templates for site (new one for many pages)
So I have my page-front.tpl.php and page.tpl.php. I'm making a music website for a client and literally only need like 5 or 6 pages. How can I basically make a php page from scratch for each page? Thank you.

P.S. I think I'd rather make it all from scratch than use panels

# Answer
> 2 votes
Drupal has flexible theme system. You can create different sections of your site and theme and select dedicated template according to path. This is what I am suggesting you.

e.g. your site has different pages(paths) targeting different sections.

* example.com/music (page-music.tpl.php)
* example.com/artist (page-artist.tpl.php)
* example.com/artist/profile/% (page-artist-profile.tpl.php)
* example.com/store (page-store.tpl.php)

# Answer
> 1 votes
In Drupal you do not really make php pages "from scratch", as this is done for you by themes. What you do though (and this is what you probably would want to do too) is define views + probably blocks for all your required page areas, and then position/style them using CSS (and usually no panels required, most could be done using properly thought-over page structure and good styling).

---
Tags: 6, theming
---


title: Exclude Latest Article From View?

text:
# Question
Title: Exclude Latest Article From View?
I'm working with Views 3, and I'm trying to figure out how to best accomplish the following scenario:

On my front page, I'd like to have my articles set up as follows:

On the left, a large thumbnail is shown for the latest article. This accounts for the Title, Author, Post date, and a short summary with a comment count.

To the side, I have a block created in Views that would show the previous three articles with smaller thumbnails, author information, post date, summary, and comment counts.

What I need to know is this: How can I set up both Article views so that:

-The view on the left only shows the absolute latest article.

-The view on the right always excludes the latest article from the listing.

# Answer
> 4 votes
You have to create a view with two displays of type block. Arrange some region or panel method to display them in side by side fashion.

Create view, select its type as node, choose fields and filters according to your requirement.

**For View display having latest item:**

Click `Pager` from your view settings and define `Items per page` as 1 and set sort order Date created/posted as descending.

**For View display having next three items:**

Click `Pager` settings and define `Items per page` as 3 and set `Offset` as 1 and define the same date order as for the previous view display.

**Thumbnails settings:**

While selecting your fields particularly selecting image field (must be part of your post's content type) as thumbnail for post, choose image style. The image style are thumbnail sizes and formats. See the interface on `example.com/admin/config/media/image-styles` to add your custom image forma-tors so that a proper thumbnail can appear on each view display.

# Answer
> 3 votes
In pager options set offset to 1.

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


# Question
Title: Drop-down Menus in Standard Drupal 7.4 Zen theme?
I'm new to Drupal so forgive me if I'm missing something obvious. I'm trying to implement a drop-down menu in Drupal 7.4 in the Zen theme with only a standard install (I'm trying to avoid installing other modules). There appears to be no easy way to do this. Is the only option to manually code one of the CSS files in the subtheme directory for this effect?

Thanks!

# Answer
> 0 votes
If you don't wNt to install other modules then your only option is to create the CSS / JavaScript needed for it in your theme.

If you don't want to use a module, take a look at nice\_menus.

---
Tags: 7, theming, navigation
---


title: problem with check_markup()

text:
# Question
Title: problem with check_markup()
I have a content type called 'microblog', and a default input format for registered users is set to 'Filtered HTML', meanwhile i want to use 'Messaging plain text' format for creating a microblog content.

```
<?php
$content .= check_markup($node->title, $format = 'Messaging plain text', $check = TRUE);
?>

```

But it seems like drupal ignores $format, still when im posting microblog content it uses 'Filtered HTML' format.

PS i'm using http://drupal.org/project/microblog module. Tried to change in microblog.module on 380 line to 'Messaging plain text' - still no effect...

# Answer
You should do like this

```
$format = db_result(db_query("SELECT format FROM {filter_formats}
                              WHERE name = 'Messaging plain text';"));
$content .= check_markup($node->title, $format);

```

The problem is that you need to use the format id not the format name.
> 2 votes

---
Tags: 7
---


# Question
Title: How can I allow a user to create a user, but not view all users?
In Drupal 7, I can set the 'administer users' permission to a certain role. However I do not want this role to be able to view and filter/search all users in my Drupal site. The `admin/people/create` only, but no `admin/people` page should be accessible because they have the capability to filter the administrator role! And able to edit it in turn.

Is there a module that can do this?

# Answer
Subuser module can help to achieve this goal. A user that is allowed to create a sub users can manage them as well.
> 2 votes

---
Tags: 7, users
---


# Question
Title: Loading nodes from a specific user and a specific node type
I have written this function to do so, but it behave strangly, i am wondering if i have the correct approach

```
function getNodes($type,$userID){
        $where = array();
        $nodes = array();
        $where[':type'] = $type;
        $where[':uid'] = $userID;
        $result = db_query('SELECT nid FROM {node} WHERE uid = :uid AND type = :type', $where);
        if($result){
            foreach($result as $o){
                $nodes = node_load($o->nid);
            }
        }
    return $nodes;
}

```

Isn't there a drupal API that loads node from the DB by passing it a UID and Node type ?

# Answer
> 8 votes
In D6 you could pass criteria to node\_load(), so you could do

```
 $criteria = array(
   'uid' => $userID,
   'type' => $type,
 );

 $nodes = node_load($criteria);

```

would do the job.

In D7, you don't have this option with node\_load as it is just a wrapper for entity\_load. This has a depricated argument which allows you to load nodes in the same way

```
 $criteria = array(
   'uid' => $userID,
   'type' => $type,
 );

 $nodes = entity_load('node',FALSE,$criteria);

```

*note untested*

This may work, but is not guaranteed to.

The approved way to do this in D7 is to use EntityFieldQuery

```
  $query = new EntityFieldQuery();
  $entities = $query->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', $type)
    ->propertyCondition('uid', $userID)
    ->execute();
  $nodes = node_load_multiple(array_keys($entities['node']));

```

*note also untested*

# Answer
> 2 votes
Technically what you have above should work. There is one small error and that is on this line:

```
// You're always setting the $nodes variable to
// the last node_load instead of adding to the $node array.
$nodes = $node_load ($o->nid);

```

That being said this can be made better. Here's a better example.

```
function get_user_node_by_type($node_type, $uid){
  $nodes = array();
  $nids = db_query('SELECT nid FROM {node} WHERE uid = :uid AND type = :type', array(':uid' => $uid, ':type' => $node_type))->fetchCol();
  if (!empty($nids)) {
    $nodes = node_load_multiple($nids);
  }
  return $nodes;
}

```

Also make sure you're using the correct node type name. You have to use the machine name of the node type.

---
Tags: 7, nodes
---


# Question
Title: Should I down-grade to Drupal 6.x? There seems to be much better support!
If I'm only looking to throw some easy-to-use modules together for a client and then put the Zen theme on, should I stick to Drupal 6.x? I've noticed in my exploration of Drop-down menus in 7.x that there is very little support for it in the form of modules.

# Answer
> 1 votes
Drupal 6 is certainly an option, and it will likely retain a sizable installed-base for some time to come, until February 24, 2016, the date after which Drupal 6 will not be anymore supported and it will not receive any security fix.

That said, Drupal 7 is where the focus is now; it will continue to be in the future, until November 1, 2023, the date of the Drupal 7 end-of-life, the date after which no security issues will be fixed for Drupal 7.

In my experience, the simple/basic/popular modules are already quite well supported in Drupal 7; only the more "exotic" modules have not been ported to Drupal 7, yet.

I've moved my site to Drupal 7 with relatively few issues; Drupal-7-specific documentation, or the lack of it, can be a challenge.

With regards to drop-down menus, Superfish is a Drupal 7 module with releases for Drupal 8 and Drupal 9 too. At least, the 8.x-1.4 release is reported to be compatible with both those Drupal releases, but some issues need to still be fixed, to warranty a complete compatibility with Drupal 9 or Drupal 10.

---
Tags: 6
---


# Question
Title: Specifying a confirmation page after you signup using the Signup Module
When using the Signup module, the form just reloads itself after every successful signup. Is it possible to redirect them to a different page instead of seeing the same page all over again?

# Answer
If this is a form then use `hook_form_alter` to add a submit handler with it and then define `$form['redirect']`. For illustration see the post
> 1 votes

---
Tags: 7, users
---


# Question
Title: How to create a block view that displays content one year ago from from the post date of the current node
We have a surf report running on D6. One of the features that we'd like to add is a block on the node page of a surf report content-type that shows the surf report from one year ago.

I know how to create a filter that sets the date to one year from the current date/time, but I want to make this block display the report from one year from the *post date* of the current node (as opposed to current date/time).

Any ideas on this? I've racked my brain and can't think of any solutions.

Any help is appreciated!

# Answer
> 1 votes
Can Views Data Rnage be a useful module? There is another choice is Views Date Range Filter D6. You will have investigate both solution if they work for you.

---
Tags: views
---


title: Problems with text formats and Iframes

text:
# Question
Title: Problems with text formats and Iframes
I'm trying to display an iframe (google maps) on my node. I allowed "iframe" with the "plain text" format and unchecked "Display any HTML as plain text": http://www.diigo.com/item/image/fgah/3hc0?size=o

I select the text processing option "Filtered text (user selects text format)" for the field: http://www.diigo.com/item/image/fgah/dmeh?size=o I enter the iframe code with the "plain text" selection http://www.diigo.com/item/image/fgah/7svw?size=o The iframe renders fine.

I changed the text processing option for this field to "plain text": http://www.diigo.com/item/image/fgah/04e2?size=o

Now the iframe won't render (just shows the iframe HTML code). Why would it not work, isn't it the same "plain text" option?

# Answer
Each text format that you create has some different processing options.

If you select

> Display any HTML as plain text

Then the result is what you explained, where HTML code is escaped and displayed instead of having any effect.

Instead

> Limit allowed HTML tags

Can be used to limit the kind of html tags which are allowed, but if disallowed tags are used, they will not take effect.

It sounds like you are confusing the two.

**Update**

The text processing and input filters are not related.

You have filter called `plain text`, but you could call it anything, like `super input field`, `pony` or whatever. When you select filtered input, you get to choose which filter to use.

The other text formatting option is plain text. Selecting this means that you wont use **any** text filter, not even the one you might call `plain text`. The result of using this kind of text processor is that the text will be rendered as plain text.
> 2 votes

---
Tags: 7
---


title: mobile site question

text:
# Question
Title: mobile site question
here's my plan to build a site w a mobile site:

1) develop all my core modules with robust api's. 2) build a pair of ui modules for each above module. These ui modules are just ui's for the api's of the above module. There will be two ui modules for each above module: one for the normal site and one for the mobile site. 3) use a device detection library and if the client is a mobile device, then use the mobile ui/theme.

example:

I'll build a 'friends' module with an api that allows for adding friends, deleting friends, etc... This module has no ui. Then I'll build a normal site ui module and a mobile site ui module that will all for controlled interaction w the ui.

what do you guys think? Anyone have a better way?

# Answer
> 1 votes
Drupal already has a UI layer in the theme. There are modules which will allow you to switch the theme depending on the device (have a look at mobile\_theme), so you can have different themes for different devices. This way your modules should only send data to the theme layer which then acts appropriately for the device viewing.

However with the increasing sophistication of mobile devices it is possible to create a site which has the same markup but adapts to the device using clever css and jquery.

---
Tags: 7, theming
---


# Question
Title: Creating simple user groups with a term in Drupal 7
I need to tag my users as belonging to a 'workplace'. And then display a page with workplace details and a list of associated users.

I have setup a vocabulary in Taxonomy called 'workplace' and I can easily tag a user. I need to know how to create a block that will show on a taxonomy / term / id page and show tagged users.

I imagine I will have to make part of the user details public as well as by default they won't be?

Any help much appreciated - even a hint as to where to start ...

# Answer
> 1 votes
1. Since users are field able you can now attach a taxonomy term reference field to users.
2. Create a view that list all users where the tid of the term reference is a select value. You could also get the value from a url arg.
3. The view itself should show the user data you want to display, maybe as a list or whatever fits you better.
4. In the views header you could display the info about taxonomy term. Right now this will require some views knowledge and some custom code, as you need to create what views calls an area handler, to display the info. You could also do this in a preprocess function instead.

---
Tags: views, users
---


# Question
Title: How to hide core fields in Content types?
Drupal-6

I created a content type and added some fields. I can manage how to show them in Diplays Field. But there are some 'core fields' which I can not hide in Displays Fields.

I need to hide the 'menu system field'. Can I do this? How? It would be great to hide it just for an specific role.

I uploaded a picture to show what I mean.

# Answer
> 2 votes
There are two ways you can do this.

You can do this with permissions for some items. 'Menu settings' is controlled by 'administer menu' permission.

If some item is being put onto the page which can't be controlled by permissions then you can use a form alter hook to remove them. I tend to set #access to false rather than completely removing the item from the form.

There is a big explanation of examples of how to alter forms here

---
Tags: entities
---


title: Show more comments

text:
# Question
Title: Show more comments
I often visit the http://foo.bar drupal-based website, where occasionally pages contain more comments than the default layout shows. By default the adress of such a page is `http://foo.bar/node/2547/`. I want to set up my Chromium and my Iceweasel (of course they are the same as Chrome and Firefox in this scenario) to open `http://foo.bar/node/2547?comments_per_page=9999`. How to do that without modifying the browser sources? Notice I don't want to check how many comments there are, just show 9999 (or a similar large number). I don't want this behaviour to apply to other sites.

An additional question: what is the maximal value of `comments_per_page`?

# Answer
You can setup your Drupal site to display any number of comments you like, tough the UI does;t support all possibilities, any number is possible as it's a variable saved/gotten using `variable_get/set`

You can AFAIK not type something into the url to display all the comments on a page, just like you can't display all the users on this site. You can however tweak the url to display page 1, 2, 3 ... of the comments.
> 1 votes

---
Tags: comments
---


# Question
Title: Need advice to get an approach to do a personalized searcher?
I have a content type called "Flats" which are Flats to sell' each one of them has a 'price' field (ex. 100 000, 150 000, 200 000) and each one has a 'city' field

I need to put a searcher in the home page of the site with 2 selects input, one for 'price range' (with values like 'lower than 100 000', '100 000 to 150 000, ...) and the other for 'city' (with values like: 'Barcelona', 'Madrid', ...)

The searcher should look for flat with prices within the price range and for the chosen city.

A first sight I think I'll need to create an API Form which once submitted should go to a view passing those 2 arguments (price range and city) in the url as $\_GET values.

Is this a right approach to do this? Can I use $\_GET values as arguments in a view?

Is there any module to do this in a easier way? I don't want to reinvent the wheel...

Thanks

# Answer
> 1 votes
Why don't you try a View using exposed filters? If your content type is made with CCK then you could achieve what you're looking for quite easily. This video might help you out. Eric London's Drupal Blog also has something on exposed filters. I would thoroughly recommend this approach, I've done something very similar to what you're looking for.

---
Tags: search
---


# Question
Title: Views Ticker missing views, what are views and where can I get them
I have just installed the module called "views ticker" but I cannot activate it as apparently it requires : views(missing).

Today represents my first experiments in Drupal (I am using V7), so I'm finding some things a little less straightforward than I would expect. For this reason I'm a little lost here, I don't know what "views" are being referred to here much less do I know how to give the module the "views" it requires!

So, any pointers in the right direction would be appreciated.

Many thanks

# Answer
Modules sometimes have dependencies on other modules.

The Views module is one of the most used modules in all of Drupal that isn't a part of Drupal core.

Generally you can find your missing modules by going to `http://drupal.org/project/[name]`. This is not always true as some modules is not a single module but multiple modules. Views is one of those modules, that has a core module called Views, and an UI module called Views UI which is used to create the interface for setting up views.
> 0 votes

---
Tags: views
---


# Question
Title: Strict warning: Only variables should be passed by reference
I get the following error:

> Strict warning: Only variables should be passed by reference in include() (line 18 of /home/sites/dev/theparce/sites/all/themes/parce/block--block--3.tpl.php).

This is the block code which is causing that error.

```
if ($user_gallery) {
  print render(node_show($user_gallery));  // Line 18
  print drupal_render ($user_gallery_edit);

}
else {
  print drupal_render($user_gallery_new);
}

```

Why do I get that error, even if I get all printed as expected?

# Answer
That error happens when a function is expecting a reference as parameter, but it is not getting a reference.

In your case, `render()` is defined as `render(&$element)`, but `node_show()` is defined as `node_show($node, $message = FALSE)`, not `&node_show($node, $message = FALSE)`.
The same would be true for `drupal_render()`, since the function is defined as `drupal_render(&$elements)`.

As explained on Passing by Reference, when a function requires a reference parameter, you can pass to the function:

* Variables (for example, a temporary variable containing the result of a function which is not returning a reference)
* References returned from functions

Using other expressions, the result is undefined, and it depends from the PHP version.

* `render(node_show())` produces a fatal error in PHP 5.0.5, a strict standards notice in PHP 5.1.1, and a notice in PHP 7.0.0
* `render(5)` produces a fatal error
* `render(new DateTime())` produces a notice in PHP 7.0.7 (*Notice: Only variables should be passed by reference*)
> 53 votes

---
Tags: 7
---


# Question
Title: How do I create a system message for a user's first failed login attempt?
When using the core login block on the homepage, it appears that the failed login system message, "Sorry, unrecognized username or password. Have you forgotten your password?" is only presented to users on their second failed login attempt. The first time they fail, only the missing/incorrect username and/or password fields are highlighted. Is there any way of changing this default behaviour, so the system message is displayed on the first attempt, as well?

# Answer
> 0 votes
The error messages are always created when a user tries to login.

If the error message doesn't show, you must have a custom module, that removes the messages some how. Maybe via redirection or something similar.

---
Tags: 7, users
---


title: Creating a Dropdown menu in Drupal 7

text:
# Question
Title: Creating a Dropdown menu in Drupal 7
My question is how do we get the menu in drop down structure. i.e

```
<ul><li><a></a><ul><li><a></a></li></ul></li></ul>

```

I used following:

```
<?php print theme('links', array('links' => $main_menu)); ?>

```

but this only produces top level menu even if we have sub menus in menu management.

# Answer
horizontal or vertical nested menus: Nice Menus or Superfish

simple vertical nested menus: Menu Block
> 4 votes

---
Tags: routes, navigation
---


# Question
Title: Join User Profile fields with custom View type
In Drupal 6, I've created a custom View type that allows me to query data in my custom table. One of my fields, uid, relates to drupal users. In the Views I create for my custom type, I can display user info for each record by using a simple join in hook\_views\_data():

```
$data['users']['table']['join']['awesome_user_submissions'] = array(
  'left_field' => 'uid',
  'field' => 'uid',
);

```

Now, I'd also like to display Profile fields in my view (eg: profile\_first\_name). Unfortunately, it doesn't appear that this will be a simple table join. How can I do this?

---

Solution: (thanks @googletorp)

Don't use the join I originally used (above). Instead replace it with the following in hook\_views\_data(), then I can use fields from the 'users' table, as well as from the 'profile\_' tables.

```
$data['awesome_user_submissions']['uid'] = array(
    'title' => t('User'),
    'help' => t('Relate an awesome submission to the user who entered it.'),
    'relationship' => array(
      'handler' => 'views_handler_relationship',
      'base' => 'users',
      'base field' => 'uid',
      'label' => t('user'),
    ),
  );

```

# Answer
> 0 votes
Views itself makes a join to the uid, so if you add the Users uid as a relationship, you should be able to get the profile fields as well.

Alternatively you could join the profile field table yourself.

For reference this is how Views makes the profile -\> user join:

```
$data['profile_values']['table']['group']  = t('Profile');

$data['profile_values']['table']['join'] = array(
  // The node table
  'node' => array(
    'left_table' => 'profile_values',
    'left_field' => 'uid',
    'field' => 'uid',
  ),
  // The users table
  'users' => array(
    'left_table' => 'profile_values',
    'left_field' => 'uid',
    'field' => 'uid',
  ),
);

```

---
Tags: views, users
---


# Question
Title: Get data form into hook_node_insert / hook_node_update
How to recover data from my form 'node' from the hook 'node\_insert' or 'node\_update'. Because I created a textfield and I can't see from the "$node" variable

# Answer
> 4 votes
The `$node` object will be populated with the data from the form, the way for form is defined.

You can do something like this

```
hook_form($node, &$form_state) {
  $form = array();

  $form['my_value'] = array(
    '#type' => 'textfield',
    'title' => t('Some title'),
    '#default_value' => isset($node->my_value) ? $node->my_value : '',
  );

  ....

  return $form;
}

```

Then get the value on the node object.

```
hook_insert($node) {
  $my_value = $node->my_value;
}

```

# Answer
> 1 votes
Values contained in the `$form_state['values']` array are copied in the `$node` from entity\_form\_submit\_build\_entity($entity\_type, $entity, $form, &$form\_state), which is called by node\_form\_submit\_build\_node(), the function called by the submission handler for the node edit form (node\_form\_submit()).

The function is called as `entity_form_submit_build_entity('node', $node, $form, $form_state)`, and contains the following code:

```
  // Copy top-level form values that are not for fields to entity properties,
  // without changing existing entity properties that are not being edited by
  // this form. Copying field values must be done using field_attach_submit().
  $values_excluding_fields = $info['fieldable'] ? array_diff_key($form_state['values'], field_info_instances($entity_type, $bundle)) : $form_state['values'];
  foreach ($values_excluding_fields as $key => $value) {
    $entity->$key = $value;
  }

```

---
Tags: 7, nodes
---


# Question
Title: Slightly different menus for different domains
I'm using Domain Access module (http://drupal.org/project/domain) for running few very similar sites out of single Drupal 6 installation/database.

What I need is to have slightly different menus between those sites.

Generally, most items will be exactly the same throughtout all domains, on some of them though I don't want specific items to be displayed (for example, maybe later there would be other requirements too).

Haven't found any module offering such functionality, so considering other options now.

Simplest and easiest solution would be to hide them using CSS, but definitely this is not a *good* solution.

hook\_menu\_alter was disqualified as well, for quite obvious reasons.

What I'm thinking about right now is doing it from theme\_menu\_item() / theme\_menu\_item\_link() level. Haven't looked yet into possibility of basing it on (something like) node access permissions (which actually would mean writing own module for this), going to do it as well, but meantime perhaps someone could suggest even different approach?

# Answer
Right. So I have written my own module to do what I wanted, using hook\_form\_menu\_edit\_item\_alter() for configuration, and hook\_translated\_menu\_link\_alter() for displaying.

If anyone is interested in checking it out, initial dev version of the module is available in my sandbox here - http://drupal.org/sandbox/maciej.zgadzaj/1209152 \- before I promote it to full project...

**Edit:**

Now promoted to full version available here: http://drupal.org/project/domain\_menu\_access
> 2 votes

---
Tags: 6, routes
---


# Question
Title: Remove "Language Undefined" from content with Multilingual module
Using Multilingual - Internationalization module, now all my pages show:

> Language
> Undefined

At the bottem. How do I remove this text? I'm using the language switcher, and I have already disabled "Hide content translation links" in the module, but I guess that isn't it.

# Answer
You can remove it from : admin - structure - content types - Article / Basic page "Manage Display" - set the language field from "visibe" to "hidden" - Save

Done!
> 5 votes

---
Tags: i18n-l10n
---


# Question
Title: Why is drush behaving strangely on this site-install run of open atrium?
I'm trying to set up openatrium to run on continuous integration with Jenkins, and part of this involves building it from scratch using a drush command.

I'm having some trouble here though:

Here's the command I'm running, in debug and verbose mode:

```
drush site-install openatrium --db-url=mysql://web_dir_1:web_dir@localhost/web_dir_1 -v -d

```

Here's the output from the command. I'm setting this to run as verbosely as possible, to make it easier to see what's going on:

```
Bootstrap to phase 0. [0.02 sec, 3.29 MB]                            [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.02 sec, 3.55 MB] [bootstrap]
Bootstrap to phase 1. [0.05 sec, 8.3 MB]                                                                                [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.06 sec, 8.31 MB]                                                                                [bootstrap]
Initialized Drupal 6.20 root directory at /Users/chrisadams/employer-code/perky.dev/web_dir [0.07 sec, 9.36 MB]                                                                                [notice]
Found command: site-install (commandfile=core) [0.07 sec, 9.36 MB]                                                                                [bootstrap]
Initializing drush commandfile: drush_make [0.07 sec, 9.36 MB]                                                                                [bootstrap]
Initializing drush commandfile: drush_make_d_o [0.07 sec, 9.37 MB]                                                                                [bootstrap]
Initializing drush commandfile: user [0.07 sec, 9.37 MB]                                                                                [bootstrap]
You are about to create a sites/default/files directory and create a sites/default/settings.php file and DROP your 'web_dir_1' database and then CREATE a new one. Do you want to continue? (y/n): y
Sites directory sites/default already exists - proceeding. [1.16 sec, 9.38 MB]                                                                                [notice]
Calling copy(sites/default/default.settings.php, sites/default/settings.php)
Calling mkdir(sites/default/files)
Drush bootstrap phase : _drush_bootstrap_drupal_site() [1.17 sec, 9.4 MB]                                                                                [bootstrap]
Initialized Drupal site default at sites/default [1.17 sec, 9.41 MB]                                                                                [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [1.18 sec, 9.41 MB]                                                                                [bootstrap]

Calling system(mysql --database=information_schema --host=localhost --user=root --password=  < /private/var/folders/eO/eO9NhXKBFrSOhZaCBGs2EE+++TI/-Tmp-/phplVq9zQ);

```

The stuff above sets up the empty databases, and as far as I can tell the following commands fake a web browser, stuffing the local and install profile to use, into the $\_GET array:

```
Executing: php -r 'error_reporting(E_ERROR);$_GET=array("profile"=>"openatrium", "locale"=>"en", "id"=>"1"); $_REQUEST=&$_GET;define("DRUSH_SITE_INSTALL6", TRUE);$_SERVER["SERVER_SOFTWARE"] = NULL;$_SERVER["SCRIPT_NAME"] = "/install.php";$_SERVER["HTTP_HOST"] = "default";$_SERVER["REMOTE_ADDR"] = "127.0.0.1";function _cli_cookie_print(){print(serialize(array(session_name()=>session_id())));}
register_shutdown_function("_cli_cookie_print"); include("/Users/chrisadams/employer-code/perky.dev/web_dir/install.php");'
  a:1:{s:36:"SESSc21f969b5f03d33d43e04f8f136e7682";s:26:"5cbv02bvq4npfbo6vds3tq3he1";}

```

This pages looks like the pages being generated for thw web ui, as if you were setting up using web browser:

```
Executing: php -r '$_GET=array("profile"=>"openatrium", "locale"=>"en", "id"=>"1"); $_REQUEST=&$_GET;define("DRUSH_SITE_INSTALL6", TRUE);$_SERVER["SERVER_SOFTWARE"] = NULL;$_SERVER["SCRIPT_NAME"] = "/install.php";$_SERVER["HTTP_HOST"] = "default";$_SERVER["REMOTE_ADDR"] = "127.0.0.1";$_COOKIE=unserialize("a:1:{s:36:\"SESSc21f969b5f03d33d43e04f8f136e7682\";s:26:\"5cbv02bvq4npfbo6vds3tq3he1\";}"); $_GET["op"]="start"; include("/Users/chrisadams/employer-code/perky.dev/web_dir/install.php");'
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Refresh" content="0; URL=http://default/install.php?locale=en&profile=openatrium&id=1&op=do_nojs">
  <link rel="shortcut icon" href="/misc/favicon.ico" type="image/x-icon" />
      <title>Installing Open Atrium | Drupal</title>
      <link type="text/css" rel="stylesheet" media="all" href="/modules/system/defaults.css?0" />
  <link type="text/css" rel="stylesheet" media="all" href="/modules/system/system.css?0" />
  <link type="text/css" rel="stylesheet" media="all" href="/modules/system/system-menus.css?0" />
  <link type="text/css" rel="stylesheet" media="all" href="/modules/system/maintenance.css?0" />
  <link type="text/css" rel="stylesheet" media="all" href="/themes/garland/style.css?0" />
  <link type="text/css" rel="stylesheet" media="all" href="/themes/garland/minnelli/minnelli.css?0" />
  <link type="text/css" rel="stylesheet" media="print" href="/themes/garland/print.css?0" />
          <!--[if lt IE 7]>
        <link type="text/css" rel="stylesheet" media="all" href="/themes/garland/fix-ie.css" />    <![endif]-->
    </head>
    <body class="sidebar-left">

  <!-- Layout -->
    <div id="header-region" class="clear-block"></div>

      <div id="wrapper">
      <div id="container" class="clear-block">

        <div id="header">
          <div id="logo-floater">
          <h1><a href="/" title="Drupal"><img src="/themes/garland/minnelli/logo.png" alt="Drupal" id="logo" /><span>Drupal</span></a></h1>        </div>

        </div> <!-- /header -->

                <div id="sidebar-left" class="sidebar">
                      <ol class="task-list"><li class="done">Choose profile</li><li class="done">Choose language</li><li class="done">Verify requirements</li><li class="done">Set up database</li><li class="active">Install profile</li><li class="">Configure site</li><li class="">Install Open Atrium modules</li><li class="">Configure Open Atrium</li><li class="">Finished</li></ol>        </div>

        <div id="center"><div id="squeeze"><div class="right-corner"><div class="left-corner">
            <h2>Installing Open Atrium</h2>                              <div class="clear-block">
              <div id="progress" class="progress"><div class="bar"><div class="filled" style="width: 0%"></div></div><div class="percentage">0%</div><div class="message">Initializing.<br/> </div></div>          </div>
            <div id="footer"></div>
        </div></div></div></div> <!-- /.left-corner, /.right-corner, /#squeeze, /#center -->

      </div> <!-- /container -->
    </div>
  <!-- /layout -->

    </body>
  </html>

```

Again, more loading for a web browser to see:

```
Executing: php -r '$_GET=array("profile"=>"openatrium", "locale"=>"en", "id"=>"1"); $_REQUEST=&$_GET;define("DRUSH_SITE_INSTALL6", TRUE);$_SERVER["SERVER_SOFTWARE"] = NULL;$_SERVER["SCRIPT_NAME"] = "/install.php";$_SERVER["HTTP_HOST"] = "default";$_SERVER["REMOTE_ADDR"] = "127.0.0.1";$_COOKIE=unserialize("a:1:{s:36:\"SESSc21f969b5f03d33d43e04f8f136e7682\";s:26:\"5cbv02bvq4npfbo6vds3tq3he1\";}"); $_GET["op"]="do_nojs"; include("/Users/chrisadams/employer-code/perky.dev/web_dir/install.php");'
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link rel="shortcut icon" href="/misc/favicon.ico" type="image/x-icon" />
  <meta http-equiv="Refresh" content="0; URL=http://default/install.php?locale=en&profile=openatrium&id=1&op=do_nojs">
  <link rel="shortcut icon" href="/misc/favicon.ico" type="image/x-icon" />
      <title>Installing Open Atrium | Drupal</title>
      <link type="text/css" rel="stylesheet" media="all" href="/modules/system/defaults.css?0" />
  <link type="text/css" rel="stylesheet" media="all" href="/modules/system/system.css?0" />
  <link type="text/css" rel="stylesheet" media="all" href="/modules/system/system-menus.css?0" />
  <link type="text/css" rel="stylesheet" media="all" href="/modules/system/maintenance.css?0" />
  <link type="text/css" rel="stylesheet" media="all" href="/themes/garland/style.css?0" />
  <link type="text/css" rel="stylesheet" media="all" href="/themes/garland/minnelli/minnelli.css?0" />
  <link type="text/css" rel="stylesheet" media="print" href="/themes/garland/print.css?0" />
          <!--[if lt IE 7]>
        <link type="text/css" rel="stylesheet" media="all" href="/themes/garland/fix-ie.css" />    <![endif]-->
    </head>
    <body class="sidebar-left">

  <!-- Layout -->
    <div id="header-region" class="clear-block"></div>

      <div id="wrapper">
      <div id="container" class="clear-block">

        <div id="header">
          <div id="logo-floater">
          <h1><a href="/" title="Drupal"><img src="/themes/garland/minnelli/logo.png" alt="Drupal" id="logo" /><span>Drupal</span></a></h1>        </div>

        </div> <!-- /header -->

                <div id="sidebar-left" class="sidebar">
                      <ol class="task-list"><li class="done">Choose profile</li><li class="done">Choose language</li><li class="done">Verify requirements</li><li class="done">Set up database</li><li class="active">Install profile</li><li class="">Configure site</li><li class="">Install Open Atrium modules</li><li class="">Configure Open Atrium</li><li class="">Finished</li></ol>        </div>

        <div id="center"><div id="squeeze"><div class="right-corner"><div class="left-corner">
            <h2>Installing Open Atrium</h2>                              <div class="clear-block">
              <div id="progress" class="progress"><div class="bar"><div class="filled" style="width: 28%"></div></div><div class="percentage">28%</div><div class="message">Remaining 33 of 46.<br/>Installed <em>Search</em> module.</div></div>          </div>
            <div id="footer"></div>
        </div></div></div></div> <!-- /.left-corner, /.right-corner, /#squeeze, /#center -->

      </div> <!-- /container -->
    </div>
  <!-- /layout -->

    </body>
  </html>

```

And now, it looks like it's finished (check for the `GET['op']="finished"`):

```
Executing: php -r '$_GET=array("profile"=>"openatrium", "locale"=>"en", "id"=>"1"); $_REQUEST=&$_GET;define("DRUSH_SITE_INSTALL6", TRUE);$_SERVER["SERVER_SOFTWARE"] = NULL;$_SERVER["SCRIPT_NAME"] = "/install.php";$_SERVER["HTTP_HOST"] = "default";$_SERVER["REMOTE_ADDR"] = "127.0.0.1";$_COOKIE=unserialize("a:1:{s:36:\"SESSc21f969b5f03d33d43e04f8f136e7682\";s:26:\"5cbv02bvq4npfbo6vds3tq3he1\";}"); $_GET["op"]="finished"; include("/Users/chrisadams/employer-code/perky.dev/web_dir/install.php");'

```

This final step is setting admin settings so get into the site with:

```
Executing: php -r '$_GET=array("profile"=>"openatrium", "locale"=>"en", "id"=>"1"); $_REQUEST=&$_GET;define("DRUSH_SITE_INSTALL6", TRUE);$_SERVER["SERVER_SOFTWARE"] = NULL;$_SERVER["SCRIPT_NAME"] = "/install.php";$_SERVER["HTTP_HOST"] = "default";$_SERVER["REMOTE_ADDR"] = "127.0.0.1";$_COOKIE=unserialize("a:1:{s:36:\"SESSc21f969b5f03d33d43e04f8f136e7682\";s:26:\"5cbv02bvq4npfbo6vds3tq3he1\";}");
  $_POST = array (
    "site_name" => "Site-Install",
    "site_mail" => "admin@example.com",
    "account" => array (
      "name" => "admin",
      "mail" => "admin@example.com",
      "pass" => array (
        "pass1" => "admin",
        "pass2" => "admin"
      )
    ),
    "date_default_timezone"=>"0",
    "clean_url"=>1,
    "form_id"=>"install_configure_form",
    "update_status_module" => array("1"=>"1")
  );

  include("/Users/chrisadams/employer-code/perky.dev/web_dir/install.php");'
Command dispatch complete [13.75 sec, 9.43 MB]                                                                                [notice]
 Timer  Cum (sec)  Count  Avg (msec)
 page   12.578     1      12578.01

Peak memory usage was 9.56 MB [13.76 sec, 9.43 MB]

```

### All looks good, right?

This is the screen I see at the end - the same old garland theme at we get by default (I don't yet have enough points to post images on this site)

https://community.openatrium.com/sites/community.openatrium.com/files/obvious\_not\_open\_atrium.png

The install profile has worked, but for Garland, not OA, and none of the modules you would see in OA are there

Here's the output of `drush st`:

```
Drupal version         :  6.20
 Site URI               :  http://default
 Database driver        :  mysql
 Database hostname      :  localhost
 Database username      :  root
 Database name          :  rbu_1
 Database               :  Connected
 Drupal bootstrap       :  Successful
 Drupal user            :  Anonymous
 Default theme          :  garland
 Administration theme   :  garland
 PHP configuration      :  /private/etc/php.ini
 Drush version          :  4.4
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  /Users/chrisadams/headshift-code/perky.dev/rbu
 Site path              :  sites/default
 File directory path    :  sites/default/files

```

When I run through these installation steps through the web browser when I call `drush st`, here's what I see:

Here's the output of `drush st`:

```
Drupal version         :  6.20
 Site URI               :  http://default
 Database driver        :  mysqli
 Database hostname      :  localhost
 Database username      :  rbu_1
 Database name          :  rbu_1
 Database               :  Connected
 Drupal bootstrap       :  Successful
 Drupal user            :  Anonymous
 Default theme          :  ginkgo
 Administration theme   :  ginkgo
 PHP configuration      :  /private/etc/php.ini
 Drush version          :  4.4
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  /Users/chrisadams/headshift-code/perky.dev/rbu
 Site path              :  sites/default
 File directory path    :  sites/default/files

```

This uses a different database driver, and has the correct themes set, and uses a different db username, and makes me wonder if this is the issue, but I'm not quite sure what might be the cause beyond this here.

The only changes I made here, in this were using a different database user, `rbu_1`, and a different password `rbu` instead of `root` and `''` for the password (I know it's bad practice, to use root like this - I switched to it when I was trying to eliminate permissions problems when debugging this issue earlier).

Any idea Open Atrium would behave differently under these two conditions?

I can do this process through the web browser, and this installs fine, but this won't be enough to setup CI for a project I'm working on.

I don't know what I'm doing wrong here, and I'd really appreciate some pointers. Any ideas, other than using `curl` and `wget` or `mechanize`?

# Answer
> 3 votes
site-install can sort of handle complex install profiles in Drupal 7 (especially the upcoming Drush5) but such profiles are virtually impossible to support in Drupal 6. The Drupal 6 installer is just not built for non-web use. Sorry.

---
Tags: drush
---


# Question
Title: Using user_load() and user_save() to change the status of a logged out user
I'm fairly new to Drupal, and I am currently working on a Drupal user registration mechanism that involves authentication on a different website. The flow is as follows: \- A user registers on a Drupal user/register form. Using user\_register\_submit() I set the the user's status to blocked. \- After registering, the user is being redirected to a different website where he is required to log in. In that redirect, I pass the newly registered Drupal username as a parameter. If the login on that external site is successful, I'd like to redirect the user back to a .php page on the Drupal site (also sending back the username parameter via POST), and then change the status of that user to Active.

In order to achieve that, I've tried using the following code in a page called auth.php I placed under my theme's root directory. This code is failing:

```
<?php
    $username = $_POST['user'];
    $user_to_activate = user_load(array('name' => $username));
    user_save($user_to_activate, array('status' => 1);
?>

```

After stumbling upon this http://drupal.org/node/820506, I realized core functions (such as user\_load() and user\_save() from the user.module) should be available from other modules. So I'd like to put my code inside a custom module, thing is I don't know in which function should I put it. Also, I wouldn't want this module to be called on every page load, only when being redirected from the external website I mentioned in the first comment.

Could someone offer some guidance?

# Answer
> 3 votes
> In order to achieve that, I've tried using the following code in a page called auth.php I placed under my theme's root directory.

Normally in Drupal you don't create php files which are called externally. This can be done in some very rare cases. But most of the time you would define a *menu callback* in a module and have that call a function which you put your code in.

One of the issues that you have found is that Drupal is not bootstrapped from a generic PHP file.

It is fairly straightforward to do this.

1. Create a module, with a .module file and a .info file.
2. Turn on this module via the admin interface.
3. In your module implement hook\_menu() and provide a path to be called, in your example this could be 'mymodule/auth'.
4. Create a function which will be called when your menu hook is fired.

There is a more in-depth tutorial here.

# Answer
> 0 votes
`hook_menu` Register a URL for your callback

```
function yourmodulename_menu(){
   return array(
      'your/desired/path' = array(
           'title' => t('page title'),
           'description' => t('page description'),
           'page callback' => 'your_callback'
           'access arguments' => array('access content'),
           'type' => MENU_CALLBACK,
      ),
   );
}

```

Now define your function that will be invoked upon accessing `your/desired/path`

```
function your_callback(){
     //Put your code here OR include your script
}

```

The code will go in your custom module here is guide to create a module.

# Answer
> 0 votes
Here's the solution that worked for me, eventually, if anyone stumbles upon this post. I have indeed put my code inside a custom module, but i didn't implement `hook_menu()`. That's because menus are getting cached by Drupal and `hook_user()` won't be called if already cached.

As described above and here Getting the $user object of a logged out user based on a username and setting its status, I needed to fetch the `$user` object based on a username and change the user's status but only when hitting a specific page. So here's the very straightforward code to do just that (put inside mymodule.module):

```
<?php
  function mymodule_user($op, &$edit, &$account, $category = NULL) {
    switch ($op) {
      case 'insert' : {
        // set user status to blocked upon registration
        user_save($account, array('status' => 0));
        break;
      }
    }
  }

  function mymodule_init() {
    // execute the following only if you're on http://www.example.com/activate
    if (drupal_get_path_alias(implode('/',arg())) == 'activate') {
      $account = user_load(array( 'name' => $_REQUEST['user'] ));
      user_save($account, array('status' => 1));
    }
  }

```

The 'activate' page access is restricted to a list of IPs and the page itself is requested through a remote http request via POST.

---
Tags: users
---


# Question
Title: Configure view to display a list of nodes with identical term id/name
How could I configure the view to display a list of nodes that with the identical term id/name?

# Answer
You can add a filter to display nodes that has term with name/id = X. This is done through the interface by clicking add filter and selecting either term name or term id.
> 0 votes

---
Tags: views, flags
---


title: How to display URL in status message?

text:
# Question
Title: How to display URL in status message?
I want to customize the status message after creating a content to include the current URL.

From

> @type %title has been updated.

to

> @type %title has been updated. Your permalink is (URL)

I'm running Drupal 7 using the String Overrides module.

# Answer
> 4 votes
You will need to create the message yourself, since the url is not available as a parameter in the string, like the type and title is via `@type` and `%title`.

To do this, you can add a custom submit function with `hook_form_alter` and delete the message created by the node module. This would look like this:

```
module_form_alter(&$form, &$form_state, $form_id) {
  if (strpos($form_id, 'node_form') !== FALSE) {
    $form['#submit'][] 'my_custom_submit_handler';
  }
}

function my_custom_submit_handler(&$form, &$form_state) {
  // Unset previous set messages.
  drupal_get_messages('status');
  drupal_set_message(t('Your custom string', array('@with' => 'params')));
}

```

# Answer
> 0 votes
Add your own submit function to node form (see http://goo.gl/FJO0s for details), and inside update the message already set by node\_form\_submit() to your liking.

---
Tags: forms
---


# Question
Title: How to change position of a block in a region?
I just added a block to the 'content' region. It shows up at the bottom of this region. How do I do to move it to the top of this region?

I'm using the Drupal default theme: Garland

thanks

# Answer
If it's showing up below the page content (and you want it above), you'll need to add a new region. It's recommended to copy Garland and rename it as your own custom theme in sites/all/themes.

In the .info file, add a new region. e.g.:

```
regions[content_upper] = "content upper"

```

In the page template file, place that region just above $content.

```
<?php print $content_upper; ?>
<?php print $content; ?>

```

Then place the block in "content upper"
> 3 votes

---
Tags: blocks, theming
---


title: How to change the behaviour of a module

text:
# Question
Title: How to change the behaviour of a module
i often need to change/add new behaviours to existing modules, but i don't really know what is the correct way to do this.

For example i have installed the webform module. What i need to add is this:

* on the list of submitted forms i need a button (create user) which creates a new user using some data of the submitted form.

What should i do?

Should i change the module code or is there a way i can inject this behavior by creating a new module?

I'd like the second option more than the first, are there some tutorials on how to do this?

# Answer
Most of the time you will want to try to stay away from modifying the modules directly. This can be done, but it makes it more difficult to upgrade to future versions of the module.

A lot of modules allow for modification, and Drupal itself is designed for you to be able to modify things at many stages in the process of building a page. So if you can inject functionality it is best to do so.

This isn't always possible to do in which case you can either modify your local copy of the module. Or you can create an issue on the modules issue queue with a patch, which may get picked up in a future release of the module.

How to inject behavior is a very broad subject (I am sure specifics are already answered or can be asked on this site).

Most of the time you will want to create a module, and implement hooks which will allow you to modify things.
> 3 votes

---
Tags: 7
---


# Question
Title: Is there a token for the body of a content type?
Is there a token for the body of a content type? I'm using the Integrated Metatags module. I want to include some of the body text inside of the Meta Description tag.

# Answer
> 2 votes
There is a feature request opened for the Token module: Token for body of node. Essentially, the reason it has not been implemented is performance issues, as modules are queried for the values of the tokens they implement, independently from the fact those tokens have been requested. This means the content for, e.g., `[body]` would be generated even if the string passed to Token doesn't contain that tag.
The Drupal 7 code that handles tokens is changed, and the modules that implement tokens gets the list of tokens that need to be replaced; the content of tokens that are expensive to generate is generated only when required.

In short, the only module that could implement that kind of token is the Token module, but so far it doesn't implement it for implementation issues. Any other module that implements it would have the same performance issues.

---
Tags: tokens, nodes
---


title: Customize search result

text:
# Question
Title: Customize search result
How can i remove `Only of the type(s)` on the advance options. and `username` and `created day` display on the footer search result?

# Answer
> 1 votes
The Custom Search module provides easy control over many of those search options.

# Answer
> 0 votes
You can use template files like search-result.tpl.php (singular) and search-results.tpl.php (lists). You should be able to remove/add anything you like.

---
Tags: search, entities
---


# Question
Title: Module Error for some content types but not for others
**The Error**

> warning: array\_keys() \[function.array-keys\]: The first argument should be an array in /home/vermontbiz/webapps/vermontbiz/modules/int\_meta/int\_meta\_cck.module on line 39. warning: Invalid argument supplied for foreach() in /home/vermontbiz/webapps/vermontbiz/modules/int\_meta/int\_meta\_cck.module on line 39.

**The Code**

```
function function int_meta_cck_int_meta($op, &$arg) {
  switch ($op) {
    case 'load': {
      if (!empty($arg->int_meta)) {
        $supported = int_meta_cck_supported($arg->type);
        foreach ($arg->int_meta as $key => $tag) {
          if (in_array($tag->field, $supported)) {
            $parts = explode('.', $tag->field);
            if (isset($arg->{$parts[0]})) {
             foreach ($arg->{$parts[0]} as $tmp) {
               $arg->int_meta[$key]->values[] = $tmp[$parts[1]];
              }
            }
          }
        }
      }
    }
    break;

    case 'fields': {
      return int_meta_cck_supported($arg);
    }
    break;
  }
}

function int_meta_cck_supported($arg) {
  $fields = array();
  if (!empty($arg)) {
    $type = content_types($arg);
    if (!empty($type)) {
      foreach ($type['fields'] as $name => $info) {

      //**Error below takes place in the line below but doesn't effect all content**

        foreach (array_keys($info['widget']['default_value'][0]) as $col) {
          $fields[] = $name . '.' . $col;
        }
      }
    }
  }
return $fields; }

```

My question is why does the line give an error to some content types but not others?

The two content types.

# Answer
> 1 votes
You're making an assumption and that is that

```
$info['widget']['default_value'][0]

```

Will always be an array. My guess is that for some fields (depending on configuration) that `$info['widget']['default_value'][0]` will be either `NULL`, `FALSE` or a scalar value.

---
Tags: 7, meta-tags
---


# Question
Title: What are the differences between the various OpenID widgets available?
There seems to be several different widgets for providing easer registration and login. I'm curious how they work and what the difference between them are? For example, there is the OpenID selector, Loginza, and Janrain.

# Answer
The first and the last link you provided takes to the same project page.

* The OpenID Selector module replaces the OpenID login form provided by openid.module (an optional Drupal core module) with the same OpenID selector used, for example, on Stack Exchange sites. Though additional modules, it integrates with login provided by:

+ Facebook
    + Twitter
    + LinkedIn
    + vkontakte.ru
    + mail.ru
    + Windows Live ID
* The Loginza module replaces the Drupal core module for OpenID, as it implement OpenID authentication, and it allows to authenticate users using the login provided by the following sites/services:

+ Google Account
    + Yandex
    + Mail.ru
    + Vkontakte
    + Facebook
    + Twitter
    + Loginza
    + MyOpenID
    + WebMoney
    + Rambler
    + Flickr
    + Last.fm
    + Verisign
    + AOL
    + Steam

The other difference between the modules is that the Lorenza module is for Drupal 7, while the OpenID Selector module has versions for Drupal 6 and 7.
> 2 votes

# Answer
Connector and OAuth Connector are modules that like Janrain can connect to accounts other than OpenID, through OAuth or other methods that people write extensions for (existed an connector for the old Facebook API).

They do mostly what Janrain do - but they do it natively in Drupal so you don't get any crippled access to any API:s and you fully control the code and can patch it any way you like.

They are currently alpha, but no that the OAuth module has been ported to Drupal 7 I can probably start porting them there and continue development on it.
> 2 votes

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


# Question
Title: Views bonus pack CSV export internal server error
I'm using the CSV export feature in the views bonus pack, but when I go to the path I set up for it I get this error message:

"The website encountered an error while retrieving http://something.com/csv. It may be down for maintenance or configured incorrectly."

I'm successfully using this module on a different site, and as far as I can tell they have the same configurations. It used to work on this site and recently broke for no apparent reason. Any ideas on what the potential points of failure might be to cause this error?

# Answer
> 1 votes
Apparently the problem was Theme Developer being on.

# Answer
> 0 votes
The error is caused because you're having an internal server error (fatal PHP error) on the URL it's trying to use. The reason is most likely faulty data, you can find the exact cause by looking in the error log of your webserver.

---
Tags: views, 6
---


# Question
Title: How do I configure the Services OAuth sub-module?
The Services module is about to release its new *3.0 version* for both D6 & D7. There's an *OAuth sub-module* to Services that adds a new *OAuth UI* within the *Services configuration UI*.

Does anyone know how to configure that UI?

I'm expecting the Services developers will write something up, but given that they are working hard on the official release, the documentation will be the last thing done. In the mean time, if anyone has figured it out from prior familiarity with *OAuth*, please share your knowledge to us less informed. (As in explaining it to someone who has not used OAuth before.)

# Answer
There is a handbook page covering testing Oauth based services at http://drupal.org/node/942866 . This does assume that you have some familiarity with both oauth and the drupal oauth module.

The basic workflow as far as implementation goes is:

* Set up an oauth context.
* Set your service to use oauth authorisation
* Configure the authorisation for all your resource operations.
* Configure one or more oauth consumers

For testing you're probably going to have to write your own client code which generates the oauth signature and then passes that with your service requests.

For learning more about Oauth itself I recommend you start by reading this guide which is fairly comprehensive - http://hueniverse.com/2007/10/beginners-guide-to-oauth-part-i-overview/
> 2 votes

# Answer
The OAuth Login Provider contains a pre-configured endpoint with OAuth support:

You need to create *OAuth contexts* for which you can create *OAuth consumers*. The reason we have *OAuth contexts* is that we don't want to tie *OAuth contexts* directly to endpoints - you should be able to share consumer keys between multiple endpoints and also between *services* and *non-services projects*.

In *Services* you select *OAuth* as the authentication mechanisms and select a context. You should also be able to select authentication level for each individual resource in the endpoint but I think someone accidentally removed that and we haven't yet added it back yet: http://drupal.org/node/1154420
> 2 votes

---
Tags: services, authentication-authorization
---


# Question
Title: How do I consume JSON data via a hook_menu callback?
I'm trying to set up Tropo's WebAPI with a Drupal site, and I thought I'd just create a hook\_menu() callback for example.com/tropo, then use the hook\_menu callback I just created to consume the API call from Tropo (which contains a simple JSON array of data), then respond.

I can do the response part pretty easily... build the data, drupal\_json\_output() and exit (that just returns the JSON basically).

The part I'm having trouble with is getting the data that is sent to the /tropo menu callback... I can't access any data by using either of the following:

```
$json = file_get_contents("php://input"); // returns NULL

```

(below uses the inputstream module:)

```
$json = file_get_contents("drupal://input"); // also returns NULL

```

I checked what some other modules do, and it looks like they use hook\_init to grab the JSON. Is this the preferred method? I'd love to be able to do it in hook\_menu and use my own path and such...

Alternatively, would I be better off writing my own PHP script and running outside of Drupal, just doing a bootstrap for the database if I need to?

# Answer
> 2 votes
Well, it turns out I was getting the data, but I forgot to decode it...

In my hook\_menu callback:

```
$received = file_get_contents("drupal://input"); // Use inputstream module.
$received = json_decode($received, TRUE);

```

Then I can play around as much as I'd like with the $received value.

Additionally, the inputstream module is invaluable in letting me get to the input stream more than once (if you try using `php://input` more than once, the second time, and those following, will return NULL).

As an additional note, I just noticed today a new module that might be an even simpler way of handling this: Content as JSON

# Answer
> 2 votes
The REST Server that is part of the Services module does this automatically for JSON as well as for other formats: http://drupal.org/project/services

It also supports Inputstream (Inputstream was built to handle both OAuth verification and Services decoding of the same stream).

---
Tags: services
---


title: Change Ubercart's "Order" to "Donation"

text:
# Question
Title: Change Ubercart's "Order" to "Donation"
I am setting up a site for a non-profit organization (using Ubercart to accept donations) and I want to change "order" to "donation".

I started in with the stringoverrides module. I was searching around trying to find all the occurrences of "Order" and putting in a string over ride that changed it to "Donation". I found this to be extremely clunky, time consuming and error prone.

I looked at the source of the string overrides module figuring that I could find how it was actually performing the override and then hack together my own solution to programmatically do some sort of search and replace on it. After looking at that and the source for the `t()` function I realized it wasn't going to be that easy.

1. Is there a way to easily pull a list of all the `t()` calls that include the text "order" in them? I could then pretty easily generate a .po file by doing a bunch of search and replace type operations.
2. Is there a way to programmatically change all occurrences of 'order' to 'donation'?
3. Is there some other obvious way that I haven't thought of?

P.S. I am proficient with custom module development in Drupal but don't have much experience in l10n\_update or i18n with Drupal.

# Answer
Have you taken a look at this http://drupal.org/project/uc\_donation... Ubercart can actually provide donation functionality. Let me know if this is what you were thinking.
> 1 votes

---
Tags: ubercart, i18n-l10n
---


# Question
Title: How to list all nodes with alphabetical headings?
I want to list all nodes with alphabetical headings like this example http://www.animeseason.com/anime-list/ How can I do this?

# Answer
> 2 votes
You can achieve this using the Views module (http://drupal.org/project/views) which actually comes with a pre-built view called "Glossary". Enable that and tweak it to suit your needs.

Hope this helps.

---
Tags: views
---