# Question
Title: Commerce Coupons, Discounts, and Tax not appearing on Checkout Review page
So I'm able to apply coupons on the Checkout page. Quantity-based discounts also appear on the Checkout page. As does basic state-based Sales tax. But, when you continue from there, you select a shipping service, and then continue to Checkout review. At this point, the coupon is gone, as are the discounts and tax.

The coupon entered still appears in the form, but the Granted Amount is now $0.00.

I'm losing my mind on this one because I'm dealing with a site that is (was) 95% complete when this started happening. I must have introduced something stupid along the way.

# Answer
Solved! Rules was the culprit. By rolling back to the previous stable version, all of the problems with checkout disappeared. Everything applies correctly to the Checkout Page, and is still there when I get to Checkout Review.

Just to be clear, I replaced the current stable version of Rules (7.x-2.8) from January 2015 with the previous stable version (7.x-2.7) from May 2014.
> 1 votes

---
Tags: commerce
---


# Question
Title: Why does Drupal need list (integer, float AND text) and what is the difference?
Could somebody explain why Drupal needs list (integer), list (float) AND list (text). What is the difference?

Values are set in key | value pairs. So:

* list integer - saves key in database in integer format
* list float - saves key in database in float format
* list text - save key in database in varchar format

Why do we need list (float) and list (text), if we have list(integer)?

An explanation with examples would be great.

# Answer
> 1 votes
Occasionally you want to access a dropdown with Jquery - in this case it can be useful to have keys which are more than just integers.

Nothing I ever did, but you could use a dropdown to apply different classes to an element:

```
style-red|Red Layout
style-blue|Blue Layout

```

The value is the human readable label and the key is the class to switch around with jQuery. If you had used '1|Red Layout' and '2|Blue Layout' you need to tell JQuery that is has to translate key 1 into class style-red and key 2 into style-blue before applying them. So whenever you would add a new key|value pair you would not only need to edit your css but also your jQuery code, while using text keys you only need to edit the css file.

It is not a real world example, but you get the point.

For the float it is similar. Imagine you have a list with prices each with a human readable label plus a float you can instantly use for calculation in jQuery.

# Answer
> 0 votes
Why would you want to store non-integer data as an integer?

Why make your data hard to understand by assigning arbitrary integer values to everything if you can instead use descriptive values that can immediately be understood?

Basically, if your data is a string then store it as a string. The same goes for other data types.

Obfuscating your data by changing the data type for no reason is bad software/data-structure design and will make it harder for anyone that has to work on your system in future (including yourself).

---
Tags: entities
---


# Question
Title: How to create a special autoincrement field?
I have a "Property" content type created for a real estate web site. The Property content type has a taxonomy field called "Type" where type can be House, Office, Apartment and so on...

I want to create a "code" field that has to be something like "H-1" where H is for Home and 1 must be an incremental number, so houses will have each a different code: "H-1", "H-2", "H-3" ... "H-188", etc. And so on for Offices "O-1", "O-2"..."O-479". I see that there is a Serial module, but that module helps me only creating autoincremental numbers for each content type, not based on other fields of that content type.

I was planning to use auto\_nodetitle \+ serial module \+ rules to create the letter+number format for my field, but I will have the same problem: If I create "H-1" and then create an Office, it will have "O-2" code, and not "O-1" code.

Is there a module than can help me? If not, how can I make it?

# Answer
The obvious option would be to have a serial field for each type. Whether or not that is feasible based on your business rules (are there lots of types, are the types likely to change, etc.) is another question.

Another module that may be very useful in these types of problems is the computed field module.

Another option (probably the one I would choose) is to make it completely custom. Either a custom entity property or a custom field of some sort that does database queries to determine the next value instead of auto\_nodetitle + serial module + rules.
Be careful of race conditions when doing something like this though.
> 2 votes

# Answer
Just thinking out loud.

In rules (after saving content), set data value of the field. To set the field (direct input), use php code that counts all nodes of that particular type with 'Type" as house for example and echo H-(count+1).
> 0 votes

# Answer
The comments were turning into a discussion, so here's some code that will retrieve the 'latest' node and retrive the code ($code) for that node.

```
    <?
$terms = taxonomy_get_term_by_name($home);
$tid = $terms[0]->tid;
$query = new EntityFieldQuery();
$query
  ->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'your_content_type')
  ->fieldCondition('term_fieldname', 'tid', $tid)
  ->propertyCondition('status', 1)
  ->propertyOrderBy('created', 'DESC');
$result = $query->execute();
$nid = array_keys($result['node']);
$picked_node = $nid['0'];
$node = node_load($picked_node);
$wrapper = entity_metadata_wrapper('node', $node);
$current_code = $wrapper->field_code->value();
$new_code += $current_code;
$field_to_set = "H-$new_code";
?>

```

Here I'm assuming that you are going with the idea of having an extra integer field. This is pretty rough and untested so try it out on a simple page with php input format. echo the vars to see what you get...
> 0 votes

---
Tags: 7, entities, rules, nodes
---


# Question
Title: How to edit module file to make layout changes?
I have installed module **Security Questions** to allow users to answer security question while retrieving the password.

It works fine. But I'm facing layout issue with it.

How can I edit this module so that I can add a container div which will contain the fields related to security questions?

I tried to edit **security\_questions.pages.inc** file but I'm unable to understand how to make changes in it.

This is the present HTML code:

```
<div id="edit-account" class="form-wrapper"> <!-- Main wrapper div -->
<div id="user_register_form"> <!-- User registration div-->
    <h1>Register</h1>
    <div class="form-item form-type-textfield form-item-name">
        <label for="edit-name">Username <span class="form-required" title="This field is required.">*</span></label>
        <input class="username form-text required" id="edit-name" name="name" value="" size="60" maxlength="60" type="text">
        <div class="description">Spaces are allowed; punctuation is not allowed except for periods, hyphens, apostrophes, and underscores.</div>
    </div>
    <div class="form-item form-type-textfield form-item-mail">
        <label for="edit-mail">E-mail address <span class="form-required" title="This field is required.">*</span></label>
        <input id="edit-mail" name="mail" value="" size="60" maxlength="254" class="form-text required" type="text">
        <div class="description">A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.</div>
    </div>
    <div class="form-item form-type-password-confirm form-item-pass">
        <div class="form-item form-type-password form-item-pass-pass1 password-parent">
            <div class="password-strength">
                <div class="password-strength-text" aria-live="assertive"></div>
                <div class="password-strength-title">Password strength:</div>
                <div class="password-indicator"><div class="indicator"></div></div>
            </div>
            <label for="edit-pass-pass1">Password <span class="form-required" title="This field is required.">*</span></label>
            <input class="password-field form-text required password-processed" id="edit-pass-pass1" name="pass[pass1]" size="25" maxlength="128" type="password">
        </div>
        <div class="form-item form-type-password form-item-pass-pass2 confirm-parent">
            <div class="password-confirm">Passwords match: <span></span></div>
            <label for="edit-pass-pass2">Confirm password <span class="form-required" title="This field is required.">*</span></label>
            <input class="password-confirm form-text required" id="edit-pass-pass2" name="pass[pass2]" size="25" maxlength="128" type="password">
        </div>
        <div style="display: none;" class="password-suggestions description"></div>

        <div class="description">Provide a password for the new account in both fields.</div>
    </div>
</div> <!-- User registration div closed-->

<input name="form_build_id" value="form-CRUX64b0qE0buRS7NH8HQmW5Kc7ss4kVotSDcrN5BGk" type="hidden">
<input name="form_id" value="user_register_form" type="hidden">

<!-- These fields are dynamically added as per the settings for the module configuration -->
<!-- I want these fields to be contained in a single div -->
<div class="form-item form-type-select form-item-questions-0-question">
    <label for="edit-questions-0-question">Security question <span class="form-required" title="This field is required.">*</span></label>
    <select id="edit-questions-0-question" name="questions[0][question]" class="form-select required">
        <option value="" selected="selected">- Select -</option>
        <option value="2">xxxxxxxxxx?</option>
        <option value="4">yyyyyyyyyy?</option>
    </select>
</div>

<div class="form-item form-type-textfield form-item-questions-0-answer">
    <label for="edit-questions-0-answer">Answer <span class="form-required" title="This field is required.">*</span></label>
    <input id="edit-questions-0-answer" name="questions[0][answer]" value="" size="60" maxlength="128" class="form-text required" type="text">
</div>

<div class="form-item form-type-select form-item-questions-1-question">
    <label for="edit-questions-1-question">Security question <span class="form-required" title="This field is required.">*</span></label>
    <select id="edit-questions-1-question" name="questions[1][question]" class="form-select required">
        <option value="" selected="selected">- Select -</option>
        <option value="2">xxxxxxxxxx?</option>
        <option value="4">yyyyyyyyyy?</option>
    </select>
</div>

<div class="form-item form-type-textfield form-item-questions-1-answer">
    <label for="edit-questions-1-answer">Answer <span class="form-required" title="This field is required.">*</span></label>
    <input id="edit-questions-1-answer" name="questions[1][answer]" value="" size="60" maxlength="128" class="form-text required" type="text">
</div>

<div class="form-actions form-wrapper" id="edit-actions">
    <input id="edit-submit" name="op" value="Create new account" class="form-submit" type="submit">
    <div class="back-to-login clearfix"><a href="/en/user/login" class="login-account" title="Sign in">Back to login</a></div>
</div>
<!-- I want to close the container here -->

```

# Answer
> 0 votes
Just added these lines to the function in **security\_questions.pages.inc** and it worked.

```
$form['#prefix'] = '<div class="security_questions_container">';
$form['#suffix'] = '</div>';

```

---
Tags: 7, commerce, security
---


# Question
Title: Is there a module or configuration that logs PHP mail errors?
On shared hosting. We're having strange mail problems... mails do not get sent to various domains or are delayed. It seems to happen more in Webforms than in Notify\_message actions in Rules.

Is there a way to log the PHP mail() error messages without hacking the MimeMail module? The Drupal log only shows that there was an error... nothing more specific.

# Answer
Have a look at maillog and Mail Logger. They both log all mail activity handled via drupal\_mail. See what they have to offer as far as mail errors go.
> 0 votes

---
Tags: 7, emails
---


# Question
Title: How to use Drupal Commerce to extract all the people who purchased a specific product?
I want to create a report (a list) of all the people who purchased a specific product.

I want to use this list for a report to verify purchase when people pickup registration packs etc., so that I can confirm those people when they arrive.

How do I get this in a report format that I can extract from Drupal Commerce?

# Answer
Not 100% sure what you mean with "reports on line items" or "a line item report" (consider refining what actually this means). But since the question is tagged with the tag, maybe you may want to consider the Forena module.

It would probably take a bit of time to achieve perfection, but you'd have all of Forena's xHTML-power available to finetune the ultimate result (report), for things such as:

* look-and-feel (styling/theming).
* maybe add some charts to it also (using selected data about commerce).
* saving the ultimate output (report) in formats such as PDF, DOC, etc.
* creating eMail campaigns about selected records.
* pulling in information stored in other databases related to this report.

For more details about Forena, 2 types of documentation are available:

* Community documentation.
* Documentation that comes with Forena, which you can access right after install and enable of the module. Checkout the demo site for an online example of the current:

+ **Forena documentation** \- use the link 'Reporting documentation' or visit relative link /reports/help.
    + **Forena samples** \- use the link 'Reporting samples' or visit relative link /reports/samples (these samples are fully functional, so make sure to experiment a bit with it, such as the drill downs available on the SVG Graph sample).

The newest 7.x-4.x version also includes an amazing (I think) UI for either creating your reports (the WYSIWYG report editor) and/or for creating your SQL queries (the Query Builder).

Here is some more info about the **other databases** in mentioned above:

1. Using a **SQLite** instead of MySQL database: the Forena samples actually get shipped including a (Tiny) SQLite database. Go check it out in the demo site: the data shown there are data contained in the sampledb, which is in SQLite format.
2. Forena comes with a full suite of Supported database connections ... such as MySQL, MS SQL, Oracle, Postgress or any PDO compliant variation.

Enough reasons for considering giving Forena a try? While doing so, use it's issue queue for any type of support/docu requests you may have.

**Be aware**: I'm a co-maintainer of Forena.
> 1 votes

# Answer
Because of the comments in my previous reply (which I believe is still an option to consider), I'd assume that using Commerce Reports should help a lot for creating that list.

Let's hope Matt (maintainer of it) will step in soon to find the (maybe out-of-the-box?) answer ... It'd be interesting to hear from him also to what extend my forena-alternative might make sense also (even if it was only to enhance Commeerce reporting with all sorts of Forena-features ...).
> 1 votes

---
Tags: commerce, log-messages
---


# Question
Title: Use Views field output as a class? Tokens?
I have a field in my view which displays the taxonomy vocabulary that each result/node is linked to. However, I need a way to get that taxonomy vocabulary result and use it as a class for the view row - not just the field.

Has anyone had any success with something like this before? Options I can think of might be Tokens, direct template theming, or Display Suite, but I don't know how I would go about fetching that vocabulary field output and using it as the row's class.

Any help would be received gratefully :)

# Answer
You can achieve this by passing replacement token to row class as shown in figure below:

**Update #1**

Install Views PHP & add Global: PHP field in view, then enter following values in PHP field

Value code =\> `return strtolower(str_replace(' ', '-', $row->title));`

Output Value =\> `<?php echo $value; ?>`

Replace \[title\] with \[php\] in Row class. Check image below for reference.
> 0 votes

# Answer
If you're looking to use it as a class for the whole row rather than just for the field, use a views template.

The Advanced -\> OTHER -\> Theme: Information section of your view usually has good ideas on what to call files but it doesn't seem to include anything for the row.

If you're using row style: fields... try making a template file called `views-view-fields--myviewname.tpl.php`.

To dig into the variables available to that template file, the first thing you want to do is install the Devel module, turn it on, and put this in the template:

```
dpm($content);

```

or maybe

```
dpm($output);

```

dpm() prints the named variable on the screen when the file is run.
> 0 votes

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


# Question
Title: Drush destination command not recognising
I'm able to see the destinations by using the 'bam-destinations' command and below is my script to get an entire site backup from a ftp destination (ID of this destination is 'ftp\_destination' and I have entered ftp details through BAM module frontend).

```
drush archive-dump default http://www.example.com/ --destination=ftp_destination

```

For some reason it's not uploading in to the ftp location but just creates a backup called 'ftp\_destination' in my local PC.

Thanks

# Answer
> 0 votes
Check out the drush documentation here.
There's no mention of ftp, the backup archive is saved locally. If you want to ftp your archive somewhere you will have to handle it separately, archive-dump will not do it for you.

---
Tags: drush, backups
---


# Question
Title: How to update failed transaction detail in drupal commerce
I am using `drupal commerce` to built a e-commerce site .

My problem is when a transaction is failed or get a late response then the transaction is not created.

Can i create it manually or i have to ? if yes then how?

Or is their any other way to attach my transaction detail to `order` .

Any help most appriciate. Thank you.

# Answer
> 0 votes
You need to load the failed transaction from order id as shown below:

```
<?php
  $query = new EntityFieldQuery;
  $result = $query
    ->entityCondition('entity_type', 'commerce_payment_transaction')
    ->propertyCondition('order_id', $order->order_id)
    ->propertyOrderBy('transaction_id', 'DESC')
    ->range(0, 1)
    ->execute();
?>

```

Then load transaction using `commerce_payment_transaction_load($transaction_id)` & update transaction object as shown below:

```
<?php
//Use following line instead of loading transaction in order to create new transaction object
//$transaction = commerce_payment_transaction_new('commerce_payment_example', $order->order_id);
$transaction = commerce_payment_transaction_load($transaction_id);
$transaction->amount = $charge['amount'];
$transaction->currency_code = $charge['currency_code'];
$transaction->status = COMMERCE_PAYMENT_STATUS_SUCCESS;
commerce_payment_transaction_save($transaction);
?>

```

You can set a cron to periodically check failed transaction & check status of same at Payment Gateway & update accordingly.

---
Tags: commerce
---


title: Taxonomy term based content

text:
# Question
Title: Taxonomy term based content
how do I get taxonomy based node content through custom query? I have taxonomy terms displayed using **drupal api function**. Now I need to fetch content based on terms id or name from **database**? Can any one please help me.Either using entity field query or SQL?

```
$tree=taxonomy_get_children(1);
 foreach ($tree as $term)
 {
 $item[] = $term->name;
 $child_term = taxonomy_get_children($term->tid);
 if (!empty($child_term))
 {
 <a href="?name=<?php print $term->tid; ?>">
 <?php
 print $term->name."<br>";
 ?>
 </a>
 foreach ($child_term as $child)
 {
 $item[] = $child->name;
 <a href="?tid=<?php print $child->tid; ?>" name="tid">
 <?php
 print $child->name."<br>";
 ?>
 </a>
 <?php
 $nodes = taxonomy_select_nodes($child->tid);
 $node = node_load_multiple($nodes);
 $nidd=(int)$node->nid;
 foreach($node as $node1):
 $tids = field_get_items('node', $node1, 'field_product_sub_cat');
 foreach ($tids as $tid){
 if($tid['tid'] == $child->tid){
 print $node1->title;
 print render(field_view_field('node', $node1, 'body'));
 }
 }
 endforeach;
 else
 print $term->name."<br>";

```

# Answer
> 1 votes
You can get nodes as shown below:

```
$nodes = taxonomy_select_nodes($tid); // $tid is term id
$nodes = node_load_multiple($nodes);

```

Ref: `taxonomy_select_nodes` -\> https://api.drupal.org/api/drupal/modules!taxonomy!taxonomy.module/function/taxonomy\_select\_nodes/7

**Update #1**

To get some fields out of $node object use following:

```
foreach($nodes as $node):
    $tids = field_get_items('node', $node, '<TERM_FIELD_NAME>');
    foreach ($tids as $tid){
        if($tid['tid'] == <SELECTED_TID>){
            print $node->title;
            print render(field_view_field('node', $node, 'body'));
            print render(field_view_field('node', $node, 'tags'));
        }
    }
endforeach;

```

To render complete node you can use `node_view` function. In order to render multiple nodes you can use `node_view_multiple` function as shown below:

```
$content = node_view_multiple($nodes, 'full');
print render($content);

```

---
Tags: taxonomy-terms
---


# Question
Title: How is a variable passed to theme_hook (theme_item_list, FacetAPI)
**Problem**

I'm trying to register a new theme function based off `theme_item_list` to alter the display of a facet.

`Theme_item_list` is passed in an array `$variables`. Crucially I can't work out how the facetAPI passes the variables needed for `theme_item_list` to render a list. It sets up the array in the `execute` method of `FacetapiWidgetLinks` and somehow successfully passes this to `theme_item_list` but I can't get my own theme function to receive anything.

How does `theme_item_list` receive it's `$variables` array?

**More Information**

*Code altered thanks to kiamlaluno*

I currently have the following code in my module:

```
function my_module_theme($variables) {
  return array(
    'item_list_aggregate' => array('variables' => array(
      'items' => array(),
      'attributes' => array(),
      'title' => NULL,
      'type' => 'ul',
  )));
}

//this is correctly called but $variables is empty
function theme_item_list_aggregate($variables) {
  $items = $variables['items'];
  $title = $variables['title'];
  $type = $variables['type'];
  $attributes = $variables['attributes'];
  ...

```

`#items` and `#attributes` values are set in the `execute` method below.

They are correctly passed to `theme_item_list` because I can't get them to pass to my theme function, `theme_item_list_aggregate`, the `$variables` variable in `my_module_theme` is empty.

```
class FacetapiWidgetLinks extends FacetapiWidget {

...

public function execute() {
    $element = &$this->build[$this->facet['field alias']];
    $this->setThemeHooks($element);

    // Here I call my own theme function. It's identical
    // to theme_item_list at the moment but my own theme function
    // never gets passed the $element array.
    if(strpos($this->facet['field alias'],"aggregation") != FALSE) {
      $element = array(
        '#theme' => 'item_list_aggregate',
        '#items' => $this->buildListItems($element),
        '#attributes' => $this->build['#attributes'],
      );
    } else {
      $element = array(
        '#theme' => 'item_list',
        '#items' => $this->buildListItems($element),
        '#attributes' => $this->build['#attributes'],
      );
    }
  }

...

```

# Answer
> 1 votes
It is not necessary to create a new theme function. You could use the existing theme\_item\_list and extend it with double underscore. Rename `item_list_aggregate` to `item_list__aggregate` in `FacetapiWidgetLinks::execute`. And implement `theme_item_list` and theme\_item\_list\__aggregate in your theme.

Look at `node_title_list` in core, this function uses the same pattern.

# Answer
> 0 votes
The `hook_theme()` implementation is wrong: The first argument passed to the hook is not the list of the variables to pass to the theme function. Your hook should be implemented with code similar to the following one.

```
function my_module_theme($variables) {
  return array(
    'item_list_aggregate' => array('variables' => array(
      'items' => 'default value for the variable',
      'title' => 'default value for the variable',
      'type' => 'default value for the variable',
      'attibutes' => 'default value for the variable',
  )));
}

```

For a list of parameters passed to `hook_theme()` see `hook_theme()`. Keep in mind that most `hook_theme()` implementation don't use them.

---
Tags: search, theming
---


# Question
Title: How to redirect into a specific page variant
I installed panels, page manager, ctools and page manager redirect.

I made a (panel) page say foo1 \- admin/structure/pages/add with variant type Panel. In this I put 5 variants named foo1variant1, foo1variant2, foo1variant3, foo1variant4, foo1variant5,

I also setup a page manager redirect say foo2: \- admin/structure/pages/add with variant type redirect. In the end I should give the url it should go to foo1 en into foo1variant3, .

How to do this?

# Answer
> 0 votes
Variants on the same Page always have the same URL. The variant that is shown is determined by the selection criteria.

If the selection criteria for Variant 1 fails, it moves on to Variant 2.

If the selection criteria for Variant 2 also fails, then it will try to show Variant 3.

The only exception to the 'same URL' rule is if you have optional Arguments (that start with `!` instead of `%`) in which case you can have a url of `foo` and `foo/bar` handled by the same page.

---
Tags: panels, redirection, chaos-tool-suite
---


# Question
Title: Drupal 7 pager from module fuction not displaying in page.tpl
I have a function *mymodule\_submissions* in my module which fetches rows from mymodule\_table and prints as table theme with pager. Its working fine if I define a menu link in my module to call that function. Pager not printing when I call the same function from a page.tpl.

```
function mymodule_submissions() {

   $query = db_select('mymodule_table', 'uf');
   $query = $query->condition('uid', $user->uid)
             ->fields('mytable', array('id', 'name', 'createdtime'))
             ->orderBy('createdtime', 'DESC')->limit(3);
   $results = $query->execute();
   $header = array('ID','Name','Created Time');

   $rows = array();

   foreach($results As $result) {
      $rows[] = array( $result -> id, $result -> name, $result -> createdtime,);
   }

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

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

```

From page.tpl, I am calling this function link below

```
print render(mymodule_submissions());

```

Anything I'm doing wrong?

# Answer
You just need to add `->extend('PagerDefault');`

```
$query = db_select('mymodule_table', 'uf')->extend('PagerDefault');

```

I find the examples module really useful. They have a pager example.

For what its worth I think using the Drupal db API with theming is a perfectly valid way forward that has a lot of strengths: it's efficient, flexible, powerful and you can put it in version control. Obviously you should use the best thing for the situation.
> 0 votes

---
Tags: theming, 7, paging
---


# Question
Title: How to avoid rendering of same node in two different view blocks on same page ?
One of my page shows two different view blocks. Suppose View-block-1 and view-block-2. Both renders and display nodes from same content type, say products. Node display Limit is set to 1 in both view and ordered by random.

**Products:**

Product 1

Product 2

**Case 1**

View-block-1 | View-block-2

Product 1 | Product 2

**Case 2**

View-block-1 | View-block-2

Product 1 | Product 1

Problem is that (case 2) sometimes both block shows same node since ordering is set to random.

Is there any way to ensure that both view do not show same node ?

# Answer
Install Views exclude previous module.Then your views filter criteria will have a option like this

Views: Views Exclude Previous (\<\> Exclude nodes that where loaded in any node based view.)

This will restrict the same content to be displayed in page more than one time.

Hope this answers your question.
> 1 votes

---
Tags: 7, views
---


title: Unable to override theme function

text:
# Question
Title: Unable to override theme function
I am trying to override the 'link\_field' theme function in the Link module. I've put this function in my template.php of my active theme and have cleared the cache, but its not overriding. What am I doing wrong?

```
 function tma_corp_link_field($vars) {
  dpm($vars);
  drupal_add_css(drupal_get_path('module', 'link') . '/link.css');
  $element = $vars['element'];
  // Prefix single value link fields with the name of the field.
  if (empty($element['#field']['multiple'])) {
    if (isset($element['url']) && !isset($element['title'])) {
      $element['url']['#title_display'] = 'invisible';
    }
  }

  $output = '';
  $output .= '<div class="link-field-subrow clearfix">';
  if (isset($element['title'])) {
    $output .= '<div class="link-field-title link-field-column">' .      drupal_render($element['title']) . '</div>';
  }
  $output .= '<div class="link-field-url' . (isset($element['title']) ? ' link-field-column' : '') . '">' . drupal_render($element['url']) . '</div>';
  $output .= '</div>';
  if (!empty($element['attributes']['target'])) {
    $output .= '<div class="link-attributes">' . drupal_render($element['attributes']['target']) . '</div>';
  }
  if (!empty($element['attributes']['title'])) {
   $output .= '<div class="link-attributes">' . drupal_render($element['attributes']['title']) . '</div>';
  }
  if (!empty($element['attributes']['class'])) {
   $output .= '<div class="link-attributes">' . drupal_render($element['attributes']['class']) . '</div>';
  }
  dpm($element);
  return $output;
 }

```

# Answer
> 1 votes
So to help keep your theme files cleaner, the preference is to place theme overrides in a custom module. This allows you to switch themes without having copy, paste, and rename a bunch of code.

Also this may be your only choice if, for example, you're trying to override a theme function that's being called from an admin page, you have an admin theme enabled, and you don't want to bother with creating a subtheme for your admin theme.

The workaround here is to use `hook_theme_registry_alter()`; see this page on Drupal Stack Exchange.

---
Tags: theming
---


title: cannot display new content

text:
# Question
Title: cannot display new content
I am using drupal 7 and i have been having this issue where i am trying to add a new page onto an existing drupal site but all I'm getting is one content (the page title and some body text) displaying.all the content types which include some images that eventually build up the page are published but are not displaying on the final live site even after clearing the cache both on admin/config/development/performance/cache and on phpmyadmin.i have also created a page--mynewpage--tpl.php page for that page.i believe i have done all the url's correctly.while adding the content types, i referenced the previous working pages just to make sure that i was filling all the required fields so as to have some uniformity within the site What could i be missing out on, since i added the link of my new page to the page.tpl.php. I have been trying to get a solution for this for a week now and any assistance form you will be greatly appreciated

# Answer
are you inserting "inline images" into your content type body-field (1) or using an image field at your content type (2)?

1) Inline images are inserted with an tag which is stripped out by the standard text formatter (filtered html). Either use the "full html" formatter or (better) make a new text formatter which includes tags for allowed html tags. Full html is normally below body field at the content edit form. To add a text formatter (or edit filtered html) go to `admin/config/content/formats/filtered_html` and add the tag (including the bracers) into the allowed html tags field.

2) If you are using an image field try to change the image field formatter to "image" and set format settings to a image style like "medium".

Greetings, krueschi
> 0 votes

---
Tags: 7, nodes
---


title: Why can't I add a product?

text:
# Question
Title: Why can't I add a product?
I need to add product via services, but I have strange issue with a price field.

The case is that all fields saved correctly except price field amount and it returns:

> The requested URL returned error: 500 Internal Server Error : An error occurred (0): Unable to get the data property amount as the parent data structure is not set.

The url which is used: `endpoint/product`.

Here is the code:

```
fields `$node_data = array(
  'sku' => 'sku1',
  'title' => 'product title',
  'type' => 'product',
//  'commerce_price_amount' => array('amount' => 122.000, 'currency_code' => 'KWD'),
  'commerce_price_amount' => 12.000,
  'commerce_price_currency_code' => 'KWD'
); 12.000,
  'commerce_price_currency_code' => 'KWD'`

```

which successfully added all fields except price.

I think it relate to price field format.

# Answer
> 0 votes
It works with me after disable some modules related to commerce like payment, order, cart, tax and then clear cache products saved.

I still didn't know the reason for that error

---
Tags: services, commerce
---


# Question
Title: Delete content problem in Multilingual site with module Global redirect
I have a multilingual mini site with 2 pages/nodes with 6 languages enabled. I don't have the translation for some language on some pages. I was hoping global redirect would help me with this by redirecting the user to the default language when the translation doesn't exist. This part only works partially but this is not not my concern for this thread.

At the beginning I added missing translations by putting the English version instead. When I learn the existence of the module Global Redirect I decided to delete those missing translation. I downloaded and activated Gloabl Redirect and started to delete the nodes which had a bad version. But when you do so, it does not delete the node of the language you selected, it deletes the default language node!!

So in other words if I have a node in English (default) and go to Content and select the delete link of the Spanish translation it will delete the English version and keep the Spanish version!! A by-product of this is to change the default language to the next on list...

Is it a know bug? What can I do to fix this other than NOT using Global Redirect? Did I do something wrong?

# Answer
> 0 votes
If not already in use, I recommend using the i18n module instead of global redirect (which is imo more a SEO module) which let set you a fall back for not (yet) translated pages as well. With this module you can also translate menu entries, path-settings, taxonomy terms etc. (even the site name and the site slogan (when using together with the variables module)).

Greetings krueschi

---
Tags: 7
---


# Question
Title: Can Views Bulk Operation be used to re-index specific nodes
Can the Views Bulk Operations module be used to reindex nodes that fulfill some criteria (e.g. nodes of specific type)?

# Answer
> 0 votes
I didn't deal with that for a few time but since I found the answer my self I thought about posting that here in the hope that someone finds it useful. I dug into Views Bulk Operations and into the Search API devel, copied and modified some code.

For this to work we need to create a custom module and put in the module the following:

```
<?php
/**
 * Implements hook_action_info
 */
function MY_MODULE_api_action_info() {
  /**
   * Defines an array of actions to be performed on nodes
   */
  return array(
      'MY_MODULE_api_reindex' => array(
          'type' => 'node',
          'label' => t('Reindex node'),
          'behavior' => array('changes_property'),
          'configurable' => FALSE,
          'vbo_configurable' => FALSE,
          'triggers' => array('any'),
      ),
  );
}

function MY_MODULE_api_reindex(&$node, $context) {
  /**
   * function to implement the action defined above (see the key of the array
   * returned in vbo_search_api_action_info()
   */
  //copied the code from the search_api_devel module
  //load all indexes
  $indexes = search_api_index_load_multiple(FALSE);
  foreach ($indexes as $index) {
      if ($index->enabled) {
        search_api_index_specific_items($index, array($node->nid));
      }
    }
}

```

There might be a better way to go around this problem. For example the code now loads the index for each visited node, whereas `Search API` supports indexing an array of `nids`. So potentially we could gather all nids and then submit to Search API

---
Tags: search, views
---


title: Apache SOLR show only nodes with images

text:
# Question
Title: Apache SOLR show only nodes with images
How can I filter SOLR results to show only nodes with images? There seems to be no support for image fields. I don't mind writing custom field mapping or something like that but some guidelines would be really appreciated.

# Answer
You can override the template file that outputs your SOLR items with a check for a set image field.

This type of check is generally ok to use in a template file:

```
<?php if(isset($item['image'])): ?>
  <?php print render($item); ?>
<?php endif; ?>

```
> 1 votes

# Answer
What if you:

* Create an exposed filter for the image field
* In the configuration select `Filter type to expose: Grouped Filters`
* Set `Widget type: Select`
* At the bottom:
    + create a label `Having image`, `Operator: Is not empty`
    + create second label `Not having image` `Operator: Is empty`

Save and check
> 0 votes

---
Tags: 7, search
---


# Question
Title: Force views to write exposed form block info to {block} table during install profile
In a D7 install profile, I am trying to modify the location of a exposed filter block with `db_update()`, where the view is defined by a module's `hook_views_default_views()`.

At this point it doesn't seem views has collected the views from `hook_views_default_views()` or the view block does not exist (or db\_update cannot address it) in the {block} table until I actually bootstrap Drupal after installation is complete. I have attempted:

* Invalidating the views cache via `views_invalidate_cache()`
* Loading the view with `views_get_view(NAME)`
* Triggering `drupal_cron_run()`

Before issuing the `db_update()` with no success. I am not versed enough in views to understand at what point views writes the exposed filter blocks to the block table, or how to force it to do so.

I am employing `'cache' => DRUPAL_NO_CACHE`, during my `db_update()` call.

Update : doing a views\_get\_view() cannot actually load the view. It appears that install profiles do not have access to views provided by hook\_default\_views.

Thanks.

# Answer
Doing a views\_get\_view() cannot actually load the view. From what I can tell, it appears that install profiles do not have access to views provided by hook\_default\_views.
> 0 votes

---
Tags: 7, views, blocks, database, installation-profiles
---


# Question
Title: How do I create a rule to run during every cron run?
I'm creating rules for posting to twitter. However I need these rules to run every time cron runs. What is the best way to structure these rules so they send the appropriate post at the appropriate time?

# Answer
> 2 votes
Rules has a specific "React on event" under system -\> "cron maintenance tasks performed". If your using the rules modules, that will trigger your rule on every cron run.

Also, if your building a custom module, and you need to call a function on every cron run, you can use hook\_cron to add a function to the cron tasks as well.

---
Tags: rules, social-network
---


# Question
Title: Notice: Undefined index: #ajax in ajax_form_callback() (line 391 of /var/www/html/includes/ajax.inc)
I'm having an a field set as unlimited in the options in my custom content type, whenever I'm clicking on "Add another item" the page is only loading AJAX and I'm getting this message in error log :

> Notice: Undefined index: #ajax in ajax\_form\_callback() (line 391 of /var/www/html/includes/ajax.inc).

Note: Though I haven't saved/updated the product there is also a message in `dblog` that node has been updated. This issues was not their previously until I updated my drupal version from `7.22 to 7.32` using `drush`

# Answer
> 2 votes
Found the solution for this issue in my case was with the `max_input_vars` which was occurring on Windows machine.

* Go to `C:\xampp\php` (the path where you have installed your WAMP or XAMPP).
* Open the `php.ini`, the configuration file located there.
* Approx on line `475` there would be `max_input_vars = 1000` change that as per your need. In my case `1500` worked for me.

Note: I'm not sure increasing `max_input_vars` is a good practice, I have done that as I was having more than 10K fields in a single form. Still for those who are looking for an alternate solution in their development phase can opt this solution for time being.

---
Tags: drush, updating
---


title: Embed a view in the body of a node

text:
# Question
Title: Embed a view in the body of a node
I want to embed a view into the body of a node on Drupal 7. I've tried the module Insert View and that didn't work.

I also saw support from Drupal on inputting PHP code, but I have no idea where to put that code.

# Answer
The best solution I've found so far is the Insert View module. It allows you to use tokens in the textarea to insert views wherever you'd like.

The UX of having to write out the token may be the biggest downside. I'd personally like to see a WYSIWYG button created to make use of this (similar to Token Insert Entity), but it's not too tricky to educate users how to use it by typing the token.

Other negatives could be potential performance and security concerns. As it says in the README.txt:

> ## SECURITY WARNING
>
> This filter is powerful, therefore it should be granted to trusted users only. If you allow this filter to untrusted users, then you have to make sure that EVERY VIEW EVERY DISPLAY (default display also!) has correct views access settings.
>
> ## PERFORMANCE
>
> To display views correctly, Insert view turns off caching for the input formats for which it is enabled. That means every node using this input format will not be cacheable. This can impact site performance. In these cases, it is recommended to create a special input format for use when inserting views.
> 0 votes

# Answer
When I want to display a View on certain content types, I make use of the functionality offered by the EVA: Entity Views Attachment module. On the entity's Field Display administration page, you can (like any other field) set the order for outputting the Views' result.

An interesting feature of the EVA: Entity Views Attachment module is that it allows to pass any token generated from the specific entity to the View as an argument.
> 7 votes

# Answer
You can use views\_embed\_views().

```
<?php
print  views_embed_view('view-name', 'display-name','arguments');
?>

```

Put that in your page.tpl.php or other relevant template file in your theme. Use Devel to find out which template the page is using if needed.

Or you can use the block display on the view and assign your block to the main content region as well.

There are several ways to accomplish this task. I recommend checking out the doc link above and reading the comments for other ways as well.
> 2 votes

---
Tags: views
---


# Question
Title: How do I show a basic search block on the front page that integrates with search api?
I've been creating my search pages in Search API, but I want to offer a search block on the front page or other pages that can do what the core search block does. Is there a way to either integrate the search block, or a work around to have a search block on the front page while it pulls up search and displays everything on the main search page?

# Answer
> -1 votes
Search API module has the ability to integrate with views module. All you need to do is to install views module and then create Search view,expose search filter and in your views configuration choose Exposed form in block option to yes, now you will the see the search block from your search api and place it on front page, the block will take you automatically to the search page to show the search items.

---
Tags: blocks, search
---


# Question
Title: How to mix charts views and table views on the same page?
I have a view with data displayed in a table format, and I have created another view formatted as a chart. For the view containing the chart, I used the views display style 'Charts', which was added as an additional views style by enabling the Charts module.

How can I display these two separated views on the same page?

# Answer
A possible answer to this question for anybody using the charts module is contained in Steps to create charts using the views UI, located within its community documentation.

Here is part of the **Bonus Tip** included in it:

> You may find it easier to start with a "Table" display and convert it to a chart display after setting up the data. It can be easier to visualize what the result of the chart will be if it's been laid out in a table first.

Refer to "Example 2" in my answer to "How to create a chart from simple data without using the Views aggregation feature?" for an illustration of this approach (which also includes a view in export format to start from).

Another approach is to use module Panels to show charts created with module Charts.

Here are some other (related) documentation pages for the charts module, which may help to get you going with the charts module:
> 1 votes

# Answer
You do not need panels just to display two views on the same page. Although you can certainly use them for that purpose (and you get the typical advantages of using panels, such as layout features, etc). It is very easy to achieve two views on the same page, just by using the 'attachment' display in views itself.

Here is how you go about it:

1. Create a view as usual with display page. Set up as you want (Eg. using **charts** as its format).
2. Add a second display to the same view, of the type 'attachment' and set it up as you want (Eg. using **table** as its format) ... Be careful not to override your first view!
3. In Attachment setting chose attach to 'page'.

You can set other options such as to display the attachment before or after the view it is attached to and if contextual/exposed filters should be inherited.

Just remember that your page and your attachment can use different formats. Eg. one can be a table and another a chart (and you could also swap the formats as suggested in step 1 and 2 above).
> 1 votes

---
Tags: views, charts
---


# Question
Title: How to change the node breadcrum name & there url inside in drupal 7?
There is a node where breadcrum shows like this :

```
Home › Shop Products › Product Name

```

Now I want to change the breadcrum. I can easily change the *"Product Name"* but unable to change the *"Shop Products"* name. How can I change. I have try to add custom code in **template.php** file but unable to got result.

Please help me to solve this.

# Answer
You can change the appearance of the breadcrumb using theme\_breadcrumb function in your template.php Here is a page with several snippets of example code you can use to get some inspiration on how you should write your code.
> 0 votes

---
Tags: nodes, breadcrumbs
---


title: Alter site logo path using drush

text:
# Question
Title: Alter site logo path using drush
I'm using drush to automatically build Drupal 7 sites. I want to have each of the new generated sites use a custom logo. I've been searching for a drush command that will allow me to set the path for the logo to a folder in the .../sites/*siteName*/files/ folder, but cant find one. Can this be done with drush?

# Answer
No, there's no such command AFAIK.

Logo path is stored in the variable table along with all theme settings as an array. For example, My Theme will store all its settings, including log\_path, in the theme\_my\_theme\_settings.

If you know all the settings for the theme you can use the vset drush command to set your theme settings variable with the right value.

This is an example of a theme settings variable value for a subtheme from Zen theme:

```
array (
  'toggle_logo' => 1,
  'toggle_name' => 0,
  'toggle_slogan' => 0,
  'toggle_node_user_picture' => 0,
  'toggle_comment_user_picture' => 1,
  'toggle_favicon' => 1,
  'toggle_main_menu' => 0,
  'toggle_secondary_menu' => 0,
  'default_logo' => 1,
  'logo_path' => '',
  'logo_upload' => '',
  'default_favicon' => 0,
  'favicon_path' => 'public://favicon_1.ico',
  'favicon_upload' => '',
  'zen_breadcrumb' => 'yes',
  'zen_breadcrumb_separator' => ' › ',
  'zen_breadcrumb_home' => 1,
  'zen_breadcrumb_trailing' => 0,
  'zen_breadcrumb_title' => 1,
  'zen_skip_link_anchor' => 'main-menu',
  'zen_skip_link_text' => 'Jump to navigation',
  'zen_html5_respond_meta' =>
  array (
    'respond' => 'respond',
    'html5' => 'html5',
    'meta' => 'meta',
  ),
  'zen_rebuild_registry' => 0,
  'zen_wireframes' => 0,
  'favicon_mimetype' => 'image/vnd.microsoft.icon',
)

```

If you want to use vset with an array see this hint:

```
php -r "print json_encode(array('drupal', 'simpletest', 'leftandright', 'category'));"  | drush vset --format=json project_dependency_excluded_dependencies -

```
> 1 votes

# Answer
You could make sure that the logo in your theme is using the default logo path (sites/all/themes/theme\_name/logo.png). Then when you deploy, just copy the custom logo to that location with the filename "logo.png".
> 0 votes

---
Tags: drush
---


# Question
Title: How can I filter the apachesolr_autocomplete results on a custom search block
We recently set up solr search and have been happy with it. I started using the custom\_search module to set up pre-filtered search results, and while my solr search pages work well, the autocomplete search suggestions return ideas from the full site.

Is there any way to filter them based on content type?

# Answer
> 0 votes
This seems to be the D.O issue for this:

https://www.drupal.org/node/1444038 (enables per-search-page support for autocomplete)

along with this...

https://www.drupal.org/node/326375 (enables having a search form block per each page)

---
Tags: search, ajax
---


# Question
Title: Problem sorting events by Term Reference
Hi I created an Event Calendar in Drupal 7.3 I have a content type set up with term ref everything works great when i click on an event I have at the bottom display the term Ref you can see it here http://www.ofmq.com/content/pain-falls-major-injury-mcalester

at the bottom of the Event there is a link to the term ref in this case it is Nursing Home when you click it you get a list of all events that have Nursing Home as a term my problem is how can I sort the list generated by event start date? Any help would be appreciated Cheers DEW

# Answer
It would seem like your link is simply rendering the taxonomy term usage page (that comes standard with Drupal). What I would recommend is creating Views with Contextual Filters (the filter could be the name of the taxonomy term, in this case `nursing-home`).

Once you have your Views with Contextual Filters built (with a set link, such as /events/) then you can simply rewrite the result of the term field (i.e. display it as plain text and then rewrite) using tokens for the machine name of the term and provide it as a link.

Does this make sense?
> 0 votes

---
Tags: taxonomy-terms
---


# Question
Title: Pathauto changing drupal_get_path file path
Pathauto changed where `drupal_get_path` looks for an image path I'm calling.

```
<img src="<?php print drupal_get_path('theme', 'maafs_subpage'); ?>/images/iafe.jpg" alt="Iafe the Network">

```

This was accessing `http://localhost/maafs/sites/all/themes/maafs_subpage/images/iafe.jpg`

Now it's trying to access `http://localhost/maafs/news/sites/all/themes/maafs_subpage/images/iafe.jpg`

Is there a work around for this or is there a better way of getting the path for the image?

Thanks in advance for your help.

# Answer
> 0 votes
Are you accessing this link from a subpage? It would seem that it is not appropriately pulling from the Drupal root when you are making the call (from a page other than the homepage).

You can use the global variable `$base_path` to get the Drupal root. More information on this global variable: https://api.drupal.org/api/drupal/developer%21globals.php/global/base\_path/7

---
Tags: 7, files, path-aliases
---


# Question
Title: Include email attachment in new content Rule
I'm trying to send an attachment within a rule I've set up for new content notification. I have the requisite modules installed: Mail System, Mime Mail, etc. I've set the rule up to send HTML mail to users of a role, specified the body content, and the attachment in the following manner...

I've tried various incantations of the attachments value by changing the token. The file I'm trying to attach is an Excel file attached to an article. The email notification does get delivered, and, appears to have an icon indicating an attachment. However, when I open the email, the body text is correct, but, there's no attachment. From the research I've done, I've found that attachments seem to be an enigma. Some posts I've read imply that I need to do some coding to get this to work. Seems like I shouldn't have to. Can anyone shed some light on how to attach a file correctly?

# Answer
If anyone else is struggling with this problem (and, I did find quite a few that were), I've found a work around. First, it appears like this may be a known bug. Given that, I found the work around at #25 worked for me. In my case, I had to tweak the attachments value in the rule to look like this...

```
[node:field-file-attachments:file:path]

```

Note: no preceding path was required. With the above, I now get attachments in emails that are generated via a rule.
> 2 votes

---
Tags: 7, rules, mimemail
---


# Question
Title: Module not appearing in list after pushing to Acquia Cloud
I have added a new module in my local code repository. After adding, I committed and pushed it to my remote repository on Acquia Cloud, but it is still not showing up in the modules list.

Can anyone suggest why this is happening?

# Answer
Unless it's automated, you'll also need to pull to code from the remote repository onto your web server.
> 0 votes

---
Tags: 7
---


# Question
Title: How do I display a fixed size Views grid regardless of the number of results?
I have a Views grid that can display anywhere from 0 to dozens of results. I want to display a 3 column, 2 row grid with a pager that will always show 6 cells regardless of how many results my filter gives. How do I do that? Also, I can't find the option to display the View even if there are no results. Where is that?

# Answer
You can take a look at Views responsive grid. I'd suggest using it over the built in views grid because it splits up your rows/columns in a more manageable way.

The functionality you're looking for is built into views, under pager. You would need to set it to use a pager as well as display 6 results.

The section under Advanced -\> No results behavior is what you are looking for.
> 0 votes

---
Tags: views
---


# Question
Title: How do I add a payment view block to Commerce Order page?
At example.com/user/123/orders/993 the customer sees an Order #993 page to review the history of a particular order.

I already have a View with a block display of the payment information for a given order.

How can I attach this block to that particular form/page (which is generated in code) such that I can pass the UserID and OrderID to the view?

EDIT: What I want to do is 'inject' the Payment view/block I've created -inside- the form generated in commerce\_cart.module (after the line items entity reference) so that I can theme it in a decent looking way.

# Answer
For the block, you can set the visibility to `user/*/orders/*`

For the info in the block, you can use a contextual filter that checks the user and displays the needed info.
> 0 votes

---
Tags: forms, commerce
---


# Question
Title: Field prints twice, or not at all when added to template file
I have set my node field to 'Hidden' in the Manage Display page, and am printing the field in the corresponding tpl.php file, but the field only prints if I set the field format to 'Default' in Manage Display.

How can I hide the node field, and JUST print it in the template?

This is the code I'm using to print the field

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

```

so basically what's happening... is that if I set the format to 'Hidden' in Manage Display, the field doesn't display at all, and then if I set the format to 'Default', the field shows twice - once where I've printed it using the above code, and again in the content area.

What am I doing wrong?

Cache has also been cleared.

# Answer
Your template file will only print fields that are not hidden in the Manage Display window, so you definitely need to make it 'default'.

It's probably printing twice because you have the default `print render($content);` somewhere in your template file.

If you want to print the field separately and not have it print when the main content is printed you need to hide the field **in the template file** not in Manage Display:

```
<?php hide($content['field_description']) ?>

```

Make sure you do this early in the file, before `print render($content);`.
> 2 votes

---
Tags: 7, nodes, theming, entities
---


# Question
Title: How to add replicate fields when adding content?
I've got a drupal structure that I'm trying to set up for hospitality venues so it has information like opening hours, and what is going on at those times. E.g. At Joe's Burgers between 9-5 Monday-Thursday it is a restaurant, but from 9-5 Friday-Saturday it's a nightclub.

I've got fields of venue name, opening hours, and category (e.g. bar, nightclub, restaurant, etc), and therefore am able to add content for one time frame: e.g. Joe's Burgers is a restaurant from 9-5 Monday-Thursday. But I don't know how to set it up so that I can attach further details such as it's a nightclub 9-5 Friday-Saturday.

Is there a button I can add into the 'add content' section which allows me to replicate the opening hours and category fields so that I can have multiple opening hours and category combinations under one venue name?

Thanks guys!

# Answer
> 2 votes
You could use Field Collection to set up a field that contains both a category and a date as one unit.

Then all you would need to do is set the field collection to allow multiple values.

# Answer
> 1 votes
Do you need to replicate an existing time collection, or do you just need to add more?

If you just need more, Field Collection will let you add multiple collections of fields. Each collection can have the fields you need: name, hours, category, etc

---
Tags: entities
---


# Question
Title: Is there a way to trigger an action on a php exception in Drupal 7?
Whenever a php error/exception occurs, I'd like to log the error and optionally send an email off to the site admin. Is there an easy way to do this with Drupal 7? Maybe an existing module or a combination of existing modules?

I have a long, non-drupal technical background, and I've done this many times over in other frameworks and custom stacks (mostly Python). Not that all frameworks should be created equal, but I figured I'd ask if there was a module for this before going off and developing my own.

I feel like I should be able to use the standard "recent log messages" for my purposes, but two things would need to be added to it. First, I would need to log php exceptions. Second, I would need to have the ability to send these log messages in an email. Now, I understand that logging php exceptions to the "recent log message" table wouldn't be totally all inclusive since the logging php code itself could have a bug in it. But if that was my only only limitation, I'll settle for the 95% solution.

Any direction at all will be appreciated.

# Answer
> 7 votes
I'm glad this question was asked some time ago, and Thanks to @coderama for offering a bounty for this. I make questionnaires/challenges to Druplars in my local community, and this was a question there.

PHP allows you to set error and exception handlers. This similar to how you register class autoloaders and shutdown functions.

See `set_error_handler`

> Sets a user function (error\_handler) to handle errors in a script.
>
> This function can be used for defining your own way of handling errors during runtime, for example in applications in which you need to do cleanup of data/files when a critical error happens, or when you need to trigger an error under certain conditions (using trigger\_error()).

Also, you can set an exception handler to handle uncaught exceptions. See `set_exception_handler`

> Sets the default exception handler if an exception is not caught within a try/catch block. Execution will stop after the exception\_handler is called.

Drupal takes over these two when it initializes the environment. even before bootstrapping advanced bootstrap levels, such as the database, variables, and full bootstraps.

**If the error happens in Drupal-handled request, it will be handled by either of these handlers (error or uncaught exception handler) unless it was overriden by other modules (Devel's error handler, and other error handling modules or server-side implementations, possibly New Relic).**

Both of these functions call `_drupal_log_error()` to proceed to the logging behavior in Drupal.

The default error handling (and other logging) functionality is based on the `watchdog()` function.

`watchdog()` function invokes `hook_watchdog()`, which the db\_log module implements `hook_watchdog` to store them in the database. `watchdog()` function itself is not storing them in the database. Similarly, there is `syslog` module that can store them in the system log (instead of, or in addition to the database log).

If you want to call your own logging/reporting tool, you can simply create a module and implement `hook_watchdog()` to log them. Note that `watchdog()` is called to log events that you probably don't want to log, such as users logging in, node CUD events, user registrations, etc. You can filter them down by inspecting the parameters passed for the hook implementation.

# Answer
> 3 votes
Drupal supports logging exceptions, although I am not sure if it will automatically log all uncaught exceptions if a module neglects to handle them.

For email alerts, I would look at Monolog or Logging and alerts. Assuming the log contains everything you want, those modules will let you send an email if a log entry is above a certain severity.

# Answer
> 2 votes
Check out the Logging and Alerts module.

---
Tags: 7, actions
---


# Question
Title: Additional field data stored outside of the field storage (in a separate table) doesn't load with the rest of the field
I've implemented a custom field that needs to store data outside of the Field Storage mechanism and in a custom DB table. (The field structure is enough to require a second table, but not enough to justify creating a new entity type. It's an image field with tooltips that will be later styled with JS.) I've hooked the necessary functions and I can see that the data is getting saved to the table, but the load hook doesn't get called when the edit screen form is built, nor does it's additional content show up in the passed-in $items array.

Since hook\_field\_widget\_form doesn't get the $entity being edited, I can't manually query the auxiliary table for the data. How do I get the data into $items and onto the form so the user can edit again?

(It also doesn't appear to be calling hook\_field\_load on the node load either, but I haven't started working on the field formatter yet.)

# Answer
hook\_field\_load *is* being called, but only once after a cache clear. Either the loaded field or the whole node is cached somewhere. Remember to clear your caches!

I missed the initial load because I had yet to instrument the function with the typical bevy of dpm() and ddebug\_backtrace() calls. Also the function itself isn't loading the data back properly, but that's outside the scope of the original question.
> 0 votes

---
Tags: entities
---


# Question
Title: "An AJAX HTTP error occurred" when sending an email via VBO (view bulk operations)
> An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows. Path: /batch?id=42348&op=do StatusText: OK

Running Drupal 7, using amazon SES to send emails. Get the above error message every time I send an email via VBO which is bizzare because the message response code is 200, the status is OK and the email is successfully sent.

Any idea why I might be getting these errors?

# Answer
As per this issue on VBO, you likely have a separate module that is stuffing up AJAX.

Try turning your custom modules off and then back on one by one to find the problem. If it happens with your custom modules all off, try it with contrib modules.
> 0 votes

---
Tags: 7, views
---


title: Moving Elements around in Date Field

text:
# Question
Title: Moving Elements around in Date Field
Trying to make the Date Module a little more user friendly.

I found out how to remove the Fieldset wrapper, and put the start and end dates in line, but due to where the check box resides, the field is a little too high, and does not sit well with the rest of the fields around it:

Would be great if I could get that check box up in the label like below:

Or inline like this option:

I'm a bit of a hack, and my efforts playing with CSS have come up with nothing (relative/absolute positioning on the checkbox works in a way, but it's really untidy and awful for a responsive site). Any help would be greatly appreciated.

To help, here's the additional template.php code to remove the fieldset:

```
function stability_date_combo($variables) {
  return theme('form_element', $variables);
}

```

And here's the replacement CSS to get the elements working in line:

```
/* Force from/to dates to float using inline-block, where it works, otherwise inline. */
.container-inline-date {
  width:auto;
  clear:both;
  display: inline-block; /*change to inline block */
  *display: inline;
  vertical-align:top;
  margin-right: 0.5em; /* LTR */
}
.container-inline-date .form-item {
  float:none;
  padding:0;
  margin:0;
}
.container-inline-date .form-item .form-item {
  float: left; /* LTR */
}
.container-inline-date .form-item,
.container-inline-date .form-item input {
  width:auto;
}
.container-inline-date .description {
  clear: both;
}

.container-inline-date .form-item input,
.container-inline-date .form-item select,
.container-inline-date .form-item option {
  margin-right: 5px; /* LTR */
}

.container-inline-date .date-spacer {
  margin-left: -5px; /* LTR */
}
.views-right-60 .container-inline-date div {
  padding:0;
  margin:0;
}

.container-inline-date .date-timezone .form-item {
  float:none;
  width:auto;
  clear:both;
}

/* Fixes for date popup css so it will behave in Drupal */
#calendar_div, #calendar_div td, #calendar_div th {
  margin:0;
  padding:0;
}
#calendar_div,
.calendar_control,
.calendar_links,
.calendar_header,
.calendar {
  width: 185px;
  border-collapse: separate;
  margin: 0;
}
.calendar td {
  padding: 0;
}

/* formatting for from/to dates in nodes and views */
span.date-display-single {
}
span.date-display-start {
}
span.date-display-end {
}
span.date-display-separator {
}

.date-repeat-input {
  float: left; /* LTR */
  width:auto;
  margin-right: 5px; /* LTR */
}
.date-repeat-input select {
  min-width:7em;
}
.date-repeat fieldset {
  clear:both;
  float:none;
}

.date-views-filter-wrapper {
  min-width:250px;
}
.date-views-filter input {
  float: left !important; /* LTR */
  margin-right: 2px !important; /* LTR */
  padding:0 !important;
  width:12em;
  min-width:12em;
}
/* Give the navigation bar a little extra padding below so it will clear the new contextual links overlay of the teasers below it. */
.date-nav {
  width:100%;
  padding-bottom:1.5em;
  clear: both;
}
.date-nav div.date-prev {
  text-align: left; /* LTR */
  width:24%;
  float: left; /* LTR */
}
.date-nav div.date-next {
  text-align: right; /* LTR */
  width:24%;
  float: right; /* LTR */
}
.date-nav div.date-heading {
  text-align:center;
  width:50%;
  float: left; /* LTR */
}
.date-nav div.date-heading h3 {
  margin:0;
  padding:0;
}

.date-clear {
  float:none;
  clear:both;
  display:block;
}

.date-clear-block {
  float:none;
  width:auto;
  clear:both;
}

/*
 ** Markup free clearing that fixes unwanted scrollbars
 ** @see http://drupal.org/node/232959
 */
 .date-clear-block:after {
   content: " ";
   display: block;
   height: 0;
   clear: both;
   visibility: hidden;
 }
 .date-clear-block {
   display: inline-block;
 }
 /* Hides from IE-mac \*/
 * html .date-clear-block {
   height: 1%;
 }
 .date-clear-block {
   display: block;
 }
 /* End hide from IE-mac */

.date-container .date-format-delete {
  margin-top: 1.8em;
  margin-left: 1.5em;
  float: left;
}
.date-container .date-format-name {
  float: left;
}
.date-container .date-format-type {
  float: left;
  padding-left: 10px;
}

.date-container .select-container {
  clear: left;
  float: left;
}

/* Calendar day css */
div.date-calendar-day {
  line-height: 1;
  width: 40px;
  float: left;
  margin: 6px 10px 0 0;
  background: #F3F3F3;
  border-top: 1px solid #eee;
  border-left: 1px solid #eee;
  border-right: 1px solid #bbb;
  border-bottom: 1px solid #bbb;
  color: #999;
  text-align: center;
  font-family: Georgia, Arial, Verdana, sans;
}
div.date-calendar-day span {
  display: block;
  text-align: center;
}
div.date-calendar-day span.month {
  font-size: .9em;
  background-color: #B5BEBE;
  color: white;
  padding: 2px;
  text-transform: uppercase;
}
div.date-calendar-day span.day {
  font-weight: bold;
  font-size: 2em;
}
div.date-calendar-day span.year {
  font-size: .9em;
  padding: 2px;
}

/* Remove 'TO:' label, as it creates a taller block and throws out placement'  */

label[for*='-field-engagement-duration'][for*='-und-0-value2']{
    display: none;
}

```

# Answer
So kids, no one could help me on this one, but if you want to do something similar, I was able to figure out the inline option...

It's not exactly how pictured, but you'll need to change the weight of the checkbox to 4.1 - this can be found on line 309 of date\_elements.inc (it's currently set to -20)

I also changed "Show End Date" to be just "To:", rather than hiding the label after the checkbox is ticked (although I'm sure I could work that out too)

You'll have to tweak some CSS in date.css to get other things working and lining up nicely too.

End result:

EDIT: Dute to some module updates, line 315 (old 309) needs to be changed from -20 to something like 6, and line 382 (the from field) needs to be updated from .2 to something like 5
> 1 votes

---
Tags: theming, datetime
---


# Question
Title: Passing variables via template.php for search module
I'm using search.module. I used dpm(get\_defined\_vars() ); in my search-results.tpl.php file to see all returned variables, so I can reference a needed variable in some PHP code I'm writing in there.

However, although the variable is being returned in the teaser/snippet (and is outputting to the page) the only place I'm finding the 'variable' is in the $search\_results array which is just a massively long string of html code. How can I parse out a needed variable (I assume in template.php) so that I can reference it and use it for comparisons on search-results.tpl.php?

The content is coming from a content type node called 'resource'. The field in questions is called 'field\_type'. Here's the code I'm currently working with in template.php to get other variables:

```
function themename_preprocess_search_results(&$variables) {
        foreach($variables['results'] as $result) {
                $node = $result['node'];
                if($node->type == 'resource') {
                      $items = field_get_items('node', $node, 'field_type');
                      $variables['field_type_items'] = $items;
                      $variables['field_type_item'] = $items[0];
                      $field_view = field_view_field('node', $node, 'field_type');
                      $variables['field_type_rendered'] = render($field_view);
                }
        }
}

// function to enable correct variables for search results
function themename_preprocess_search_result(&$variables) {
  $variables['search_results'] = '';
  if (!empty($variables['module'])) {
    $variables['module'] = check_plain($variables['module']);
  }
  /*foreach ($variables['results'] as $result) {
    $variables['search_results'] .= theme('search_result', array('result' => $result, 'module' => $variables['module']));
  }*/
  $teaser = node_view($variables['result']['node'], 'teaser');
  $variables['teaser'] = $teaser;
  /*
  $variables['body'] = substr(render($teaser['body']), 0, 200);
  if (strlen($variables['body']) >= 200) {
    $variables['body'] .= "...";
  }
  */
  $variables['snippet'] = drupal_render($teaser);
  $variables['info'] = '';
  $variables['pager'] = theme('pager', array('tags' => NULL));
  $variables['theme_hook_suggestions'][] = 'search_results__' . $variables['module'];
}

```

Is there something I can add to this to get the field field\_type and pass it to my tpl files?

Or, if that's not the right solution, what is?

# Answer
> 1 votes
You need to implement a preprocess hook for template\_preprocess\_search\_results() in your theme's template.php file. The node object should be available in the variables array:

```
/**
 *  Implements hook_preprocess_HOOK()
 */
function themename_preprocess_search_results(&$variables) {
  foreach ($variables['results'] as $result) {
    $node = $result['node'];
    if ($node->type == 'resource') {
      // Use the field API to pass the field on to the template.
      $items = field_get_items('node', $node, 'field_type');

      // Pass this field item to the $variables array for use in the template.
      // If the field accepts multiple values
      $variables['field_type_items'] = $items;
      // Or, for single-value fields
      $variables['field_type_item'] = $items[0];

      // Or pass the rendered HTML for this field only:
      $field_view = field_view_field('node', $node, 'field_type');
      $variables['field_type_rendered'] = render($field_view);
    }
  }
}

```

You don't need to copy in the code from template\_preprocess\_search\_results(). That function prepares the $variables array before it is passed to your preprocess function. That's why `$variables['search_results']` is already themed HTML.

# Answer
> 1 votes
# Adding fields programatically

Use plain old `dpm($variables);` in your search-results.tpl.php file to check variables.

And yes, the preprocess function is where to add in extra information, you can use something like:

```
$variables['custom'] = field_view_field($entity_type, $entity, $field_name)

```

field\_view\_field prevents you from having to load the whole node and takes care of languages etc for you.

---

# Adding fields in the UI

Go to the Manage Display tab for the content type in question and scroll down to CUSTOM DISPLAY SETTINGS.

Turn on the Search result checkbox and save, then go to the Search Result sub-tab.

Arrange your fields how you wish them to show in search results - note that fields aren't available to the template file unless they are displayed in the Manage Display tab, this might be the root cause of your problem.

---
Tags: theming, search
---


# Question
Title: VBO Custom Operation to create pdf of selected nodes detail page
I need to create an vbo action to produce a seperate document (pdf) of every selected node's detail page (node--content.tpl.php).

What i have to do for that..??

Right now i am creating simple pdf with dummy variables to check pdf is generate or not,

For that i done the following code

```
function MYMODULE_action_info() {
    return array(
        'export_pdf_bulk' => array(
        'type' => 'entity',
        'label' => t('Export PDF'),
        'configurable' => FALSE,
        'behavior' => array('view_property'),
        'triggers' => array('any'),
        ),
    );

function export_pdf_bulk(&$entity, $context) {

$html = '<html><body>';
$html.="<div class='test' id='test_print'>";
$html.="<p align='center'><b>Testing</b></p>";
$html.="<p>Dear Sir/Madam,</p>";
$html.="<p></p>";
$html.="<p>Testing string Here</p>";
$html.="<p></p>";
$html.="<p>Details are as follows:</p>";
$html.="<p></p>";
$html.="</div>";
$html .= '</body></html>';

pdf_using_mpdf_api($html, "Track grievances");
}

```

Using this code to generate dummy pdf (Use MPDF for generate pdf https://www.drupal.org/project/pdf\_using\_mpdf) for selected content, i got the ajax error and in error pdf content is displayed in junk characters, but ajax code is 200 and status is ok, then why pdf is now downloading and display in ajax error in junk characters??

# Answer
> 1 votes
You can achieve this using rules. Import following component & add Rule component in Views bulk operation list as shown in figure below:

```
{ "rules_create_pdf" : {
    "LABEL" : "Create PDF",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "REQUIRES" : [ "php", "rules" ],
    "USES VARIABLES" : { "node" : { "label" : "Node", "type" : "node" } },
    "ACTION SET" : [
      { "php_eval" : { "code" : "$view = node_view($node, \u0027PDF\u0027);\r\n$html = drupal_render($view);\r\npdf_using_mpdf_library_exist();\r\n_pdf_using_mpdf_generator($html, \u0027node-\u0027.$node-\u003Enid);" } }
    ]
  }
}

```

In order to save PDF files at server use above Rule component & comment two line given below in `pdf_using_mpdf.module` of function `_pdf_using_mpdf_generator`. You can find that on line no. 324 & 325 of pdf\_using\_mpdf 7.x-2.6.

```
//drupal_goto($_SERVER['HTTP_REFERER']);
//exit;

```

Figure:

---
Tags: views
---


# Question
Title: How to use drupal_add_tabledrag() with paging feature?
I have set up a table to reorganize content based on custom weight field. Everything works well without pager.

But if I add a pager to the form, only the items displayed will be reorganized - causing conflicts with items in other pages. Why drupal\_add\_tabledrag doesn't consider only the weight values that are in the current page. This would avoid any item in current page to take the same value as an item in another page.

The Taxonomy Core module do it perfectly. For example in the form where you can reorganize terms, there is a pager (admin/structure/taxonomy/\[vocabulary\]):

In Taxonomy form, when there are several pages, the last item of a page will appear in in first in next page (so user can drag & drop either against next items or/and previous items)

How can I do the same in a custom form?

/\**** EDIT \****/

Due to @Aneek Mukhopadhyay answer, I updated my post.

Actually the issue is not related with pager, but drupal\_add\_tabledrag(). The pager is working well.

The drag & drop feature too. The problem is that when reorganizing content in a page, some items will take a weight value already used by another item (in another page).

For example here is the first page of my form (before dragging any item):

And the second page:

If I move the item "Test 11" for example, new weight value for the item "Test 2" will be 2:

And the weight value 2 is already used by item Test 1 (in second page)

To achieve that I used drupal\_add\_tabledrag() this way:

```
drupal_add_tabledrag($table_id, 'order', 'sibling', 'example-item-weight');

```

I tried several options with drupal\_add\_tabledrag() but didn't find any other way to make it working without issues.

I also checked the taxonomy module but cannot figure out how they work with drupal\_add\_tabledrag().

# Answer
This can be done. If taxonomy module does it then its doable isn't it? So to do that you have to mainly follow 2 functions.

1. function taxonomy\_overview\_terms(..) in line # 249 @ /modules/taxonomy/taxonomy.admin.inc
2. function theme\_taxonomy\_overview\_terms(..) in line 548 @ /modules/taxonomy/taxonomy.admin.inc.

The first function is the form that generates the list of items present in the term listing page. (The screenshot you attached) The second function is the hook\_theme implementation of the prior function and adds the table drag functionality to the page. If you look closely, the form has navigational steps added in it and then in the theme function they are made available for JavaScript to handle the back and forth navigation you mentioned. These are `$form['#back_step']` & `$form['#forward_step']`. Those are converted to `backStep` & `forwardStep` and added to Drupal's JavaScript settings. So also you have to look at the taxonomy.js in where these are called and handled.
> 0 votes

---
Tags: forms, paging
---


# Question
Title: How can I change comment text to "DELETED" instead of actually deleting the comment?
I'm using threaded comments on my Drupal 7 site, and I'd like to be able to publicly preserve the fact that so-and-so commented here, and these were the replies. However, when a comment is deleted, all the replies are removed too. When a comment is deleted, I want the comment text to be changed to "DELETED" instead of actually deleting the comments.

I know about the un-publishing and hidden-comment kind of solutions, but I'd like the specific functionality I described instead of a workaround like those.

# Answer
> 0 votes
I use module Comment Delete, rewritten for Drupal 7. Here is the code that is responsible for what you need:

```
$num_replies = db_query('SELECT COUNT(cid) FROM {comment} WHERE pid = :cid AND status = :status', array(':cid' => $comment->cid, ':status' => COMMENT_PUBLISHED))->fetchField();
if ($num_replies) {
  $comment->comment_body[LANGUAGE_NONE][0]['value'] = t('[The comment subject/body has been deleted, all replies will remain]');
  comment_save($comment);
  drupal_set_message(t('The comment subject/body has been deleted, all replies will remain.'));
}
else {
  comment_delete($comment->cid);
  drupal_set_message(t('The comment has been deleted.'));
}

```

---
Tags: 7, comments
---


# Question
Title: Batch API processes next operation if existing operation is taking too much time
I am using batch api for processing the operations. In my operation I am sending xml request to different-different external server and waiting for its response, after getting its response I am processing it.

But sometimes it is taking too much time. In case where it is taking too much time (If response is taking more than 2 minute). I want to process the next operation.

I checked batch\_set but could found the way. How to implement it?

# Answer
> 0 votes
I have achieved this using php.

Here is the sample code

```
$operations[] = array('batch_function_1');
$operations[] = array('batch_function_2');

$batch = array(
  'title' => t('Processing'),
  'operations' => $operations,
  'init_message' => t('Please wait processing is starting.....'),
  'progress_message' => t('Processed @current out of @total.'),
  'error_message' => t('Processing has encountered an error.'),
  'finished' => 'processing_finished',
);

batch_set($batch);

```

In case of soap I achieved using default\_socket\_timeout

```
function batch_function_1 () {
  ini_set("default_socket_timeout", $time);
  try{
    $client = new SoapClient($path_to_wsdl));
  }
  catch(Exception $e) {
    dpm('Timeout'); // echo 'Timeout';
  }
}

```

And timeout when using exec.

```
function batch_function_2 () {
  // $command : Which needs to be executed for communicating with server.
  exec("timeout {$time} {$command}", $output);
}

```

I also tried the set\_time\_limit which was not working with batch api.

---
Tags: 7, batch-operations
---


# Question
Title: How can i give alphabets only validation in webform?
I can give only required and maxlength validation in webform fields , How can i give

alphabets or numbers only validation in webform textfields ??

**UPDATE**

I used hook like this :-

```
function mymodule_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'webform_client_form_48') {
        if (!preg_match('/^[A-Za-z]+$/', $form['submitted']['name']['#value'])) {
            // $form['submitted'][$key]['#attributes']['class'] = 'error';
            form_set_error('name', t('Please enter alphabets only for Name.'));
        }
    }
}

```

this is working . but the order of displaying message is not proper , the first three

message is coming from ajax form validation and fourth one is from the hook , but i need

the fourth message should come first .

# Answer
> 4 votes
If you want to go for a module, Try the Webform Validation module

> This module adds an extra tab to each webform node, allowing you to specify validation rules for your webform components. You can create one or more of the predefined validation rules, and select which webform component(s) should be validated against those. By using the hooks provided by this module, you can also define your own validation rules in your own modules.
>
> The following validation rules are currently included:
>
> * Numeric values (optionally specify min and/or max value)
> * Minimum length
> * Maximum length
> * Minimum number of words
> * Maximum number of words
> * Equal values on multiple fields
> * Unique values on multiple fields
> * Specific value
> * Require at least one of two fields
> * Require at least one of several fields
> * Minimum number of selections required
> * Maximum number of selections allowed
> * Exact number of selections required
> * Plain text (disallow tags)
> * Regular expression
> * Must be empty (anti-spam: Hide with CSS)
> * Words blacklist
> * Must match a username

---
Tags: 7, webforms, forms
---


# Question
Title: Which graphs solution for Drupal 7 can be used to upgrade my Open Flash Chart solution from Drupal 6?
I have upgraded from Drupal 6 to Drupal 7 and for me, everything is better in Drupal 7 until I hit this problem.

**What I'm trying to achieve:**

I have to create and show graphs to users depending on whatever the data they have stored on the site, I mean I have collected the data and stored in a Mysql database. I now have to fetch these data from that Mysql database and display it as a neat graph.

In drupal 6, making such dynamic graph is a cake walk..! I used Charts and graphs module with "Open Flash Chart" to create some very interactive and pretty graphs. But it does not has a Drupal 7 version..!

**Attempting to use the 'Charts' module fails:**

Then I searched for one that could work in D7 and found the charts module. It looked very promising and has a Drupal 7 version too. So I tried to install it, but I can simply not get it to work! I found a patch, but still no luck. Even if I get it to work, it will only work with Google Charts and not with Open Flash Charts or Fusion Charts because it requires those charts to be installed by us and Open Flash Charts or Fusion Charts, do not have a D7 version..!! FYI, the same problem existed in D6: when I installed everything (even Open Flash Chart API), it said "no chart plugin installed". And not even a single line of documentation is provided regarding how to install these plugins and make other charts work. Hence I think its out of the picture.

**My Question(s):** So what can I do now..?? How can I create graphs..? What can I use..??

**Update about this question**:

Since I didn't find any graphs module that I could use in my Drupal 7 site, I tried using an external PHP charting library "pChart". I configured everything without getting any errors or warnings, but I only get a bizarre output ...

I have explained everything in detail, along with the code I have used to create the graph in my (new) question What is causing the unusual output when trying to create charts in Drupal 7 using the pChart library? Any help to answer that new question would be greatly appreciated!

# Answer
> 1 votes
I've used highcharts script before, not with this module, but it might work for you http://drupal.org/project/highcharts

# Answer
> 1 votes
A few years later now, but the question seems still relevant. That's one of the reasons why I started my Comparison of Charting Modules. Then I started working on Chart 2.0 ...

Recently I extended the above mentioned comparison with Maintenance Scorecards for all Native Charting Modules. Consider using these scorecards to decide about using which "charting modules" these days.

Disclosure: I'm a (co-)maintainer of some of the charting modules mentioned,
I hope this does not violate the site's policy on self-promotion.

---
Tags: 7, charts
---


# Question
Title: How to add a Google Maps containing GeoRss Feeds on a page - don't know exactly what module to use
I have developed a Google maps following the example from https://developers.google.com/maps/documentation/javascript/examples/layer-georss but I am new to Drupal and I don't know how to include it on a page. Could someone please tell me what module should I use?

Some guidance would be very much appreciated!

# Answer
Try to use GMap module. This module solve your issue.

How to use ?

If your issues not solved then try to use any of these modules :

1. Simple Google Maps
2. Google Maps Location

For GeoRSS try to use below module :

1. GeoRSS
2. Google Maps Tools
> 0 votes

---
Tags: 7, google-maps, javascript, location
---


# Question
Title: How to integrate webform into multi form wizard into drupal 7
I am trying to integrate webform into multiform wizard in drupal 7. but its not working, i dont have any idea how to integer it. if it is not possible to integrate awebform into multiform wizard then is there any alternate solution to do the same like wizard format.

# Answer
> 0 votes
You could set the redirection path of the webform to your new form upon completion. By default it stays on the node page.

---
Tags: webforms, chaos-tool-suite, forms
---


# Question
Title: I want to send a confirmation mail on event of submit button in webform?
I have a webform and a E-mail field in it Is it possible to have a confirmation mailed out to the person registering? (as in, is it possible to have the functionality also worked in?)

# Answer
> 2 votes
On your Webform settings, click on the E-mail settings tab. Then make sure you select the radio button with "Component value", select "Email", then add this component. In the next page configure the fields as you want. You also have there a template area, where you can select a custom template and add there whatever you want. You can also use tokens.

Notice that I use the SMTP Module, and I haven't tried without it, so i'm not entirely sure it will work. Best of luck!

# Answer
> 9 votes
The webform module comes with an option to send e-mails after submission. Check the webform e-mail tab when you are editing a webform

# Answer
> 3 votes
Drupal core

Drupal core modules comes with the function to send email confirmation for when a user registers. It's not necessary to use a webform for this.

Webform

With the module Webform Rules you can add conditions to your webform, each can then trigger an action. There are a lot of options for posible action, since the module Rules provides most of them. There you can check for the email notification you need.

---
Tags: 7, webforms, rules
---


# Question
Title: How to create add and edit pages for content types beside to Administration
In my drupal installation (Drupal 7) I have various users. What I want to do is, I want to enable somehow my users to be able to create content their own, without using the administration page.

Lets say, user clicks on a link to create an article or blog without going to administration page. The linked page contains a form for the article/blog and the user submits that form. So has been the content created.

What is the proper way to do it? Self development of forms? How is the URL then built?

I have found something like that how-to-create-different-panels-for-add-and-edit-node but here the module "Pages" is probably used.

It would surprise me that something like that does not exist.

# Answer
> 0 votes
If it's simply a matter of using the non-administration theme for node edit pages, there is a setting at admin/appearance, at the bottom of the page, for setting the administration theme. It also includes the following check box: "Use the administration theme when editing or creating content". Simply uncheck this to use your non-admin theme for node add/edit forms.

---
Tags: 7, nodes, forms
---


# Question
Title: How to add 'title' attributes to breadcrumbs links?
I'm currently using Crumbs module for creating breadcrumbs on my website. I added 'short title' field to nodes and show its content in breadcrumbs instead of much longer node titles. This makes breadcrumbs shorter and much prettier however it is sometimes difficult for users to understand links destinations as I often use abbreviations as 'short titles'. Would be nice to add the full node titles to the breadcrumbs' links (they will be shown on hover as a guide for users). I haven't found any solutions to achieve this so far. Any ideas?

# Answer
You can use hook\_menu\_breadcrumb\_alter().
I think it is

```
$item['localized_options']['attributes']['title'] = 'The title';

```

Play around and report here if this works!

It is called from crumbs\_CurrentPageInfo::breadcrumbItems(), with some useful data with each trail item.

However, this added data is only available if Crumbs is active. Your module with the hook\_menu\_breadcrumb\_alter() implementation may no longer work correctly if you disable Crumbs.
> 0 votes

---
Tags: navigation, breadcrumbs
---


# Question
Title: Why do i get a select dropdown when in mobile view from superfish
I have a navigation menu from superfish in the header for my site. It looks fine in my regular desktop and even landscape view of tablets but when it gets down to the size of a phone the wheels kind of come off. In the mobile view I still get the ususal three horizontal bars that expand into the dropdown menu. But a "select" element shows up for some reason. I dont know what i changed because this doesnt show up in my original installation but in my dev sight it does.

Does anyone have any idea where this "select" comes from?

# Answer
This is from a superfish plugin called `sf-smallscreen`.

You can either change it to kick in at a lower screen width, or you can disable it completely at `/admin/structure/block/manage/superfish/1/configure` -\> Superfish Plugins -\> SF-Smallscreen -\> Disable
> 2 votes

---
Tags: theming, navigation
---


# Question
Title: How to embed Drupal content in other websites?
I want to be able to have widgets with Drupal content to be embedded in other websites. For example a widget could show "new stories" or "top stories".

# Answer
You can use the Views module to output content as XML/RSS and add a widget to your target site that can build links based on the content in your XML feed.

Depending on your target site there may be pre-built (Wordpress, Drupal, Joomla, Blogger) plugins/addons available to do exactly what you're hoping to accomplish.
> 4 votes

# Answer
To avoid having to use an iframe (and because Drupal is moving more and more toward using APIs) I would recommend looking into the Content API module. It is still being developed, but it does allow any content on your site to be made into an import-friendly format for use with any other site/program.

Using Views is another option, but that depends on your ability to create and parse feeds with all the data you need, whereas the API method should do that for you.
> 1 votes

# Answer
Take a look at the Aggregator module, which is part of Drupal core.
> 0 votes

# Answer
A detailed explanation on how to embed an iframe can be found here: http://drupal.org/node/650612#comment-2336864

---

Associates website and copied their link to put their store Amazon store in an iframe.

```
<iframe src="http://www.charlottefabrics.com" width="100%" height="4000" frameborder="0" scrolling="no"></iframe>

```

It was really very simple: I copied their link and went to my website, and created a new page. (make sure your wysiwyg editor is turned off before pasting) I then pasted the link into the body area and changed the link to the Iframe src Also, since many of the searches from the Charlotte fabrics website can return many choices, I changed the scrolling to "yes".

Here is what I pasted into the blank body text:

```
<iframe src="http://www.charlottefabrics.com" width="100%" height="4000" frameborder="0" scrolling="yes"></iframe>

```

Note: I set the Input Format to "Full Html". Also, If you have the Wysiwyg editor enabled by default, I'd recommend that you change it so that the Wysiwyg is NOT enabled by default. Because the Wysiwyg will delete the link each time it is enable.

---

For our applications/sites we use the Colorbox module to display iframes. Works like a charm
> 0 votes

# Answer
Use the Entity Iframe module. This allows any node to be an iframe, and it even provides the embed code for all nodes.

You'll need to create a new theme that you want to use for the iframe, probably the same as your main theme but then remove all headers, footers, sidebars, etc.

Another possible solution: use the splashify module and create a "splash" page for the node you need to be in an iframe.
> 0 votes

---
Tags: 7
---