# Question
Title: how to display Variables in User account page
In the node template, I used to put the following code to find the variables:

```
<?php print_r($node) ;?>

```

What if this is a user account page (e.g. /user/1), what "$object" should I print to see the variables. I need to pre-fill the webform's fields with the profiler2's fields.

# Answer
Try get\_defined\_vars

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

Also you can try

```
<?php
 dsm (array_keys(get_defined_vars()));
?>

```

**See also:**

get\_defined\_vars()

get\_defined\_constants()

get\_defined\_functions()
> 6 votes

# Answer
Variables for template files are set in their preprocessor functions, for example the node template has template\_preproess\_node(&$variables).

Any module or theme can hook into these preprocessor functions to set/modify/remove variables, which will then be available in the template file.

For example if in the preprocessor you set:

```
$variables['my_new_variable'] = 'This is some text in a new variable';

```

You can then use $my\_new\_variable in the template file.

Now after all the preprocess functions are called, then there are process functions, which for the node template would be template\_process\_node(&$variables).

So most of the time variables are added in preprocessors, so to see all the variables you should check in the processor.

So in your theme's template.php file add:

```
/**
 * Variable processor for the node template.
 */
function THEMENAME_process_node(&$variables) {
  // Print the variables to the screen.
  print_r($variables);
  // A better alternative is to install the devel module and then do this.
  dpm($variables);
}

```

In the above example change THEMENAME to the name of your theme. As noted in the above example, you get a much better result if you install the devel module and use the dpm() function, instead of print\_r(). Note that when you use dpm() in templates & preprocessors it takes 2 page refreshed to see you message instead of 1.

You will also usually get a satisfactory result by doing this in the equivalent preprocess function instead of the process function.

Now there is still a (negligible) chance that after your process function is run, that another implementation of the process function. If you really need to (you most likely don't), update the weight of your theme in the settings table of the database and make it a very high number, so it runs last. **Note:** This is more advanced and if you are unsure of what I'm talking about you are probably best not to mess with this. It likely isn't necessary anyway.
> 3 votes

---
Tags: users
---


# Question
Title: Minimally working end-to-end example of drush batch job execution
I'm trying to make drush run my batch jobs. There's some amount of documentation at Processing batch jobs with drush, however, I can make no sense of it.

I would like to see real code, and the CLI requirements/instructions for running it, that when called by Drush, prints something trivial, such as "Hello world", once per operation.

# Answer
I've written drush CLI commands. I've also written some Batch API processes. On each individual topic you've asked about there is alot of documentation.

I'm not sure why you want to use the Batch API specifically via Drush. The Batch API in part is used to avoid HTTP request timeout in long PHP processes. If you're using Drush from the command line -- you have no `max_execution_time` to worry about from php.ini essentially ...

EDIT: Have you looked into the Migrate source to see how they run Batch stuff from drush cli?
> 1 votes

# Answer
Look at the Drush core updatedb command - this uses the batch system. You can also look at the Drupal 7 content\_migrate Drush command that is part of the CCK project.

The main reason you would want to use the batch system from Drush is that it runs each batch in a separate command line process. This gives some ability to manage fatal errors (very handy when developing upgrade/migrate type systems, so you can still complete as much as possible and then go back and review errors!), as well as to constrain memory - even with an unlimited timout and unlimited memory in php.ini, Drupal static caches and other things will eventually use up all the memory on a server (I have used 8GB or more in the past) on runs that are long/complex enough.
> 0 votes

---
Tags: drush, batch-operations
---


title: Move primary tabs to the shortcuts bar

text:
# Question
Title: Move primary tabs to the shortcuts bar
I am using drupal7 and the admin menu overlay (in seven). And I'm always apalled by the primary tabs appearing in view mode. They are messing up the layout for the editors / admins, and they're usually not in style with either the site design or the overlay design.

I was just wondering .. is there a pretty way to move the primary tabs ('edit' et al) to the admin overlay shortcuts bar - 'if the overlay is visible and you are in view mode'

Perhaps there are two answers:

1. remove the primary tabs from the content, if the overlay is visible and you are in view mode
2. add the primary tabs to the shortcuts bar, if you are in view mode

Any hints ?

\*-pike

# Answer
The easiest way would be to use the http://drupal.org/project/admin\_menu module.

It has an option to move the tabs into the admin menu bar. Set it by going to the admin menu settings page (admin/config/administration/admin\_menu) and checking the "Move local tasks into menu" option.

For users gien access to the admin menu, you should remove access to the drupal toolbar module, or they will have 2 toolbars.

You could even disable to toolbar module and just use admin menu.

If you want to keep using the toolbar module instead of the admin menu module, you can remove the tabs from the page.tpl.php file in your theme and then print them elsewhere.

I don't know off the top of my head how you would go about doing that though.
> 3 votes

---
Tags: 7, modal-dialogs, routes, users
---


# Question
Title: How to create file->node relations use relations modules?
I have a little issue that How to create file-\>node relations use relations modules?

In my case: I need to create music(mp3) and album relations. After i check some information and said that music(mp3) and album is file-\>node relations.

But, i don't know that how to do this relations.

when i create a relation type, which bundles need to selected?

# Answer
\[Resolved\] 1. Create relation between Node and file 2. Create a view for relation and only view out all related file 3. setting view to relation select values
> 2 votes

---
Tags: views
---


# Question
Title: Fatal error: Unsupported operand types in common.inc on line 2287 when registering new user
I am receiving this error message when registering as a new user on a site-in-progress:

> Fatal error: Unsupported operand types in common.inc on line 2287

The actual line 2287 is:

> $query += $options\['query'\];

Here is the surrounding code:

```
// Without Clean URLs.
  else {
    $path = $prefix . $path;
    $query = array();
if (!empty($path)) {
  $query['q'] = $path;
}
if ($options['query']) {
  // We do not use array_merge() here to prevent overriding $path via query
  // parameters.
  $query += $options['query'];
}
$query = $query ? ('?' . drupal_http_build_query($query)) : '';
$script = isset($options['script']) ? $options['script'] : '';
return $base . $script . $query . $options['fragment'];
  }
}

```

I use LoginToboggan, not sure if that has anything to do with this issue. Does anyone have any ideas on what might cause this issue and how it can be fixed?

Thanks!

# Answer
> 2 votes
The problem is in the url() function and is because either the l() or url() functions are being called with a 'query' that is not an array.

Those functions expect the 'query' option to be an array and it is likely that something is passing a string into them.

Do you have any custom code in modules or themes that is calling l() or url()?

I see you have already seen the issue at http://drupal.org/node/1275048

To debug the problem, add this code to the line before the error line:

```
if (!is_array($options['query'])) {
  die(print_r(func_get_args()));
}

```

Then reload the page with the error and you will get a bunch of text on a white screen. Post that text back here and/or that drupal.org issue.

**After your latest information** There is a bug in logintoboggan that makes this break whenever you have a redirect url with a query string in it (that is the part with ?key1=value1&key2=value2).

I have made a patch to fix it in the issue mentioned above.

# Answer
> 0 votes
As you are saying that you get this error when registering new users so check your form, there you will be missing # in front of a property e.g. type instead of #type or name instead of #name etc. This is the case which I have come across when i get this type of error.

---
Tags: 7, users
---


# Question
Title: Combine 2 contextual filters - taxonomy term ID from url and NID
Is it possible to get taxonomy term from url and node id at the same time from current node? I need to get taxonomy term from current node to pull some date from referenced nodes that have parent taxonomy of current node term. So far ok. But moreover I need to be able to get to current node's fields. Using another conextual filter to get NID was not helpful.

# Answer
> 1 votes
I don't think you can do this with multiple contectual filters.

Sounds like you need relationships.

Use the contextual filter to get the current nid and show the fields for that node.

Then add a relationship between the node and its terms (you can limit this by vocab if need be) by adding the relationship "Content: Taxonomy terms on node".

Then add a relationship from the term to the parent term by add the "Taxonomy term: Parent term" relationship. This relationship should use the previous relationship.

The add a relationship from the parent term to the content that uses that term by adding the " Taxonomy term: Content with term" relationship. This relationship should use the Parent relationship.

Then you can do extra things like adding filters that use these relationships.

All these relationships can have the "Require this relationship" checkbox checked.

With some relationships you can end up with duplicate results. One way to try to avoid this is go in the "Query options" in the "Advanced" part of the views configuration and check the "Distinct" checkbox.

Relationships can be confusing and they are hard to explain, but if you play around with them, once you understand them they are very useful.

**Extra question** To answer your extra question of whether you can display the value of one field if it is there and if it is not then show another field in its place:

Yes, you can do that. Depending on your requirements there are a couple of ways it can be done:

1. Exclude the secondary field from display and for the primary field check "Rewrite the output of this field" and use the tokens to print the primary and secondary fields out next to each other. This solution will only work if only one or the other of your fields will have a value. If there is a chance that both fields will have a value you will end up with both values printing next to each other.
2. Exclude the secondary value from display. Then in a custom module implement hook\_view\_pre\_render() and you can check the $view-\>result to see if the primary field has a value. If it doesn't you can replace the empty value with the value of the secondary field.
3. Override the template for views\_view\_fields.tpl.php so that if the primary field is empty you print the secondary one. And don't print the secondary one. This could also be handled in the preprocessor function template\_preprocess\_views\_view\_fields() in your theme's template.php file.

Unfortunately I don't have time to give code examples right now.

---
Tags: 7, views
---


# Question
Title: Create a field programatically with let me to introduce two values
I don't want to use field\_collection ;) I'll be easy.

I want to build a module that create a a field that let me to save two values at the same time, name and date.

I'd like to have both in the same table, but I don't find any article that explain how to make/define it.

It will be a field with two fields to fill in a node.

Any idea?

Thanks.

# Answer
> 1 votes
Download the examples module and look through the *Field Example* module.

It contains extensive code examples that show you in detail how to create a custom field, widget and formatter.

# Answer
> 0 votes
You can create custom compound fields in cck. I found following article for Drupal 7 Compound fields in Drupal 7 , you may get a clear idea from this article how to get proceed.

Previously i have tried this D6 tutorial, and created a compound field. i have not tried yet in D7

# Answer
> 0 votes
The answer was in my library, thanks to "Drupal 7 module development" I found what I was looking for.

The chapter to build a new field explain how to build a field with 2 o 3 database-fields, more easy than drupal 6 :)

---
Tags: 7, entities
---


# Question
Title: Anyone knows a good tutorial to learn how to create install profile?
I just want to create an 'install profile'.

Anyone knows a good step-by-step tutorial to learn how to create install profile starting from a production site?

Thanks

# Answer
Developing installation profiles covers the majority of install profiles, well worth a look at to get started.

There is a how to guide here as well.
> 2 votes

# Answer
While I think the drupal documentation is pretty good, I found this series of blog posts really helpful and easy to undestand.

http://scotthadfield.ca/2011/10/20/overview-d7-install-profiles
> 1 votes

# Answer
This post really helped me get to grips with splitting down individual elements of profile config, such as setting up WYSIWYG options:

http://internetdevels.com/blog/drupal-7-install-profile
> 1 votes

---
Tags: distributions
---


title: How to set default role in Drupal 6

text:
# Question
Title: How to set default role in Drupal 6
I have created some user roles in my drupal 6 website.

Have can set one of them as default role when users register in the site?

# Answer
> 1 votes
The Auto Assign Role module will allow this.

It allows you to:

1. Provide an automatic assignment of roles when a new account is created.
2. Allow the end user to choose their own role or roles when they create their account.
3. Provide paths that will trigger a specific role when an account is created.

# Answer
> 1 votes
Download and install Registration role module.

Registration role lets an administrator select a role to automatically assign to new users. The selected role will be assigned to new registrants.

---
Tags: 6, users
---


# Question
Title: Image gallery with mobile view optimization
I'm using Drupal 7, and I want to have a photo gallery.

When viewing the gallery using mobile phone or ipad, I wish to have the photos shown like facebook photo gallery:

1. image will auto resize according to screen size
2. when user slides the image to left or right, it will shows previous or next photo

Is there any module which can achieve the above effect?

# Answer
> 0 votes
You may try out the Photoswipe module (dev).

---
Tags: views, media
---


# Question
Title: Override Taxonomy Node content for different terms without using views
I have **taxonomy-term.tpl.php** page in my theme folder which shows the standard layout of a taxonomy term page like : Title, Description and content listing corresponding to the taxonomy term. Now I wish override this standard layout for a particular term and I create another term file namely : **taxonomy-term--32.tpl.php**. For this I haven't added any function in the template.php file in my theme.

My problem is that for the term page with **tid / term id = 32**, does not entirely override the content block. Precisely, the listing of the contents related to that taxonomy term remains in the overridden web page as well, which is not what I want.

N.B : I have disabled the Taxonomy Term View from the admin end of the site as I am not absolutely sure about its functionality.

# Answer
I don't want to simply edit my first answer because I think that's just as feasible an option as this one is (and less complicated). Regardless, this should do the trick. Basically all we're doing is modifying the page callback for the `taxonomy/term/%taxonomy_term` menu item.

1) Inside the `sites/all/modules` directory, create a folder (directory) called `newtaxonomypages` and inside that folder, create two files: `newtaxonomypages.info` and `newtaxonomypages.module`.

2) Paste the following code inside `newtaxonomypages.info`:

```
name = New Taxonomy Pages
description = Changes the display of taxonomy/term pages.
core = 7.x
dependencies[] = taxonomy

```

3) Paste the following code inside `newtaxonomypages.module`:

```
<?php

/**
 * @file
 * Alters the page callback for the menu item taxonomy/term/%taxonomy_term.
 */

/**
 * Implements hook_menu_alter().
 */
function newtaxonomypages_menu_alter(&$items) {
  // Change page callback to 'newtaxonomypages_page' from 'taxonomy_term_page'...
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'newtaxonomypages_page';
  // ... which was originally found in a separate file, but now it's defined below. So:
  unset($items['taxonomy/term/%taxonomy_term']['file']);
}

/**
 * The code inside this next function is the exact same code that you'd find on line 17 of
 * modules/taxonomy/taxonomy.pages.inc, except the nodes have been commented out and removed
 * from the view.
 */
function newtaxonomypages_page($term) {
  // If there is a menu link to this term, the link becomes the last part of
  // the active trail, and the link name becomes the page title. Thus, we must
  // explicitly set the page title to be the term title.
  drupal_set_title($term->name);

  // Build breadcrumb based on the hierarchy of the term.
  $current = (object) array(
    'tid' => $term->tid,
  );
  // @todo This overrides any other possible breadcrumb and is a pure hard-coded
  //   presumption. Make this behavior configurable per vocabulary or term.
  $breadcrumb = array();
  while ($parents = taxonomy_get_parents($current->tid)) {
    $current = array_shift($parents);
    $breadcrumb[] = l($current->name, 'taxonomy/term/' . $current->tid);
  }
  $breadcrumb[] = l(t('Home'), NULL);
  $breadcrumb = array_reverse($breadcrumb);
  drupal_set_breadcrumb($breadcrumb);
  drupal_add_feed('taxonomy/term/' . $term->tid . '/feed', 'RSS - ' . $term->name);

  // Set the term path as the canonical URL to prevent duplicate content.
  $uri = entity_uri('taxonomy_term', $term);
  drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE);
  // Set the non-aliased path as a default shortlink.
  drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE);

  // Normally we would call taxonomy_term_show() here, but for backwards
  // compatibility in Drupal 7 we do not want to do that (it produces different
  // data structures and HTML markup than what Drupal 7 released with). Calling
  // taxonomy_term_view() directly provides essentially the same thing, but
  // allows us to wrap the rendered term in our desired array structure.

  $build['term_heading'] = array(
    '#prefix' => '<div class="term-listing-heading">',
    '#suffix' => '</div>',
    'term' => taxonomy_term_view($term, 'full'),
  );

  // *****PART THAT HAS BEEN REMOVED: START***** //
  /*
  if ($nids = taxonomy_select_nodes($term->tid, TRUE, variable_get('default_nodes_main', 10))) {
    $nodes = node_load_multiple($nids);
    $build += node_view_multiple($nodes);
    $build['pager'] = array(
      '#theme' => 'pager',
      '#weight' => 5,
    );
  }
  else {
    $build['no_content'] = array(
      '#prefix' => '<p>',
      '#markup' => t('There is currently no content classified with this term.'),
      '#suffix' => '</p>',
    );
  }
  */
  // *****PART THAT HAS BEEN REMOVED: END***** //

  return $build;
}

```

4) Save both files, go to `admin/modules`, find the *New Taxonomy Pages* module (under *Other*), enable it, then *Save configuration*.
> 0 votes

# Answer
Change your `node.tpl.php` file so that it only returns the parts of the node you want, **if** the current path of the page being viewed is `taxonomy/term`. Using the *Bartik* `node.tpl.php` file as an example, and assuming you only want the title (linked to the node) to be displayed, you could do something like this:

**Original ("before"):**

```
<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

  <?php print render($title_prefix); ?>
  <?php if (!$page): ?>
    <h2<?php print $title_attributes; ?>>
      <a href="<?php print $node_url; ?>"><?php print $title; ?></a>
    </h2>
  <?php endif; ?>
  <?php print render($title_suffix); ?>

  <?php if ($display_submitted): ?>
    <div class="meta submitted">
      <?php print $user_picture; ?>
      <?php print $submitted; ?>
    </div>
  <?php endif; ?>

  <div class="content clearfix"<?php print $content_attributes; ?>>
    <?php
      // We hide the comments and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      print render($content);
    ?>
  </div>

  <?php
    // Remove the "Add new comment" link on the teaser page or if the comment
    // form is being displayed on the same page.
    if ($teaser || !empty($content['comments']['comment_form'])) {
      unset($content['links']['comment']['#links']['comment-add']);
    }
    // Only display the wrapper div if there are links.
    $links = render($content['links']);
    if ($links):
  ?>
    <div class="link-wrapper">
      <?php print $links; ?>
    </div>
  <?php endif; ?>

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

</div>

```

**Altered ("after"):**

```
<?php if (!$page && arg(0) == 'taxonomy' && arg(1) == 'term'): ?>
<?php
 // Note:
 // If you want to see all the values available to you at this point, uncomment
 // the next line (not safe for production environments):
 // print '<pre>' . check_plain(print_r($node, 1)) . '</pre>';
?>
<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
  <?php print render($title_prefix); ?>
    <h2<?php print $title_attributes; ?>>
      <a href="<?php print $node_url; ?>"><?php print $title; ?></a>
    </h2>
  <?php print render($title_suffix); ?>
</div>

<?php else: ?>

<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

  <?php print render($title_prefix); ?>
  <?php if (!$page): ?>
    <h2<?php print $title_attributes; ?>>
      <a href="<?php print $node_url; ?>"><?php print $title; ?></a>
    </h2>
  <?php endif; ?>
  <?php print render($title_suffix); ?>

  <?php if ($display_submitted): ?>
    <div class="meta submitted">
      <?php print $user_picture; ?>
      <?php print $submitted; ?>
    </div>
  <?php endif; ?>

  <div class="content clearfix"<?php print $content_attributes; ?>>
    <?php
      // We hide the comments and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      print render($content);
    ?>
  </div>

  <?php
    // Remove the "Add new comment" link on the teaser page or if the comment
    // form is being displayed on the same page.
    if ($teaser || !empty($content['comments']['comment_form'])) {
      unset($content['links']['comment']['#links']['comment-add']);
    }
    // Only display the wrapper div if there are links.
    $links = render($content['links']);
    if ($links):
  ?>
    <div class="link-wrapper">
      <?php print $links; ?>
    </div>
  <?php endif; ?>

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

</div>
<?php endif; ?>

```

Hope that helps...

:)
> 0 votes

---
Tags: taxonomy-terms
---


# Question
Title: What are the reasons for images going missing without changes made?
I have a client who is complaining that images which were there are no longer there. I wasn't sure what to think about it, so I asked him to add them again and let me know if it happens again, meanwhile I took note of the file path (/sites/default/files/styles/large/public/map.jpg).

I have now received another email saying they have disappeared, and upon checking the default Drupal broken image can be found within the WYSIWYG, but there is nothing on the actual page display of the node. I checked the file path and the image still exists on the system. There is also no new node revisions, so they have obviously not messed around with it.

Could anyone provide me with a list of explanations on what could possibly have happened here? I'm confused and I have no idea where to start with this problem!

FYI Drupal version is 7.12!

# Answer
1. There are known issues with the images after the security update of Drupal 7.20. I would suggest you to update the latest release if it is the case.
2. I would also check if there is a .htaccess file preventing access to the files or folders. I remember that there was a similar issue and it was related with a .htaccess file restricting access to the files under the path where the images are saved.
> 2 votes

---
Tags: 7, media, wysiwyg
---


# Question
Title: How to set page title for forum's Active and Unanswered tabs in Drupal 7?
I have to set up forums in Drupal 7. I want to set page title, meta keywords and meta description for forum tabs like

> Active Forums and Unanswered Topics for forum.

How to do this?

# Answer
> 1 votes
I have solved my problem by setting custom page title in our theme's template.php file.

i have used **bartic theme** so in my function in template.php file is as follows

```
 function bartik_process_page(&$variables) {
    $path = $_GET['q'];
    if (strpos($path,'forum/active') !== false)
       {
        $variables['head_title'] =  drupal_set_title('Your_Page Title');
       }
   }

 function bartik_preprocess_html(&$variables) {
 global $theme_path;

// Add conditional CSS for IE7 and below.
  drupal_add_css($theme_path . '/css/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));

 $variables['head_title'] = implode(' | ', array(drupal_get_title(), variable_get('site_name'), variable_get('site_slogan')));
  }

```

---
Tags: 7, nodes, routes
---


# Question
Title: When a user has forgotten their password, how to let them set a new one?
A user has forgotten her password, so she uses the 'forgotten password' function. She receives an email with one-time login, and proceeds to edit her profile to set a new password.

But that form requires the old password in order to reset password. A catch 22 situation?

# Answer
> 1 votes
The forgotten password function should not require the old password. Rather, the password reset link that you get in the email should take you to a password reset page immediately.

The path I got was something like `domain.com/user/37/edit?pass-reset-token=[long token string]` and on this page, it immediately asks for your new password which you must set.

# Answer
> 2 votes
Same problem here. My site had an action set to direct to the homepage on login. This helped me a lot to identify it. My solution was to disable the action an set a destination parameter by GET in my template to redirect user to the homepage on login. "/user?destination=/"

---
Tags: 7, users
---


# Question
Title: How to change all hyperlinks in the content
Hi i am new to the drupal and i got problem in my site in the hyperlinks. I have book copy module by which i have created one copy of the book. After creating the book i set aliases to content/newbook but the links in the content pointing to the old links they have not updated so i need some module which can change all hyperlinks in the content. I have tried with views/pathauto/pathlogic/path filter but not able to solve the problem any of these. Please let me know if there any such module.

# Answer
> 0 votes
That is a good reason why you shouldn't link to path aliases in your text areas. Because if they change you are in a mess.

You should always link to non-aliased patch like node/12 or user/4.

Then you can use a module to make your node/12 type links pretty. Namely the pathologic module will do that.

Do you have any record of what the old path aliases were or are they gone from the system and only the new aliases remain?

If the old ones are gone then you are out of luck, there is no way of knowing what pages those links should link to.

If the old ones are still there, you will be able to do some custom PHP/SQL to fix the issue.

You will have to check all the field values (database tables starting with field\_data\_ and field\_revision\_) for links, then check the url\_alias table for 'alias' matching the link. If there is one get the 'source'. Then you re-write the link in the field value to use the source path and write it back to the database.

That should allow you to get your links to be of the form node/12, which is good.

Then to get pretty urls in text set up the pathologic module.

# Answer
> 2 votes
I am not sure if I understand the problem correctly.

But if you're looking for a module that will do a batch search and replace, replacing the path of an URL embedded in node content with another path, the search and replace scanner can do plain text search-and-replace, or regular expression search-and-replace, against the body fields on *all* nodes in your system.

---
Tags: navigation, path-aliases, nodes
---


# Question
Title: Drupal 7 views admin redirecting to json returned after changing jquery version
I have installed the seven theme on the admin side and blocks theme on the user side... after getting alot of errors from multiple files adding jquery library, i have removed the extra files and upgraded the jquery in the misc directory to 1.9 with migration plugin.

the main problem was that wysiwyg and hierarchical select didnt work on the front end, so after removing the extra jquery libraries it is working now.

the problem after all that is that now when i try to edit a View, each time i edit something in the view and click on save, it redirects me to the json returned from server instead of just closing the dialog and showing the View edit panel.

In short the problem is that the ajax doesn't work.

So What Should I Do??

# Answer
> 2 votes
You can't just upgrade the jQuery in the misc directory. You will get many many problems.

If you want to update jQuery because a specific plugin you want to use requires it, I would recommend the jQuery multi module.

However if you want your whole site to use a newer version, use the jQuery update module. Currently though, the jQuery update module only supports up to jQuery 1.8.2.

In my experience using jquery update with versions above 1.5 was still too buggy, however those issues are claimed to have been fixed recently, so if you use the latest dev version it will apparently work.

However, you need 1.9 so jquery update isn't an option yet.

If you need 1.9 for a library (I assume that is probably the case), I would say use jQuery multi (I have successfully used it to run a bunch of things off on top of backbone.js and it has been working without issue for a long time now).

---
Tags: views, ajax, javascript
---


# Question
Title: How to hide some fields from user in add content page?
I have a content type with some fields created using cck module in Drupal 6 . I want user just fill in some of them in create content page and doesn't see others which will fill later by admin.

How can I do it in drupal 6 ? Is it possible ?

# Answer
If they are fields that the user is not permitted to use then there is a module included with CCK called content\_permissions.

If you install that then you can set role based permissions for each field on the permissions page.

If it is not an issue of access control, but you just want to hide some fields that once, you can implement hook\_form\_alter() in a custom module to do it.

It would go along the lines of this:

```
/**
 * Implementation of hook_form_alter(),
 */
function MODULENAME_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) {
    $node = $form['#node'];
    // Only for page content and only when adding a new node.
    if ($node->type == 'page' && empty($node->nid)) {
      // Hide the name field by restricting access.
      $form['field_name']['#access'] = FALSE;
    }
  }
}

```
> 0 votes

---
Tags: 6, entities
---


# Question
Title: How to exclude forms from processing by Hide Submit module?
According to module description this is possible.

However I didn't find how to do it and I did not able to exclude form by any way, e.g:

http://drupalcode.org/project/hide\_submit.git/commit/8aab1ab

# Answer
> 3 votes
The 2.x branch introduced `hook_hide_submit_alter()` which can be implemented to exclude certain forms based on the current path:

```
function MYMODULE_hide_submit_alter($hide_submit_settings) {

  // IMPORTANT NOTE: given the way module_invoke_all and array_merge work you
  // should not modify and return the original array. Instead create a new one
  // and add only the keys you care about. If two modules implement this hook
  // and try to modify the same values then the default will be used instead.
  $altered_settings = array();

  // Disable the module for my special form page.
  if (arg(0) == 'my-special-form') {
    $altered_settings['hide_submit']['hide_submit_status'] = FALSE;
  }

  return $altered_settings;
}

```

There doesn't look to be a way to turn the functionality off for a specific form, just by path. Might be worth a feature request on the module issue queue if that's something you'd like to see.

# Answer
> 1 votes
The commit you link to is from Sun, 19 Apr 2009. That code no longer exists in the latest drupal 7 version.

After having a quick look at the latest drupal 7 code there doesn't seem to be such a feature in it anymore.

---
Tags: 7, forms, javascript
---


# Question
Title: How to not index comments in search_index?
I'm using drupal search, the core module.

I want to not index the comments in the search\_index

In the node.module, the "function \_node\_index\_node($node)" loads and renders the node. Comment content is loaded and indexed here. I would like to not load the comments content here in order to not index this content. How can i do this ? Thanks

NB : i'm drupal 6, but tips in 6 or 7 are welcome

# Answer
> 2 votes
There doesn't seem to be an easy way to do this in drupal 6.

It gets added in hook\_nodeapi() but the comment module, so comment\_nodeapi().

There is no way to override what gets added in this manner.

So you would have to hack the comment module to make it no longer do that by removing the 'update index' part.

**Hacks** A note on hacks: In cases where you really do have to hack core, I recommend creating a patch file for the change and give it an informative name. Then commit to your version control the change and the patch. Keep a list of any hacks you might have, along with their purpose, which files have been changed, and their relevant patch file, in your developer documentation.

Then when you go to upgrade drupal next time you have the patch file, so you can update, then apply the patch (if the patch doesn't apply cleanly you can re-roll it). Easy.

This way if you ever hand over the project the next person will have it easier too.

---
Tags: 6, search
---


# Question
Title: How to get taxonomy image and path by tid in Drupal 7?
I want to get categiries image and path in Catalog Block for Ubercart 3 (Drupal 7) which is taxonomies. I know only `tid`.

~~For path i try this~~

~~```
$tid = (int)$variables['catid']; // return tid
$term = taxonomy_term_load($tid);
print_r(entity_uri('node', $term));

```~~

~~but site crashed.~~

# Answer
> 2 votes
I'm guessing you're looking for something like:

```
$term = taxonomy_term_load($tid);
if ($image_items = field_get_items('taxonomy_term', $term, 'field_name')) {
  $uri = $image_items[0]['uri'];
  $external_url = file_create_url($uri);
}

```

Where `field_name` is replaced with the name of your image field.

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


# Question
Title: Drupal 7 set default value from database in hook_form
I have implemented a hook menu:

```
$menu['question-view'] = array(
  'title' => 'Question View',
  'page callback' => 'item_view',
  'access arguments' => array('access question view'),
);

```

`item_view` callback is generated using table theme:

```
$output = theme('table', array(
  'header' => $header,
  'rows' => $rows,
));

$output .= theme('pager');
return $output;

```

which displays a table like this:

```
Question            Edit
Question1     Click here to edit
Question2     Click here to edit
Question3     Click here to edit

```

where "Question1", "Question2", and "Question3" are just questions like "What is your name?", which were all obtained from `questions` table in database.

When I click "Click here to edit", it should go to a form containing that question. For example, when I click edit beside Question2, the form should display Question2 as default value in the `$form['question']` field.

I want to do something like:

```
$form['question'] = array(
  '#title' => t('Question'),
  '#type' => 'textfield',
  '#default_value' => ... // This should come from the question where I clicked.
);

```

Question: How should I set the default value of `$form['question']`?

# Answer
Basically, you have to add an indicator with edit question link i.e **query string** to load the selected question from database and pass the default value to the form.

> A **query string** is the part of a uniform resource locator (URL) that contains data to be passed to web applications.

"Click here to edit" link may look like (clean URL enabled):

http://www.your-domain.com/item\_view/question/44

or

http://www.your-domain.com/question/44/edit

44 in both cases represent question id.

Then, take question id from the url and pass it to a mysql query to retrieve question title and assign it to `#default_value`

Example as follow:

```
function question_form() {

  $question_id = 0;

  // assuming url: www.your-domain.com/item_view/question/44
  if (arg(1) == 'question') {
    $question_id = arg(2);
  }

  // retrieve question title by question id
  $query = db_select('questions', 'q')
    ->fields('q', array('question_title'))
    ->condition('q.question_id', $question_id);
  $result = $query->execute()->fetchAssoc();

  $form['question'] = array(
    '#title' => t('Question'),
    '#type' => 'textfield',
    '#default_value' => ($result && isset($result['question_title']))? $result['question_title'] : '';
  );
}

```
> 1 votes

---
Tags: 7
---


# Question
Title: How to move the edit tab in node.tpl.php
The $tabs variable is being printed in page.tpl.php, but I want to move it under the title of my node. I can't use the $tabs variable in my node template and I don't see the variable being prepared in template.php as well.

How can I get $tabs to show where I want in my node template file?

# Answer
> 9 votes
The `$tabs` variable is set up in `template_preprocess_page()`; you can add the same var to the node template file by implementing a preprocess hook:

```
function MYTHEME_preprocess_node(&$vars) {
  $vars['tabs'] = menu_local_tabs();
}

```

---
Tags: nodes, routes
---


# Question
Title: Option for User to edit their own Profile
Is it possible for the user to be able to edit their own profile without going through the Drupal administration panel? I have a /user page with views that output the needed fields. Ideally I would like an 'edit profile' button that loads up the same editable fields.

Could someone point me to how this can be achieved?

Thanks in advance,

P.S.: I'm on Drupal 7. Might be worth noting that I'm using *Profile 2* as well.

# Answer
> 1 votes
I've managed to find the solution to this problem. I have to call the 'edit user' link directly from Views as a field. Thank you.

# Answer
> 0 votes
As long as you don't give users the permission to use the admin theme they will only ever see the regular theme, regardless of what page they are on.

So you could do that and then just link to the profile edit page.

The user will never know they are in the administration area. They just see a form they can fill out.

Is that an acceptable solution?

---
Tags: users
---


# Question
Title: How to get rid of error messages after second try where file was uploaded successfully?
My question is similar to:

https://stackoverflow.com/questions/9676988/in-drupal-7-errors-for-file-managed-field-remain-even-when-fixed

Why error message from my custom file validator remains the same after next try where was file uploaded successfully ?

How can I solve this problem?

I didn't find any JS handler which I can extend.

# Answer
There is a working patch for this issue here. (File validation error message not removed after subsequent upload of valid file - 1792032)

That patch issue is waiting on someone to write tests before it can be RTBCd. It shouldn't be hard to adapt that patch to Drupal 7 in the mean time. Just make sure you document the fact that you have patched/modified core somewhere for future developers.
> 0 votes

---
Tags: 7, ajax, files, status-messages
---


# Question
Title: How could I create multiple private sites within one Drupal site?
Can I create a Drupal site, where a user, let's call her Jane, can create an account and publish some content, like a few articles. Then create accounts for her friends who can login and view all the nodes she has created, and which they create. At the same time, Paul creates an account, creates some nodes, and invites his friends etc. However, Paul and his friends cannot see Jane's nodes or users - and vice versa. It feels to Jane and Paul that they have there own separate website.

What are the key Drupal concepts or methods for creating a site like this? Thanks.

# Answer
This seems like a *perfect* use case for Organic Groups.

> Enable users to create and manage their own 'groups'. Each group can have subscribers, and maintains a group home page where subscribers communicate amongst themselves.

I'm not going to go in depth with setup or anything, as OG is a **beast** of a module, but the benefits are immense, and should allow you to do exactly what you need. It's the same module that provides the groups.drupal.org functionality :)

A quick Google search will provide a wealth or information, as will a browse of the tag.

Also check these out for a brief overview of OG:
> 4 votes

# Answer
> However, Paul and his friends cannot see Jane's nodes or users - and vice versa. It feels to Jane and Paul that they have there own separate website.

Organic Groups (as suggested by Chapabu) may well be the solution you're after, but it is (IMHO) not a module that is easy to set up or manage.

As an alternative, in particular if you want a clear and total separation between Paul's and Jane's "sites" you can achieve this by means of a so-called multi-site. A multi-site allows you to share a single Drupal installation (including core, contributed modules, and themes) among several sites, where each site has its own database, content, and users.

The canonical documentation for setting up a multi-site can be found at Drupal.org: Multisite.

In addition to the official documentation, you may want to read my tutorial about setting up a multi-site here. I hope the instructions are clear enough to follow.
> 0 votes

---
Tags: users
---


# Question
Title: How to share Drush code with the community?
I created a simple Drush command. How can I share it with the community? Do I need to create a module and add it to drupal.org ?

# Answer
If it's a useful Drush command, and one that you could see being used on a daily basis, the I'd suggest heading to the Drush issue queue and posting a feature request. Then answer the feature request with a patch that adds the command. Whether to not it's suitable for Drush core will most likely then be discussed and further action will be taken by the maintainers.

Another option as you mentioned, is to create a module form your command and submit it via the standard module submission process.

The *last* thing I would suggest it hassling the module maintainers on social media channels or e-mail.

Greg Anderson does sometimes frequent this site though, so he might be able to provide a preferred approach :-)
> 5 votes

# Answer
Get an account on github.com or another code repository, upload your code, then encourage others to help to work on it with you. Get the word out about your code. Involve other people in your work. Find out about the processes of making new Drupal projects and interacting with the community.
> 0 votes

---
Tags: drush
---


# Question
Title: Is there a central document store in Drupal 6 or a module that does?
I have a content type in Drupal 6 that consists of 3 main fields, each allows for the upload of unlimited files, which I have restricted to being PDF or DOC based formats. Lets say there will 100 pieces of content based on this type. Whilst most of the uploads made, may well be unique, the customer has identified that there are a few docs, that may need to be uploaded to more than one piece of content.

This led on to the question regarding if there is a central document store of some kind in Drupal (especially 6 in this case). Such a tool would mean that files would only need to be uploaded once but referenced many times from various pieces of content.

Does anyone have any solutions to this scenario?

# Answer
> 3 votes
Sounds like the FileField Sources module is exactly what you're looking for.

> FileField Sources is an extension to the FileField module. The FileField module lets you upload files from your computer through a CCK field. The FileField Sources module expands on this ability by allowing you to select new or existing files through additional means, including:
>
> * **Re-use files by an auto-complete textfield Attach server-side files**
> * uploaded via FTP Transfer files from a remote server (cURL required)
> * Paste a file directly from the clipboard (Drupal 7 only) Select
> * existing files through the IMCE file browser

# Answer
> 2 votes
*All* uploaded documents in Drupal goes into the *same* directory (you identify this directory when you configure files system settings). This directory is the central document store you ask about.

As for allowing one uploaded file to be attached to multiple nodes, there is nothing in Drupal that stops you from doing this, but there is no UI for it in core (so without a module, you need to manipulate the DB directly). However, the File Framework module has an UI that lets you do this.

# Answer
> 2 votes
What you are looking is the file\_entity module in D7.

If you search around, it's possible you can find a similar back ported functionality, but I haven't seen it. Here's a blog post that discusses some alternatives: http://blog.merge.nl/2010/07/15/media-library-alternatives-drupal-6

You can emulate it in D6 by basically uploading each file into a node, and using node references as provided by CCK, but that's very bulky compared to file entities.

---
Tags: nodes, 6
---


# Question
Title: Rules: How to let users create a node when they register
I'm trying to come up with a workflow using Rules that would enable a visitor to register + create a node (e.g. article) in one go, before the account is approved by an admin.

Details:

* Visitors can create account, but administrator approval is required
* anonymous users cannot create content
* currently using the **After saving a new profile** event
* when visitors click on 'Create new account' they are redirected to node/add/article
* the created article would be saved as 'unpublished'
* when account is approved, the article would automatically be published

I'm having problems creating the article. The redirect doesn't work. I instead get the usual 'account pending instructions sent' message.

# Answer
> 4 votes
I would approach this by adding the Logintoboggan module, which integrates with Rules via a submodule.

Logintoboggan will allow you to assign users a special role before their account is verified. Normally, this verification is performed by the users themselves via e-mail, but you could stop that e-mail from being sent and instead have the admin do the verification.

With this approach, you can give users with the *Unverified* role (awarded upon registration with Logintoboggan) the permission to create content of type *Article* and then add rules to publish such articles upon verifying the account (Logintoboggan provides a *User account is verified* event).

# Answer
> 2 votes
I think you could overide the redirect on the user register form.

Ie:

```
// This should target only user registration form ...
function YOUR_MODULE_form_user_register_form_alter(&$form, &$form_state, $form_id)
{
    $form['#redirect'] = "node/article/add";
}

```

Hope this helps. Happy coding!

---
Tags: rules, workflows
---


# Question
Title: Entity Registration module: Enable registration by default or programmatically
By default, the Entity Registration module disables the registration. We need to enable it everytime a node is created from 'Manage Registrations - Settings' tab. How to automate the process?

I tried changing the 'status' value to '1' in registration\_field\_info() of registration.field.inc but it didn't work.

Is there a way to do it programmatically, otherwise?

# Answer
> 0 votes
```
/**
* Implements hook_entity_insert().
*/
function registration_entity_insert($entity, $entity_type) {
  $registration_type = registration_get_entity_registration_type($entity_type, $entity);
  if ($registration_type !== FALSE) {
list($entity_id) = entity_extract_ids($entity_type, $entity);

$settings2 = array(
  'multiple_registrations' => 0,
  'from address' => variable_get('site_mail', ini_get('sendmail_from')),
);

$settings = array(
  'status' => 1,
  'capacity' => 0,
  'send_reminder' => 0,
  'settings' => serialize($settings2),
);

registration_update_entity_settings($entity_type, $entity_id, $settings);
//registration_entity_set_default_settings($entity_type, $entity);
 }
}

```

References:

http://drupal.org/node/1430870

http://drupal.org/node/1357280

---
Tags: 7
---


title: How to access field in view template?

text:
# Question
Title: How to access field in view template?
I am trying to access from **views-view-field--title.tpl** template to another field...

I have this code:

```
<?php print $output;
  print $row->{$view->field['field_NAME']->field_alias};
 ?>

```

But it shows me just a number.. (1,2,3,4,5,....)

Can someone help me?

Thank you!

# Answer
> 5 votes
I'd suggest that you enable the Devel module on your drupal site (hopefully not a production version ;-). Once you've enabled that module, you can use the dsm() function, within php tags in your templates to **inspect in detail** the variables that are provided in each template!

So enable the Devel module, then add the following to your template file:

```
<?php dsm($view->field['field_NAME']); ?>

```

Clear your cache and go to a page that contains a view... What the dsm() function should do is output your object in the 'Help' section of your page:

Just click on the object and start inspecting all the fields it has available. You'll see that what it's returning with the 'field\_alias' property is just the nid of that node...

Since you didn't specify what you're trying to get with the additional field, I can't be any more specific, but hopefully digging around will let you figure out how to get to the field property/properties you need. Let us know if you figure it out!

p.s. Since the 'title' field template is called for each row displayed in your view, you will get that 'field' object multiple times - once for each time the template was called.

# Answer
> 2 votes
I had the exact same problem, I inspected the $row variable using this

```
foreach ($row as $key => $value)
{
   print $key;
   print " : ";
   print $value;
   print "<br>";
}

```

until I had this

```
foreach ($row->field_field_link_text[0]["rendered"] as $key => $value)
{
   print $key;
   print " : ";
   print $value;
   print "<br>";
}

```

Which finally gave me the answer I was looking for:

```
$row->field_field_link_text[0]["rendered"]["#markup"]

```

# Answer
> 1 votes
I wish I had known about this before :-)

---
Tags: views, theming
---


# Question
Title: How to import nodes that reference each other using Feeds?
I have a content type that references nodes of the same content type (using References module).

So example nodes might look like this:

```
Title   Body       See also (Node reference)
AAA     Testing    CCC
BBB     Testing
CCC     Testing    AAA, BBB

```

I'm pulling all of this information from an XML feed using Feeds Node processor. The problem is that when creating node AAA, node CCC hasn't been created yet so the reference field doesn't populate.

Do I need to create a second importer - but can two importers update the same nodes? I also had a look at Feeds Self Node Processor but don't think that's the answer.

# Answer
> 5 votes
Two importers can work on the same nodes without any problem, but that's not what you need. Instead, You need to set the importer to update/overwrite existing nodes when they have the same GUID. Then you run the importer twice on the same xml file. The first time they won't be populated properly, but because they'll already exist the second time, the second run should fix it.

# Answer
> 1 votes
Importing twice the same xml won't work because feeds store a hash of each item to be sure it has changed. The better will be to order the items to be imported to have referenced item loaded before. Otherwise, you should empty the table 'feeds\_item'.

# Answer
> 1 votes
just run it without the reference column first... then all the nodes will be there... update the nodes with a second run to add the reference column. I think you need GUID to ensure that it updates the same field rather than make a new one as well as changing the importer settings to update the node rather than replace it.

---
Tags: 7, nodes, feeds
---


# Question
Title: How to provide facility to download & upload files to specific type of user in drupal 6
**What i did:-**

So , i am create one content type like "login\_page", so in that i want to display title , description and file download & display. This content type display on when user logged in instead of user page . And i have 2 types of user i.e Customer user & guest user.

**What i want:-** So now i want to display or download text file such as pdf or doc files facility to **customer user** & display facility to **guest user** . This files are uploaded by the admin.

So for that any module is available or any solution nearly same to such situation. Please help me i am stuck on that.

# Answer
> 1 votes
Create two roles namely "customer" and "guest" (if you had not created yet). Now you can use field\_permissions to give each role the permission you want. Add permission to customer role to download it and guest to view it.

---
Tags: views, 7, files
---


title: Database updates Out of date

text:
# Question
Title: Database updates Out of date
I downloaded a couple of module updates. Before I did so, I didn't disable the modules. Is this ok? I am now seeing the following in my Status Report:

Database updates Out of date Some modules have database schema updates to install. You should run the database update script immediately.

Is it safe for me to run the database update script now? Or should I first do a core update (am currently running 7.18 and would be upgrading to 7.19)?

# Answer
Yes. Go ahead and run update.php. It will run the updates (which are usually but not necessarily schema updates) for the new modules.

There is no need to disable modules before updating them. There is no need to update Core first. You *should*, however, put the site into maintenance mode before updating the modules until after you run update.php.

You should run update.php every single time you update a module or the Core.
> 1 votes

---
Tags: updating
---


# Question
Title: Internal Server Error? Why is this happening?
All normal to start my website, but to click on any of the links, menus, etc, I get redirected to this with the following message:

> Internal Server Error
>
> The server encountered an internal error or misconfiguration and was unable to complete your request ...

Why is this happening?

What happens is that had risen another database project (one domain to another) I think it has a lot to do this.

There a way to fix it? Perhaps when exporting the database did wrong, what I want is that this database will serve me for several other projects. other domains. I need your comments, help or suggestion

# Answer
> 2 votes
**Q. Why is this happening?**

This can happen if the .htaccess files in your Drupal directory use settings or trigger actions which are not supported by your Apache server config. If you're not running the server yourself, but are registered with a webhost, you can either ask your webhost to enable the options in question, or just comment them out in the htaccess files.

1. The options which are known to cause an Error 500 are:

Options -Indexes
2. It may also occur when setting very permissive file permissions (777) and your hoster added some security checks to avoid this. Try to lower permissions.
3. Another problem can occur if you're using .htaccess files using UTF-8 codification with Byte-Order Mark (BOM). Reencode your .htaccess files properly without BOM to solve this.
4. This error can also manifests itself as a PHP error. Try adding the code below to one of your PHP files such as local.php, then checking the error log file it generates.

ini\_set('log\_errors', 1); ini\_set('error\_log', 'errorlog.txt');

Read:

HTTP Error 500 Internal server error

List of HTTP status codes

---
Tags: database
---


# Question
Title: How do you export configuration from configuration module
I need to include the configuration that I track in configuration modules into my install profile or however I will allow so that it will be initialised on install. How do I do this?

# Answer
Enable **Configuration Management UI** submodule

Goto yoursite.com/admin/config/system/configuration/migrate

There is links for `Export` & `Import`
> 1 votes

---
Tags: configuration
---


# Question
Title: How to get the out of the box slideshow to display on a page other than /node? - Corporate Clean/Omega theme
I am using a domain access module and currently running two domains. Out of the box, my default domain was displaying a slideshow on the homepage. Using these instructions I created a new front page -

However, now the slideshow isn't displaying. How do I get it back up?

By the way, the reason I went ahead with the front page setup as per the instructions was to avoid the "No front page content has been created yet." message.

# Answer
> 2 votes
If it was displaying the slideshow correctly out of the box (i.e. without any modifications made), then you should be able set the default front page back to its original state (empty... i.e. delete whatever's currently in the box), then add a file in the theme directory called `page--front.tpl.php`. Inside that file, copy/paste the original code found inside the file `page.tpl.php`.

Assuming you're using the Corporate Clean theme, scroll down your new `page--front.tpl.php` file about 220 lines and change this line:

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

```

... so that it's commented out:

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

```

... Or, if all you want to do is simply remove the *No front page content has been created yet* message, you can hide the default message and then print the rest of the content like normal (i.e. instead of changing the line, just add another one right above it):

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

```

Or, you could just delete that line but I assume you'll eventually want some content there (in which case you can go back and undo the commenting out).

After you've completed all the changes, saved all the files, etc, go to `admin/config/development/performance` and clear all the caches -- the new front page should now appear with the slideshow and without any "No front page content has been created yet" content.

Hope that helps...

:)

---
Tags: theming
---


# Question
Title: Button with Drupal Behavior jQuery Conflicting with AJAX 'Add More' Button on Unlimited Cardinality Field
I have a form with an unlimited cardinality field that creates an 'Add more' button to add more fields. I also have a separate pair of fields. One of these fields has a value prepopulated on starting a new form, the other field is another unlimited cardinality field with an 'Add more' button & is blank on page load. I have attached a Drupal Behavior jQuery function to a button that I have added in a custom module with hook\_form\_alter: this jQuery sets the value of the second of the pair of fields to the value of the first when the custom button is clicked. This works. And the 'Add More' buttons for the unlimited cardinality fields work as well. However, after the custom button has been clicked once, the 'Add More' button will no longer create a new field, & I get the following errors in my logs:

`Apr 25 02:56:36 lucifer drupal: https://somesite.com|1366880196|php|111.111.111.111|https://somesite.com/system/ajax|https://somesite.com/node/add/inventory-stocking-ticket|1||Warning: implode(): Invalid arguments passed in form_error() (line 1649 of /hosting/somesite/com/htdocs/cms_sandbox/includes/form.inc).`

`Apr 25 02:56:41 lucifer drupal: https://somesite.com|1366880201|php|111.111.111.111|https://somesite.com/system/ajax|https://somesite.com/node/add/inventory-stocking-ticket|1||Notice: Undefined index: #ajax in ajax_form_callback() (line 379 of /hosting/somesite/com/htdocs/cms_sandbox/includes/ajax.inc).`

Here is my code for the custom button:

```
$form['field_ending_weight_garbage']['und']['garbage_no_change'] = array(
  '#type' => 'button',
  '#value' => t('No Change'),
  '#attributes' => array('onclick' => 'return (false);'),
  '#name' => 'garbagenochange',
);

```

And the code for the behavior:

```
(function ($) {
  Drupal.behaviors.noChange = {
    attach: function (context, settings) {
     $('#edit-field-ending-weight-garbage-und-garbage-no-change').once('noChange', function() {
      $('#edit-field-ending-weight-garbage-und-garbage-no-change', context).click(function () {
     var a = $('#edit-field-starting-weight-garbage-und-0-value').val();
     var b = $('#edit-field-ending-weight-garbage-und-0-value').val();
     if (b == "")
     {
       $('#edit-field-ending-weight-garbage-und-0-value').val( a );
     }
     else
     {
       $('#edit-field-ending-weight-garbage-und-0-value').select();
     }
        return false;
      });
    });
   }
  };
}(jQuery));

```

Which is attached in an after\_build function like so:

```
drupal_add_js(drupal_get_path('theme', 'corolla').'/js/inventoryNoChange.js');

```

I'm using jQuery 1.5 by means of jQuery Update module, uncompressed. What could be causing this?

**Edit:** I've managed to eliminate the first error by adding the custom button like this:

```
$form['field_starting_weight_garbage']['und'][0]['garbage_no_change'] = array(
  '#type' => 'button',
  '#value' => t('No Change'),
  '#attributes' => array('onclick' => 'return (false);'),
    '#limit_validation_errors' => array(),
  '#name' => 'garbagenochange',
);

```

So, it's on the first field in the pair rather than the second, & it's at `$form['field_starting_weight_garbage']['und'][0]['garbage_no_change']` rather than `$form['field_starting_weight_garbage']['und']['garbage_no_change']`.

But the ajax error persists, & the 'Add Another' functionality is still broken. I should note that it only throws the error & fails seemingly randomly. I can add several extra fields with the 'Add Another' button, but then it breaks, throws the error, & won't add more fields.

I've determined that it is not the Behavior/jQuery that is breaking things. Simply adding the custom button with no behavior attached to it causes the problem. Still hoping someone can shed some light on this.

# Answer
So I went with a different approach to achieve the same thing. Instead of adding a button using the '#button' or '#submit' property in hook\_form\_alter, which was causing the conflict, I added a button with the following code:

```
$form['field_starting_weight_garbage']['und'][0]['value']['#prefix'] = '<div>';
$form['field_starting_weight_garbage']['und'][0]['value']['#suffix'] = '<input type="submit" value="No Change" class="form-submit" id="garbagenochange"></div>';

```

& adjusted the Drupal Behavior to attach to this element (id="garbagenochange").

I still don't know exactly what was causing the conflict or how to fix it, but this does what I need, so I'll go this route.
> 1 votes

---
Tags: 7, forms, ajax, javascript
---


title: Fancybox module error messages

text:
# Question
Title: Fancybox module error messages
I enabled the fancybox module, but since doing so am getting the following error messages:

```
Notice: Undefined index: options in _fancybox_filter_settings() (line 559 of /home/mysite/public_html/sites/all/modules/fancybox/fancybox.module).
Warning: Invalid argument supplied for foreach() in _fancybox_filter_settings() (line 559 of /home/mysite/public_html/sites/all/modules/fancybox/fancybox.module).

```

Any advice as to how to fix them?

# Answer
I guess you have a solution available in the following bug report filed at http://drupal.org/node/1904006

You have two possible options available. 1. There is a patch available in that post, use that. 2. Download development release, which already has that path applied in it.
> 1 votes

---
Tags: 7
---


# Question
Title: Can you tag individual searches per search in order to apply different filters to each?
I've got a site where we use solr to generate some menu items and other custom lists as well as running the default search. The issue I'm running in to is all the different hook\_apachesolr\_query\_alter calls across several different modules seem to be getting applied on top of each other stopping everything from working as expected.

Is there an identifier I can look for, or that I can add, in order to identify which query is currently being altered so I can filter them appropriately?

This is what I want to be able to do:

```
<?php
if ($query->name == 'special_menu'){
  $query->replaceParam('qf', 'sm_vid_Colour');
}
?>

```

(This is a dupe of my post on Drupal.org at http://drupal.org/node/1976224 but I wasn't getting any love there and thought I'd try my luck here!)

# Answer
> 0 votes
I found a solution that worked for me. Here it is in case anyone else wants to do something similar, or in case someone wants to suggest a better way of doing it!

So the situation is that for a single page, I need to run a handful of SOLR queries to determine what should show up and what should not. Each of those queries works on different fields, so we need to be able to add a different 'qf' parameter to each of them. This gets harder however, when all hook\_apachesolr\_query\_alter calls trigger on all searches! (See the related issue about enabling 'qf' #1659184: Allow apachesolr\_search\_search\_results() to accept 'qf' (query fields) parameter)

After a lot of experimentation I found that the only field I could manipulate when starting a query and fetch and act on in hook\_apachesolr\_query\_alter was using the search path value in a custom $search\_page. This is how I did it:

```
<?php
$search_page = array(
        'env_id'   => 'solr_server',
        'settings' => array(
          'apachesolr_search_per_page' => 25,
          'spellcheck' => FALSE,
        ),
        'search_path' => 'ducks-BiGhE3Nxv34lyTKVoka74WI3r9yjJyc5ohiuJkeCiqp8gJunyWk3gXMDK8W',
      );

      $search_terms = array('"duck"', '"cheese sauce"');

      // Only run if the solr is enabled server environment is detected.
      if (module_exists('apachesolr') && apachesolr_environment_load($search_page['env_id'])) {
        $results = apachesolr_search_search_results('"' . implode(' ', $search_terms). '"', NULL, $search_page);
?>

```

Then, in hook\_apachesolr\_query\_alter for this particular module/query:

```
<?php
function pet_or_dinner_apachesolr_query_alter($query) {
  /* test that this is a 'ducks' query */
  if (stristr($query->getPath(), 'ducks')){
    /* now apply different settings depending on the current page */
    $node = menu_get_object();
    if (isset($node->type) && $node->type == 'pets') {
      //Search only the Pet field
      $query->replaceParam('qf', 'sm_vid_pet');
    } elseif (isset($node->type) && $node->type == 'meals') {
      //Search only the Meal field
      $query->replaceParam('qf', 'sm_vid_meal');
    }
  }
}
?>

```

I don't know if it's necessary, but I put the extra long random string in the 'search\_path' so that I didn't have any site visitors accidentally tripping over it. I don't think it is publicly accessible though. Someone else can confirm or debunk that concept!

But there we go, a hook to be able to perform custom modifications on concurrent queries. Definitely not clean but it gets us over the line!

**I'll leave this question open in case someone has a better answer.**

---
Tags: search
---


# Question
Title: How to change "Read more" and "Add new comment" link to an image in teaser view?
On the project that I'm working on now I need to display the "Read more" and "Add new comment" links in my teaser as images in sepperated divs.

The problems that I have is:

* I'm using "display suite" to show my content but it only gives me a "Read more" link no "Add new comment" link
* I need to hide the tekst and display only the image. (see link "read more" part)

Here is a png of what i need to have:

Thx up front for any help you can give me!

# Answer
> 3 votes
You can display both links enabled the "links" field in "manage display" page. The "display suite" module redirect to default content types manager.

Path to this page; Administration » Structure » Content types » Your\_content\_type » Manage display. Don't forget to select the view mode "teaser" in the upper side of the page to display all the fields associated with this view mode.

If you want to change the output, you will have to code the changes. We have different alternatives to reach to the same place:

1. Implement in your theme template or in your\_module.module the hook `hook_preprocess_node` . We examinate this function:

```
/* Tip 1 => You have to change 'yourmodule' for the real name of your module.
* For example, when you create a file like apple.module where you will write your code,
* 'apple' will be the machine name to implement hooks. Following the example,
* the name of this hook in apple.module should be apple_preprocces_node()
*/

function yourmodule_preprocess_node(&$variables){

  // Change *your_content_type* for the machine name of your content type
  // In your database, node_type table, you can see the machine name of your content types
  // By default, Drupal comes with 2 content types called Article and Basic Page,
  // but i assumed that you created a new type.
  // The reason of applying a conditional statement is we only want to apply these changes to a specific type,
  // because it's probably that you will use them to build theme like articles to build a blog.
  if ($variables['type'] == 'your_content_type' ){

  // Change the link node read-more
  // I am changing the title of the link. The text stay in the code,
  // but it's invisible.
  // Default text received in array => 'Read more<span class="element-invisible"> about ...</span>'

    $variables['content']['links']['node']['#links']['node-readmore']['title'] = '<span class="element-invisible">Read more about ...</span>';

  // We only have hidden the text with the span tag.
  // With css you can display the image you want

     $variables['content']['links']['node']['#links']['submitted']['title'] = $variables['submitted'];
     $variables['content']['links']['node']['#links']['submitted']['html'] = TRUE;
     $variables['display_submitted'] = FALSE;

  // -----------------------------------

  // We apply tha same strategy

  // Change the link node add-comment
  // Default text received in array => 'Add new comment'

    $variables['content']['links']['comment']['#links']['comment-add']['title'] = '<span class="element-invisible">Add new comment</span>';
    $variables['content']['links']['comment']['#links']['comment-add']['html'] = TRUE;

  // With css, the link looks better.

  } // end if

}

```
2. You could build your own functions that build the output that you want. This possibility will give you a great power of customization. For example:

```
 function theme_link_YourContentType_readMore($variables){

   // Build your code and return it

 }

 function theme_link_YourContentType_addComment($variables){

   // Build your code and return it

 }

 // Finally, you need to tell to the system that apply the theme functions that have been built previously

 function yourmodule_preprocess_node(&$variables){

   $variables['content']['links']['node']['#theme'] = 'link_YourContentType_readMore';
   $variables['content']['links']['comment']['#theme'] = 'link_YourContentType_addComment';

 }

```

# Answer
> 0 votes
Kinda hack,definitely there will be better answer you can pick the class on the div on add more link and then, let say class is xyz .xyz { text-indent:99999999px; }

---
Tags: 7, comments
---


title: Events calendar & time

text:
# Question
Title: Events calendar & time
When working with an Event content type and creating an Events Calendar using views, is it best to keep the date and time separate or together? I was thinking of having them separately, but there is no Time field type, and if I select the content type of Date for the Time only, it messes things up, in a sense that it also requires a date, which conflicts with my Date Field. :S

The reason why I want to separate the Date from Time is because I only want the time to displayed in the calendar view.

Any tips would be greatly appreciated.

# Answer
> 0 votes
You go to admin/configuration/regional and language/date and time/formats. you can add a formats. so, you click on the Type and add a type.

# Answer
> 0 votes
Drupal 7?

Use admin/config/regional/date-time/formats and create a new Date/Time format that only outputs the time. Then in your view set the field display to use that format by selecting "date and time" under "formatter." Now select your newly created format under "choose how users view dates and times."

I think that is the same in D6 as well or at least similar.

---
Tags: views, datetime
---


# Question
Title: Where do these version numbers come from "module-name-1.0-alpha1+13-dev" with plus?
I've started to work in an existing drupal development project and wanted to do some module updates and found modules with versions like this:

* Universally Unique IDentifier 7.x-1.0-alpha3+47-dev
* Taxonomy CSV import/export 7.x-5.10+17-dev

I've never seen this before. According to drupal version number guidelines this is not wanted.

Now, our head developer says they *never* modified any contributed modules and only took them from drupal.org ... Where do that version numbers come from?

Did I miss something?

# Answer
> 6 votes
-dev versions, are regularly built from the latest source code.

To differentiate between todays -dev release, and yesterdays, the number you've indicated counts the number of changes between any two dev releases.

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


title: How to delete system menu links

text:
# Question
Title: How to delete system menu links
I want to remove the "My Account" and "Log out" menu links, as I've incorporated those into other parts of the page.

Now, I'm a Drupal novice so if I'm making rookie mistakes here go easy!

What I've tried is something like this in my module.install file

```
function mymodule_enable()
{
    menu_link_delete(null, 'user');
    menu_link_delete(null, 'user/logout');
}

```

Now - that doesn't work as those two menu links are 'system' links. I tried to brute force this by creating a variant of menu\_link\_delete which forces deletion, by passing "true" to the $force parameter of `_menu_delete_item`...

```
function force_menu_link_delete($mlid, $path = NULL) {
    if (isset($mlid)) {
        _menu_delete_item(db_query("SELECT * FROM {menu_links} WHERE mlid = :mlid", array(':mlid' => $mlid))->fetchAssoc(), true);
    } else {
        $result = db_query("SELECT * FROM {menu_links} WHERE link_path = :link_path", array(':link_path' => $path));
        foreach ($result as $link) {
            _menu_delete_item($link, true);
        }
    }
}

```

When my module is enabled, that does successfully delete the relevant rows of the menu\_link table, but by the time the Drupal has finished working its magic they have reappeared in the table!

The reason of course is that the `user_menu()` hook goes and reestablishes them. I wondered if removing them with a menu\_alter hook would work...

```
function mymodule_menu_alter(&$items) {
    unset($items['user']);
    unset($items['user/logout']);
}

```

Sure enough, they disappear, but so does the actual capability to logout!

So - I'm going about this the wrong way. I'm guessing I shouldn't try to delete the menu links themselves, but somehow prevent my theme from displaying them.

Pointers are very welcome....

# Answer
Not sure if this is the correct approach, but it worked - I used a menu\_alter hook to move the menu items to a different menu.

```
function mymodule_menu_alter(&$items) {
    $items['user']['menu_name'] = 'unused-menu';
    $items['user/logout']['menu_name'] = 'unused-menu';
}

```
> 1 votes

---
Tags: routes
---


title: Show Distance in table from openlayers

text:
# Question
Title: Show Distance in table from openlayers
So I followed the instructions from this thread; Need a simple Google Maps solution; lost in the labyrinth of modules. I've gotten everything to work how I need it on my test server a few months ago. The SS below shows how it looks with the distance/proximity working.

Just before I got it working. I had a problem that the distance would not show based off the address or zip searched for. After some tinkering with views (atleast I think it was views), I finally got the distance working.

Now, my boss wants me to push it live and I can't remember how I got the distance to calculate based off an address or zipcode when I expose the proximity in views. It looks like the following;

I've opened both my test server and live side by side and checked over tons of the settings MANY MANY times over and still haven't been able to figure out what I missed. I've tried the following;

* Refreshing the Proximity calculations via the openlayers/proximity tab
* Tinkering with many different views settings.
* Creating new test nodes
* Rebuilding the process from the beginning

If you guys can maybe point me in the right direction or just mention SOMETHING that maybe I haven't thought about it would be great help. Thanks in advanced.

# Answer
Have you got this sorted yet?

Ensure that you're using the "Geofield - proximity" field for output and not the Proximity - distance field. I've tried using the latter and not had it working (yet).
> 0 votes

---
Tags: 7, javascript, location
---


title: Data overlay filter

text:
# Question
Title: Data overlay filter
I have an OpenLayers View created to display products at various locations. I have some locations that don't have any products yet; therefore, should NOT be displayed. My page view filters these out perfectly but the Map still displays the locations without products.

My assumption is that the points that are drawn on to the map are generated by the OpenLayers Data Overlay. I've tried multiple filters but none seem to affect the View. Even changing the Content Type doesn't change the output of the OpenLayers Data Overlay.

Any idea on how I can get the Map to ONLY display those results given in the page view?

# Answer
If you make sure to use the filters across all view elements, this should work.

It's the data overlay views that are producing the output for the page view to overlay. You can see this data in the preview panel on views.

You may even consider putting your filters on the data overlay view only and not the page view.
> 0 votes

---
Tags: views, javascript
---


title: Page redirect on login

text:
# Question
Title: Page redirect on login
I want to redirect all the users to a specific page after login. It seems like an easy thing to do using rules.

Event
User has logged in

Action
Page redirect

There is a small problem though. Page redirection will also work on the first login/password recovery scenario which in practice disallows the user to set/change his password.

Any ideas how can I deal with this issue?

I have found that the Login Destination module seems to be able to solve my problems, but I would prefer not to add more modules if it is unnecessary (I have enough things to debug now).

# Answer
> 1 votes
Would something like the following work?

```
{ "rules_after_login_redirect_to_page" : {
    "LABEL" : "After login redirect to page.",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "0",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "user_login" ],
    "IF" : [
      { "NOT text_matches" : {
          "text" : [ "site:current-page:path" ],
          "match" : "^user\/reset\/",
          "operation" : "regex"
        }
      }
    ],
    "DO" : [ { "redirect" : { "url" : "your_page_url" } } ]
  }
}

```

# Answer
> 1 votes
Use the `$account` object's `access` property to check if the user has logged in before, in `hook_user_login`.

```
function MODULE_user_login(&$edit, $account) {
  if ($account->access == 0) {
    // Account never accessed
  }
  elseif (arg(0) == 'user' && arg(1) == 'reset') {
    // User on password reset page
  }
  else {
    // User has logged in before.
    drupal_goto('<redirection/path>');
  }
}

```

# Answer
> 1 votes
`drupal_goto()` in general is not the good way to go in form handling because it stops all hook execution after it , and you may dont want that to happen...

The drupal way is to fully control your login form(s) and their submit handlers.You just have to add your own submit handler to the form

```
<?php
/**
 * Implements hook_form_alter().
 */
function MODULE_form_alter(&$form, &$form_state, $form_id) {
  // Take care the login block also
  $forms_to_alter = array(
    'user_login', 'user_login_block',
  );
  // Add your own submit handler to the default ones
  if (in_array($form_id, $forms_to_alter)) {
    $form['#submit'][] = '_my_login_submit';
  }
}

```

And then all you need is to change the $form\_state\['redirect'\] in there like:

```
function _my_login_submit($form, &$form_state) {
  $form_state['redirect'] = 'your_other-path';
}

```

---
Tags: users
---


title: Change drupal search result count

text:
# Question
Title: Change drupal search result count
Drupal search is giving 10 items per page. The number is hard coded in search core module. Is there any way to make it 15?. I am using drupal 6.

# Answer
> 1 votes
The search configuration module (version 7.x-1.1-beta1 or above) allows you to do that, among other things.

---
Tags: 7, theming, hooks, search, paging
---


# Question
Title: Drupal 7 with Media: YouTube only embeds static image
Using Media (7.x-1.3) and Media: Youtube (7.x-2.0-rc2) to embed a simple YouTube video on a page using the Media Browser in WYSIWYG. I go to the "Web" tab in the browser, pasted the YouTube URL, and choose the "Default" option.

What gets put into the content is a static image. What I'm expecting is an embedded video. Even a static image that uses the built-in lightbox capabilities would be fine.

Here's what I've already checked:

* I was getting Lightbox2 errors in admin/config/media/file-types/manage/video/file-display. Removed Lightbox2 module.
* Went to admin/config/media/file-types/manage/video/file-display and confirmed that **YouTube Video** and **YouTube Preview Image** were selected for the "Default" option.
* Went to admin/config/content/formats/full\_html and ensured *Convert Media tags to markup* was enabled. I also moved it to the top of the order.
* Checked permissions for *View media* in admin/people/permissions

Suggestions are greatly appreciated.

# Answer
> 2 votes
Media 7.x-1.x only embeds images via WYSIWYG. I would always recommend media 7.x-2.x for anyone unless you have a strict security policy of only using full releases. 2.x has many great new features.

With Media 7.x-2.x:

The media module currently only has support for embedding images via WYSIWYG.

What version of media are you using? If you use media 7.x-2.x you can get it to work by using this sandbox module - http://drupal.org/sandbox/DevinCarlson/1823634 (note that you also need separate http://drupal.org/project/issues/file\_entity module with 2.x because it has now been split out of media - it was part of media in 7.x-1.x)

That sandbox module allows configuring which view modes are used for different file types when embedding via WYSIWYG.

There is a related issue for the media module here http://drupal.org/node/1792738 \- It has been decided in that issue that the sandbox module will be integrated into the media module. So you can safely use the sandbox knowing that the functionality will eventually be in the media module, at which point you won't need to rely on a sandbox project.

When using that setup of modules I find that in a lot of cases it is also good to use http://drupal.org/project/entity\_view\_mode \- which allows you to create new view modes (the file\_entity 7.x-2.x module doesn't provide many view modes out of the box).

---
Tags: media
---


# Question
Title: Views: Page by view-group where multiple results are loaded under each group from a relationship
I have a view displaying data as follows:

**Course name 1**

* Course instance a
* Course instance b

**Course name 2**

* Course instance a
* Course instance b
* Course instance c
* Course instance d

**Course name 3**

* Course instance a
* Course instance b
* Course instance c
* Course instance d

The view is grouped by **Course name**, and there's a relationship with the course instance table to bring in the course's course instance.

The pager is set to 10, but the list displays 10 course instances. How can I get it to display 10 Course names, with all of their instances underneath.

# Answer
> 0 votes
One possible solution would be to use the Views Field View module.

You can make a view that displays course instances as an unordered list, with a contextual filter that is the parent course nid.

Then create a view of courses, limited to 10, and add a view field to the view, using the first view you made. You can pass in the course nid as the contextual filter, so that field just displays the result of the first view for that particular course.

---
Tags: views
---


# Question
Title: What is the name of the module that gives a detailed report of modules and themes installed?
There is a module that gives a very detailed view of all the modules and themes installed on a site and the core modules as well. I can't remember the name, but I know it exists because I installed it for testing purposes some time ago.

Can anyone remember the name, or tell me about some other modules which do the same thing so I can check if it is the one?

# Answer
> 0 votes
The module in question is the Views System module.

It provides a very detailed view of all the modules and themes on your system. It was actually installed on one of my systems.

The name makes it sound as though it is a Views enhancing module rather than the fact that it relies uses Views to generate its output.

System View may be the better name.

# Answer
> 1 votes
It sounds like you are talking about the Module summary module for D7. The Used modules for D6 is no longer supported.

---
Tags: 7
---


# Question
Title: View To Show Tagged Comments Via Arguments
Hello i like how you can add taxonomy to comments now in D7. Im having a few problems though creating a View that will take a tid contextual filter and show the comments in the taxonomy page as a block. Has anyone managed to achieve this?

Thanks

# Answer
> 0 votes
Add Relationships Field: newtag (whatever your term referance field is called)

Contextual filters (term from field\_newtag) (add relationship from above)

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


title: attachment views and pager

text:
# Question
Title: attachment views and pager
I have created a overriden taxonomy term page using views, page displays and attachment displays. A term landing page looks kind of like this:

* 3 articles showing image as a list (page display)
* 3 articles without showing image as a list (first attachment display)
* 6 articles in 2 column table (second attachment display)

I would like to somehow enable paging on this thing. Ideally the pager would sit on the bottom of the last attachment. When a user goes to page 2 (assuming a page size of 12), the first (page display) view would show articles 13 to 16, the first attachment from 17 to 19 and so on.

Is this possible?

# Answer
> 1 votes
If you're using Views 3:

While I don't know how to exactly do what you want purely with Views (or even if it's possible), I can suggest you a module called Display Suite which can work with Views. You can define different display modes for nodes first, and then go to Views and choose "Node Display" type of output, and define in the settings which article should be displayed with which display, for example First 3 nodes in the list should use "Teaser with Image" display, next 3 would use "Teaser without Image" display, and then the next 6 would use a normal "Teaser" display. Then you can use CSS to define the columns for the last 6. Doing it this way you eliminate having the need to use Attachments, so all your results come from 1 display. Pagers then should work normally. I cannot guarantee you this will work 100% as I haven't used this module by myself, but I've seen a colleague implement something like this before, and he also had problems with using Pagers. I'm not sure if this functionality is compatible with Views 2 as it's been a long time since I used Views 2. Good luck.

# Answer
> 0 votes
I've had success doing this with core taxonomy alone using a custom `node-article-taxonomy.tpl.php` template. That template has a var `$id` available which corresponds to the delta of a given node per page. So you can do something like this in that template:

```
<?php if ($id < 4) : ?>
  <?php // print your 3 articles showing image as a list ?>
<?php elseif (($id > 3) && ($id < 7)) : ?>
  <?php // print your 3 articles without showing image as a list ?>
<?php else : ?>
  <?php // print your 6 articles in 2 column table ?>
<?php endif; ?>

```

You'll have to manually print each of the fields or create new contexts/view modes for each of the three scenarios.

You'll also need to configure the "Number of posts on front page" variable (set on the Site Information page) to 12 as this dictates how many posts are shown on taxonomy pages too. By default, the form only allows you to set that value to 1-10, 15, 20, 25, 30 - so you'll have to use a `hook_form_alter()` or manually set that variable.

Terms with more than 12 nodes will automatically display the pager and page 2 will display nodes 13-24 using this method.

Note: These instructions are for Drupal 6. The template name might have changed slightly in D7.

---
Tags: 7, views, paging
---


title: Appointment Scheduling

text:
# Question
Title: Appointment Scheduling
I am looking to create an apointment scheduling system on drupal 7.x, however all of the modules and instructions that I can find are for 6.x. The system is fairly simple, and only needs to be able to have users schedule appointments for certain blocks of time.

How would I go about doing this in 7.x? Are there any modules that I can use, or is there some way to "hack" this out?

# Answer
> 2 votes
We use the signup module for this - we actually used it for tax appointments this year. Yes, it's 7 version is in development but I don't see it being very much different from the 6.x version.

It enables you to attach "slots" to nodes and have people sign up for them. They can be timed or untimed. As the 7.x version is a straight port from the 6.x version, all the tutorials should be the same.

# Answer
> 0 votes
This looks like what you are looking for: module Click to Schedule.

Here is a quote about it (from the module's project page):

> ... a new, proven way to convert website visitors into booked appointments or meetings for you and your team using online appointment scheduling.
>
> It enhances your Drupal website by providing your visitors with a hassle-free way to schedule time with people in your organization simply by clicking a button. No back-and-forth emails or phone calls and no manual follow-up required.
>
> Meetings are automatically confirmed, added to your Outlook, Google Calendar, or iCal and confirmation emails are sent to both parties. You never have to say, “Let me check my schedule” again. You’ll spend less time with the hassle of booking appointments and more time focusing on your business.
>
> When you install the Click-to-Schedule module, you automatically get these features right out of the box:
>
> * A free TimeTrade account
> * Sync capabilities for Outlook, Google calendar or iCal for Mac
> * A click-to-schedule button in the size and color that you choose
> * Appointments and meetings from your website on the calendars of up to 3 of your team members
> * Full control over the times web visitors have to choose from. Just because a time is free on your calendar doesn’t mean it’s available to the public if you don’t want it to be.

---
Tags: 7, datetime
---


title: Drush sql-sync not working on multisite

text:
# Question
Title: Drush sql-sync not working on multisite
I use drush site aliases and `drush sql-sync` as part of my daily workflow between my local development environment and my company's production/staging servers (Acquia dev cloud). This works great for single site instances, but I haven't been able to get it to work with multisites.

Example site structure for my @remote alias:

```
@remote
  - default.com ``drush @remote`` <-- commands not targeted with `-l` execute here
  - sitename.com ``drush @remote -l sitename.com status``
  - foobar.com ``drush @remote -l foobar.com sql-connect``

```

For other drush commands, I can target the multisite that I want use the `-l` switch to specify a particular multisite, and I get the correct output for `drush status` and `drush sql-connect` (correct `URI` and `Database name`).

However, when I try to use `-l` with drush sql-sync, it just targets the root site, no matter what. I can get around this by manually dumping the database and doing `drush sql-cli @remote -l multisite.com < db.sql`, but it's not half as quick as just doing `drush sql-sync @local -l sitename.com @drush.remote -l sitename.com`

I can open up a drush issue queue if this is a bug, but I'm wanted to check and see if I was doing something wrong first. Thanks!

# Answer
> 5 votes
It is true that mixing @alias and -l together does happen to work in the local case, but is not supported in sql-sync. If this did work, you would need to use --target-uri and --source-uri to distinguish the two different -l/--uri options, but this has never been implemented. Drush always uses the source and target alias records, and nothing else, to determine how to look up the source and target database records.

As Clive says, the best thing to do it so set up separate aliases for each site. If you put all of your aliases in a single file, they will automatically create an alias group.

For example, I do something like this:

**sitename.aliases.drushrc.php:**

```
<?php

$aliases['live'] = array (
  'parent' => '@server.urpad',
  'root' => '/srv/www/sitename/htdocs',
  'uri' => 'http://sitename.com',
}

$aliases['dev'] = array (
  'root' => '/srv/www/sitename/htdocs',
  'uri' => 'http://sitename.com',
}

```

**server.aliases.drushrc.php:**

```
<?php

$aliases['urpad'] = array (
  'remote-host' => 'my.remote-server.org',
  'remote-user' => 'www-admin',
}

```

Using a 'server' alias file allows me to easily specify where I want to put each remote site without having to duplicate the remote host information.

Then, to use it:

```
drush sql-sync @sitename.live @sitename.dev

```

---
Tags: drush, multi-sites
---


# Question
Title: I need to reference a custom field I created in User Profile
I used Drupal 7 computed fields to calculate weight loss. This is what I current have. Which works in a sense but only where the user inputs their initial weight and subtracts their current weight to track the total weight loss at the time of the input. But I need it to reference their initial weight from their user profile so that they only have to enter their current weight. One step process versus having to always enter the data that already exists. How can I achieve this?

Current Code which works great but two fields have to be filled in. Needs to reference field in user profile.

```
$entity_field[0]['value'] = ($entity->field_iweight['und'][0]['value']) - ($entity->field_current_weight_['und'][0]['value']);

```

# Answer
Use the `$user` object to access the logged in user.

```
 global $user;
 $account = user_load($user->uid);

```

Now you can use `$account->field_iweight['und'][0]['value']` (just an example) to access the weight or any other field from the user profile.

Updated code:

```
<?php
global $user;
$account = user_load($user->uid);
$entity_field[0]['value'] = $account->field_iweight['und'][0]['value'] - $entity->field_current_weight['und'][0]['value'];
?>

```
> 0 votes

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