# Question
Title: How to save an uploaded image in an admin form?
I wrote the following module to upload a background image. My problem is, that my submit function is not called, though the pic is uploaded and showed in the block until the next cleanup is coming.The managed file table shows status 0...what should be 1 as far as i know.

Here is the Code of my Module: Whats the mistake?

```
function backgroundimage_block_info() {
    // This example comes from node.module.
    $blocks['backgroundimage'] = array(
        'info' => t('Background Image'),
    );

    return $blocks;
}
function backgroundimage_block_view($delta = '') {
    $fid_now=variable_get('backgroundimage');
    dpm($fid_now);
    $file_obj = file_load($fid_now);

    $bg_img_url = file_create_url($file_obj->uri);

    // This example is adapted from node.module.
    $block = array();

    switch ($delta) {
        case 'backgroundimage':
            $block['subject'] ="imagebackgroundblock";
            $block['content'] ="<div class='background-image'><img src='".$bg_img_url."'></div>";

            break;

    }
    return $block;
}
function backgroundimage_admin() {
    $form = array();

    $form['backgroundimage'] = array(
        '#type' => 'managed_file',
        '#name' => 'backgroundimage_image',
        '#title' => t('upload image, huh!'),
        '#default_value' => variable_get('backgroundimage', ''),
        '#description' => t("Here you can upload an image to the background!"),
        '#required' => TRUE,
        '#upload_location' => 'public://backgroundimage/'
    );

    return system_settings_form($form);
}
function backgroundimage_form_submit($form, $form_state) {
    dpm("yeah"); // is not being called!
    $form['backgroundimage']['#file']->status = FILE_STATUS_PERMANENT;
    file_save($form['backgroundimage']['#file']);
}

function backgroundimage_menu() {

    $items = array();

    $items['admin/settings/backgroundimage'] = array(
        'title' => 'Settings Background Image',
        'description' => 'Image upload',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('backgroundimage_admin'),
        'access arguments' => array('administer backgroundimage settings'),
        'type' => MENU_NORMAL_ITEM,
    );

    return $items;
}

?>

```

Thanks a lot!

# Answer
You have used `system_settings_form_submit()` so you can add custom submit handler for your form by adding this code to your `hook_menu`

```
function backgroundimage_admin() {
    $form = array();

    $form['backgroundimage'] = array(
        '#type' => 'managed_file',
        '#name' => 'backgroundimage_image',
        '#title' => t('upload image, huh!'),
        '#default_value' => variable_get('backgroundimage', ''),
        '#description' => t("Here you can upload an image to the background!"),
        '#required' => TRUE,
        '#upload_location' => 'public://backgroundimage/'
    );
    $form['#submit'][] = 'backgroundimage_form_submit';
    return system_settings_form($form);

}

```
> 8 votes

---
Tags: 7, files
---


title: Multiple Image upload in drupal 7

text:
# Question
Title: Multiple Image upload in drupal 7
I want to upload mulitple image at a time , for more clarification i have mention below link

http://www.olx.com.pk/posting.php?categ\_id=378

when you click on add photos , you can upload 20 picture at a time.

# Answer
> 1 votes
This has been answered before, but I can't mark it as a duplicate or flag.

You can use the the Plupload module to allow multiple uploads and even set limits by going into the code.

# Answer
> 1 votes
http://drupal.org/project/swfupload is a widely-used multiple image upload module. There are installation instructions here and if you run into issues be sure to read through the issue queue before posting a support ticket!

How to install SWFUpload for Drupal 7:

1. Download the FileField module.
2. Download the jQuery Plugin Handler (jQp) module. This module is required for loading the SWFUpload javascript library.
3. Place both modules, as well as the SWFUpload module, in your module directory. (`sites/all/modules`)
4. If you do not have created a 'libraries' directory yet, create one. (`sites/all/libraries`)
5. Create a new directory called 'swfupload' inside the 'libraries' folder. (`sites/all/libraries`)
6. Download the SWFUpload 2.2.0.1 release.
7. Copy the files 'swfupload.swf' and 'swfupload.js' to the swfupload folder inside the libraries folder. The end result will read: `sites/all/libraries/swfupload/swfupload.js` and `sites/all/libraries/swfupload/swfupload.swf`
8. Enable this module by navigating to: `admin/build/modules`
9. Ensure the library is available by visiting: `admin/build/jqp/swfupload/`

# Answer
> 1 votes
You may also want to consider http://drupal.org/project/multiupload\_filefield\_widget.

Used with his little brother http://drupal.org/project/multiupload\_imagefield\_widget, it should do the trick.

Really easy to install.

# Answer
> 0 votes
go for module plupload

\[relationship\] (http://drupal.org/project/plupload

kindly go through readme.txt for more information regarding module.

---
Tags: media
---


# Question
Title: Formatting elements without formatting similar elements throughout entire site
So I've been fiddling around with elements, or blocks around my site.

I find the element or item I want to change my right clicking it in my browser and clicking "Inspect Element". Then, I find where the CSS file is and head to that directory in my FTP client. When I find the class or styling section, I copy that to my theme's global.css file.

However, when I edit some class/header/basically anything, any other object in my site that uses the same titled class is affected.

If my descriptions aren't very clear, here's my attempt at clarification. So let's say www.example.org/home has a H1 class that I'd like to center to the left. But there's an element over at www.example.org/aboutus that also uses the H1 class style. If I copy and edit the H1 class into my global.css file, both of those elements are affected, when I only want the one at www.example.org/home to be changed.

Is there a way to go around this? Should I try renaming the class that the element in www.exmaple.org/home so that it doesn't end up using the same class as everything else?

# Answer
> 0 votes
while writing your css for any html element you need to be more specific. Suppose you are writing a css for an h1 tag which you want to get applied on that tag only , then be more specific by giving the h1 tag an id or class so that this css do not apply on other tags .More over you can alos filter your result as shown... eg you have a h1 tag in your header region eg.

```
<header>
<div id="first">
<h1> Hello There i am in header tag region 1</h1>
</div>
<div id="second">
<h1> Hello There i am in header tag region 2 </h1>
</div>
</header>
<h1> How are you I am not in header tag</h1>
CSS
h1 {                            for last h1
color :red;
}
header #first h1 {
color:green;
}
header #second h1 {
color:blue;
}

```

.. output

# Hello There i am in header tag region 1 and i will be green

# Hello There i am in header tag region 2 and i will be green

# How are you , i will be red

................ now if you write your css in this way.. h1 { color : #262626 ; } then it will get applied to all the h1 tags...so you just need to be more specific you can also filter the tags by using pseudo classes... you can learn about the css specificity on these links...

http://www.youtube.com/watch?v=0ZOV-KTTI1E

http://www.youtube.com/results?search\_query=css+specificity&oq=css+spe&gs\_l=youtube.1.2.0l4.1505.7011.0.9461.7.7.0.0.0.0.247.1042.1j4j2.7.0...0.0...1ac.1.\_LOJTw6jxBA

---
Tags: theming
---


title: What exactly is a theme?

text:
# Question
Title: What exactly is a theme?
I am an experienced programmer in various languages, and also have experience with web development. I am new to Drupal, and as with any new platform there is sometimes a language barrier. I've read drupals small documentation on theming on their site, but I just want to make sure I'm wrapping my head around this correctly.

The way I understand it, a theme in Drupal is a site's skeleton, the basic HTML and CSS. If that's true then I at least have that part right. Where I'm losing it is where does the theme stop, and web design/content development start? For example, what exactly should I expect when I download a Drupal theme/template, should I be editing the theme directly to add my images and text, or is there specially created modules for that I'm just not seeing? Is it common practice to sub theme or just edit the theme directly?

# Answer
Just as structured programming revolutionized system building, modern web sites have strived for a conceptual structure. Today we try as far as possible to separate information, process and presentation. Think of the three as a venn diagram of overlapping circles: content, function, and theme.

Images and text are information, and the core and modules necessary to work with them are function.

The theme is the look and feel, the overlap is your information architecture. In Drupal, you can retain the same function and information, and completely change the presentation by changing the theme.

Think of it as structured programming taken to the next level.
> 2 votes

# Answer
Making a Drupal website look non Drupal is an overwhelming task. Themes help you to do exactly the same thing. Drupal provides more than 1600 themes with which you can play around and customize your site as per your requirements. Sticking to your questions:

1.The best practice is to decide your website's layout first and do primary theming.

2.This can be done better by creating a sub-theme out of an existing popular theme. Later you can start with the content addition and finally use some css to give it the perfect look.

Mostly content addition is done post theming to avoid designing issues.
> 2 votes

# Answer
Look at this template. This will explain how the theme doing in drupal.
> 1 votes

# Answer
Themes allow you to change the look and feel of your Drupal site. You can use themes contributed by others or create your own to share with the community. Contributed themes are not part of any official release and may not have optimized code/functionality for your purposes. You can also create a sub-theme of an existing theme. A sub-theme inherits a parent theme's resources.

For more information about what theme is and how how to go around theming refer to http://api.drupal.org/api/drupal/includes!theme.inc/function/theme/7 and could read about different themes and what the features they provide you could refer to http://drupal.org/project/Themes......

Cheers...
> 1 votes

# Answer
theme is basically used in drupal to design the site layout . you can use the theme others have contributed or u can create your own theme .

for better theming experience i think u should go for "Omega theme" in drupal through this you can create your own theme in a much better way.

for more information regarding omega theme working you can also refer to free tutorial on drupalize.me .

also in theming basically we have block structure and those blocks are space where we place over node like articles views n all other stuffs

you can add your custom css in sites/all/theme/global.css file :)
> 0 votes

# Answer
1.Themes allow you to change the look and feel of your Drupal site. 2.you can create your own theme and can also download one. 3.there are built in themes which provide their own css. 4.you can modify the css provided as per your requirement. 5.there are 2 types of themes- a) responsive theme b) not responsive themes. 6.Responsive themes are the one which can have different layout of a single site according to the device..for eg:different layouts for tablet,mobile. 7.Unresponsive theme maintain the same layout throughout irrespective of any device used and any resolution used.. 8.for better understanding of themes-refer thos--http://drupal.org/node/1351116
> 0 votes

---
Tags: theming
---


# Question
Title: Drupal 7 and google maps, distribution or modules
Throughout my apprenticeship with Drupal 7 I always wondered if it is able to do this:

I mean inserting Google map and how it interacts with such websites.

For example: in Teslamotors page, at the top there are buttons: "N. AMERICA EUROPE and ASIA / PACIFIC "and that by giving clik in each, the map is changed geographical position.

Another example that I'm interested in this page (teslamotors) is seen as the pinmaps update when I press the buttons (which are at the bottom center of the map inside): "STORES & GALLERIES" or "service centers." Geographical points are updated and change color.

Similarly we can see the same for the second page I share, on the button: "All Blogs" and see how the updated pinmaps position icons and very dynamic.

Can this be done with Drupal 7? Maybe, I do not know, and there is a distribution which contains all this attached, so I can analyze it and go familiarizing myself more with this fascinating Drupal platform.

# Answer
Both the Open Layers project and the Gmap module support google maps. Both can work with a number of geolocation types. See the modules for more details.

I am using both (in different sites) and either one can support what you are trying to accomplish. I would recommend Open Layers as more versatile, and Gmap as easier to use.
> 3 votes

# Answer
There is a Contrib module for this: the Geolocation module. Just download it, and install it. It actually it comes with 3 sub-modules you need to enable too.

Then, when you add a new field to to a content type, you will get a new option for a geolocation field.

In case you want to view the locations of all the contents of that content type on a single map, create a view and select the format to be "Geolocation (Google Maps)"; this view will show all the locations of the contents on a single map.
> 3 votes

# Answer
The Geolocation Field and Geolocation Views modules are a great place to start. Use GF to add geolocation to your custom content types. Use GV for displaying the map as well as the info windows.

There are no README yet. So look into the issue queues of GF and GV for more information.
> 1 votes

---
Tags: 7, google-maps, distributions
---


# Question
Title: Migration not importing into image fields
I'm working on a Migration class to import from a depreciated WordPress plugin and everything's just about there -- everything succeeds when importing and there aren't any errors; taking the SQL from Migrate UI and plugging it into MySQL yields the data table I need.

However, the images aren't importing at all. None of the relevant tables -- file\_managed, field\_data\_field\_photo -- are updating.

All images are already in /sites/default/files/wp-content/uploads/. The paths are stored like "2012/10/image.jpg" (I.e., year/month/filename) in the source database.

Hugely grateful for any help.

```
<?php
/**
 * @file
 *  Migrating WordTour WordPress plugin to OpenMusicFestival on Drupal.
 */

abstract class WordTourMigration extends Migration {
  public function __construct() {
    // Always call the parent constructor first for basic setup
    parent::__construct();
  }
}

class ArtistMigration extends WordTourMigration {
  public function __construct() {
    parent::__construct();

    //Set up other database

    Database::addConnectionInfo('wp', 'default', array(
          'driver' => 'mysql',
          'database' => 'db_wp',
          'username' => 'user',
          'password' => 'pass',
          'host' => 'localhost',
          'prefix' => '',
        ));

    $this->description = t('Migrate the artists!');

    $this->map = new MigrateSQLMap($this->machineName,
        array(
          'artist_id' => array(
                           'type' => 'int',
                           'length' => 7,
                           'not null' => TRUE,
                           'description' => 'Artist ID',
                          )
        ),
        MigrateDestinationNode::getKeySchema()
      );

    $query = Database::getConnection('default', 'wp')
           ->select('artists', 'a');
    $query->join('attachment', 'at', 'a.artist_id = at.attachment_target_id');
    $query->join('attachment', 'att', 'a.artist_id = att.attachment_target_id');
    $query->join('postmeta', 'pm', 'pm.post_id = att.attachment_type_id');
    $query->fields('a',
              array(
                  'artist_id',
                  'artist_name',
                  'artist_publish_date',
                  'artist_bio',
                  'artist_record_company',
                  'artist_social_links',
              )
            );
    $query->fields('pm', array('meta_value'));
    //$query->addField('pm', 'meta_value', 'photo');
    $query->addExpression('GROUP_CONCAT(DISTINCT at.attachment_info)', 'genres'); //Pull in genres.
    $query->condition('at.attachment_target', 'artist');
    $query->condition('at.attachment_type', 'genre');
    $query->condition('att.attachment_type', 'thumbnail');
    $query->condition('pm.meta_key', '_wp_attached_file');
    $query->groupBy('a.artist_id');

    // Create a MigrateSource object, which manages retrieving the input data.
    $this->source = new MigrateSourceSQL($query, array(), NULL, array('map_joinable' => FALSE));

    // Set up our destination
    $this->destination = new MigrateDestinationNode('artist', array('text_format' => 'full_html'));

    // Assign mappings TO destination fields FROM source fields.
    $this->addFieldMapping('title', 'artist_name');
    $this->addFieldMapping('uid')
         ->defaultValue(1);
    $this->addFieldMapping('changed', 'artist_publish_date');
    $this->addFieldMapping('status')
         ->defaultValue(1);
    $this->addFieldMapping('promote', '')
         ->defaultValue(0);
    $this->addFieldMapping('sticky', '')
         ->defaultValue(0);
    $this->addFieldMapping('revision')
         ->defaultValue(0);
    $this->addFieldMapping('log')
         ->defaultValue('Migrated to Drupal 7 from WordPress.');
    $this->addFieldMapping('comment')
         ->defaultValue(1);
    $this->addFieldMapping('body', 'artist_bio')
          ->arguments(array('format' => 'full_html'))
    $this->addFieldMapping('created', 'artist_publish_date');
    $this->addFieldMapping('field_labels', 'artist_record_company')
          ->separator(', ')
          ->arguments(array('create_term' => true));
    $this->addFieldMapping('field_photo', 'meta_value');
    $this->addFieldMapping('field_photo:source_dir')
         ->defaultValue('/Users/aendrew/Sites/test/sites/default/files/wp-content/uploads/');
    $this->addFieldMapping('field_photo:preserve_files')
         ->defaultValue(true);
    $this->addFieldMapping('field_photo:destination_file', 'meta_value');
    $this->addFieldMapping('field_photo:file_replace')
         ->defaultValue(MigrateFile::FILE_EXISTS_REUSE);
    $this->addFieldMapping('field_photo:alt', 'artist_name');
    $this->addFieldMapping('field_photo:title', 'artist_name');
    $this->addFieldMapping('field_links', 'artist_social_links')
         ->description('See prepare()'); //Needs to be unserialized
    $this->addFieldMapping('field_genres', 'genres')
          ->separator(',')
          ->arguments(array('create_term' => true));
  }

  public function prepareRow($row) {
    watchdog('migrate', 'Filename is ' . $row->meta_value); // This is reporting correctly.
  }

  public function prepare(stdClass $node, stdClass $row) {
    //Set up the links
    $links = unserialize($row->artist_social_links);
    $empty = 'a:10:{s:13:"artist_flickr";s:0:"";s:14:"artist_youtube";s:0:"";s:12:"artist_vimeo";s:0:"";s:15:"artist_facebook";s:0:"";s:14:"artist_twitter";s:0:"";s:13:"artist_lastfm";s:0:"";s:14:"artist_myspace";s:0:"";s:15:"artist_bandcamp";s:0:"";s:13:"artist_tumblr";s:0:"";s:19:"artist_reverbnation";s:0:"";}';
    if ($node->field_links[LANGUAGE_NONE][0]['url'] == $empty) {
      unset($node->field_links);
    } else {
      $i = 0;
      foreach ($links as $site => $link) {
        if (!empty($link)) {
          $site_name = ucfirst(str_replace('artist_', '', $site));
          if ($site_name == "Youtube") $site_name = "YouTube";
          if ($site_name == "Lastfm") $site_name = "Last.fm";
          if ($site_name == "Youtube") $site_name = "YouTube";
          if ($site_name == "Myspace") $site_name = "MySpace";
          $node->field_links[LANGUAGE_NONE][$i]['title'] = $site_name;
          $node->field_links[LANGUAGE_NONE][$i]['url'] = urldecode($link);
          $i++;
        }
      }
    }
  }
}

```

# Answer
Apparently having the same source and destination directory mucks things up — I moved all the images outside of Drupal and suddenly everything works great!
> 5 votes

---
Tags: media, database, migrations
---


# Question
Title: Is there a way to determine what styles can be used for a nice menu?
I am attempting to style a 3-level "nice menu" but between the themes and menu styles, I am having a hard time finding the correct styles to change. I am using firebug, but I cannot get the styles for some menu items, because moving the cursor over them changes them to hover (or focus). Unselected menu items are not displaying consistently at all levels the way I want and I cannot identify the styles without hovering on them. I need to find out what the full styling options are so that I can figure out what is affecting them.

# Answer
On the HTML tab of firebug there is a "break no mutate" button that will stop whatever javascript adds/changes HTML. This can be used to trap something that is a result of a nice menus change. It can be a little tricky as each hover initiates some javascript and then when you continue execution the break on mutate is turned off, but it gets easier with practice :)
> 1 votes

# Answer
Mate...In nice menu when you hover the mouse over any list two things occurs...first of all the class of that element changes to :hover and after 1 second , a new class "over"is added to it using JQuery '.addClass("over")' function... so you need to do your css for that class...

li.over is the tag when mouse is over that tag.. li.menuparent ..is a tag who has sub list ul li...

CSS..(This Is the Css Tags I Have Used In My Project..)

```
ul.nice-menu ul {  /*Css for sublinks*/
}

ul.nice-menu li ul li ul { /*css for the sublinks*/
}

ul.nice-menu li ul li.menuparent a,
ul.nice-menu li ul li.menuparent ul li.menuparent a /*css for setting the sublinks menu images*/
    {
    }

ul.nice-menu li ul li.menuparent ul li a ,
ul.nice-menu li ul li.menuparent ul li.menuparent li a /*css for unsetting the sublinks non-menu images*/
    {
    }

ul.nice-menu li ,
ul.nice-menu li.over,
ul.nice-menu-down li.menuparent,
ul.nice-menu-down li.menuparent.over,
ul.nice-menu-down li.menuparent:hover { /*changing background color of the main menu links*/
}

ul.nice-menu-down li li,
ul.nice-menu-down li li.over,
ul.nice-menu-down li li:hover,
ul.nice-menu-down li li.menuparent,
ul.nice-menu-down li li.menuparent.over,
ul.nice-menu-down li li.menuparent:hover /*drop down sub lists css (changing color and giving padding)*/
        {
        }

ul.nice-menu-down a /*css for the main menu links*/
{
}

ul.nice-menu-down .over a ,
ul.nice-menu-down a:hover {/*css for the main menu links on hover*/
    }

ul.nice-menu-down .over a  /*css for the main menu links to expanded lists*/
     {
    }

ul.nice-menu-down .menuparent ul a { /* to the dropdown sublinks*/
        }

ul.nice-menu-down .menuparent ul li.first a { /* to the first link in drop down menu*/
            }
ul.nice-menu-down .menuparent ul li.last a {  /* to the last link in drop down menu*/

            }

```

Hope this will help..
> 0 votes

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


# Question
Title: Spam filter options for unregistered user to registered user email service
I would like to give unregistered visitors the chance to send emails to node authors through a contact form. What would be the best and most efficient way to filter out spam?

1) Simply add a CAPTCHA to the contact form. However, I experienced CAPTCHA module to be not very reliable and I won't be able to afford Mollom.

2) Involve an external Gmail account and make use of their sophisticated spam filters. For example, when user A submits a contact form on a node created by user B, the email is first sent to an external Gmail account, filtered, and then - if spam free - forwarded to user B.

# Answer
> 0 votes
As an alternative for Mollom, perhaps Akismet could work? The service runs analysis on the comments/posts and determines whether they are spam from their content.

As an alternative for Captcha, perhaps Are You A Human could work? Rather than using wobbly text it asks you to complete a very simple game - causing less frustration to your users.

To properly answer your question: Given the two alternatives, I think the most efficient way to filter spam would be through Gmail, although it might violate their EULA.

---
Tags: emails, captcha, advertising
---


# Question
Title: Drupal module versioning and compatiblity. How to know what to use?
Sorry if this is a really stupid question or if I should have been able to find it.

When it comes to module versions, how exactly does it work? Say for example the Openlayers module that has several other sub-modules, modules it integrates with, as well as modules/libraries it depends on.

Lets say open layers has the following available versions:

Reccomended: **7.x-2.0-beta5**

Other Releases: **7.x-3.0-alpha0**

Dev Releases: **7.x-3.x-dev** **7.x-2.x-dev**

Now it's time to install dependencies lets use "views module" for this case. Lets say it has these versions...

Recomended: 7.x-3.6

Other: 7.x-2.16

Dev 7.x-3.x-dev

So my question is do module updates/versions have any correlation on dependency modules? So in this situation if I install the Recommended : **7.x-2.0-beta5** of OPENLAYERS, am I suppose to install the Recommended : 7.x-3.6 of views or should I alternately install the version that has the 7.x-2.16 since both modules would then be in the same 2.x stage.

From what I've read patches are for minor releases like 7.x-2.{something) and only a major release would make a developer change to the next version 7.x-3.x. Also how does alpha, beta versions fit in with all this??? How is it that a alpha version of something is recomended over a non aplha or beta version?

The versions I've listed above are not real, but just an example. Hoverer, recently I do have issues with Openlayers and another module that required it. Both these modules had several stable versions and dev releases. Sine the sub-module is stable I'd assume it had a release that worked at one point in time with Openlayers. Is there a way to know this. Or is there a way to download using something like drush to chose dependency modules that are tested against openlayers version-whatever without problems.

Sorry for the long and horribly formatted question I hope someone can either answer or point me in the right direction to get some good documentation on this

# Answer
> 2 votes
Unfortunately, there are no rules. "Recommended" is just a flag set by the maintainer meaning "I think this is my most stable branch". Alpha and beta are also just labels, in the Drupal world beta often means "Works for me, but I don't want to create a full release yet."

You'd usually want to use a recommended release, if it's not too old (if it's a year old, yesterday's -dev will probably be better). Sometimes the -dev release is the most stable version of the code, if the maintainer doesn't create releases regularly.

When I have a dilemma such as yours (which version of dependency X should I use for module Y), I open an issue in the Y issue queue and ask. The maintainer knows best which code he optimized for.

# Answer
> 0 votes
Module versioning works like this:

DrupalMajorVersion.DrupalMinorVersion-**ModuleMajor.ModuleMinor-ModuleSpecial**

This means that the 7.x is your version of Drupal (i.e. any Drupal 7 version) and the 2.x-beta5 part is the version of that particular module.

With that said, you can safely install the recommended version of Views (3.6) and it should work fine with Openlayers' 2.0-beta5. (Assuming they dont explicitly tell you otherwise).

---
Tags: community-official-site
---


# Question
Title: Porting a multi-site setup to local (MAMP) server
There seems to be plenty of tutorials about setting up a local multi-site installation, however, I cannot seem to find any information about porting a live multi-site to a local environment.

Specifically I want to work on just one of the sites from the live setup. I am using Drupal 6. Here are the steps I have taken:

1. I have setup a database on my local MAMP server with the same name as one of the live sites that I want to work on.
2. I have imported the mysql dump of just the database I want (removing the others multisite sites from the dump).
3. All site files transfered to a folder in my MAMP\>htdocs\>new-folder-name
4. In new-folder-name\>sites\>desired-site-folder\>settings.php I've set the db\_url variable to `mysql://root:root@localhost/dbname`

What further steps do I need to take? When I navigate to the local site I get the 'It works!' message. I presume I maybe need to set up a htaccess file to redirect, but if so, how should it be formed?

# Answer
> 2 votes
Unless you've got MAMP pro, or have set it up as such (which you haven't mentioned) vhosts probably won't be enabled; Apache will be looking at MAMP \> htdocs for the web root, not any folder underneath it.

Try moving the Drupal web root up one folder (i.e. directly under MAMP \> htdocs) and try again

---
Tags: multi-sites, .htaccess
---


title: Help with Web forms

text:
# Question
Title: Help with Web forms
I would like to create a simple form that allows a teacher to enter the individual names of their pupils. I would then like to create another form that returns the individual names of the pupils one at a time and allows the teacher to input a score next to the name. is there a module that would allow me to do this

# Answer
> 2 votes
drupal itself provide a module "webform" for manipulating webform

before you use module just go through readme.txt for better understanding just download the module :)

# Answer
> 0 votes
alternatively Entity Form

I find this one more powerful out of box, however it all depends on what exactly you would like to achieve.

---
Tags: 7, webforms
---


title: Multiform/Wizard module

text:
# Question
Title: Multiform/Wizard module
I'm looking for a module, that changes the workflow of creating a node. I want to be able to have several fields in named group sections so the author of a node has some structure.

But when editing the node the author should be able to quickly jump around the forms.

So for example the Content Type "Article" has the following group sections:
Content \> Images \> Related Articles

In each section there are fields.

How can I do that? Are there mature modules for that case?

# Answer
You could check out the field group module. You have several options to group your fields:

> ```
> Fieldsets
> Horizontal tabs
> Vertical tabs
> Accordions
> Divs
> Multipage steps: Note: This is only client side.
>
> ```
> 1 votes

---
Tags: 7, forms
---


title: Multisite for intranet/extranet

text:
# Question
Title: Multisite for intranet/extranet
I'm currently developing a Drupal environment for a school project. I've already read a few books about Drupal, but still need to improve my skills when it comes to programming.

The project exists of developing a new intranet/extranet for existing content. Currently, the intranet/extranet exists of standard html files linked to eachother. The content on the intranet(intranet.example.com) is only available for users on the company network. However, some content needs to be available on the extranet (extranet.example.com).

I'd like to use one Drupal installation to manage all content, users... Is this possible by using a multisite configuration?

# Answer
> 1 votes
Multi-site is designed for a shared codebase with seperated content. It is possible to share a few tables within all multi-sites without complications (e.g. users, roles, session) but espacially sharing of content and content-types is not quite easy.

I would suggest **Domain Access**: http://drupal.org/project/domain

> The Domain Access project is a suite of modules that provide tools for running a group of affiliated sites from one Drupal installation and a single shared database. The module allows you to share users, content, and configurations across a group of sites

# Answer
> 0 votes
I think this will work for you really well:

Organic Groups

Documentation is great and you can find many videos on youtube explaining how to work with this module (I'm using it myself for exactly the same purpose)

I wouldn't use multisite for that as per

> However, some content needs to be available on the extranet...

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


# Question
Title: how to select different colorbox styles for different content types in drupal 7?
i tried to select different colorbox styles for different content types but i couln't. because we can select only one colorbox style for all using.

if onybody know how can select different colorbox style for different content type please help me

# Answer
There is no way to do it from admin UI. Formatter settings also has no option to select style for current image display.

But you can try the following:

```
function [themename]_preprocess_node(&$vars) {
  if ($vars['type'] == 'node_type' && $vars['view_mode'] == 'full') {
    variable_set('colorbox_style', 'stockholmsyndrome');
  } else {
    variable_set('colorbox_style', 'default');
  }
}

```

Yep, it's dirty hack, but it can helps... maybe... =)
> 1 votes

---
Tags: nodes, javascript
---


# Question
Title: Customizing tableheader.js Sticky table Header
As I am having a custom "position:fixed" top navigation bar in my admin pages, the sticky table header are being hidden behind it when I scroll-up.

I went through tableheader.js and saw there is a Drupal.settings.tableHeaderOffset that helps change the "top" property, but I don't know where I should override it. Possible to do it in my template.php?

Also, I would like to change the position that triggers the sticky header to change visibility from hidden to visible...

```
  // Track horizontal positioning relative to the viewport and set visibility.
  var hScroll = document.documentElement.scrollLeft || document.body.scrollLeft;
  var vOffset = (document.documentElement.scrollTop || document.body.scrollTop) - this.vPosition;
  this.stickyVisible = vOffset > 0 && vOffset < this.vLength;
  this.stickyTable.css({ left: (-hScroll + this.hPosition) + 'px', visibility: this.stickyVisible ? 'visible' : 'hidden' });

```

# Answer
You can override tableheader.js using `hook_js_alter(&js) {}`, just replace path of file, like in example (details here).

Also you can override `Drupal.settings.tableHeaderOffset` value. Thus, in template.php place something like this:

```
drupal_add_js('themeTableHeaderOffset() { return 200; }', 'inline');
drupal_add_js(array('tableHeaderOffset' => 'themeTableHeaderOffset'), 'setting');

```
> 1 votes

---
Tags: javascript, theming
---


# Question
Title: obscuring email addresses in user to user email conversation
my registered users can send each other proper emails (not private messages) through contact forms on their user profiles. When user A sends such an email to user B, I need user B to be able to reply to the email that was sent by A such that the two can start having an email conversation.

\*) How can I encrypt the sender's and the recipient's email address such that the original email addresses of A and B are **never** revealed, even if the whole email conversation - after being initiated through the contact form - continues in their external email mailboxes?

Let me elaborate this a little bit further, even though I don't know if the path I am suggesting to take is at all feasible: To each user I assign a randomly generated key, e.g. 1k1 for user A and ki8 for user B. I would then set up the contact form on the profile of A such that every submission gets sent to 1k1@mydomain.com. Then, how can I make sure that every email going to 1k1@mydomain.com automatically gets forwarded to the *actual* email address of user A? If this could be done, I would simply replace the sender of this forwarded email with ki8@mydomain.com and upon reply start over again.

# Answer
Setting up a mail forwarding system would require a properly configured email server with access to the Drupal user tables. You could certainly configure a program like Exim to accept email for username@yourdomain.com and forward it to that users email address. The problem is one of authentication. You would somehow have to leverage Drupal's authentication system for the mail server. Not quite sure how to start that.

If you did not require authentication, then the mail server becomes an open relay for your domain and will probably end up on several blacklists.

I would recommend you just let this one go. Using contact forms, the recipient's email address remains unknown to the sender until the recipient replies. These are decisions your users make as they initiate and accept a conversation. Let them make the decision.
> 2 votes

# Answer
I think this is perfectly possible, though out of the scope of Drupal to some extent. Drupal can set from and reply\_to headers in the mails sent out to, eg "John Doe \<abc@mydomain.com\>". You'd have to then set up a mail service on the domain which would receive any replies and forward them to the correct users. How you would configure the mail service is a matter for another forum, I think.

(I suggest you edit the original question to make it about obscuring or masking the original email address rather than encrypting it. What you describe is not really encryption.)
> 2 votes

---
Tags: 7, rules, emails
---


# Question
Title: Suggestions for sending email to third party merchant when checkout is completed
I need to build a site that will sell products on behalf of merchants referenced on the site and I need to notify these merchants every time a sell of their products occurs and send them information about the order we received for their product. Out of the box, commerce uses rules to send an email to the buyer and can also notify the site admin that a new order was created.

That is great but what if I need to notify a third party? Is there a way to do this out of the box or via configuration? Or is there a module for that? I have been looking and couldn't find anything. When I try to use rules the only email available for order checkout as tokens are the customer email and the site admin email.

For the sake of clarity here is the setup I have gone for so far and where I am stuck:

I have setup a field collection on my product pages listing the contact details for the merchant selling the product.

I collect three fields information inside the field collection:

* name of merchant
* address
* contact email

I can easily make them visible on the order form with views by using relationships but I need to make the contact email available to rules so that I can set up a rule that will send and email to the merchant when the checkout process is completed.

That's it.

Thanks for your help

# Answer
> 0 votes
You can use a rule for that.

Use the action "Send a mail to an arbitrary mail address"

Set the recipients with php, like this (it's more powerful than tokens) :

```
<?php print _get_custom_emails_list( $node->field_custom );?>

```

Add this custom function in your custom module

```
<?php
// Your custom function
function _get_custom_emails_list( $field_custom ){
  // your query here.....
  return 'test@test.me, test2@test.me'
}
?>

```

---
Tags: commerce, rules
---


# Question
Title: How to pass variables between preprocess functions
I've some problem with themes and preprocess functions.

I see that, if I declare a variable in, for example, MYTHEME\_preprocess\_region(&$vars), this variable is available ONLY in region.tpl.php (I'm using Omega). But in preprocess\_region and region.tpl there is the $vars\['node'\] variable (if I'm displaying a node), so in these functions I can't create variable based on $node.

In my example, the $vars\['node'\] variable is available in preprocess\_page and preprocess\_node.

The question is: if I want to add on region.tpl.php (or preprocess\_region) a variable based on $node how should I do?

The "general" question is: how can I declare a variable in a theme function, in template.php, and let this function available in other functions?

# Answer
> 3 votes
Hm...

First of all you should control order of preprocess functions execution.

`preprocess_block` executes earlier than `preprocess_region`, `preprocess_region` earlier than `preprocess_node`, and so on...

In first preprocess, you should declare static variable, like here.

```
$var = &drupal_static('variable_name_that_will_be_placed_in_static_stack');
if (!isset($var)) {
  $var = $value_to_store;
}

```

So, you can access this var from later executed functions.

```
$var = &drupal_static('variable_name_that_will_be_placed_in_static_stack');

```

As for your problem, it's more easy to get node from `menu_router`:

```
theme_preprocess_region(&$vars)
  $node = menu_get_object();
  if ($node) {
    // get required value
  }
}

```

---
Tags: 7, theming
---


# Question
Title: how to use hook_cron_queue_info in a custom module?
I am retrieving remote data by clicking an update button. I want to make it automatic. I read many articles about it but I didn't find a good example for using hook\_cron\_queue\_info in my module. can anybody help me?

# Answer
You can look at the example code shown in the documentation from hook\_cron\_queue\_info(), which still needs an explanation on how it is used.

```
function hook_cron_queue_info() {
  $queues['aggregator_feeds'] = array(
    'worker callback' => 'aggregator_refresh',
    'time' => 60,
  );
  return $queues;
}

```

The code show is actually the implementation of `hook_cron_queue_info()` made from the Aggregator module. (See aggregator\_cron\_queue\_info().)

"aggregator\_feeds" is the name of a Drupal queue that is filled with items that need to be processed; "aggregator\_refresh" is the name of a function that will be called when Drupal executes cron tasks, once for each item contained in the "aggregator\_feeds" Drupal queue. aggregator\_refresh() gets the item taken from that Drupal queue as first parameter.

The question you would ask at this point is: When are the Drupal queue items added to the queue?

The Aggregator module does that in its `hook_cron()` implementation, but any function could add items to a Drupal queue, including other hooks (with the exception of `hook_cron_queue_info()` and similar hooks*), form submission handlers, page callbacks, or any function called from those functions.

* By "similar hooks" I mean all those hooks that return information, and that are not invoked to handle an event or after/before an event occurred/occurs (as in the case of hook\_node\_delete()). In the list of "similar hooks," I would add, for example:
> 14 votes

---
Tags: cron
---


# Question
Title: Changing vertical alignment of teasers to horizontal
I use the theme 'Business' and the standard setting of it is that the teasers of the articles I put on the front page are aligned vertically, but I'd like to have them horizontally in blocks of three--next to each other--instead.

Now I would like to know if it's possible to change this, probably by changing some of the css code (If explained in detail I think I should be able to do this, but I'm rather inexperienced..) and otherwise perhaps with a module I haven't found yet?

I'd be very much obliged.

Edit to answer Volker's question:

I create the teasers automatically when I make a new page: In the menu settings there's an option to 'Promote to front page', which I do and then the link, the image and the first paragraph appear on the front page.

# Answer
> 2 votes
I think you'll have to investigate a bit further into your site structure generally. ;)

Assuming that you have content types of articles and basic pages on your frontpage, you could try something like this in your CSS:

```
.node-promoted {
float: left;
margin-right: 20px;
max-width: 280px;

```

}

"node-promoted" is the class one of several classes of teasers of articles and/or basic pages promoted to frontpage. You can use the almighty Firebug-Addon for FF to find this out ...

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


# Question
Title: How to make Username as non mandatory on Drupal 7 registration form?
I am working on a project where i want to remove the Username form registration from. Is it possible? How?

# Answer
Yes it's possible, there are couple of modules out there that will auto-generate the username and just require an email address on the registration form (and there are probably a few more as well)

* Email registration

> Allow users to register and login using only an email address. Users can then log-in using their email address and password for authentication.
>
> A username is generated and assigned based on the user name part of the email address. Subsequent users who have the same name (email prefix) are numbered sequentially. For example, "johndoe@a.example.com" would be assigned username "johndoe", "johndoe@b.example.com" would be assigned "johndoe\_1" and so forth. Sites that want to create usernames in their own way can do so by implementing hook\_email\_registration\_name.
* Login Toboggan

> The LoginToboggan module offers several modifications of the Drupal login system in an external module by offering the following features and usability improvements:
>
> 1. Allow users to login using either their username OR their e-mail address.

Out of those two Email Registration is a bit more lightweight, so if you don't need the features from LoginToboggan it would make more sense to use that one.
> 1 votes

---
Tags: users
---


# Question
Title: What's the difference between !, %, and @ in replacement tokens?
I'm using the Message module on Drupal 7. For **Replacement tokens**, the help text says:

> A comma-separated list of replacement tokens, e.g. %title or !url, of which the message text makes use of. Each replacement token has to start with one of the special characters "@", "%" or "!". This character controls the sanitization method used, analogously to the t() function.

What's the difference between %, !, and @? Are there standards about when I should use each symbol?

# Answer
> 20 votes
From the `format_string()` docs:

* **@variable**: Escaped to HTML using `check_plain()`. Use this as the default choice for anything displayed on a page on the site.
* **%variable**: Escaped to HTML and formatted using `drupal_placeholder()`, which makes it display as *emphasized* text.
* **!variable**: Inserted as is, with no sanitization or formatting. Only use this for text that has already been prepared for HTML display (for example, user-supplied text that has already been run through `check_plain()` previously, or is expected to contain some limited HTML tags and has already been run through `filter_xss()` previously).

---
Tags: tokens
---


# Question
Title: What is the different between an install profile and a drush make file?
I am just getting into using drush and excited about using drush make and installations profiles. What is the different between a drush make file and an installation profile and do they /can they work together?

# Answer
Drush make...

> Drush make is an extension to drush that can create a ready-to-use drupal site, pulling sources from various locations. It does this by parsing a flat text file (similar to a drupal .info file) and downloading the sources it describes. In practical terms, this means that it is possible to distribute a complicated Drupal distribution as a single text file.

Note that it **doesn't install/set up the site for you** \- it merely downloads and prepares the required files in the specified locations.

Install profiles...

> Installation profiles provide specific site features and functions for a specific purpose or type of site. They make it possible to quickly set up a complex, use-specific site in fewer steps than if installing and configuring elements individually.

Once you've used Drush Make to download all the files relevant to your project, you go ahead and install Drupal as normal (whether through the UI or with Drush), except you choose your profile during installation.

The code in the profile enables required modules, sets up initial configuration for those modules and the core system, perhaps installs demo content (think Commerce Kickstart), adds menus, sets variables, etc.

Using Drush make to install a profile would be a good question/answer to look at to get an idea of how they can integrate together.
> 5 votes

---
Tags: drush, installation
---


# Question
Title: Is there a implementaion of the foundation framework for panels?
I recently heard about the foundation framework and I wondered if there is an implementation for panels.

# Answer
There is ongoing work in the Zurb Foundation Theme to implement Panels support.

It look's like there has been some progress, I'd check that discussion out first and foremost; then have a look at the search for Panels in that module. There might be more...
> 2 votes

---
Tags: panels, theming
---


# Question
Title: Total number of published comments from the logged in user
On our Drupal 6 site we are looking at setting up this rule for comments:

1) If you don't have an approved (i.e. published) comment then your comment goes into the moderation queue

2) If you have an approved comment, then your comment is published straightaway

Is it best to use Rules in Drupal? How can we check how many published comments a user has? Custom PHP code perhaps?

Any help appreciated!

# Answer
> 1 votes
You do not have to execute a rule every time a user submits a comment. If you have approved a comment for the user, then the permissions systems can handle it.

First create a new role 'Comments approved' and give the role a single permission to 'Publish comments without approval'.

Then create a rule triggered on the event 'After publishing a comment'. Have the rule perform the 'Add user role' action giving the comment author the Comments approved role.

This will mean that the user will be able to publish comments after you have approved their first one, and you will be able to remove the role from the user if they abuse the privilege.

If you want to get really fancy, create another role called 'Moderation only' with no additional permissions. If you have to control comments from a particular user, assign them this role, and in the conditions for the rule, check to see if they are a 'Moderation only' user, and do not assign the 'Comments approved' role if the 'Moderation only role' is present.

---
Tags: 6, rules, comments
---


# Question
Title: Can I create a drush make file and installation profile from existing site?
I have an existing Drupal site, that I would really like to be able to put entirely (or as much as possible) into code and use drush, a git repo, and installation profiles to be able to properly track my code and do rebuilds on my site. Is it possible to create this from an existing Drupal site. If so what are the steps to achieve this?

# Answer
> 2 votes
Profiler and Profile Builder, while useful, are for building a new profile using tools and libraries. If you would like to convert an existing site into an installation profile, please see:

http://drupal.org/node/1368242

This issue contains a Drush command to build a Drupal 7 installation profile from an existing site. The issue is marked as "needs work" because the code templates for Drupal 6 are not in place yet, but if you're working on a D7 site, it should do the trick for you.

---
Tags: drush, installation
---


title: Issue with the features Module

text:
# Question
Title: Issue with the features Module
I am experiencing an error when creating some nodes of a particular content type on my site: It triggers a 500 error when users try to save the node. When I look into the log error this is the message displayed:

> Notice: Trying to get property of non-object in \_MO\_events\_is\_event\_page() (line 461 of /var/www/Server\_Name/htdocs/MO/sites/all/modules/features/MO\_events/MO\_events.module).

Does anyone have any ideas as to what may be the cause?

Here is the Code on line 461

```
function _MO_events_is_event_page() {
  $is_event = &drupal_static(__FUNCTION__);

  if (NULL === $is_event) {
    $menu_item = menu_get_item();
// If the current menu router is a node of type event or virtual_conference we're on an event page

     //Line 461:
    $is_event = (TRUE === isset($menu_item['page_arguments'][0]) && TRUE === isset($menu_item['page_arguments'][0]->type) && ('event' == $menu_item['page_arguments'][0]->type) || 'virtual_conference' == $menu_item['page_arguments'][0]->type);
          }

          return $is_event;
        }

```

# Answer
That error means that `$menu_item['page_arguments'][0]` isn't an object in the context in which that code is run. It's probably happening during a redirect where the page isn't `node/123`, and so there's no node object available.

You can fix it by adding a bit of error checking (I've taken the liberty of using `menu_get_object()` instead of `menu_get_item()`, it's a more standard way of getting the current node object):

```
function _MO_events_is_event_page() {
  $is_event = &drupal_static(__FUNCTION__);

  if ($is_event === NULL && $node = menu_get_object()) {
    $is_event = $node->type == 'event' || $node->type == 'virtual_conference';
  }

  return (bool) $is_event;
}

```
> 1 votes

---
Tags: 7, features, chaos-tool-suite
---


title: How do I call pathauto alias using php

text:
# Question
Title: How do I call pathauto alias using php
I have pathauto installed on my D7 setup along with all my taxonomy terms configured.

How do I then call the alias using PHP for custom code?

EDIT: just to clear things up - I want to output the alias URL that has been created and assigned to each specific node. For example:

Terms \- Country \- City

For node #1 an alias is created as {site}/\[country\]/\[city\]

I would like to output the alias that has been created for the node so I can visit for example {site\]/england/london instead of {site}/node/1

# Answer
If you mean the alias for the taxonomy term you can use `url()` (if you just want the URL), or `l()` if you want a link:

```
$url = url('taxonomy/term/' . $term->tid);

$link = l('Link text', 'taxonomy/term/' . $term->tid);

```

Both of those will give you the current path alias for the term page
> 4 votes

---
Tags: path-aliases
---


# Question
Title: Dynamically grow menu based on terms in vocabulary?
As terms are added to a vocabulary, I need these terms to be incorporated into a menu with a custom URL structure. For example, I might have the `Restaurant Taxonomy` which has the following terms:

* McDonalds
* Taco Bell
* Wendys

I need to have a menu generated that matches a particular pattern with the term names plugged in - this pattern can be arbitrary. For example, I have the pattern `/restaurants/<term-name>` would generate a menu with the following links:

* /restaurants/mcdonalds
* /restaurants/taco-bell
* /restaurants/wendys

As terms are added, this menu needs to grow dynamically. How can this be accomplished?

# Answer
The Taxonomy Menu module will be able to handle that...

> Transform any of your taxonomy vocabularies into existing menus easily!
>
> Features
>
> * Custom Menu per vocabulary
> * Uses the default taxonomy term path or custom paths
> * Integrate with Views
> * Integrate with Pathauto: use URL/path aliases
> * Does not interfere with other menu modules

The module page also links to a tutorial called How to add a block menu of tags (or other taxonomy terms) on a Drupal site in conjunction with the Menu Block module in case you need that functionality.
> 1 votes

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


# Question
Title: entityform association with organic group
Is it possible to associate entityform with organic group? Ive created form and would like it to be accessible by a group specified.

Organic Groups allow to make that possible with content types but I was wondering if this is possible with entityform.

If not - are there any alternatives?

# Answer
> 0 votes
It looks like you and I have two very similar questions going. This is a link to my question, which you (@sly) have a nice answer to, and which also includes my custom module answer: Organic Groups access to Entityforms: is it possible?.

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


# Question
Title: Setting up video for Drupal- to play in popup
I've set up a Drupal website and would like to have video box that pops up when a user clicks a picture graphic. Sounds simple enough, but it turns out it is not straightforward in the land of Drupal, flash, codecs, and iphone... Here's what I'd like:

User clicks a link on my Drupal website, a video box player pops up as a mini-box player for the user to watch in a PC or Mac. For iphone users, want the ability for them to view video on iPhone (which means it can't be flash). Here's where I am so far. I recorded a screencast using both Camtasia for Mac and Screenflow. But I don't know which format to encode the video- or how to.

I've read that JW player (long tail video) is a good player because it will play both flash and HTML (good for iPhone), but then also read that Drupal and JWplayer does do a popup video window from a link. Is that true?

So before embarking further, I'd love some input on how to proceed? Which encoding format, how to achieve pop-up video player, and have ability to play on iPhone. Of course all through a Drupal site. Btw- I would be hosting the video on Vimeo, or Amazon's cloudfront.

# Answer
> 2 votes
Video is hard. One thing to think about is that if you are going to use Vimeo then you don't need to worry about formats since Vimeo will handle that on upload (and the player, and the HTML5). My personal preference would be to use embedded media field, and the media:vimeo module.

Then you end up with the video as a cck field and you can use something like colorbox to give you your popup.

# Answer
> 0 votes
Check out the OSM Media Player: http://www.mediafront.org/project/osmplayer

I use it to play video in an online store, where the videos are hosted at the store, but the OSM Player works with remotely hosted videos just fine. AND I've noticed with my self-hosted videos that if I encode the videos in iPhone format, the OSM Player does something where the videos play on every device and OS I've tried: OS X, iOS, various flavors of Windows, both an Android phone and tablet worked, and also Ubuntu and Redhat Linux played the videos fine.

I play the videos both on a "static page" (built using their standard player in a block, and that as a Panel in a Panels page) and in a LightBox2 "popup" just as suggested by Kiamlaluno.

I do this is D6, not tried the setup in D7 yet... Also, there is a batch-processing capable version of QuickTime 7 Pro (OS X only) out there that correctly encodes these videos in the iPhone h26whatever format, enabling one to process gigs of video without having to sit there and babysit the process.

# Answer
> 0 votes
It's simple, try this module ; install it with the dom window librarie

# Answer
> 0 votes
use video\_embed\_fiels and colorbox to make popup video. if you make a popup video gallery with image preset you use also image cache actions for good image preset for the video.

---
Tags: files
---


title: Drupal queue task sequencing

text:
# Question
Title: Drupal queue task sequencing
Is there a way to use Drupal Queue API to sequence the execution of tasks, like in a pipeline?

My use case is pretty simple: I have a number of tasks executing in the background, doesn't matter their order because they are self-contained. However, I'd like a single task (of a different function) to execute after all the others are done.

How would this be done?

# Answer
> 1 votes
*(Note: I've worked with queue in d6 but not in d7 yet; I don't know if there's a difference.)*

My case was a little different, but I did need to impose a sequence on some items. In my schema, I have a field for sequencing (actually a next\_attempt time). In createItem(), when adding an item to the queue, I set that field. Then in claimItem(), my query to fetch an item to work on checks that field as well as expire.

# Answer
> 2 votes
Together with a bunch of other people we created the queue runner and it does support this use-case and we use it internally. You can add a collector task that includes all your small tasks and you add a second collector task so it is executed after the whole lot of small tasks. See the API file for the queue runner to figure out how you should do this exactly. It works with the default Drupal queue class so you can even extend it with external queue systems such as http://drupal.org/project/aws\_sqs (amazon queue class) or others.

http://drupal.org/project/queue\_runner Works for D6 and D7

# Answer
> 1 votes
According to the documentation, the best you can get from the Queue operations API is ordered tasks and at least one execution of each task. However, the documentation does not specify how ordering apply. A reliable queue that guarantee the execution of an item only starts after the execution of all previous items has started would comply with this specification but would not be suitable for your use case.

You could solve this with some sort of tasks counter. When en-queuing the self-contained tasks, you increase their shared counter by the number of en-queued tasks. At the end of each task, you decrease that counter. If the counter reach zero, you can safely en-queue the final task, knowing that all previous self-contained task has been completed.

Finally, the documentation states that even a reliable queue will execute each item at least once. So the same self-contained task could be executed twice. Since you want all your self-contained tasks to complete before execution of the final task, you will need to add a safeguard to avoid the same self-contained task to decrease the counter twice.

# Answer
> 0 votes
To execute a single task after all others, use a different queue with that single task wrapped in a worker which peeks at the other queue for emptiness and runs the single task when empty, otherwise does nothing. Fine tune in hook\_cron\_queue\_info how often you peek.

---
Tags: queue
---


title: How to implement a semantic search?

text:
# Question
Title: How to implement a semantic search?
How can I add or implement a semantic search functionality in my site?

I have rdfx and schema.org modules in my site to add semantic data to my content so I need a way to add semantic search functionality to my site.

# Answer
The following may or may not meet your needs exactly, but they're ideas. Since I am now aware of semantic search modules currently available, these would be my workarounds.

The default drupal search does not really provide you with a lot of configuration options to determine which of your nodes' fields/tags can be weighed more heavily when determining search result relevance, I would enable and use the Apache Solr Search Integration module to get at more accurate search results.

With this module, you can get several benefits:

* It lets you configure different weights, in terms of search result relevance, for the title, body, text in bold, text in comments, as well as terms in all your vocabularies. This way, you can weigh very heavily the terms from a certain vocabulary, while omitting text from comments and weighing very lightly text that is in terms from another vocabulary (for example) -- adjust weights to your needs. What I'm suggesting here is that **you can use tagging as a form of search metadata** with this module... (Author name, etc are also fields that can be weighed with this interface)

* You can use facets with apachesolr search, which can allow your customers to actually narrow down and interact with search results themselves! It also provides a 'sort by' block, which users can use to sort results by relevancy (the default), or date, author or type if they prefer. These aren't exactly what you asked for, but are a way to interactively let users tailor results... Screenshot below is directly from apachesolr's module demo site.

To use apachesolr search, however, you have to have to install and configure a solr server for drupal to use: http://drupal.org/node/1053074
> 1 votes

---
Tags: search, 7
---


# Question
Title: Is there a standard Drupal way to link to 3rd party configuration forms?
I am writing a custom module. On my module's configuration form I would like to provide links to relevant modules' configuration forms; e.g. the cron configuration form.

Is there a standard Drupal way to encode such links?
For instance is there a Drupal function that takes the menu path (eg. 'admin/config/system/cron') and provides an actual URL?

Thanks!

# Answer
> For instance is there a Drupal function that takes the menu path (eg. 'admin/config/system/cron') and provides an actual URL?

Definitely!

```
print l(t('Cron configuration'), 'admin/config/system/cron');

```

Will print an a tag as follows:

```
<a href="/admin/config/system/cron">Cron configuration</a>

```

to the configuration with paths resolved correctly (works well when you have installed Drupal in a sub folder as well - just use the Drupal path).

If you are putting your own text, most likely that you are using `t()` function. Example:

```
$form['warning']['#makup'] = t('You need to make sure that you have setup a working !cron',
  array('!cron' => l(t('Cron configuration'), 'admin/config/system/cron')));

```

`l()` \- Generates the anchor link (`<a href="path/to/page">text</a>`)

`url()` \- Returns URL for a given Drupal path (`l()` calls this function to get the correct link)

See function reference for more configuration (absolute URLs, prevent using aliased path, etc)
> 4 votes

# Answer
If a module has declared it's config form in the info file, I think you should be able to use `drupal_parse_info_file();`.

I'd probably get all the module names into an array, and then just run a `foreach` to get the paths.

Example:

**This is untested code that you should use as an example - there is no array error checking or anything like that:*

```
function MYMODULE_get_config_pages() {
  $config_pages = array();
  $modules = array('cron', 'views', 'ctools', 'panels');

  foreach ($modules as $module) {
    $path = drupal_get_path('module', $module);
    $filename = $module . '.info';

    $info = drupal_parse_info_file($path . '/' . $filename);

    $config_pages[$module] = $info['configuration'];
  }

  return $config_pages;
}

```

This will give you an array of module configuration pages, keyed by module name.

Next you'll want to run those links through `l()`

Example:

```
function MYMODULE_get_config_links($config_pages) {
  $links = array();

  foreach ($config_pages as $module => $uri) {
    // You might want to run $module through t() here or perhaps capitalise it.
    $links[] = l($module, $uri);
  }

  return $links;
}

```

You could probably turn that into a neat little reusable object and bundle it with a module, but the above code should get you started :)

Please note, that I've not written any error checking for modules with no config pages declared in their info file! You might want to run an `array_key_exists` somewhere in the first function.
> 2 votes

---
Tags: forms, navigation
---


# Question
Title: Programmatically Filter Node Access beyond permissions, views, etc
Short Version:

What would you say is the best way to filter how nodes appear (in a binary sense: published vs. hidden) to users based off of a dynamic value? This solution is beyond the scope of typical modules like Permissions, Views, or Content Access.

Long Version:

My application calls for having select nodes display to select users based off of values changed over time. For instance, lets say a user wants access a node but both the users and the nodes change their location (daily). When a customer views the site (or any page) I want them to only be able to see nodes in their specified range. Because of this the basic Permission and Views and other stock Drupal modules seem to be ineffective. It seems like it would be a bad way to use the Permission system because their are so many variables in the user / node relationship. I can't unpublish nodes because they need to remain active to other users, processes, etc. Even a dynamic Views filter with custom php code for my distance measurement would be ineffective because then nodes would still be accessible by directly inputting the URL.

Thus far, I am planning on using `hook_node_load()` to perform my calculations - determining the user and node relationship - and then only return nodes that are applicable. This should prevent direct URL access to unavailable nodes, keep active nodes that exist but don't match the criteria, and by default control

# Answer
> 0 votes
`node_access_example.module` (link) would appear to be the best response to the issue of custom filtering of nodes through the node API. It and a few other comments (1)(2) describe these as being the key hooks in accomplishing this task:

```
hook_node_access()
hook_node_access_records()
hook_node_grants()

```

# Answer
> 2 votes
You say that you do not want users to be able to enter node URLs directly. To me this suggests you **do** need to use permissions, as it is the only way tou can guarantee your node won't be accessed.

The reason is that you never know which parts of Drupal might be displaying your node. For instance you could manually insert a `drupal_goto` in `hook_boot` to provide your own custom permission handling, testing the URL for the node id - however the node would still be accessible via Views. The great thing with Drupal is that all sorts of modules can use your data in all sorts of ways - however this means you have to present your data (in that case, your permissions) in a way other modules will understand.

You say that your permissions are distance-based. This means you cannot use Role-based permissions, since you would end up having one role per user. What you could use however is the ACL module \- this provides an API allowing you to define per-user/node permissions.

You would then need to implement `hook_node_update`/`hook_user_update` to re-calculate the permissions and change the ACL for that node/user when the node/user is changed.

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


# Question
Title: Easy way to add EU cookie notification to multiple Drupal websites?
I have 20+ Drupal sites that I have to add Cookie notifs to. Is there an easy/batch/automated way to do it?

# Answer
> 3 votes
Check out EU Cookie Compliance for your notifications.

> This module intends to deal with the EU Directive on Privacy and Electronic Communications that comes into effect in the UK on 26th May 2012. From this date on, you run the risk of enforcement action if you are not compliant or visibly working towards compliance.

Automating the process however is quite localised depending on your server setup, and would probably be considered off topic.

# Answer
> 2 votes
There is a module for that: EU Cookie Compliance

---
Tags: cookies
---


# Question
Title: In Views how to configure a contextual filter to exclude the node being viewed?
I have the following setup: a content type (event) can have a "mother" event, which is configured as entity reference (Basically it's the same event on another date).

I have a view for a single event which is embedded in a panel pane and another view for the other similar events (with the same "mother") in another panel pane on that page.

This works pretty good, except when i try to filter out the event that is shown on the first pane from the second pane, so that this one isn't shown twice.

The view for the "related events" has a contextual filter of the nid and relationship to the "motherevent" which is set to "required".

Now you would say, check the exclude field for the contextual-filter. Yes, this works, but with a side effect: all other events not related to the "mother" are shown as well.

I feel like I have arbitrary tried all possible combinations of "set relationship" / required and so on, but with no effort. I even tried a second contextual filter of the nid with different settings... I don't get it.

Can someone please explain how this could be achieved? Thanks a lot!

# Answer
> 3 votes
The problem I believe is the relationship. I assume the entity reference on each event points to the parent event, including that on the parent (recursive).

Get rid of the relationship. Set up two contextual filters, one on Content:Nid and the other on Content:field\_parent.

On the configuration for the contextual filter on NID, set the default value to Content ID from URL, open up the 'More' settings, and select 'Exclude'.

For the contextual filter on field\_parent, set the default value to PHP Code and use something like the following:

```
$node = menu_get_object();
return $node->field_parent['und'][0]['target_id'];

```

This will get the ID of the parent from the current node, and will require all nodes displayed to have the same parent. The exclusion of the current node from the list will work, and you will have a list of all other children related to the same parent.

---
Tags: 7, views, entities
---


# Question
Title: Multiple Drupal Commerce line items in the database but one in the order page
I am doing a report module to show various information about drupal commerce orders and line items.

I am now facing a problem with the line items:

For some orders, in the commerce\_line\_item table, there are multiple line items for the same product and quantity.

However, in the order page of these orders, I only see one line item. I suppose only one of these line items is the good one, but how can I know which one is good in the table?

They looks the same except the line\_item\_id field which is different. So how can I get the line items of an order without any of these dupplicate line items?

Why are there dupplicate line items in the table?

For instance, this query:

```
SELECT SUM(quantity)
FROM {commerce_line_item}
WHERE order_id = 388

```

gives me 5 intead of 1.

Note:

I am using Drupal Commerce 7.x-1.3.

Dump for the order 388:

```
-- commerce_product
product_id  revision_id sku     title   type    language    uid status  created changed data
1   52  sku     Product Name    product_type    und     1   1   1342634788  1352819763  [BLOB - 4o]
-- commerce_order
order_id    order_number    revision_id type    uid mail    status  created changed hostname    data
388     388     1865    commerce_order  123     mail@example.com    completed   1359728586  1359755276  1.2.3.4     [BLOB - 208o]
-- commerce_order_revision
order_id    order_number    revision_id revision_uid    mail    status  log revision_timestamp  revision_hostname   data
388     388     1838    984     mail@example.com    cart    Log message     1359754659  1.2.3.4     [BLOB - 6o]
388     388     1859    984     mail@example.com    checkout_checkout   Log message     1359754827  1.2.3.4     [BLOB - 6o]
388     388     1860    984     mail@example.com    checkout_review     Log message     1359754829  1.2.3.4     [BLOB - 6o]
388     388     1861    984     mail@example.com    cart    Log message     1359755005  1.2.3.4     [BLOB - 6o]
388     388     1862    984     mail@example.com    checkout_checkout   Log message 1359755034  1.2.3.4     [BLOB - 6o]
388     388     1863    984     mail@example.com    checkout_review     Log message     1359755074  1.2.3.4     [BLOB - 74o]
388     388     1864    984     mail@example.com    checkout_payment    Log message 1359755075  1.2.3.4     [BLOB - 153o]
388     388     1865    0   mail@example.com    completed   Log message     1359755276  1.2.3.4     [BLOB - 208o]
-- commerce_line_item
line_item_id    order_id    type    line_item_label quantity    created changed data
773     388     product     sku     1.00    1359754516  1359754829  [BLOB - 232o]
763     388     product     sku     1.00    1359728686  1359728686  [BLOB - 232o]
762     388     product     sku     1.00    1359728699  1359728699  [BLOB - 232o]
761     388     product     sku     1.00    1359728689  1359728689  [BLOB - 232o]
758     388     product     sku     1.00    1359728642  1359728642  [BLOB - 232o]

```

Thanks for your help.

# Answer
> 2 votes
I finally found out how to do what I want. The last commerce line items are in the `field_data_commerce_line_items` table. The `commerce_line_item` table seems to contain all the commerce line item revisions.

```
SELECT SUM(quantity)
FROM {commerce_line_item}
INNER JOIN {field_data_commerce_line_items}
    ON {field_data_commerce_line_items}.commerce_line_items_line_item_id = {commerce_line_item}.line_item_id
WHERE order_id = 388

```

I don't know if it is documented somewhere. However, it is what I found by reading the source code and the SQL queries.

---
Tags: commerce
---


# Question
Title: Get list of taxonomy terms for current node through Views
I've been trying this for awhile, and I keep finding answers that are close - but not quite.

If there is a node with taxonomy terms attached to it, I want to create a block in Views that I can place in the sidebar that will load the terms that are attached to THAT node.

I want to do it through Views so I can rewrite the URL with a custom query using the term IDs.

I'm open to other suggestions as well! I've also tried Display Suite, but I didn't want to go too far down that path just yet. The attached image is ideal, where the category taxonomy terms are being loaded based on terms that are attached to the node.

Ideal Wireframe Example

# Answer
Come on it's not that hard! I'm assuming you want to display all taxonomy terms across multiple taxonomy reference fields/vocabularies. You can however filter the list of taxonomy terms that the View returns using Vocabulary filters.

1. Create a new view on Taxonomy table. You are basically showing taxonomy terms.
2. In the View creation page, uncheck "create page" and check "Create block". Give it a title "Categories". Click "Continue and Edit".
3. In the Views UI, add a new **Relationship** **Taxonomy term: Content with term**, and uncheck "require this relationship".
4. Add a new **Contextual filter** : **Content: Nid** and choose the just-created relationship as the relationship, **Provide default value** \> **Content ID From URL** under **When the filter value is NOT available**. Also add basic validation check to the contextual filter.

5 . Save the View and put the block where you want to display.

You can check the view by entering a test node ID to the preview field. It should show **all** taxonomy terms attached to THAT node.
> 12 votes

---
Tags: views, taxonomy-terms, display-suite
---


title: Disabling the editing of Group Titles

text:
# Question
Title: Disabling the editing of Group Titles
I'm trying to stop the editing of Group Titles (Content Types that are set as Groups) by users. With Drupal (v7.21) I've added Organic Groups (7.x-2.1) and set it so that the Group manager does not have full permissions. Instead I've created a Role for them called 'owner' and give them the ability to edit the group but not administer the group. I want them to be able to change the Group Body but not the Title. I have the Organic groups field access module installed and that lets me stop them editing fields like the Body but it doesn't allow me to stop them editing the Title. Does anyone know if there is a way to do this?

# Answer
You could use either of these two modules Automatic Nodetitles or Automatic Entity Label to hide the title field. Use tokens to give the groups a name and hide the field on the edit form.
> 1 votes

# Answer
Display Suite 2.x also comes with field permissions, which I think also works with title fields. @Dee: This issue is not about "per node", though, it is "per role per content type", if I understand it correctly.
> 0 votes

---
Tags: organic-groups
---


# Question
Title: DAMP / Aquia Dev (mac) apache fails on import of drupal core 7
I'm attempting to switch from Bitnami to Aquia Dev Desktop for the mac (OS 10.8.2). I'd like to be able to develop a couple sites (using core drupal - not the aquia distro) simultaneously in a reliable environment.

1. Ran the uninstaller on Bitnami and checked that all files were deleted.
2. I successfully installed Aquia Dev Desktop, saw that Apache and MySQL servers were both running, and got the local Aquia Drupal site when I clicked "Go to my site" in the control panel. So everything was working fine.
3. Downloaded Drupal 7 to a folder on my desktop, decompressed, renamed the drupal folder to my site name (all lower case and no special characters), and reset the folder permissions to "Read & Write" and applied to all enclosed folders.
4. I attempted to import into Aquia Dev Desktop but got "Error - Process 'Apache Web Server' failed to start".

I tried using the settings panel in Aquia Dev Desktop to reset port from 8082 to 8080 but apache still won't start. Tried a few other port numbers and no luck.

Here's the complete Apache error log:

> \[Fri Apr 05 15:05:54 2013\] \[notice\] Apache/2.2.23 (Unix) PHP/5.2.17 configured -- resuming normal operations
> \[Fri Apr 05 15:06:37 2013\] \[notice\] caught SIGTERM, shutting down
> \[Fri Apr 05 15:06:43 2013\] \[notice\] Apache/2.2.23 (Unix) PHP/5.3.18 configured -- resuming normal operations
> \[Fri Apr 05 15:16:41 2013\] \[notice\] caught SIGTERM, shutting down

I have very little experience with server administration or apache configuration.

Can anyone point me in the right direction?

# Answer
> 0 votes
This turned out to be a bug in Dev Desktop. The good folks at Acquia fixed the bug and posted a new version that works nicely.

---
Tags: installation
---


title: Endless Redirection of Drupal on IIS

text:
# Question
Title: Endless Redirection of Drupal on IIS
I just transferred a Drupal 6 website from an Apache-based dev environment to an IIS-based production environment. Now I am getting a "too many redirects" error.

What could be causing that and how do I fix it?

# Answer
> 0 votes
Need more info! The Devel module has an option for interrupting page redirection and displaying the page you're about to be forwarded to - very handy for debugging redirection. Common redirection issues stem from Rules, Context, Delta, and even just the URL Alias system within Drupal itself.

The transition from Apache to IIS is an interesting hint though - any chance we can take a look at your `.htaccess` and `web.config` files to check for differences? Something else to watch for could be trailing slashes and the difference in server handling, as well as the user that PHP is running as under a possibly different CGI.

---
Tags: redirection, iis
---


title: multiplying fields values

text:
# Question
Title: multiplying fields values
Hi can someone help me with some field maths. I have taxonomy vocabulary called "plast" with several terms (large box, small box etc.) i have created field within the taxonomy called weight which is linked to each term. Now i have a nod where the user selects term from the taxonomy "plastic"and in the next field enters amount, what i want is to show i the next field "total weight" is weight from the taxonomy term multiplied by the amount.

thanks

# Answer
Ok i think there must be an easer way using views so if have taxonomy term "small box" which has a field "weight" linked to it with defaolt value 0.6 the folowing field in my nod is "amount" how do i get the result in views so i would see 0.6 multiplied by the "amount"

Thanks
> 0 votes

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


# Question
Title: How to write test cases for custom ajax functionality using simpletest in drupal7
I am trying to write the test case for my custom ajax functionality in Drupal 7. I am firing the event on click in my `.js` file but the test case gets a fail.

In my `.tpl.php` template file I have the following code:

`<a href="javasctipt:void(0)" id="myFirstEvent">Click Here</a>`

In the Js file I am getting the event as follows:

```
$('#myFirstEvent').live('click', function())
$.ajax({
        cache: false,
        url: Drupal.settings.basePath + '?q=mymodule/add',
        data: {page: page, sort: sort, order: order},
        dataType: 'text',
        error: function(request, status, error) {
            alert(status);
        },
        success: function(data, status, request) {
            /**Function definition goes here**/

}

```

In my custom.test file I have the following:

```
$edit = array();
$this>drupalGet("myform/add");
$this->drupalPost('myform/add', $edit, 'myFirstEvent');
$this->assertResponse(200, 'Success');

```

But I am not getting the success screen (Green Color) after I execute my test cases.

# Answer
> 3 votes
You cannot test custom javascript with simpletest because it simply ignores them. Simpletest can simulate the ajax behavior (via xpath) only if you add that to the form with the #ajax property. http://api.drupal.org/api/drupal/developer!topics!forms\_api\_reference.html/7#ajax

To test custom js you might want to have a look at Selenium.

---
Tags: 7, ajax, javascript, testing
---


# Question
Title: Cannot use string offset as an array in includes\form.inc on line 3575
Before creating "form" custom module, everything was fine. After creating this module, I have got the following error message:

> Cannot use string offset as an array in includes\form.inc on line 3575

I deleted the entire custom module folder, and cleared the cache as well. Still, I am getting the same error when modules page.

How do I overcome this error?

coding inside the form.module page is

```
        function form_menu() {
      $items = array();
      $items['form/form'] = array(
        'title' => t('My form'),
        'page callback' => 'form_form',
        'access arguments' => array('access content'),
        'description' => t('My form'),
        'type' => MENU_CALLBACK,
      );
      return $items;
    }

    /**
    * This function gets called in the browser address bar for:
    * "http://yourhost/form/form" or
    * "http://yourhost/?q=form/form". It will generate
    * a page with this form on it.
    */
    function form_form() {

      // This form calls the form builder function via the
      // drupal_get_form() function which takes the name of this form builder
      // function as an argument. It returns the results to display the form.
      return drupal_get_form('form_my_form');

    }

    /**
    * This function is called the "form builder". It builds the form.
    * Notice, it takes one argument, the $form_state
    */
    function form_my_form($form_state) {

        // This is the first form element. It's a textfield with a label, "Name"
      $form['name'] = array(
        '#type' => 'textfield',
        '#title' => t('Name'),
      );
      return $form;
    }

```

# Answer
> 0 votes
Deleting the module folder outright, without uninstalling it through the UI/Drush (even manually in the DB) is bound to cause a few problems.

To get rid of any errors caused by Drupal thinking the module files are still there, you can simply delete the row in the `system` table which corresponds to the relevant module; but make a database backup first, of course.

In case you haven't come across the pages before, you can disable modules at http://mysite.com/admin/modules and uninstall them at http://mysite.com/admin/modules/uninstall through the UI, or use Drush.

# Answer
> 0 votes
Run update.php after disabling that form module. My problem has been solved after doing this.

---
Tags: forms
---


# Question
Title: Exclude fields from a node-add form (but keep them on the node-edit form) by excluding (to save load time) not hiding? Drupal 7
The site I am building is for a parts database and parts are related to each other - eg a circuit board can have a bunch of screws and relays that are sub parts and the board itself can be a sub-part of a module.

When you are registering a circuit board (node-add) you don't need to associate it with parent parts or sub parts. But you may want to do that when you edit it (node-edit).

The parts are associated by entity reference fields and the entity select views take a bit of time to load. I want to save that load time for the node-add by excluding those fields from the node-add form completely (not just hiding them) but I want them to load as normal for the node-edit form.

Thanks very much and have a great Friday!

# Answer
> -1 votes
Okay I got it to work. On new nodes there is no NID on existing nodes there is. This code works.

```
function custom_form_alter(&$form, $form_state, $form_id) {
if($form_id == 'custom_node_form') {
    if (empty($form['nid']['#value'])) {
    unset($form['field_remove_this_field_name']);
    }

```

}

Unfortunately I still have a slow load time and I suspect that even though I'm unsetting the form fields that involve entity references (and therefore views queries to populate selection lists) that the queries are still getting run.

It's only really slow on the first form load after clearing caches. The second form load is much faster.

If anyone has any ideas to speed up the initial form load, I'd love to hear them.

It may be that I need to create a custom form from scratch using module code and only load the essential fields.

---
Tags: entities
---


# Question
Title: Is it possible to use a different theme for just a section on the page?
In Drupal 7, using a different theme on each page is easy, but what I could really use in this particular case is **2 themes on the same page**.

Let's say I want to use *Rubik* theme for all page sections (menu, etc.) **except** 'content' section, where I'd like to use *Stark* theme.

Is this possible at all? If it is, how?

# Answer
Thanks Clive and Cromian for your input. Guess its not possible to actually use 2 different themes on the same page.

The simplest solution I found is to use one theme, then add 2nd ones css using drupal\_add\_css function. Then hope 2 CSS don't interfere too much and it's good enough without HTML part of the theme.
> 1 votes

---
Tags: theming
---


# Question
Title: overriding ubercart - add to cart button
I try to override add to cart button with hook form alter in custom module with this function but I got an error **Fatal error: fatal flex scanner internal error** end of buffer missed in. What can be the problem?

```
function uc_button_form_alter($form_id, &$form_state, $node) {
  if ($form_id == 'edit-submit-' . $node->nid) {
    $form['submit']['#attributes']=  array(
      'class' => 'node-add-to-cart',
      'xxx' => 'xxx',
    );
  }
};

```

Thank you

# Answer
> 3 votes
In D7, below is my solution for different product classes.

```
/* Overrides the Add to Cart form text*/
if ( !empty($form['nid']) ) {
  $node = $form['nid']['#value'];
}
else {
  $node = 0;
}
if (($form_id == 'uc_product_add_to_cart_form_'.$node) and ($form['node']['#value']->type =='uc_recurring_subscription')){
   $form['actions']['submit']['#value'] = t('Subscribe');
}

if (($form_id == 'uc_product_add_to_cart_form_'.$node) and ($form['node']['#value']->type =='credit')){
   $form['actions']['submit']['#value'] = t('Buy');
}

```

For regular product or just one product class, this should work.

```
/* Overrides the Add to Cart form text*/
if ( !empty($form['nid']) ) {
  $node = $form['nid']['#value'];
}
else {
  $node = 0;
}
if (($form_id == 'uc_product_add_to_cart_form_'.$node){
   $form['actions']['submit']['#value'] = t('Buy now');
}

```

# Answer
> 1 votes
Your function's arguments are wrong. See hook\_form\_alter docs.

So basically you need to rewrite your function as follows.

First, grab the correct form ID.form\_alter functions don't have a $node but in some forms, full node object form is in $form. So use the following code. You will now see at least 2 message on your messages area with form ID and array explanation of $form.

```
function uc_button_form_alter(&$form, &$form_state, $form_id) {
  drupal_set_message($form_id);
  drupal_set_message('<pre>'.print_r($form, 1).'</pre>');
};

```

Now, check if the node ID you are looking for is available in the $form array. (in most cases, it's in $form\['#node'\]). Now you can change the function to the real code.

```
function uc_button_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['#node']->nid) && $form_id == 'edit-submit-' . $form['#node']->nid) {
    $form['submit']['#attributes']['class'] = 'node-add-to-cart';
    $form['submit']['#attributes']['xxx'] = 'xxx'; // we don't want  to clear existing values.
  }
};

```

However, even this implementation is not necessary. You can make use of default classes with tricky nesting if you only want to add a class to the button.

Update after 3rd comment: Try this:

```
function uc_button_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['nid']['#value']) && $form_id == 'edit-submit-' . $form['nid']['#value']) {
    $form['submit']['#attributes']['class'] = 'node-add-to-cart';
    $form['submit']['#attributes']['xxx'] = 'xxx'; // we don't want  to clear existing values.
  }
};

```

---
Tags: ubercart, forms
---


# Question
Title: View data not showing after moving website
I just move a drupal 7 website from my localhost WAMP server to a production server (using phpmyadmin for the database).

Everything is fine except the views which didn't show anything. The data are here but even with the views ui, the preview doesn't show a single data.

I suspect a database problem but I don't know what to do

# Answer
You can export the whole view from local server to production server, if it works it means that there must be a problem in db, so try exporting the database again. And one suggestion you can use features module for deployment process.
> 0 votes

# Answer
update the database on the staging machine probably you might not have taken the latest updated for database..

still i think using the feature module to export view would be helpful in your case

features module here

the feature module will provide you with a module that you can directly install on your staging . what you only need to do is just install and enable the module that feature will provide you . go through readme.txt of module for better understanding
> 0 votes

---
Tags: views
---


title: What URLs does the Update module uses?

text:
# Question
Title: What URLs does the Update module uses?
I have to put in white-list the URLs used by the Update module. What URLs does it uses?

# Answer
> 2 votes
You're probably looking for:

http://updates.drupal.org/release-history

From the update.module file:

```
/**
 * URL to check for updates, if a given project doesn't define its own.
 */
define('UPDATE_DEFAULT_URL', 'http://updates.drupal.org/release-history');

```

It's worth noting the *"if a given project doesn't define its own."* part of that - the vast majority of modules use the standard Drupal URL, but not necessarily all of them. If you have any modules that haven't been installed via Drupal.org, check through their .info file and look for the `project status url` key. If any modules define a value for that, you'll also want to whitelist it.

---
Tags: community-official-site
---


# Question
Title: Wanting to add a drop down menu to reg form
I want to add a drop down list to the user registration form for users to pick a category for their page to be under when signing up.

I also want it so people can click on a menu and it will take them to a page view that their catagory is under.... for example, clicking on "food" brings up a view with all pages related to food..

Is this done with the taxonomy? Or can I just set up a view to fetch the related shops from the database?

Any ideas?

# Answer
1. Create a BLOCK-VIEW of type TAXONOMY.
2. Select the vocabulary which u have created and want to be displayed in DROP DOWN LIST.
3. In the format type,select JUMP MENU.
4. SAVE the view.
5. Assign view to a region where you want drop down menu to be displayed..
> 1 votes

# Answer
Your first question: The Profile 2 module let's you add additional fields to a user profile. If you need PHP logic have a look at hook\_form\_alter.

Your second question: Yes taxonomy is the way to go for this and has full views integration.
> 0 votes

# Answer
if you are using webform module for generating web form than there is way to add drop down list to your field by directly adding the value in options field

once you had generated your web form its there in your content region .

go to edit link part and in option field provide your drop down option in a format like

(value)|(value)

like if you want to add "x" to drop down write it in a form eg : x|x

the content on one side of pipe is to refer the name of content in databse and other is one which is displayed on drop-down.

hope this would be helpful
> 0 votes

---
Tags: taxonomy-terms, users
---


title: Text input onchange event

text:
# Question
Title: Text input onchange event
I'm working on a custom field that will store a string. The text will have a custom formatter applied to it that will manipulate the structure of the string (adding dashes in the right places). I have a javascript that will apply those changes in the field's input textbox when creating a new content type with the custom field, but I can't figure out how to fire the javascript when the user enters the text. Can it be done and if so can anyone point me in the right direction?

# Answer
> 1 votes
You probably want to use Drupal behaviors which is a wrapper of sorts for JQuery. With JQuery you can make it so that everytime your textfield gets edited your Javascript code gets executed. Behaviors/JQuery is a big subject and will take time if you're not familiar. You can start here

The Drupal JavaScript API

JQuery tutorials

# Answer
> 0 votes
1.With the help of onblur() function,you can trigger the written js. 2.onblur() function helps you in calling a js once the text is entered in the input field and the user press ENTER after entering the text.

---
Tags: javascript, entities
---