title: No results behavior - HTML link

text:
# Question
Title: No results behavior - HTML link
I have created a View (for `/blog`). The blog page is just articles grouped together. Underneath each blog post I'd like "Comments (`x`)" (`x` = showing the number of comments).

That part is done, using *Rewrite results \> Output this field as a link*. Link path = `blog/[title]#comments`

What I would like to do now is when there are **no** comments, have a HTML link "Comments (`add`)" which goes to the comment form for that blog post. E.g. `blog/[title]#comment-form`

**Problem:**

I haven't been able to create the "Comment (`add`)" HTML link using *No results behavior \> No results text* (Is it possible?)

I've tried:

```
<a href="/blog/[title]#comment-form">add</a>

```

and many other alternatives. The link becomes

```
/blog/%3Ca%20href=

```

Am I on the right track? How do you recommend I go about this?

# Answer
> 1 votes
You may want to investigate Page Manager (Ctools suite). This module allows you to intercept a URl and create variants based upon conditions (contexts) from the URL call. Page Manager works very well with Panels which allows you to break down regions in your them into subregions and insert views in the panel. Panels is fairly easy to use and even if you do not want to include additional sub regions, it combines well with Page Manager to accomplish what you want. You can find more on how to use Page Manager at nodeone.se

By way of an example you could create a panel page using Panels or Page Manager (it works the same starting in either module). If the path were `/blog/%blog` then the page definition will intercept all /blog/anything URLs. You could then create two variants, one to act if there are no comments and one if there is. You would then add a layout and include a view for each one.

Another approach might be to use Page Manager variants to redirect a URL request to another location so one could call the View directly and the other could go to the comment form.

# Answer
> 1 votes
I solved it! Using a simple method I discovered within Views!

In `Views > YourView (Page) > Fields` (Make sure you have the following fields)

* Content: Nid (In it's properties, select "Exclude from display")
* Content: Comment count

I discovered that when you add another field (e.g. `Content: Nid`) it becomes available in the `Output this field as a link` \> `Replacement patterns` for all fields! Sweet!

What I did then was (Modifing `Content: Comment count`)

(Show the comment count, and turn it into a link)

```
Rewrite results > Output this field as a link. Path= blog/[title]#comments

```

(If there are no comments, add a HTML link with a link to the Node's ID comment field)

```
No results behavior: (<a href="http://www.yourwebsite.com/comment/reply/[nid]#comment-form">add</a>) Comment

```

Hope that makes sense! :D

---
Tags: views
---


# Question
Title: Using a view to attach fields from a content type to another one
I am a bit new to this, but I do have a programming background, and I have been working with Drupal for a while.

I am putting together a site for our Yoga Studio and I have a content type (scheduled class) that has a field (field scheduled\_class) that is a node reference to a content type (class description). The Scheduled Class content type has as field for date which is used in a calendar, and there are multiple classes using the same class description.

I am trying to use a view to attach fields from the class description to the scheduled class content type and I cannot get it to work. I have been banging my head against the wall for months now.

```
                               --> fields
Scheduled class --> Class Type --> fields
                               --> fields

```

I have not been able to get the contextual filter and relationship set up properly to allow this to work. I have tried every single combination I can think of. I am pretty sure the source of the problem is trying to get the right default value of the Class Type, but I am not sure.

# Answer
What I would do:

Enable the query preview under Views settings.

1. Create a new View.
2. Make sure "Title" is a selected field, and that the titles of both "Scheduled classes" and "Class type" is available in the list.
3. Add a new relationship, pick the one representing your node-reference. Make it required.
4. Change the title-fields configuration to select the newly added the relationship.
5. You should now only have titles from "Class type".

From there on, you likely want to add a contextual filter on a nid so you can pick out "Class type" from a specific "Scheduled class".

I haven't used references in a while. If you get stuck already here, give the same thing a try with entity reference instead, just to see if it plays better together with Views.

Also see Learn Views with NodeOne, episode 11 is specifically about relationships.
> 2 votes

# Answer
I think this will help you.

1. Make a content view.
2. Add a filter for "Content:type" that shows only the node of the "scheduled class" content type.
3. Add the relationship "Content: Field node reference."
4. Add the field "Content:body" and use the above relationship while displaying.
> 1 votes

---
Tags: 7, views
---


title: How to implement facebook wall?

text:
# Question
Title: How to implement facebook wall?
Is there any module which works the same as facebook's user wall?

On facebook's wall, users can post/share anything and friends can also post/comment.

# Answer
I am able to do it without statuses. But I used formblock, rules, heartbeat.

1. I created a content type wall post with user reference field and body field.
2. I showed the node/add/wall-post block on profile page using formblock.
3. I created form\_alter to set default value of user reference field to profile autor id.
4. I hid the user reference field using css.
5. I created the rule "redirect user to profile page after saving wall post" so that when user post it will come back to same profile.
6. I cloned the heartbeat template "heartbeat\_add\_node" to create "heartbeat\_add\_wall\_post" and set its content to "!username has posted on !username2 wall. !node\_body".
7. I updated above rule and added one more action "log a user activity" = heartbeat\_add\_wall\_post". Set the Entity ID to \[node:nid\], User ID to \[node:author:uid\], User target ID to \[node:my-user\_reference\_filed\] and provided the values for !username, !username2 and !node\_body.
8. And showed the user activity stream block on profile page. User can also comment the logged activity and heartbeat saved comments to original wall post.
> 5 votes

# Answer
Yes, but it's under development. It's called statuses.
> 5 votes

# Answer
There are couple of modules that could help you, Although you would still have to write a bunch of custom modules and install bunch of modules.

start by downloading this module fb module

theres another under dev module statuses
> 0 votes

# Answer
You may want to look at the Disqus module.

> DISQUS is a comments platform that helps you build an active community from your website's audience. It has awesome features, powerful tools, and it's easy to install.
>
> ### Disqus Features
>
> * Threaded comments and replies
> * Notifications and reply by email
> * Subscribe and RSS options
> * Aggregated comments and social mentions
> * Powerful moderation and admin tools
> * Full spam filtering, blacklists and whitelists
> * Support for Disqus community widgets
> * Connected with a large discussion community
> * Increased exposure and readership
> 0 votes

---
Tags: 7, social-network
---


# Question
Title: How can I render a field based on the value of another field
I set up a boolean field and an image field. I want to display the logo when the page is viewed only when the boolean field is checked. Below is the code that I am working with in a node template file.

```
<?php
      // We hide the comments and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      hide($content['field_boolean']);
      hide($content['field_logo']);
      print render($content);
    ?>
  <?php if ($content['field_boolean']['und'][0]['value'] == '1'): ?>
    <?php print render($content['field_logo']); ?>
  <?php endif; ?>

```

# Answer
> 3 votes
Try this:

```
$logo = render($content['field_logo']);
hide($content['field_logo']);
// ...
<?php if ($content['field_boolean']['und'][0]['value'] == '1'): ?>
  <?php print $logo; ?>
<?php endif; ?>

```

At the moment you're hiding the logo field, which will probably prevent it from being rendered at all, even the second time you call `render()`. Taking a copy of the rendered logo field and outputting it later should work instead.

You could also do it this way:

```
<?php if ($content['field_boolean']['und'][0]['value'] == '1'): ?>
  <?php
  show($content['field_logo']);
  print render($content['field_logo']);
  ?>
<?php endif; ?>

```

# Answer
> 1 votes
first in node tpl try to print\_r($node) to check value of boolean and try this

```
<?php
      // We hide the comments and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      hide($content['field_boolean']);
      hide($content['field_logo']);
      print render($content);
    ?>
  <?php if ($node->field_boolean['und'][0]['value'] == '1'): ?>
    <?php print render($content['field_logo']); ?>
  <?php endif; ?>

```

# Answer
> 1 votes
@Ahmed voted your answer up again because it’s correct. In order to ensure the field is really initialized and available you would use PHPs isset function like so.

```
<?php

  if (isset($node->field_boolean['und'][0]['value']) && $node->field_boolean['und'][0]['value'] === '1') {
    echo render($content['field_logo'];
  }

```

This code is also faster because it does not open and close the PHP tags all the time (and prints the spaces) and it uses echo instead of print. And I mean much faster, test it yourself with the following code:

```
<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);

header('Content-Type: text/plain');

define('ITERATIONS', 1000000);

$node = (object)array('field_boolean');
$node->field_boolean = array('und' => array(0 => array('value' => '1')));

$before1 = microtime(true);

for ($i = 0; $i < ITERATIONS; ++$i) {
?>
  <?php if ($node->field_boolean['und'][0]['value'] == '1'): ?>
    <?php /* Do something */ ?>
  <?php endif; ?>
<?php
}

$after1 = microtime(true);

$before2 = microtime(true);

for ($i = 0; $i < ITERATIONS; ++$i) {
  if (isset($node->field_boolean['und'][0]['value']) && $node->field_boolean['und'][0]['value'] === '1') {
    // Do something!
  }
}

$after2 = microtime(true);

echo "\n\n\n\n" . ($after1 - $before1) . ' sec1 ' . ($after2 - $before2) . ' sec2';

```

I got "18.2180221081 sec1 1.09752106667 sec2" on a simple LAMP server without any special optimizations.

---
Tags: entities, theming
---


# Question
Title: Load an iFrame to Drupal with JavaScript
Because of Google Analytics I would need to use JavaScipt to load iFrame to my Drupal template. I use this only just on one custom content type template.

Can I put the JavaScript straight to the template?

At the moment the JavaScript in my node template is like this:

```
<script type="text/javascript">
var iframe = document.getElementById('myIFrame');
iframe.src = pageTracker._getLinkerUrl('http://mydomain.com/iframepage/');

</script>

<iframe id="myIFrame" height="500px" width="350"></iframe>

```

But it doesn't load anything to the iFrame. I followed this http://code.google.com/intl/fi/apis/analytics/docs/tracking/gaTrackingSite.html#trackingIFrames

Any idea where the problem is?

EDIT: noticed that I get error: "Uncaught ReferenceError: pageTracker is not defined"

# Answer
Your code is missing some important stuff. The original code from the Google page you linked yourself:

```
_gaq.push(function() {
  var pageTracker = _gat._getTrackerByName();
  var iframe = document.getElementById('myIFrame');
  iframe.src = pageTracker._getLinkerUrl('http://www.my-example-iframecontent.com/');
});

```

So you would end up with something like the following.

```
<script type="text/javascript">_gaq.push(function () {
  document.getElementById('myIFrame').src = _gat._getTrackerByName()._getLinkerUrl('http://www.my-example-iframecontent.com/');
});</script>
<iframe id="myIFrame" height="500px" width="350"></iframe>

```
> 1 votes

---
Tags: theming, javascript, google-analytics
---


# Question
Title: How to customize the data retrieved by a REST call?
I've enabled the REST server (plus services) and can retrieve user profile data at www.example.com/endpoint/user/123

How can I customize the data that's being retrieve? I want to not include the email address and add a couple of other fields.

When I make a login request at www.example.com/endpoint/user/login I would like to have those additional fields included as well.

# Answer
All you need is to define your Resource, take a look at files in site/all/module/services/resources, you can find some examples, but for simplicity I will take you and example:

endpoint\_user moduel:

endpoint\_user.info file:

```
name = endpoint_user
description = endpoint_user
core = 7.x

```

endpoint\_user.module file:

```
<?php
function endpoint_user_services_resources() {
  $endpoint_user_resource = array(
      'endpoint_user' => array(
          'retrieve' => array(
              'callback' => '_endpoint_user_resource_retrieve',
              'args' => array(
                  array(
                      'name' => 'uid',
                      'optional' => FALSE,
                      'source' => array('path' => 0),
                      'type' => 'int',
                      'description' => 'The uid of the endpoint_user to get',
                  ),
              ),
              'access callback' => '_endpoint_user_resource_access',
              'access arguments' => array('view'),
              'access arguments append' => TRUE,
          ),
      ),
  );
  return $endpoint_user_resource;
}

function _endpoint_user_resource_access($op = 'view', $args = array()) {
  return TRUE;
}

function _endpoint_user_resource_retrieve($uid) {
  $endpoint_user = user_load($uid);
  $endpoint_user->custom_field = 'Mohammad Ali Akbari';
  if ($endpoint_user) {
    $uri = entity_uri('user', $endpoint_user);
    $endpoint_user->path = url($uri['path'], array('absolute' => TRUE));
    // Unset uri as it has complete entity and this
    // cause never ending recursion in rendering.
    unset($endpoint_user->uri);
  }
  return $endpoint_user;
}

```

then create new Service in `admin/structure/services` and select endpoint\_user.

open your browser and go to your service URL, like endpoint/endpoint\_user/1

you will see:

```
<custom_field>Mohammad Ali Akbari</custom_field>

```

This result comes from `$endpoint_user->custom_field = 'Mohammad Ali Akbari';` in `_endpoint_user_resource_retrieve`
> 6 votes

---
Tags: 7, services
---


# Question
Title: How to display views exposed filter as links when the filter is a date field with year granularity?
I have a student project View that I want to filter by year using a date field.

I would like to find a way to have the years appear as links or a menu at the top.

I have tried the Better Exposed Filters module but I don't get the option to display the year as links with a date field.

I have tried making a block view which has the date field rewritten as a link with it's token value(/2010) as well as a contextual filter on the date field .

This works except I get as many 2011's as there are values for 2011.

Is there something I could do with glossary mode?

Anyone know of a way?

# Answer
> 1 votes
You are almost there: you have to group your results by the year field. In the settings of your display format just pick a grouping column:

# Answer
> 0 votes
Sadly, I don't believe the BEF module has the ability to display dates as links, but you can create a custom block and use drupal functions to create links that will work with it.

And if you do go this route you can switch from exposed filter to a contextual filter and utilize cleaner URL's and core Views functionality for re-writing the page title, breadcrumb, etc.

---
Tags: 7, views
---


# Question
Title: How to apply a theme function/template to my form
I think `theme_form()` is responsible for rendering forms! I want to change the look of a form, a lot. I think just instead of `theme_form` I can use my custom theme function/template file.

I can use `hook_form_alter` to change any form's structure using my module. Now my question is, how do tell the form to use a theme function/template I've created?

Is there a `#theme` property *(or something like that)* available for forms, which I can set to my theme function/template file?

***P.S.*** I checked out this but I need more explanation, when the case is: I'm trying to theme a form defined by another module/core modules.

# Answer
> 2 votes
Open `template.php` of your theme

```
function YOURTHEMENAME_theme($existing, $type, $theme, $path) {
  $hooks['form_id_of_form'] = array(
    'template' => 'path_to_tpl_file',
    'arguments' => array('form' => NULL),
  );
  return $hooks;
}

```

Also you can try

```
function hook_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'form_id_of_form') {
    $form['#theme'] = 'path_to_tpl_file';
  }
}

```

# Answer
> 2 votes
> Is there a #theme property (or something like that) available for forms, which I can set to my theme function/template file?

Yes there is. Take a look at the #theme key in the Form API Reference. Take a look at the code for theme\_form() for the default implementation.

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


# Question
Title: How to filter view with date field by today's date?
I came up short on good ways to filter a user list to only show users who's birthday is today.

There has been efforts in D6 but nothing in D7?

As a "hack" I used an exposed filter for the birthday field (a date field) and then created a link from a block using PHP code:

```
$today = date("m-d", strtotime("today"));
print '<a href=/members/birthday?birthday='.$today.'>Today\'s Birthdays</a>';

```

Ideally, I would like to override the input field with a select option to show " yesterday, today, tomorrow, next week".

Are there any better options doing this in D7?

# Answer
> 0 votes
Based on the comments, it seems like you already have an answer, so I'm posting it as such.

A regular date filter already has support for doing a check for field\_birthday == now. You can granularity, such as hour, day, week, and even do simple arithmatic, "now + 1 day" and similar.

---
Tags: 7, views, datetime
---


# Question
Title: Ubercart Recurring Payments and Subscriptions:Charge automatically?
I'm using Drupal 6 and Ubercart 6.x-2.7. In my online store I'm going to manage subscription for the products. Every product can be subscribed for some period of time, weekly, biweekly, monthly, semiannually. I'm going to use PayPal PayFlow Pro and PayPal Website Payments Pro gateways to receive payments.

The issue is here how to manage getting recurring payments through this payment gateways? Any php code or something else?

Here I'm including how this process works:

1. Customer adds required products in his shopping cart.
2. In the cart there is a select-box per every product for subscription(options: just one time, daily, weekly...)
3. Customer checks out from the site paying with Credit/Debit card or PayPal account.

Question: How to charge automatically the fee for subscription in the selected period?

# Answer
You can use this module.

UC Recurring Payments and Subscriptions

**Features**:

* New/improved API for payment gateways to interface with uc\_recurring - see hook\_recurring\_info().
* Ability to treat a recurring fee as a new order - so it gets access to everything a new order gets at the time of renewal e.g separate invoices, apply roles etc...
* Option for unlimited renewals (ie: renew until canceled).
* Option for recurring payments to be set that same as product price (this means that the recurring payments can be based on adjustments of a products from things like attributes).
* Conditional action support - sending emails on failed renewals.
* Extension API - administrators can configure what will happen on a failed payments, e.g order can be extended and re-attempts as many times as required.

**Take a look at discussions here**

PayPal community

x.com

**Please note module is not stable yet**
> 1 votes

---
Tags: payment-gateways, notifications
---


# Question
Title: Gather arbitrary data in feeds xpathparser without mapping it to a field?
I gather data with the feeds module and xpathparser.

Sample data 1:

```
<xml>
  <id>1234</id>
</xml>

```

Sample data 2:

```
<xml>
  <id>1235</id>
  <ref-id>1234</ref-id>
  <action>delete</action>
</xml>

```

In the incoming XML data, there are two fields, used to signify an old entry should be deleted. In my feeds `Parser->parse()`, I have

```
$this->config['sources']['refid'] = 'XML/ref-id';
$this->config['sources']['action'] = 'XML/action';

```

which makes the parser get these two data values even if I don't map them to a field. But I can find no way of making this information available to the Processor. I would like to find some way of sticking this data on to the $node, so that in entitySave() I can ignore saving id 1235 and instead delete 1234.

# Answer
> 0 votes
As per this issue: Map "Temporary target" to a property of an entity, Feeds tamper seems to be the way to do this.

---
Tags: feeds
---


title: Help installing rpx module

text:
# Question
Title: Help installing rpx module
I'm trying to use the RPX module and I get as far as step 5.

I've installed and enabled the plug

checked permissions

and selected "visitors"

Then i get here.

> Visit admin/config/people/rpx and enter your Janrain Engage API key.\* This API key must be entered for the module to function properly.

I find that the path admin/config/people/rpx doesn't exist.

I'm running Drupal 7.12 with RPX 7.x-2.2

Is this a common problem, does anyone know how to fix it?

# Answer
I install `7.x-2.2` version and follow structures, `admin/config/people/rpx` exists and work correctly.

this may cause because of bad/in-complete installation, install DEVEL module and try: clear cache / re-install / re-build menu
> 1 votes

# Answer
The page you are referring to, `admin/config/people/rpx`, is defined in the module named `Janrain Engage UI`, machine name `rpx_ui`. You need to have it enabled for the path to be registered.
> 3 votes

---
Tags: 7
---


title: The panel is not showing up

text:
# Question
Title: The panel is not showing up
I'm making my own custom panels **layout** using the Panels module for the front page of my site. This is how I have my page set up.

Two blocks will be displayed on all pages: a header, and a footer (each have their own navigation bar). The header contains a few images (logo and two more) plus a customized login block (using the hook). Now, I've decided to create my home page, which uses the clean URL /home. I've copied the files from the **twocol** folder in the **modules/panels/plugins/layouts** folder to a **twocol-bottom folder** in my layouts folder of my theme's root (I hope you guys can understand what that means: basically **/sites/all/themes/my\_theme/layouts/twocol-bottom**).

I've renamed the twocol folder to twocol-bottom (because, I just want to add a bottom panel that extends the full length of the #main area (inside the #main-wrapper). I've renamed all the files to twocol-bottom.css, twocol-bottom.inc, twocol-bottom.png, twocol-bottom.tpl.php. I've added the following line to my theme's info file:

```
plugins[panels][layouts] = layouts

```

### twocol-bottom.inc

```
<?php

// Plugin definition
$plugin = array(
  'title' => t('twocol-bottom'),
  'category' => t('Columns: 2'),
  'icon' => 'twocol-bottom.png',
  'theme' => 'twocol-bottom',
  'css' => 'twocol-bottom.css',
  'panels' => array(
    'left' => t('Left side'),
    'right' => t('Right side'),
    'bottom' => t('Bottom pane')
  ),
);

?>

```

### twocol-bottom.tpl.php

```
<div class="twocol-bottom-display panel-2col clear-block"
<?php if (!empty($css_id)) {  print "id=\"$css_id\""; } ?>>
  <div class="twocol-bottom-panel panel-col-first">
    <div class="inside"><?php print $content['left']; ?></div>
  </div>

  <div class="twocol-bottom-panel panel-col-last">
    <div class="inside"><?php print $content['right']; ?></div>
  </div>

  <div class="twocol-bottom-bottom">
    <div class="inside"><?php print $content['bottom']; ?></div>
  </div>
</div>

```

I changed all the CSS classes to match the classes in the .tpl.php file.

When I flush my cache in Drupal and choose to change the layout of my first panel, the newly added panel isn't showing up. I'm not sure how to make the panel show up.

# Answer
> 2 votes
I think you're taking the wrong approach. One of the main reasons for using the Panels module is to avoid writing custom code like this.

Instead of making your own custom panels layout in code for just your front page, use the "Flexible" layout builder provided by Panels. You can then use the layout designer to add rows, regions, and columns however you want. You can even add CSS classes and choose between fluid and fixed widths, setting the percentages as you like.

Given that you can do all of that *within* the Panels module itself, I would think twice before you try to code a layout just for one page.

---
Tags: 6, panels
---


# Question
Title: Determining current user's relationship to node author
I'm currently using User relationships module, and setting the UR-Node access module so that nodes can only be viewed by users related to the author.

However, I want to have a public display version of the node for search engines, sharing links, and also for a button to say 'You need to become friends with x to see this node'.

So, I was thinking of using the User relationships API to determine the users' relationship, and output two different displays in the tpl.php file.

Does anybody know how to determine the relationship programatically? I'm stuck.

(I've done this in the Views I've made, it's just in the nodes, that I'm having trouble)

# Answer
> 5 votes
It looks like you can use the `user_relationships_load()` function. The following code will load all relationship objects that exist in the system between 2 users. From there you can inspect the relationships for their type/properties and make your decision based on that:

```
// Set up the user ids
global $user;
$current_user_uid = $user->uid;
$node_author_uid = $node->uid;

// Set up the parameters
$params = array('between' => array($current_user_uid, $node_author_uid));

// Get the relationships
$relationships = user_relationships_load($params);

```

# Answer
> 0 votes
Here is a sample code to check relationship:

you should replace `friend` with your relation type

```
$relations = user_relationships_load(array('between' => array($node->uid, $user->uid)));
$are_friends = FALSE;
foreach ($relations as $relation) {
  if ($relation->name == 'friend') {
    $are_friends = TRUE;
  }
}

if ($are_friends):
//do something
else:
//do something else
endif;

```

---
Tags: theming, users
---


# Question
Title: Add language switcher in section where i need
I want to add the language switcher block along with menus as show in the example. Please see this website http://rafedh.sa . I want to do something like this. Drupal by default does this. But i am not able to move it to top to shown in menu. By default its shown at end of the node.

I am using this theme http://drupal.org/project/danland

# Answer
> 4 votes
Move the `print render($content['links']);` up, as this outputs the alternative language links (among others).

# Answer
> 2 votes
I think you may be confused. The "language switcher block" is a block on the blocks page that allows you to switch the language. You can move it around like any other block; if you don't see it, you will need to install the Internationalization module.

The language link at the end of the node is a link to the translation that can be hidden or shown for your content type by editing the `Manage display` page for the relevant content type.

---
Tags: 7, i18n-l10n
---


# Question
Title: Avoid the preprocess/hook function defined from the Zen theme is called for its sub-theme
We are using a theme that inherits from the Zen theme. the Zen theme implements `zen_process_html_tag()` and `zen_html_head_alter()`, and we want these functions not to be called; we tried to override these functions in our theme, but then Drupal call zen's functions first, then the functions in our theme.

How can I avoid this happens?

# Answer
> 1 votes
Those are part of HTML5 support bundled with Zen 7.x-5.x. Your options are either downgrading to Zen 7.x-3.x or patching Zen. Please open an issue at Zen's issue queue asking to provide an option to turn on or off the header manipulation.

---
Tags: 7, hooks, theming
---


# Question
Title: Is there an alternative to themegarden.org - one that has Drupal 7 themes?
I like themegarden.org and I think it'll be a useful tool to help me explain to clients and colleagues how content and presentation can and should be separated. It looks like Theme Garden only caters for Drupal 4.7, 5 and 6. Does anyone know of a D7-compatible site where I can browse themes as easily?

# Answer
I haven't come across a really good site for Drupal 7 themes. Here are some sites that might be helpful:
> 1 votes

# Answer
I found the following sites which claim to Theme Garden:

Both are free.
> 0 votes

---
Tags: 7, theming
---


# Question
Title: Views module doesn't call hook_node_view() when set to display fields
I use Drupal 7 with Views and want to override some node field output in a view (namely change its Title to something I want). To accomplish that I set the view to display Fields and not Context or Rendered Entity and select Title and Body from the list of fields. And here is where the problem lies:

I have a (homemade) module that makes use of `hook_node_view()` hook to modify Body and Teaser text. When I display article body as a Field in the Views this hook for some strange reason is not called (on Context and Rendered Entity all works correctly). So I need a way to either:

1. override Title output while NOT setting my view to display Fields, or
2. find a way to call `hook_node_view()` while setting my view to display Fields.

Is there a way to do it?

**Upd:** provided a screenshot showing that hook\_node\_view() is not called on teaser when setting Show to Fields (left pane) but called when setting Show to Content (right pane):

screenshot showing that hook\_node\_view is called on teaser when setting Show to Content and is not called when setting Show to Fields http://ari-linn.nightmail.ru/views\_and\_hook\_node\_view.jpg

**Upd 2:** Okay, I did some Drupal colonoscopy and it even works though I can't say whether it is the right way to do things (probably not). I found out that when you render **context** Drupal apparently thinks you want to render a normal node but when you render **fields** Drupal is at a loss and doesn't think you're dealing with nodes anymore. Thus it doesn't fire any node hooks including `hook_node_view()`. If anyone still needs to run their functionality of `hook_node_view($node, $view_mode, $langcode)` they can use `hook_views_pre_render(&$view)` though access to node `$view_mode` and `$langcode` will be gone.

In case people out there are interested how I override node titles in taxonomy views, here is the scenario. My task was to override node Title with the value of another field, SortKey, and do it only in taxonomy views. I'm happy with "Britney Spears" node title at the main page but when it comes to taxonomy I want her to display "Spears, Britney".

I personally thought it to be tiresome and bothersome to deal with fields (they mess up all my CSS) and found a hack in Views 7.x-3.3: if you set Show parameter in your view to Fields and select Material:Rendered Material AND any other field (you can exclude it from display, just make sure Rendered Material is not the only field you load) you'll get a neat and tidy Node object at `$view->result->_field_data`. I fail to explain how it is so but it's there, and you can bend it to your needs, and what is even better Drupal will think you're rendering a node and fire all node hooks on it. I pray though that Views coders won't remove this wonderful hack in later versions ruining my code.

Here is the code:

```
/*
* Changes MYARTICLETYPE title to sortkey on taxonomy views pre-render
*/
function MYMODULE_views_pre_render(&$view)
{
    if($view->name == 'taxonomy_term')
    {
        foreach($view->result as $i => $value)
        {
            $node = &$value->_field_data['nid']['entity']; //it's a real node, yes.
            if($node->type == 'MYARTICLETYPE') //override titles only for this type
            {
                $node->title = $node->field_sort_key['und'][0]['value'];
            }
        }
    }
}

```

# Answer
> 1 votes
The title of your question is.

> Views module doesn't call hook\_node\_view() when set to display fields

That is working as intended. The reason is that it's not a node that's being rendered, but just a bunch of fields and attributes that belong to a node that is being rendered.

One way of fixing `hook_node_view` not being called, would be to actually render the nodes.

If the problem is that the field is not rendered as you which, the best way of dealing with that, would be to alter the rendering of the fields, instead of trying to make Drupal act like you're rendering a node when in fact you're not.

The easiest, cleanest and most flexible way to do that, would be to create some custom field formatters for the fields in question. Field formatters are like theme functions for the fields, and you can in views select which field formatter to use when you want to render a field. It requires some work, but gives great flexibility. That would make your `hook_node_view` obsolete as you can use field formatters when fields are rendered under the `manage display` tab in the field settings interface.

# Answer
> -1 votes
in view you can overide field output (settings from view) and to call hook\_node\_view you have to display teaser of full content or any other display of the node

to override the field you can check this image

---
Tags: 7, views, hooks
---


title: How do I automate shipping calculation?

text:
# Question
Title: How do I automate shipping calculation?
Is it possible to auto calculate shipping for Drupal 7? Is there a way to automate with coupons integrated as well? e.g. Free Shipping coupon.

Currently, if someone were to input a free shipping coupon, these are the necessary steps.

1. Enter FREESHIPPING code
2. Apply to order
3. Update order
4. Calculate shipping
5. Select "Free Shipping" instead of "Paid Shipping"

I would like to exclude the last three steps as it's a pretty long process, and some customers might not know to click on *Calculate Shipping* after clicking *Update order*. They may think the coupon is broken. Anyway, applying a free shipping code is self explanatory. What I'm looking for is a way to automate the calculate shipping when users enter or change the delivery country when *Apply to Order* is clicked on the coupon pane.

Do you have any thought?

# Answer
I'm still using D6 but I did something similar with jQuery:

Make a mymodule.module file that goes like this:

```
<?php

function mymodule_form_alter(&$form, &$form_state, $form_id){
  if ($form_id == 'uc_cart_checkout_form'){

    drupal_add_js(drupal_get_path('module', 'mymodule') . '/mymodule.js');

  }
}

```

The format of your hook\_form\_alter may be different in 7, but there are tutorials all over the place for this. The point is that you use drupal\_add\_js (again, format may differ) to cram some javascript onto only the form with the ID you want - your checkout form.

Make a mymodule.info that goes like this:

```
name = Re-calculate Shipping
description = Use JavaScript to automatically click the Calculate Shipping button at checkout.
core = 6.x
dependencies[] = uc_quote
package = "Example.com custom modules"

```

(But you're core is 7.x - copy another module's info file.) And make a mymodule.js file that goes something like this:

```
$(document).ready(function(){
      $("#edit-panes-quotes-quote-button").click();
      $("#edit-panes-delivery-copy-address").click();
});

$(document).ready(function(){
   $("#edit-panes-billing-billing-zone").change(function() {
      $("#edit-panes-quotes-quote-button").click();
   });
});

$(document).ready(function(){
   $("#edit-panes-delivery-delivery-zone").change(function() {
      $("#edit-panes-quotes-quote-button").click();
   });
});

```

Note that this just clicks the "calculate" button for the user, but I'm sure that you can work out how to use jQuery to click more things.

Imagine you have a drop-down select with the attribute id="cram". In your js file you would use `$("#cram")` to select anything with the ID "cram":

```
$("#cram").change(function() {

```

Sticking `.change()` on the end triggers anything between the brackets after `.change` when the #cram element changes, such as when a different fruit / rodent is selected. we're triggering a function here, and it is defined in-situ.

Sticking `.click()` on the end of a selector clicks the selected element.

Enjoy :)
> 3 votes

---
Tags: 7, ubercart
---


# Question
Title: How to display multiples jQueryUI progressbars in a page in Drupal 7?
I am developping my personnal website with Drupal 7. I would like to show a progressbar for each of my skills, but with differents values.

For exemple, I would like to see a progressbar under (or between if possible) a text, and (also if possible) with a percentage.

So I tried to use jQuery UI to solve my problem.

I want all my progressbars with a different value for each. Below, an exemple of the code of my website :

```
<?php
drupal_add_library('system', 'ui.accordion');
drupal_add_library('system', 'ui.progressbar');
drupal_add_js('jQuery(document).ready(function(){jQuery("#accordion").accordion();});', 'inline');
drupal_add_js('jQuery(document).ready(function() {jQuery(".progressbar").progressbar({ value: 37 });', 'inline');
?>

<div id="accordion">
<h3><a href="#">RÉSEAU</a></h3>
<div>
<p><h4>Windows Server 2008</h4>
<div class="progressbar" rel="50">50%</div>

<h4>Ubuntu Server</h4>
<div class="progressbar" rel="50">50%</div>

<h4>Virtualbox</h4>
<div class="progressbar" rel="90">90%</div>
</p>
</div>

```

But it does not work.

To solve that problem, I tried that kind of code found on that website, but I does not work for me, when I include it in drupal like that :

```
<?php
drupal_add_js('jQuery("div.progressbar").each (function () {var element = this;jQuery(element).progressbar({value: parseInt(jQuery(element).attr("rel"))});});', 'inline');
?>

<div class="progressbar" rel="90"></div>

```

Perhaps, I am in wrong, but any answer would be so great. Thank you in advance. :)

# Answer
Your first code example for the progress bar has a small syntax error (missing a `});` at the end of the line). I'm not sure exactly why your second example doesn't work, (I didn't try it) but this code works perfectly for me using your HTML as an example:

```
drupal_add_js("
  (function($) {
    $(function() {
      $('.progressbar').each(function() {
        var val = $(this).attr('rel');
        $(this).progressbar({ value: parseInt(val) });
      });
    });
  })(jQuery);",
  'inline'
);

```

This code produces:

**EDIT**

I've just noticed you have some invalid HTML in your code which probably won't help. You're wrapping `<h4>` and `<div>` tags in a `<p>` tag, which is invalid XHTML. It might not be the problem but it would be better practice to change that `<p>` to a `<div>`.
> 1 votes

---
Tags: javascript
---


# Question
Title: When a node has multiple locations (using location cck), is it possible to filter location results in views based on only one field?
I have a content type with multiple location types attached:

* loc\_past (Places I've been)
* loc\_now (Where I am now)
* loc\_future (Places I'm going)

When I create a view that shows nodes of the content type, the node is shown once for each location in each field. However, I would like to limit the results to one field (for example, show results only for where users are now).

Is there a way to configure Views/Location to do this?

# Answer
Upon further research, I have discovered that no, this is not possible. It's just not the way location is currently implemented; if a node has multiple location fields, they are all "seen" as a single field.
> 0 votes

---
Tags: 7, views, location
---


# Question
Title: Drupal 7 contexual filter display block based on node reference
I have been going around in circles with this for a few hours now... Time to ask for help!!

I have two Content Types:

1: Book

2: Reader

The `Book` Content Type has a `node reference` field which is a select list of readers create with the `Reader` Content Type.

This is all set up and working fine.

Now the issue with my views:

I have a view with is a block containing the `Reader` fields. What I want to do is have it when the `Book` node is loaded my block shows underneath with the referenced `reader` details. Also if no reader is referenced then no block shows up.

I have spent some time in `Relationship` and `Contextual Filters` but can't get it to work.

The book URL is formatted like this:

books/\[book-title\]

I tired using 'raw value from url' in `Contextual Filters` as setting it to the 2nd argument but that didn't work either.

If anyone can help me out here I would be very much appreciative.

Thanks C

# Answer
Here is what I would do if I am understanding this correctly:

Create a new view block

1.) Create a view with Filter critera: **Content type is book**
2.) Then I would create a Relationship to: **Content Reader**
3.) Add all the fields and add a relationship to the Reader content type (whatever you want displayed from the reader content)
4.) Add a contextual filer with: **Content NID**, where it says WHEN THE FILTER VALUE IS NOT AVAILABLE click on the **Provide default value** radio and select **Content ID from URL**
5.) Add that block to the story display page wherever needed
> 2 votes

---
Tags: views, entities
---


# Question
Title: Paypal Instant Payment Notifications - Add a role but not as a subscription upon purchase
Here's my use case: I have a Paypal "Buy now" button that I have created using Paypal's Website Payments Standards utility. This provides an Instant Payment Notification when a user successfully makes a purchase.

What I would like to do is automatically give a user a role upon a successful purchase. I installed the lm\_paypal module, but it is a full-featured subscription solution which I don't need; all I want to do is give users a specific role. (It's impossible to configure lm\_paypal to simply give a user a role; it wants to turn the role into a subscription, but my use case is not a subscription.)

At worst, I can just add the role to user accounts manually when I receive payment, but I'd like to find a way to do it automatically.

# Answer
I'm not sure the PayPal button is the way forward - you're probably better off using one of the cart modules (Ubercart, Drupal Commerce) so that when the IPN comes in the order status will be updated.

Then using Rules or Conditional Actions you can set up an event (triggered by the status update) to fire off an action that will add the role to the user.

Make sure to add conditions so that this only happens if the order balance is \<= 0 (fully paid for) and if a certain product is in the cart. Also to make sure that it only occurs on updates between the two particular statuses (In Checkout -\> Payment Received).

If there is no built-in action to actually add the role then you can use the "Custom PHP" action (or similar). If you find the idea of writing that chunk of php yourself, don't fret. Just search for "drupal add user role programmatically" (without quotes) and you'll be on your way. I don't know it off the top of my head, but I know that it isn't long.

One thing I have found very useful is to add an "email" action to my conditional actions, with myself as the recipient. Set the input format to PHP and put this in the body:

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

This gives you the $order array from which you can extract values such as the user ID to use in your PHP action.
> 2 votes

---
Tags: 7, payment-gateways
---


# Question
Title: Make errors also display in proper format and language
I used webform and Internationalization. It works fine, but when error message are displayed, it shows in partial english and RTL and LTR is mixed up as shown in image.

how do i correct it.

# Answer
> 5 votes
Either import translation for Webform, or keep in synch with i10n.

If the string ('field is required') is not translated, you have to do it yourself in the translation interface `admin/config/regional/translate`.

# Answer
> 5 votes
The required string for error messages is hardcoded into the Webform module, but it is run through the t() function (which translates known strings) like any other string. To translate it visit "admin/config/regional/translate/translate" and search for the string "!name field is required."

---
Tags: 7, webforms, i18n-l10n
---


# Question
Title: Views Galleriffic- pagination does not show
When I updated the Views module to 6.x-3.x-dev, pagination stopped being shown in Views Galleriffic 6.x-1.x-dev.

http://demo.dolphin-sch.ir/Doctor/content/asas

My settings are:

* Use pager: Paged, 9 items
* Style: Galleriffic Gallery
* Enable Bottom Pager: yes

And I have 17 images.

Please guide me.

I want to show pagination like this link: http://demo.dolphin-sch.ir/nagara/fa/galleriffic/95

# Answer
1) Turn off the Views pager (ie set it to "All items).

2) In the "Style" set the number of thumbnails you want to display before the pager. If you have 17 images you can set it to "9" there.

3) Make sure you have the top or bottom pager turned to "yes" in "Style".

Any luck? I just tested it with views-6.x-3.x so it should work if you have the right settings.
> 0 votes

---
Tags: views, theming, media
---


# Question
Title: Is there a way to display an 'All' link following the alphabetic glossary with Views 7.x-3.x?
I have an existing feature in a Drupal 5 site I'm trying to reproduce in Views 7x3x, but I didn't find a way to make it happen.

I have the glossary functionality working in Views 7.x-3.x but the 'All' link functionality is eluding me. This selector needs to work in combination with a filter (taxonomy) so this limits the obvious workarounds because the Views module needs to be aware of the filtering.

How do I display an 'All' link following the alphabetic glossary?

I have it working using a jQuery snippet, but would love an elegant server side solution.

---

I found these solutions on drupal.org.

I haven't tested any but if anyone does; please post your experience as an answer for this question.

# Answer
Altering views-views-summary-unformatted.tpl.php is certainly the way forward. Don't be lazy and use the header if you can't get the template file to register initially, it's worth it in the end. That way you can add --view\_name on the end and target all displays without having to copy bits of code around, or symlink the file to target another view or specific display so that you don't have to edit twice.

As I mention in the post we both linked to, the HTML doesn't validate if you use any exposed filters but it's fixable with regex.

The post has recently been updated; there is a version for 7 that includes 0-9 and ALL which works as described, if that answers your question?

Additionally you refer to the glossary as a filter but it is actually an argument selector. On my site I have it working with two taxonomy filters.
> 1 votes

---
Tags: views, paging
---


# Question
Title: Is it better to start a Drupal theme from scratch or extend an existing one?
I am new to Drupal and am curious if it is better to start a theme from scratch, or extend one that is already out there. Also, are there any resources out there that someone could point me towards?

I am using Drupal 7.8.

# Answer
I've done both many, many times and my experience has led me to say: I would start a theme from scratch every time.

Most of the starter/base themes for Drupal contain massive amounts of superflous HTML code (because they have to allow for every possible eventuality) which introduces more DOM complexity than there ever needs to be in a page. This is bad for your page load time, which in turn is bad for SEO. It's also bad for code readability and Javascript performance on the client side.

The other thing is that (rightly or wrongly) you won't always agree with the decisions the developer(s) of the theme have made with their HTML/CSS/JS and it can be very time consuming to fix an existing theme to conform to your own standards.

Why not create your own base theme? It would be a good exercise to learn how to do it and you'll be 100% sure that the code is as streamlined as you want it to be. From then on you can just use your own base theme each time you want to create a new one.

The link to the theming guide in alastair's answer would be the perfect place to start.
> 7 votes

# Answer
Extend an existing one. There are loads of starter or "base" themes available to choose from depending on your needs. I think for Drupal 6 the recommendation was to use the Zen theme, but that's been superseded for Drupal 7.

Drupal.org provides a comprehensive guide to theming Drupal 6 and 7.

Good luck!
> 3 votes

# Answer
You should really checkout the Omega theme, and watch the video that is on this page (you have to scroll a little).

I promise you will not ever choose another base theme again.
> 1 votes

# Answer
Start from scratch. It's good practice and really helped me understand theming a lot.
> 1 votes

---
Tags: theming
---


title: Views: get the raw data

text:
# Question
Title: Views: get the raw data
I am building a module where I would like to use the fields from a user generated view. So let's say the user create a view with 3 fields: Class, Subject, & Nid. I run `views_get_view_result()` on the view, but that returns entire node objects.

How do I get the simple values like this: `{"1 grade", "English", 54}` as an array perhaps?

Remember I don't know beforehand what fields have been selected by the user, so I have to get the raw data like that, or be able to see what fields have been selected and in what order.

Just did a print\_r on $view-\>result\[1\].

```
stdClass Object
(
    [node_title] => "The Trial" by Franz Kafka
    [nid] => 52
    [node_created] => 1334720754
    [field_data_field_subject_node_entity_type] => node
    [_field_data] => Array
        (
            [nid] => Array
                (
                    [entity_type] => node
                    [entity] => stdClass Object
                        (
                            [vid] => 52
                            [uid] => 1
                            [title] => "The Trial" by Franz Kafka
                            [log] =>
                            [status] => 1
                            [comment] => 2
                            [promote] => 1
                            [sticky] => 0
                            [nid] => 52
                            [type] => assignment
                            [language] => und
                            [created] => 1334720754
                            [changed] => 1334733704
                            [tnid] => 0
                            [translate] => 0
                            [revision_timestamp] => 1334733704
                            [revision_uid] => 1
                            [body] => Array
                                (
                                    [und] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [value] => Many attempts have been made to examine Kafka's legal background and the role of law in his fiction. These attempts remain relatively few in number compared to the vast collection of literature devoted to the study of his life and works, and marginal to legal scholarship. Mainstream studies of Kafka's works normally present his fiction as an engagement with absurdity, a critique of bureaucracy or a search for redemption, failing to account for the images of law and legality which constitute an important part of "the horizon of meaning" in his fiction.

However, James Hawes argues many of Kafka's descriptions of the legal proceedings in The Trial – metaphysical, absurd, bewildering and "Kafkaesque" as they might appear – are, in fact, based on accurate and informed (although exaggerated) descriptions of German and Austrian criminal proceedings of the time, not well understood by many British or American people, who were familiar with an adversarial rather than inquisitorial system of justice. Similarly, the requirement for the traveller to register with the authorities in The Castle to stay a night seems repressive and odd to Britons and Americans, whereas in the present-day Germans (and most continental Europeans) are required to register their address (and hoteliers their guests) with the local authorities.

The significance of law in Kafka's fiction is also neglected within legal scholarship, for as Richard Posner pointed out, most lawyers do not consider writings about law in the form of fiction of any relevance to the understanding or the practice of law. Regardless of the concerns of mainstream studies of Kafka with redemption and absurdity, and what jurists such as Judge Posner might think relevant to law and legal practice, the fact remains that Kafka was an insurance lawyer who, besides being involved in litigation, was also "keenly aware of the legal debates of his day" (Ziolkowski, 2003, p. 224).

In a recent study which uses Kafka's office writings as its point of departure, Reza Banakar argues that "legal images in Kafka's fiction are worthy of examination, not only because of their bewildering, enigmatic, bizarre, profane and alienating effects, or because of the deeper theological or existential meaning they suggest, but also as a particular concept of law and legality which operates paradoxically as an integral part of the human condition under modernity. To explore this point Kafka's conception of law is placed in the context of his overall writing as a search for Heimat which takes us beyond the instrumental understanding of law advocated by various schools of legal positivism and allows us to grasp law as a form of experience"
                                                    [summary] =>
                                                    [format] => filtered_html
                                                    [safe_value] =>

Many attempts have been made to examine Kafka's legal background and the role of law in his fiction. These attempts remain relatively few in number compared to the vast collection of literature devoted to the study of his life and works, and marginal to legal scholarship. Mainstream studies of Kafka's works normally present his fiction as an engagement with absurdity, a critique of bureaucracy or a search for redemption, failing to account for the images of law and legality which constitute an important part of "the horizon of meaning" in his fiction.

However, James Hawes argues many of Kafka's descriptions of the legal proceedings in The Trial – metaphysical, absurd, bewildering and "Kafkaesque" as they might appear – are, in fact, based on accurate and informed (although exaggerated) descriptions of German and Austrian criminal proceedings of the time, not well understood by many British or American people, who were familiar with an adversarial rather than inquisitorial system of justice. Similarly, the requirement for the traveller to register with the authorities in The Castle to stay a night seems repressive and odd to Britons and Americans, whereas in the present-day Germans (and most continental Europeans) are required to register their address (and hoteliers their guests) with the local authorities.

The significance of law in Kafka's fiction is also neglected within legal scholarship, for as Richard Posner pointed out, most lawyers do not consider writings about law in the form of fiction of any relevance to the understanding or the practice of law. Regardless of the concerns of mainstream studies of Kafka with redemption and absurdity, and what jurists such as Judge Posner might think relevant to law and legal practice, the fact remains that Kafka was an insurance lawyer who, besides being involved in litigation, was also "keenly aware of the legal debates of his day" (Ziolkowski, 2003, p. 224).

In a recent study which uses Kafka's office writings as its point of departure, Reza Banakar argues that "legal images in Kafka's fiction are worthy of examination, not only because of their bewildering, enigmatic, bizarre, profane and alienating effects, or because of the deeper theological or existential meaning they suggest, but also as a particular concept of law and legality which operates paradoxically as an integral part of the human condition under modernity. To explore this point Kafka's conception of law is placed in the context of his overall writing as a search for Heimat which takes us beyond the instrumental understanding of law advocated by various schools of legal positivism and allows us to grasp law as a form of experience"

                                                    [safe_summary] =>
                                                )

                                        )

                                )

                            [field_files] => Array
                                (
                                    [und] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [fid] => 16
                                                    [display] => 1
                                                    [description] =>
                                                    [uid] => 1
                                                    [filename] => Franz Kafka - The Trial.pdf
                                                    [uri] => public://Franz Kafka - The Trial.pdf
                                                    [filemime] => application/pdf
                                                    [filesize] => 977591
                                                    [status] => 1
                                                    [timestamp] => 1334720754
                                                    [rdf_mapping] => Array
                                                        (
                                                        )

                                                )

                                        )

                                )

                            [field_submissions] => Array
                                (
                                )

                            [field_class] => Array
                                (
                                    [und] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [value] => 9B
                                                )

                                        )

                                )

                            [field_subject] => Array
                                (
                                    [und] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [value] => English
                                                )

                                        )

                                )

                            [rdf_mapping] => Array
                                (
                                    [rdftype] => Array
                                        (
                                            [0] => sioc:Item
                                            [1] => foaf:Document
                                        )

                                    [title] => Array
                                        (
                                            [predicates] => Array
                                                (
                                                    [0] => dc:title
                                                )

                                        )

                                    [created] => Array
                                        (
                                            [predicates] => Array
                                                (
                                                    [0] => dc:date
                                                    [1] => dc:created
                                                )

                                            [datatype] => xsd:dateTime
                                            [callback] => date_iso8601
                                        )

                                    [changed] => Array
                                        (
                                            [predicates] => Array
                                                (
                                                    [0] => dc:modified
                                                )

                                            [datatype] => xsd:dateTime
                                            [callback] => date_iso8601
                                        )

                                    [body] => Array
                                        (
                                            [predicates] => Array
                                                (
                                                    [0] => content:encoded
                                                )

                                        )

                                    [uid] => Array
                                        (
                                            [predicates] => Array
                                                (
                                                    [0] => sioc:has_creator
                                                )

                                            [type] => rel
                                        )

                                    [name] => Array
                                        (
                                            [predicates] => Array
                                                (
                                                    [0] => foaf:name
                                                )

                                        )

                                    [comment_count] => Array
                                        (
                                            [predicates] => Array
                                                (
                                                    [0] => sioc:num_replies
                                                )

                                            [datatype] => xsd:integer
                                        )

                                    [last_activity] => Array
                                        (
                                            [predicates] => Array
                                                (
                                                    [0] => sioc:last_activity_date
                                                )

                                            [datatype] => xsd:dateTime
                                            [callback] => date_iso8601
                                        )

                                )

                            [cid] => 0
                            [last_comment_timestamp] => 1334720754
                            [last_comment_name] =>
                            [last_comment_uid] => 1
                            [comment_count] => 0
                            [name] => admin
                            [picture] => 0
                            [data] => a:1:{s:7:"overlay";i:1;}
                        )

                )

        )

    [field_field_subject] => Array
        (
            [0] => Array
                (
                    [rendered] => Array
                        (
                            [#markup] => English
                            [#access] => 1
                        )

                    [raw] => Array
                        (
                            [value] => English
                        )

                )

        )

)

```

In the view I have selected:

```
Content: Title
Content: Subject (Subject)
Content: Nid (Nid)

```

Solution:

```
    $view_fields = $view->style_plugin->options['columns'];
    foreach ($view->result as $index => $row) {
        $view->row_index = $index;

        foreach($view_fields as $field){
            $field_output = $view->style_plugin->get_field_value($index, $field);
            error_log($field.": ".$field_output."\n", 3, "debug.log");
        }
    }

```

Instead of the error\_log build an array instead or whatever you need

# Answer
> 6 votes
EDIT:

Sorry, didn't quite read this exactly. `$view=views_get_view_result()` returns that result array. If you want them in array form, you can cast them, eg, `$row0=(array) $view[0];` and now you would have a keyed array of the views results for the first row along with some views housekeeping information like the nid if present, etc. I should also mention that at times when dealing with nodes, Views only returns the id, or nid, and it's in the render stage that this is turned into a link or body, etc.

ORIGINAL:

Within the `$view` object, you have `$view->result` which is an array of values, eg, `$view->result[0]` contains all the raw data for the first row, `$view->result[1]` contains all the raw data for the second row, etc.

MORE INFORMATION:

I created a view here that has my 'tagline' field in it, and the result looks like this:

```
    Array
    (
        [0] => stdClass Object
            (
                [node_data_field_tagline_field_tagline_value] => The Dirty Dirty Duval
                [node_type] => area
                [nid] => 1
                [node_vid] => 1
            )

        [1] => stdClass Object
            (
                [node_data_field_tagline_field_tagline_value] => Atlanta GA is in the house...
                [node_type] => area
                [nid] => 18
                [node_vid] => 18
            )

```

so I see my tagline field up in there (along with other views housekeeping info) so I am not sure what you are seeing unless your view row style is node instead of fields, but then all you would see is the nid at this point...

# Answer
> 3 votes
This probably piggybacks on the Jimajamma's post above, but this was some code that I pulled from somewhere (I forget where, it was in the Views queue) for dealing with a similar kind of situation.

```
$view = views_get_view('view_machine_name');
$view->set_display('view_display_name');
$view->pre_execute();
$view->execute('view_display_name');
foreach ($view->result as $result) {
  // do something with your results
  // print_r() or dsm() from the devel module would be helpful here.
  // dsm($result);
}

```

---
Tags: 7, views
---


# Question
Title: Drupal 7- "Users who bought this also bought that" module
Does anyone know of a module for Drupal 7 that provides a "users who bought this also bought that" feature?

I found Ubercart Views but it only works for D6, not D7.

My site uses Drupal 7 and Ubercart.

# Answer
Check this out, a module that does the same for you: Recommender API.

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

> ... provides a set of easy-to-use, fully-documented APIs and computational tools to help you write Drupal content recommendation sub-modules.
>
> Modules built with Recommender API
>
> * Browsing History Recommender: "Users who browsed this node also browsed"; personalized node recommendation based on users' browsing history.
> * Commerce Recommender: Personalized products recommendations based on customers purchasing history.
> * OG Similar groups module: "Users who joined this group also joined"
> * Ubercart Products Recommender: "Customers who ordered this also ordered" and personalized recommendation "Recommended for you"
> * Fivestar Recommender: User-to-user and Item-to-item (used in Amazon.com) recommendations for Fivestar module.
> * Points Voting Recommender: User-to-user and Item-to-item (used in Amazon.com) recommendations for Up/Down and Plus 1 modules.
> * Flag Recommender: Recommender for the Flag module.
> 0 votes

# Answer
There are two modules available for Ubercart; the first one is Ubercart Products Recommender which provides a View for:

> Users who ordered this product also ordered.

The second is easyrec for ubercart, which provides a block called:

> other users also bought

Either one should be fine for what you want, and both have a stable Drupal 7 version available.
> 1 votes

---
Tags: 7, ubercart
---


# Question
Title: What's the difference between the "Mime Mail" and "Mail MIME" modules?
There appear to be two ways of sending HTML e-mail using Drupal:

Mime Mail has significantly more installs, but it depends on Mailsystem, which is maintained by the maintainer of Mail MIME.

What is the difference between these modules? Is one a fork of the other?

# Answer
> 3 votes
There are many more than 2 ways to send mail with Drupal. But, the modules you are showing are not for *sending* mail at all, they are there only to encode / decode mime content.

The problem you are facing is common in Drupal land: Developers re-inventing the wheel. You will often bump into modules that do similar tasks.

Mime mail has more support, is much more active, and has more features, (it can decode incoming html mail if I understood correctly). I would go for this over Mail Mime with HTML Mail Pear class.

As for *sending* the emails, I can **strongly** recommend SMTP Authentication module if you don't want to use Drupal's built-in mechanism.

Hope this helps, cheers!

# Answer
> 2 votes
Mail MIME just provides integration with the PEAR Mail\_MIME class to encode and decode Mime Mails. Other modules can then integrate with it, for example HTML Mail to use it to send Mails.

Mime Mail on the other hand, is the same as those two modules combined, it contains both the functions to deal with mime encoded mails and exposes itself to Drupal so that mails from other modules are sent with it.

Neither of these modules actually allow you, as a user, to send mails, they deal with mails sent by other modules. There is a small exception there, namely that Mime Mail comes with Rules integration that allows to send HTML formatted mails.

# Answer
> 0 votes
First, I overlooked this when I originally asked my question, but there is a post on Drupal.org by the Mail MIME maintainer describing the differences between the two modules.

I spent the last few hours evaluating both the modules and here are my thoughts:

* Mail MIME is much more modular than Mime Mail. The maintainer has created a large number of modules that one can pick and choose from to get the features required. Personally, I prefer this approach.
* However, in my case there was no easy way to install the Pear classes on my server, so I ended up going with Mime Mail.

---
Tags: emails
---


# Question
Title: Update to Commerce shipping 2.x breaks site with WSOD
Implementing shipping 2 is becoming a bit more troublesome than i had anticipated.

Right now, I am getting the following error on a White Screen of Death when I install commerce shipping 7.x-2.0-beta1

Fatal error: Call to undefined function commerce\_shipping\_services() in /var/www/html/nidadev/sites/all/modules/contrib/commerce\_shipping/commerce\_shipping.rules\_defaults.inc on line 44

I am not sure what to make of this Is there something obvious that I am missing?

Is there some sort of update to rules I need to perform?

The problem goes away when I go back down to Shipping 1

This issue is standing in our way of working with Tim Rohaly on the Fed Ex Commerce module, so the quicker we fix this, the quicker he can get his code out to the community.

Thanks for any help

# Answer
> 2 votes
The 7.x-2 branch of Commerce Shipping is only in beta, it's not ready for production use yet (but you probably already know that).

The release notes for the branch warn you not to install this on a site that currently uses v1.x of the shipping module:

> **Note: If you are currently using Shipping 1.x on a live site, do not attempt an update on your live site. See the roadmap below for more information.**

(emphasis theirs, not mine!)

I would heed that warning if I were you :)

# Answer
> 1 votes
I think I figured out part of the problem - We did not have the payment module enabled and that was causing some issues. It seems that Shipping has a dependency on Payment. Since our site distributes free publications, we were not using the payment module.

---
Tags: commerce
---


# Question
Title: Creating a list of child taxonomy terms with Views
I have a a taxonomy with 2 levels:

* Parent 1
    + Child 1
    + Child 2
    + Child 3
* Parent 2
    + Child 4
    + Child 5

When I am on `/taxonomy/term/parent1` I want to display a view of a list of child terms in a block:

* Child 1
* Child 2
* Child 3

I have been through similar questions on this site, some with accepted answers, but it did not help me. Here is my Views settings.

For now, it displays the term name for each node containing the parent or child term, causing a lot of duplicates.

* parent 1
* parent 1
* child 1
* child 1
* child 2
* child 2

I'm using Views 3 and Drupal 7 If someone has a hint to share it would help me a lot :) Thanks in advance

# Answer
> 4 votes
I may be wrong but I guess you have created a View of type 'content' while your intention is to list 'taxonomy terms' (I understand that Child # are taxonomy terms). The type of a View is indicated by the label within parenthesis, above the top of the admin lightbox. If my assumption is right, you would want to create a new View of type 'taxonomy term'.

# Answer
> 1 votes
I think you may be looking for the Taxonomy menu module. I don't know if it will show the subtree of the taxonomy when visiting parents, but the module page says that it integrates with Views.

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


# Question
Title: How to export a view to module file with CTool Bulk Export module?
I am trying to export some views to module file. It could be done by Views Bulk Export module, but it looks like that Views Bulk Export no longer exists for Views 3??

It (views\_export.module) left a node says

```
<?php
// This module has been removed, and this note is left here to ensure
// that users who don't delete their directory before upgrading have
// the code removed and to let people looking for it to know to use
// the CTools bulk export module instead.

```

So how can I export my view now?

# Answer
I figured it out.

@kiamlaluno, the 'export' link in your answer (screenshot) does not require Chaos tool, it comes out of box of views. And it only exports view code, to module file.

To export to module, goto admin/structure/bulk-export, then tick views,
> 3 votes

# Answer
In the page listing all the enable views (admin/structure/views) click on the arrow that you see in the "operations" column; once you click it, you will find the "export" menu item.

The menu item appears after you enabled the Bulk Export module.

The Chaos tool suite module is required from the Views module.
> 0 votes

---
Tags: 7, views, chaos-tool-suite, importing-exporting
---


title: Unknown error: Function eregi_replace()

text:
# Question
Title: Unknown error: Function eregi_replace()
i am using pressflow 6.25 there is a flie views-view-field--events--block--field-date-value.tpl.php in template theme directory

in line 5

```
$create_date = explode(' ',eregi_replace('<[^>]*>','', $output));

```

in my web site show this error Unknown error: Function eregi\_replace() is deprecated in include() (line 5 of C:\xampp\htdocs\fiddle\sites\all\themes\sttheme\fiddle\templates\views-view-field--events--block--field-date-value.tpl.php). how can i solve my problem?

# Answer
There may be a problem with the PHP version.

See HERE

> This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.
> 1 votes

---
Tags: theming, views
---


# Question
Title: PDO exception for Entity Reference Module
I have 2 custom content type 'Movie' and 'Director';

In the Movie type there is a field that refers to some Director type.

Now , when i try to create a Movie content type it generates the following error.But the site admin can successfully create Movies.

```
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'nid' in where clause is ambiguous: SELECT DISTINCT node.nid AS entity_id, node.vid AS revision_id, node.type AS bundle, :entity_type AS entity_type FROM {node} node INNER JOIN {node_access} na ON na.nid = node.nid WHERE (nid IN (:db_condition_placeholder_0)) AND (type IN (:db_condition_placeholder_1)) AND(( (na.gid = :db_condition_placeholder_2) AND (na.realm = :db_condition_placeholder_3) )OR( (na.gid = :db_condition_placeholder_4) AND (na.realm = :db_condition_placeholder_5) ))AND (na.grant_view >= :db_condition_placeholder_6) ; Array ( [:db_condition_placeholder_0] => 2 [:db_condition_placeholder_1] => writer [:db_condition_placeholder_2] => 0 [:db_condition_placeholder_3] => all [:db_condition_placeholder_4] => 32 [:db_condition_placeholder_5] => user_relationship_node_access_author [:db_condition_placeholder_6] => 1 [:entity_type] => node ) in EntityFieldQuery->execute() (line 1136 of /home/mysite/public_html/includes/entity.inc).

```

I solved the problem .In /public\_html/includes/entity.inc I changed

```
$this->addCondition($select_query,$sql_field, $this->entityConditions['entity_id']);

```

to

```
$this->addCondition($select_query,"$base_table.".$sql_field, $this->entityConditions['entity_id']);

```

this statement should be somewhere near of line 1207

# Answer
The reason is here:

```
[…] ON na.nid = node.nid WHERE (nid IN (:db_condition_placeholder_0)) […]

```

Can you see the `nid` after the `WHERE` keyword, it has no identifier and therefore PDO does not know how to handle it. You must prefix it with the correct table name (or assigned shortcut). Either `na.nid` or `node.nid` should do the trick.
> 2 votes

---
Tags: 7, entities
---


# Question
Title: nusoap web service available to .net from Drupal 7 but not from Drupal 6
I have a Drupal 6 module that provides a web service using nusoap. I can access the service with php but service can't be accessed from .net application. If I however use the same code to provide web service in Drupal 7 it can be accessed from .net application.

Here is the function providing the web service:

```
function _provide_nusoap_server(){

  // Pull in the NuSOAP code
  require_once('lib/nusoap.php');

  // Create the server instance
  $server = new soap_server();

  global $base_url;

  // Initialize WSDL support
  $server->configureWSDL('mynamespace', 'urn:mynamespace', $base_url.'/mysoap');

  // tämä paluuarvoille
  $server->wsdl->addComplexType(
    'stringArray',
    'complexType',
    'array',
    '',
    'SOAP-ENC:Array',
    array(),
    array(
        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]')
    ),
    'xsd:string'
  );

  // Register the method
  $server->register('mysoap_addModifyProduct',      // method name
      array(
      'salasana' => 'xsd:string',
      'rekkariId' => 'xsd:int',                     // to identify event in rekisteri. Later on id can be used to update or delete certain event
      //'op' => 'xsd:string',                       // op should be 'insert' or 'update'
      'tuotenimi' => 'xsd:string',
  ),
      array(
        'ret' => 'tns:stringArray',
      ),
      'urn:mynamespace',                      // namespace
      'urn:mynamespace#mysoap_addModifyProduct',      // soapaction
      'rpc',                                     // style
      'encoded',                                 // use
      'Adds stuff to Drupal database'            // documentation
  );

  // Use the request to (try to) invoke the service
  global $HTTP_RAW_POST_DATA;
  $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
  $server->service($HTTP_RAW_POST_DATA);

}

```

And here is the wsdl-file:

```
<?xml version="1.0" encoding="ISO-8859-1"?>
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:mynamespace" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:mynamespace">
<types>
<xsd:schema targetNamespace="urn:mynamespace"
>
 <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
 <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
 <xsd:complexType name="stringArray">
  <xsd:complexContent>
   <xsd:restriction base="SOAP-ENC:Array">
    <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:string[]"/>
   </xsd:restriction>

  </xsd:complexContent>
 </xsd:complexType>
</xsd:schema>
</types>
<message name="mysoap_addModifyProductRequest">
  <part name="salasana" type="xsd:string" />
  <part name="rekkariId" type="xsd:int" />
  <part name="tuotenimi" type="xsd:string" /></message>
<message name="mysoap_addModifyProductResponse">
  <part name="ret" type="tns:stringArray" /></message>
<portType name="mynamespacePortType">

  <operation name="mysoap_addModifyProduct">
    <documentation>Adds stuff to Drupal database</documentation>
    <input message="tns:mysoap_addModifyProductRequest"/>
    <output message="tns:mysoap_addModifyProductResponse"/>
  </operation>
</portType>
<binding name="mynamespaceBinding" type="tns:mynamespacePortType">
  <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
  <operation name="mysoap_addModifyProduct">

    <soap:operation soapAction="urn:mynamespace#mysoap_addModifyProduct" style="rpc"/>
    <input><soap:body use="encoded" namespace="urn:mynamespace" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
    <output><soap:body use="encoded" namespace="urn:mynamespace" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
  </operation>
</binding>
<service name="mynamespace">
  <port name="mynamespacePort" binding="tns:mynamespaceBinding">
    <soap:address location="[the url of the service]/mysoap"/>
  </port>
</service>

</definitions>

```

# Answer
Workaround for this problem is to save the wsdl -file as a physical file to the web server. The con here is that every time the service changes the wsdl-file has to be saved again.

An alternative and maybe better idea would be to use the services module http://drupal.org/project/services
> 1 votes

---
Tags: services
---


# Question
Title: How can I limit the days returned in the date module to today's and future dates only?
I have the Date module installed on Drupal 7 (version 7.x-2.5) and I am attempting to disable the selection of past dates within the date popup.

```
$form['ratesDateSelect'] = array(
    '#title' => 'Arrival Date',
    '#type' => 'date_popup',
    '#default_value' => '',
    '#size' => 21,
    '#maxlength' => 100,
    '#date_flexible' => 0,
    '#date_year_range' => (date('Y')) . ':+5',
    '#attributes' => array('autocomplete' =>'off','readonly' => 'readonly'),
    '#description' => '',
    '#value' => array('date' => $date),
    '#date_format' => 'D d M Y',
    '#required' => FALSE,
);

```

I have limited the popup to return this year and five years into the future, but I also need to restrict it so that people cannot select past days.

I have managed to do this in another project using pure javascript, using the datepicker param: `minDate: 0`

# Answer
> 1 votes
I worked this out shortly after posting, but it required a little bit of "hacking" of the date module.

To get this working I added a new '#settings' variable onto the date\_popup type so it would look like ..

```
$form['ratesDateSelect'] = array(
'#title' => 'Arrival Date',
'#type' => 'date_popup',
'#default_value' => '',
'#size' => 21,
'#maxlength' => 100,
'#date_flexible' => 0,
'#date_year_range' => (date('Y')) . ':+5',
'#attributes' => array('autocomplete' =>'off','readonly' => 'readonly'),
'#description' => '',
'#value' => array('date' => $date),
'#date_format' => 'D d M Y',
'#required' => FALSE,
'#settings' => array('minDate'=>'0'),
);

```

on the form element and then I added this code into date\_popup.module (around line 336) after the settings array.

```
$user_settings = $element['#settings'];
foreach($user_settings as $setting_key => $setting_val) {
    $settings[$setting_key] = $setting_val;
}

```

This allowed me to inject javascript settings/options so that I can restrict the dates returned from now into the future.

Ryan

---
Tags: datetime
---


# Question
Title: creating custom content comprising both static and dynamic data
I need to create certain pages in my site, some of them relatively simple layout with mostly static content like Contact Us and About Us which I've created as Content Type Page (node). Similarly other content types have a relatively complex layout and content composed of both static and dynamic data. For example a page with some fancy header images a couple of paragraphs (static) and a list of URLs for contents belonging to a specific category (dynamic). Some of the pages have their own flyout menu (which i use Nice menus) and I create a new menu element and add the block for that specific page which I feel is definitely not the best method to go about this. My site is content heavy and there are many such pages and so its not possible for me to code the URLs in the content body in static manner.

I'm relatively inexperienced with contributed modules like Views and Panels but tried to get some ideas watching webcasts. But it seems that they are very vast topics and I couldn't find what I required from them. Hence request any of the members who've faced similar circumstances to share their experience and provide the methods/implementations or even modules they tried for this.

# Answer
> 2 votes
Panels and Views is the way to go. However, this question is way too broad; in fact, a book could answer it. That book is *Drupal's Building Blocks: Quickly Building Web Sites with CCK, Views, and Panels* by Earl and Lynette Miles.

Also see the Views tag wiki on this site, which links to Node One's excellent screencast.

---
Tags: 6, nodes
---


title: Save PDF file using webform2pdf

text:
# Question
Title: Save PDF file using webform2pdf
I am using Drupal 7.12 and Webform2PDF 7.x-3.0. Is there any feature to save the PDF file to server using this module? Or how can I do this with this module? Or is there any other module ?

# Answer
No you cannot save it on the server. One way would be to create your own code to grab the pdf with a tool like cURL and save it to the server. You could trigger your code to run every time a webform is submitted throught Rules and Webform Rules. You could issue a feature request to the module developer in case he wants add this fuctionality.

There is also this module: Fill PDF that does what you require. It is quite harder to get it to work with Webforms since you need to build your own pdf form template.
> 1 votes

# Answer
Have you read the documentation ? It states

> The Webform2PDF Drupal module is an extension of the Webform module. It can be used to generate PDF document from the results of a form. The generated PDF document can be attached to the form summary e-mail sent by Webform module, or **it can be downloaded from the /Results/ page.**

As it can be downloaded it should be in your server. You can access it by typing the URL for sure.

See Webform2PDF Module Users' Guide
> -2 votes

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


title: Content and data migration module?

text:
# Question
Title: Content and data migration module?
I'm looking for a content and data migration module.

Which are commonly used?

# Answer
Try

Backup and Migrate

Migrate

**Related projects**

Migrate Extras

Migrate Drupal
> 0 votes

# Answer
It depends on what you're looking for, but unless you are working on an enterprise-level site, my experience is that it will be faster to do the migration manually without using helper modules.

While the Feeds and Migrate modules are probably the most common approaches, they are difficult to configure and manage due to the large number of possible use cases that must be dealt with. For example, if you look at the backers of the Migrate module, the credits include PayPal, the World Economic Forum, Warner Music, and other similarly large organizations.
> 0 votes

# Answer
I learned the hard way what Patrick kenny is saying. I spent 1 day finding modules, trying to configure them and I was not able to do it. I had 500 + records which I needed to create drupal nodes. These were nodes with custom fields and file attachments. I created a database and populated it with the raw data then I wrote a script to get each row and add it to drupal database. I placed the pdf file attachements in the required folder.It took me only two hours to do all this. Script is as follows.

```
 //connect database with raw data
$pub_link = mysql_connect('127.0.0.1', 'root', 'root');
if (!$pub_link) {
    die('Could not connect: ' . mysql_error());
}

//connect drupal database
$drupal_link = mysql_connect('127.0.0.1', 'root', 'root');
if (!$drupal_link) {
    die('Could not connect: ' . mysql_error());
}

// get each row

$number = 1;
while ($number < 576) {
//get the content
    mysql_select_db("raw_database_name", $pub_link);
    $pr_result = mysql_query('SELECT * FROM pub WHERE id =' . $number);
    $pr_row = mysql_fetch_assoc($pr_result);

    $pub_id_one = $pr_row['id'];
    $pub_id = mysql_real_escape_string($pub_id_one);
    $pub_author_one = $pr_row['author'];
    $pub_author = mysql_real_escape_string($pub_author_one);
    $pub_title_one = $pr_row['title'];
    $pub_title = mysql_real_escape_string($pub_title_one);
    $pub_ab_one = $pr_row['ab'];
    $pub_ab = mysql_real_escape_string($pub_ab_one);
    $pub_year = $pr_row['year'];
    $pub_pubid = $pr_row['pubid'];

//insert the content
    mysql_select_db("drupal_database_name", $drupal_link);
//get the existing node id +1 for next nodeid to insert
    $result = mysql_query('SELECT MAX(nid)+1 FROM node');
    $nid = mysql_result($result, 0);
//get the existing node_revision id +1 for new node_revision id
    $result = mysql_query('SELECT MAX(vid)+1 FROM node_revisions');
    $vid = mysql_result($result, 0);
//get the existing fid for files +1 for new fid
    $result = mysql_query('SELECT MAX(fid)+1 FROM files');
    $fid = mysql_result($result, 0);
//check if fields are not empty run the script to enter the data.
if($pub_title !="" and $pub_ab != ""){
    mysql_query('INSERT INTO  node_revisions  (vid, nid, uid, title, body, teaser, timestamp, format)  VALUES (\'' . $vid . '\', \'' . $nid . '\', 1, \'' . $pub_title . '\', \' \', \'\', now(), \'2\');');
    mysql_query('INSERT INTO content_type_name (vid, nid, field_field_name_value, field_field_name_format, field_pub_date_value, field_pub_file_fid, field_pub_file_list, field_pub_type_value, field_pub_sri_value, field_pub_note_value, field_pub_note_format) VALUES(\'' . $vid . '\', \'' . $nid . '\', \'' . $pub_ab . '\', 2 , \'' . $pub_year .'T00:00:00\', \''.$fid.'\', \'1\', "journal", 1, \''.$pub_author.'\', 2);');
    mysql_query('INSERT INTO node (  vid, nid, type, title, uid, status, created) VALUES (\'' . $vid . '\', \'' . $nid . '\', \'publication\', \'' . $pub_title . '\', 1, 0, now());');
    $query_four = 'INSERT INTO files (fid, uid, filename, filepath, filemime, filesize, status, timestamp) VALUES (\'' . $fid . '\', \'1\', \'' . $pub_pubid.'.pdf \', \'sites/default/files/uploads/publications/pdf/' . $pub_pubid.'.pdf\', \'application/pdf\', \'160000\', \'1\', \'1331410502\')';

    mysql_query($query_four);
mysql_query('INSERT INTO workflow_node (  nid, sid, uid, stamp) VALUES ('.$nid.', "8", "1", "1327964040");');
}else{
    print $number."not set";
}
print'</br>';
    $number++;
}
print 'Done go and check it now  >>> ';
mysql_close($pub_link);

mysql_close($drupal_link);

```
> 0 votes

# Answer
At least migrate has the option to import a CSV or XML file.

If you have the option to export the file, then importing will not be more difficult than the code example here.
> 0 votes

---
Tags: 7, nodes
---


# Question
Title: Display user role with the Advanced forum module
I use the Advanced forum and the Author pane modules.

I want to show the role the user has, as in the following screenshot.

I looked everywhere, but I have not found a real solution.

NB: I'm not a PHP expert.

# Answer
> 1 votes
In advanced forum module edit advf-author-pane.tpl.php in your chosen forum theme and and below `print $account_name;` you'll need a similar line like `print implode(', ', $account['roles'];`. It should be wrapped in some HTML tag (span, p, ...) so you can style its display.

---
Tags: 7, users
---


title: Autofill fields for logged-in users

text:
# Question
Title: Autofill fields for logged-in users
I have a content type with several fields; one field defines a postal address. If new content is created and the user has logged in, this field should be automatically filled with the address defined in the user profile. If a guest is creating new content, he will have to fill in the address by himself.

How I can achieve this? Are there any modules?

# Answer
The Token module is a start, but it alone won't allow you to pre-fill the content. By default it will provide a token for the value of every field defined in the user profile.
> 1 votes

---
Tags: 7, entities
---


# Question
Title: How can I identify for which core release a database is?
I have been sent site files and a database for a website to review but have had trouble loading it up. The core and contributed modules are all D7, but when I import the database and run a page on the browser I get a message,

> PDOException: SQLSTATE\[42S02\]: Base table or view not found: 1146 Table 'example.semaphore' doesn't exist: SELECT expire, value FROM {semaphore} WHERE name = :name; Array ( \[:name\] =\> variable\_init ) in lock\_may\_be\_available() (line 167 of example.com/includes/lock.inc).

I suspect this means that the database I have been given is a D6 one, but need to confirm this. Is the version declared anywhere, or is the absence of the semaphore the evidence I need?

# Answer
In Drupal 6 the node revisions are in `{node_revisions}`, and in Drupal 7 the node revisions are in `{node_revision}`. So, you can just check which table exists. There are some structural differences with the tables, too. For example there is a `status` column in D7, but not in D6.
> 4 votes

---
Tags: database
---


title: Image upload fails

text:
# Question
Title: Image upload fails
I am running drupal 7 on Arch Linux with PHP 5.3, nginx, and php-fpm. I can't upload any image, and I get the following error:

> An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size

php.ini, nginx.conf, and my.conf all have their respective directives set to allow 1GB. I get this error even if I try to upload 1KB.

Is there any workaround?

# Answer
> 3 votes
It was the nginx progress module. I disabled that, and everything now works.

---
Tags: 7, files
---


# Question
Title: How do I enable the WYSIWYG editor on fields?
I added couple of Text fields on a content type in Drupal; however, only the in-built "body" fields is WYSIWYG editor enabled. I am using FCKEditor as the WYSIWYG editor (installed under the Wysiwyg module).

How can I get WYSIWYG editor enabled on custom added field?

# Answer
> 8 votes
If you are not wanting to make every single textarea an editor, FCKeditor under Drupal lets you choose exactly which fields will be WYSIWYG editors .. you need to configure (.../admin/settings/fckeditor/default) for "include" mode and list the node-type field IDs. You can even specify a simple vs normal toolbar. Quite flexible

# Answer
> 9 votes
Click **Configure** of your CCK field and choose *Filtered text (user selects input format)* under **Text processing**. This configuration will show input format selection you need to choose. As long as you configure properly your WYSIWYG module the editor will show.

# Answer
> 3 votes
Yes! You can enable the WYSIWYG editor for every field that you add using CCK.

1. Add and enable the WYSIWYG module.
2. Configure the WYSIWYG module. You can use either CK EDITOR or FCK EDITOR.
3. Go to `Manage fields` under `Content types` and configure each field. Enable `filtered text` under `Text processing` of `Global settings`.

And you're done!

# Answer
> 2 votes
I kept searching for this issue for about 6 hours and finally i found the reason, for your custom textarea field you must add this line, to use the default input format (Full HTML):

`$form['format'] = filter_form();`

be careful if you use this form element inside fieldset you must include this fieldset:

`$form['donation-instructions']['format'] = filter_form();`

I hope this will help you

# Answer
> 1 votes
Don't forget to check on the **minimum rows** setting. This was my problem... I had my field's rows set to 3 and my FCKEditor settings to minimum rows 3. I changed field's rows to 4 and it worked!

It doesn't seem to matter if I've set the field to Plain Text or Filtered Text - it works either way.

# Answer
> 0 votes
OK. I figured it out. I went back and edited the field definition: Changed the "Text Processing" value to "Filtered Text" from "Plain Text" so that the user can select input type.

# Answer
> 0 votes
I went round and round with this and finally saw the fckeditor setting in the profile settings (NOT the global one) that reads

```
Minimum Rows [ 4 ]
FCKeditor will be triggered if the textarea has more rows than entered here. Enter '1' if you do not want to use this feature.

```

And of course, in my field setup I had rows set to 4, so the darn editor never kicks in! I changed my field rows to 5 and woop! there it is!

---
Tags: entities, wysiwyg
---