# Question
Title: Replicating an existing table-based form as PDF views output?
The Drupal 6 project I'm working on involves a custom content type with a bunch of different elements. I'm needing to replicate an existing form -- see screenshot.

Ultimately, I need to take the data stored in the CCK fields attached to this content type, and rebuild them as a table as per the screenshot. It then needs to be savable as a PDF.

It seems like there are two ways of doing PDF content of the nature I'm wanting:

* Views PDF -- cumbersome as heck to configure; requires manually positioning each field.
* Print -- I can't figure out how to directly access the CCK field variables through its $print object; consequently, I can't rebuild this as a table.

**How would one go about taking a lot of CCK fields, formatting them as a table, then making that PDF-able?**

Thanks.

*Edit:* To clarify, I have each row of, say, the FAC table stored as a row in the content type, through a compound/multifield module called "Flexifield". Data isn't stored as per the table; it's stored as a label ("level"), a decimal number and a boolean (above or below grade?). Another boolean toggles between Imperial and Metric for the entire sheet. The columns are generated by converting the number stored to either Imperial or Metric, depending on which the stored measurement is set as. Consequently, I'll ultimately need a way to tweak and restructure the data using PHP. This is why I can't, for instance, just tell the fields to display as a table.

# Answer
> 1 votes
I've done exactly this using the Print module.

Basically, you can build a view to display all of the cck data that need, and embed that view into a new page template which you've pointed to using hook\_theme from a custom module.

In my case, I created the template named property\_report.tpl.php and dropped all of the views that I wanted to pdf into that page. To print a pdf of any content on your website using the Print module, you just build the url like so:

www.example.com/printpdf/nid

# Answer
> 2 votes
Just a shot in the dark, but the Slickgrid module may be of help in this situation. Here is an excerpt about it from the module's project page:

> ... is an implementation of Michael Leibman's jquery slickgrid plugin, a lightening fast JavaScript grid/spreadsheet.
>
> It defines a slickgrid view style, so all data can be output as an editable grid.

# Answer
> 2 votes
You have the following options:

1. If you count with a predefined and fixed layout with always the same lines/columns, go create a PDF form and populate it with the Fill PDF module.
2. If the columns/lines are dynamically generated by your datas so I'll build an excel version of your datas with PHPExcel and use the save file as PDF. PHPExcel is quite simple to use and I think it's the easiest way to create tabular datas in PDF. Download it and have a look at the examples they're quite intuitives.

# Answer
> 1 votes
Certainly looks like some PDF modules are available ... if only in-development.

As an alternative, just fyi, we've done similar display & PDF export of formatted data within a CMS (not Drupal ... yet), where we've split the problem, moving high volume PDF generation to a Tomcat-hosted document processing app.

We query & format data for online display from within the CMS, taking advantage of query-building and display tools (like CCK?) then export data in any available, well-defined XML format. Next, external XSLT transform of the data to XSL-FO format, and finally conversion/generation of PDF using Apache FOP (http://xmlgraphics.apache.org/fop/#intro) running on a Tomcat servlet container (If you already have Solr running on Tomcat, it's convenient ...).

We've done this for transformation of flexible online medical record presentation to strictly-formatted PDF for print and electronic delivery. The fine-grained control of the XML -\> XSL-FO transformation, using Xalan, Xerces, etc. results in 'professional quality' output, and offloading to heavier-iron ensures we've never bogged down the CMS.

All depends on what your particular needs are.

---
Tags: views, theming, files
---


title: Views page themeing

text:
# Question
Title: Views page themeing
I am displaying some node content in a LightBox. The output needs to be customized so that the output is entirely bare with the exception of the actual views results. I want every surrounding div, menu, styling etc gone.

To achieve this, I created a custom views page called **views-view--Facilities-FloorPlans--page.tpl.php**. The out put is printed from a single line of php print code. I deleted everything except that line but I still get all the clutter I am trying to get rid of.

If you visit http://test2omniforce.co.uk/node/9 and click on the **enlarge floormap** link at the top right of either floormap please. You should see the enlarged floormap partly showing but surrounded by the website styling. How do I get rid of the excess markup?

**Also, if anyone can advise on how to expand the lightbox iFrame I would be grateful**

Thanks for your time.

# Answer
> 1 votes
The LightBox2 module might help you:

> The Lightbox2 module is a simple, unobtrusive script used to overlay images on the current page. It's a snap to setup and works on most modern browsers.
>
> The module places images above your current page, not within. This frees you from the constraints of the layout, particularly column widths. It keeps users on the same page. Clicking to view an image and then having to click the back button to return to your site is bad for continuity (and no fun!).

Alternatively, you can place this in node page (after setting your input filter to php) this code:

```
<?php
  echo theme('galleria_lightbox_link', arg(1), 800, 600,  "linktext");
?>

```

# Answer
> 0 votes
you need bypasses the theming system, one way can be use:

```
<?php die(); ?>

```

after output your content.

---
Tags: theming
---


title: Why isn't my mail sent?

text:
# Question
Title: Why isn't my mail sent?
I'm writing my first module that will show a form to users, who submit data that is sent as a mail to the people chosen from a list.

But there is an issue; the mail is not sent. What is the problem with my code?

```
function my_module_menu() {

$items['kategori'] = array(

'page callback' => 'my_module_kategori',

'access callback' => TRUE,

'type' => MENU_CALLBACK,

);

return $items;

}

function my_module_cmp($a, $b) {

  $a = (array) $a;

  $b = (array) $b;

  return strcmp($a['name'], $b['name']);

}

function my_module_kategori() {

// Show both the form and the title

return array(

    'form' => drupal_get_form('my_module_form'),

);

}

function my_module_form($form, &$form_state) {

// The form

$form['offert'] = array(

    '#title' => t('Skicka offertförfrågan till FLERA leverantörer samtidigt!'),

    '#type' => 'fieldset'

);

$form['offert']['question'] = array(

    '#type' => 'textarea',

    '#title' => t('Förfrågan'),

    '#default_value' =>  t('Skriv en förfrågan till dina utvalda leverantörer här....'),

    '#cols' => 50,

    '#rows' => 5,

    '#resizable' => FALSE

);

$form['offert']['name'] = array(

    '#type' => 'textfield',

    '#title' => t('Namn'),

    '#default_value' => t('Ditt namn....'),

    '#size' => 33,

    '#maxlength' => 64

);

$form['offert']['mail'] = array(

    '#type' => 'textfield',

    '#title' => t('Epost'),

    '#default_value' => t('Epost....'),

    '#size' => 14,

    '#maxlength' => 30

);

$form['offert']['compname'] = array(

    '#type' => 'textfield',

    '#title' => t('Företagsnamn'),

    '#default_value' => t('Företagsnamn....'),

    '#size' => 15,

    '#maxlength' => 64

);

$form['offert']['phone'] = array(

    '#type' => 'textfield',

    '#title' => t('Telefon'),

    '#default_value' => t('Telefon...'),

    '#size' => 14,

    '#maxlength' => 20

);

$form['offert']['comptype'] = array(

    '#type' => 'textfield',

    '#title' => t('Företagstyp'),

    '#default_value' => t('Typ av företag...'),

    '#size' => 15,

    '#maxlength' => 64

);

$form['offert']['submit'] = array(

    '#type' => 'submit',

    '#value' => t('Skicka')

);

// The html

$url = taxonomy_get_term_by_name(arg(1));

foreach($url as $term) {

    $tid = $term->tid;

}

$term = taxonomy_term_load($tid);

$name = taxonomy_term_title($term);

$terms = taxonomy_get_tree(3,0,1);

usort($terms, "my_module_cmp");

$counter = 0;

$result = taxonomy_select_nodes($tid);

$options = array();

foreach($result as $nid) {

    $form[$nid] = array(

        '#type' => 'fieldset',

    );

    $node = node_load($nid);

    $options[$nid] = $node->title;

    $phone = db_query("SELECT field_phone_value FROM {field_data_field_phone} WHERE entity_id=$nid")->fetchField();

    $body = db_query("SELECT body_value FROM {field_data_body} WHERE entity_id=$nid")->fetchField();

    // company image

    $form[$nid]['logo'] = array (

        '#markup' => '<div class="logo"><a href="/branschguiden/'.$nid.'"><img src="hdfsd01372593e5e.gif"></a></div>',

    );

    // title

    $form[$nid]['title'] = array (

        '#markup' => '<div class="title"><a href="/branschguiden/'.$nid.'">' . $node->title . '</a></div>',

    );

    // body

    $form[$nid]['body'] = array (

        '#markup' => '<div class="body"><a href="/branschguiden/'.$nid.'">' . $body . '</a></div>',

    );

    // phone

    $form[$nid]['phone'] = array (

        '#markup' => '<div class="phone"><img src="/sites/hrtorget/themes/hrtorget/images/phone-icon.png">'.$phone.'</div>',

    );

    // checkbox

    $form[$nid]['companies'] = array (

        '#type' => 'checkboxes',

        '#title' => t('Check it'),

        '#options' => $options,

        '#default_value' => array(),

    );

$counter++;

}

return $form;

}

function my_module_form_validate($form, &$form_state) {
// Validate that a company has been checked, at all

$valid_companies = $form_state['values']['companies'];

    if (!$valid_companies) {

    form_set_error('companies', 'Du har inte kryssat i något företag');

    }
}

function my_module_form_submit($form, &$form_state) {

// Send mail to each of the checked companies with the date from the form

$values = $form_state['values'];

$question = $form_state['values']['question'];

$name = $form_state['values']['name'];

$mail = $form_state['values']['mail'];

$compname = $form_state['values']['compname'];

$comptype = $form_state['values']['comptype'];

$phone = $form_state['values']['phone'];

$to = 'Ann array of all the checked companies email';

$from = 'test$tesfd.com';

$subject = 'Offer';

// Get the checkbox values from the form

//  $nids = array_keys($form_state['values']['company_wrapper']);

$nids = array_filter($form_state['values']['companies']);

// Print all the values from the form

drupal_set_message('<pre>'.print_r($form_state['values'], 1).'</pre>');

//  drupal_set_message('<pre>'.print_r($form_state['values']['company_wrapper'], 1).'</pre>');

drupal_set_message('<pre>'.print_r($form_state['values']['companies'], 1).'</pre>');

//  dpm($form_state['values']['company_wrapper']);

$body = 'Mesage text with a all the stuff from the form';

$message = array(

'body' => $body,

'subject' => $subject,

);

foreach ($nids as $nid) {

    // Get the node from nid

    $node = node_load($nid);

    // Get the author of that node

    $user = user_load(array('uid' => $node->uid));

    drupal_set_message(t('DEBUG nod:'.$nid.', användare: '.$user->name.','.$user->mail.'')); // DEBUG

    // Check if the mail has been sent and show a message based on that

    if (drupal_mail('my_module', 'branschguiden', $user->mail, language_default(), $message, $from, TRUE)) {

        drupal_set_message(t('Mail sent to %name',array('%name' => $user->name)));

    }

    // If no mail was sent.

    else {

        drupal_set_message(t('Error'));

    }

}

}

```

# Answer
> 2 votes
This is Drupal's example module mail code

```
$module = 'module_name';
$key = 'key';
$language = language_default();
$params = array();
$from = NULL;
$send = FALSE;
$message = drupal_mail($module, $key, $email, $language, $params, $from, $send);

$message['subject'] = $subject;
$message['body'] = array();
$message['body'][] = $line1;
$message['body'][] = $line2;

// Retrieve the responsible implementation for this message.
$system = drupal_mail_system($module, $key);

// Format the message body.
$message = $system->format($message);

// Send e-mail.
$message['result'] = $system->mail($message);

```

so `$system->mail($message)` actually sends the mail

# Answer
> 1 votes
change

```
if (drupal_mail('my_module', 'branschguiden', $user->mail, language_default(), $message, $from, TRUE)) {
    drupal_set_message(t('Mail sent to %name',array('%name' => $user->name)));
}
// If no mail was sent.
else {
    drupal_set_message(t('Error'));
}

```

to

```
 $result = drupal_mail('my_module', 'branschguiden', $user->mail, language_default(), $message, $from, TRUE))
  if ($result['result'] == TRUE) {
    drupal_set_message(t('Mail sent to %name',array('%name' => $user->name)));
  }
  else {
    drupal_set_message(t('There was a problem sending your message and it was not sent.'), 'error');
  }

```

---
Tags: forms, emails
---


# Question
Title: Drupal 7 main-menu - change item text if user logged in
I'm using Drupal 7's 'main-menu' to run my site's navigation. In my design, the links to join and sign in are in the main nav.

My join link goes to `/user/register` so it vanishes when a user is logged in. But my sign in is just `/user`, so that still shows up when a user is logged in. I want it to be replaced, or at least change the text to something like 'My Profile' instead of 'sign in'.

Ideas?

# Answer
Drupal 7 comes with a user menu as well, that contains these links that change automatically when logged in or not. Edit the user menu items and move them to the main menu.
> 1 votes

# Answer
change the sign in link to /user/login. It will now vanish when the user logs in. As for replacing it you would need to write some custom code
> 2 votes

---
Tags: 7, routes
---


title: D7: form input name array

text:
# Question
Title: D7: form input name array
need to build a form which has fields of type array. php normally would:

```
<input name="MyArray[0]" />
<input name="MyArray[test]" />
<input name="MyArray[1]" />

$array = $_POST['MyArray'];

```

already tried the following but is not input as an array:

```
$form["MyArray[1]"] = _d7_taxonomy_term_select($node_type->name, 2, $default_value);
$form["MyArray[2]"] = _d7_taxonomy_term_select($node_type->name, 2, $default_value);
$form["MyArray[3]"] = _d7_taxonomy_term_select($node_type->name, 2, $default_value);

```

someone help?

# Answer
> 4 votes
You need to specify them like this and set #tree to TRUE. Like this.

```
$form['MyArray']['#tree'] = TRUE;
$form["MyArray"][1] = _d7_taxonomy_term_select($node_type->name, 2, $default_value);
$form["MyArray"][2] = _d7_taxonomy_term_select($node_type->name, 2, $default_value);
$form["MyArray"][3] = _d7_taxonomy_term_select($node_type->name, 2, $default_value);

```

# Answer
> 0 votes
You have to use Drupals Form API to build forms. You can't just create them like you did in your example

Resources:

And probably the best one to get started

---
Tags: 7, forms
---


title: Managing Fields Tips

text:
# Question
Title: Managing Fields Tips
My database is getting way out of hand with respect to field\_data... and field\_revision...

is there any tricks in managing fields, seems really odd design method to me, I have over 100 tables just for fields alone.

I have tried to reuse the same field multiple time, but you cant use the same field more than once in the one content type.

ideally i would just have a field for each different data type and not every single field.

# Answer
How exactly is it going out of hand? Unless you have some kind of maximum number of tables you're allowed to have, 100 tables aren't really a problem. It's like this because this is the only way support multiple values per field.

The field storage system is pluggable, you can for example also use MongoDB to store your fields. The advantage of that is that it can store a complete content type in a single "document" and retrieve it with a single lookup/fetch. The downside is, you have to manage/maintain a second database server (and be able to so, which you aren't on shared webhosting for example).

See also The truth about field storage in Drupal 7. As linked from there, there is also a Per bundle storage project, but development stopped. Looks like nobody cares enough about this to maintain that module.
> 1 votes

---
Tags: entities, database
---


title: Multi-user/role testing, best practices

text:
# Question
Title: Multi-user/role testing, best practices
Am loving using Drupal 6 for creating a site with more than one user "type", with different Content Profiles, different Roles with associated Permissions, different access to nodes etc. My current site has 3 different roles - Recruiters, Candidates and a Simple Administrator (as a reduced feature subset administrator, to limit the amount of damage that a non-technical administrator can do to the site, yet still do things like edit the outgoing emails, add/remove users etc).

I was wondering... when I am testing, I am currently using multiple browsers (dev in Firefox, Testing one user type in Chrome, one in ie9) to get around the "current" session issue (you can only be logged in as one user). What techniques do people use to test on multiple roles simultaneously? Is there, for example, a Firefox plugin or something else to isolate different browser based session cookies in different tabs?

# Answer
You could try the Masquerade module for Drupal. It allows you to switch users if you have the right permissions, so you could switch mid-session to a user with a different role etc.

Another thing you could try, though non-Drupal, is multiple sessions within Firefox. Look here, here and here to see if that could help you.
> 5 votes

---
Tags: users, testing
---


# Question
Title: How to display taxonomy terms of a particular vocabulary in views
I am trying to display taxonomy terms of a particular vocabulary in views terms field, but I am lost as to how to do it. I have done the same thing in full view mode using template.php.

# Answer
**Answer revised**
Create a view of type `Node`
Add a display of type `block` or `page` according to your need
Add your desired fields(CCK) along with a field `Taxonomy: Term`
Add a filter `Taxonomy: Vocabulary` and select `is one of` operator and choose the particular vocabulary name.

This solution will include taxonomy terms associated with content node but filter according to the defined vocabulary in filter.
> 2 votes

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


# Question
Title: Inserting search terms into a search input in Drupal 7
When using Drupal 7, how do I print the current search terms into a search form in a block?

In Drupal 6, I used something like this in my template.php:

```
$vars['search_keys'] = search_get_keys();

```

Then, in search-theme-form.tpl.php I had:

```
<input type="text" value="<?php print $search_keys; ?> name="search_theme_form" id="edit-search-theme-form-1">

```

But search\_get\_keys doesn't exist in Drupal 7, so I can't use this method.

Using arg(2) is the only method I've come up with, but that seems a little hacky, because it will break if the URL ever changes.

# Answer
> 6 votes
If you're using **Apache Solr** (http://drupal.org/project/apachesolr) you can use

```
$query->getParam("q")

```

in your search-result.tpl.php template.

Otherwise, you can use the slightly modified version of the function above:

```
function get_current_search_terms() {
// only do this once per request
static $return;
    if (!isset($return)) {
        // extract keys from path
        $path = explode('/', $_GET['q'], 3);
        // only if the path is search (if you have a different search url, please modify)
        if(count($path) == 3 && $path[0]=="search") {
            $return = $path[2];
        } else {
            $keys = empty($_REQUEST['keys']) ? '' : $_REQUEST['keys'];
            $return = $keys;
        }
    }
    return $return;
}

```

edit: no need for check\_plain here

# Answer
> 3 votes
Here's what I've come up with:

```
function mytemplate_preprocess_search_block_form(&$vars) {

  $path_args = arg();

  // Insert the current search term (if applicable).
  $value = (count($path_args) == 3 && (strpos($path_args[0], 'search') !== false)) ? filter_xss($path_args[2]) : '';

  $vars['search_form'] = str_replace('value=""', 'value="' . $value . '"', $vars['search_form']);

}

```

Is there a better way to do this?

---
Tags: 7, theming, search
---


# Question
Title: "Censor" View results/ CCK fields (Censor based on a role)
Drupal 6 Nodes + CCK allow the creation of custom fields on nodes and per Role based Permissions to view / edit / delete on a per Field basis. Whilst I don't want to simply "switch off" fields (disable the Permission to View a field based on a Role), I want the field to display "\********", or "*withheld*".

So essentially I want to add additional permissions to the View CCK field, called "View Censored", which doesn't allow them to see the content, but know at least the content *exists*. In addition, it means that I don't have to have duplicate Views (one with full details, one with some sort of templated \*** instead of fields) and the linked Nodes will display, but with censored fields automatically.

# Answer
The only way I can think of to do this without making two views (which would be my preference to be honest) would be to use the Views Customfield module and use a PHP snippet to check permissions and display the result accordingly.

Create your view as normal and when choosing the field that you wish to change, make sure you check the bock that says "Exclude from display". Then add a custom PHP field directly after it and use code along these lines:

```
<?php
  // Check the logged in user
  global $user;
  // Check if the user has a certain role
  if (in_array('USER ROLE', array_values($user->roles))) {
    print $data->FIELDNAME;
  }
  else {
    print "Withheld";
  }
?>

```

Obviously you'll need to replace `'USER ROLE'` with the role that you're looking for and you'll need to replace `$data->FIELDNAME` with whatever the Views fieldname is, for example `$data->nid` or `$data->title`.

Otherwise you could use a View with two slightly different block displays, embedded in a contextual Panel that checks for users permissions and displays accordingly.

**Edit after asker comment:** Craig, a few things. Firstly, I don't think you're approaching the problem correctly at all. What you want to do is difficult and a outside of the scope of your question - you asked how to alter a value on a view, not show two different values globally depending on permissions. Before you can get the solution you need to ensure you're tackling the right problem. You simply need to hide a value in two situations depending on a permission, nothing more.

Secondly, I'm not going to give you another solution as I have given you a perfectly good solution to your question. This may not be perfect for you but with some initiative you could very easily solve this problem with what I've given you. If you persevere with this information you can use the Content Templates module and the same code as above to hide the value on a node.

Thirdly, never hack modules. If you want to change the behaviour of a module, write another module to alter it.
> 2 votes

---
Tags: views, entities
---


title: How to have an extension in hook_menu()

text:
# Question
Title: How to have an extension in hook_menu()
I am trying to create a menu with a file extension in `hook_menu()` with the following code:

```
$items['pdf/products/%.pdf'] = array(
    'title' => 'Download PDF',
    'page callback' => '_pdf_get',
    'page arguments' => array(2),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK
);

```

It works fine without the .pdf.

Any ideas how I can do this?

# Answer
Why do you need the .pdf part in the hook menu? Can't you just perform a check on the arg() function in your \_pdf\_get function to ensure that the argument contains ".pdf" and if not, redirects the user to the url with ".pdf" appended?
> 3 votes

---
Tags: routes, hooks
---


# Question
Title: How to use multiple content types in a "Calendar" View sorting by the field type of "Date"?
I am using a module called "Calendar" that puts a calendar on the sidebar, and allows you to add events using a cck, which will be displayed on the calendar so that you can click the date, and it will bring you to the event (along with any other event that day.) the problem is, that i don't want to have to create all new content using the cck that was part of the Calendar module. when installing the module, it added a field type called "Date", which is what the calendar events are sorted by. this allowed me to add other cck events that had that field, into the calendar. The problem is, that it puts in onto the wrong date. instead of putting it onto the date that it is set at, it is put onto the date that it was created. is there a way to fix this?

# Answer
> 1 votes
You need to change the calendar view's Contextual Filter (Under "Advanced") to use the new date field, instead of the post date.

---
Tags: 7, entities, datetime
---


title: Webform node titles - 6x

text:
# Question
Title: Webform node titles - 6x
I have a custom content type that has a webform. One of the components is the node title. Is there a way to use a token to pull the node title instead of typing it? I've tried setting %title as default but that simply spits back the token at me as text "%title". Please advice.

# Answer
> 1 votes
Last I checked, Webform didn't pick up a title token.

But it is possible to send the page's url in an email by using the %server\[key\] token.

For example, in the Webform tab \> e-Mails subtab \> E-mail template, include:

```
http://yourdomain.com%server[REQUEST_URI]

```

See this page for more info.

EDIT: This comment may have a full solution

---
Tags: nodes, webforms
---


# Question
Title: Contextual Filters within Block Display?
using d7.4

I am trying to setup a block on my node pages that will show: View Count Comment Count Flag Count

My node paths are setup as: category/categoryname/nodetitle

I know I need a Contextual Filter to link this view to the Node Title (right???) - but how do I designate a path for that within a block? I know I can name a path with a View-Page Display- but I need this to be shown inside a block, not a page. What am I missing here?

Thanks for the reply! This newbie appreciates it!

# Answer
In the Block Display, create a contextual filter with these settings:

Content: Nid *(not title)*

Under "When the filter value is NOT available" check "Provide default value" then choose "content id from url"

Under "When the filter value IS available or a default is provided" check "Specify validation criteria" then choose "Basic Validator" or any other you like.
> 4 votes

---
Tags: views, blocks, 7
---


title: Load node based on a field name

text:
# Question
Title: Load node based on a field name
I have a content type that has a unique field. How can I load a specific node based on this? `node_load()` only takes the `nid`. I am using Drupal 7.

# Answer
> 4 votes
There is indeed an API function: `EntityFieldQuery`, which has lots of example use cases scattered around this site.

# Answer
> 2 votes
Run a query against the database to find the node that has the field with the specified value and return the nid. Then run the nid through `node_load()`

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


title: How do non administrators add content?

text:
# Question
Title: How do non administrators add content?
In Drupal 7, how do I let the users with a specific role add new articles?

I logged in as administrator, set the permission for the role to allow creating and editing nodes that are articles.
When I login with a user with the role, for example, "NewRole," I do not see any control or dashboard that allows me to create new articles.

How do I start adding new articles as this new user?

# Answer
> 10 votes
You probably don't have the Navigation menu enabled/placed in a region, or have any other links to direct a user to the Create Content page.

As an administrator, either enable that menu or create a link to "node/add" (to allow the users to see all the content types for which they can create a node); you can also add a link to "node/add/article" in another menu or in your theme.

To allow a user to see the administration toolbar, they must have a role that has the permission to use the administration toolbar. See below:

# Answer
> 3 votes
You must set the right permission! Now i give to you a screenshot

If you set the permission for example as the screenshot the user will modify article type content.

---
Tags: users, nodes
---


# Question
Title: Taxonomy vs. CCK List for categorizing Events
Could someone let me know what the best practice is for choosing between implementing something as a Taxonomy vs. a List field in the Content Type? Assuming that there is a preset list of values and there is no need for content creators to create their own.

For example, a Content Type of an "event" could be categorized based on *audience* or *type*. Audiences can be \[Kids, Youth, Adults, Seniors, etc.\]. Similarly, type would have a preset list as well.

Should *audience* or *type* be created as Taxonomy or a List field in the Content Type?

# Answer
> 1 votes
If you use taxonomy, then using the calendar module they can be colour-coded in the legend based on their category.

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


# Question
Title: How to list all inactive modules on a multisite?
I have kept several hundreds of modules in my D6 Drupal multisite. I have had them there so that when I need any of them I don't have to download it first - I just go to /admin/build/modules and switch on what I want.

The problem is that that list of modules takes ages so long to load that the work becomes inefficient. Also Drupal monitoring services, such as the excellent droptor.com, have a hard time (literally, very time consuming calls) to retrieve the current status of each site. The PHP memory allocation is stretched as well.

In short, **I am looking for a programmatic way to select and then delete all inactive and uninstalled modules in any site of a Drupal 6 multisite.**

I know there are complications -- module folders often do not correspond exactly to their module names (e.g. module "CCK Privacy" is in folder "privacy"). Also, some modules might actually be in subdirectories in cases where one project ships several modules at once. The problem is especially confounded in case of multisites, where some modules might be inactive for one of the sites, but they need to be in the directory because some of the other sites use them.

(There was an interesting thread on this at http://groups.drupal.org/node/123179 but it did not offer any practical solution for multisites.)

# Answer
> 1 votes
I am not sure of a way to do this programatically, but you could install http://drupal.org/project/enabled\_modules and cross-reference the lists.

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


title: jQuery Dialog, passing html to dialog

text:
# Question
Title: jQuery Dialog, passing html to dialog
I am looking for a method to pass html to jquery dialog. Without success.

I try:

```
Drupal.jqui_dialog.html(messages);

```

And

```
        Drupal.jqui_dialog.open({
              data : messages
        });

```

But it doesn't work.

# Answer
> 3 votes
If you have the jQuery UI library with dialog activated on your site, you should be able to do

```
$('<div>' + message + '</div>').dialog();

```

---
Tags: 6, forms, javascript
---


title: Search on other fields of content type

text:
# Question
Title:  Search on other fields of content type
I created a content type called "Automobile" and that has the following fields: "Model," "Manufacturer," and "Year." When I go to "Dashboard \> Content \> Find Content," the search does not offer me controls to "find all automobiles between the year 1990 and 1995 with the model Caravan." How do I configure Drupal to allow such queries?

# Answer
> 4 votes
You have to create a view if you want this control. Like this

This will give you a page with the exposed filters you asked for @ www.mysite.com/automobile.

# Answer
> 1 votes
You can also use the Search API ranges module. Here is a quote about it (from its project page):

> ... provides widgets for Search API range queries. Currently includes: jQuery UI min/max slider.

---
Tags: search, nodes
---


# Question
Title: Use image scale and crop in custom function
In Drupal 7, I'm trying to use `image_scale_and_crop()` to take an image from an external URL and resize it. Then I want to print it out to my page. Here is my code:

```
$filename = $bjt_img;
$img_url = "http://www.mydomain.com/uploads/".$filename;
$myimg = image_load($img_url);
$myimg_scaled = image_scale_and_crop($myimg, 100, 80);

print '<img src="'.$myimg_scaled.'">'

```

I'm getting the message:

> Recoverable fatal error: Argument 1 passed to image\_scale\_and\_crop() must be an instance of stdClass, boolean given, called in...

How exactly is the image returned with `image_scale_and_crop()`?

# Answer
You problem is image\_load($img\_url) is returning FALSE, which is not an object.

```
$filename = $bjt_img;
$img_url = "http://www.mydomain.com/uploads/".$filename;
if (isset($myimg = image_load($img_url)) {
  $myimg_scaled = image_scale_and_crop($myimg, 100, 80);
  print '<img src="'.$myimg_scaled.'">'
}
else {
  print 'error'
}

```

Plus I think it must be a file, not a url to a file
> 1 votes

# Answer
The problem is the value returned from image\_load(), which is the boolean `FALSE` because the function is not able to load the image file.

> ### Return value
>
> An image object or `FALSE` if there was a problem loading the file. The image object has the following properties:
>
> * 'source' - The original file path.
> * 'info' - The array of information returned by `image_get_info()`
> * 'toolkit' - The name of the image toolkit requested when the image was loaded.

As for the parameters accepted from the function, the first one is the path to the image file, which normally doesn't mean the URL of the image. Check also that in your PHP installation, the file functions are allowed to open remote files; in the case it is not enabled, passing a URL when a function is expecting a file name would cause the error you noticed.

The documentation for imagecreatefromjpeg(), which is the function that is called if the image toolkit Drupal is using is GD2, and the image is a JPEG one, reports:

> A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

Similar warning is given for imagecreatefrompng(), and the other `imagecreatefrom[image-type]()` functions.
> 0 votes

---
Tags: media
---


# Question
Title: How to post three nodes of same content type in three different blocks in the front page?
I have already set the block regions in both my page--front.tpl.php and site.info files, created the custom content type and created the content that should be displayed on each of them....now how am I supposed to post this in the front page? I was told I should use Views for this with no much further explanation and I'm following some nodeone's screencasts on views... but I'm not really sure what I'm looking for here. Any hints?

# Answer
> 1 votes
Create 3 separate block views, each will display 1 node. make sure they are offseted.

*This will display 2nd top node of the content type 'automobile' that is promote to front page.*

Then configure them at admin/structure/block

---
Tags: 7, views, nodes
---


# Question
Title: I have issues with multiple paged tables in pages with multiple tabs (JQuery UI tabs)
I have a series of pages that provide paged tables inside of tabsets. Using the Tabs module, I get jQuery UI tabs, and I am using that to create pages with multiple horizontal tabs; inside those tabs I have forms and paged tables, typically one form or one paged table per tab.

The paged tables are generated using `pager_query()`, where I am providing a pagerElement parameter because I have multiple paged tables on the same page (but on different tabs).

Likewise, when I call `theme('pager')`, I am passing in my pagerElement so my multiple paged tables do not get confused, as well as an additional associative array for my active tabset parameter. The call looks like `theme('pager', NULL, $pagerLimit, $pagerElement, array('tabset'=>$pagerElement));`.

The issue I'm having is the pager links being generated, for example: when first landing on one of these multi-tabbed pages, the pager links look like http://example.com/Projects-Dash?tabset=0&page=1.

However, as soon as a pager link is clicked, the pager links look like http://example.com/Projects-Dash?tabset=0&page=2&tabset=0, where `tabset=0` is repeated. At least the links from the second paged table are somewhat different, looking like this http://example.com/Projects-Dash?tabset=1&page=1%2C1&tabset=0, but they still have that extra `tabset=0` at the end.

How do I prevent that?

# Answer
The problem was being caused by how the pager logic handles existing URI encoded parameters: it simply copies them, pre-pending any new URI encoded parameters used by the pager logic. The result being a duplicate of my 'active tab' parameter "tabset", the previous one present in a copy of the prior URI parameters, and the one I introduced in the paging link.

My solution was to parse the request URI myself inside my form logic, with knowledge that the first encountered "tabset" value is the active one, not the second (older) version at the end of the URI.

```
$activeTab = 0;
  $requestUri = $base_root.request_uri();
  if ($requestUri == '') {
    _devReport( '$requestUri is empty!' );
  }
  else {
    $requestArray = explode( '/', rawurldecode($requestUri) );
    // if course, this parsing logic is specific to my WebApp URI setup:
    if (($requestArray[0] == 'http:') &&
        ($requestArray[3] == 'WebApp')) {
      // this should always be true, but just in case:
      if ($requestArray[4] != '') {
        $split1 = explode( '?', $requestArray[4] );
        $split2 = explode( '&', $split1[1] );
        if ($split2[0] != '') {
          $split3 = explode( '=', $split2[0] );
          if ($split3[0] == 'tabset') {
            $activeTab = $split3[1];
          }
        }
      }
    }
  }

```

Now $activeTab has the correct value, even though it may be present a 2nd time in the URI with a different value.
> 1 votes

---
Tags: theming, paging, routes
---


# Question
Title: On the theme "busy" how to remove the "0 comments" at the bottom?
I have already deactivated the ability to comment on every page but now it just says "0 comments" this is very annoying.

# Answer
Try disabling the comments module, or set the comments to be hidden in the content type settings.
> 1 votes

# Answer
The problem you are having is caused by the code in the template.php file.

Change the line containing the following code:

```
if ($vars['page'] && isset($vars['content']['links']['comment'])) {

```

Replace it with the following code:

```
if ($vars['page'] && isset($vars['content']['links']['comment']) && $vars['comment_count'] > 0) {

```
> 1 votes

---
Tags: 7, theming
---


title: Step-By-Step Content Type in d7?

text:
# Question
Title: Step-By-Step Content Type in d7?
I want to create a tutorial content type, something where people can upload images, title, body, etc into 'steps'; each step would then be linked together.
The users can upload an unlimited number of steps for the entire node. It is very similar to the instructables.com site. How could I achieve that?

By the way, someone did ask a similar question about this using Drupal 6. The suggestions were to use a story book content type, or to use CCK field grouping. I don't understand how to do those things in d7.

# Answer
The suggestion of using the book structure or field groups would be exactly the same in D7 as it would have been in D6. However, the CCK multigroup module would be a much better fit and would check on it's D7 status (I tried, but it's spread over several issues in the queue)
> 1 votes

---
Tags: views, nodes
---


title: problem using facebook connect module

text:
# Question
Title: problem using facebook connect module
i installed the module Fbconnect in my drupal 7 site

the fbconnect button starts appearing now but the window which opens upon clicking the button, gives the error ,"An error occured, try again later."

Anyone please help

# Answer
> 2 votes
have put in the api key, I think you are missing that. Have you also enabled it on certain node types you want to display.

---
Tags: 7, users
---


# Question
Title: Organic Groups - Group members list (with content profile) with views
http://ruh.kz/groups/ruhkz under the title - Участники группы - is placed a view block that displays members of this group. I've used a default view → og\_recent\_members, but it doesn't works for content profile. I need to display a CCK field from content\_profile module.

Tried to set in filters - content type:profile, and in fields selected Content:field\_photo, but it doesn't works. Displays nothing.

How to display CCK imagefield (Profile Photo) instead of usernames in og\_recent\_members views block?

# Answer
In the view add a new relationship
1.) Select node and then content profile-\>corresponding content type, which creates a relationship.
2.)Now in the fields add your content profile fields u want to display. here select the relationship content profile.
Now you should have your profile fields coming from content profile.
> 1 votes

---
Tags: entities, organic-groups, users
---


title: Limited Node References

text:
# Question
Title: Limited Node References
I am building a site for a client where each page has 3 other pages associated with it. I know how to create node references but I would like to find a way to limit the user to creating just 3 node references per page.

So each page only allows the creation of 3 references and whrn all of them are created the "add reference" link is removed ( until perhaps one or more of the references is deleted ).

Can anyone suggest a potential solution?

Thanks

# Answer
> 3 votes
In node reference field settings page (content type -\> manage fields -\> name of field) in "global settings area" set "number of values" to 3.

Thats it. Hope this helps.

---
Tags: nodes
---


# Question
Title: How to properly add anchor to form element
I try:

```
         $form['field_profile_club']['anchor'] = array(
           '#value' => '<a name="my_club"></a>',
         );

```

But my field (field\_profile\_club) disappear.

Could somebody help?

# Answer
Take a look at the form apis prefix and suffix attributes these will allow you to wrap html around your form element.
> 2 votes

---
Tags: 6, forms
---


title: Configuring a taxonomy argument view

text:
# Question
Title: Configuring a taxonomy argument view
Using Views 6.x-3.x-dev

I have a content type called Images and a Content stype called Stars. Both Types share a Vocabulary Called Name. The vocab is tags.

Via a View, I want to display all the images associated with that Star when viewing that particular Star node.

So say I am currently viewing Brad Pitt's Node. This node is tagged the term 'Brad Pitt' in the Names Vocab. I want all his images (too who are tagged 'Brad Pitt') to be displayed below the his node.

So I need to get NODES from type IMAGES that are tagged the same term in vocab NAMES as the currently viewed node

So in the Brad Pitt Node,
get NODES from type IMAGES tagged BRAD PITT from the vocab NAMES

# Answer
If I understand you correctly:

Use Taxonomy: Term ID as argument.

Write php to get taxonomy term/terms from current node and return them.

Configure this view to display node types you want to display.
> 1 votes

# Answer
What you need to is

1. create a view

* add an argument of the term name or term id.
    * Add a filter of `Node: Content type` for foo and bar.
    * *EDIT:* Add another filter for the vocabulary you want.
2. embed the view into your node. You can embed the view in the node.tpl.php file or add a cck text textarea field, with a php code input filter. Then follow Embedding a View in Drupal 6 using views\_embed\_view. *EDIT:* You must pass the term id into the embedded view.
> 0 votes

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


title: Content List vs Administer nodes

text:
# Question
Title: Content List vs Administer nodes
New Drupal and playing with permissions. I can't figure out how to get a content list or something similar if the Administer Nodes permission has been disabled.

I'm trying to restrict a user role, strip down the admin menu, e.g. remove 'Post Settings' under content management.

I have a feeling I'm doing this wrong, so my question is: Can I create a user menu, same as the admin menu without certain links and how?

# Answer
> 1 votes
You could use views to create a list of all the nodes on the site and make sure the role has access to see it. This is by far the simplest and quickest way of implementing such a feature.

A more complex way would be to alter the menu link and change it's access control but I wouldn't recommend doing this.

---
Tags: routes
---


# Question
Title: Drupal use Node or not? And how to use them?
I'm on the way to develop a website for a kind of a sport-league where we have every year one season with different teams. A team can be built out of two Users and they can play against other teams. There will be a kind of different Leagues (depending on how good they are..)

So my question is now, how to implement this? :P (Of course this is nit the main question, but I need some hints for my drupal-start :)

In drupal there is this concept of "Nodes". As I understood, a Node is a Content. And depending on the NodeType it is shown different.

How should I now implement for example a "Game". To the beginning of a season the site will create all the game-records. During the Season the users will enter the results into this game-records. They can write comments and probably rate the game.

For the edit-page I'm going to write my own module (guess this is the right path to go..) same I'll do for the rankings.. this should work! But how can i combine this "Node"-Concept with my "Database"-Concept I've learned before I get known to drupal?

Is it then possible to hide a specific Node-Type from Administration -\> Content? I do not want to see there all the Games played during the last 10 Years as this would be quite a big list...

Any help/idea/hint would be very appreciated :)

# Answer
> 6 votes
Nodes are for content, complex data managed by your website are not necessarily content. In Drupal 6 and before, using node for everything was a common practice because only nodes could benefit easily from the CCK, Views and other modules. Drupal 7 introduced the concept of entities. You can create new entity type and for one entity type your can have multiple bundles. Node is an entity type and the content types (or node types) are bundles. Using the Field API, fields are defined by bundle to attach values to entities.

So you don't need, and probably shouldn't, manage everything as nodes but instead defines your own entity types and bundles to store and manage your site data. The Entity API module provides a better API to manage entities and entity types to complete Drupal core's one. The Model Entities project provides a model entity and entity administration interface to kick-start your entity related development. For Field API usage, the Examples for Developers project provides the field\_example. You can also use Features to easily export field definitions into code.

---
Tags: 7, nodes
---


# Question
Title: Approval required for all comments apart from on the forum
We need to allow all forum comments to be published automatically, however any comments to articles or any other content type will require approval before being published.

Unfortunately Drupal seems to only have a single permission "post comments without approval" which applies to both the general comments for nodes and also the comments for the forum topic (yes I know they are still nodes)

Is there any easy way round this? I was thinking maybe a rule but it seems a little over the top, surely this must be a common complaint but my searches didnt bring back anything helpful...

# Answer
> 2 votes
I know this is the reason advance forum modules recommends installing nodecomment. You can select which content type's comments to be nodes. Select Form topics. In nodecomment content type select uncheck publish from the publish options. Now every comment publish will be unpublish by default

---
Tags: 6, users, comments, nodes
---


# Question
Title: Views, Views-Slideshow, and Paging in Drupal 7
The situation is as follows: I have a content type Slide, and I want to display the three newest slides in a slideshow. The slides need to cycle, and the slides also need to be controllable by a pager. The pager should have three bullets/links/images to be able to jump to a particular slide in the slideshow. The pager should also have left and right arrows for incrementing and decrementing the the slide in the slideshow.

This technique is used ubiquitously around the web, yet I can't seem to figure out how to set this up correctly using Views and Views Slideshow. Any pointers from all of you experienced Drupalites out there are welcome.

Cheers, Les.

# Answer
(1) Required Modules (Version: Drupal7.0)

```
Views
Views Slideshow
Chaos tool suite
Libraries
Link Field
Token

```

(2) Install the Modules

In Drupal7 you can install modules from the admin section, but I still feel this new feature doesn't have any meaning, because we have to search for the module link in the Druapl site and then copy paste into the admin module installation area, really crazy. It would have been so good if they would have made it something like wordpress a small search feasture. Anyway I just gonna download and istall it in the old way (I still recommend this old way).

Download all the modules from Drupal site and install in the directory yoursitename/sites/all/modules. Go to http://www.yoursitename.com/node#overlay=admin/modules and enable these modules as below;

(1) Views (2) Views UI (3) Views Slideshow (4) Views Slideshow: Cycle (5) Chaos tools (6) Link (7) Libraries (8) Token (Optional) (3) Create Image Cache

In Drupal7 imagecache is part of core module and is named as Image styles. So let's create two image cache from here, one for the full size slider image and other for the thumbnail image. In this tutorial I use 935x293 (pixels) dimension for the full size slider image and 210x100 (pixels) dimension for the thumbnail image. Note: These configurations csn be defered depends on your needs.

* Fullsize Slider image settings

Go to http://www.yoursitename.com/node#overlay=admin/config/media/image-styles and click on the add new style link (1) Give an Image style name and click on create new style button (2) On the next configuration screen select new style you want and then click add button (In this tutorial I choose resize style) (3) On the next screen set the width and height and click on the add effect button. (The settings may vary depend on the style you choose). I set width as 935 and height as 293 pixels.

Do this same process for the thumbnail image too. (for the thumbnail image dimension, I set width as 210 and height as 100 pixels.) (4) Create New Content Type

Let's create a new content type, From the dashboard menu bar cick on Structure and then content types then click on the add new content type link.

(1) Give a human-readable name, I named it as Featured Slider (machiine name will be auto generated based on the human readable name) (2) Give a brief and relevant description (3) Submission form settings, I leave as the default settings (4) Publishing options, I checked only published (all other settings unchecked) (5) Display settings, I have unchecked the authour and date info. (6) Comment settings,I set hidden (disabled) (7) Menu settings, I leave as default settings. (8) Click Save and add fields Button (5) Create New Fields

Here in this example I create only two fileds, and they are image field and link field. We will use image field for uploading our slider image and link field for creating a custom link where we want our slider to be linked.

Image Field Settings

```
(1) Label: Slider Image
(2) Field: slider_image
(3) Field type: image
(4) Widget (form element): image
(5) Click Save button, and on the field settings page leave default settings and click on Save field settings button.
(6) On the image field configuration settings page you can configure as you wish.

```

I set this field as required, I added a file director name called slider-image so that this images will be arranged sperately from other images. You can set the maximum upload size and resolution here, I have anabled alt and title field and finally click Save settings button.

By using same method create the link field too.

Link Field Settings (1) Label: Slider Link (2) Field: slider\_link (3) Field type: link (4) Widget (form element): link (5) Click Save button, For the link field configurations leave evrything to default settings. I have re arranged the field like shown below; Title field Image field Link field Body field (you can even remove this field if not necessary) Manage Display On the manage display tab you can conigure how the out put of the field to be diplayed. I have set the link field as hidden and I have also set image label as hidden Drupal7: manage fields (6) Create Feature Slider Content

I have created four featured slider content for this tutorial.

(1) Click on add content link (2) Create Featured Slider content (3) Give a proper title name (4) Upload slider image (5) Give alt and title field names (6) Give a link title and url where you want the slider to be linked (7) Leave all othe settings as default except for the path field if yo want you can give an SEO friendly URL alias. (8) Save the content.

Same way create more Featured Slider contents (I have created four contents) (7) Create a New View

Now it's time to create our new Slideshow view. From the Dashboard menu click on the Structure and then click on the Views.

(1) Click add new view link (2) Give view name, I have named as Featured Slider (machiine name will be auto generated) (3) Give an apropriate view description (4) Choose Show Content of type Featured Slider (your content type name). (5) Uncheck Create a Pge and check Create a block (6) Type in Block title and choose display format as "Slideshow" of "fields" items per page 5 (you can enter the number of items you want to display) (7) Click the button "Continue & edit" Views Field Settings First let's add link field (link must be the first field in order to work everything properly) so click on the add icon and from the filter Groups select Content Add Content: Link, Click "Add & configure button" in the next cofiguration window uncheck "Create a label". "Check" Exclude from display. Click "Apply button"

Next let's add image field, so click on the add icon and from the filter Groups select content Add Content: image field (Note: make sure you choose the image field which we crerated for this slider content type only.) Click "Add & configure button" in the next cofiguration window uncheck "Create a label".

Formatter: Image (if you have installed Colorbox or lightbox you can choose them here!) Image Style: Fullsize (Choose the imagecache you have created in the above step) Link image to: Nothing Style Settings: Leave default settings No result behaviour: Leave default settings Rewrite Results: Check Output this field as a link Link path: \[view\_node\] (Note:Scroll dow a bit and you can see replacement patterns created by Core Token module, (if we didn't set the link field as first we can't see link field option here) copy only \[view\_node\] then scroll up and paste it in the link path field.) Click "Apply button"

Finally we need one more field for the thumbnail, so let's click on the add icon and from the filter Groups select Content Add Content: image field (Note: make sure you choose the image field which we crerated for this slider content type only.) Click "Add & configure button" in the next cofiguration window uncheck "Create a label" and CHECK EXCLUDE FROM DISPLAY, Formatter: Image (if you have installed Colorbox or lightbox you can choose them here!) Image Style: Thumbnail (Choose the imagecache you have created in the above step) Link image to: Nothing Style Settings: Leave default settings No result behaviour: Leave default settings Rewrite Results: Check Output this field as a link Link path: \[view\_node\] (Note:Scroll dow a bit and you can see replacement patterns created by Core Token module, (if we didn't set the link field as first we can't see link field option here) copy only \[view\_node\] then scroll up and paste it in the link path field.) Click "Apply button"

Views Filters Settings

In views3 the filters are created in the beginning while we choose the content type and other settings! If you need any additional filetering you can create it here!

Views Style Settings

Click on the Format Slideshow | settigs and on the next configuratioin window set as below; (1) List type: Unordered list (2) Wrapper class: Leave default settings (3) Style\> Skin: deafult (4) Slides\> Slideshow type: cycle (5) Cycle options You need to download jQuery cycle plugin and copy jquery.cycle.all.min.js to sites/all/libraries/jquery.cycle You can find the plugin at http://malsup.com/jquery/cycle.

IN SIMPLE ENGLISH Create a folder named "libraries" in the site/all directory and then create an another folder named "jquery.cycle" in that directory and finally copy and paste only the "jquery.cycle.all.min.js" into this directory.

(6) Transittion: Fade (7) Action: pause on hover (8) Internet Explorer Tweaks: default (9) Widgets: You can choose either or both Top and Bottom (I choose bottom here, and the advance settings as below;) (10) Bottom Widgets\>Pager\>Pager type: Fields (11) Pager field: Content: Image (Note: last one we added for the thumb, don't mistake since both field will be named same.) (12) Activate Slide and Pause on Pager Hove: checked, controls and slider counter leave unchecked. (13) Click Apply button.

Format Show Field Settings

```
Inline fields: Choose the thumbnail field as inline.
Click Apply button. (Note: Well it actually doesn't change much in appearance but it does change in the code. Next step use the firebug and find the class and add some styles to display properly.)

```

(8) Create a Custom Region (optional step)

(1) On your thems folder open the your\_theme\_name.info file and add a new region like this shown below; regions\[featured\_slider\] = Featured Slider and save the .info file. (2) Open your themes page.tpl.php file and add these code where you want your slide to be displayed as shown below;

You can even create custom front page template like page--front.tpl.php so that you do't need to make any changes to the default page.tpl.php template. \[9\] Enable & configure the Block

Now this block will be visible in the blocks disabled area, so from the Dashboard menu go to Structure\>Block and enable the block to a themes default region or the custom region we created (featured\_slider). (Regions varies depends on the theme you are using.)

Block Configuration Settings After enabling the block you get a link to configure the block so click on the Configure link and on the settings section set as below;

(1) Block title (if you don't want blobk title to be displayed just type ) (2) Again you get all enabled theme specific Region settings. On visibility setings (3) Pages\>Show block on specific page: choose Only the listed pages and type so that this block will be displayed only on the front page. CSS TIPS TO DISPLAY THUMBNAILS INLINE

Add these CSS codes to your themes style sheet to display the thumbnails inline. .views-slideshow-controls-bottom .views-slideshow-pager-field-item { float: left; margin: 20px 6px; } Make necessary adjustments.
> 14 votes

# Answer
Take a look at this Mustardseed Media podcast: Views Slideshow Theming.

During the podcast, Bob runs through some of the basics of Views Slideshow as well as how to theme the output. It is based around Drupal 6, but I believe most of the basics and lessons will be the same. With only a little CSS, a slideshow can look a *ton* better. I highly recommend watching this podcast if you want nice looking slideshows.
> 2 votes

# Answer
If you want to know more of views slideshow (for example with thumbnails ) you must see this good tutorial: http://www.brightwebsitedesign.com/how-to-install-views-slideshow-module-on-drupal7
> 1 votes

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


title: Upload images in Blocks in drupal admin

text:
# Question
Title: Upload images in Blocks in drupal admin
Is there any way through which we can upload images from blocks in admin ? I have imce to upload pictures but if it was there in blocks it would be have been better , i saw many work arounds for this like creating a cck feild of image type then save it as view, instead is there any straight forward approach like upload module for nodes ?

# Answer
You can also uploading images on blocks with a normal editor as TinyMCE and the WYSIWYG module after setting in the right way the module, see my screenshot when i create a block...
> 0 votes

# Answer
You could use webfm module upload images and then display them using img tag in the blocks.
> 0 votes

---
Tags: 7, blocks, files
---


# Question
Title: Field with content entries from a content type
I want to add a field (List text) to a content type, using as values the entries of another content type.

Should I use the References module?

# Answer
> 2 votes
No. Fields can be reused between any content type. In node's field administration page, use the existing field and values you attributes you set to that field will be available in both node types. But you can have different field labels and descriptions.

# Answer
> 0 votes
If you mean you have already created a field in another content type, and you want to add the same field (a List(text)) in another content type :

* Just search for "Add existing field" in the "manage fields" section of your new content type.
* In the machine name list, select the one you've created. Name it, select the same widget.
* Add-it the same way.

Normally the values will be copied.

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


title: Email multiple user selected pages

text:
# Question
Title: Email multiple user selected pages
I need a way where someone can visit multiple nodes, add them to a list, and email them in a batch / list to a person. I've looked at ShareThis and AddToAny, and each would seem to do a fine job for a single page, but I need to be able to collect an arbitrary number of pages and then forward them via email when the client is done creating the list.

The "use case" is that a salesman will visit a store, select 3 or 4 items on an iPhone / iPad that they would like to send more information on, and use Drupal to create the list and send the email.

I'm trying to avoid custom coding a solution because my skills are not quite up to the task, and as with everything, deadlines are tight.

# Answer
> 2 votes
Sounds like a job for Nodequeue or Flag and the Printer, e-mail and PDF versions Modules

---
Tags: 7, emails
---


# Question
Title: make the sidebars and the "content" region the same length as each-other?
I have a website that has regions that are uneven. the sidebar first is a different length than the content, and the content is a different length that sidebar second. it looks something like this:

I could fix it manually in the css and make them the same length, but then any time I add something to any of them, it becomes uneven again. is there any way (or any module) to fix it so that it will dynamically stay the same length, so that when I add something to the content, and it becomes longer that the sidebars, they will fill with white-space and become the same length as the longest content?

# Answer
try using Faux Columns. it basically repeats a blank image so that the columns will match the length of the longest element. this creates the illusion of equal lengths, hence the name "faux" or "fake"
> 1 votes

# Answer
There is the Equal Heights jQuery module.

> This modules implements a jQuery Equal Heights plugin that can equalize the height of the elements of the specified class.
> 3 votes

# Answer
This is not Drupal specific problem. Try one of suggestions reported on Equal Height Columns using CSS: It has two CSS solutions, and one JavaScript solution.
> 3 votes

---
Tags: 7, theming
---


# Question
Title: making a views grid go from right to left?
I have views, that I need placed differently. normally the images in a grid view show from left to right, but I need them the other way. How can i set a grid to show starting from right to left instead of left to right?

# Answer
As far as I am aware, there are no settings in views to change this behaviour. However you can change the view format to "Unformatted" and give the .views-row a width and float:right (tweak as desired). This will line them up as a grid rtl.
> 1 votes

---
Tags: 7, views
---


# Question
Title: Assign Fields programatically to custom node defined by custom module
Trying to convert a module from Drupal 6 to Drupal 7 which defines its own node type in hook\_node\_info.

Even though hook\_node\_info defines has\_title and has\_body to TRUE, how I can get these fields to appear on the node form? Previously, I used hook\_form():

```
function mymodule_form(&$node, $form_state) {
  $type = node_get_types('type', $node);

  if ($type->has_title) {
    $form['title'] = array(
        '#type' => 'textfield',
        '#title' => check_plain($type->title_label),
        '#required' => TRUE,
        '#default_value' => $node->title,
        '#weight' => -25,
    );
  }

  if ($type->has_body) {
    $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
    $form['body_field']['body']['#rows'] = 5;
    $form['body_field']['body']['#description'] = 'Enter a short message to present to the user.';
  }

  return $form;
}

```

In D6, this worked fine for me. In Drupal 7, hook\_form has changed, and I am not quite following the documentation of it.

How can I utilize the Body and Title Field in core and assign them to this node type when the module is activated?

Furthermore, how can I define a new Field type to mimic Body (Long text with summary) to something of my choosing?

# Answer
To add the body field to a content type, you use node\_add\_body\_field(). To add a field that is not the body field, you use field\_create\_field(), if the field doesn't exist, and field\_create\_instance() to assign an instance of the field to an entity (e.g. a node or a user object).

As example of how to use those functions, you can look at standard\_install(), which is the installation hook of the standard profile, that contains the following code:

```
  $field = array(
    'field_name' => 'field_' . $vocabulary->machine_name,
    'type' => 'taxonomy_term_reference',
    'cardinality' => FIELD_CARDINALITY_UNLIMITED,
    'settings' => array(
      'allowed_values' => array(
        array(
          'vocabulary' => $vocabulary->machine_name,
          'parent' => 0,
        ),
      ),
    ),
  );
  field_create_field($field);

  $instance = array(
    'field_name' => 'field_' . $vocabulary->machine_name,
    'entity_type' => 'node',
    'label' => 'Tags',
    'bundle' => 'article',
    'description' => $vocabulary->help,
    'widget' => array(
      'type' => 'taxonomy_autocomplete',
      'weight' => -4,
    ),
    'display' => array(
      'default' => array(
        'type' => 'taxonomy_term_reference_link',
        'weight' => 10,
      ),
      'teaser' => array(
        'type' => 'taxonomy_term_reference_link',
        'weight' => 10,
      ),
    ),
  );
  field_create_instance($instance);

```

The code is adding a taxonomy term field to the content type "Article."
> 4 votes

# Answer
This is a great document on Converting your module from Drupal 6.x to 7.x

In there is states

node body field instances are now handled exclusively by field API

> When defining a node type or creating one with node\_type\_save(), the 'has\_body' and 'body\_label' keys have been deprecated.
>
> To add a body field, you can instead call node\_add\_body\_field($type); which will add the field instance to that node type. See blog.install and forum.install for examples.

Check out forum.install & blog.install

So the place where you want to do this is in mymodule.install, and either inside the mymodule\_install() or mymodule\_enable().
> 1 votes

---
Tags: entities
---


# Question
Title: Add lightbox to product list in Ubercart
I'm trying to enable lightbox2 for product listings in Ubercart for Drupal 6. This is simple via views, but I think the product list is being generated by uc\_catalog module. How can I add classes to the product thumbnails or enable lightbox2 for them? Are tpl.php files available to customize output? Thanks for any help.

# Answer
> 1 votes
Maybe you should create the product list with Views instead. Not only can you easily add lightbox like you write yourself, but you can make a lot of customizations should the need arise.

If you don't want to use Views, it's most likely the taxonomy module that generates the product list, that's how it's done on many UC sites. You could install the devel\_themer and inspect the product list page with it. It should allow you to see what theme functions is being used to create the page. This should also help you figure out how you can add the customizations your want via template files or theme overrides.

---
Tags: 6, theming, ubercart, javascript
---


title: Exposed Post date filter on views

text:
# Question
Title: Exposed Post date filter on views
When you expose a filter date on views you get something similar to the following:

When you expose the post date you get:

The former is a lot more useful. Is there a way you can get the post date to look the same?

# Answer
Sure therefore add a date: filter not a node: post date.

On the date filter configuration form you can select the node: post date field and that's all you need.
> 21 votes

# Answer
To those looking to integrate this filter in a `hook_views_data()` definition in your own module (say, if you're trying to expose your own custom table to Views 2.x or 3.x), you need to have the Date installed, and then you can add in the following in your field definition:

```
'filter' => array(
    'handler' => 'date_views_filter_handler_simple', // Requires date.module.
),

```

The full field definition for a created date, updated date, etc. would be something like the following:

```
'field_created' => array(
  'title' => t('My Created Date'),
  'help' => t('When an item was created.'),
  'field' => array(
    'handler' => 'views_handler_field_date',
    'click sortable' => TRUE,
  ),
  'sort' => array(
    'handler' => 'views_handler_sort_date',
  ),
  'filter' => array(
    'handler' => 'date_views_filter_handler_simple', // Requires date.module.
  ),
),

```
> 2 votes

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


title: search with transliteration

text:
# Question
Title: search with transliteration
How I can implement transliterated searches? for example if someone write in latin characters these to be converted to another coding characters?

How I can instruct drupal that latin character a corresponds to another language character?

Or how i can integrate google transliteraion api in drupal search?

Thanks

# Answer
This is possible by implementing hook\_search\_preprocess() and integrating with the Transliteration module. Example code is below:

```
<?php
/**
 * Implementation of hook_search_preprocess().
 *
 * Transliterates text added to the search index and user submitted search
 * keywords.
 */
function mymodule_search_preprocess($text) {
  return transliteration_get($text, '', language_default('language'));
}
?>

```

There is a more complete example and discussion at http://drupal.org/node/1058064.
> 1 votes

---
Tags: search
---


title: Apache Solr Facet

text:
# Question
Title: Apache Solr Facet
I need to create some custom facets/custom filters for my search. I have Facet API installed; has anyone any experience with this? Ideally, I would use Apache Solr Facet Builder, but this only seems supported in D6.

# Answer
The Apache Solr Search Integration module gives you very good Solr integration and it is actively developed and updated. With this installed you can then go to /admin/settings/apachesolr/enabled-filters and enable a facet block for numerous fields from your content types.

Various CCK fields are automatically sent to Solr however not all are. See here for some extra guidance and check out the comments as they have some useful bits of info on enabling facets. The article is written by the main author of the module itself so he knows what is going on :)

Also http://drupal.org/node/903398 will help you for searching cck fields, note you can only search on text fields and NOT stings. String fields are useful for facets, text fields are for searching.
> 5 votes

# Answer
Facet API allows for custom display widgets by implementing a plugin. The plugin has full access to the render array, so you ultimately have complete control over the the look and feel of the facets.

Plugins are added to the system by implementing hook\_facetapi\_widgets(), which point to a class that has an execute() method. See the the plugins/facetapi/widget\_links.inc file in the Facet API module for an example of a working plugin. Other examples of cool things you can do with Facet API widgets are chart facets and tagcloud facets.

View the Render Arrays in Drupal 7 article at http://drupal.org/node/930760 for how to work with the render arrays in the plugin's execute() method.

Some example code is below:

```
/**
 * Implements hook_facetapi_widgets().
 */
function mymodule_facetapi_widgets() {
  return array(
    'mymodule_mywidget' => array(
      'handler' => array(
        'label' => t('My Custom Widget'),
        'class' => 'MymoduleMywidget',
      ),
    ),
  );
}

```

Add the class to a separate file, and set it to be included automatically as described here: http://drupal.org/node/542202

```
/**
 * My custom widget.
 */
class MymoduleMywidget extends FacetapiWidget {

  /**
   * Renders the widget.
   */
  public function execute() {
    $element = &$this->build[$this->facet['field alias']];

    // $element is the render array that will render the facet.
  }
}

```
> 4 votes

# Answer
If you are still having issues, you can check out the IndexTank module.
> 1 votes

---
Tags: search
---


title: OG homepage URL

text:
# Question
Title: OG homepage URL
My current/default group front page is groupname/node/nid

But this is quite ugly, and when clicking on the site title the user is redirected to /group which does not display the group node but only the "river". Any way to fix this? I don't want to have to individually specify node/nid as the homepage in each individual group (in any case the Panels override that I have for the "group" node type displays "Home" as the title instead of the group name when I do this, for some reason)

# Answer
Change your settings in the Pathauto module, and specify a pattern that you wish to use.
> 4 votes

---
Tags: 6, organic-groups, path-aliases, uri
---


# Question
Title: Validating and Modifying Form Data Simultaneously
I have a custom phone number field that I would like to be able to validate and modify simultaneously.

I want to make sure the field has a total of 10 digits regardless of the formatting.

The following values should all be 'valid'

```
555.555.5555
(555) 555-5555
(555) 555.5555
555-555-5555
5555555555

```

Can I have a validate function return a new value upon success? In essence, as long as there are exactly 10 digits present the validate function should return '5555555555' for every value above.

# Answer
The `$form_state` variable is passed to your validation function by reference. This means you can indeed alter the value while validating it.

```
function mymodule_myform_validate($form, &$form_state) {
  if (...) {
    // Value is valid
    $form_state['values']['my_form_element'] = NEW VALUE;
  }
  else {
    // Set form error.
  }
}

```
> 3 votes

---
Tags: 7, forms
---


# Question
Title: Content field list(text) : using correctly <img>?
I have a little problem concerning the following :

For a specific content type, I've created a field of type "List(text)", which represents the difficulty of the content ; so in the values I've entered (**I want to attach an icon to each value of that list**) :

```
easy|<img src="[image path]/content_difficulte_easy.png" alt="Easy"> Padawan

middle|<img src="[same path]/content_difficulte_middle.png" alt="Middle"> Jedi

hard|<img src="[same path again]/content_difficulte_hard.png" alt="Hard"> Jedi Master

```

I've checked that the image path is correct, but the images don't appear anywhere...!

Thanks for reading ! :)

# Answer
I tried this too and it didn't work. https://stackoverflow.com/questions/4248061/what-is-the-easiest-way-to-have-images-next-to-the-text-on-a-html-dropdown-combob you cannot put images in dropdown box in general (unless you use javascript). I tried it as a 'Check boxes / radio buttons' widget and it did work. Maybe that will be a good enough solution for you
> 1 votes

---
Tags: 7, entities, media, nodes
---


title: Doubts on Marinelli Menu

text:
# Question
Title: Doubts on Marinelli Menu
I'm trying to have submenus like the ones that can be seen on http://marinelli.netsons.org in Cameras menu item.

Could anyone point me on how can I achieve that? I don't know how to create the sections that can be seen in that submenu.

# Answer
> 1 votes
Megamenu might be of use.

> Mega menus are a type of menu drop-down, which seeks to overcome some of the usability drawbacks to traditional style drop-downs. Primarily, mega menus have two advantages:
>
> 1. The information architecture of your navigation is made clearer and is visible all at once
> 2. The amount of clicking, searching, and navigating is reduced

---
Tags: routes, navigation
---


# Question
Title: Display of multi values image field problem
I am getting this output for example image:

```
    <div class="field-item field-item-1">
        <a class="imagefield other-classes" rel="lightshow[field_photos][Exerci conventio quia causa quae probo. <br /><br /><a href="http://ita.pl/ita_drupal/sites/default/files/zdjecia/dodatkowe/filefield_c0ldK7_1.png"
  target="_blank"
  id="lightbox2-download-link-text">Download Original</a>]" href="http://ita.pl/ita_drupal/sites/default/files/zdjecia/dodatkowe/filefield_c0ldK7_1.png"></a></div>

```

I know it looks horrible, but main problem is that there is no \[img\] tag inside \[a\] tag.

Only first image of list render properly.

# Answer
> 2 votes
I could be way off, but with the information given, your problem might because of lightshow. Try another module such as colorbox

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


# Question
Title: Import a big website using Feeds XPath Parser
I'm trying to import the content of a website with thousands of posts using Feeds and its related tools.
I will import the content by accessing a page that contains all the links.

I've tried importing the content using `<h2>http://premiumtemplate.org/kaboodle-premium-business-wordpress-theme.html</h2>` as URL.

Below is the function I use:

Context: `/`
URL: `//h:h2`
title: `//h:title`
body: `//*[@class="entry"]`

I don't know what happens. It doesn't import anything, and I get the message "There is no new content."

# Answer
> 7 votes
Feeds is a very powerful module, and it is much more than a basic RSS aggregator. Many people are beginning to leverage Feeds as a migration tool, and Feeds XPath Parser is emerging as a popular way to import static HTML documents. I set up a quick parser to import this page, so hopefully the example will assist you with what you are trying to do.

First, it is important to enable the debugging options when using Feeds XPath Parser. This will show you what text was matched by your various queries.

Second, the image below shows the Context and XPath queries I used to import this page. The result is that it pulls the HTML title tag along with the content under an element containing the "question-page" class.

If you are looking to pull the header elements, I think you will have to explicitly use "h1", "h2", etc. in your XPath query, but I am not sure about this. The downside of this approach is that you will have to have a source node for every page you are importing, or you will have to find a way to batch submit the import form either programmatically or through some automated tool such as Selenium, JMeter, Firefox Macro, etc.

# Answer
> 0 votes
It's hard to give a good answer with the limited info you provided.

Usually Feeds is used to import from an feed (RSS) and not a stand alone page. Most likely you have setup feeds in a way that it expects to find a feed and not a plain HTML page.

---
Tags: 7, feeds
---


# Question
Title: WYSIWYG do not make url when pasted in a hyperlink
When I paste a URL into a TinyMCE editor using WYWIWYG it converts the text into a link.

So `http://vimeo.com/18150336` would be come `<a href="http://vimeo.com/18150336">http://vimeo.com/18150336</a>`. I would like to keep the plain text. Is their a way to configure TinyMCE to keep the link as plain text.

I do not want to strip out tags as adding a hyperlinks should be an option on the toolbar. It should just not happen by default.

# Answer
> 1 votes
**This is the solution--** On drupal administration:

*Administration » Configuration » Content authoring » Text formats*

you must remove "**Converts URL into links**" and then all it's Right!!

# Answer
> 0 votes
* In Drupal 6, go to admin/settings/filters/list
* Click "configure" for the type of input filter being used
* Uncheck "URL filter", then Save Configuration

---
Tags: 6, uri, wysiwyg
---


title: Feeds: removing text from a title

text:
# Question
Title: Feeds: removing text from a title
I am using the feeds module to import an rss feed from twitter. The feed title and body starts with ": then my tweet". I wish to remover ":" from the creation of my nodes. I can remove it in the body by using a custom input format that removes it. However I can't remove it from the title.

I suppose I have two options:

* While saving the nodes of my custom content type, remove the text
* create a custom plugin for feeds

What do you think is the best way to do this? Should I try another way?

**Update**

I added hook\_node\_presave to deal with this. As it is called on both the insert and update.

```
/**
 * Implementation of hook hook_node_presave
 */
function my_module_node_presave($node) {
    if($node->type=='mytype'){
        $node->title =  _my_module_my_function($node->title);
        $node->body[$node->language][0]['value'] =  _my_module_my_function($node->body[$node->language][0]['value']);
    }
}

```

It works great but is this the correct place to be doing the check and removal?

# Answer
> 2 votes
I think this approach is fine for your use case, since it's so unlikely you'd intentionally begin a title or body with a colon on purpose.

I'd clean up the code a bit though for coding standards like

```
/**
 * Implements hook_node_presave().
 */
function my_module_node_presave($node) {
  if ($node->type == 'mytype') {
    $node->title = _my_module_my_function($node->title);
    $node->body[$node->language][0]['value'] =  _my_module_my_function($node->body[$node->language][0]['value']);
  }
}

```

# Answer
> 1 votes
Depending on what you are trying to do, the Feeds Tamper module might be a way to do simple modifications without having to write any code.

---
Tags: 7, feeds
---


# Question
Title: is it possible to search for user names with solr?
I'm trying to allow users to be able to search and find their friends on my site. I'm not sure how to do this. Could someone guild me please?

I read that solr is not able to search usernames so instead you must convert their profile to nodes..I installed Content Profile, and migrated but still no luck. Not sure how to do this.

please help!

Thanks!

# Answer
> 1 votes
Regarding the Content Profile module, as long as anonymous users have access to view the profile nodes, the content should be able to be indexed by Solr. You can use the Automatic Nodetitles and Token modules to ensure that the username is set as the Content Profile node's title. You might want to set the field bias for the title to a higher value so more importance is placed on it when ranking search results.

Normal users probably can't see the core User search because they don't have the "access user profiles" permission. If they are granted that permissions they should be able to use the core User search.

---
Tags: search
---


title: views... display random node on click

text:
# Question
Title: views... display random node on click
I'm trying to create a view that's like a randomizer like this: http://www.celebritynetworth.com/richest-celebrities/snooki-net-worth/.

I'm not sure out I could activate the view on a click of a button. Then the view would have to display totally random nodes from the terms I've filtered it to display. Would anyone know how I could do this? Thank you.

# Answer
First, it is important to note that true randomizing is an expensive operation. The method involving Views will work with little effort, but if the site experiences very heavy traffic it could tax your database server to a point where it collapses.

The easiest way to accomplish this would be to create a View displayed as a block and filter by the appropriate content type. Use a "Global: Random" sort to randomize the content and configure the paging options to show only one result. Make sure you are displaying "fields" and not full nodes, then add the node title as a field. It should be configured by default to link to its content, but verify this in the field's settings. Instead of displaying the title of the page, you will want to display the text "Random" which can be accomplished by using the "Rewrite the output of this field" setting. Then you can place the block where you want and style the link via CSS to look like a button. Clicking on the button will then take you to a seemingly random node.

For a more scalable solution, you might want to move away from Views and leverage JavaScript for the randomizing. On the backend you would queue up a handful of nodes and have JavaScript decide which one to display, thus taking the randomizing task off of the database. It will be limited to the handful of nodes you pre-select, but your database will thank you in the long run.
> 2 votes

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


# Question
Title: View for the user followed by the author of a node
I have installed the Flag module, and I have a view that displays how many followers (flags) an author has. How do I reverse that query, and output how many users that author is following?

# Answer
This is a little tricky, but it is very similar to the article posted at http://drupal.org/node/326580.

* Create a view of users
* Add the "Flags: User flag" relationship making sure that the flags are by **any user**.
* Add the "Flags: User" relationship which will allow us to filter by the person who did the flagging.
* Add a contextual filter (D7) / argument (D6) fir the "User: Uid" and make sure is uses the "Flag user" relationship.
* In contextual filter / argument, select the "Provide default value" option and add the following code snippet to pass the node author as the value.

Code snippet:

```
if ($node = menu_get_object()) {
  return $node->uid;
}

```

In order to get the count it will depend on whether you are using Drupal 6 or Drupal 7, but using the Views Group By module for D6 or the internal Aggregation features of D7 should be able to get you the number of users.
> 1 votes

---
Tags: views, flags
---


# Question
Title: Need Module for Images/Video in Node, works with Views
I'm using d7.2. I have been searching and working on this all day- can't figure it out. So I'm posting here for some help...

I have a Node that I want the users to be able to upload images and/or video to. They can upload either or BOTH if needs be. They can upload a single image, multiple images, single or multiple videos (3rd party hosted- you tube, vimeo, etc), or a combination of images and video.

I'd like for it to be displayed in a nice looking format- kind of like gallery formatter does (can't seem to get that to work for me) with a larger image on top/middle, and thumbnails of the others on the side or bottom. When the user clicks on the larger image, it'll open in lightbox.

I need it to work with views, as I'll be attaching a voting module to it, as well as others that will implement with Views.

I am really stuck and frustrated on this one. There doesn't seem to be any solid modules that can handle this- unless I'm just not seeing it.

I sincerely appreciate any/all help!

# Answer
> 1 votes
For handling the video, check out the Media module or the Video module. These will allow you upload, manage, and reuse video files.

For images, these features have been put into Drupal core, so you shouldn't need an extra module for uploading, managing, and displaying images.

Once set up with that, you can theme the display of the fields and if you choose, add other modules (such as Lightbox2) to enhance the user's experience).

# Answer
> 0 votes
Try could try out this module: Media Front

> The MediaFront module is a front end media solution for Drupal. It employs an innovative and intuitive administration interface that allows the website administrator to completely customize the front end media experience for their users without writing any code. In addition, this module provides an interface to which 3rd party media players can integrate and utilize settings presets to display rich media. Out-of-the-box, this module provides two media player solutions.

---
Tags: views, nodes, media, files
---


title: Book module versus Taxonomy module

text:
# Question
Title: Book module versus Taxonomy module
The Book and the Taxonomy modules are very similar for organising content in a hierarchy structure.

Both modules:

* Allow Multi level hierarchies
* Can be accessed by Views
* All custom theming via node.tpl.php files
* Offer the means for promoting or demoting content within a hierarchy, or moving it to another hierarchy

The Book module has the added advantage of creating navigation system (Although you could probably recreate this with taxonomy and Views).

My question is this: Which is the better to use for organising content in a hierarchical structure? Does one have any disadvantages or advantages over the other?

It seems odd to me that two similar modules exist in core. Why aren't they just combined into one?

# Answer
> 5 votes
The difference is that the Book module defines a content type ("Book page") that can be used to create books. The Book module allows also to create a hierarchical structure, and it shows:

* the list of the child pages associated with the current book you are visualizing
* a menu that allows to pass from a page to the next one, the previous one, and the top one
* a link that allows you to create a new child page
* a link that allows you to see a printable version of the current book page

The Taxonomy module is used to categorize the content of a site, but when you click on the link of a taxonomy term used by a node, the page you see shows all the nodes using that taxonomy term, without allowing you to pass from a node to the successive, or the one hierarchically on the top.

Said in sort, the Taxonomy module handles an attribute (in Drupal terminology is a field, handled with the field API) that can be associated with nodes, but also to users, while the Book module defines a content type that can be used to create books, and allows to handle that content type in a hierarchical way.

---
Tags: taxonomy-terms, nodes
---


# Question
Title: Changing size of user avatar in template file
In node.tpl I currently display a users avatar' using this code

```
theme('user_picture', $account)

```

My avatars are currently set to 85x85px but when they are displayed in nodes I want them to be smaller. How can I change the size for just this inclusion of user avatars?

# Answer
Although iStryker's suggestion works I found a simpler, easier to manage way.

I had to install imagecache and imagecache\_profiles then I simply put this in my template (after creating a new preset in imagecache)

```
$account->imagecache_preset = 'NAME_OF_PRESET';
print theme('user_picture', $account);

```

I did some googling after someone suggested Imagecache and found the above code here: http://drupal.org/node/374372
> 1 votes

# Answer
This is definitely the command you want to run

```
theme('imagecache', 'your_custom_preset', $picture, $alt, $alt);

```

You will have to install imagecache module for Drupal 6. Its in core for Drupal 7. You have to define 'your\_custom\_preset', in the imagecache profiles.

The other place you can theme the avatar is inside the function `[YOUR_THEME_NAME]_preprocess_user_picture(&$variables)` and again use the same line as above. for more information checkout the api.drupal.org documention on this issue
> 2 votes

# Answer
you can modify line modules/user/user.module line 425:

```
'file_validate_image_resolution' => array(variable_get('user_picture_dimensions', '85x85')),

```

or

create user-picture.tpl.php in your theme folder:

```
<div class="picture">
    <?php print $picture; ?>
</div>

```

and modify above code. use below code to understand what you should do:

```
global $user;
print_r($user);

```
> 1 votes

---
Tags: theming, media
---


# Question
Title: Bulk import images into content image field
I've created a content type called "Products" wich has the following fields:

code (Product's id)
Title (Product's name)
Description
Image (Product's picture - image field)

I've imported a list of products from a CSV file using Feeds module. So far everything is ok. Except for the pictures.

Then I have a lot of pictures (3000+) that I need to do a bulk import into each product's image field.
The picture's files are named product\_code.jpg, e.g.: 001.jpg being the image of the product 001, 002.jpg for the product 002... and so on.

I've searched for modules that could do this kind of import, but have found none.
I took a look at the database and I'm thinking about uploading the files to the server via FTP and alter the tables by hand, since the filenames = product's code.

What's the best method for me to do this kind of import? Is there any module I am missing?

Thanks!

# Answer
> 4 votes
Why don't you make a new csv field for the images with a relative path to each image as the row value? Then when you import the nodes using Feeds, the image field will automatically have a link the the image

---
Tags: 7, entities, feeds, importing-exporting
---


title: Do entities need to have URIs?

text:
# Question
Title: Do entities need to have URIs?
I am trying to figure out the best way to manage some data. I don't want it to be accessible like nodes through any kind of URI. I know that, when entities are defined, I have to provide a URI callback. Is this callback necessary?

I mostly want to use entities because the API makes it easy (and standard) to work with data.

# Answer
> 3 votes
1. You don't have to define a uri/URL callback.
2. Defining one won't make your entities visible to users, you have to create a menu callback to make them visible.

---
Tags: 7, entities
---


title: Views/Views slideshow confusion

text:
# Question
Title: Views/Views slideshow confusion
I am trying to create a slideshow that would be showing 3 instances of my custom contant type "Slideshow Image".
After spending hours without any success I've decided to seek help! I noticed that Views changed a lot when I updated all modules, and it seems as if Slideshow is not among the options for display under "Format" in the control panel of my view. I have Grid, HTML list, Jump menu, Table, Unformatted list but no slideshow. Now, I think I remember seeing "slideshow" as an option before "Views" changed! My questions are:

1. Have Views changed so that Slideshow is no longer an option for display? Am I going insane?
2. If it has, what is the new way of doing things?
3. If it hasn't, what could I be doing wrong?
4. There is a module called "Views Slideshow". It seems to not be fully ready for Drupal 7 yet. Do I need it? Is that my only option (as a Drupal & web programming newbie)?

Can anybody please help me clear this out?

# Answer
> 1 votes
Views Slideshow does not come with the views module. Therefore you will not see it by default. You have to download and enable the views\_slideshow module to see this option.

There is alot of other contrib slideshow modules as well

Related modules

Most of these module does not have a supported Drupal 7 version, however most of their Drupal 7 dev version will be stable enough to use. I know I have used views\_slideshow\_ddblock without any troubles.

# Answer
> 0 votes
Drupal 7 modules usually need a bit to catch up as they're all so new. You should always be using the dev versions unless this is a production site. I believe Views 3 (which it sounds like you're using) was a significant update that required a little more than just running the update.

Views Slideshow gives the following warning:

> If you don't have http://drupal.org/project/libraries module enabled then please enable that module before you upgrade to the latest alpha release of version 3. It is now a required module and you will receive a fatal error if you don't have that module enabled first. See this issue for ways to fix it if you receive the fatal error.

http://drupal.org/project/views\_slideshow

---
Tags: 7, views
---