# Question
Title: The 'publish on' date must be in the future
Is there a way to set the content to be published on future time instead of future date. I get the message "The 'publish on' date must be in the future" when trying to set publish date to today but late at night.

# Answer
> 1 votes
Under

> admin/config/content/scheduler

you can set your date format. What have you set here? Has the date format included time formatting?

The publish time has to be added after the date (that is today).

---
Tags: rules
---


title: Move location of drush

text:
# Question
Title: Move location of drush
Currently there is a .drush folder in my user profile on my mac. However, is it possible to move it into my git repo? How does one move it? If I drag and drop it, then run a drush command, the folder is remade in my user profile folder.

# Answer
No. Your Mac is running a version of the Unix operating system.

Files and directories starting with a dot (.) in Unix are hidden system files/directories and should not be moved or deleted unless you know what you're doing.
> 1 votes

---
Tags: drush
---


# Question
Title: "Manage Display" for taxonomy term does not allow management of the name field
There is a taxonomy with an image associated. It is supposed to display with the image and no title. However, in going to the "Manage Display" section for this taxonomy, the name field is not displayed at all.

Searching for this has proven futile. I can manually remove it by modifying display code but then that leaves no way to change its display from the CMS.

* Why is the name not manageable as part of the display?
* Is there some way to manage the taxonomy term display including the name?

# Answer
> 6 votes
> Why is the name not manageable as part of the display?

Because it's a 'property' of the entity, not a 'field' as such. The 'Manage display' tab is really a 'Manage field and pseudo-field display' tab, it doesn't take properties into account.

This is completely standard and is inline with all core entities. For example, if you check the display settings for one of your node types, you'll notice the 'Title' isn't available there either.

> Is there some way to manage the taxonomy term display including the name?

The simplest way is to manage it with templates, as you've already suggested (and again, exactly how it would be done for all other core entity types).

You could always implement `hook_field_extra_fields()` to expose the term name as a pseudo-field on the display forms; but bear in mind you'll have to link up the logic to hide the titles from the template file yourself, as the core taxonomy module doesn't have that functionality.

I think Add entity properties to "Manage Fields" form is a relevant D.o discussion, there's even some sample code to get you going.

---
Tags: 7, taxonomy-terms
---


# Question
Title: How do I direct users to my custom search?
I'm trying to use hook\_search\_execute to run a custom search inside my module:

```
function mymodule_search_execute($keys = NULL, $conditions = NULL) {
    die; // just to see if we get called
    // lots of lines copied from the hook_search_execute doco
    return $results;
}

```

I can get the default Drupal search form inside my page.tpl.php with:

```
<?php print render(module_invoke('search', 'block_view', 'search')); ?>

```

But, when I click the "search" button on that form, my custom search isn't called.

I'm using D7. What's the appropriate way to actually force a search to get results from my custom search function?

# Answer
> 1 votes
I would use **hook\_form\_alter()** to alter the default search form to call your own submit function.

So, in your custom module do something like this:

```
// Alter regular search box
function YOURMODULENAME_form_alter(&$form, &$form_state, $form_id) {
  if($form["#id"] == 'search-block-form') {
    // Add any additional fields or things you need here

    ...

    // Modify the submit handler that is called
    $form['#submit'] = array('YOUR_CUSTOM_search_submit');
  }
}

```

This actually modifies precisely that block search form, so including the search block just like you've described in the template file should work once you've implemented the form alter.

---
Tags: search
---


# Question
Title: Drupal JavaScript settings versus jQuery.data()
When I writing JavaScript code for my module, I could use jQuery.data() or the setting object passed to the Drupal behavior my module add.

Should a module always use the settings object, or could I use `jQuery.data()` in my module?
Is there any case where using `jQuery.data()` is problematic when used in AJAX code?

# Answer
Personally, I used `Drupal.settings` as a read-only object for communicating settings and configuration information from PHP to JS. Runtime state isn't appropriate here.

`jQuery.data()` should only really be used to pull out data attributes that you have set via PHP, and for setting data that is specific to **that element-only**.

Runtime logic and state should be stored in its own closure. I use a variant of the Javascript Module Pattern, which I have adapted for Drupal. Boilerplate looks like:

```
var FOO = (function(me, $, Drupal, undefined) {
    me.name = "FOO";

    // local properties

    var foo = null;
    var bar = null;

    // local functions

    function somethingAwesome () {
        console.log(me.name + '.' + arguments.callee.name + '()');
    }

    // global properties

    me.baz = null;

    // global functions

    me.somethingAwesomer () = function somethingAwesomer {
        console.log(me.name + '.' + arguments.callee.name + '()');
    };

    // Drupal

    function init (context, settings) {
        if (settings.foo) {
            console.log(me.name + '.' + arguments.callee.name + '()', $.fn.jquery);

            // do stuff
        }

        Drupal.behaviors[me.name] = undefined;
    };

    Drupal.behaviors[me.name] = {
        attach: init
    };

    return me;
}(FOO || {}, jQuery, Drupal));

```

I don't do a lot of true behaviors, though, hence making my initialization function a oneshot.
> 1 votes

# Answer
They're not used for the same thing...

`jQuery.data()` is used for storing data *specific to a DOM element*.

> Store arbitrary data associated with the specified element and/or return the value that was set.

The `Drupal.settings` object is for storing global settings specific to the enclosing page build. It's essentially used to pass data from PHP to JavaScript, not to pass/store data within a a client-side page view.

> ...Drupal's global storage of JavaScript settings. Per-page settings are required by some modules to function properly.

If you want to store data related to a particular DOM element, against that DOM element, then use the `jQuery.data()` method.

If you want to pass global page settings from PHP to Javascript, use `drupal_add_js()` with the 'setting' type (which results in the data being added to `Drupal.settings` in the front end).

You may well find yourself in the position where you're looping through items in `Drupal.settings` in order to save the same data against the appropriate DOM element - that's perfectly normal (in my experience anyway, a more worldly JS ninja might be able to correct me there though).
> 1 votes

---
Tags: javascript
---


# Question
Title: Make the git repo part of the drupal site so I can commit my changes whilst testing
I've got a git repo on my desktop with a couple of make files. I am currently building the drupal site in my htdocs folder by copying the distro.make file there, running the command: `drush make distro.make geoslate_test --working-copy --no-gitinfofile`

and then cding into the geoslate\_test folder and running:

```
drush si vimn_geoslate --db-url='mysql://root:root@localhost/geo_test' --site-name=Geoslate

```

to install drupal.

I would like instead to have the git repo as part of the drupal site, so that I can commit my changes whilst testing on the site build install.

Any idea how I can do this?

# Answer
I found that if I cd into the profiles folder on the Drupal site that has been installed as above, and then commit changes, and push them to git, it also works as if I was committing them from the folder on the desktop which I initially ran the git init on. I read something that said that Drush automatically knows that you are in the directory of a Drupal install, so perhaps this is the resolution.
> 0 votes

---
Tags: users, drush, installation
---


# Question
Title: Module for recommendations based on Solr
I would like to ask if there is any module for recommendations (products,nodes etc) based on Solr.

I have searched on Drupal.org, and I have found Content recommendation modules, which doesn't list any module using Solr.

# Answer
Actually, if you go to Apache Solr's 'Pages/blocks' configuration page at admin/config/search/apachesolr/search-pages, you should see whether your "More like this" (which is like a "Related content") block is enabled.

If it's not, just click on the "Add search block "More Like This" as shown below:

That will take you to a page where you can configure your 'More Like This' block.

* you can title it and call it something like "Similar Products",
* you can define which content types it recommends (if you only want articles, or regular pages or just products to appear in this block) --\> set that in the 'Filters' section which is collapsed by default
* you can configure settings about the word matching it uses to pull up relevant content (how frequently words must appear or excluding words that are too short or too long from being matched on, etc)

Would this default block that comes with Sorl meet your needs?
> 2 votes

---
Tags: 7
---


title: Birthdays migrate to Profile2

text:
# Question
Title: Birthdays migrate to Profile2
guys.

I've this issue, i did migrate a user list from csv file with Migrate module to Profile2. I'd use one only value for the import with the format dd/mm/Y. All was fine, but at the end the birthdays fields are empty.

What is the right way to import (update) my user birthdays.

Thanks!

# Answer
> 0 votes
I might be wrong but I believe (most) dates in Drupal are simply stored as 11 digit integers. The `format` you refer to is only whats displayed on the page. Your migration probably just needs to be moving the integer date data by simply moving the data from your source csv column into your new profile2 Drupal Field:

```
$this->addFieldMapping('csv_birthday_column', 'new_profile2_birthday_field');

```

Then you just use a Profile2 `Manage Display` under the Field UI to setup how you want it to look on the page such as `d/m/Y`.

**EDIT:**

If your CSV has for example "04/15/2013" as a date for a piece of content you could use PHP `strtotime()` in a Migration class `prepareRow()` function to get an integer value to save in Drupal.

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


# Question
Title: How to print multi-value link image CCK field in template?
I have a multi-value CCK field set up using the Link Image Field module, and I need to print all of the images (linked) on the content page. I used the code below to print the images themselves, but cannot figure out how to wrap each image's link around each image.

```
                <?php if ($node->field_day_option_buttons[0]['filepath']): ?>
             <?php
                foreach($node->field_day_option_buttons as $image) {
                 if (file_exists($image['filepath'])) {
                     print theme_imagecache('my image cache preset name', $image['filepath']);
                    }
                  }
              ?>
            <?php endif; ?>

```

Can anyone provide input on how to accomplish that?

Thanks!

EDIT Here is the info placed on the page when I run a print(r) on that cck field:

```
Array (
  [0] => Array (
    [fid] => 347
    [uid] => 1
    [filename] => days-5.png
    [filepath] => sites/default/files/days-5_0.png
    [filemime] => image/png
    [filesize] => 440
    [status] => 1
    [timestamp] => 1366038083
    [list] => 1
    [data] => Array (
       [alt] => Alt Text
       [title] => Title Text
       [url] => http://www.mysite.com
       [target] => _self
    )
    [nid] => 18
  )
  [1] => Array (
    [fid] => 348
    [uid] => 1
    [filename] => days-20.png
    [filepath] => sites/default/files/days-20_0.png
    [filemime] => image/png
    [filesize] => 506
    [status] => 1
    [timestamp] => 1366038108
    [list] => 1
    [data] => Array (
       [alt] => Alt Text
       [title] => Title Text
       [url] => http://www.mysite.com
       [target] => _self
     )
    [nid] => 18
  )
)

```

# Answer
You should be able to use the l() function (link function) to print out your link.

Typically, l() is used with the arguments l("My link text", $path), however, the first argument doesn't have to be text and can be just html. You just have to specify that with the optional $options array argument at the end if you're including html. :-)

Here is more documentation on using l(): http://api.drupal.org/api/drupal/includes!common.inc/function/l/7 The 6 & 7 versions should work similarly.

In your case, you can build your link like this:

1. Your first argument will be an image, rather than text as the link
2. Your second argument will be the path you want the image to link to, which should be $image\['filepath'\]
3. Your third argument should specify that the first argument is html, and not just text

So, try something like:

```
<?php
print l(
    theme_imagecache('my image cache preset name', $image['filepath']),
    $image['data']['url'],
    array(
          'attributes' => array(   // Sample attributes you can apply to your anchor tag
            'id' => 'your-link-id',
            'class' => 'your-link-class',
            'target' => '_blank',  // open link in new window.
          ),
        'html' => true,
    )
);
?>

```

I haven't tested this yet, as I don't have a Drupal 6 site handy, but this should work. Let us know if it works or if it needs some tweaking...
> 2 votes

---
Tags: 6, theming, entities
---


# Question
Title: Sort a View by whether content has a user reference
I have a view that lists all users that have flagged a piece of content (using the Flag module). Also, for that content, I have certain user references attached (using the References module).

So:

* User can flag a piece of content.
* Content can reference user.

I want to be able to have the view show all users that have flagged the piece of content (I have that working correctly), but **also** show them in the order of:

1. Users that are *referenced* by the piece of content.
2. Username, alphabetically.

I think I just have a mental block from getting this done. Any pointers or advice to help me get this kind of sort working? **Note**: I also need to have everything done in one display, since it needs to be sortable and filterable.

# Answer
> 2 votes
I have an idea! Use your current block to limit the list to users who are referenced in the node, and then add an ATTACHMENT to the block listing users who have flagged it who *weren't* referenced in the node.

That way you can separate them our and sort independently, but they'll still appear as if they're displayed in the same view.

Here are the exact steps:

* Add an additional relationship that is the node user reference field, but reversed:

* I added the 'Content: nid' field with the above relationship to my view just while testing, and that was helpful, so I'm including it as a step...
* Add that field 'Content: nid' using the user-reference relationship to your set of contextual filters too, if you're using it, to make sure the content they're referenced in is the *current* node (don't want to sort them first just because they're referenced in SOME node on the site, right? ;-))

* Add an attachment to your view, and set it to display directly after your existing page or block. In this one, you'd want to do the exact same as above, however, when you're setting the contextual filter, select to 'Exclude' the matching answers (you'll find that check box in the collapsed 'More' section at the bottom.

---
Tags: views, nodes, flags, users
---


# Question
Title: Selectively clear cache, without AdminMenu
I've been using AdminMenu on my site, and have noticed significant performance issues. I'd like to disable it, but I have a number of "Admin Lite" users, who depend on being able to selectively clear parts of the cache - css/js, theme cache, etc. They're not the type of users who are going to install Drush, so I'd really like a simple web based UI that allows selective cache clearing. Rules & Cache Actions feels close, but I don't actually want automated rules for clearing the cache. Is there a module out there? Or do I need to write one?

# Answer
> 1 votes
After going through 19 pages of search results I don't think what you want exists. I'd say you need to write one yourself.

I also checked GitHub Several modules to easily clear everything...

---
Tags: caching
---


# Question
Title: Finding out what file was called immediately before error
I'm getting the following errors in dblog whenever I look at a page:

> Notice: Undefined offset: 0 in \_menu\_check\_access() (line 635 of /home/mysite/public\_html/includes/menu.inc).

> Notice: Undefined offset: 1 in \_menu\_check\_access() (line 635 of /home/mysite/public\_html/includes/menu.inc).

I know it's not Menu that's causing the issue, but rather, some module is passing permissions incorrectly via hook\_menu.

I remember reading a long time ago that one way to find out which module is causing core to emit notices, is to drop a function right before the line in question. Alas, I cannot find that page at all.

Any thoughts?

# Answer
If you are tracking down a weird error, editing core is perfectly acceptable.

1. Make sure everything is in your RCS.
2. Edit includes/menu.inc
3. Place a `print_r(debug_backtrace())` near line 635, preferable at the top of `_menu_check_access()`. Alse `print_r()` the arguments.
4. Trigger the problem.
5. Figure out what happened.
6. Revert the site to the checked in RCS version.

My guess is you are getting weird path, and the argument is wonky for your access check. In other words, you are trying to access check something that should really 404.
> 3 votes

---
Tags: routes, users, debugging
---


# Question
Title: How can I convert first page of a pdf as its thumbnail?
I'm trying to build a document sharing site so I need to convert first page of each document as its thumbnail in a grid view. I've found some module like PDF-to-ImageField module, but unfortunately it has been released only for Drupal 6.

Now what can I do? is there any Module to convert first page of each document (specially pdf and doc) to a thumbnail for drupal 7? or any other ways?

# Answer
Some people have started a Drupal 7 version, but it's nowhere near ready yet. If you can program for Drupal 7 and want to get involved, you could check out their Git repository and help them out.

If you're not ready to start porting D6 modules to D7, you could try one of these options to build those thumbnails, then write a little snippet of code to attach them to your nodes in your imagefields:
> 1 votes

# Answer
I would like to add the **PDFPreview** module as an viable option. I use it in the exact same area as you for a bunch of document sharing sites and it works well. I tweaked it a little bit so that it works better in combination with image\_styles, but beside of that its a nice little module that does what you want.

Link: PDFPreview project page
> 0 votes

---
Tags: media, files
---


title: How to create OG image view?

text:
# Question
Title: How to create OG image view?
I facing issue with `OG 7.2x` and `image`.

I create a group content type and add new field with `image`. After that i upload some picture, and view with `colorbox` working fine.

After that, i create normal view all things is workings well. if i add `contextual(OG member:group id)` and `relationship(member from og node)`, the picture disappeared and nothing display under OG view.

Would you please tell me that how to do this?

Many thanks.

# Answer
Hi what you can do is that create a content pane from a view display and configure it in the following screen shot listed below.

Next in the fields section you can add the image field and other fields as per you like.

```
 ![Add fields accordingly][2]

```

Also you can clone the view that comes default with OG.

```
OG:CONTENT(clone this view and add fields)

```

Hope this helps. :)

Edit:- For displaying images

I havent done anything like this before. But I think you can do this by "rewriting" the result of the url field.

You can do this by clicking the field with the url that you will find under "FIELDS" in your view settings. Then under "Rewrite Results" you can write something like

```
<img src="[image_url]" />

```

here, 'image\_url' must be the name of the field. you can verify this in the list displayed under "Replacement Patterns"

Hope this helps. :)
> 0 votes

---
Tags: organic-groups
---


# Question
Title: How to create an autocomplete textbox in register page - Drupal 6
Consider I am doing a registration form with the following fields.

```
1. Name

2. Email

3. City

```

Here the city should be auto complete.

I created the city field with the help of content profile module in order to add more fields in future.

**Now how can i make the "City" text box auto complete.**

**How can i store the records in the table ?**

Thanks in advance...

# Answer
There's a full example for Drupal 6 here: \[Textfield that uses autocomplete\]\[1\]. The code will probably be useful to people on this site as well so I'll post i here:

*The following is based on a module with the name: 'cities'*

In your form function:

```
$form['city'] = array(
  '#type' => 'textfield',
  '#title' => 'City',
  '#maxlength' => 128,
  '#autocomplete_path' => 'cities/autocomplete',
);

```

In your module file:

```
function cities_menu(){
  // path with autocomplete function for cities
  $items['cities/autocomplete'] = array(
    'title' => 'Autocomplete for cities',
    'page callback' => '_cities_autocomplete',
    'access arguments' => array('use autocomplete'),  //or whatever permission makes sense
    'type' => MENU_CALLBACK
  );
  return $items;
}

```

Also in your module file:

```
function _cities_autocomplete($string) {
  $matches = array();
  //search table `cities` for cities that begin with the letters the user enters in the form
  $result = db_query_range("SELECT city FROM {cities} WHERE LOWER(city) LIKE LOWER('%s%')", $string, 0, 10);
  // add matches to $matches
  while ($data = db_fetch_object($result)) {
    $matches[$data->city] = check_plain($data->city);
  }
 print drupal_to_js($matches);

}

```
> 1 votes

# Answer
Try Autocomplete Widgets for Text and Number Fields, I use it for this purpose and it works great.

> This module adds 3 autocomplete widgets for CCK fields of type Text and Number.
>
> * Autocomplete for allowed values list: `... snip ...`
> * Autocomplete for existing field data: This widget can be used for Text only and it takes candidate values from existing values in the database for that field.
> * (7.x only) Autocomplete for predefined suggestions: `... snip ...`
> 0 votes

---
Tags: 6, users, ajax
---


# Question
Title: Problem with "content access" (module) and permission "View own unpublished content"
I have a problem since few days and i didn't find my answers.

When i install content access, the permission `View own unpublished content` doesn't work anymore.

**Some explanation about my configuration:**

I use workbench and workbench moderation to create a simple workflow (i didn't change any setting: so draft, in review, published)

I have 2 roles who manage all the content (editor, manager and another role admnistrator who has all the bypass etc.)

**And now, i've juste discovered that i have a problem when i need to see nodes that are not published. Editor and Manager can't see them event if they have created this content.**

They can't see unpublished content everywhere in the site (in `workbench administration` and in `content section` so it's not a views problem)

I made another installation in local to make some test. I re-created my role with a basic configuration (permissions):

* `Access administration menu`
* `Access the content overview page`
* `View own unpublished content`
* `View the administration theme`

So when my manager creates a content type and it's unpublished it works fine. But when i install `content access`, it doesn't work anymore.

I don't know what's going wrong in my site but the only way for the user to see unpublished content is to have that permission : `Bypass content access control`

Problem, if i give them that permission, an editor can published content. It's override the workbench permission (he can just use draft and in review, only manager can published)

The only setting for `content access` i saw are in the content type section.

I think i made a stupid mistake, forget a setting but i didn't see where.

Thxs for your help :)

# Answer
I've just found some interesting information about my problem. Maybe it will help someone else.

In fact, it's seems impossible to resolve this problem in a proper way.

There is a very good article about that: Access Control module prevents View of user's own unpublished content, and an issue on drupal.org

If we want to see our own unpublished content in workbench, we have to go in `view` and make:

* Go to query settings
* and check Disable SQL rewriting option

It's not very good solution like he said but we can't do anything else for now.
> 4 votes

# Answer
I actually have an answer for you!

I had run in to this issue on a site and was about to just give everyone bypass access permissions, when it clicked that the only reason users can't see the unpublished items is because the view that's driving the default Content admin page doesn't know about Workbench Moderation's states.

The solution therefore is to override the default Content page, and the easiest and most effective way to do that is to install Administration Views.

Administration views replaces the default content view and ootb this view supports the permissions workbench moderation provides. Your problem is now fixed!

Note that Administration Views requires Views, Views Bulk Operations, Chaos Tools and Entity API, but if your site doesn't have most of those already you're probably doing Drupal wrong!

If you don't want to allow any of the VBO functions (because they tend not to play nice with Workbench Moderation in my experience) you can just hide that field in the view, or disable all the actions you don't want people to use.
> 0 votes

---
Tags: 7, nodes
---


# Question
Title: Is there a way to show a page dynamically when hovering on it's link?
Just wondering if there is a module or some way in general to do the following:

When hovering on a page link show the content of that page as a tooltip or some kind of small dropdown window.

Thanks.

# Answer
Beauty Tips is a drupal module and a jQuery plugin that will allow you to display content tooltip style via hover, click or a range of other events.

It provides an API for adding custom beautytips as well as some built-in features. Admins can enable rollover balloon-help style tooltips for text fields within forms. It also supplies hover tips for Drupal help links and advanced help links.

Most importantly, it allows developers to add their own custom beautytips popups to their site without having to delve into jQuery.

You can use this module and fetch the data which do you want to display in tool tip.
> 1 votes

---
Tags: 7, theming
---


title: No 'pagination' on Article comments

text:
# Question
Title: No 'pagination' on Article comments
Ok, I'm on D7 and using the default Bartik theme. I set comments for content type Article to be 10 per page, threaded. I published a test Article and started commenting to test the paging, and when I surpass the set limit of 10 per page, the article only displays the first 10 comments and I don't see a "more" or a "next page" or anything linking to the second page of comments.

I did not touch any PHP or CSS.

# Answer
This was cross-posted to the Drupal Sub-reddit. Just posting here for any future googlers:

If you have more than one pager on a page (think a views block of recent content) you have to give it a unique Pager ID which you can do in the advanced settings for the pager in views.
> 0 votes

---
Tags: 7, nodes, comments
---


# Question
Title: I want to know the module through which any user can add his own tags for the content on the pages
I want to know the module from D7 which i can use to add tags for the any content. Suppose i have one page Guide for beginners then on this page there is word "Guide" So at the bottom of the page there should be Add tag option in which i can add the tag for the word "Guide". once i tagged it should display at the bottom in my tags. So this facility should be for any user. Please let me know the module if any available or the method for implementing this.

Thanks in advance.

# Answer
Looks like you need to know how to use the Taxonomy module, which comes with Drupal core.

Good place to start would be its documentation.
> 0 votes

---
Tags: taxonomy-terms
---


# Question
Title: how to create a grid view with only ONE image from nodes containing multiple images?
I have Nodes that have an Image field that can have any number of Image Fields. I want to create a Grid View in which I should only a single IMage field (can be the first one or any one actually).

Attached image shows my Views settings that shows multiple images - how do I limit to picking a single image from each node for the grid views display?

(I am in DRUPAL 6)

# Answer
> 4 votes
You can do it easily, by clicking the **"Image Field"** and check the **Group Multiple Values** and set **show values** as **1** and set **starting from** 0

see the image below

---
Tags: 6, views, media
---


# Question
Title: Webform radio button sets common functionality
I have 2 sets of radio buttons which have different data and because they are radios, you can only select a single option per set.

However, I am trying to achieve a setup which will allow only one selection between the 2 sets of radios.

**So, if I select an option in set#2, any previously selected option in set#1 will be deselected and vice-versa.**

Can anyone help with this?

*ps: I know JavaScript should fulfil this need but I am trying to find alternative solutions in case javascript is switched off and the functionality breaks.*

# Answer
> 0 votes
AFAIK javascript is the only option and I do not see any help in the Drupal webform module

You could do it effectively in javascript/Jquery.

Another option as Beebee suggested you could force all the 4 radio buttons into a single set.

```
<div id="content">
 <input type=radio name="chooseme" value="1" />
 <input type=radio name="chooseme" value="2"/>
 <input type=radio name="chooseme" value="3"/>
 <input type=radio name="chooseme" value="4"/>
</div>

```

Now,user would be left to choose any one of the four radios.

---
Tags: 7, webforms
---


# Question
Title: How give users ability to change their blog pages theme?
I am using Drupal7 and I am designing a blog engine site that any user can create a blog for him/herself and he/she can change the theme of his/her blog page. Is there any module to integrate with the core blog module and provides this ability for my site?

# Answer
> 0 votes
Take a look at the Switchtheme module.

> Adds a block to allow users to switch between enabled themes.

Read the readme.txt of the module for the instructions.

If you wish to have different themes according to roles, take a look at the Role Theme Switcher module.

> Useful Drupal module to assign separate themes for different roles (including anonymous) in your system.

---
Tags: theming, nodes
---


# Question
Title: Is deactivating modules safe regarding settings?
I had a strange error after uploading a module to a shared hosting server when going to admin/modules before even activating the module (image\_desaturate\_formatter).

> PDOException: SQLSTATE\[23000\]: Integrity constraint violation: 1062 Duplicate entry 'sites/all/modules/image\_desaturate\_formatter/image\_desaturate\_fo' for key 'PRIMARY': INSERT INTO {system} (filename, name, type, owner, info) VALUES (:db\_insert\_placeholder\_0, :db\_insert\_placeholder\_1, :db\_insert\_placeholder\_2, :db\_insert\_placeholder\_3, :db\_insert\_placeholder\_4); Array ( \[:db\_insert\_placeholder\_0\] =\> sites/all/modules/image\_desaturate\_formatter/image\_desaturate\_formatter.module \[:db\_insert\_placeholder\_1\] =\> image\_desaturate\_formatter \[:db\_insert\_placeholder\_2\] =\> module \[:db\_insert\_placeholder\_3\] =\> \[:db\_insert\_placeholder\_4\] =\> a:11:{s:4:"name";s:26:"Image Desaturate Formatter";s:4:"core";s:3:"7.x";s:7:"package";s:5:"Field";s:7:"project";s:26:"image\_desaturate\_formatter";s:12:"dependencies";a:2:{i:0;s:5:"field";i:1;s:5:"image";}s:7:"version";s:11:"7.x-2.0-rc1";s:9:"datestamp";s:10:"1356346648";s:11:"description";s:0:"";s:3:"php";s:5:"5.2.4";s:5:"files";a:0:{}s:9:"bootstrap";i:0;} ) in system\_update\_files\_database() (line 2307 of xxx/htdocs/site/modules/system/system.module).

Now the update module isn't working anymore but just showing the following message, when I try to start the update process manually:

> Failed to get available update data for 27 projects.

1. Could the module upload error be related to the update module not working?
2. Is it safe to stepwise deactivate the modules to check if update isn't working due memory issues? Do I loose all the settings I've made?

EDIT/UPDATE:

I have limited access to server logs and there is a

> The timeout specified has expired: ap\_content\_length\_filter: apr\_bucket\_read() failed

and the "reports" section doesn't show anything except the PDO above.

I now have disabled every module except core and tried to run update in between with no effort. The update module isn't working anymore. Is there something else i could do?

# Answer
> 4 votes
1. It's impossible to say from here. Theoretically yes.
2. It depends on the module - a specific module could easily clear its variables in hook\_disable(), or hook\_uninstall(), or not at all. You'll have to check the install file for each module you disable to see how it will affect what you're doing.

It sounds very much like you have two copies of the image\_desaturate\_formatter module in your Drupal install though; that could account for the error.

Regarding server logs - your host should give you access to these (I've never come across a host that would deny you access to your own logs, it's criminal!) so give them a call, they might have valuable information in them.

---
Tags: 7, updating
---


# Question
Title: How to link menu item to a page in Drupal7, that can display database content?
I am using a custom module in my Drupal7 to add data in a form and then inserting it into the database. The form has fields like "Menu Name", "Image", etc. I want to know :

* How can i show this dynamic content in my site, by clicking on each of the menu items?

In other words, how to link dynamic content to the menu items? The name of the menu item will be equal to one of the fields (Menu Name) in the form in my custom module. Each of the menu item pages can have a different design & layout (based on form data).
* Do i need to hack my page.tpl.php?
* Do i need to create as many .tpl pages as those of menu items for showing the dynamic content?

I just want to know What is the best way to achieve this.

# Answer
There are 3 broad ways of doing this i) create a widget ii) ajax/json iii) create a block.

The widget method is suitable if you are trying to create an element in the form that is more sophisticated than the form elements provided. You present it in a node--contenttype.tpl.php template. Replace 'contenttype' with the name of the content type you created.

If you want to print out just parts of the data captured in the form then you can use hide($content\['fieldname') to get rid of any fields that you don't want rendered. That is the 'streamlined' way. See the 'field example' module in the examples project.

Assuming the module is called ognotify you will need to implement:

1. ognotify\_field\_info() to declare the field
2. ognotify\_field\_widget\_info to define the widget and
3. ognotify\_field\_formatter\_info() to define the available formats.

These 3 things define the 'edit content type form' in the administration area of drupal.

To process the output you also need to implement

1. ognotify\_field\_is\_empty($item, $field)
2. ognotify\_field\_widget\_form(&$form, &$form\_state, $field, $instance, $langcode, $items, $delta, $element) to define the form elements

and some validation routines. You can add this 'widget' to any content type.

It sounds as though you are trying to render something more specific. If by dynamic you mean via ajax then one way is to create an ajax block and callback response from the block (module is called bookreview this time).

Define the block as per:

```
function bookreview_block_display($delta, $args) {
...

```

This calls a form element of ajax type.

```
function _bookreview_publish_review_link($args) {
  $block = array();
  if (empty($args['nid']) || empty($args['status'])) {
    return $block;
  }

  $block['content'] = array(
    '#type' => 'link',
    '#title' => 'Publish review',
    '#href' => 'bookreview/publish/' . $args['nid'],
    '#prefix' => '<div class="publish-review" id="ajax-link-div-' . $args['nid'] . '">',
    '#suffix' => '</div>',
    '#ajax' => array(
    'effect' => 'fade',
    ),
 );

 ...
  return $block;
}

```

Render this on a page. You can do this by mapping blocks, or in code in a template:

```
$block = module_invoke('bookreview', 'block_display', 'bookreview_publish_review_link', $args);
print render($block['content']

```

The callback in this example is 'bookreview/publish'. This is the 'access content from a menu' solution. Implement the menu:

```
function bookreview_menu() {
  $items = array();
  $items[BOOKREVIEW_MODULE_NAME . '/publish/%node'] = array(
    'title' => 'Publish a Book Review',
    'page callback' => 'bookreview_publish_review',
    'page arguments' => array(2),
    'access callback' => 'bookreview_access_callback_check',
    'access arguments' => array(array(BOOKREVIEW_ADMIN_PERMISSION_NAME)),
    'type' => MENU_CALLBACK,
    'file' => 'includes/BookReviewEvents.php',
  );
  return $items;
}

```

Now we have mapped a menu item (uri) to a function that prints out the content.

```
function bookreview_publish_review($node) {
  if (!isset($node)) {
    return;
  }

```

This takes a node argument, %node in the menu definition which automatically gets converted from a node number to a node loaded from the database. The address publish/123 will result in node 123 being passed to your function. You can create a callback for each of the fields in the content type as per /bookreview/menu-name-field/%node. Then create a function to either directly print out the ajax json response:

```
...
// How you want to get the data from the node. Best to use Netbeans/php debugger
// or dpm() if you don't have it.
$menu_name_field_data = $this->node->{$this->_findMenuFieldName()}[LANGUAGE_NONE][$delta]['value'];
$data_to_print[] = $menu_name_field_data;
ajax_deliver(array('#type' => 'ajax', '#commands' => $data_to_print));
...

```

The 3rd way is similar to creating the ajax response, except that you define a block that allows you to render the html content. As per the ajax defining a menu item and declaring a block. You print out the content there instead of defining an ajax form.

The widget answer is the most reusable, the ajax answer is the most dynamic and flexible and the block method presents HTML instead of ajax responses. Regarding 'dynamic' the ajax solution best meets your description in the question, although I thought it necessary to present the breadth of the possibilities so that you can make choices regarding the tradeoff between reuse and dynamic.
> 1 votes

---
Tags: 7, routes
---


# Question
Title: How can i print multiple query output in GLOBAL:PHP view field?
I have custom global:php fields on which I put the following code as value.

```
$shop_url=db_query("select page_url from mytable1 where user_id=$row->uid");
return $shop_url;

```

As output code, I put the following one.

```
foreach($shop_url as $data) {
  print($data->page_url);
}

```

I am getting no output. How can I achieve printing multiple database results in GLOBAL:PHP?

# Answer
> 2 votes
There are many errors in your code :)

First, **don't use $data variable**, as it's already used in your view ; check the *available variables* section under your php inputs. Normally, it's advised to use **$static**.

Second, did you check elsewhere that

`$shop_url=db_query("select page_url from mytable1 where user_id=$row->uid");`

returns something ? Because I would have thought that only

`$shop_url=db_query("select page_url from mytable1 where user_id=:uid", array(':uid' => $row->uid));`

would work.

---
Tags: views
---


# Question
Title: How to find out allowed memory for a specific Drupal page
I want to find out how much allowed memory a page uses after it is loaded on my drupal 6 site. I know that you can do this when a page is not loading correctly, by enabling errors in php.ini. How do find this out on successful page loads?

# Answer
> 1 votes
Check out the performance module (formerly part of Devel):

> This module provides performance statistics logging for a site, such as page generation times, and **memory usage, for each page load**.
>
> This module is useful for developers and site administrators alike to identify pages that are slow to generate or use excessive memory.

emphasis mine.

---
Tags: debugging
---


# Question
Title: Adding extra info to each Node -> Taxonomy Term relationship
We have a basic site with a pages that have a taxonomy term content type associated with a number of terms.

What we would like to is to add more information to each of the node -\> taxonomy relationship.

For example, the details of the author that tagged the term(different authors can tag a term to a node), the date the particular tag was added and so on.

I have looked at the Entity API, the Relation module and various other solutions in between.

From what I can tell, Entity Reference along with the Entity API seems to be the simplest way forward.

While I am not loathe to get my hands dirty and start coding this out, my knowledge of how each of these things fit together is limited.

Can someone point me in the right direction and point out any potential pitfalls along the way with regards to getting this done?

# Answer
> 1 votes
Imho, the simpliest way to achieve associations of data with field value **without** coding is to use **Field Collection**.

> Provides a field-collection field, to which any number of fields can be attached.
>
> A field collection is internally represented as an entity, which is embedded in the host entity. Thus, if desired field collections may be viewed and edited separately too.

You will then be able to set, each time you tag one or more terms, additional informations in other fields of your field collection. Plus, you can have multiple field collections of the same type on your content.

---
Tags: 7, taxonomy-terms, entities
---


title: In Drupal 7, what events are logged?

text:
# Question
Title: In Drupal 7, what events are logged?
I'm looking for a list of the events that Drupal 7 logs via watchdog. The question I'm trying to answer for a colleague is this:

"What logging Drupal is capable of, specifically related to security, performance, and metrics?"

I realize that I can log whatever I like but I'm looking for the default list. Googling hasn't helped.

Thanks very much.

# Answer
If you have a look through the list of Drupal core functions that call watchdog(), you can get a good idea of the events that get logged.

http://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/calls/watchdog/7
> 3 votes

---
Tags: log-messages
---


# Question
Title: Feedback module block doesn't follow visibility rules
I'm using the Feedback module on my Drupal 6 but I found out a strange behaviour about its block's visibility.

The module appeared even if the block was in the disabled region, not assigned to any site space, and moreover it still appears even if I set for example a PHP code which returns false, or if I set it to appear only on listed pages without giving it any valid page.

If I move the block to different regions it still appears on the bottom right corner, so I have no control on how it works.

Am I missing something or is it a wanted feature of the Feedback block to be always there?

# Answer
Wow. It's pretty snarky, for no better word, and does the following...

```
/**
 * Implementation of hook_footer().
 */
function feedback_footer($main = 0) {
  if (user_access('access feedback form') && $_GET['q'] != 'admin/reports/feedback') {
    $block = (object)module_invoke('feedback', 'block', 'view', 'form');
    $block->module = 'feedback';
    $block->delta = 'form';
    $block->region = 'footer';
    return theme('block', $block);
  }
}

```

...which basically puts it on every page except `admin/reports/feedback` by stuffing the form into page.tpl's `$closure` variable.

So, yes, it does appear to ignore standard block visibility rules somewhat on purpose.
> 1 votes

---
Tags: 6
---


title: Context select submenu

text:
# Question
Title: Context select submenu
I'm trying to enable a submenu item through context rules.

However, the Context is consistently trying to select only the top parent item, and not the submenu. I tried few times on completely clean installs with the same results.

Am I doing something wrong or it should be working this way?

How can I otherwise open a submenu item with context rules?

Thanks!

# Answer
I am using a Menu Block module and Context to achieve a similar thing.

For conditions, I have this fire on a Content Type of Instructor Profile. I add Menu Block's blocks to region's One and Two accordingly.

And I use `Context` to automatically select the menu level for me
> 1 votes

---
Tags: 7
---


# Question
Title: Problems w/ themes and multi-site installation
so i'm currently migrating a single install drupal site into a multi-site drupal install, and for some reason it doesn't seem to be picking up my templates... which is a bit odd considerign that when in the drupal admin interface on the actual client facing CMS I can see that i'm in the correct "theme" which is a custom theme called "press".

however, drupal isn't using my page.tpl.php file. So what I did was hit the main drupal install and opened up bootstrap.inc and found that it is finding the correct directory for the conf and everything... not sure what else to do.

something that's interesting is that if I ping my site on localhost it looks as though it's pulling in 1 block (which should be displayed on the homepage), no wrapper, no menus, etc (which is why i think it's not using the correct templates, also the html is formatted differently than when it uses the correct template).

this is what i did to migrate

1. moved moved settings.php/modules/themes/files into the drupal/sites/mysite
2. reconfig'd my httpd.conf to point to the right site (it is).
3. reset my file path from sites/default/files to drupal/sites/mysite/files

using - drupal 7

curious if anyone has any advice or knows how I can investigate this further.

# Answer
I have also experienced this issue as well. It seems that drupal doesn't want to recognise themes and modules on a multisite subdomain basis (i.e. sites/yoursite.com/themes is ignored!!!). I don't know if this is intended behaviour but the only solution I have found thus far is to put all modules and themes into the sites/all folder and then to check they are enabled in the admin interface. Drupal will correctly respond to the subdomain request (and rewrite paths where appropriate) so long as you have the sites/yoursite.com folder.
> 3 votes

# Answer
This problem resolved itself for me when I moved my sites/default/settings.php file to sites/mysite.com/settings.php.
> 2 votes

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


title: How do I resolve Access Denied message

text:
# Question
Title: How do I resolve Access Denied message
I created 2 roles on my site: Buyer and Seller

I used auto assign role to allow the user choose a role on sign up.

I then created an additional profile for seller using profile 2. (The buyer is supposed to be logged in immediately he signs up)

Using rules, i tried to redirect the user who chooses the seller role to the page setup with profile 2, but it comes up with access denied, you are not authorized to access this page.

Kindly assist.

# Answer
> 1 votes
The redirection is happening before the login is processed, hence the error. The way I'd handle this would be to do the check when the profile page is viewed, rather than during the login process. So the trigger for the action is on viewing a page, specifying the user view page and adding a condition that the user being viewed is a seller.

---
Tags: users
---


title: Insecure fmath editor

text:
# Question
Title: Insecure fmath editor
fmath is an extremely powerful plug-in library for wysiwyg editors.

It provides an editor for mathematical formulas, which generates images that can be used in drupal sites. It processes mathml and latex.

There is a problem though, images are saved on a server using the following php file.

```
if($_POST["save"]){
   $type = $_POST["type"];
   if($_POST["name"] and ($type=="JPG" or $type=="PNG")){
      $img = base64_decode($_POST["image"]);
      $myFile = "img/".$_POST["name"].".".$type ;
      $fh = fopen($myFile, 'w');
      fwrite($fh, $img);
      fclose($fh);
      echo "http://your_server/capture/img/".$_POST["name"].".".$type;
   }
}else{
   header('Content-Type: image/jpeg');
   echo base64_decode($_POST["image"]);
}

```

This file is publicly available, and can not be restricted with .htaccess to localhost only (the whole library will not work).

From my understanding the file is called by scripts on a user side via an url, and the image is passed by the POST method. That makes the file very dangerous as it allows anyone to save anything on the server.

Are my suspicions correct? How can I make this safe to use?

The whole library weights 11MB so I don't feel like debugging it.

# Answer
> 2 votes
This should really be addressed to the fmath project maintainers. I've mailed them to point out some security concerns in the code. If they don't respond I'll edit this post to answer the question here, but hopefully they will respond with a new version ;)

## Original comment - mailed to fmath maintainer:

Some key things this is missing that you would want to get right:

* CSRF protection - If you don't use the form API (which includes this already) then you can manually use drupal\_get\_token and drupal\_valid\_token are helpers.
* Malicious file types - file\_munge\_filename is a helper here
* Too many/too big of files
* Temporarily uploading the file to a temporary directory outside of the webroot and giving it a random name so that it can be validated in that temporary location before moving it to the final location
* Ideally you would validate the file contents (e.g. virus scan, confirm the file is a valid file of whatever the extension/mime type says it is).
* Control where the file can be placed.

This script looks like it would only allow jpg or png files to be uploaded, but it misses out on a few other security features

There are probably a few other things to worry about, but I think that list is a good start.

I also wonder about this piece and whether you could sneak base64 encoded html into a "jpg" file and then some veresions of internet explorer and safari will do mime type detection and execute the html (i.e. cross site scripting attack):

```
   echo base64_decode($_POST["image"]);

```

# Answer
> 0 votes
I have solved this problem by plugging the file to drupal and checking the user if he is not anonymous (please correct me if I'm doing something wrong here).

```
define('DRUPAL_ROOT', '/home/username/www/');
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
global $user;
if($user->uid != 0){
   // the provided imageCapture.php script
   if($_POST["save"]){
   ...
   }
   // end the provided script
}

```

As users of my portal will be trusted it does the trick for me. I agree with greggles though that it is something that fmath maintainers should fix.

---
Tags: wysiwyg, security
---


title: Dynamic Views Title

text:
# Question
Title: Dynamic Views Title
Drupal 7.

I have a view that displays all taxonomy terms based on an argument in the URl. Is there a way to set the title to display dynamically?

For example, the I have a Taxonomy called Publications, where level one are magazines, and level two the individual issues. If I go to the url for 'Time Magazine' which is 'publications/12345' I would like the view title to be 'Time Magazine Issues.'

I was able to get the argument in the title using '%1 Issues' but I want the name, not the ID.

# Answer
> 12 votes
I tested the view and the trick seems to be to select the "filter type value: taxonomy IDs separated by , or +": (right click on image and open in new window to see full size):

For reference, this is discussed here: http://drupal.org/node/1137672. I would would think this is a bug in views, could be a feature ;-)

# Answer
> 1 votes
> This solution doesn't work for localized taxonomy terms in title

Didn't work for me either but it started working after applying this patch: http://drupal.org/node/1788832#comment-6495290

---
Tags: 7, views
---


# Question
Title: Drupal 7 Views Organic Groups Complex Relationship
I have an Organic Groups setup with many relationships. My groups are separated into 3 primary group types..let's call them:

* Trucks
* Cars
* Vans

All of these groups have group content:

* Tires
* Rims

I've created a view that is a list of Tires and I need to be able to sort by group type...so I need a list of tires for Trucks (for instance). How do I relate the bundle type?

# Answer
> 2 votes
This worked for me....

Create two relationship:

* OG membership from node
* Group node from OG membership (Relate to Above)

Filter by Content Type and use relationship Group node from OG membership.

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


title: Using AJAX in menu and menu tab links

text:
# Question
Title: Using AJAX in menu and menu tab links
I have a few pages with sub pages as tabs. Each pages are in a custom menu. I'd like to convert the menu links to load each page using AJAX, is this possible?

I know how to load a page using a regular AJAX link, but not a menu, or menu tab link. One way is to replicate the menu links using AJAX and binding the events to the corresponding menu links, which works, but there must be a better way?

# Answer
> 1 votes
I managed to get this working by manually adding AJAX to each menu item:

```
(function ($) {

Drupal.behaviors.test = {
  attach: function(context, settings) {
    $('#sidebar-first ul.menu a').addClass('use-ajax').addClass('ajax-processed').each(function () {
      var element_settings = {};
      element_settings.progress = { 'type': 'throbber' };
      if ($(this).attr('href')) {
        element_settings.url = $(this).attr('href');
        element_settings.event = 'click';
      }
      var base = $(this).attr('id');
      Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
    });
  }
};

```

Each of the menu items then checks to see if AJAX was used, if so it delivers the page using ajax\_render(). })(jQuery);

# Answer
> 1 votes
Assuming I understand your question correctly, it is possible. This is how I would do it (not sure how much this differs from the way you mentioned). Obviously you would need to change your page callback function, which you set for the tab in hook\_menu(), to return a json object rather than a rendered page.

At the end of your page callback function you should add something like this:

```
// Return the rendered view in a JSON object. The object will contain a property
// named “contacts”, which containes the rendered view.  This will be sent to the
// browser and is accessable to javascript.
return drupal_json_output(array('contacts' => $view));
exit;

```

You would then need to include some javascript on the client-side to send an ajax request to the server using the URI/path you set for the tab in hook\_menu. This same client-side javascript would then process the returned data.

```
  currentMenuLink.click(function() {
      var updateContacts = function(data) {
        // The data parameter is a JSON object. Do something with the returned data here.
      };

      // Send ajax request.
      $.ajax({
        type: 'POST',
        url: this.href, // Which url should be handle the ajax request. This is the url defined in the <a> html tag
        error: function() {
          $('#namecards-get-contacts-by-nid-row-' + currentNid).show();
          $('#namecards-get-contacts-by-nid-cell-' + currentNid).html($('<div class="">An error has occurred while retrieving the list of contacts.  Please try again.  If the problem persists, please inform your website administrator.</div>'));
        },
        success: updateContacts, // The js function that will be called upon success request
        dataType: 'json', //define the type of data that is going to get back from the server
        data: 'js=1' //Pass a key/value pair
      });
      // return false so the navigation stops here and not continue to the page in the link.
      return false;
    }
  });

```

# Answer
> -1 votes
I use hook\_menu\_alter() for this:

```
function THEMENAME_menu_link(array $variables) {

  //mlid - menu link ID. I want AJAX only some menu link
  if ($variables['element']['#original_link']['mlid'] == 1177) {
    drupal_add_library('system', 'drupal.ajax');
    $element = $variables['element'];
    $output = l('YOUR_LINK', $element['#href'].'/nojs', array('attributes' => array('class' => array('use-ajax'))));
    return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . "</li>\n";
  }

  // render other items dy default way
  return theme_menu_link($variables);
}

```

---
Tags: ajax, routes
---


# Question
Title: Drupal for a portfolio- Images as nodes or something else?
I am creating a portfolio using Drupal. I was wondering about best practice for handling images. Would it be best for me to have each image as a node and then create a view and display in a slideshow, or is there a different way that images can be handled - e.g. have a collection of images attached to a node of 'gallery'?

# Answer
> 0 votes
I'd go with the **image-per-node** option if you think you may at any point want to add additional information per image. You can call the content type 'Project' or something like that and put an image field on the content type. You can have an 'unlimited' checked as the number of images allowed in that field or only allow for a single sample image. Up to you.

The point is - imagine that down the road you want to add extra information about that particular screenshot/project, such as the date you worked on it, or who your client was, or a link to the live site or something like that. If you make a separate node for each project, you have the flexibility to add fields in the future.

If your entire portfolio is a single node with a bunch of images, *you don't have the option* to add extra information to explain those images later without re-doing the entire setup.

You can always just display them as a slideshow with no extra information, regardless of which option you choose, but I'd go with the one that allows for flexibility in the long term. :-)

---
Tags: media
---


title: Theming Panels with Zen Grids

text:
# Question
Title: Theming Panels with Zen Grids
I want to theme Panels using Zen Grids for layout.

Question:

Since all content in Panels appears in the 'content' div, what is the most flexible way to use Panels to place content anywhere on the page?

EG. Right now, my content-item that is styled with 'region-sidebar-first' is appearing in the main content section (of course).

Do I use \- Panels Everywhere? \- Mini-Panels?

I don't want to over-complicate things. Is there some way of configuring Panels to place content within ANY div within the *body* section of a page? I'd like to avoid using too many other modules etc.. and keep it very clean.

Ideal Scenario:

1. I place all the content-items inside a ONE column layout with Panels : (layout not important, but Panels does it's magic to create content based on Context etc... )
2. I style each content-item using 'css-properties' inside Panels, and choose CSS from Zen Grids
3. I use SASS to create a responsive layout via Zen Grids

Thanks in advance,

PW

# Answer
> 4 votes
Your answer is quite flexible actually.

You select the one column template and disable drupal standard regions and then just add a php filter custom content for each row in your grid. You add the grid classes inside your php filter and then use block render or views\_embed\_view.

Another more clean solution would be to create your own layout plugins for panels. It is not as difficult as it sounds. Just download and fork panels\_extra\_layout and you have everything you need in order to create your own custom and reusable grids.

Have fun.

# Answer
> 1 votes
AlexPsi covers it pretty well, and you mostly answered it yourself. Panels works best replacing theme layout in the main content area, not integrating with your theme regions. Use panels in the main content area and just turn off all the columns, unless you need them for standardizing things across your site. I don't think we're at the stage of dropping blocks and regions, yet.

One big tip: In most cases you want to use Panelizer because it layers on top of nodes/fields/CCK, rather than replacing nodes with Node Panels (deprecated). In other words, Panelizer layers on top of your pre-existing Drupal knowledge.

# Answer
> 1 votes
I think Panels Everywhere will work well for you. I've used it in a professional context and it seems to be a good solution.

# Answer
> 0 votes
If you're using Zengrids for layout and only using panels for context you should check out the context module.

http://drupal.org/project/context

---
Tags: panels, theming
---


# Question
Title: How to use a drupal footer and header on an external page
Sorry if the title is not the best description, it is my first time working with Drupal. My client has a portal created on Drupal 6.22, I'm creating a concurrent website for him, and he wanted to use the same header and footer that is created on the Drupal portal on my area.

So basically I would like to know if there is a include, or reference I can add to my website that would use\compile\something that Drupal header\footer on my layout.

# Answer
This *may* be fairly simple (with a couple of caveats, explained below). Treat it as though you were just going to use static files--i.e. so your site can simply include the contents of those files in the relevant \*.tpl.php files in the theme.

The meat of the problem is that you'll need to convince Drupal to make those files for you. You can do this by creating two nodes in Drupal on the portal--call them something like 'header-include' and 'footer-include'. Take note of their node ids.

Then, assuming for the sake of demonstration that the two new nodes have node ids 1 and 2, copy the portal theme's page.tpl.php file twice, so that you have two files, page-node-1.tpl.php and page-node-2.tpl.php (see Drupal 6 Template Suggestions for more details). Modify any paths in these files that refer to the portal site.

That done, remove everything from one file except for the code and markup required to generate the header, and everything from the other file except for the code and markup required to generate the footer. Depending exactly how you need to do this, you may need to include the opening html tag and all the scripts etc. for the header, and similarly for the footer.

Clear the caches on the portal site, and you should now have two pages, header-include and footer-include that contain only the basic html code required for the header and footer respectively.

These can be included into the theme on the new site using PHP's `file_get_contents()` function.

## Caveats

There are two points where this can go wrong:

### 1. Some paths may still be wrong

If there are paths in the header and footer includes that you generate (i.e. paths not hardcoded into the original page.tpl.php file), they will either include the domain of the portal site, or no domain at all. If there are any such, you will need to change how they're output at the portal (difficult), or add the relevant domain to the include at runtime (potentially expensive, though if the resulting pages will be cached, maybe not a huge concern...)

### 2. Include files may be accessible

This way of doing things makes the include files accessible to anyone on the portal site with the access content permission. How much of a problem this is is up to you and the client, but I don't know of a simple way to exclude them from search results in Drupal 6.
> 3 votes

---
Tags: 6
---


title: How to style block on certain pages?

text:
# Question
Title: How to style block on certain pages?
I would like to add a around a menu block I am displaying on a section of my site to style it differently on a certain page only.

How do I do this? Can I target a certain page with a conditional somehow?

# Answer
If your theme utilizes body classes and you don't need to modify the HTML structure you can simply do:

```
body.page-node-1 #block-block-1 {
  /* styles goes here */
}

```

Replace "1" above with the ID's for the node and the block.
> 2 votes

# Answer
Sure.

First, get fully familiar with Template Suggestions (here is a good reference) then

A. copy block.tpl.php to your theme if it's not there already, and then,

B. copy it to block-MENU-DELTA.tpl.php where MENU-DELTA is the correct incantation of menu and name/delta for your block, then,

C. Inside this new template, put in some logic that does whatever differently based upon what page you are looking at. Easiest is to do wrap your html in an `if` keyed off $\_GET\['q'\], eg, something like:

```
<?php if ($_GET['q']=='page/we/are/looking/for'): ?>
   // custom html here
<?php else: ?>
   // regular html here
<?php endif; ?>

```
> 1 votes

---
Tags: 6, blocks
---


title: Custom node.tpl.php for specific page

text:
# Question
Title: Custom node.tpl.php for specific page
I have a custom page template (Drupal 7) created from a basic page and I call it page--node-84.tpl.php. I'd like to manually print/render the 'body' field from this page and so I tried that doing this:

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

```

But that is not working because I believe I can only print a field when using a node template and not a page. Correct?

Could someone help me with a pre-processing function to be able to print a field in a page template. Or maybe using a custom node template is the way to go?

# Answer
The available variables differ between the page.tpl.php versus the node.tpl.php (see the top of each of those links for documentation of the default variables).

If the default variables in the templates don't meet your needs, you can customize them using preprocess functions. See the documentation for template\_preprocess\_page to get an idea of how the variables get added. NodeOne has a screencast on "Providing new template variables" that might also be helpful.
> 0 votes

---
Tags: 7
---


# Question
Title: What "access argument" or permission-string to use for a custom module?
When developing a custom module that has a configuration area, what is the correct or preferred permission to use? In core, you see a mixture of:

* `administer site configuration`
* `access administration pages`
* `administer {modulename}`

They appear to be applied almost at random, and searching the documentation does not show me a unambiguous "Best Practice" or "HUG" for this.

In this case, the module is small, has only one configuration-page and is related to Taxonomy, so a fourth option would be to re-use `administer taxonomy`.

Is there an unambiguous, or distinctive guideline on this matter?

# Answer
If you set a custom permission for your module you get finer control over who can configure your module's features. If your module is strictly related to Taxonomy you may stick to Administer taxonomy. You may find this link useful for your decision.
> 0 votes

---
Tags: routes
---


# Question
Title: How can I populate a node field based on a user field?
I have an "address" field among the user fields. Here users can specify several entries for their addresses. They can create orders (these are custom content type nodes). The order node has a "shipping address" field. Users should be able to choose one address from their previously stored ones and use them on the order form.

How can I do this? What I have in mind is adding a custom js that makes an ajax call and fetches the addresses from the user fields. Is it a good idea or is there any simpler method?

It would be fine too if I can make a reference field to the user datas and users would see a combo box to choose their address from.

# Answer
> 0 votes
I believe you could achieve this with the Rules module. Checkout Learn Rules with NodeOne, part 7: Conditions on loaded objects. In part 8 you will see how to Use PHP to populate CCK fields. Although this is for Drupal 6, you should be able to use a similar approach in Drupal 7.

---
Tags: nodes, users
---


# Question
Title: How do I use rules to iterate over the subscribed users of a organic group to send email notifications?
Using the great tutorial at http://webwash.net/tutorials/log-site-activity-message-and-rules I have been able to set up my Site Activity Log. I now want to extend it to be able to use message\_subscribe and message\_notify to send users, that are following the organic group, an email with the info. In rules I have been able to add an action Send Message with Message notify. However, I can't seem to set "The recipient of the email" to users that flagged (following) the group. Any insight into how to pull this into the rule would be much appreciated.

# Answer
There is a Flag action called **Fetch users who have flagged \[entity\]**. It will generate a list of users that you can then loop through and perform action on (e.g. send an email to). And since OG groups are entities, it should work (although I have not tested this). Also, beware that this might not scale if you have upwards of 1000 subscribers.

Reference: Nodeone's Learn the Rules framework. Checkout part 22 Flag and Rules: overview at the 4:00 minute mark.
> 2 votes

---
Tags: organic-groups
---


# Question
Title: Password protection for section of a drupal website
I am planning out a Drupal website, and it will have a password protected section. All users will need a username and password to access content, but client wants to issue passwords by company (group). For example, ABC company might have 20 employees, and they can all use the "ABC" username and password (issued by client) to access and read articles/content online. DEF company will use the "DEF" username and password, to access the same content. What is the best module to accomplish this?

# Answer
Introducing password protection to parts of a Drupal website means that you enter the the wild (and somewhat mysterious) world of *node access control*.

Out of the box, Drupal 7 (and previous versions) only provides a single global permission to grant a *role* the right to *view* a node (i.e. `view published content` in Drupal 7). To get more fine grained access control to published content, you must use a *node access module*. There are several node access modules to choose from. This page gives a good introduction to the rules that govern node access, and lists the major modules that help you manage node access, along with capsule reviews of each.

There are no single "best" module. Each module have different characteristics. I suggest you identify those you think are the best fit for your site, and check them out, before committing to one of them.

Your plan (to have a company user with a company password) have some logistical problems (see last paragraph), but can be implemented (sort-off) by means of a role based access module.

A better approach (IMHO) would be to create a set of node access "groups" (this can be roles, OG groups, or ACLs - depending upon the module you choose to use), where each "group" consists of all the users associated with a single company. I.e. you assign existing users to these groups. Now users can authenticate with their *primary* password, but you can set up node access grants to be determined by each user's "group" membership.

The approach you suggest (with a company user and company based password) will have the problem that the company user's password can not be protected against changes without a custom module. Also, you may run into problems if a user leaves one company and joins another. Then the old company's passwords must be changed so that this user may no longer have access, and the new password must be communicated to all existing employees of that company. If you do this the way I suggest, you just remove this user from the group belonging to the old company, and adds him to the group belonging to the new,. That is all that is needed to make sure that he loses access to the content belonging to his "old" company, and gains access to the content belonging to the "new" company.
> 5 votes

# Answer
Organic Groups is probably your best bet.

> Enable users to create and manage their own 'groups'. Each group can have subscribers, and maintains a group home page where subscribers communicate amongst themselves.
>
> They do so by posting the usual node types: blog, story, page, etc. A block is shown on the group home page which facilitates these posts. The block also provides summary information about the group.
>
> Groups may be selective or not. Selective groups require approval in order to become a member, or even invitation -only groups. There are lots of preferences to configure groups as you need.
> 2 votes

---
Tags: nodes, users
---


title: URL Rewrite trouble

text:
# Question
Title: URL Rewrite trouble
I have a website develop on Drupal 7 on IIS + MSSQL. I cannot update or create content when clean urls is active. The website return to edit form when i submit any change or new content.

If the cleans url is disable then the content is saved.

Please help me with this trouble.

Regards.

# Answer
Place the following debug statement in your index.php to debug your request:

```
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
debug($_GET['q']); //debug querystring
menu_execute_active_handler();

```

Now save/edit a node with and without friendly-urls.

If the values differ from each other, your rewrite-rules do not match. If the values are the same, something else causes the problem.

If so, its hart to say, what causes the problem. One hint: page requests are GET-requests, save/edit requests are POST-requests
> 2 votes

# Answer
Google is your friend. From IIS.NET:

> By default, Drupal uses query string parameters for all the URLs it generates for your Web site. With the URL Rewrite Module, however, you can create “clean URLs.”
>
> IIS 6.0 does not have URL rewriting capabilities, so you can use a third-party URL rewriting product such as ISAPI Rewrite or Ionics ISAPI Rewrite Filter.
>
> IIS 7 and above have URL rewriting support, which can be enabled by installing the URL Rewrite Module.
>
> The following instructions describe how the URL Rewrite Module for IIS 7 and above can be used to enable clean URLs in Drupal.
>
> 1. Open the Web.config file located in C:\inetpub\wwwroot\drupal folder. If you do not have a Web.config file in the WordPress directory, create it.
> 2. Copy and paste the following XML code into this file.

```
<?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="Drupal Clean URLs" stopProcessing="true">
                        <match url="^(.*)$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />
                    </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

```

> 1. Save the web.config file.

Then you can properly configure CleanURLs in drupal at `/admin/settings/clean-urls`
> 0 votes

---
Tags: 7, uri, iis
---


title: Cron set in Drupal UI or by server?

text:
# Question
Title: Cron set in Drupal UI or by server?
Under /admin/config/system/cron I can choose how often the cron runs. However do I still need to set up my server to ping the cron key (that I see in my reports page after I manually run the cron)?

How do these 2 work together? Is the server still required to run the cron, but then the cron wont run more often than is specified in Drupal's UI here: /admin/config/system/cron ?

# Answer
The value you set on the configuration panel determines how often Drupal will automatically trigger a cron during a page request, if it hasn't been run by some other means. This is what was provided by the module poormanscron in previous versions of Drupal, and it ensures that cron will get run even if you do not configure a job to do it on the server.

You should still provide a job to do it because it's not good for the unlucky visitor who happened to make that request to wait while cron runs. You need to set the job to run more often than the value configured on the panel so the poormanscron function never gets triggered.
> 1 votes

# Answer
Drupal has a built in "poor man's cron" which is invoked on a schedule when regular users visit pages.

Setting up a proper crontab entry (and turning off poor man's cron, i.e. set it to "Never") is usually the best thing to do.

If you set both, the poor man's (in-built) cron and also add a crontab entry to ping the cron URL, then yes the cron will run twice.
> 1 votes

---
Tags: cron
---


title: How do I choose a database?

text:
# Question
Title: How do I choose a database?
I am NOT a developer or DB guy but a webmaster who has manipulated mysql successfully for several wordpress sites. I know how to use the command line tool and also to run things via phpmyadmin. I know how to perform basic administrative mysql functions and occasionally to make a custom query.

I am setting up a drupal7 site on a VPS where I will already have a wordpress-mysql instance. But it occurred to me that there's nothing really stopping me from installing another db -- postgresql, SQLite, MariaDB. I am less interested in power than ease of use -- but obviously better performance would be welcome. I would probably need some management tool with a web interface. As I said, I wouldn't expect to be doing a lot of DB work; just the routine maintenance and rescue operations that occasionally are necessary.

The site should be a low or medium traffic site with not a lot of writes, but probably a lot of reads. There would probably not be enough traffic to do load balancing or clustering. (It's for a magazine site).

Is there any rule of thumb for which db to choose? Sticking with mysql seems to the obvious and easy solution; I'm just wondering if there's any reason to think differently in 2013.

# Answer
If you've got the choice I'd go with MariaDB.

It's a drop-in, transparent replacement for MySQL; any client connecting to it would think it's just accessing a regular old MySQL database. But you get advanced features and performance improvements out-of-the-box. It also has a very fast drop-in replacement for InnoDB.

It was written by the original MySQL developers (before Oracle got their hands on it) so it's a solid bet.

I've been using it for a little while and have been very happy with it.
> 2 votes

# Answer
Well choosing a database for your site depends on many ways, I prefer MySQL to keep it quite simple.

MySQL is preferable PHP sites because:

* Drupal 7 now comes with default table engine which is InnoDB(advantages over MyISAM) for MySQL
* MySQL has choice of table types for better read performance.
* Drupal has PHPMyAdmin Web Interface for MySQL.
* WAMP,XAMP comes with MySQL so it makes life easier when you use MySQL
* Drupal's much better tested with MySQL

http://drupal.org/node/37268
> 2 votes

---
Tags: database
---


# Question
Title: "messages status" div not showing up when submitting page comment
"messages status" div not showing up when submitting page comment.

It's just a regular old page content type and "messages error" div shows up fine in same place... when I try to submit a comment and leave something blank.

But, if I fill everything in, then the comment goes through and shows-up, but it doesn't get me the expected "messages status" div (the div tag doesn't show-up there at all.)

After successfully submitting a comment, it goes to a URL something like this: http://mywebsite.com/pages/2013/april#comment-4563

page.tpl.php - Looks good: `<?php print $messages ?>`

It should say something similar to what another Drupal 6 site of my says:

> Your comment has been queued for review by site administrators and will be published after approval.

Someone else set the site up, so I have no idea when it stopped working... I'm going thru opening permissions and disabling various modules...

Does anyone have any clues or answers on why this would happen?

Any help, would be greatly appreciated... Thanks in advance!

# Answer
I would look at the following permissions:

to see what is going on. On first blush, I'm going to assume `post comments without approval` is checked for more roles than you want or expect.

You can also surf over to `admin/content/node-type/CONTENT-TYPE` and click on "Comment settings" to see if anything is set for that specific type of node.

If these don't give you any "AHA!" moments, look around to see if any other comment approval modules are in place on the system.

Also, a lot of page.tpl's in D6 wrap their various content areas with something like this:

```
<?php if ($messages): ?>
  <div id="messages">
    <?php print $messages; ?>
  </div>
<?php endif; ?>

```

which basically means if you don't have any content for that area, there is no need to print an empty `<div>` which probably explains why you aren't seeing anything (eg, there was no message in the first place).
> 0 votes

---
Tags: 6, comments, status-messages
---


# Question
Title: How to add Email field in Checkout page and sending E-mail in Drupal Commerce?
I did cart using "commerce\_kickstart-7.x-2.4-core" module. I would like to add "Email Id" field when doing a checkout. Actually I need that If user provides different email Id's rather than registered mail-id in "BILLING INFORMATION" and "SHIPPING INFORMATION" then after completion of Checkout process, the product payment details should send mail to those E-mail Id's.

Rules export

```
{ "rules_check_order_for_billing_information_mail" : {
    "LABEL" : "Check order for Billing information Mail",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "commerce_checkout" ],
    "ON" : [ "commerce_checkout_complete" ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "commerce_customer_profile",
            "param_type" : "billing",
            "param_user" : [ "site:current-user" ]
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      },
      { "mail" : {
          "to" : [ "entity-created:field-billing-email" ],
          "subject" : "Test Subject for Billing mail",
          "message" : "Test Message for Billing mail",
          "language" : [ "" ]
        }
      }
    ]
  }
}

```

# Answer
> -1 votes
Atlast, I found the solution. Just by Adding Actions -\> Send mail -\> In Field "TO" -\> \[commerce-order:commerce-customer-billing:field-billing-email\]. Simply I got Mail. Thanks for your Contribution.

# Answer
> 2 votes
I believe you are using Customer Profile for asking customer billing and shipping address.

* So navigate to Store-\>Customer profiles-\>Profile types-\>Billing/Shipping Information-\>Manage fields.
* Add one more fields in there for email & make that mandatory.
* Add a checkout rules, put condition like "Entity has field" & check your added field.
* Add a action "Send mail" and select your added field in TO field & organize your template using tokens of commerce-order.

I hope this will work, though there are other way working around code.

---
Tags: commerce
---


# Question
Title: How to set the sizes for image thumbnails
When I am editing "Image" content type there is an option:

Where can I changes sizes of these previews? And regenerate the corresponding pictures?

# Answer
These are the same settings as for your normal image styles. You can manage them here: admin/config/media/image-styles. Klick on edit on the rhs, then "override defaults", then edit the effect.
> 3 votes

# Answer
From your image it looks like you are setting the image style of the preview. This is the admin/editor preview of this image field (when editing content). If you would like to set an image style shown to the public, the easiest way would be to manage display for your content type and choose an image style for your image field there. (Look for the manage display tab)

As Volker said you can edit image styles and create new image styles here: admin/config/media/image-styles and then use these in your manage display settings.
> 0 votes

---
Tags: media
---


# Question
Title: How to get rid of the default field markup
I need to customize registration form fields. Drupal generates form fields like this:

```
<div>
 <label>Name</label>
 <input type="text">
</div>

```

but I need to leave just `<input>` and be able to add some other tags around it.

For example:

```
<ul>
<li><span>Name</span><input type="text" /></li>
</ul>

```

It seems to be a common problem as the default html fields markup don't always what needs to be applied in particular html templates.

What is the best approach to this?

# Answer
> 2 votes
As with pretty much everything like this in Drupal, the answer lies in overriding theme functions/templates.

That markup is added by the `theme_form_element()` function; to override the output for that function simply add a function like this to your theme:

```
function THEMENAME_form_element($vars) {
  // ...
}

```

And change what you need to from the original function (e.g. replace `<div>` with `<ul>` if that's what you need). You might also need to override some of the individual element templates (depending on exactly what you want to do).

Some examples of those:

---
Tags: theming, forms
---


# Question
Title: Altering select elements to include data-img-src
I am trying to create a content type with select list options that are replaced by images that you can pick.

Plugin here http://rvera.github.io/image-picker/

How would I go about altering the option element to include the data-img-src option?

```
<option data-img-src="img/01.png" value="1">  Page 1  </option>

```

Any help would be appreciated.

# Answer
> 1 votes
Looking at:

http://api.drupal.org/api/drupal/includes%21form.inc/function/form\_select\_options/7

It appears there's no way to add your own attribute to the select option from the form builder.

You may need to override theme\_select to call a custom select\_options handler instead, that checks some of the form data and adds the attributes to the option element.

http://api.drupal.org/api/drupal/includes!form.inc/function/theme\_select/7

---
Tags: nodes, entities
---


# Question
Title: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'fmotors_fms.block_node_type' doesn't exist:
This was working fine last night but when i login to my computer again I got this error now. What is this table `{block_node_type}` I cant find it in the database but it is in the drupal code in node.module. PLease help

# Answer
If it was working last night, and now it doesn't and the table is missing, then the table has been deleted/renamed, or the database is partially corrupted. There isn't any other logical explanation.

As you rightly say that table is installed, unconditionally, by the node module upon installation of Drupal (see `node_schema()`).

If the table is really gone then your only option is to restore the DB from a backup; or if there was no data in that table, just manually create it (or copy from another Drupal install).
> 1 votes

---
Tags: database
---


# Question
Title: Permit user roles to see node (not via view) based on a taxonomy
I have some content type with a term reference field (think a magazine site where news are linked to a category).

I must block the node view for a user role, but I don't want to set this access for single node (like tac/tac\_lite do), but for single category linked to the node (via term reference field). For example I want that role "FOO" can see node of category "BAR" but not nodes of category "XYZ", where "BAR" and "XYZ" are terms od f the same vocabulary.

My idea is this:

* add a select list field to the vocabolary's fields (and the allowed values will be the role's ID) so that I can link role to each category/term
* when a user try to access to a node, I check (via hook\_node\_access() ) that current user's role is available in the node's category fields (that I have setted in previos step).

Is there a better way ?

M.

# Answer
You can do your own implementation of hook\_node\_access in a custom module. It passes you the node and the user object, so you can check for certain criteria, and limit access appropriately.

http://api.drupal.org/api/drupal/modules!node!node.api.php/function/hook\_node\_access/7
> 0 votes

---
Tags: 7, users
---


title: portfolio/sorting/gallery

text:
# Question
Title: portfolio/sorting/gallery
I want to use Views Quicksand for one of my websites. I downloaded the zip folder and put it in

> \[yourdrupalroot\]/sites/all/modules/views\_quicksand/.

Now Views Quicksand shows under the modules tab, but its disabled and says some files are missing. I can't enable it by enabling the checkbox because its not clickable. Please help me in activating the plugin to give the desired effect (http://razorjack.net/quicksand/) to my portfolio page.

# Answer
did u forgot to use js plugin with it.

> Download 'jquery.quicksand.js' from 'http://razorjack.net/quicksand/' and put it into \[yourdrupalroot\]/sites/all/libraries/jquery.quicksand/
> 0 votes

# Answer
As Volker said earlier, please download and enable the missing modules:

By doing so you will be able to click and enable the Quicksand module(s).
> 0 votes

---
Tags: views
---


title: PHP in database: bad practice but

text:
# Question
Title: PHP in database: bad practice but
Lots of times here I've been told that using views custom php fields, filters or others is a bad practice, because **putting php in the sql is dangerous**.

My question is, **if you only call to a function, that you defined in a module, is it still as bad**?

Sometimes, especially for Views, making a custom handler, or, other example, a custom token, can be really heavy.
What are the risks if I make a custom field that only calls a function? Is it as dangerous and "forbidden"?

# Answer
Here's my take on it:

The PHP docs says about `eval`:

> **Its use thus is discouraged**

It is *always*, let me emphasize that again, **always**, bad to use the PHP module (technically eval, but the PHP module makes a dangerous language feature much worse).

Details discussed in this question: What are the downsides of using PHP Filter code in blocks, nodes, views-args, etc?

The link provided by Clive claims

> Sometimes eval is the only/the right solution.

It is possible that this is true, some times, but during quite a few years of professional development, I have *never* stumbled across a real need for it, in PHP or other languages.

Personally, I've taken it to the level that my servers disable the functionality on the php level itself, with `disable_functions = eval`.

With that said, on a small personal website, it's likely of less consequence than on a large enterprise one, and there are cases where it's at least not completely horrible to use it.
> 8 votes

# Answer
There are some great answers here, but I don't think they address *why* it's a security issue to allow php execution inside the CMS.

In my opinion the problem with php.module and other modules that do their own eval is that it makes it so anyone who can exploit your Drupal site (see *note* below) has the ability to run arbitrary php. The WordPress brute force attack going on now is getting admin (i.e. uid 1) permissions on WordPress sites. If that gives someone the ability to just deface the sites then that's a meddlesome problem, but not much more. If it gives them the ability to run arbitrary php (which it usually does) then it's horrific for those sites, other sites hosted on the same server, and even the internet as a whole: the sites become a massive botnet that can do whatever their owner wants.

If WordPress didn't allow php execution would it be a worthwhile target for this attack? Probably not.

So, what can you do? letharion's tip about disable\_functions is a great one. There's also the paranoia module which can help reduce people's ability to execute php.

* Note: I said "exploit your Drupal site" which is pretty generic. It could be done via brute forcing an admin password, social engineering access to email and then doing a password reset mail, session sniffing, an XSS attack or maybe even a few other ways. But once an attacker has that kind of attack...the eval feature means your whole server becomes a great tool for the aettacker.
> 6 votes

# Answer
Be aware adding invalid PHP code to a form textarea can bring your site offline with a fatal error. It also makes it difficult to determine where functionality is being added from, if nothing can be found in the source code files and is instead in an obscure database field.

While it's tidier to call a function defined in a module, where the source code can be tracked properly, if you're going to do that, it's recommended to export and store those Views etc.. using a module like Features so that the configuration and code can be tracked properly in version control.

In most cases there's an API equivalent where the PHP code would better reside, for example hook\_block\_view or a custom Views argument handler.
> 3 votes

---
Tags: 7, database, security
---


# Question
Title: Views: Filtering nodes on the basis of logged in user role
Is it possible to filter out nodes with respect to current user role? For example, I want to create a view where users can see the all the published nodes as well as the unpublished nodes they have created. And if current user is a site admin, he should be able to see all the nodes. Is it possible using views?

# Answer
Yes, you can use node "Author uid" as the "Contextual filter" in the views and can set default value as "User id from logged in user" or "User id from URL" for the "Author uid".

If you will select "User id from logged in user", then it will display the node created by the logged in user or if you select "User id from URL", then it will display the node created by the user id from the URL.

Regarding, displaying node published and unpublished, you need to set permission for user role to view "unpublished own nodes", so user can view his unpublished node.

For the site admin user, he can only view the node created by him. If you want to display all nodes to site admin, then you need to create another view.
> 1 votes

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


# Question
Title: Views - comprehensive source for studying?
Making my first website I've been playing a lot with Views recently but I am still struggling to master both Relationships and Contextual filters. I've watched the video trainings provided in the views' section as well as passed through the docs but I think that's not deeper enough. Could you guys suggest some source for studying on this topic - a book, video series, web page ... ? Much appreciated :) BR, Ivan

# Answer
By all means - start the Taming the Beast screencast series by NodeOne: http://nodeone.se/en/learn-views-with-nodeone-part-1-overview
> 5 votes

---
Tags: views
---


title: Share content with All Groups

text:
# Question
Title: Share content with All Groups
Is there a way around to get Share with All Groups option in the group audience field for a specfic group content type.With share with All Group I mean to say share content to all groups we are not even if are not member of. I am using og module on drupal 7 installation.

# Answer
I managed to it with some custom coding basically i alter the form add a one more option to group audience field and then on form validation I am checking if user has input that field then I am making a db query to grab all og groups on site and then assign the group ids to the group audience field,looks kinda hackish but did'n get any better solutions.
> 0 votes

---
Tags: organic-groups
---


# Question
Title: How can I omit downloading default themes in drupal core in make file
Is it possible to not download the default themes- e.g. bartik, garland etc, in my make file when I download the drupal core?

# Answer
> 1 votes
No, I do not believe a makefile (assuming you mean Drush Make) can do this. Deleting the actual theme files is not the best approach, since each time core is updated they will be re-downloaded.

If you want to remove core themes from the Appearance admin section, you can hide them with hook\_system\_info\_alter().

```
function example_system_info_alter(&$info, $file, $type) {
  if ($type == 'theme' && $info['name'] == 'Bartik') {
    $info['hidden'] = TRUE;
  }
}

```

---
Tags: drush
---