# Question
Title: Security considerations for special characters in usernames?
I would like to create some users on a Drupal site where the usernames are actually company names and some of those company names contain ampersands or other non-alphanumeric characters.

I have read this answer which describes how that might be achieved (by overriding the form validation for creating/editing a user).

My question is: Would there be some security risk in allowing special characters such as &/#?()+ in usernames, or did the Drupal developers make these characters illegal purely for aesthetic reasons?

# Answer
I can think of three concerns when it comes to usernames and security: Cross Site Scripting (XSS), SQL Injection, and Homograph "attacks".

As long as you don't allow the \< and \> in usernames then you don't have to worry about XSS. If you want to allow one or both of those then you need to be more suspicious and do a thorough test of your site for XSS by entering a malicious username and seeing what happens.

SQL Injection should not be a problem. This has largely been solved in Drupal for a while and DBTNG in Drupal 7 makes it even less common. You could still test for it with some weird usernames that contain '; and other character combinations.

Homograph is then the worst thing. For a while (maybe still) you could register a username like Admin which looks a lot like Admin but in fact uses the MATHEMATICAL BOLD CAPITAL A from the list of confusables. The problem would arise from someone using a username that is a homographic match to a known "admin" on your site to register on the site and then using the contact or private message feature of the site (or even a public node/comment) to trick other users of the site into doing something stupid (e.g. posting a message "Our site is having login problems, please go to http://sitename.evil.example/password-reset and enter your credentials to have your login fixed."). By adding more characters to the allowed set of username characters you make a homograph social-engineering attack more likely/easier. I don't consider this to be a big problem and you should consider whether this is really a problem for your site before worrying about it.

The Real Name module is meant to give you this ability without the form alter. I don't think it's really any safer for homograph attacks, though.
> 2 votes

# Answer
Security? Not really, as all database communication is now wrapped in prepared statements. But they may break your URLs, as Drupal core is not really prepared to handle URL-unsafe usernames.

I suggest leave them be, and just add a field to a profile, call it "display name", and use it instead of username whenever you need a pretty name with URL-unsafe characters. It will be easier than changing default username handling.
> 1 votes

---
Tags: users, security
---


# Question
Title: Using nested node content type template files
Using Drupal 7 I have setup a structure in which a widget\_set content type has a node reference field that allows the user to choose nodes of the content\_widget content type.

The template files are `node--widget_set.tpl.php` and `node--content_widget.tpl.php`

Inside the `node--widget_set.tpl.php` template, I call print render($content); and was hoping to have the output be formatted as specified in `node--content_widget.tpl.php`, but I just get output that seems to ignore the content\_widget template.

Is that the expected behavior? I could just pull the code from the content\_widget template into the widget\_set template but I have a bunch of content\_widget types and wanted to keep them all separate.

Thanks.

# Answer
Assuming you want the structure to be something like this:

```
<div class='node node-widget_set'>
  <!-- other fields -->

  <div class='node node-content_widget'>
  </div>
</div>

```

ie, render the template inside the the other template, and assuming you have named your templates properly, put them in your theme, and cleared the theme registry (or cleared all caches), you need to set the display settings appropriately.

In the **Manage Display** settings for **Widget Set**, find the **Content Widget** field, and adjust the settings:

* Set the **Label** as you need
* Set the **Format** to **Rendered entity**
* The click the gear, and adjust the settings. You can pick the view mode (full, teaser, etc), whether to show links or not, and potentially other settings that modules have defined.

Note that this does assume your node-to-node fields are using Entity References and not Node References.

Then you should get output to use nested templates. Using Entity View Modes and Rabbit Hole also come in very handy when you do things like this on your site.
> 1 votes

# Answer
Drupal will only use one node template file based on the template suggestions. So if you have two content types Drupal will look for node--\[type\].tpl.php first and if that is not found then use node.tpl.php.

One node template file will not inherit from another node template file. So you'll need to create two node template files, one for each content type.
> 0 votes

# Answer
If you need to share one template between two types then the easiest way is to add something like this to your template.php file. Sorry if I missed the point I did not completely understand the problem.

```
function hook_base_preprocess_node(&$variables) {

    if(node_is_page($variables['node']) && ($variables['type'] == 'node-type1' || $variables['type'] == 'node-type2')){
      $variables['theme_hook_suggestions'][] = 'node__your_template';

}

```
> 0 votes

---
Tags: 7, theming
---


title: Render array doesn't render children

text:
# Question
Title: Render array doesn't render children
I can't add a form to a node. Using the following code, the generated HTML show only the node. If I return $form, the form is rendered correctly. What is my mistake ?

function hook\_menu() {

$items\['presse/rss'\] = array(

```
'title' => 'RSS',
'access callback' => TRUE,
'page callback' => 'press_rss_page',
'page arguments' => array('fr'),
'menu_name' => 'nav-fast-links-fr',
'file' => 'press.rss.inc',
'type' => MENU_NORMAL_ITEM,

```

);

FILE: press.rss.inc

function press\_rss\_page($lang) {

```
     $nid = variable_get('press_rss_nid_' . $lang, 0);
     $page = array();
     if ($nid) {
        $page = node_view(node_load($nid));
     }

     $path = $_SERVER['HTTP_HOST'];
     $path .= $lang == 'fr' ? '/presse/rss/' : '/press/rss/';
     $form['#weight'] = 1000;
     $form['container'] = array(
        '#prefix' => '<div class="rss-url-block">',
        '#suffix' => '</div>',
     );

     $form['container']['all']['title'] = array(
        '#markup' => '<h3>' . 'All the press room content' . '</h3>',
         );
     $form['container']['all']['text'] = array(
        '#type' => 'textfield',
        '#title' => t('All the feeds', array(), array('context' => 'frontend')),
        '#value' => $path . 'all',
        '#disabled' => TRUE,
        '#id' => 'rss-1',
        '#attributes' => array(
        'onClick' => "this.select();",
        'readonly' => 'readonly',
),

```

);

```
  $page['form'] = $form;

   return $page;

```

}

# Answer
> 0 votes
Return your renderable page build with 2 entries, one for the node and one for the form:

```
return array(
    'node' => $page,
    'form' => $form,
);

```

---
Tags: forms, theming
---


# Question
Title: Error with Node_load() - : Base table or view not found
I implemented a function to load nodes which it is loaded from a unitary test..

```
function labdoo_rest_get_laptop($id) {
    $node = node_load($id);
    return $node;
    }

```

And i get an error like this:

```
    Test PDOStatement->execute() failed: <em class="placeholder">PDOException</em>: SQLSTATE[42S02]: Base table or view not found: 1146 TabTest PDOStatement->execute() failed: <em class="placeholder">PDOException</em>: SQLSTATE[42S02]: Base table or view not found: 1146 Table                    [error]
'lbd.simpletest291431node_type' doesn't exist: SELECT nt.*
FROM
{node_type} nt
WHERE  (disabled = :db_condition_placeholder_0)
ORDER BY nt.type ASC; Array
(
    [:db_condition_placeholder_0] => 0
)
 in <em class="placeholder">_node_types_build()</em> (line <em class="placeholder">738</em> of <em
class="placeholder">/var/www/lbd/modules/node/node.module</em>).
le                    [error]
    'lbd.simpletest291431node_type' doesn't exist: SELECT nt.*
    FROM
    {node_type} nt
    WHERE  (disabled = :db_condition_placeholder_0)
    ORDER BY nt.type ASC; Array
    (
        [:db_condition_placeholder_0] => 0
    )
     in <em class="placeholder">_node_types_build()</em> (line <em class="placeholder">738</em> of <em
    class="placeholder">/var/www/lbd/modules/node/node.module</em>).

```

The error is difficult to read... anyway i can understand it is trying to load the node from the database 'lbd.simpletest', but it is not correct!!, I don't know why it is trying to do this.... I tried the 'db\_set\_active' operation, but i receive the same error, also i could get the node information with sql\_query but i prefer this method, it seems better.

My file (with name labdoo\_rest.test) to test the SQL function is:

```
<?php

//TODO Add comments

class LabdooRestUnitaryTest extends DrupalUnitTestCase {

  public static function getInfo() {
    return array(
      'name' => 'Labdoo REST test functionality',
      'description' => "Test SQL  operations: Review functions with SQL queries. ",
      'group' => 'Labdoo'
    );
  }

  function testHelloWorld ()  {
        print "test message\n";
        $this->assertTrue(TRUE,"My first test works");
 }
 function testGetLaptop ()  {
        $id=2;
        $result = labdoo_rest_get_laptop($id);
        print "$result"."\n";
        $this->assertTrue(TRUE,"Test get laptop");
}

}

```

Thanks for your help...

UPDATE:

* $id = 2; \<- it is the node's nid, and the node exists
* I proved var\_dump($node) but I didn't receive results because my error message is an exception (PDOException).

UPDATE2:

* I tested `drush php-eval "print print_r(node_load(2), 1)"` and it returns the correct information.
* I am using druh with `drush test-clean && drush test-run
...` to run the function. I suppose the problem is related to the `drush test-run` call.

UPDATE3: \- My code in the Github project: https://github.com/Labdoo/Labdoo-2.0/tree/features/web-services-api/modules/custom/labdoo\_rest

# Answer
Maybe you should define on the test class what profile are you using. Somehow simpletest does not detect it automatically. Without knowing which profile to install, it will not know what is a laptop node, because this content type has not been created. You can try to define on the test class the attribute:

```
protected $profile = 'labdoo';

```

See as an example: https://github.com/dashohoxha/oauth2\_client/tree/7.x-1.x/tests

In particular, the shell script can be interesting: https://github.com/dashohoxha/oauth2\_client/blob/7.x-1.x/tests/run\_tests.sh
> 0 votes

---
Tags: database, nodes
---


title: How to implement a hook?

text:
# Question
Title: How to implement a hook?
I've been told I should implement this hook thing, what does that mean?

# Answer
The details for how to implement a hook varies from one hook to another.

One of the easiest examples though, is hook\_init(). Hook init is a generic way of saying "Do something on every un-cached page load". The \_un\_cached part is important, if you are logged out when testing this, probably nothing will happen.

In a module file named "my\_module.module", one would implement hook\_init like this

```
<?php
my_module_init() {
}

```

To make something actually happen, we can add a call to drupal\_set\_message().

```
<?php
my_module_init() {
  drupal_set_message('Hello Drupal!');
}

```

If you have Devel installed, a common way to do debugging could look something like this:

```
<?php
my_module_init() {
  dpm(menu_get_item());
}

```

For more details and examples, see What is the basic concept behind hooks?
> 4 votes

---
Tags: hooks
---


# Question
Title: Implementation of hook_file_default_displays() {media module} makes it impossible to export image display settings via features
This is a issue I am dealing with for days. It looks like is related to: https://drupal.org/node/1702700

I've created a feature relying on media, file\_entity and media\_youtube, vimeo... whose main purpose is to embed youtube, vimeo videos etc.

I've correctly set up the file\_entity displays weights: Structure » File types » Video » Manage file display so that the thumbnails shows ok

```
    e.g
    "Large filetype icon"   weight: 50
    "Youtube Image Preview" weight: -40.
    {GOOD}

```

```
After complete feature export,
"Large filetype icon" weight: 0
"Youtube Image Preview" is set 2.
{WRONG}

```

I even edited manually the feature's .info and default\_displays.inc file with no luck.

Secondly, there are also feature overrides unable to revert. It looks like somethings alters the file display weights.

# Answer
> 0 votes
The problems comes from the heart of Media module which programatically add default overrides.

I have managed to solve the problem in 2 steps: (1) Sunk the Media Icon to the bottom

apply a patch to Media module:

```
--- sites/all/modules/contributed/media/media.module
+++ sites/all/modules/contributed/media/media.module
@@ -1082,7 +1082,7 @@
   $file_display = new stdClass();
   $file_display->api_version = 1;
   $file_display->name = 'video__preview__file_field_media_large_icon';
-  $file_display->weight = 0;
+  $file_display->weight = 50;
   $file_display->status = TRUE;
   $file_display->settings = '';
   $file_displays['video__preview__file_field_media_large_icon'] = $file_display;
@@ -1093,7 +1093,7 @@
   $file_display = new stdClass();
   $file_display->api_version = 1;
   $file_display->name = 'audio__preview__file_field_media_large_icon';
-  $file_display->weight = 0;
+  $file_display->weight = 50;
   $file_display->status = TRUE;
   $file_display->settings = '';
   $file_displays['audio__preview__file_field_media_large_icon'] = $file_display;
@@ -1104,7 +1104,7 @@
   $file_display = new stdClass();
   $file_display->api_version = 1;
   $file_display->name = 'document__preview__file_field_media_large_icon';
-  $file_display->weight = 0;
+  $file_display->weight = 50;
   $file_display->status = TRUE;
   $file_display->settings = '';
   $file_displays['document__preview__file_field_media_large_icon'] = $file_display;

```

(2) I exported my feature but manually edited the File Display like this:

YOURFEATURE.features.field.inc

For Default the order is

```
Vimeo
Vimeo Preview
Youtube
Youtube Preview

```

For Preview the order is

```
Vimeo Preview
Vimeo
Youtube Preview
Youtube

```

---
Tags: media, files
---


# Question
Title: A clean solution for adding _target attribute on flickr thumbnails
I have a module relying on media\_flickr.

Some images in the body are thumbnails with anchors:

```
<a class="" href="http://www.flickr.com/photos/28040142@N07/10785045611">
<img alt="" src="http://farm3.staticflickr.com/2847/10785045615_41c12c8f99_q.jpg" typeof="foaf:Image">
</a>

```

What hook to use to add the \_target HTTML attribute on links?

The markup is to be found in

```
body['und'][0]['safe_value']

```

I prefer not to use javascript.

# Answer
In simple words, the story can be put like this:

```
(function ($) {
    Drupal.behaviors.yournamespace = {
        attach: function(context, settings) {
            $("a[href^='http://www.flickr.com']").attr({
                target : "_blank"
            })
        }
    }

})(jQuery);

```
> 0 votes

# Answer
There isn't one - links contained in HTML in a node body are not structured, do not run through `l()`, and no opportunity is given to 'hook' into them during rendering.

You have 3 options:

1. Change the markup to include the target attribute.
2. Preprocess the field and run a regex replace on the HTML to add the attribute.
3. Use javascript (by far the best option).
> 1 votes

---
Tags: javascript
---


# Question
Title: How do I include taxo description in a View's no argument summary?
I've got a view with an argument based on taxo terms that shows a summary list when no argument is present. Now I need the list of terms to include a description for each one. Clearly the logical way to get this is to include the taxo description under each term, but I don't see how to do this. Drupal 6, views 2.

I'd be willing to take a stab at writing a Views plugin to get this functionality, but I don't really know where to start. I do have some idea how to get the taxo description through code, but now how to integrate that into a Views no argument option. Any suggestions?

# Answer
> 0 votes
Hmm. Interesting that no one replied to this. I would have thought this was a common need.

Turns out the answer was not a plugin but another display. Using the Views Group By module (https://drupal.org/project/views\_groupby \- thanks Phase2!) I created a page with the summary links but also including the taxo description. Made the links bring up the other display, and all is well.

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


# Question
Title: Multigroup field in view only showing single delta
How are CCK multi groups handled in a view? Because when I select the fields for the views, they come with a "delta" field:

The delta fields are always empty, so it doesn't work out of the box. The delta fields are always empty in the table view.

Is there any way I can have support for multigroup fields, or even a way to concatenate the delta's of the three fields ('Naam', 'Bedrijfsnaam', 'E-mailadres') for each delta?

# Answer
OK, to get this to work on Drupal 6, CCK 3 and Views 2, I spun up a testbed on the ever trusty Pantheon and created a content type:

and then created three nodes, the first one had two sets of name/biz/email, the second had one and the third had three.

I then created a View:

with these results which I hope is what you were after.

Things that needed to be done differently:

One. Add in that Content multigroup filter. I just chose 'Name' as the field to join on.

Two. Turn off all grouping of the Fields, eg uncheck this in their setup:

Three. Put all the values in the Global Custom Text field:
> 1 votes

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


title: Rewrite Link to taxonomy page in Views

text:
# Question
Title: Rewrite Link to taxonomy page in Views
I am using views to show a list of items from a vocabulary, I want a link under each item to the friendly url for the full view. Currently I am using the rewrite results in views like this:

```
<a href="taxonomy/term/[tid]">Find out more about [name]</a></p>

```

How can I get the friendly url that is setup in pathauto i.e. /partners/google?

# Answer
> 1 votes
You can set

```
Find out more about [name]

```

(without the anchor tag) in `Rewrite the output of this field`, and then use the `Output this field as a link` option and set that to

```
taxonomy/term/[tid]

```

Views will rewrite the link according to Url Alias settings.

---
Tags: views, path-aliases
---


title: Basic Page - Associated Image Field

text:
# Question
Title: Basic Page - Associated Image Field
I created an Image Field for the Basic Page Content Type.

I want to control the output of this image to use as a banner with a caption on top. Is there a function to render out a field specific to the page,

such as `<?php print render($page['my_image_field']); ?>`.

I wan't to style this separately from the body content.

# Answer
> 1 votes
You can do this within a tpl file specific to your content type. In this case it sounds like it'd be node--page.tpl.php

All the drupal 7 template naming suggestions are available at - https://drupal.org/node/1089656

Just make sure you have a regular node.tpl.php file in your theme before creating the new one.

From there this thread tells you how to go about printing your field elsewhere (specific to drupal 7)- https://drupal.org/node/1059636

Specific to your question:

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

```

then wherever you want your image to appear at use

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

```

---
Tags: theming, media, entities
---


# Question
Title: Architecture advice for site with lessons that belong to courses
I need to build out a site that features courses and lessons, each defined as a content type. I currently have the site running with lessons linked to courses using entity reference (entity reference field is in lessons) and use EVA to attach a view of lessons to each course. (see screen below for reference)

This works fine, however I now have a new requirement to allow lessons to be re-used across multiple courses. This means:

1. Courses can contain multiple lessons
2. Lessons can appear in more than one course
3. Lessons appear in "sections" which are custom per course
4. Lesson and section sort order is custom per course
5. Courses need to be able to handle up about 150 lessons per course

Since lessons need to appear in sections, the link requires both a reference and a section. I've experimented building this out with field collections embedded in the course entity. This works pretty well, but performance degrades significantly after about 30 lessons are added to a course.

To avoid the performance problem, another approach I'm considering is to code a compound field (entity reference with a text field) that would be added as an unlimited value field to the course content type.

Before I try the compound field approach, I'm seeking input/advice on the architecture for this solution. Given the requirements, and available D7 functionality, what approach makes most sense?

# Answer
How about this unproven setup.

Create a third content type, Sections. Courses reference sections with a mutli-value entity reference field, which you can drag/drop the order of this field from the node edit form. You can use inline entity form to assist with content creation.

Then, reference Lessons from Sections with a multi-value entity reference field, also allowing you to drag/drop the order of the field values. Not sure if you can use the inline entity form within an inline entity form...maybe.

Then, you can continue to use EVA on both the courses and sections to display view results, using a node id contextual filter...I assume.

Or, you could just render the referenced entity, selecting a custom display mode, which you theme accordingly. This may offer better performance.
> 0 votes

---
Tags: 7, entities
---


# Question
Title: Setting menu weight for "Edit" and "View" items in a node
I am trying to rearrange the order of my menu items for my custom node. Most of the menu items are created programmatically in hook\_menu() so I can simply set the weights for those which works great. But I would like to move the edit menu item down the list a bit but I can't find a way to change its weight from the default of zero.

Is this possible?

# Answer
> 1 votes
I believe you can do this with hook\_menu\_alter().

Another option would be to leave the edit at 0 and change the weights of the items you can adjust to work around the edit.

---
Tags: 7, routes
---


# Question
Title: Need to filter events from the current week only
I am using drupal 7 & views for a simple event agenda website. I need to display content for the current week only. How do I filter those with views? For example, I need to be able to set an event that will show only through week number 36. thanks!

# Answer
Views can do this.

Add a contextual filter for the date field you're trying to filter. In the "Preview with contextual filters" box, you will be able to specify something like "2012-W34" (Edit: or any other valid date format for that matter) to say year 2012 on week 34. Use PHP's date() function to retrieve the current week and pass that as an argument to your view. This will give you your current week while avoiding current day +/- 7 days.

Edit: When passing the argument to your view, be sure it's a string in the date format and not just a week number.
> 3 votes

# Answer
Jimajamma's method does the job perfectly and is easily applied; only the start date should be set to `this sunday` instead of `last sunday` (or whatever you choose as the first day of the week). With `last sunday` you get the results of the entire past week if the current date is a sunday itself.
EDIT: It shows that neither 'this' nor 'last sunday' will provide consistent results. The best method to get an invariable current week frame, no matter which day is now, seems to be the one described here (via this):

```
$start_of_week = strtotime("next monday - 1 week"); // Will return Monday of the current week starting at 00:00:00"
$end_of_week = strtotime("next monday - 1 second"); // Will return Sunday of the current week ending at 23:59:59"

```
> 1 votes

# Answer
For the current week, Views can do this very easily by selecting a plain old filter on a date field of your choosing and then selecting `is between` for the operator and putting `last sunday` in the `date default` and `this saturday` in the `to date default`.
> 0 votes

---
Tags: views, theming, datetime
---


title: Multisite drupal bootstrap

text:
# Question
Title: Multisite drupal bootstrap
Is it possible to bootstrap a particular drupal 'settings.php' ?

I've gotten bootstrap to work with the default site only.

# Answer
> 1 votes
I ended up using this code:

```
chdir('/path/to/drupal/sites/example.com/');
define('DRUPAL_ROOT', '/path/to/drupal/core');
require_once('/path/to/drupal/includes/bootstrap.inc');
drupal_override_server_variables(array('url' => 'http://example.com/'));
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

```

It could perhaps be more efficient but it works from crontab.

---
Tags: 7, bootstrapping
---


# Question
Title: How do I change the output of a database query from an integer to a string?
I'm working on a module that has a form that that submits to a database table and then queries that database to place that information in a table on another page. Everything works like I want with the exception of the 'country' entry which is a select box on the form and returns a numeric value (0,1,2, or 3). I would like to display in the table the text of the country instead of the numeric value. I have tried elseif statements and arrays and have been able to get the text string to display on the page but not replace the number in the table. I just learning to write modules and any insight would be greatly appreciated.

```
function drupalform_form1_submit($form, $form_state) {
  $d_id = db_insert('drupalform')
    ->fields(array(
      'name' => $form_state['values']['name'],
      'last_name' => $form_state['values']['last_name'],
      'email' => $form_state['values']['email'],
      'country' => $form_state['values']['country'],
    ))
    ->execute();
   drupal_set_message("Form has been submitted");
}

function drupalform_submissions() {
  $query = db_select('drupalform', 'df_list');
  $query
    ->fields('df_list', array('d_id', 'name', 'last_name', 'email', 'country'))
    ->range(0, 50)
    ->orderBy('df_list.d_id');
  $results = $query->execute();

  $header = array(t('ID'), t('First Name'), t('Last Name'), t('Email'), t('Country'));
  $rows = array();

  foreach ($results AS $result) {
    $rows[] = array(
      check_plain($result->d_id),
      check_plain($result->name),
      check_plain($result->last_name),
      check_plain($result->email),
      $result->country,
    );
  }

  return theme('table', array('header' => $header, 'rows' => $rows));
}

```

# Answer
The numeric value from the country is essentially a database lookup value to either a Taxonomy Term, a Countries entry ... or whatever module you're using to reference the location. This is typical DB usage, store keys -- not (text) values of the data. If it was a taxonomy term you could do:

```
function drupalform_form1_submit($form, $form_state) {

  // Lookup the value for the country id key, somewhere, here I assume Taxonomy.
  $country_term = taxonomy_term_load($form_state['values']['country']);
  $d_id = db_insert('drupalform')
    ->fields(array(
      'name' => $form_state['values']['name'],
      'last_name' => $form_state['values']['last_name'],
      'email' => $form_state['values']['email'],
      // Store the country text value, for Taxonomy Terms thats the name value of the object.
      'country' => $country_term->name,
    ))
    ->execute();
   drupal_set_message("Form has been submitted");
}

```

Assuming your using Taxonomy Terms as countries, and the `TID` is in only 1 Taxonomy. You would use the same approach with any 3rd party location module.
> 0 votes

---
Tags: database
---


title: Automatically Create View

text:
# Question
Title: Automatically Create View
I'm not even sure I know enough about Drupal to ask the question properly, but here goes. I've managed to make a drupal view that displays submitted locations on a map of people who all received the same physical card. Under the map, anecdotes etc of how people received that card appear. I'll spare you the rest of the details.

You can see what I mean here: http://www.wwghosting.com/sevendeg/final-leaf-test

Anyway, what I would like now is: if someone searches the site, for say card 2701, they will be shown a page that looks like that.

The problem is, I had to manually make that view with a filter that filters out card #2701 and anyone who submitted that card.

If I had to do it that way, I'd have to make 5000 views manually if we had 5000 cards. Also, the map there is just shown in the header of another view, so really, it's two views in one page.

What I want is for a display similar that to be automatically made if someone searches for card 2701. Or once they submit a card, I want them to be redirected to that page.

I think somewhere I read that it is possible to render a view from URL info, but not sure if that's the way to go about things.

Thanks in advance for any help/guidance.

-Todd

# Answer
What you're looking for is Contextual Filters. Rather than creating many views, you create one view that accepts an argument to change the value of one or more filters. In your case, the filter is the card number.

There are many ways to do this. One way is to pass the value of the card to the view by URL argument. This can be done with query string parameters at the end of the URL (which you can set as hard links in HTML that the user clicks on. Another option is using a very specialized configuration of Panels module, where it will pass a URL argument to a view which is contained in one of its panel panes. See https://drupal.org/node/1584046

Those options are only necessary if you need the value to be pre-populated when the user visits the page. They are a bit tricky to implement, but something that Drupal does very well once you know how to configure it.

The other option is to set an exposed filter on your view. On the view configuration page, click on your filter and check the box to expose the filter. Then, there will be an input area when you load the view on your page, which will accept any valid values for your filter.
> 0 votes

---
Tags: views
---


# Question
Title: Update database with data from dev site?
I've made changes to 12 nodes on a site that already has about 4000 nodes. I'd like to be able to push these changes to the database without affecting any other data (and without having to redo all the changes by hand).

Problem is, this is a live site, so if I try to simply import the updated database I'll lose some data. What is the best method for doing a partial update? -JB

# Answer
Jordan.

Unfortunately, this is not something that Drupal does very well.

You can try using the Deploy module, but in my experience as a professional developer, I have never met anybody who has found a good way to export nodes in a way that is thorough, consistent, and safe.

More specifically, Deploy may not support all field types, and sometimes field definitions are hard to find, and can be inconsistent (for example, taxonomy terms are exported as TIDs, which change if the term is deleted and then added again).

Sorry for the bad news.
> 0 votes

# Answer
If the node structure is not too complex you could export the nodes using https://drupal.org/project/node\_export and use feeds module to import on live website. Rembember to always backup the data on the live website before trying.
> 0 votes

---
Tags: database
---


# Question
Title: Why Views is ignoring my field override, and printing fields regulary?
You can see the question I am reffering here

I wrote a .tpl file to override the output of some fields. I wanted the field will be printed with html like below (and succeed on doing so). here is the output, when I am printing the field as a panel, through panels:

```
<div class="field field-name-field-preptime field-type-number-integer field-label-hidden">
<div id="md11" class="field-items">
          <div itemprop="prepTime" class="field-item even"></div>
      <time datetime="PT3H45M" itemprop="prepTime">3 hours 45 min</time>
  </div>

```

For some reason, when I am printing this fields regualry or with panels, the output is fine. but, when I am printing them through a content-pane of views, the output is:

```
<div class="field-content">25 min</div>
</div>
    <span class="views-label views-label-field-preptime">Prep Time: </span>
<div class="field-content">25 min</div>
</div>

```

as you can see, views printing the field with "itemprop="prepTime" and without datetime="PT3H45M".

Why is that happening, and how can I fix it?

Thanks for your help!

---

UPDATE:
After I used @FiNeX tip, and checked the option "Use field template", it helped me solve some issues. Now the prepTime and cookTime fields are using the field template perfectly.

But, the totalTime template, which get the value from a computed field, print the output differently between views, and the regular way.

In the regular way the output is:

```
<div id="md15" class="field-items">
          <div itemprop="totalTime" class="field-item even"></div>
      <time datetime="PT1H35M" itemprop="totalTime">1 hour 35 min</time>
  </div>

```

As you can see, the "datetime=PT1H35M" and the hour ("1 hour 35 min") are printed perfectly.

But, with views, the output is:

```
<div id="md5" class="field-items">
          <div itemprop="totalTime" class="field-item even"></div>
      <time datetime="P" itemprop="totalTime">5700</time>
  </div>

```

As you can see, Views now is using the template, but the output of the template is:

* datetime="P" and not datetime="PT1H35M"
* "5700" and not "1 hour 35 min" (by the way 5700 seconds are equal to 1 hour 35 min)

Why views is changing the output of the template after using it?

Here is the part of the template, that is creating the "Date time" and the time as I want to print it:

```
<?php
function time_to_iso8601_duration($time) {
    $units = array(
        "Y" => 365*24*3600,
        "D" =>     24*3600,
        "H" =>        3600,
        "M" =>          60,
        "S" =>           1,
    );
$str = "P";
$istime = false;

foreach ($units as $unitName => &$unit) {
    $quot  = intval($time / $unit);
    $time -= $quot * $unit;
    $unit  = $quot;
    if ($unit > 0) {
        if (!$istime && in_array($unitName, array("H", "M", "S"))) { // There may be a better way to do this
            $str .= "T";
            $istime = true;
        }
        $str .= strval($unit) . $unitName;
    }
}

return $str;
}
 ?>

<div class="<?php print $classes; ?>"<?php print $attributes; ?>>
  <?php if (!$label_hidden): ?>
    <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>: </div>
  <?php endif; ?>
  <div class="field-items"<?php print $content_attributes; ?>>
    <?php foreach ($items as $delta => $item): ?>
    <?php $time = strtotime(render($item), 0); ?>
      <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>></div>
          <time datetime=<?php print time_to_iso8601_duration($time); ?> itemprop="prepTime"><?php print render($item); ?></time>
    <?php endforeach; ?>
  </div>
</div>

```

# Answer
views renders fields with his own template. I imagine you're using a view which show "fields", right? On each field settings inside the view you can check the following option:

"Use field template"

If you select this option the view will use the field template instead of the view template.
> 1 votes

---
Tags: views, string-overrides
---


# Question
Title: What does rc stand for? when to use alpha, beta and dev instead?
how to name your projects

* project\_name-7.25-1.0-alpha
* project\_name-7.25-1.0-beta1
* project\_name-7.25-1.0-dev2
* project\_name-7.25-1.0-rc3
* project\_name-7.25-1.0-stable4
* project\_name-7.25-1.0-unstable5

following best practices?

# Answer
See Drupal.org for release naming conventions and further explantion.

Summary:

rc = Release Candidate, deemed suitable by the author for production sites.

**rc**: A release candidate should only be created when all the critical bug type issues are reported as fixed in the project's issue queue. This tag should only be used when the developer believes that the project is ready for use on a production site. There is no official best practice for how long a project should be a release candidate before creating an official .0 release, but it is suggested that it should be out for at least a month with status set to "needs review". If something (e.g. a new critical bug is reported) makes it necessary to create a new release during this period, a new release candidate should be created and this should remain for at least a month with status set to "needs review".

It is OK to tag a module "rc" with feature requests issues outstanding. Module authors are not required to fulfill every feature request users of the module post to the issue queue.

Here is a description of the other allowed release tags:

**alpha**: The project is not in a stable state. There are probably numerous unfixed bugs, including security issues. The API may change without notice. The database schema may change without `hook_update_N` being implemented. Usage and API may not be documented. Installing a new alpha release entails uninstalling the project, thereby losing all data. Only for those who want an early preview of the project. Not yet suitable for shared development. Not suitable for production sites. Target audience is developers who want to participate in testing, debugging and development of the project.

**beta**: All critical data loss and security bugs are resolved. If the module offers an API, it should be considered frozen, so that those using the API can start upgrading their projects. If it is an upgrade or update of a project, an upgrade/update path should be offered, and it should be possible for existing users to upgrade/update to the new version without loss of data. All documentation should be up to date. Target audience is developers who want to participate in testing, debugging and development of the project, and developers of other projects that interface the project. Not generally suitable for production sites, but may be used on some production sites if the site administrator knows the project well, and knows to handle any remaining issues.

The strings "dev" and "stable" are not valid as part of a release tag, but *untagged* development releases are assumed to be "dev" and are given descriptions such as "7.x-1.x-dev" by the Drupal.org release packing system to indicate that they are untagged development releases.

All release tags must end with a number. The numbers are just to distinguish releases of the same class. The first is numbered "1" (as in "alpha1"), the next "2", and so on.
> 22 votes

---
Tags: 7
---


title: Clean Url not enabling

text:
# Question
Title: Clean Url not enabling
I have problem in clean url i am trying to enable it but it showing radio buttons deactivated and showing Your system configuration does not currently support this feature.

My web is on shared hosting under the sub directory Like This http://tailoredsuitonline.com.previewdns.com/oceanwis/ The main Web is "Oceanwis"

Your help is really appreciated

# Answer
> 0 votes
1. Check if mod\_rewrite is enabled (if you are using Apache as your web server).
2. Add .htaccess file to the root of Drupal installation. Here is a link to documentation.

---
Tags: uri
---


# Question
Title: How to Delete A Field and Retain Its Value?
I created a new field called `field_code_file` and I transferred all the value from `field_code`. Reference here.

Now if I delete the old field called `field_code`, the value in `field_code_file` is also deleted. So how can I delete `field_code` by retaining the value in `field_code_file`?

BTW, not only the value that is being deleted but also the files. What I'm doing is simply restore the files from the backup. The only problem I have is to retain the value in the table, whatever table it is.

Anyone can help me, please?

# Answer
> 0 votes
I'm not sure this can help you, but one solution that I can suggest is to update your nodes (instead of directly querying the database): transfer one field values to the second one and save it then delete the first one. You can use entity\_metadata\_wrapper or just functions that are provided by node module. You can try something like this... Example:

```
$nodes = node_load_multiple(array(), array('type' => 'MY_CONTENT_TYPE'));
foreach($nodes as $node) {
  $node_wrapper = entity_metadata_wrapper('node', $node);
  $field_code = $node_wrapper->field_code->value();
  $node_wrapper->field_code_file->set($field_code);
  $node_wrapper->save();
}

```

---
Tags: 7
---


# Question
Title: Can't connect to a remote MySQL during installation, drupal uses unix_socket instead of host?
I'm installing a drupal site on a cloud, which has a remote database cloud service.

But I found that drupal seems ignore the `host` I give and use `unix_socket` to connect the remote database.

Here is the **Set up database** screen during installation. I'm sure database name, username and password are correct. I have try ip address and domain name in the `host` field. The `socket` field leaves **empty**.

And I got:

> Failed to connect to your database server. The server reports the following message: SQLSTATE\[HY000\] \[2002\] Invalid argument.

I'm not familiar with PHP and mysql, I don't know a better way to find out what *Invalid argument* is. I So I do some `grep` and add some `print_r()` in `[drupaldir]/includes/database/database.inc`:

```
$driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
print_r($dsn);print_r($username);print_r($password);print_r($driver_options);
// Call PDO::__construct and PDO::setAttribute.
parent::__construct($dsn, $username, $password, $driver_options);

```

This is what I got (add a few line break, and replace the real name and password):

```
mysql:unix_socket=;dbname=demo_db
demo_username
demo_password
Array ( [1000] => 1 [20] => 1 [3] => 2 )

```

Is this mean, Drupal installation ignores the `host` what ever I give and just use `unix_socket` even it's empty?

# Answer
> 1 votes
I think I have located this issue. includes/database/mysql/database.inc, line 32:

```
// The DSN should use either a socket or a host/port.
if (isset($connection_options['unix_socket'])) {// will be TRUE if unix_socket is ''
  $dsn = 'mysql:unix_socket=' . $connection_options['unix_socket'];
}
else {
  // Default to TCP connection on port 3306.
  $dsn = 'mysql:host=' . $connection_options['host'] . ';port=' . (empty($connection_options['port']) ? 3306 : $connection_options['port']);
}

```

`$connection_options['unix_socket']` will be an empty string if we leave it empty on the page. So this test will be `TRUE`. Replace `isset` with `!empty` solve this issue:)

---
Tags: installation, database
---


# Question
Title: Seamless Responsive Photo Grid with Omega
I'm trying to create a responsive full screen gallery based on quite a simple idea, but without success. Idea is to have full screen view of many pictures that are adapting to screen resolution responsively.

The idea you can see here: http://css-tricks.com/seamless-responsive-photo-grid/

I'm working on D7.20, Omega 3.x

And what I want to do is to have content type, let's say, "picture" and create a view, which is displayed in a fluid full screen layout and is shown in such a way like in a given example.

But no success, it looks like it should be simple, but I cannot manage to understand how should I change the CSS to make it work...

It is probably possible to make similar effect using jQuery Masonry module, but I would like to do this with only CSS.

# Answer
> 2 votes
I have a kind of similar issue. I was actually trying to display different packages where the packages div's had variation in heights. I tried to align them using css without any luck.

so I then tried Isotopes and that worked perfectly.

You should also try https://drupal.org/project/isotope it comes with Example Context Reaction for Isotope.

there is also https://drupal.org/project/views\_isotope module

You can also use

https://drupal.org/project/views\_fluidgrid https://drupal.org/project/masonry https://drupal.org/project/masonry\_views

# Answer
> 0 votes
Have you looked at the Picture module? I've used it for responsively scaling individual images. I think it's worth a try in Views.

# Answer
> -1 votes
If you use a view, you can make a template for the view, and for each record of the view, and then use both html and css to style it as you want.

---
Tags: javascript, theming, media
---


# Question
Title: After publish node send email to someone
Let's say i have a custom module in D7 , i want to add a feature to this .

the feature is : when a user publish a node send an email to someone .

```
   function sending_email_node_update($node){
    if (isset($node->original->status) && $node->original->status == 0 && $node->status == 1){
        drupal_mail('sending_email','email_action','soheilsadeghbayan@yahoo.com',language_default());
  }
}

function sending_mail_mail($key, &$message, $params) {
switch ($key){
    case 'sending_email_node_update':
        $message['subject'] = t('this is my action report');
        $message['body'][] = t('this is a reporting from sending email made by soheil') ;

        break;
}
}

```

Could you please help me how to do this ?

# Answer
Why not just use Rules to do this. You'll have to watch a few tutorials to wrap your head around rules, but you won't have to re-invent the wheel or maintain any code.

If you need the custom module solution, check these out.

Check if node is being published: How can I detect when a node is changed from 'Published' to 'Unpublished'?

Then, use drupal\_mail() to send your emails.
> 4 votes

# Answer
Why not using the Message stack? I think Rules is sometime is overrated:

1. To much work to set up the rule.
2. Why to use a large module like rule when you can use your own module and deal with the situation in 20 +- lines of code?
3. How would people become module developer and contribute code back to the community if they need rules to do simple action when a entity is updated?

And this how you can send email to a user when a node is updated in 4 simple steps:

1. Download the module Message and Message Notify and enable them.
2. Create a Message Type with the text your want to put in the mail.
3. Create your own module or just export the Message with Features (this could be your module).
4. Use the next gist in your module: https://gist.github.com/RoySegall/8369317

This is how that gist looks like:

```
/**
* Implements hook_node_update().
*/
function hook_node_load($node) {
  if ($node->original->status == $node->status) {
    return;
  }

  $message = message_create(MESSAGE_NAME, array('uid' => SOME_UID));
  message_notify_send_message($message);
}

```

The Message stack is great. Commerce Kickstart and Drupal Commons are using them, why not you to?
> 1 votes

# Answer
I have a solution for you, use `hook_node_update` something like this in your custom module run when the node be published

```
function MYMODULE_node_update($node){
  if (isset($node->original->status) && $node->original->status == 0 && $node->status == 1){

       put your code here to run after node publish

  }
}

```
> 0 votes

# Answer
while calling drupal\_mail function the second argument is key and you are sending key as **email\_action** and in you hook\_mail you are checking for **sending\_email\_node\_update** instead of **email\_action**.. once you fix this you will be able to catch that mail just before being sent.. do your stuff there and done..

one more thing i would suggest you is check out drupal **RULES** module https://drupal.org/project/rules ... The Rules module allows site administrators to define conditionally executed actions based on occurring events..
> 0 votes

---
Tags: 7, emails
---


# Question
Title: Theme reply comments differently from node comments (Drupal 7)
I am using Drupal 7. I have a question/answer website, I want to theme reply comments differently from node comments. How can I apply a different css theme to differentiate node comments from comment replies? I checked the css class and both node comments and comment replies have the same css class. So how do I add different css class to comment replies and theme them differently?

Clarification: My question is just about theming comment replies differently, like removing borders around them or adding background to all comment replies, while node comments (answers) remain same.

# Answer
> 1 votes
You will have to use the surrounding classes to target the direct comments. Consider a site with the following structure (this is actually based on drupal.org):

```
...
<div class="content">
  <div id="node-01" class="node node-forum clearfix">
    ... Node content ...
  </div>
  <section class="comments comment-wrapper">
    <h2 class="title">Comments</h2>
    <a id="comment-7635897"></a>

    <div class="comment clearfix">
      ... Comment content ...
    </div>

    <div class="indented"><a id="comment-7728095"></a>
      <div class="comment comment-by-node-author clearfix">
        ... Comment reply ...
      </div>
    </div>
  </section>
</div>
...

```

Node comments can be targeted with the CSS selector `.comment-wrapper > .comment`. (only target first level childs).

Replies can be targeted with `.indented .comment` (target all level childs of indented comments).

So have a look at your site's structure and try a similar approach.

---
Tags: 7, theming, comments
---


title: submit function not call

text:
# Question
Title: submit function not call
I create a menu , in call back of menu create add content form , add one submit function to it, but the function not call **NEVER** . where is the problem?

```
 $items['share/%'] = array(
        'page callback' => 'ym_alter_sharing_content',
        //'page arguments' => array(''),
        'access callback' => 'user_is_logged_in',
        'type' => MENU_CALLBACK,
    );

function ym_alter_sharing_content($form,$form_state) {
module_load_include('inc', 'node', 'node.pages');
$nid=arg(1);
$form = node_add('share');
//$form['#submit'][]='ym_alter_sharing_sub';
//array_unshift($form['#submit'], 'ym_alter_sharing_sub');
//array_unshift($form['actions']['submit']['#submit'][], 'ym_alter_sharing_sub');
//$form['actions']['submit']['#submit'][]='ym_alter_sharing_sub';
array_unshift($form['actions']['submit']['#submit'], 'ym_alter_sharing_sub');
//return render($form);
return $form;
}

function ym_alter_sharing_sub($form,$form_state){

 //dsm($form_state['values']);
 var_dump($form_state['values']);
 die("kill for debugging");
}

```

# Answer
> 1 votes
I'd do something like this:

```
$items['share/%'] = array(
  'page callback' => 'ym_alter_sharing_content',
  'page arguments' => array(1),
  'access callback' => 'user_is_logged_in',
  'type' => MENU_CALLBACK,
);

function ym_alter_sharing_content($some_arg = NULL) {
  module_load_include('inc', 'node', 'node.pages');
  $form = node_add('share');
  array_unshift($form['actions']['submit']['#submit'], 'ym_alter_sharing_sub');
  return render($form);
}

function ym_alter_sharing_sub($form, &$form_state){
  //dsm($form_state['values']);
  var_dump($form_state['values']);
  die("kill for debugging");
}

```

**EDIT:** Another suggestion:

```
module_load_include('inc', 'node', 'node.pages');
$node_type = 'YOURNODETYPE';
$form_id = $node_type . '_node_form';

$node = new stdClass();
$node->type = $node_type;
node_object_prepare($node);

$form = drupal_get_form($form_id, $node);
array_unshift($form['actions']['submit']['#submit'], 'ym_alter_sharing_sub');
return render($form);

```

---
Tags: forms
---


title: Taxonomy term custom menus

text:
# Question
Title: Taxonomy term custom menus
I have a site with different sections for separate projects. Some of the sections are just a single page with a project summary, but others are more involved with several pages. All the pages are created via a content type "projects." I have a term reference field in the content type in order to categorize which pages belong to which project.

What I'm trying to do is have a menu automatically generate for all the pages that belong to a specific project. I've found ways to create menus of terms, but I can't find a way to make a menu of nodes using the term.

Any ideas? -JB

# Answer
> 1 votes
you should create a view which display only the nodes related to the current term. You'll have to play a bit with contextual arguments but it works. The simple way is to add a contextual argument to the term field.

# Answer
> 0 votes
i think I have the a similar goal.

For exemple I would have 2 differents **content type** "**Story**" and "**tutorial**" each of them have the **common tag "potatoes"**.

I would like a **menu item** that **link to a view** that will display **all the stories about potatoes** and another to **all the tutorial about potatoes**.

I was thinking of using views for that but there is no "**display format: Menu Item**" so i'm stuck.

help please

---
Tags: taxonomy-terms
---


# Question
Title: How to get fields values in an override file?
I am writing a field override tpl file, in which I want to sum up two INT fields to one INT field. In the file I tried the code:

```
$sum = $field_one + $field_two;

```

The problem is that I get an a notice that Drupal doesn't know what are these variable ($field\_one, $field\_two). I tried using "field\_get\_item", but I didn't succeed. I guess I use it wrong.. Can someone help me get these two fields to my override .tpl file.

How can I get these fields and calculate?

Thanks.

# Answer
> 2 votes
If you look at the comment in the beginning of the template file you're overriding, you should notice that it lists the variables available for any override code.

For instance, in `field.tpl.php` (used as starting point for overrding field templates), you should see the following line inside that comment:

```
* - $element['#object']: The entity to which the field is attached.

```

This gives you the name of the global (`$element['#object']`) to examine to look for the values of the fields.

Now, you need to look "inside" this object to figure out how to access the values of these fields. To do so, the Devel module is what you need, so install and enable this for your (test) site.

Then put the following near the top of your template override file:

```
<?php dpm($element['#object']); ?>

```

When you look at the page again as administrator (clear cache and reload if necessary), there should be a Krumo accordion in the message area that expands this object. Expanding it will tell you how to get to the value of each field present in the entity. For instance, it may tell you that the value of `field_one` is `$element['#object']->field_one['und'][0]['value']`.

Now, you should be able to extract and add the fields, e.g.:

```
<?php
$field_one = $element['#object']->field_one['und'][0]['value'];
$field_two = $element['#object']->field_two['und'][0]['value'];
$sum = $field_one + $field_two;
?>

```

Disable Devel and delete the call to `dpm()` on a production site.

---
Tags: entities, string-overrides
---


title: My uninstall module tab is almost empty

text:
# Question
Title: My uninstall module tab is almost empty
hello to the drupal pro,

I have over **50 disable modules listed** on my module list page but **only one** appear under the **uninstall tab**. (Toolbar module)

I discovered that when i wanted to uninstall a module for the first time

**Any idea** why?

PS: i'm running my drupal site on the localhost using WAMP server

# Answer
> 3 votes
Modules only appear listed on the uninstall tab if they have been enabled and then disabled at some point in the past, AND if they actually installed something in the database that can be uninstalled (i.e. custom tables, variables, etc.) OR they implement hook\_uninstall, even if they don't install anything in the database.

---
Tags: installation
---


title: use features to export products

text:
# Question
Title: use features to export products
i would like to use features module to export products. The commerce\_features module gives a way to do the products types and other things but not product itself. It does not show up under content section or anywhere I can see. How to use features module to export products? How do you export products from one environment into another? Thank You for any help

# Answer
> 1 votes
Features will handle export and import of content types (a.k.a. products types, I think) but not nodes (which is what I think you mean by exporting "products".) I have not used it myself, but I think that the Node export module is designed to do what you want.

---
Tags: commerce
---


# Question
Title: Can I use --remote-host without a site-alias?
I am trying to use Drush to execute some commands as part of my CI/CD workflow. The problem is that due to it's flexibility I want to avoid using site aliases which would basically mean writing temporary files during the build process (I really want to avoid that).

However, I've been trying to use --remote-host, --remote-user and --root in-line (e.g. 'drush --remote-host=example.com --remote-user=exampleuser --root=/var/www/example.com') without success. I did some debugging with XDebug and it seems that even though Drush initially picks up the provided command-line options it later purges them again/overrides them at some point. Is that a Drush Bug or am I doing something wrong / missing something?

Will do some further debugging now but maybe someone knows the answer ;).

# Answer
Drush internally converts site aliases into command line options before doing a remote dispatch, so I would expect that you should be able to make --remote-host work without creating an alias.

Here is something that I tried.

```
$ drush @live sql-conf -v
Calling proc_open(ssh -o PasswordAuthentication=no user@server.org 'drush  --verbose --root=/srv/www/drupal/htdocs --uri=http://site.org  sql-conf 2>&1' 2>&1);

$ drush --remote-host=server.org --remote-user=user --root=/srv/www/drupal/htdocs --uri=http://site.org sql-conf

```

The first version, with an alias, worked, but the second invocation with cli options got confused, and tried to execute the command locally. I got the same result in 6.x and 5.x, so I guess this has been broken for a long time. I created a bug report on GitHub for this:

https://github.com/drush-ops/drush/issues/369

Fortunately, there is one more option. Drush will let you craft an alias on the command line, by combining the different elements of the alias record in a special form, "user@server/path#site". So, I did this:

```
$ drush user@server.org/srv/www/drupal/htdocs#site.org sql-conf -v

```

That worked.
> 4 votes

---
Tags: drush
---


# Question
Title: Recommendations for security testing a Drupal site?
I'm about to relaunch my company's website using Drupal 7. I'm the sole web engineer in our IT department, so I have a lot on my plate as we approach the launch date. As this is my first major Drupal site, I want to be certain that it is as secure as possible. I have completed as many proactive security measures as possible, including following the secure configuration and the best security practices guides on drupal.org, I've subscribed to the security newsgroup, and hardened the LAMP server using industry best practices.

Now that I have completed due diligence with regards to proactive security, I want to run a security audit before we go live to be able to generate a report stating we are "as secure as possible" for management. I usually do all of the testing by hand, page-by-page, using the OWASP Web App testing cheatsheet; however, I'm new to Drupal, this site is hundreds of pages, and I have limited time.

What are your recommendations for security testing a Drupal site of this size? I have access to Rapid7's Nexpose Enterprise, so I will be using that for some automated testing. I do not want to use hosted scanning tools, but will consider security-audited tools that I can install myself to use. Do you have security checklists you go by, similar to OWASP, but specific to Drupal 7? Any other advice for things I might have missed are also appreciated!

# Answer

> 12 votes

---
Tags: 7, security, testing
---


# Question
Title: Text field will not save after moving it from commerce billing profile to account fieldset in checkout
I am having difficulty moving a text field from the commerce billing profile entity to the account fieldset on the checkout page. No matter what I do the text field is not saved after moving it back in the custom validate function. Is there something that I'm missing?

```
/**
 * Implements hook_form_alter() from checkout page.
 */
function example_form_commerce_checkout_form_checkout_alter(&$form, &$form_state, $form_id) {

  // Move phone number field from billing profile to account fieldset
  $form['account']['phone_number'] = $form['customer_profile_billing']['field_customer_phone_number'];
  unset($form['customer_profile_billing']['field_customer_phone_number']);

  // Declare custom validate and submit functions
  $form['buttons']['continue']['#validate'][] = 'example_checkout_form_validate';
  $form['buttons']['continue']['#submit'][] = 'example_checkout_form_submit';
}

/**
 * Custom checkout form validate function
 * @param type $form
 * @param type $form_state
 */
function example_checkout_form_validate($form, &$form_state) {

  // Move field back to billing profile
  $form_state['values']['customer_profile_billing']['field_customer_phone_number'] = $form_state['values']['account']['phone_number'];
  unset($form_state['values']['account']['phone_number']);
}

```

EDIT: I tried moving the text field back to commerce profile in a custom submit handler as shown below, but I still can't get it it work.

```
/**
 * Custom checkout form submit function
 * @param type $form
 * @param type $form_state
 */
function example_checkout_form_submit($form, &$form_state) {

  // Move field back to billing profile
  $form_state['values']['customer_profile_billing']['field_customer_phone_number'] = $form_state['values']['account']['phone_number'];
  unset($form_state['values']['account']['phone_number']);
}

```

I want to move this field, which is for the customer's phone number, on the checkout page for aesthetic purposes. In the current workflow the shipping address is shown first followed by the billing address. Since the phone number field is attached to the billing profile, it looks strange when "My Billing information is the same as my Shipping information." is check as shown below.

This is the last part of the checkout page redesign. I am so close to finishing it. Any help would be much appreciated.

Thanks Paul

EDIT

I was finally able to figure this out with the help of Ryan Szrama and http://www.drupalcommerce.org/questions/3711/saving-customer-profile-field. Thank you guys.

```
function example_checkout_form_submit($form, &$form_state) {
  $order = $form_state['order'];
  $phone = $form_state['values']['account']['phone_number'][LANGUAGE_NONE][0]['value'];
  $po = $form_state['values']['account']['po_number'][LANGUAGE_NONE][0]['value'];

  $order_wrapper = entity_metadata_wrapper('commerce_order', $order);

  // get profile id
  $profile_id = $order_wrapper->commerce_customer_billing->profile_id->value();

  // load customer profile
  $profile = commerce_customer_profile_load($profile_id);
  if ($profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile)) {
    // set the value of the field and save the profile
    $profile_wrapper->field_customer_phone_number->set($phone);
    $profile_wrapper->field_customer_po_number->set($po);
    $profile_wrapper->save();
  }
  unset($form['account']['phone_number']);
  unset($form['account']['po_number']);
}

```

# Answer
> 1 votes
Unfortunately, you can't move this and have it continue working as normal. Entity form submission depends on a specific "tree" hierarchy in the submitted field values, and moving it like this disrupts that. Thus when the customer profile information is saving, your custom textfield is just invisible.

If you really need to move this, then you should add a custom submit handler that populates the customer profile as before.

---
Tags: 7, commerce, forms
---


# Question
Title: commerce_order_status_update() doesn't update the order status
After the order is paid in full (or not checkout is complete if there is no payment required and I ever get that working) I need to do a bunch of processing to set up the product the user has just bought. Only once that is done can I say the order is complete and I thought this would do it

```
commerce_order_status_update($order, 'completed');

```

But it doesn't change the order status. They are always left as Pending.

How do I programmatically change an order status from pending to completed?

# Answer
It sounds to me like you're updating the order to completed before the checkout completion rule fires that updates the order to pending. You can confirm this by looking in your revision log for the order in question.

If I were you, I'd just add a condition to that default checkout completion rule to not update the order status if it is already completed.
> 3 votes

---
Tags: 7, commerce
---


# Question
Title: Get a views result using PHP code, and iterate the proper way
I have a view called all\_projects\_list. This view fetches Fields (not nodes), and i'd like to get it by code, and iterate on it. I managed to do this by using:

```
$view = views_get_view_result('all_projects_list', 'default');
foreach($view as $project){
    print_r($project->_field_data['nid']['entity']->field_project_code['und'][0]['value']);
}

```

Which as you can see is very, very dirty. Is there a Drupal way of doing this ? Thanks in advance.

# Answer
It's not very different from what you do, but here's example code from a project of mine, showing how I usually do it

```
$view = views_get_view('a_view');
$view->preview('panel_pane_1', array($node->nid));
foreach ($view->result as $tid) {
  print $tid->taxonomy_term_data_taxonomy_term_hierarchy_tid;
}

```

Based on the function documentation

> To be called externally, probably by an AJAX handler of some flavor. Can also be called when views are embedded, as this guarantees normalized output.

I've always assumed that preview() is the proper way to do it, and it has served me well on a number of occasions.
> 6 votes

# Answer
you can do this

```
$view = views_get_view($view_name);
$view->set_display($display_id);
$view->pre_execute();
$view->execute();
$total = $view->total_rows;

```

to get the total number. If you want to iterate, maybe

```
$result = views_get_view_result($view_name, $display_id);
foreach($result as result) {
  // do something.
}

```

Note: this depends on use pager to display all results, otherwise you will get only limited results.
> 4 votes

---
Tags: views
---


title: Module Page Keeps Redirecting

text:
# Question
Title: Module Page Keeps Redirecting
I inherited someone else's project.

I see he created a module called `bcompanies.module`. In that module file I see this:

```
function bcompanies_menu() {
    $items['company'] = array(
        'title'     => 'Company',
        'page arguments'    => array(1),
        'page callback' => 'company_page',
        'access callback'   => TRUE,
        'type'          => MENU_CALLBACK
    );
    $items['company_page2'] = array(
        'title'     => 'Company',
        'page arguments'    => array(1),
        'page callback' => 'company_page',
        'access callback'   => TRUE,
        'type'          => MENU_CALLBACK
    );

}

function company_page()
{
      return 'hello world';
}

```

When I go to the url `http://site.com/company`, I see the text "hello world". When I go to the url `http://site.com/company_page2`, I am redirected to `http://site.com/welcome` . Does anyone know why the second url keeps redirecting me while the first does not, even though they seems exactly the same in terms of set up?

I did a test and wrote a die() statement in company\_page(), that forced it to not redirect. But that's not that great, because it prevents subsequent drupal hooks from firing.

**Additional Notes**

I noticed that if I login as an admin user, then there is NO REDIRECT when i go to `http://site.com/company_page2` \- I see hello world wrapped nicely by the header html template and the footer html template. The redirect only happens when i login as a regular user going to that page.

So is this a permission/role issue? But I never set the permission or role or anything...

# Answer
There can not be a permission issue in your code (because you code is very simple:) ). Just try to change your code as documentation says:

```
function bcompanies_menu() {
    $items = array();

    $items['company'] = array(
        'title'     => 'Company',
        'page arguments'    => array(), // I removed arguments because of callback function doesn't require in your case;
        'page callback' => 'company_page',
        'access callback'   => 'user_access', // I changed your access callback, it's a bad practice to set just TRUE as an access callback
        'access arguments' => array('access content'),
        'type'          => MENU_CALLBACK
    );
    $items['company_page2'] = array(
        'title'     => 'Company',
        'page arguments'    => array(),
        'page callback' => 'company_page',
        'access callback'   => 'user_access',
        'access arguments' => array('access content'),
        'type'          => MENU_CALLBACK
    );

    return $items; // I added this line, because I don't know you 're returning a value in your module or not..

}

function company_page()
{
      return 'hello world';
}

```
> 0 votes

---
Tags: 7
---


title: Image style is not rendering

text:
# Question
Title: Image style is not rendering
My field\_image is not rendering on user-profile.tpl. I have the following code (two different ways to render for testing):

```
    $image = field_get_items('user', $user, 'field_image');
    $output = field_view_value('user', $user, 'field_image', $image[0], array(
      'type' => 'image',
      'settings' => array(
        'image_style' => 'header_image_160x160',
      ),
    ));
    print render($output);

```

This produces the following in html:

```
<img src="https://coinme.io/sites/default/files/styles/header_image_160x160/public?itok=f31sbmSd" width="160" height="160" alt="">

```

I get the dead image logo. It is missing the final part of the file structure. And this is how I normally render:

```
$to_render = field_view_field('user', $user, 'field_image', array('settings' => array('image_style' => 'header_image_160x160'))); print render($to_render);

```

This is showing the default image, even though the image does exist:

https://coinme.io/sites/default/files/styles/header\_image\_160x160/public/images/profile/profile-large.png?itok=rb-2qFOw

I have the same field in a content type which is rendering correctly (only difference being the $user user -\> $node node.

```
<?php $to_render = field_view_field('node', $node, 'field_image', array('settings' => array('image_style' => 'header_image_160x160'))); print render($to_render);?>

```

So it appears that when using user-profile specifically is the issue. I have also tried adding a new field type and same effect. Any suggestions?

Thanks, Paul.

# Answer
> 0 votes
The answer was simple: `$user` is the logged-in user; since the logged-in user didn't have a profile image, I got the default image.

Elsewhere on the page, I wasn't using `$user`, but all the variables whose ID started with `$field_`, so it looked like I was using the right variable. This fixed it.

```
$account = $elements['#account'];

```

Then, I updated `$user` to `$account`.

```
$to_render = field_view_field('user', $account, 'field_image', array('settings' => array('image_style' => 'header_image_160x160'))); print render($to_render);

```

---
Tags: 7, media
---


title: Separate users content by year chosen

text:
# Question
Title: Separate users content by year chosen
Website has several types of users and all can post images, videos, events etc.

One user type is hard to solve for me.

This user type is summer school that is happening every year and last for few weeks.

This user as all other can post images, videos, events etc. but i would like to separate all of these by the year. So summer school happened in 2009, 2010, 2011 etc.

For other user types i have menu in sidebar: Bio Photos Videos Etc.

For summer school i have the same menu but somehow i would like to have a year above the menu with drop down if possible ? When year is picked website should remember it so the menu gives content based on year picked.

Also when user (summer school) creates content it should be able to pick which year it happened. I can use date field here i guess, but the bio should remain the same for any year chosen.

Hope i was clear enough.

# Answer
A "user type" is a role, right?

You can create a Year field as either a Date, Taxonomy, or plain Text field. Then you can attach it to each of the content types that these users are allowed to post.

I have not used it myself, but I think that the Field permissions module will let you restrict this field to just the desired role. If that does not work, you could do a little theme work to add the user's role(s) as CSS classes on the `<body>` tag, then hide the Year widget with CSS.
> 0 votes

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


# Question
Title: How to add static content before the feed on the front page?
I want my front page to contain some static content (a short description of our association), and after that the normal feed of articles fed by "promote to front page". How can this be achieved?

I know how to add content to the front page feed and I know how to change the front page to another page, but I couldn't figure out how to get both static content and the front page feed. (It seems such obvious and often-wanted functionality for a front page...)

# Answer
@Serpiente's answer gives several valid options, but I prefer yet another. The Views module comes with a view that emulates the default home page. Enable this view, set it as your home page, and add your static text as a Header section.

One advantage to this method is that it gives you more control over the items in the front-page feed. Some day, you may decide that static text in the header is not quite flexible enough, and then you can change your Header to show another view.

If you are not already using Views, this is a good way to start. In D8, Views will be in core, and the front page (as well as most or all of the admin pages) will be implemented as views.
> 1 votes

# Answer
there are multiple ways to do this:

# 1. Use the default block system

Create a new block `admin/structure/block/add` and insert your headline (or none) and the body text. Under `Visibility settings` select `Only the listed pages` and insert `<front>`. Select under region the region where the block shall be shown, or do this at `admin/structure/block` after saving the block.

# 2. Use panels \+ page manager (ctools)

Create a new panel page and make this page your frontpage, put the feed you want to be displayed inside of the main area, add a custom content pane before that feed/ view.

# 3. page.tpl.php

inside of your templates page.tpl.php you can add a codeblock for your custom content, drupal\_is\_front\_page will help your here:

```
<?php
if (drupal_is_front_page()) {
  //your custom code
}
?>

```

reference for bartik: page.tpl.php with bartik you could use the `$is_front` variable as well for detection.
> 1 votes

---
Tags: theming
---


# Question
Title: list of parent nodes with a list of child referring nodes
I would like to make a list of all parent nodes and under each parent display a list of child nodes that are referencing parent node. Something like drupal.org modules page, except in my case this is not with taxonomy. Using drupal 6 views 2

```
example

parent1
-child1
-child2
-child3
more parent1

parent2
-child1a
-child2a
-child3a
more parent2

```

I am not able to display it using one view. Can anybody help me with some ideas? Thank you

# Answer
probably you're using Node reference, right? If this is your case the solution is quite simple.

1) Create a view with a contextual argument for displaying all the children of a specified parent.

2) Use Display Suite module to attach this view on a custom display mode of parent nodes. With display suite you can pass the current nid to the view argument. You can also use Views Attach module ( https://drupal.org/project/views\_attach )

3) create a view with the list of every parent and set to show the customized display created before.

I hope this will help you.
> 1 votes

---
Tags: 6, views
---


title: Listing Polls and choices on same page

text:
# Question
Title: Listing Polls and choices on same page
I have couple of polls, I want all of them on one page. Like this:

Any clue?

# Answer
You can use Views to do this . create a view of poll and show display as content (full content) not field and you're done
> 1 votes

---
Tags: views, polls
---


title: hook_url_outbound_alter() not working

text:
# Question
Title: hook_url_outbound_alter() not working
I'm trying to rewrite the URL of a node. I have the following test code:

```
function mymodule_url_outbound_alter(&$path, &$options, $original_path) {

    if ($path == 'testpage') {
        $path = 'test-alias';
        $options['alias'] = $path;
    }
}

```

Which doesn't seem to do anything when I visit /testpage or /test-alias. It's definitely executing the code inside the if statement. Am I doing something wrong here?

I have previously implemented hook\_url\_inbound\_alter(), which works perfectly and doesn't do anything on this particular page. I also use the Path module.

# Answer
If you want to create an alias using `hook_url_outbound_alter()`, you need to implement also `hook_url_inbound_alter()`, since the former is for links output from Drupal, and the latter is for links received from Drupal. The former changes the path with its alias, while the latter changes the alias with the equivalent path.

Keep in mind that:

* If you are not doing conditional replacements, then it is probably less performance-heavy to use the normal Drupal path aliases
* Between the arguments taken from `hook_url_outbound_alter()`, `$path` is the path as already changed by the previously executed module, while `$original_path` is the path before being changed from any module

Also, `$options['alias']` is really a boolean, not a string, which tells `url()` whenever the path being passed to the function is already a path alias. In the case it is, `drupal_get_path_alias()` will not be called.
> 5 votes

---
Tags: hooks
---


# Question
Title: Which entity table should be used for data common to all revisions?
Translatable and revisionable entity has ho have four tables in Drupal 8: entity, entity\_revision, entity\_field\_data and entity\_field\_revision.

Let's say I have a "product" entity and the product has a manufacturer. The manufacturer will be the same all the time, no matter which revision is active. Another example would be a "car" entity. The car will always have a certain ammount of wheels(4).

Where(in which table) should I put this "global" fields?

# Answer
> 2 votes
An entity can have up to 4 tables, it doesn't have to. So if you don't need revisions or translations, you can simply not define them. There are 4 test entities in the entity\_test.module that test every possible combination, only base table, base + revision, base + data/translation and all of them. So that should work fine.

other than that, it's fairly straight forward. The base table contains information that's the same for all revisions and all translations. \_revision contains information that is for a specific revision but all translations. field\_data and field\_revision contain both the per-revision-per-translation, field\_data being the data of the default revision, field\_revision the same information for all revisions.

---
Tags: entities, 8
---


# Question
Title: Why are values in Entites obtained directly and sometimes by using getters?
For example

* `Drupal\Core\Entity\Entity::id() returns $this->id(or NULL)`
* `Drupal\Core\Entity\ContentEntityBase::id() returns $this->id->value`
* `Drupal\Core\Entity\ContentEntityBase::uuid() returns $this->get('uuid')->value`
* `Drupal\node\Entity\Node::id() returns $this->get('nid')->value`

Also in some methods there are `setValue()` and `getValue()` utilised but sometimes there are just `$this->field->value`.

So what is the reason for this inconsistent behavior? From my understanding all the "fields" are TypedData fields hence the `setValue()` and `getValue()` methods should be used instead of directly access `$this->field->value`. Besides it's strange because $value is private.

# Answer
> 18 votes
Ok, trying to answer this. This could get a bit long :)

First, to have that out of the way, Drupal\Core\Entity\Entity::id() is not TypedData relevant, only content entities (subclasses for ContentEntityBase) are typed data at the moment. So that implementation is for example used for config entities.

Now about the different methods that you mentioned.

* `getValue()` is part of TypedDataInterface and it's not strictly defined what it returns, but it can be understood as the raw value of that typed data object. For anything that is not a so called primitive value (like a string or integer), `getValue()` returns an array. So if you call `getValue()` on the first field item of the node body (`$node->body[0]`), it will return `array('value' => ..., 'format' => 'text_plain')`. If you call it on the field item list, you get `array(0 => array('value' => ..., 'format' => 'text_plain'))`. So for all complex data (another typed data term, it defines an objects that consists of sub-properties, like an entity or field item), think of `getValue()` as `toArray()`.
* Content entities no longer have public class properties. `$entity->id->value` goes through `$entity->__get('id')->value`, which is almost identical to `$entity->get('id')->value`, with the following differences:

+ get() currently only supports defined fields. _*get()/*\_set() allow to set anything on an entity, mostly due to BC reasons, because a lot of code still sets tons of random stuff on $node. So `print $node->bla` works, `$node->get('bla')` will throw an InvalidArgumentException('Field bla is unknown.'). This could be changed if we want to.
    + Before PHP 5.4, `$node->get('body')[1]` is not supported (while $node-\>body works fine), so you have to use the rather weird `$node->get('body')->offsetGet(1)` (this is ArrayAccess, #2110467: Add first(), get($index) and possibly other methods to ListInterface will hopefully soon change that to a `$node->get('body')->get(1)`). Now that D8 will require 5.4, this isn't much of an argument anymore and the referenced issue makes it easier too.
    + get() is faster than \__get(). On the large scale, there's not a big difference I think (other things are worse), but relatively speaking are magic method calls considerably slower than non-magic ones.
* The -\>value part involves more magic methods. To explain that, I first have to mention that all entity fields (including base fields like the ID) now have a fixed structure enforced: Entity : Field item list : Field item : Field properties (like value, format, target\_id). If you write `$entity->id->value` then `ContentEntityBase::__get()` gives you the field item list for the id field. Then you call $field\_item\_list-\>value, which points to `FieldItemList::__get()` which assumes that you want to access the first field item, so it passes the call through to `FieldItemBase::__get()`, which then returns the value. I suggest that's enough detail for that question, if you want to know more about FieldItemBase, I'm happy to answer that in a separate question.
* Now, `$entity->id->getValue()` and `$entity->id->value` are often mixed up, but they are not actually related in any way, it's just an unfortunate naming conflict. value happens to be the pseudo-standard main field property name, especially for those that only have a single value. Reference fields use target\_id, and if you want to name the property of your own field type `banana` , then all you have to do is set it up accordingly in your `FieldTypeItem::getPropertyDefinitions()` implementation and it will be `$entity->your_field->banana`.
* There are (at least) two remaining issues that will affect these API's. That is #2002134: Move TypedData metadata introspection from data objects to definition objects and #2002138: Use adapters for supporting typed data. The main goal of those combined is that entities and field items are no longer typed data objects themself but can be used as typed data through adapter classes. That in turn means that those classes do not have to respect (and poorly implement in case of entities) the `TypedDataInterface/ComplexDataInterface` interfaces but can define method names that make more sense in their context. For example, we can hopefully rename `getValue()` to `toArray()` or something else that has no naming conflict with `value`, we can rename $entity-\>getPropertyDefinitions() to $entity-\>getFieldDefinitions() and so on.

So, to come back to what your actual (I think) question is, $entity-\>id-\>value and $entity-\>get('id)-\>value are almost identical, both are currently supported, but I usually prefer and recommend get(). \__get() *could* still change (although I consider it unlikely, as nobody is pushing there), so if you use get(), you're on the safe side I think.

---
Tags: entities, 8
---


# Question
Title: Page where I can see my user's managed files
Is there a page in Drupal that lists all of the files in file\_managed that the logged in user owns?

# Answer
> 0 votes
I do not think there is a pre-made page for this, but you can make one using Views. Create a new view of type Files. Under the Advanced section, add a Relationship for the user who uploaded the file. Then add a filter "User: current" using this relationship.

---
Tags: 7, files
---


title: How to work with TypedData?

text:
# Question
Title: How to work with TypedData?
So I was wondering how to utilize this new addition to Drupal. For example, should I use TypedData to set default value, description or required attributes in (entity)forms?

What is the usage of computed(), setReadOnly(), setTranslatable(), is/setQueryable(),.. ?

# Answer
Yes, this is a very broad question, so I can only offer a broad answer.

Typed Data is only really interesting for you if you are a module like Rules, a context/token system or something like that, that wants to work with any possible data structure on any level, with generic code. Like displaying that famous rules data selector based on getting an arbitrary object (or actually a definition object *about* that object that you will get at runtime) and all you know about it is that it is typed data.

For most other cases, like when you know that you are working with an entity, or a specific field, you want to work with more context-specific API's, if available.

You specifically mention entity forms, note that work there is still going on, but the idea is that editing fields should work the same for base fields as it does already with configurable fields, with widgets, whose configuration you will set in your baseFieldDefinitions() method. Support for that very recently landed, see the node title definition in Node::baseFieldDefinitions(). There is no change notice yet but the relevant issue is #2144919 Allow widgets and formatters for base fields to be configured in Field UI.
> 2 votes

---
Tags: entities, 8
---


# Question
Title: How to hide Article Fields which are displaying on the front end
Please help me, i just started learning drupal and implementing it.

I have a problem in hiding fields which are displaying in article pages.

Please check this page . "Body" field is displaying in all Articles. Please help me.

Please find the attached screen shot for reference.

>

# Answer
Guessing there is no views implemented.

Go to manage display settings of article content type \[ `admin/structure/types/manage/article/display` \]. In Label column select 'hidden' for body row.

You are done.
> 4 votes

---
Tags: entities
---


# Question
Title: How to use Twitter Bootstrap with panels?
I am using D7 to built a new site. I am using Twitter Boostrap to create responsive themeing in my site. But most of my design has to be built with panels, the panels does not work responsive with the twitter bootstrap. I found that adaptive theme can be used with panels to make it responsive, But my requirement is to use twitter bootstrap for responsive themeing.

Is there an chance by which I can make the panels responsive with the twitter bootstrap?

Thanks.

# Answer
> 4 votes
Use Panels Bootstrap Layouts module.

# Answer
> 2 votes
If you already are using twitter bootstrap only need create you own layout plugins with bootstrap's fluid layout scaffold.

Check my example module. its functional and has two ports made at this moment but the intention its make a full port of Panels layout plugins.

# Answer
> 1 votes
If you are using panels and specifically panopoly i would check out Kalatheme

---
Tags: 7, panels, theming
---


title: pass argument from url to view

text:
# Question
Title: pass argument from url to view
I have a view with 5 results limit and a more link to show all nodes. The more link goes to xxx/yyy/123. Number 123 is the nid of node, that listed nodes are referencing to.
On a current page, lets say- xxx/yyy/123 I would like to use another view that can print the name of node with 123 nid.
I tried to set a view using default argument - node id from url and use a field with title but it seems that the number from such url it is not picked up as an argument. Can anybody give some advice? Thank you

# Answer
Views generally gets node id from url when url format seems to be `node/nid`

For your case, select '`Raw value from URL`' in `Provide default value` section and select path component as 3 as nid lies in 3rd url arg. Your views should be getting the desired nid now.

Hope this helps you. :)
> 0 votes

---
Tags: 6, views
---


# Question
Title: Force users to add Organic Groups content only to their group(s)
When a group member try to add group content, how come this user can still choose to witch group this content belongs to?? I was expecting that group members adding content could only add content for their specific group, not for all groups... In the event a member is part of several groups then there should be a way to detect from witch group the edit content as been trigger and then only modify the content for that specific group ..

Anyone have such experience to share ?

Thanks,

# Answer
> 1 votes
At admin/og/og (D6) you can uncheck the setting "Audience checkboxes". From the description "Show each group that the user is a member of as a checkbox in the "Audience" section. This enables the member to place her post into multiple groups. If unchecked, simplify the user interface by omitting the checkboxes and assuming user wants to post into the current group. This simplification only applies to new nodes, and not to edits of existing nodes. Group administrators always see checkboxes."

# Answer
> 0 votes
Here's how to force the target audience on a create/edit form:

1. Make sure that you've added the Groups Audience field to your bundle (e.g. content type) through the Organic Groups configuration (Adminstration -\> Configuration -\> Organic Groups -\> OG Field Settings).
2. In the Administration section, surf to your bundle's (e.g. content type's) "Manage fields" tab.
3. Edit the "Groups audience" field.
4. Check "Required field".
5. If you only want the entity instance (e.g. node) to be placed in N group(s), select N as the "Number of values" field. By default, it's set to "Unlimited" which you may not want.

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


# Question
Title: HybridAuth has stopped working with FaceBook
Before the weekend, I successfully set up the HybridAuth module. Upon returning to this project this week (July 1), Facebook logins no longer seem to respond.

Watchdog logs contained numerous of the following lines

```
Exception: Authentication failed! Facebook returned an invalid user id. in Hybrid_Auth::initialize() (line 147 of xxxxxxxx/public_html/sites/all/libraries/hybridauth/hybridauth/Hybrid/Auth.php).

```

Now I have checked the FB AppID and AppSecret. They are correct.

Permission is set as follows....

Sand box is off

I'm using the latest library from HybridAuth. I've clone it using git

# Answer
> 1 votes
Please check the issue already submitted in drupal.org https://drupal.org/node/1860618 . Especially check this comment. You have to use latest 7.x-2.x-dev release.

---
Tags: social-network, users
---


# Question
Title: Diferences between: migrate_d2d and migrate
I need to migrate a d7 site to a d7 distribution. This is to migrate from d7 to d7.

I found this modules which I undertand will help me with this task.I've read the documentation but I don't fully understand the diferences between them.

Which one is the right module for my situation?

# Answer
> 0 votes
From Drupal-toDrupal data migration (migrate\_d2d) module page:

> migrate\_d2d provides a framework based on the Migrate API

So the diference is - migrate is an API module for migrations, and migrate\_d2d uses it to perform task like yours. Either way you will use migrate, only difference is - do you feel you need to write what authors of migrate\_d2d already wrote? Or maybe you want to use or modify their work to save some time?

---
Tags: migrations
---


# Question
Title: How to display drupal 7 Ubercart product attribute options in views filter?
I want to display drupal 7 Ubercart product attributes(for eg: size - Medium, Small, Large) as views filter in the products listing page. I have searched on google but did not find any solution for that.

# Answer
> 0 votes
Add "add to cart form" field in view. we can see all attributes in view which are added for this product

---
Tags: views, ubercart
---


# Question
Title: How to manage the display of a multiple value field in a individualy way?
I have a content type with a field called "anotations" which is set to have 2 values.

Im using display suite,then in `admin/structure/types/manage/mycontenttype/display` I'd like to show the 1st value of the "anotation" field in the "header" region and the 2nd value of the "anotation" field in the footer.

Is there any way to do this?

Just in case someone wonders why do I need to do this: I'm just trying to avoid to create new fields as much as I can, since I noticed that having too much fields affect the general performance of the site.

# Answer
> 0 votes
I got this creating Dynamics Fields with the Display Suite module. Here is a quote about it (from the module's project page):

> ... allows you to take full control over how your content is displayed using a drag and drop interface. Arrange your nodes, views, comments, user data etc. the way you want without having to work your way through dozens of template files. A predefined list of layouts (D7 only) is available for even more drag and drop fun!
>
> By defining custom view modes (build modes in D6), you can define how one piece of content should be displayed in different places such as teaser lists, search results, the full node, views etc.

---
Tags: entities, display-suite
---