# Question
Title: Dealing with nodes that do not have the field when sorting views using date field
I have an 'Expired' date field that holds the date when a node expires. However, not every node has this field so nodes missing this field come after nodes containing the field. I want nodes that do not have this field to be sorted above nodes that have the field. How can I do this?

# Answer
> 1 votes
You would need to sort your posts by two criteria

* Has a expired date
* The value of the expired date

Or alternatively you could use ASC/DESC to display those without an expire date first. Doing that would effect the sorting of the rest of the nodes.

If you want to use two criteria, you could create a computed CCK field that has a value of 0/1 indicating if it has an expire date. You can use that to display all nodes without expire date first, and then sort those with an expired date by the expired date.

---
Tags: 6, views
---


title: Attaching CSS to block doesn't work

text:
# Question
Title: Attaching CSS to block doesn't work
mymodule is in modules/custom directory.

```
$block['content']['#attached']['css'][] = drupal_get_path('module',
                                          'mymodule' . '/mymodule.css');

```

mymodule.css exists.

However file is not attached.

# Answer
> 5 votes
You have a typo in your statement. It should be:

```
$block['content']['#attached']['css'][] = drupal_get_path('module', 'mymodule') . '/mymodule.css';

```

Also, be sure to clear the cache after you add statements like this to your code.

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


# Question
Title: Does anonymous can access current node? How to check it in my module?
I need to do something witn current node by my module only if anonymous users can view this node. How to check it?

By default I use `$node->status == 1`, but some other modules can change anonymous access rights also for published nodes.

# Answer
> 1 votes
The check if the anonymous user has access to a given `$node`, you can use the `node_access()` like this: `node_access('view', $node, user_load(0))`.

As a side note, `$node->status == 1` will check that the node is published. An unpublished node is usually not visible by anonymous user. Which users are allowed to view unpublished node depends on the granted permissions and node access module enabled on the site.

# Answer
> 0 votes
Do you use a special module to set node permissions? Or just core Drupal?

If just core Drupal, then I think anonymous users only need the "access content" permission, and maybe you could check this with (I have not tested this code):

```
$anonymous = user_load(0); // load anonymous user
$can_access_content = user_access('access content', $anonymous);

```

---
Tags: 7, hooks, users
---


# Question
Title: How can I refer to a user in a content type using CCK in Drupal 7.7
In a content type I want to let the author select one or more of the site users. It's something like term reference field but I need to refer to a user instead. I can't find a suitable module for that although I can roughly remember that I did that before. I am using the latest drupal version 7.7.

Thanks

# Answer
> 3 votes
Use the References module.

---
Tags: entities
---


title: Marking objects from view for later use

text:
# Question
Title: Marking objects from view for later use
If I have a table containing, say, images, how can I be able to select an image from one view, one from another and have them added/marked for later use (i.e., some sort of "add to cart" feature). So then I could select an image from slideshow1, one image from slideshow10 etc and then be able to do whatever I want with them (perhaps create another view?)

# Answer
This sounds like a perfect job for Flag module.

From the module description:

> Flag is a flexible flagging system that is completely customizable by the administrator. Using this module, the site administrator can provide any number of flags for nodes, comments, or users. Some possibilities include bookmarks, marking important, friends, or flag as offensive. With extensive views integration, you can create custom lists of popular content or keep tabs on important content.

For your use case, I would create a new flag for your image content type. Add the flag operation to your current views of images. Create a new view that uses that flag as a filter.
> 1 votes

# Answer
Write an action and use it with Views Bulk Operations.
> 0 votes

# Answer
As you are talking of selecting an image from a view, and another one from a different view, then I think there is nothing that allows to do that.

The closer I can think of is something that allows you to select nodes shown in a view, and apply an operation to those nodes. This is what the Views Bulk Operations (VBO) module does. This is an example of what the node view that comes with the module outputs.

I installed the Image module, which has support for the Views module, and in the VBO view I added the field for attached images.

As result, the view now shows what visible in this screenshot. I could have removed any not necessary fields from the view, and obtained a more compact view.

The list under "Bulk operations" contains all the operations that can be done to the selected nodes, and includes also what other modules export as node operations (through hook\_node\_operations()) or as actions (through hook\_action\_info()). Ubercart exposes some actions too; if those are applicable to nodes, then you should see them in the bulk-operations list. If they don't appear, or they are not the actions that you need, then you need to create a custom module, and implement one of the hooks I reported.
VBO has also the "Execute arbitrary PHP script" operation, but it would execute the code that users would enter when selecting that operations; it doesn't always execute code that you decided.

VBO also allows you to select which operations to show in the view; this means you can remove all the operations that are not necessary in your view, and show only the operations exposed from your module.
> 0 votes

---
Tags: views, media, ubercart
---


# Question
Title: Possible to group views by date field larger than current date?
I want to group my nodes into active and expired based on a date field. Currently I have the view set to group by this field but I don't want the active and expired groups to be broken down into specific dates such as 2 weeks, 3 days etc. I just want two groups, active and expired. How can I do this? An example of what I currently have http://www.glumbo.com/deals/footlocker.com-deals

# Answer
I used this module to accomplish this http://drupal.org/project/views\_customfield. It allows you to define a new views field using custom php code
> 0 votes

---
Tags: 6, views
---


# Question
Title: Cron Run resulted in Fatal Error Message
Using Drupal 6.22 PHP 5.2.17 PHP memory limit - 150M

Last time I ran Cron was 2 weeks 19 hours ago

I am experiencing no errors with the site but opted to run Cron manually and received the following error message

Fatal error: Allowed memory size of 157286400 bytes exhausted (tried to allocate 7680 bytes) in /home4/xxx/public\_html/xxx/includes/theme.inc on line 1078

Is this an error message I need to be concerned about? If yes, How do I fix it? And...Is running Cron a necessity, if the site is functioning fine everywhere else.

# Answer
Whatever cron is doing, you'll need to allow it more memory for it to succeed. You can find out about increasing PHP's `memory_limit` at http://drupal.org/node/207036

However, it looks like you already have `memory_limit` set to a high value for a small site.
> 1 votes

---
Tags: cron
---


title: webform module in drupal

text:
# Question
Title: webform module in drupal
I've installed the webform module in my drupal site and want to configure it so that the submission limitation is by email instead of cookies. I dont want users who have already submitted to submit twice if their email is in the system. Is there a way to do that? Would I Have to create a new module for this? If so, how do I communicate my new module with the webform module? Or would editing this webform module be the solution (which I dont think is a good idea in case I have to upgrade it and lose the changes I've done). Please help. Thanks.

# Answer
> 1 votes
You can use the webform validation to create a rule that compares the e-mailaddress with all e-mailaddresses in the table where the webform data is stored (you will have to look it up but I believe it is the email field in the webform\_emails table).
Or you can create a custom module depending on webform\_validation to compare data, there is a similar issue in the issues..

---
Tags: 7, webforms
---


# Question
Title: My webhosting won't allow "Options" in .htaccess
My webhosting provider of 4 years said they don't allow "Options" in .htaccess files. They were referring to lines 11 and 14 of the .htaccess file. Is it ok to comment these out?

These lines are

```
# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

```

Does it pose a security risk?

# Answer
> 2 votes
`Options -Indexes` prevents users from seeing which files exist in a directory. You shouldn't use this feature to secure your site, it mainly exists for aesthetic reasons. It is technically never necessary.

`Options +FollowSymLinks` is not necessary in a vanilla Drupal installation, chances are you do not need this one either.

Have a look at the documentation of the Options directive for more details.

---
Tags: 7, .htaccess
---


# Question
Title: Setting up subdomains, confused on "Settings.php" / "web.config" setup
First, I'm using shared hosting. I've set up the DNS so I have one.example.com, two.example.com, etc. Each subdomain works properly, but they use the default page.tpl.php/look exactly the same as my front page. I'm assuming the next step is to configure the settings.php, web.config, and to create preprocessed theme hooks. Is there a good D7 tutorial on how to do all of this via "subdomains"?

Also, I'm planning on using the "Domain" module. I've got it properly configured. But, don't really see a point in using it until the above mentioned is setup properly.

# Answer
Instructions for multisite installations are in `sites/default/settings.php`. To quote from that file:

> For example, for a fictitious site installed at http://www.drupal.org/mysite/test/, the 'settings.php' is searched in the following directories:
>
> 1. sites/www.drupal.org.mysite.test
> 2. sites/drupal.org.mysite.test
> 3. sites/org.mysite.test
> 4. sites/www.drupal.org.mysite
> 5. sites/drupal.org.mysite
> 6. sites/org.mysite
> 7. sites/www.drupal.org
> 8. sites/drupal.org
> 9. sites/org
> 10. sites/default
>
> If you are installing on a non-standard port number, prefix the hostname with that number. For example, http://www.drupal.org:8080/mysite/test/ could be loaded from sites/8080.www.drupal.org.mysite.test/.

The lookup can be changed as described in `sites/example.sites.php`:

> This file allows you to define a set of aliases that map hostnames and pathnames to configuration directories. These aliases are loaded prior to scanning for directories, and they are exempt from the normal discovery rules. The aliases are defined in an associative array named $sites, which should look similar to the following:
>
> ```
> $sites = array(
>   'devexample.com' => 'example.com',
>   'localhost.example' => 'example.com',
> );
>
> ```
>
> The above array will cause Drupal to look for a directory named "example.com" in the sites directory whenever a request comes from "example.com", "devexample.com", or "localhost/example".

BTW: multisite installations are usually done to facilitate using different databases.
> 2 votes

---
Tags: 7, configuration
---


# Question
Title: drupal_render($form) not rendering a form
I wonder if anyone has found a solution to the problem I'm seeing. I've built a very simple "beginner's form" in drupal.

```
function simple_nameform() {
    $form = array(
        '#method'           => 'post',
        '#prefix'           => '<div class="staf">',
        '#suffix'           => '</div>',
        'your_name'         => array(
            '#title'        => t('Your Name'),
            '#type'         => 'textfield',
            '#description'  => t('Please enter your name')
        ),
        'submit'            => array(
            '#type'         => 'submit',
            '#value'        => t('submit')
        )
    );
    return $form;
}

```

I've put this form in a module, with info, I've enabled the block in admin. When I'm on the main page render I run the commands

```
<div class="simple_overlay" id="simple">
    <h1>Send to a Friend</h1>
    <?php
        $output = drupal_get_form('simple_nameform');
        drupal_render($output);
    ?>
</div>
<pre>
<?php // debug purposes only
          print_r($output);
    ?>
</pre>

```

The form does not appear to render from the "drupal\_render" line, however, the $output variable is most definitely full of something that looks very much like it might be a drupal form.

(it's a huge array filled with my form elements. at parts it even manages to render some of the elements to page correctly).

Anyone with an idea of what I've missed?

# Answer
Try:

```
<?php print render(drupal_get_form('simple_nameform')); ?>

```
> 6 votes

# Answer
EDIT -- My original answer was incorrect in that it applies to Drupal 6.

it seems that the form builder function in D7 needs 2 arguments, `$form` and `$form_state`

```
<?php
function simple_nameform($form, &$form_state) {
/...
?>

```

I wonder if the \_valdiate and \_submit function aren't also required, as they are present in the D7 example here: http://api.drupal.org/api/drupal/includes--form.inc/group/form\_api/7

if that doesn't work, try using hook\_forms() to register your form with a module

---

**original solution for D6**

```
<?php
$output = drupal_get_form('simple_nameform');
print $output;
?>

```

`drupal_get_form` returns a rendered form. notice the last line here: drupal\_get\_form()

also, unrelated, you probably need to add a line to your submit button:

```
<?php

        'submit'            => array(
            '#type'         => 'submit',
            '#value'        => t('submit'),
            '#executes_submit_callback' => true
        )
?>

```

and to make debugging easier, try this:

```
<?php // debug purposes only
          drupal_set_message("<pre>".print_r($output,true)."</pre>");
?>

```

(the 2nd arg of print\_r makes it return inline instead of pooping at the top of your document.)
> 3 votes

---
Tags: 7, forms, theming
---


# Question
Title: Can Date API/Calendar and CCK send an argument to Views with data from a field?
I have a data/calendar content type using the Date API and Calendar Modules. Each event I add to the calendar uses Advanced Node Reference and returns a list of 5 other events of the same type.

What I want is a list of the next five events following the event node's *advertised* event date (not the date it was published). If a new event node is added, and it falls within the *next five events* parameter, then when the page is generated, it is listed, bumping the furthest future event from the list. If a event node is removed, then a new (previously out of range) event node is added to the list. It is a simple sort, and very reasonable requirement using the "advertised" date and not the "published" date. The field data would be the advertised date.

The Node Reference module allows a view to be used to make the selection to populate the node reference. This I have also done. The problem is the list of possible dates/events to be linked are produced by a filter with *relative* date value from *today's* date ('\>= now'), rather than from the node's content value for *event date*.

*TDW* might use an argument to pass the current date value of the date/event being edited to Views. If this exists, where is it? What is it? Some kind of \[keyword\] to pass in the allowed argument field of the Advanced Node Reference of this Date Content Type?

If this was a PHP template I was hand coding, the value of the current form's 'event date' field would be available from the query used to populate the form. In Drupal I don't know where this is. I'm still a newbie at Devel Module and its variables page was no help.

# Answer
It sounds like you need to do a relationship to the parent node, and then use a Filter by node published date using that relationship.
> -1 votes

---
Tags: views, 6, nodes, datetime
---


title: Get content type with PHP from database

text:
# Question
Title: Get content type with PHP from database
I have created a content Type Student, I have imported the list of student with node import. Now I want to get the name, location and other values of the content type Student from my database. How can I do that with PHP? I have already created a simple module with a menu and block.

# Answer
Why don't use **Views** module. This is exactly the purpose of this module. And if you are not so aware of all drupal's API, it will really save you a lot of time, and security in your website.

> This tool is essentially a smart query builder that, given enough information, can build the proper query, execute it, and display the results. It has four modes, plus a special mode, and provides an impressive amount of functionality from these modes.
>
> Among other things, Views can be used to generate reports, create summaries, and display collections of images and other content.
> 4 votes

# Answer
To retrieve a Student node (in OO-lingo that would a Student instance), use `node_load()`. If you want to retrieve all Student nodes, you have to loop over the result of a database query like this

```
$results = db_query(db_rewrite_sql("SELECT nid FROM {node} WHERE type = 'student'"));
while($nid = db_result($results)) {
  $node = node_load($nid);
  // Do something with $node
}

```

If you have a lot of Student nodes, it's probably not a good idea to process all of them in a single run. If you really need to process all of them, you should use the Batch API.
> 5 votes

---
Tags: nodes
---


# Question
Title: Prevent items from being indexed so it won't come out on search
Drupal 7 - Can you you exclude an entire content type (or just selected entries from it) from being indexed so they won't come up in a search result? I'm just assuming that indexing is the answer but the main point is that neither of the items will come up on a search result.

# Answer
> 4 votes
You can use the Search API module in Drupal 7 to give you this granular control over your search indexing and results.

You will need at least one other module to use the Search API, namely one that defines a service class (e.g. search\_api\_db ("Database search"), provided with this module).

* Creating a server (Configuration \> Search API \> Add server)

The most basic thing you have to create is a search server for indexing content. Go to Configuration \> Search API in the administration pages and select "Add server". Name and description are usually only shown to administrators and can be used to differentiate between several servers, or to explain a server's use to other administrators (for larger sites). Disabling a server makes it unusable for indexing and searching and can e.g. be used if the underlying search engine is temporarily unavailable. The "service class" is the most important option here, since it lets you select which backend the search server will use. This cannot be changed after the server is created. Depending on the selected service class, further, service-specific settings will be available. For details on those settings, consult the respective service's documentation.

* Creating an index (Configuration \> Search API \> Add index)

For adding a search index, choose "Add index" on the Search API administration page. Name, description and "enabled" status serve the exact same purpose as for servers. The most important option in this form is the indexed entity type. Every index contains data on only a single type of entities, e.g. nodes, users or taxonomy terms. This is therefore the only option that cannot be changed afterwards. The server on which the index lies determines where the data will actually be indexed. It doesn't affect any other settings of the index and can later be changed with the only drawback being that the index' content will have to be indexed again. You can also select a server that is at the moment disabled, or choose to let the index lie on no server at all, for the time being. Note, however, that you can only create enabled indexes on an enabled server. Also, disabling a server will disable all indexes that lie on it. The "Index items immediately" option specifies that you want items to be directly re-indexed after being changed, instead of waiting for the next cron run. Use this if it is important that users see no stale data in searches, and only when your setup enables relatively fast indexing. Lastly, the "Cron batch size" option allows you to set whether items will be indexed when cron runs (as long as the index is enabled), and how many items will be indexed in a single batch. The best value for this setting depends on how time-consuming indexing is for your setup, which in turn depends mostly on the server used and the enabled data alterations. You should set it to a number of items which can easily be indexed in 10 seconds' time. Items can also be indexed manually, or directly when they are changed, so even if this is set to 0, the index can still be used.

* Indexed fields (Configuration \> Search API \> \[Index name\] \> Fields)

Here you can select which of the entities' fields will be indexed, and how. Fields added by (enabled) data alterations will be available here, too. Without selecting fields to index, the index will be useless and also won't be available for searches. Select the "Fulltext" data type for fields which you want search for keywords, and other data types when you want to use the field for filtering (e.g., as facets). The "Item language" field will always be indexed as it contains important information for processors and hooks. You can also add fields of related entities here, via the "Add related fields" form at the bottom of the page. For instance, you might want to index the author's username to the indexed data of a node, and you need to add the "Body" entity to the node when you want to index the actual text it contains.

* Index workflow (Configuration \> Search API \> \[Index name\] \> Workflow)

This page lets you customize how the created index works, and what metadata will be available, by selecting data alterations and processors (see the glossary for further explanations). Data alterations usually only add one or more fields to the entity and their order is mostly irrelevant. The order of processors, however, often is important. Read the processors' descriptions or consult their documentation for determining how to use them most effectively.

# Answer
> 0 votes
This is a native feature of the https://drupal.org/project/apachesolr module.

Using apachesolr + the apachesolr module you can configure the content types that you wish to have indexed using checkboxes. No coding required here.

Plus you get the added bonus of a far more advanced search engine, with facets etc

---
Tags: search
---


# Question
Title: Use Views to display tabs such as, "Add User Relationship," "Send message," etc
In D7, is there a module that allows to display tabs similar to the following ones, in Views?

* Add Relationship
* edit
* Messages
* Send Private message

I want to add these tabs as views blocks so I can place them where I want.

# Answer
I didn't understand your question clearly, where are you getting those tabs from? If its a View you could use the Views Display Tabs module, unfortunately the D7 port still hasn't been started it seems: http://drupal.org/node/985960 \- Its a good time to write a patch for it or hire someone to do it for you.
> 1 votes

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


# Question
Title: Hiding language names in "Language switcher" block and displaying only country flags
I would like to **hide language names** (like "English", "Español", "Magyar", etc.) **in the "Language switcher" block**, and display only country flags, because I have Language icons module installed, and the flags are unambiguous enough for navigating between different languages.

I already set language elements to be displayed in an "inline" style and hide language switcher block's title in my stylesheet file (in a Zen sub-theme) like this:

```
#block-locale-0 li{
    display:inline;
    list-style-image: none;
}
#block-locale-0 .title{
    display:none;
}

```

# Answer
> 6 votes
OK, in the meantime I found the perfect solution which I earlier just simply overlooked: there's a really simple configuration option in Language icons module's settings in `http://`<yoursite>`/admin/settings/language/icons` (D7: `http://`<yoursite>`/admin/config/regional/language/icons`) .

You have to set "**Icon placement**" option from "Before link" or "After link" to "**Replace link**", which results in displaying only the country flags.

Here are some screenshots (on the admin site I'm currently using RootCandy Dark):

BEFORE:

AFTER (on the admin site):

AFTER (on the main site's right sidebar \[design is strongly under development :P\]):

---
Tags: 7
---


# Question
Title: Views... two panes each contains a view.  One is the exposed filter, other is the fields.  How can they communicate?
I have have two panes each containing a view. But, these views are and exposed filter and it's fields/results. How can I make these views aware of each other? I want results of the exposed filtered view to be displayed in the other fields pane.

I'm assuming this would be done through relationships.

# Answer
> 1 votes
Exposed filters are only linked to the view they were exposed on.

I haven't done this before, but I think the correct method would be:

1. Create a view
2. Expose any of the filters you need to on that view (not a separate one)
3. In the advanced settings of that view, set "Exposed form in block" to yes
4. Add the block to your panel (not a separate views pane)

# Answer
> 1 votes
Use a single View, and expose its filters. Under the exposed filters settings, you can choose to expose them as a block. When doing so, the exposed filters from won't show up above the view's results. Display the view in a pane and it's exposed filters block in another.

Note: Relationships are used to bring data from additional *base tables* (in Views *speech*, not in SQL) related to the main *base table* used for the view. For instance, to bring data from the *user* table related to the main *node* table. Once you have added one, you can filter on a relationship' fields.

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


title: Validate a comment from a custom module

text:
# Question
Title: Validate a comment from a custom module
I want to validate comments using a custom module; I am using `hook_comment()`, and "validate" as value for `$op`, but I cannot get the value of the comment field. How do I get the comment value from a custom module?

# Answer
Assuming you're working in Drupal 6:

```
/**
 * Implementation of hook_comment().
 */
function mymodule_comment(&$a1, $op) {
  switch ($op) {
    case 'validate':
      $subject = $a1['subject'];
      $comment = $a1['comment'];
      // validate here
      break;
  }
}

```

In Drupal 7 hook\_comment() is gone, being replaced by a set of hooks hook\_comment\_view(), hook\_comment\_load(), etc. Unfortunately there is no hook\_comment\_validate() but see this answer for a solution.
> 0 votes

---
Tags: 7, comments
---


# Question
Title: How do I limit webform submissions based on the email address?
Is there a way to limit the submissions based on the email address when using the Webform module in Drupal? Right now, there is a setting to limit using the ip address & cookies but I only want to limit using the email address. Anyone has any ideas?

# Answer
Edit the email field in the webform and check both the "mandatory" and "unique" options. That way, it will not except more than 1 submission with the same email address.
> 3 votes

---
Tags: webforms
---


title: Undefined variable: node

text:
# Question
Title: Undefined variable: node
Im using

```
views_embed_view('view_name', 'view_block_name', $node->nid);

```

and im getting error Notice: Undefined variable: node in functin include() So in D7 We cant use $node inside page.tpl.php?

# Answer
If you are using drupal 7, there should already be a node object available when you are looking at a full node page. Looking at http://api.drupal.org/api/drupal/includes--theme.inc/function/template\_preprocess\_page/7 \- the default implementation embeds it into the $variables array:

```
  if ($node = menu_get_object()) {
    $variables['node'] = $node;
  }

```

If your theme is overriding this, you can simply add it back in.

An example might be:

```
function YOURTHEME_preprocess_page(&$variables) {
  if ($node = menu_get_object()) {
    $variables['node'] = $node;
  }
}

```
> 1 votes

---
Tags: nodes
---


title: open atrium - securely share videos

text:
# Question
Title: open atrium - securely share videos
Just started learning a more about open atrium.

Is there a way to securely share streaming videos on open atrium?

If so would this involve utilizing a contrib module?

# Answer
> 1 votes
Place any videos or other protected content on a Content Type that only certain roles have access. Then your users have to login to gain access, and only those with the appropriate role(s) get to see these pages with videos (or other protected content) on them.

You can use Ubercart(d6) or Commerce(d7) to create a product that is selling a role assignment to view your video (protected content) Content Type. Or a fairly simple custom module could track 'purchases' of specific media, granting access to only those pages hosting the purchased media.

For the media hosting & playback, the MediaFront module is a great free and open source media solution. And it plays nice with CDNs, when you get serious...

# Answer
> 1 votes
If your videos come with some kind of embed code e.g. Youtube of Vimeo then you could embed them into Notebook pages in OA. This would make them visible only to the select users in that group.

---
Tags: distributions
---


# Question
Title: how do I create multiple modules that both add to the output of a node?
We have a content type called "sales\_order" which contains order data for online sales.

I have created a custom module that adds a form to the node that allows a user to generate shipping quotes. I do this by creating this function which adds my form to the node:

```
function mymodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {

if ($node->type=='sales_order' || $node->type=='sales_orders')  {
    switch ($op)
    {
        case 'view':

            $form .= drupal_get_form('mymodule_form',$node->nid);
            $node->content['form'] = array
            (
                '#value' => $form,
            );
        break;
    }
}

```

This works great, but, now I want to add an additional form for another shipping provider. So I created a new module doing the same thing but when I enable both, it only outputs the form for the first module and not both?

I think I am misunderstanding how this is supposed to work.

How should I get multiple custom modules to add content (a form) to a node?

PS I know I could easily integrate both providers into a single module but I would prefer to keep them separate for now.

# Answer
> 1 votes
If you're using `$node->content['form']` for both modules, that would be why. Instead do `$node->content['module1_form']` and `$node->content['module2_form']`.

This is because each function is getting passed the *same* node object and $node-\>content\['form'\] is being overwritten between the two modules.

---
Tags: 6
---


# Question
Title: Change node content after logging in under the same URL alias (showing other content for authenticated users)
I would like to **change node content under some specific URL aliases after the user logs in, to show some other contents for authenticated users**.
With a really simple example, there's a node which can be reached under the URL alias `http://`<mysite>`/something`, and this content contains the string *"You have to be logged in, because this would be good to you"*, but after logging in, the same URL alias would show *"OK, now you're logged in"*.

Another user wrote here that

> "in views we can setup same url for different views that is one for anonymous and another for registered."

Is this the right solution?
If yes, how should I do this in practice?
If no, what else can you suggest?

Thank you in advance!

# Answer
> 2 votes
You can do this with views using the technique in this blog post: Making a view show different content to different users based on role

# Answer
> 1 votes
If you want to use views to do that, then the previously mentioned links are good examples.

You might also take a look at Restricted Text and Block CPR (Content Per Role) modules. Each module allows you to show separate content based on role. The former will do this anywhere you can set an input format and the latter is just for blocks.

---
Tags: views, nodes, uri, path-aliases, users
---


# Question
Title: Am I able to call functions in my custom module from other modules?
I would like to integrate the Barcode (http://drupal.org/project/barcode) module functionality into a custom shipping module that I am creating.

I would like to make calls the genBarCode method or something similar so I may generate barcodes within my module.

Is this ok within the context or custom/contrib modules and if so how can it be done?

# Answer
There are two issues:

1. Is the function you're going to call intended to be an API function? In general, functions that are not intended to be called by other modules are prefixed by an underscore as in \_mymodule\_private\_function().
2. Is the function in a file that is guaranteed to be loaded when you need it to be. If it's in a .module file and the module is enabled, then it will be available. If it's in a class that's declared in a file listed in a files\[\] declaration of an enabled module's .info file, it will also be available. If it's a regular function in a .inc file, you may have to force it to be loaded with module\_load\_include() or require\_once() or similar techniques.

How do you do it? Just call the function the same way as that module calls the function, the same way as you call any Drupal core function.

Don't forget to make the module a dependency of your module.
> 8 votes

# Answer
The Barcode defines a CCK field, so I recommend going the CCK path: a barcode field in your content type, an appropriate widget to set values and an appropriate formatter to display them.

If you want to do a bit of a theming and put the barcodes where you want them within your node output, you can use

```
print content_format('field_my_barcode', $field_my_barcode[0]);

```

More info at Theming Individual CCK Fields.

If you want to run free, however, and put random barcodes at random places, you can leverage the existing formatters and use the following snippet:

```
if (module_exists('barcode')) {
  print theme('barcode_formatter_default', array('#item' => array('barcode' => '0123456789')));
}

```
> 1 votes

---
Tags: 6
---


title: form_set_error checkbox CCK 2 drupal 6

text:
# Question
Title: form_set_error checkbox CCK 2 drupal 6
How can I highlight the checkbox boxes when be validated a CCK field? (CCK 2.9). Data is validated correctly, and message is displayed correctly in the head of the form, but the checkboxes does not appear highlighted.

```
<?php
$quantity_options = count($form_state['values']['field_checkboxes']);
if ($quantity_options > 2) {
form_set_error('field_checkboxes', 'message.');
}
?>

```

# Answer
> 4 votes
Have a look if the class `error` has been added to your `<input>`. It has on my side, it's the CSS that does not highlight the elements properly.

You can either adjust your stylesheet for `.form-item input.error` or you can use a piece of jQuery to make the parent of the radios styleable, such as

```
$('.form-radios:not(.error):has(.form-item input.error)').addClass('error');

```

Another option would be to add the appropriate class via the Drupal's theming system (`theme_optionwidgets_buttons()`).

---
Tags: forms
---


# Question
Title: how to default value to select list CCK with form_alter
I am usingCCK 2 (2.9), and I know that CCK field give the option to assign the default value using the pipe, for example

```
Please select|Please select

```

But I am just curious about if exist a programatically way to assign a default value to a select list. I have several tries, using this kind of syntax:

```
$form['field_color']['value']['#default_value'] = 'Black'; //or
$form['field_color']['#default_value'] = 'Black'; //or
$form['field_color']['#default_value'][0]['value'] = 'Black';

```

but nothing. To me not is clear what is the correct syntax.

thanks in advance.

# Answer
CCK requires a little voodoo to alter values with a hook\_form\_alter(). You need to implement a special type: `after_build`, so put this code in a `custom.module`:

```
//Declare the callback for after_build for page node form
function custom_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'page_node_form) {
    $form['#after_build'][] = 'custom_after_build';
  }
}

function custom_after_build($form, &$form_state) {
  //For a select list you have to modify this to set default to black
  $form['field_select']['value']['#value'][0] = 'black';
  //if your field is multivalued you can put more
  $form['field_select']['value']['#value'][2] = 'red';

  //for a single text it's a little different:
  $form['field_text'][0]['value']['#value'] = 'black';
  //have a look at the form after after_build
  dsm($form);
  return $form;
}

```

Here are some (a little confusing/complicated but useful) articles regarding this:
> 5 votes

# Answer
Make sure to enable the core *PHP filter* module and a PHP code textarea will show up in your content type field's configuration form, along with guidelines on how to use PHP to set a default value for your field.

In your case, for a select list, it would be something like:

```
  return array(0 => array('value' => 'black'));

```

Remember, the returned default value is supposed to be the select option's value, not label (i.e. the "black" part from the `black|Black` pair in the list of allowed values).
> 1 votes

# Answer
It looks like you were almost there with that last attempt. As Tomka pointed out, be sure you are targeting the option value, not the label.

Here's my working code sample in my custom module:

```
function mymodule_form_alter(&$form, &$form_state, $form_id){
    switch($form_id) {
        case 'the_form_id':
          $form['field_color']['#default_value'][0]['value'] = 'black';
          break;
    }
}

```
> 1 votes

---
Tags: entities
---


# Question
Title: hook_form_alter selecting a default value in a node reference select list
I am trying to add some logic to auto select a node reference option on a select list on my content type. I am trying to set it with the following.

```
$form['field_my_field']['#default_value'][0]['nid'] = 5;

```

Where 5 is a nid. The value is set correctly in the form but when it is rendered to the page the option in the select list is not selected.

What am I doing wrong?

# Answer
> 2 votes
CCK requires a little voodoo to alter values with a hook\_form\_alter(). You need to implement a special type: `after_build`, so put this code in a `custom.module`:

```
//Declare the callback for after_build for page node form
function custom_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'page_node_form) {
    $form['#after_build'][] = 'custom_after_build';
  }
}

function custom_after_build($form, &$form_state) {
  //Set my node ref to 5
  $form['field_node']['nid']['nid']['#value'][0] = 5;
  //you can set more than one using
  $form['field_node']['nid']['nid']['#value'][2] = 6;
  //have a look at the form after after_build
  dsm($form);
  return $form;
}

```

I adapted a previous answer of mine, but I have to admin that node reference is even more confusing ;)

# Answer
> 1 votes
According to docs you should:

```
'#default_value' => variable_get('field_my_field','5');

```

btw, maybe use javascript is the easiest way?

# Answer
> 0 votes
Assign a direct value to it. e.g.

```
$form['field_my_field']['#default_value'] = 5;

```

---
Tags: nodes, entities, 6
---


# Question
Title: I'm trying to retrieve a custom content type onto the user profile page
I'm using D7. I have a custom content type that I need to relate to the user. The user will set up and maintain this page themselves. i.e. Each user has one page of content for this content type.

When a user profile is viewed though I need to show the relevant page that relates to the the user.

What's the best way of doing this in D7? I'm guessing it's something to do with creating a block view and then using contextual filters. I've managed to get a block view that does this within the preview but I can't get any further than that in terms of linking it to a user profile.

There is the possibility of linking the user name to the content title. In fact if the two were intrinsically linked it would be better. Ideally I would have used the profile 2 module but I'm using location ( doesn't work with users in D7 ) and FiveStar ( doesn't work with users in D7 ).

Any suggestions on where to start looking to solve this would be appreciated.

# Answer
Have a look at the Profile 2 module. It replaces the Content Profile module from Drupal 6 and the profile module that is build into Drupal Core.
> 1 votes

# Answer
You could create a node reference on the profile and populate it with an empty node, when the profile is created. Then it's just a matter of theming when it comes to displaying that node on the profile page.
> 0 votes

# Answer
I've managed to solve this. Here's how I did it.

In Advanced settings:

First, I created a relationship in the view to link the content to the user profile. This was achieved by selecting content:author.

Next I created a contextual filter using this relationship on user:id.

On Page Settings:

I then set the path up to be user/%/content, this allows the user page to bring up the relevant content that the user has posted.

Finally, I created a menu tab on the user menu.

Job done!

Next I need to find a way to ensure that each user can only create one page of the relevant content. Any suggestions?
> 0 votes

---
Tags: blocks, users, views, nodes
---


# Question
Title: Why does Drupal use the database for the cached data?
Why Does Drupal put the cached data in the database? It's hard too understand it, because the database can easily cause performance bottleneck.

# Answer
> 8 votes
Drupal core comes out of the box with a good caching system that will handle low level usage. Using the database as cache, you could easily create a site with hundreds/thousands of daily visitors, which is enough for many. This is a good default, as it's easy to setup, but more advanced caching strategies for high performance are supported:

* For both Drupal 6 and 7 there are modules to improve caching by using memcache instead the database for some of the caching.
* For Pressflow 6 and Drupal 7 core you can setup external cache like Varnish.

So Drupal really has a lot of caching possibilities, but in order to use the more advanced for high performance, you need to do some extra work. This will also require various server setup anyways. But making the default easy to use really is preferred.

# Answer
> 11 votes
The question that asked here is not whether the database cache can be replaced by something else, but why Drupal caches database information in the database. A reason that is not mentioned here is that although database information is again cached in the same database, it is not cached in the same format. The original data, such as node information or theme information, is stored in a kind of normalized form, which makes it easy to edit and query data. The cached values are stored in a way that reduces the amount of processing needed to display a page.

Let's say a page view consists of the following simplified steps:

1. Fetch information from database
2. Manipulate information to make it suitable for display
3. Display the result

Now Drupal stores the result of step 2 into the database, so on subsequent page views, steps 1 and 2 do not have to be executed. This saves time and processing power. When the original data changes, the cache needs to be cleared.

# Answer
> 5 votes
Fetching cached data from the database is easy and fast enough because they are simple SQL requests. Also, most of the results are cached in memory by the SQL caching system.

There are also other caching system, but they are not as good as database for a default caching system:

* File system: you have to deal with data coherence, file permission, file lock, file management.
* Memory: is faster than database, but you need extra setup. Thus this one should not be the default caching system.

# Answer
> 4 votes
Well in fact the drupal cache system is pluggable in drupal6 and drupal7, which means that you can put any kind of caching system behind it.

By default drupal uses a database based caching system, but you can replace it for example with the memcache module with a memcache, which scales much better then the database for the cache.

If you want you could even write a file based one, which will probably be must slower.

# Answer
> 2 votes
A very simple explanation is that it provides a caching interface which improves performance which, by default, doesn't add more layers to a Drupal site. Other caching mechanisms may be better or faster, but they would introduce additional requirements which would not be needed for many Drupal sites.

Luckily, the caching system can be swapped for those who need it.

---
Tags: database, caching
---


title: Facebook Canvas-friendly Theme

text:
# Question
Title: Facebook Canvas-friendly Theme
I'm very new to Drupal and web dev in general (J2SE C/ObjC background). I've just installed Drupal For Facebook. With its help I'm able to get my FB App to get its content from my Drupal site. However, none of the standard Drupal themes seem to format nicely for facebook.

My criteria are:

* formats pages to \< 520 pixels wide (main criteria)
* shows the page contents but very little else (no breadcrumbs or menus)

I thought about writing my own theme to achieve this end. But I thought I'd ask if there's anything readily available out there that I can use, since I can't be the first guy that wants this. Or if there's a way to constraint the page width and hide the menus and breadcrumbs using only CSS trickery, I'd love to know about it too (mind you I'm an HTML noob here)

Gracias

# Answer
> 3 votes
My thoughts in a nutshell:

* Start with the Zen base theme
* Sub theme this with your custom theme (there are instruction in the Zen theme on how to do this)
* Use a fixed width option, and resize the main column to 520px
* Add CSS to spice it up and give it colours etc (out of the box it is fairly boring colour wise)

In order to hide breadcrumbs you can override the page.tpl.php to not display them.

---
Tags: social-network
---


# Question
Title: Can views pages be indexed and be searchable by apachesolr?
By default drupal will only send nodes to apachesolr, is there a way to send views pages to solr, so that they may show in the search index?

I know this question seems a little out there, just looking to see what clever minds within Drupal think about what can be done here.

# Answer
> 3 votes
Thought I would post about how we ended up solving this:

* Installed the module https://drupal.org/project/viewfield (which has a 7.x-dev release)
* Created a new content type called 'Section Overview'
* Added a viewsfield to the content type 'Section Overview' that allows the author to choose the view they wish to embed from a dropdown list
* Told apachesolr to index nodes of type 'Section Overview'

In the end it was not that hard, just took some lateral thinking.

# Answer
> 2 votes
Yes, there's a (half-finished Drupal 6) module for it too: http://drupal.org/project/apachesolr\_views

\** DISCLAIMER - I've never actually used this. Just know of it, considered it recently. ;-)

# Answer
> -3 votes
Solr indexes your content. Views displays your content. The stuff that views can display....is still content. You build views from the indexed content, not build an index from a view. Solr indexes your db, and doesn't parse pages.

---
Tags: 7, views, search
---


# Question
Title: What is the best way to submit form values and output on an unthemed page?
I am writing a custom module that will be used to print consignment labels for a shipping provider.

The labels print 4 to a page. The module provides a form that allows the user to specify the number of packages, the dimensions etc then prints a label for each package. I will want to format them with CSS so that they print correctly to the label peel off sections etc

One way I had worked out to do this was to have a second form on the page which submits to a PHP file in my module directory. I place the code in this PHP page to process the labels and output which I can then print from.

This solution works, however it is outside of Drupal in that the form posts to a standalone PHP script. Is there a way to do this within Drupal? I have looked at the Print, PDF module but I dont know if I can configure it in this way.

# Answer
> 1 votes
If you want to break out of the theming system and display your own markup for a page you can do so.

Simply print whatever you want in your callback and rather than returning the content do an exit;

It isn't very elegant but it will do the job.

# Answer
> 0 votes
A simple solution is to store submitted data in `$form_state['storage]` and rebuild then form. Then in form function, you can check to see if the `$form_state` has the submitted data and display the result instead, or the result and the form.

---
Tags: forms
---


title: Views, multiple pagers on same page

text:
# Question
Title: Views, multiple pagers on same page
I have multiple views with pagers on same page. But all of the pagers using the same GET argument "page", so when user chooses a page in first pager, all of the pagers changing their state to those page. How can I make things work? Drupal 6, Views 2.

# Answer
Change the ID used for the pager: The setting is under the advanced options for the view, in the administration area.
> 11 votes

---
Tags: views, paging
---


# Question
Title: In "Status report" it just outputs the string "version", which causes problems when querying Drupal version
When I go to "**Status report**" menu, only the string "**version**" is getting printed, which can cause problems with some modules like Webform.
I have Drupal **6.22**, but in the "Status report", Webform writes *"Webform requires at least version 6.16 of Drupal core."*, which means the problem above can be a possible reason.
How can I fix that?

Here are some screenshots:

---

EDIT

The file `system.module` contains

```
define('VERSION', '6.22');

```

on line 11, which is correct, BUT the return value of this function was `bool(false)` (after checking it with a `var_dump()`), which means a failure (like when this was defined earlier or sg similar). After that, I put the following line **BEFORE** the above mentioned define function:

```
var_dump(defined('VERSION'));die();

```

and it gave back `bool(true)`, which means this constant has already been defined!
I still don't know where, why and how...

There's a function with the name `_drupal_bootstrap_full()` (in /includes/common.inc, line 2673), in which `module_load_all()` function is called. The "`VERSION`" constant is defined after calling this function (and its value is "version" then), but knowing that doesn't make an advance.

# Answer
> 1 votes
I think I found the answer to my own question, after a long investigation.

**It's a "bug" (or a programming idiocy)** in the **JW Player Module**!!!

**As soon as I disabled it, I went to "Status report", and everything was OK!!**

Here is the proof, look at this (since asking my question, I modified the admin theme):

BUT as soon as I reenable JW Player Module, version number is wrong again!
Here's a screenshot after reenabling the module again:

I think I should report this bug...
Hope this helped someone who uses JW Player Module.
I try to find the code in the module where this problem occurs, I will tell if I found it.

---

EDITING:

Since then I can see that this bug is already reported on Drupal's official site!
Here's the bug report: "Constant VERSION already defined".

The source of the problem is in the 18th line of the file `/modules/jwplayermodule/jwplayermodule.module`:

```
define("VERSION", "version");

```

I don't really understand why there was a need to do that, but the programmer who put this line into this file deserves a kickass! :) It cost me a couple of hours.... and it absolutely doesn't make sense that it's in the code - for example, a JW\_PLAYER\_VERSION constant could be used, or any other constants that is NOT in Drupal core...

# Answer
> 2 votes
That is weird. What does line 11 of the file `modules/system/system.module` read? For me, it is `define('VERSION', '6.22')`. How did you obtain the Drupal source files? Via a zipfile or through a git check out perhaps?

# Answer
> 1 votes
I can only reproduce that behavior by changing `modules/system/system.module` like so

```
define('VERSION', 'version');

```

When I remove the line altogether the Status report page contains string `VERSION` in uppercase...

You may want to have a look in your `modules/system/system.module` ;-)

---
Tags: webforms
---


# Question
Title: Adding classes to menu items to signify what level they are
How can I add classes to the `<a>` or `<li>` tags of the main menu to signify which level they are in the menu hierarchy (e.g. "level-1", "level-2", etc.)? The code below shows the first link has 3 sublinks (dropdown):

```
<ul class="menu">
  <li class="first expanded">
    <a class="level-1" href="#" title="">Top link</a>
    <ul class="menu">
      <li class="first leaf"><a class="level-2" href="#">Dropdown 1</a></li>
      <li class="leaf"><a class="level-2" href="#">Dropdown 2</a></li>
      <li class="last leaf"><a class="level-2" href="#">Dropdown 3</a></li>
    </ul>
  </li>
  <li class="last leaf">
    <a class="level-1" href="#" title="">Another top link</a>
  </li>
</ul>

```

# Answer
> 7 votes
You can use `theme_menu_link()` in Drupal 7.

```
function MYTHEME_menu_link(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';

  $element['#attributes']['class'][] = 'depth-' . $element['#original_link']['depth'];

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}

```

Here I added:

```
$element['#attributes']['class'][] = 'depth-' . $element['#original_link']['depth'];

```

Which will provide a class on the list item with the menu depth.

# Answer
> 3 votes
Modifying classes and markup in the menu structure is not very easy (at least not in Drupal 6 and I think Drupal 7 is the same). The problem is that in order to know what lever you are printing, you need to handle the creation of the menu pretty much by your self.

With the proper CSS, you don't need such indication, as you an use the nesting instead:

* `ul.menu li a` Level 1
* `ul.menu ul li a` Level 2
* `ul.menu ul ul li a` Level 3

This is not elegant, and can make matter more complicated than needed, but it's a simpler solution than having to deal with the Drupal menu system.

---
Tags: navigation
---


# Question
Title: Is the "Count content views" settings related to the "Discard access logs older than" option?
My question is related with statistics module to know the "most popular" content.

I have enabled the Statistics module (Core Drupal). As you already know, to get this statistics is necessary enable the option "Count content views" in "Access log settings"; also, in "Access log settings," I saw the option, "Discard access logs older than" necessary to set time to log statistics.

According to your experience, are these statistics related with the interval of time indicated in the "Discard access logs older than" option, or are statistics of all "content views" since that statistics module was enabled?

According the code of statistics.module (line 54), the behavior expected is only add one value per visit, and nothing about use an interval of time to calculate some value; but in the "Access log settings" page it seems that this interval of time is related with the option "Discard access logs older than." Are the most popular articles tied to this interval of time?

# Answer
> 2 votes
According my review, I confirm that "Most popular" default statistics (Drupal 6), give the "most popular" "al time" since "Count content views" option was enabled.

So, I reviewed several modules like Statspro, Visitors, Quickstats, Reports and Radioactivity, and I chose Radioactivity to solve this. Radioactivity give results, per day, very close to Analytics.

---
Tags: nodes
---


# Question
Title: Changing navigation depending on authentication status
How can I change my menu items depending on whether the user is logged in or not? For example, I would like my secondary navigation to have a "sign in" link if the user isn't authenticated and "log out" if the user is authenticated.

Thanks! Jane

# Answer
Drupal's menu system checks the permissions of menu items that it connects to. So, depending on the permissions of your content you could use the same menu for users with different roles. Also if you use the path "user/login" in a menu and name it "Sign in" it will only show up when users are logged out. Similarly a menu item with "logout" as the path will only show up when a user is logged in.
> 1 votes

# Answer
Check out Menu per Role Module. This module allows you to restrict access to menu items based on user roles. Once enabled, there will be a new fieldset that allows you to restrict access by role. The fieldset also appears in the node edit form.
> 3 votes

---
Tags: 6, users, navigation
---


# Question
Title: How to filter the options from a select list field according to a previous select list?
I'm trying to build a content type that has two selectlist fields. My problem is that the first field should filter the second field options

For example:

First field options (This field must filter the next field options):

-Red (Selected)

-Blue

-Green

Second field options would be:

-Apple

-Strawberry

-Cherry

# Answer
Sounds like you need the Hierarchical Select module. Here is a quote about it (from the module's project page):

> ... defines the "hierarchical\_select" form element, which is a greatly enhanced way for letting the user select items in a hierarchy.
>
> Hierarchical Select has the ability to save the entire lineage of a selection or only the "deepest" selection. You can configure it to force the user to make a selection as deep as possible in the tree, or allow the user to select an item anywhere in the tree. Levels can be labeled, you can configure limit the number of items that can be selected, configure a title for the dropbox, choose a site-wide animation delay, and so on. You can even create new items and levels through Hierarchical Select!
> 0 votes

# Answer
Take a look at Conditional Fields module to define dependencies between fields based on their states and values. Conditional Fields allows you to manage sets of dependencies between fields. When a field is “dependent”, it will only be available for editing and displayed if the state of the “dependee” field matches the right condition. When editing a node (or any other entity type that supports fields, like users, terms and files), the dependent fields are dynamically modified with the States API.
> 1 votes

---
Tags: views
---


title: Content Type and Sub Pages?

text:
# Question
Title: Content Type and Sub Pages?
I have a drupal 6 instance and I want to make it so when I create a content type (for example movies) it would create 2 sub pages (reviews, and photos). So if I went to

www.site.com/movie-BLAHBLAH/ it would load the node content type info and

www.site.com/movie-BLAHBLAH/reviews/ it would display a page where I could theme the page.tpl.php file to do what i want it to do. and same with the other one.

Is this possible somehow?

# Answer
For Drupal 6, there is the CCK Fieldgroup Tabs module.

> Display CCK fieldgroups in tabs. Enables splitting up content onto tabs in both editing and display.
> Requires Tabs module as well as Content and Fieldgroup modules, part of CCK. For Drupal 5.x, Tabs module is part of Javascript Tools. For Drupal 6.x, Tabs is a separate module.

That project is seeking new maintainers and no longer developed by its maintainers. It does not have any release for Drupal 7 or more recent Drupal releases, which means that, as the project page for that module suggests, a Drupal 7 or a Drupal 8 site should use the Field Group module, which is now compatible with Drupal 9 and Drupal 10.

> Fieldgroup will, as the name implies, group fields together. All fieldable entities will have the possibility to add groups to wrap their fields together. Fieldgroup comes with default HTML wrappers like vertical tabs, horizontal tabs, accordions, fieldsets or div wrappers.
> 1 votes

# Answer
Yes you can do this. Just like the node module has create an url where all nodes are visible: `node/[nid]` you could create path for `node/[nid]/review` and create a custom page that display the reviews for that node.

This is done by the use of `hook_menu`.
> 1 votes

# Answer
It sounds to me like what you really ought to do is create 3 content types, movies, reviews & photos. And use something like references or relation to keep them related to each other.
> 0 votes

---
Tags: nodes
---


title: How to put User Profile in a Block?

text:
# Question
Title: How to put User Profile in a Block?
I know this is simple but can't find the answer. I'm just wanting to put the contents of user-profile.tpl.php in a block. No extra formatting or anything. Just pull the information and put it in a block. It can either be in my custom module or by creating a block. Thanks for your help!

After trying the initial suggestion, I received this error message:

```
Fatal error: Unsupported operand types user.module

```

My user-profile.tpl.php doesn't contain the usual information and I should have mentioned that originally. There's a lot to it but I think the problem is here:

```
$account = menu_get_object('user');

```

Since it calls that immediately at the top, it may create a problem. Beyond that, the rest of the user-profile.tpl.php file uses the account variable highlighted above to get a bunch more information.

I'm using the latest version of Drupal which is 7.7 at this time.

# Answer
For Drupal 6 you create a custom block and let the content be:

```
theme('user_profile', $account);

```

For Drupal 7 you do change the code a bit:

```
render(user_view($account));

```

In both cases `$account` if the fully loaded user object who's profile you want to display in the block.
> 2 votes

---
Tags: users
---


title: Theming views page and pagination

text:
# Question
Title: Theming views page and pagination
I am new to drupal and views. I have successfully created views page and understood some basics of it and views theming. I have created a views page for content type(products) listing. Now on the views page i have successfully listed the products. and now i want to theme it and also would like to know how to do pagination for it?

# Answer
> 0 votes
You have to be a bit more concrete when you ask for *how to theme a view*. One thing to note is that views help you with template suggestions (names for templates) which is one of the most common and easiest ways to alter the output of Views.

Pagination can be setup from within the interfacer. There is a pager link you can click on to set that up, if you look around a bit I'm sure you'll find it. The location depends on the Views version you use.

---
Tags: views
---


title: Theming node for views page

text:
# Question
Title: Theming node for views page
I created a new views page which lists specific content types(products). And i have specific node node--products.tpl template file which is being used in views. I want to be able to use specific node template for views. How do i do that?

# Answer
> 1 votes
In the Other section of the views edit form, there is a link "Theme: Information." Inside that link there is a list of the many ways to template the view output. As always when theming, you start by copying the base file (e.g., views-view-unformatted.tpl.php), and make your modifications to the copy. Follow the naming conventions given in the link exactly. It can sometimes be tricky to get the dashes correct. Double-dashes are used to separate sections within the filename but single dashes are used to replace single underscores in content names. For example, for a content type named article\_ratings, the template file would be named views-view-unformatted--article-ratings--default.tpl.php.

---
Tags: views
---


title: Not all strings are translated

text:
# Question
Title: Not all strings are translated
With Drupal 7, we have a custom module that displays a form that will work in both English and Spanish. Throughout the form we used t() to translate the text, and it works in all but two places. One is in the form when we declare a fieldset, and the other is the menu entry declaration (which isn't using t()). For the menu entry we have '\[SiteName\] Events' like this:

```
$items['sitename-events/register'] = array(
    'title' => 'SiteName Events',
    'page callback' => 'sitename_events_event_register',
    'access arguments' => array('view events'),
    'file' => 'public.events.inc',
    'type' => MENU_NORMAL_ITEM,
);

```

For the form, the element is declared like this:

```
// Personal Information
$form['personal'] = array(
    '#type' => 'fieldset',
    '#title' => t('Personal Information'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
);

```

Other pages are translating just fine, as well as other elements in the form, including the other field sets. What would cause these two entries to not translate, and is there a way that I can force them to translate since we're only going to support English and Spanish?

# Answer
> 4 votes
The literal strings that are passed to `t()` are not directly translated from the function; the function just searches the provided string in the databases used from the Locale module ("locales\_source" and "locales\_target"; see locale()). Before searching in that databases, `t()` checks the Drupal variable `locale_custom_strings_<lang_code>`, where `<lang_code>` is the language code for the language to which the strings are translated.

In the first case, the strings are imported from the translation files. In the second case, the Drupal variable can be set in the settings.php file.

As you want to have the translation for strings used by a custom module, the first method (creating a .po file, and then importing it) is probably too laborious, especially because it's a custom module for which localize.drupal.org cannot provide the translation files (the ones with extension .po). The only alternative is to use code similar to the following one in the settings.php file:

```
$conf['locale_custom_strings_es'][''] = array(
  'forum'      => 'foro',
  '@count min' => '@count minudos',
);

```

The strings I used are just an example (I hope I translated the strings in Spanish correctly ); the strings I used already have their translation in Spanish as part of the core translation.

---
Tags: i18n-l10n
---


# Question
Title: Why are there so many different ways to translate menus?
I'm very confused about the way Drupal 7 translates menu items. I have many modules installed, so I'm not sure which would be relevant to state; in fact, I don't have my head fully wrapped around which modules do what and what they are dependent on.

I'm working on a bi-lingual website, in English and French. I noticed two different ways to create menues with translation. Let me outline the steps and results for both, and you can explain to me why these differences exist and how to effectively apply these differences.

### Method 1

* Go to Structure\>Menu\>(select the menu you want)
* Click Add Link
* Provide a "Menu link title" and "Path"
* **Under language, select English**
* Save
* Translate this menu item into french

### Result of Method 1

* There are TWO menu items under Structure\>Menu\>(select the menu you want), one for each language item. Additionally, I can no longer convert a menu's languge from English or French back to Language Neutral...what's up with that?

### Method 2

* Go to Structure\>Menu\>(select the menu you want)
* Click Add Link
* Provide a "Menu link title" and "Path"
* **Under language, select Language Neutral**
* Save
* Go back to the edit form of the menu link you just saved, change language to English and save
* Translate this menu item into french

### Result of Method 2

* There is ONE menu item for the link you added under Structure\>Menu\>(select the menu you want). But when you edit that menu item, you will see the french translation under the translate tab.

Why is the Result of Method 1 different from the Result of Method 2? Why is it that in Method 1, each translation is a new menu item, but in Method 2, translations are grouped together?

It is so easy for a user to forget to select a language when creating a menu item, which unintentionally creates a parallel track of information in the site (it's almost like a duplicate site where we lose the correlation between english and french pages ). Fixing this after the fact would be so troublesome!

# Answer
Method 1 points to the node translation. Method 2 is a translation of the link but goes to the same path. For most people method 1 is the way to go. But method 2 could be handy as well.

Maybe life would be easier if you just build it in one language and use Google Translate Elements JS addon. It really depends on the needs of your users. For my client I had to use method 1.
> 4 votes

---
Tags: routes, i18n-l10n
---


# Question
Title: Specific node is being attacked by spam comments. What do I do to prevent it?
My site is being heavily attacked by spam bots and this is taking place only on one specific node. All other nodes are safe or the spam there is being blocked by Mollom. How do I prevent further spam comments from being posted over there? Do you have any idea?

# Answer
> 1 votes
If you don't care if nobody can comment on that node anymore, you could disable comments for that node. Go to the edit form and below "Comment settings" (assuming D6, slightly different in D7 but basically the same thing) change the value to "Read only" or "Disabled".

# Answer
> 1 votes
You could possibly

1. disable comments for the given node, as mentioned by the previous user
2. block by IP (link)
3. install and enable CAPTCHA and it's "submodule", reCAPTCHA (the reCAPTCHA service is provided by Google), which effectively prevents spamming attacks when using forms (a spambot can't read the constantly changing texts with various forms).
Note: after enabling reCAPTCHA, you have to sign up for a free key here, and set the appropriate values on the admin page `http://`<yoursite>`/admin/user/captcha/recaptcha`.
4. use Honeypot module, as suggested by @*geerlingguy* in his comment, which are *"are effective against many spam bots, and are not as intrusive as CAPTCHAs or other methods"* (quote from the module's page).

---
Tags: comments, advertising
---


# Question
Title: How to add nofollow attribute to links in profile text field and url field
I add 2 fields via Profile module,one is textarea field names "About me", the other one is url field names "my website". My questions is how to add nofollow attribute to the links in these 2 fields. I googled for a while but without luck.

# Answer
> 2 votes
In your link field settings, there is a setting...

Rel Attribute rel = " "

When output, this link will have this rel attribute. The most common usage is rel="nofollow" which prevents some search engines from spidering entered links.

---
Tags: users, 6
---


# Question
Title: Why are some of my modules reporting missing inter-module dependencies after migration?
I'm troubleshooting modules after a host migration--did I miss something? Before I changed my host I backed up MySQL database, made a list of all my used modules and burned a dvd of the Drupal root directory. Now, after I've successfully restored the database of 5/6 sites, three modules report missing inter-module dependencies within their module groups:

* **Event-** Calendar Signup - 6.x-2.x-dev - Depends on: Signup (missing)
* **Rules-** Rules Simpletest - 6.x-1.4 - Depends on: Simpletest (missing)
* **Services -**
    + **servers -** REST Server - 6.x-3.0-rc1 - Depends on: Autoload (missing)
    + **authentication -** OAuth Authentication 6.x-3.0-rc1 - Depends on: Oauth\_common (missing)

How can these other modules be missing if they were there before the migration? The folders are still the same. Do some modules "make" other modules in the database? Something like cTools 'makes' the css directory.

All of my sites are in the sites directory and share the same modules, though they each have their own database. Each is missing the same module dependencies.

# Answer
Are those missing modules in your sites/all/modules folder? I'm not sure why they would have been left out of a file migration, but anything's possible.

Modules do not 'create' other modules (except possibly Features, I haven't used that in awhile) in the sense that you're referring to w/ the cTools example, though there are modules that exist as part of the parent module package.
> 0 votes

---
Tags: 7, migrations
---


# Question
Title: How do you embed addtional RSS feeds into the <head> section of your theme
I have 5 RSS feeds I am looking to embed into the `<head>` section of the page. What is the best way to accomplish this on drupal 7?

# Answer
You can use `drupal_add_feed()` or if you don't want to have an icon appear on the page itself

```
 drupal_add_html_head_link(array(
    'rel' => 'alternate',
    'type' => 'application/rss+xml',
    'title' => $title,
    'href' => $url
  ));

```
> 5 votes

---
Tags: 7, theming, feeds
---


# Question
Title: How do I rename a field name of a table?
I need to rename one of my fields in a table via a .install file. How can I to do this ?

**Let us consider I have a table called "register" and field name called "fname". Now I need to change the field name "fname" to "name". How can I do this using a .install file?**

We can add a field for a table using the below syntax :

```
db_add_field($ret, 'table_name', 'field_name', array('type' => 'varchar',
             'length' => 255, 'not null' => TRUE,));

```

What is the syntax for doing a field rename?

# Answer
> 2 votes
Using db\_change\_field.

Under the parameter section:

> $field Name of the field to change.
>
> $field\_new New name for the field (set to the same as $field if you don't want to change the name).

---
Tags: database
---


# Question
Title: Drupal 6 as a call logging system - question about node performance & scalability
We currently use Drupal as a Knowledge, communications and assessments system for our call centre agents and it is working great. However there has been a request that this to also handle our call logging.

We utilise profiles to allow manager roles to check their team members assessment scores and what communications they have read, the idea is that they could also do the same with calls taken.

My concern here is that this will **dramatically increase the number of nodes** from what we have now (articles, comms etc are all created by our team so nodes will be within the 1000's).

If we employ Drupal for logging calls this would mean that our 1000's of agents would be creating dozens of call logs per day. This potentially would push nodes up into the 1000000's.

Would Drupal and its node / cck be able to cope with this type of load where 1000's of users would be submitting dozens of nodes simultaneously?

# Answer
> 2 votes
This is quite a subjective question. Your best bet would be to ask on some of the Drupal groups that handle this stuff like Drupal High Performance.

There are so many factors in making a drupal site scale it's hard to list them all.

Pressflow is a drupal distro that is built for scaling, they also have some great blog articles on scaling.

---
Tags: 6, nodes, entities, performance
---


title: Filter two vocabularies in Drupal 7

text:
# Question
Title: Filter two vocabularies in Drupal 7
I want to do a similar filter like at this page: http://www.nasdaq.com/screening/companies-by-industry.aspx?industry=Technology

I have two vocabularies. Countries and Industryes. We chose an industry, and then we choose from what country we want the company. It show me a firms, witch are in one industrie, an example Technologies and in one country, an example Afrika. Not all countries, not all industries. Can someone help me with this? I´m sorry for my english. I will be grateful for any help. I use Drupal 7.

# Answer
> 1 votes
This is not a standardfeature of Taxonomy. In fact, it is not a part of the *concept* Taxonomy, regardless of using Drupal at all.

However, you can achieve this, somehow with Drupal taxonomies, when you abuse them as Facets.

For that, you need to set up your views and provide quite some hacks, amongst others, you need to add some PHP to your views.

From a birdseye, here is what you do:

* You create views that list only nodes with term X as parameter: `/mypage/12` to show only pages with term 12.
* You allow Drilling down in that list, by nesting the parameters: `/mypage/12/35` to show only nodes with BOTH term 12 AND term 35.
* You abuse the views header to present links with options: links to the nested options: on `mypage/12` it would show, amongst others, a link to term 35, a link to `/mypage/12/35`.
* The code to select these options can be simplified by making a second view: a view that lists all options nested under 12.
* In the header of the first, node, view, you then place some PHP that fetches and renders these links.

For a long and detailed howto, I think burningbird has a good manual

---
Tags: 7, views
---


# Question
Title: What happens if you leave out an `access callback` specification?
In a custom module, if you have a menu hook item that has a custom access argument, but don't specify an access callback, what is drupal's default behavior? Does it use `user_access`? In other words, is an access callback necessary to specify?

# Answer
> 2 votes
Yes it uses user\_access() by default, but only when you specify 'access arguments'. See http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook\_menu/7.

# Answer
> 1 votes
Drupal will use `user_access()` as default value for the access callback, if the menu item doesn't inherit the value for the access callback from the parent menu item, and you define the access arguments.

This is an example of menu item that inherits the access callback from the parent menu (the menu items are defined in node\_menu()):

```
  $items['admin/content'] = array(
    'title' => 'Content',
    'description' => 'Find and manage content.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('node_admin_content'),
    'access arguments' => array('access content overview'),
    'weight' => -10,
    'file' => 'node.admin.inc',
  );
  $items['admin/content/node'] = array(
    'title' => 'Content',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );

```

The second menu item doesn't define neither the access callback nor the access arguments, but they are inherited from the parent menu item.

---
Tags: routes, users
---


# Question
Title: I can't translate the text <Any> in a form select list
I just can't translate the text in a form select list. I need it to be translated in spanish lang. I tried to translate it using the translate interface but I couldn't find it. Please take a look a the capture:

# Answer
There seems to be a problem translating strings with "\<" and "\>" in them, which is odd, but anyway:

http://drupal.org/node/348130
http://drupal.org/node/663156

If it's a Views related problem, at `admin/build/views/tools` you can change **Label for "Any" value on optional single-select exposed filters:** to *\- Any -* (instead of *\<Any\>*) and translate that.
> 3 votes

---
Tags: i18n-l10n
---


# Question
Title: User registration with content profile + data manipulation on submit
I'm actually using a type with content profile in my user register form, and I'm trying to manipulate both the user and node data after submitted and inserted in database. I'm supposed to use hook\_user with $op insert/after\_update/update, but I dont get any data from my content profile node, just the user data, and I also tried hook\_nodeapi also with $op insert/update, but got no success too.

I have a custom module, and also tried to change the weight in system, to be executed before the content-profile module.
This is driving me nuts!

Do you have any idea on how I can manipulate that in the user register submit?

# Answer
> 0 votes
basically I had this problem, because I didn\`t get my user register to be saving correctly the user or even the content profile... after a deep research over the google, i found a couple of instructions that solved my problem...

if you wanna checkout, see it at my blog: http://nunesweb.com/blogs/2011/07/12/integrating-content-profile-user-registration-drupal-6

thx lnunesbr

# Answer
> 1 votes
I use hook\_nodeapi() with the operation ID (`$op`) equal to "insert" (conditionally for the content profile content type) and then get at the user data with `$account = user_load(array('uid' => $node->nid))`.
Then, I do as I please with both the `$node` and `$account` data.

---
Tags: 7, users
---


# Question
Title: Displaying view as row-based table, not as grid
Currently I have my view style set to grid (row style); but they're not displayed too nicely. Is there anyway I could modify the views grid php file so that I can have them displayed as a real table? If you set the view to table, you get all your fields as columns. I want to have something like

```
Feature A          x
Feature B          y

```

etc. so that they display nicely in a table view in iOS.

# Answer
> 0 votes
You can probably achieve this with CSS, rather than modifying the PHP - or are you saying you want to output as an actual HTML table? Views should do that for you.

# Answer
> 0 votes
If you want to change the markup, just have a look at your theme information from Views. There it will tell you what templates you need to override in your theme. You're probably looking for views-view-grid.tpl.php

Btw, theme information should be on the left column of the Views UI when you're editing your view. You need to press the link and it will load the information underneath.

---
Tags: views, theming
---


# Question
Title: Passing in URL parameters to menu callbacks
I implemented `hook_menu()` to create a new path called 'user-login'. The page callback function receives url parameters like `$_GET['parameter']`; however, when I go to http://site.com/user-login?parameter=test, I get a 404 error. How should I implement `hook_menu()` to get this working?

This is the code I'm using

```
/**
 * Implementation of hook_menu()
 */
function login_menu() {
  //$items = array();

  $items['user-login'] = array(
    'title' => 'External login',
    'page callback' => 'user_login_callback',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );

  return $items;
}

function user_login_callback() {

  // Get the URL params
  $uid = urldecode($_GET['uid']);
  $expiry = urldecode($_GET['expiry']);
  $provided_hash = urldecode($_GET['hash']);

}

```

Page would be called like http://site.com/user-login?uid=2?expiry=3?hash=sd7wdah

# Answer
The drupal menu system does not care about $\_GET arguments, you can do whatever you want with them, it doesn't affect the hook\_menu() implementation \**.

So, the error lies somewhere else. The result of hook\_menu() is stored, it is not called on every page. If you change/add anything in that function, you need to rebuild the menus. The fastest way to do that is using the drush command "drush cc all" or "rebuild menus" in devel.module's Development links block. You can also submit the modules page, though.

\** That said, it is much more common to pass arguments *through* the menu system as additional path arguments. Anything passed after the path will be passed as arguments to your page callback automatically. So calling user-login/2/3/sd7wdah will pass these three arguments to your function as user\_login\_callback(2, 3, 'sd7wdah'). You can also make these arguments required by specifying the path like this in hook\_menu(): `user-login/%/%/%` and defining the path arguments like this: `'path arguments' => array(1, 2, 3),`. This will make sure that your function can only be called with these three arguments and that they aren't optional.
> 4 votes

# Answer
Just for clarity,

http://site.com/user-login?uid=2?expiry=3?hash=sd7wdah

will not work, it should be:

http://site.com/user-login?uid=2&expiry=3&hash=sd7wdah

Note how there's only one "?" and each additional parameter is separated with "&"
> 1 votes

---
Tags: 6, hooks
---


# Question
Title: Is there a way to disable the js of the Views Display Tabs module without hacking the module?
I'm using Views Display Tabs module and it works really well. My problem is that I'm using Views exposed filters as a block. When I switch between tabs the filters don't get updated because they are in a block and the module uses js to switch between tabs, so the page doesn't get refreshed. I would like to know a way to disable the js functionality of the module without hacking it. Ideally the module would have a setting for this.

# Answer
> 1 votes
The standard practice for adding javascript is to use `Drupal.behaviors` to execute your modules code when appropriate.

This gives an easy way to override modules javascript by redefining that modules behavior. For Views Display Tabs I took a look at their javascript source to see that the behavior was called `Drupal.behaviors.viewsDisplayTabs`.

So now you can add your own javascript to override this:

```
//Override Views Display Tabs javascript
Drupal.behaviors.viewsDisplayTabs = function() {}

```

---
Tags: views
---


# Question
Title: Drupal CMS - Find Content - how to drop the ?destination=admin/content in the edit link?
I'm using drupal 7. When I go to the CMS at the url `http://mysite.com/admin/content`, the edit link for each of the content records are

`http://mysite.com/node/206/edit?destination=admin/content`

I want to convert the url to:

`http://mysite.com/node/206/edit`

How do I do this?

The reason I want to do this is because I want the user to always see the result of his work after he's saved it. Additionally, there are important Call-To-Action requirements on the `/node/206/edit` page that appear immediately after saving a record. These CTA requirements are not available in the admin/content area.

**Additional Info** I applied a bandaid solution for now. I went into my admin theme at `/theme/nameoftheme/page.tpl.php`, then I replaced the statement

```
<?php print render($page['content']); ?>

```

with

```
<?php print str_replace('/edit?destination=admin/content', '/edit', render($page['content'])); ?>

```

Can someone please provide me with a more elegant solution, so I don't have to use this band-aid solution?

# Answer
> 1 votes
This is a result of the content editing screens returning the user to that. If they edit content from the front-end, the destination is the node.

You can override that default content manager with a View configured the way you want it. The 'Edit' link won't have a destination in the URL, and if I recall, it will return the user to the content after editing.

Also, if this is D6 and they have access to this page it sounds like they have administer nodes access. You might want to tune the permissions differently and setup a view so you can override admin/content path(s) with your View to override the content manager.

---
Tags: 7, nodes
---


title: do predicates in Ubercart really work?

text:
# Question
Title: do predicates in Ubercart really work?
I´m trying to update a shipment cost for different zones of a country (using predicates, conditional actions)

Using the trigger Getting shipping quote via Flat Rate class uc\_flatrate, activated , I´m trying to modify the rate..

Still the trigger doesn´t get called, I tried to modify the objects with php , didn´t work , then i tried a simple test to display a message to the user, didn´t work..

then I tried to write a simple text into a file to see if the event gets called... didn´t work

How can I run a php script when I press calculate shipment cost? (or whenever the shipment cost is calculated) ?

# Answer
> 1 votes
To directly answer your question, **yes**, Predicates work. I use them extensively at a D6 Ubercart site of mine. Aside from that, my store is all digital goods, so no shipping.

# Answer
> 0 votes
If you have:

CountryA

* Zone1
* Zone2
* Zone3

CountryB

* Zone1
* Zone2
* Zone3

Where Zone 1 and 2 of Country A and Zone 3 of Country B cost the same, then create one shipping method which has the same flat rate, give it 3 conditions under "Order: Shipping Address" - "Check an order's shipping State/Province" and state Zone1, Zone2, Zone3. Make sure you select OR as the operator at the top.

If the other zones are also the same costs, do the same. To have a shipping condition for "the rest of the destinations", you may do either of two methods whichever is fewer: 1.) Select all the state/provinces that already have shipping quotes and negate them, meaning "NOT" these destinations. Or, just keep going with the select destination "TRUE" method.

If you want to complicate things further with different countries and provinces, you can sort out the conditions and "override" the rules using weights for importance of the rule. Lowest weighted condition will triumph. Have a think about the best method to sort your shipping rules.

---
Tags: ubercart, rules
---


# Question
Title: Views - sticky items per page paginated using several displays (Hooks or UI way)
Hi and thanks for take the time to read this post.

(I want to know if exist some hook or User Interface way to make this)

I have two content types (content type X and content type Y), and I want to build one view that have the nodes of content types X and Y, but that shows always sticky items for X content type per each paginated page.

For example: the view will show 10 items per page.

to the first page --\> the first 3 items will have positions 1,2,3 to X content type nodes, and the last positions 4,5,6,7,8,9,10 will have Y content type nodes.

to the second page --\> the first 3 items will have positions 11,12,13 to X content type nodes, and the last positions 14,15,16,17,18,19,20 will have Y content type nodes.

I am reviewing modules like Nodequeue or Weight but I can not understand how to reach this using this modules (i think that this is a useful way with nodequeue: http://www.absolutecross.com/tutorials/drupal/custom-re-ordered-front-page-teasers but my question about how to sort automatically in the required way still is pending)

I must say that I have some aproximation to resolve this using a php snippet in one page: I use one pagination control that handle a SQL query with all results (all content types needed), and the other two SQL queries will call the respective quantity of data to each kind of content type (the sum of results of all individual queries, must be the number in the respective pagination parameter)...it works, but, like I already indicated, I want to know if exist some hooks way, or User Interface way, to make this because I will use several exposed filters that will change SQL queries.

Thanks in advance.

# Answer
> 0 votes
First off, this can all be done in views, no custom code required (yay!). This is accomplished by creating an attachment view which will inherit the pager settings.

First you create a view with a page display that shows 7 Y nodes only.

Second, on the same view, add an attachment display. For the attachment, set it to show 3 X nodes only. In the attachment settings, make sure that `Inherit arguments`, `Inherit exposed filters`, and `Inherit pager` are set to `yes`. Set `Render pager` to `no`. Set `Position` to `before` and set `Attach To` to your page display.

---
Tags: views, database
---


# Question
Title: unblock ip address after failed login attempts?
I have a custom login page that I'm testing the javascript on. The events I'm testing happen after a failed login.

After running a couple tests, I've managed to get my ip blocked because of numerous failed logins!

I have access to the database. How can I unblock my ip so I can continue to test my features without interruption?

# Answer
I presume you are using Drupal 7. Did you check the {blocked\_ips} table?
> 3 votes

---
Tags: users
---


title: Accidentally Deleted Admin Menu Items

text:
# Question
Title: Accidentally Deleted Admin Menu Items
Hi i hope someone can offer me a bit of advice here. I seem to have deleted all my admin menu items. Is there a way to restore them without losing any data on my site?

thanks

# Answer
> 0 votes
Your menu items are probably still there but disabled. In Drupal 6, navigate to *admin/build/menu-customize/navigation* and check if your administrative menu items are enabled. In Drupal 7 the path is *admin/structure/menu/manage/management*.

If you re-enable any menu items, make sure you scroll to the bottom of the page and hit the Save Configuration button to save your changes.

---
Tags: routes
---


# Question
Title: Internationalization (i18n) + Translation Management - No interface for adding translator available
In the **Translation Manager** menu (`http://`<mysite>`/admin/content/translation-management/manage-translator?from=en&to=hu`), when I want to add a translator to a given page, I see the following error message: **"No interface for adding translator available."**.

What should I do?
I think I gave the right permissions to the administrator and another given user (I checked the following permissions in "ICanLocalize translator" checkbox: "submit content for translation", "can do translation jobs", "can view translation jobs", "translate content", and gave "ICanLocalize translator" role to the admin and the other mentioned user), i18n module is installed, so I don't know what is missing.

Here's a screenshot:

# Answer
In the meantime I found the answer: I just realized that ***"ICanLocalize translation service"*** module wasn't enabled.

After enabling, I can see the following:

So I think I can consider my problem solved. :)

---

You could also enable ***"Local translation service"*** module to add your local translators.
> 1 votes

---
Tags: 6, i18n-l10n
---


# Question
Title: Get the nid from current URL after the ? for views argument
I am adding a post to an Organic Group and I want to display a list of all posts to that group below the node add form. The url looks like this:

```
    node/add/group_post?gids[]=23

```

I want to add argument that filters the view using the group's id. How can I use the PHP to get that gid?

This is what I have so far, but it's not working.

```
    $gid = htmlspecialchars($_GET["gids[]"]);
    return $gid;

```

# Answer
Just put `$_GET['gids']` this will return you an array in PHP.
Then if there's only one nid you can make:

```
$gids = $_GET['gids'];
return $gids[0];

```

Source: How to get PHP $\_GET array?
> 0 votes

---
Tags: views
---


# Question
Title: Displaying a text field for the user to embed media, and then enabling rating (fivestar) for that content; listing all of them as separate writings
On a given site's page, which is supplied with the "*casting*" URL alias, I would like to show some embedded videos with a description field, which users have uploaded (embedded) via a simple text field that **Embedded Media Field** processed. These would appear as separate writings, signing the user who uploaded this stuff.
There would also be a rating/voting opportunity (fivestar, thumbs up/down, etc.) with the help of **Rate or Fivestar** module (which one do you suggest?!) to let users vote for the embedded video.

When someone logs in, I would like to **show the form which helps embedding** (or a link to this form) at the top of the page, and below that, there would be the embedded media from the different users.
So the form would be as simple as that: containing a **text field**, in which e.g. Youtube URLs could be copied (it would be processed by Embedded Media Field module) and a **description** textarea to write about the embedded stuff.
The result output would contain these: the embedded media, the description, who this post created and when, and a rating/voting opportunity (five stars, etc.).

How could I do that? What do you suggest for creating a form like that?
Maybe it's not too difficult, but I didn't find the perfect solution, and I couldn't restrict content types to these fields (and with the help of Webform I couldn't add a field of Embedded Media Field).

# Answer
> 3 votes
Why don't you just let your users create a node with this field and a fivestar widget and then you use `node_view()` to display these nodes in your page.

**Updated:**
To embed the node form in a page, have a look at Embedding CCK content type create form in your page, then create a block and put this code in it (select the php format - you have to activate the php filter module first):

```
if(!function_exists("node_object_prepare")) {
  include_once(drupal_get_path('module', 'node') . '/node.pages.inc');
}
print node_add('store_review');  //put the content type machine name here.

```

Then on another page you create a view to retrieve the listing of your videos.

You can also have a look at the Blockify module it may be useful to embed the node form (I'm not sure it'll do the job but can be easy if you're not comfortable with embedding PHP code in a block).

---
Tags: 6, forms, webforms, rating, nodes
---