title: Display suite PHP field using tokens

text:
# Question
Title: Display suite PHP field using tokens
I'm trying to use a Display Suite field to wrap an image in a div.

What I also want to do is to htmlspecialchars on the token \[node:field\_mainimage\].

It doesn't want to work for me. Is there any other way I can accomplish this?

# Answer
Where are those images placed ?

If this is in content type, you can style the content type content by using custom tpl.php files and wrap your images in div there. (in sites/all/thems/yourtheme , that is.)

Also, you can create template files even for fields.

That gives you enormous power of controlling output :) .

It is bit "dirty", but you can also wrap images in div using jQuery. But first method is cleaner.
> 1 votes

# Answer
If you just want wrap image field formatter (html output of field) in another div (or other html containers) I recommend to use Field Group module.

It allows you in formatters configuration (admin/structure/types/manage/\*/display) to group any fields and configure to wrap them by basic HTML wrappers, tabs, multistep form etc.
> 0 votes

---
Tags: display-suite
---


title: Grouping field in tabs

text:
# Question
Title: Grouping field in tabs
When I select unformatted settings and can Grouping field, it is working fine. Now I am using Bootstrap tabs, but it is not working.

How we can do this?

# Answer
> 0 votes
For using Bootstrap tabs with views you need to use the Views Bootstrap module: Views Boostrap module enables you to create components following the theme structure of the Bootstrap framework all within the configuration settings of the powerful Views module.

Views Bootstrap module supports following:

* List item
* Grid
* Tables
* Thumbnail
* Media object
* Accordion
* Carousel
* Tabs
* **List group**

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


title: block view is not displaying

text:
# Question
Title: block view is not displaying
This problem starts with the subtheme. I am using drupal 7 with a subtheme based on omega 3.1.

For some reason node title and admin tabs are displaying only on the home page and two basic pages, while they do not appear on the rest of the website(articles, basic pages, custom type content).

I tried goggling and trying out different solutions but none of them were successful.

So I thought I could create a view block that would display only a node title. in the view I used contextual filters 'content: Nid', display 1 item, fields 'content: title'. By default auto preview does not display anything, when you insert a node number or a page name it displays it's title which means that the view works fine(as example when I enter '1' it displays 'About me' title).

After that I insert the block on a page by going blocks \> configure for the block view \> selecting the region in the sub theme I am using and in Show block on specific pages selecting 'Only the listed pages' and typing '1' as an example.

When I click save block and going to about me page I still do not see the title then check by inspect the page there is no html for the block view found.

To check weather the problem is not in the omega, I switch to bartik and select to display the block for bartik theme too, but still cannot see it on the page. The answer is probably something really simple.

# Answer
Sounds to me like you have the 'Only listed pages' setting wrong. I tend to use pathauto, so always have nice 'friendly' URL's, but I suspect you want "node/1" rather than simply "1" in the "only listed pages" field of the block config.

WRT your initial issue - are you using Delta? Regions may not be enabled for all delta's of the subtheme which could cause the initial problem.
> 0 votes

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


# Question
Title: How to add slider to show multiple view's product in a slider in commerce site of drupal 7?
I am working on Commerce Kickstart. In my homepage there are 3 views & each view contain 3 product. Each view's products are shown in a column like below image :

I want to add slider to show all products by clicking "\< \>" arrow. How can I implement. Please Help. Thanks

# Answer
> 1 votes
you can achieve your requirement using views\_slideshow module.

Views Slideshow can be used to create a slideshow of any content (not just images) that can appear in a View.

```
News item slideshow (such as the title, image etc).

The Last X number of X submitted (images, videos, blog entries, forum posts, comments, testimonials, etc.).

Rotate any image, based on any filters you can apply in views.

Hottest new products for any ecommerce drupal site.

Rotate contact links, share links, etc.

```

Implementation :

Steps:

Enable view slideshow module.

Create a view using existing content type(ex-product).

View format: Slideshow

Add item for slideshow (such as the title, image etc).

**For getting Next & Previous link**

Goto view slider settings

Enable the controls as text.

It displays 'next','pause' and 'previous' link

Later you change the css as per requirements.

# Answer
> 1 votes
if you wants multiple product in slider with next previous arrows then go for `jcarousel` module

Features

```
Built-in Views support.
AJAX-loading of additional items as needed.
Carousel pager/navigation to jump between multiple pages.
Circular wrapping of items.
API for direct usage of jCarousel without Views.

```

---
Tags: views, commerce, javascript
---


title: Open Menu links in new browser window

text:
# Question
Title: Open Menu links in new browser window
I have created various menus, via the menu structure-\>menu page in Drupal for various pages in my site. I want to have some, if not all, of these menu links to open in a new page. You can not add `target="_blank"` to the path in the menu screen and I don't want to add a new module right now.

**I am trying this:**

```
Drupal.behaviors.externalMenu = function (context) {
  if (jQuery().attr) {
$(document).ready(function(){
  $('.page-node-166 a', context).attr('target', '_blank');
});
}}

```

My Steps: created a new js file, added the above code, went into my themes .info file, referenced this js file in the scripts section, refreshed, a few times, nothing works. Links still open in current window.

What should be happening in this code snippet is, find this class\[page-node-166\], which is the page, then for any link on that page, open it in new window. My first time attempting this so I don't know if I am missing a step.

How can I have menu links open in new window in drupal 7?

=====================

Update:

# Answer
You don't really need a drupal behavior to do this. Instead just simple do this:

```
;(function($){
  $(document).ready(function(){
    $('.page-node-166 a').attr('target', '_blank');
  });
})(jQuery);

```

or

```
jQuery(document).ready(function(){
  jQuery('.page-node-166 a').attr('target', '_blank');
});

```

By default drupal uses jQuery.noConflict() so that it does not interfere with the $ that may be used from other libraries.
> 0 votes

---
Tags: javascript
---


# Question
Title: How do I make an external URL open on a new tab?
When I try putting a link like `<a href="http://www.example.com/" target="_blank">` on the link path, I get the following error message:

> The path '//www.example.com/" target="\_blank"\>' is either invalid or you do not have access to it.

Is there a way to have the external URL opened in a new tab?

# Answer
If you can target your menu tag with jquery using its ID you can put something like this in an JS file that you'll add in your theme via your\_theme.info

```
Drupal.behaviors.externalMenu = function(context, settings) {
    $('#menu_id').attr('target', '_blank');
};

```

Or you can use the Menu attributes module.
> 12 votes

# Answer
Not per menu item. However, the External links project allows to open all external links in a new window and indicates them as such with an icon.
> 3 votes

# Answer
The problem is that you are entering `<a href="http://www.example.com/" target="_blank">`, when Drupal is expecting only the link (`http://www.example.com`, in your case).

If you would enter `http://www.example.com`, Drupal would notice it's an external link, and it will allow you to use it.
I tried adding a link to drupal.org, and as you can see, Drupal accepted it (it's the link shown as "Drupal").

For how to open the link in a new browser tab, the other answers already explain how to do that.
> 1 votes

# Answer
There's a project called "Menu Target" that allows you to do just that. Maybe that helps those who only need individual menu links to open in a new browser.
> 0 votes

# Answer
If you need to make all external links open in a new window you can rewrite theme\_links in your current theme, if not use menu\_attributes module as given above.

```
function yourtheme_name_link($variables) {
  // Add target blank to all external links.
  if (url_is_external($variables['path'])) {
    $variables['options']['attributes']['target'] = '_blank';
  }
  return '<a href="' . check_plain(url($variables['path'], $variables['options'])) . '"' . drupal_attributes($variables['options']['attributes']) . '>' . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '</a>';
}

```
> 0 votes

# Answer
I just got this answer from the board which was a big help, this may work for you as well:

```
(function($){
  $(document).ready(function(){
    $('.page-node-166 a').attr('target', '_blank');
  });
})(jQuery);

```

in my case, i referenced the page class, then the 'a' and that made the links on that page open in new window. I am going to do a bit more selector chaining to I can better pinpoint the specific menu in the sidebar.
> 0 votes

---
Tags: 7
---


# Question
Title: How to add conditional javascript to theme?
I'd like to use Selectivizr script to emulate CSS3 selectors in IE6-8.

But I'm having a hard time adding it to my theme. So far tried:

1) Forcing this into html.tpl.php head section:

```
<!--[if lt IE 9]>
<script src="<?php print base_path() . path_to_theme(); ?>/js/selectivizr.js"></script>
<![endif]-->

```

But base\_path() doesn't seem to return anything in D7 (at least in html.tpl.php - maybe in page.tpl.php...). And I know this isn't the *Drupal way* to do it anyway.

2) Adding to my theme's .info file:

```
scripts[] = selectivizr.js

```

But then it's unconditional, of course :(

3) Using drupal\_add\_js() in my template.php.

But again, I'm not sure that it can be set conditionally there?

# Answer
I think your 1) is the best option.

You don't need to call any function, you have already those values:

```
<script type="text/javascript" src="<?php print $base_path . $directory; ?>/js/selectivizr.js"></script>

```

FYI, `<?php dsm($variables) ?>` in any template file to see what variables are available. (with devel module installed)

There is a module Conditional Stylesheets that has a elegant solution for adding IE conditions in the .info file, but still only for CSS. (see feature request for JS)
> 3 votes

# Answer
This is how I've added html5shiv in my template.php file:

```
$html5shiv = array(
  '#tag' => 'script',
  '#attributes' => array( // Set up an array of attributes inside the tag
    'src' => drupal_get_path('theme', 'mythemename') . '/js/lib/html5shiv.js',
  ),
  '#prefix' => '<!--[if lte IE 8]>',
  '#suffix' => '</script><![endif]-->',
);
drupal_add_html_head($html5shiv, 'html5shiv');

```
> 16 votes

# Answer
I thought this was baked in but was wrong.

It looks like the mothership theme uses this librabry.

IT does things a little differently from you but essentially does your option 1

```
  $vars['selectivizr'] = '<!--[if (gte IE 6)&(lte IE 8)]>';
  $vars['selectivizr'] .= '<script type="text/javascript" src="/sites/all/libraries/selectivizr/selectivizr.js"></script>';
  $vars['selectivizr'] .= '<![endif]-->';

```

Looks like this code won't work if your site is not under /

But if the library is needed for your theme I don't see a problem with putting the conditional code into the page.tpl.php file.
> 1 votes

# Answer
I would use drupal\_add\_html\_head() in your template.php. Unfortunately, #865536: drupal\_add\_js() is missing the 'browsers' option
> 1 votes

# Answer
If your JS file has no dependencies, it can be included just like this in head tag of HTML:

```
$selectivizr = array(
  '#tag' => 'script',
  '#attributes' => array(
    'src' => file_create_url(drupal_get_path('theme', 'theme_name') . '/js/lib/selectivizr.js'),
  ),
  '#prefix' => '<!--[if lte IE 9]>',
  '#suffix' => '</script><![endif]-->'
);
drupal_add_html_head($selectivizr, 'selectivizr');

```

If you have, let's say, jQuery dependency, it makes sense to put your code to bottom of the page:

```
function THEMENAME_preprocess_html(&$vars){
  $vars['page']['page_bottom']['jquery_dependent_js'] = array(
    'footer' => array(
      '#type' => 'markup',
      '#markup' => '<!--[if lte IE 9]><script src="' .
        file_create_url(drupal_get_path('theme', 'theme_name') . '/js/lib/jquery_dependent_js.js'). '"></script><![endif]-->',
    )
  );
}

```
> 1 votes

---
Tags: 7, theming, javascript
---


title: Notice Error UND

text:
# Question
Title: Notice Error UND
I have a error that keeps popping up through my website after I added tags to print custom user profile fields. The code i'm using is

```
<?php
global $user;
$user_fields = user_load($user->uid);
$name = $user_fields->field_name;
$department = $user_fields->field_department;
?>
<?php

```

to pint the fields i'm using

```
<?php print $name['und'][0]['value'];?>
<?php print $department['und'][0]['value'];?>

```

i'm not sure if this is the correct way to do this or if there is a better way. I tried to remove \[0\] and the tag no longer works. I have also tried to use the following:

```
  <?php if (!empty($action_links)): ?>
  <?php print $name['und'][0]['value'];?>
  <?php endif ?>

```

This again did not display the custom field.

# Answer
> 0 votes
The proper way to print fields in Drupal 7 is to use field\_view\_field() to fetch a renderable array that can be passed to dupal\_render() like so:

```
<?php
  global $user;
  $user = user_load($user->uid);
  print drupal_render(field_view_field('user', $user, 'field_name'));
  print drupal_render(field_view_field('user', $user, 'field_department'));
?>

```

This is also true for $node objects FYI.

# Answer
> 0 votes
If you are wanting to render the field as drupal would in the "manage display" then use Webdrips answer. If you are simple wanting to render the value and have the entity API then you can do this:

```
<?php
  global $user;
  $user = user_load($user->uid);
  $user_wrapper = entity_metadata_wrapper('user', $user);
  $name = $user_wrapper->field_name->value();
  $department = $user_wrapper->field_department->value();
?>
<?php
  print $name;
  print $department;
?>

```

# Answer
> 0 votes
These are the warnings because you are accessing any `indexes` that are not present in that field. Mainly occurres when these fields are not entered so these indexes are not created. You can use it with the isset to avoid these `error/warnings`

```
<?php print isset($name['und'][0]['value']) ? $name['und'][0]['value'] : "";?>
<?php print isset($department['und'][0]['value']) ? $department['und'][0]['value'] "";?>

```

OR

You can use the default drupal method to print field using field\_view\_field() function as mention in the earlier answer.

```
<?php
global $user;
$userFull = user_load($user->uid);
print render(field_view_field('user',$userFull,'field_name',$display=array() ));
//Where $display handles the label(hidden or to show), format etc
?>

```

Hope it will help!

---
Tags: 7, theming
---


# Question
Title: Sorting by linked node/entity reference fields
Suppose I am printing name tags for thousands of content nodes in one content type called "Attendee." Each of these nodes specifies a single "Attendee" for an event, (and their respective name tag). Suppose these attendees also needed name tags printed out for their “friends” who are attending with them. That is not a problem: These *friends* need their own node with the same fields to get their own name tag, so I keep them in the same content type and distinguish that they are a *friend of an attendee* with a simple checkbox.

When rendering the view, I need these *friends of attendees* to appear right after the attendee they are going with. So to link them, I used a node reference or a entity reference field. How do I get the Views module to sort the *friends of attendees* right after the attendee they are going with?

P.S. I am technically using the Views PDF module, but it has the basic views functions, so if it's possible with Views, it will probably be possible with this module.

# Answer
Since you haven't been able to see the new fields for ordering (which is odd), you will probably have to perform a query alter on the views query and do some modifications:

```
<?php
function mymodule_views_query_alter(&$view, &$query) {
  if ($view->name == 'myviewname') {
    $view->query->somecodetoselectfields
    $view->query->somecodeforleftjoin
    $view->query->orderby[0]['field'] = "FIELDNAME";
    $view->query->orderby[0]['direction'] = "ASC";
  }
}
?>

```

What I usually do is just add a tag on the views query so that I can modify it using the standard Drupal query interface, which is much easier to use IMO.

```
<?php
function mymodule_views_query_alter(&$view, &$query) {
  if ($view->name == 'myviewname') {
    $query->tag[] = 'mytag';
  }
}
?>

```

Then

```
<?php
function mymodule_query_mytag_alter(QueryAlterableInterface $query) {
  $query->blablabla;
}
?>

```

Take a look at:

https://www.drupal.org/node/310077 https://api.drupal.org/api/views/views.api.php/function/hook\_views\_query\_alter/7 https://api.drupal.org/api/views/plugins%21views\_plugin\_query\_default.inc/class/views\_plugin\_query\_default/7

Apologies if the solution is not straightforward enough.
> 1 votes

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


title: Drupal custom OG subscribe url

text:
# Question
Title: Drupal custom OG subscribe url
I am using latest version of Organic Groups module. And create a page with panel page to view this group (classroom) content type. After that I added group\_group field to subscribe user in this node.

But when user is going to subscribe, this path look like:

siteURL/group/node/63/subscribe/og\_user\_node

**But I want to customize this path which look like:**

siteURL/classroom/subscribe/?classroomId=63

It's not necessary to make it (siteURL/classroom/subscribe/?classroomId=63)

But I want to remove "group/node" & "og\_user\_node" from url and replace with other word.

Thanks for your kind help.

# Answer
I'll suggest the most easy thing to do: Create a menu item and in that menu item you'll create the membership by your self. Don't know why this happening to you but the solution i suggest might be quicker.
> 0 votes

---
Tags: organic-groups
---


# Question
Title: Set the value of a hidden field in form block
Using the code below in a block, I am displaying a form in a block on all pages for a content type called Goals. I want to use this block / form to update progress on the goal to a content type called Goal Progress, and connect the two through a key called goal\_id - the nid of the Goal.

The challenge that I am having is setting the value for the goal\_id field (Goal Progress content type). I suspect I need to use $form\_state\['values'\]\['field\_goal\_id'\]\['und'\]\['0'\]\['value'\] = 'value'; to declare the value, but I can't figure out where that should be placed.

Been looking for a solution for a couple of hours now, so any suggestions are greatly appreciated.

```
<?php
  $node = menu_get_object();

  if (isset($node->nid)) {
    $nid = $node->nid;
  }

  module_load_include('inc', 'node', 'node.pages');
  $node_form = node_add('goal_progress');
  print drupal_render($node_form);
?>

```

# Answer
OK, I have found a working solution. I added $form\['field\_goal\_id'\]\['und'\]\['0'\]\['value'\]\['#value'\] = $node-\>nid; to hook\_form\_alter in template.php, and the value is populating the field and the form is submitting successfully. Sweet!
> 0 votes

---
Tags: forms
---


title: Plain text comments

text:
# Question
Title: Plain text comments
In Drupal 8, can I remove the subject field from comments and only have a single plain text box?

My goal is to set up something like a ticket tracking system. I will have a the Issue node. But I'd like to have a repeating text field that any authenticated user can *add* to. I'd like a user to report a problem. For this notes piece, it looked like comments would be the most logical. That is I need the Note to be saved for historical purposes and I don't want people to edit or change the initial issue.

Or, should I use another content type (let's call it Note) with an Entity Reference back to the related Issue?

# Answer
> 3 votes
See admin \> structure \> comment types then click manage fields. Configure from manage form display.

---
Tags: comments, 8
---


# Question
Title: Restrict product availability to certain languages/countries in Commerce
I need to make a commerce shop where certain products (containing alcohol) should not be available to a certain country/language. How to do this?

* Jonas

# Answer
I am assuming you have shipping enabled for your site. In that case, you can add a country field to your product display, say "Unsupported countries". And while creating a product, you can chose countries for which you are not going to sell. On checkout, add a rule to compare this field's value and the shipping address and If the shipping country is one of unavailable country, show a message and re-direct to cart page asking them to remove this product from their cart.
> 2 votes

---
Tags: commerce
---


# Question
Title: What is the php code to display a field of a referenced node in the node form of the node that references the node?
So I have a node (content type A) with some text fields and a reference field referencing another node (content type B).

When a user wants to update one of the text fields an existing node (content type A) , they need to see the text field of the referenced node (content type B).

Question: what is the php code that I can use to output that textfield from the referenced node (content type B) on the node form of the referencing node (content type A).

I'd like to add this to a code field in Display Suite and I also like to learn how to retrieve the variables from a loaded node and how to display them.

Cheers!

# Answer
> 0 votes
One way is to use panels, I highly suggest this method. It might be complicated at first but no coding is required.

* Enable the built in panels page for the path `node/%node/edit`.
* Add a selection rule: node (from node being edited) is of bunle 'type A'
* in **context** configuration page of enabled panel variant, create a relation using the entity reference field you have other.
* in Panels content add each field of node being edited (and submit buttons too!).
    + or perhaps add the general form instead of each field individually.
* again in add content, node section, choose rendered entity.
    + or create a view with a display of type `content pane` (ctools `views content panes` has to be enabled). Add a contextual filter of type nid, choose `argument input: nid from context` in view's configuration and use it to render the entity in panel. while adding this view to panel, choose the node you added with relationship.

Any way, the original question:
First, implement hook\_field\_extra\_fields. take node module's node\_field\_extra\_field as an example. or follow this question: how should I use hook\_field\_extra\_fields()?

```
/**
 * Implements hook_field_extra_fields().
 */
function MODULE_field_extra_fields() {
   $etype = 'node';
   $bundle = 'content_type_a';
   $field_name = 'the_other_entity';
   $extra[$etype][$bundle]['form'][$field_name] = array(
     'label' => t('The other entity'),
    'description' => t('Renders the related entity'),
    'weight' => 0,
  );
  return $extra;
}

```

Next, taking node.module as an example, implement a form alter for your content type:

```
function MODULE_node_form_content_type_a_form_alter(&$f, &$fs) {
  $field_name = 'the_other_entity';
  $f[$field_name] = array(
    '#markup' => $the_mighty_markup,
  );
}

```

Here is another example how to do it: http://johnheaven.eu/en/extending-drupals-user-contact-form it attachs fields to contact form though.

And about the $the\_mighty\_markup, here you have to generate output of your entity. One suggested way is to create a view, add a contextual filter on nid to it, display the fields you want. Then in your code execute the view to generate the output:

```
$this_node = entity_metadata_wrapper('node', $this_node);
$other_node = $this_node->field_the_other_node_er->value();
$nid = $other_node->nid;
// or simply:
$nid = $this_node->field_the_other_node_er->nid->value();
$the_mighty_markup = views_embed_view('the_created_view_of_yours', 'master', $nid);

```

edit: This is how to output a view: http://codekarate.com/blog/outputting-drupal-7-view-programmatically-contextual-filters-arguments

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


title: Comment form on a separate page

text:
# Question
Title: Comment form on a separate page
I want to have "Add new comment" link to open in a new page. I already read Placing the comment form on a separate page, but this didn't solve my problem. When I go to /comment/reply/\[nid\] or /comment/reply/\[nid\]#comment-form, a page opens with "Add new comment" as the h1 page title. Then underneath the page title is my entire custom content type, followed by the comment form. I don't know why my content type is also displaying. In my content type, I've got "Show reply form on the same page as comments" unchecked. In the "Comment Fields" tab, I only have the fields I want on the comment form and no fields from my content type are listed. Can anyone offer any suggestions?

Thanks, Paul

# Answer
For anyone with the same problem, what I had to do was:

```
function mymodule_page_alter(&$page) {
    unset($page['content']['system_main']['comment_node']);
}

```

I'm not fond of having to do this, but I couldn't figure out why the content type was displaying.
> 0 votes

---
Tags: comments
---


title: Unflag other users flag

text:
# Question
Title: Unflag other users flag
I have a site where people can sell their own items, so when a user creates a new product there is a flag "request product" that is added on the content.

I want the user who created the product to be able to unflag requests from other users.

Is this possible? Thanks

# Answer
You could use the Rules module as it integrates very well with the Flag module.

Check out the Flag video series by Johan Falk. Part 7 is specifically regarding Rules.

In short you're looking to generate a list of users that have flagged a node and then with built in Rules actions, unflag them.
> 2 votes

# Answer
You could also look at the "Flag Clear" module. This module will offer a much more straightforward approach to your problem than using a twisted Rules logic.

This module provides functionality to remove user flags for nodes and other entities.
> 0 votes

---
Tags: 7, flags
---


# Question
Title: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'semaphore' doesn't exist
I am having problems migrating my site to a production server. It's build in Drupal 7. I used the backup and migrate plugin to export the DB. The development server is Windows with Wamp installed and the production server is CentOS with Cpanel.

These are the errors I am getting:

> Error The website encountered an unexpected error. Please try again later. Error message PDOException: SQLSTATE\[42S02\]: Base table or view not found: 1146 Table 'fosagams\_co\_za.semaphore' doesn't exist: SELECT expire, value FROM {semaphore} WHERE name = :name; Array ( \[:name\] =\> variable\_init ) in lock\_may\_be\_available() (line 167 of /home/balabalab/public\_html/includes/lock.inc). Uncaught exception thrown in shutdown function.
>
> PDOException: SQLSTATE\[42S02\]: Base table or view not found: 1146 Table 'fosagams\_co\_za.semaphore' doesn't exist: DELETE FROM {semaphore} WHERE (value = :db\_condition\_placeholder\_0) ; Array ( \[:db\_condition\_placeholder\_0\] =\> 191980980751f69eddeb26b7.24464293 ) in lock\_release\_all() (line 269 of /home/balabalab/public\_html/includes/lock.inc).

I did however verify that the semaphore table exists. I am out of ideas, any help would be appreciated.

Thanks in advance.

# Answer
> 0 votes
I also got the same problem. Then i realizez that when migrating, i copy and paste from old server. And when i opend the database on my new server and choose a table in it, it was emty giving me error: "table does not exist". So check out if it is importing the content of the data firt before continuing with your search.

---
Tags: database
---


# Question
Title: Use Case : Registration of a Team for some event
Here is my use case:

> The users can register for the website and then form TEAMS. One of the users would be the TEAM LEADER. The team leader can register for various events for his/her team(s). When the team leader registers his/her team, all the TEAM MEMBERS automatically get registered.

Now, how to implement the above functionality? That is:

1. How do I implement the formation of teams?
2. How do I implement the registration of the whole team entity for some event?

**How is event registration handled?**

For events, I have a content-type event. The registration for event can be done using two approaches. Either using flag module, or making a registration content type and using references (and nodereference-url) module. I haven't finalized on the approach yet.

Furthermore, I'm thinking of using OG module for team formation, but I'd like to avoid that as it'd be an overkill.

Kindly suggest approaches for my use case.

Thank you in advance.

# Answer
> 1 votes
What you just described can indeed be implemented in various ways but it really depends on how you have architectured your website. Here is how to do it using relation angway:

# Use relation module

After installing relation, Create a relation type and name it something like *is member of* and it's reverse *has member*. The relation will be from user2user and with arity of 2.
I wouldn't suggest using any other configuration, such as using a single relation from *leader* to all *members*. Later it will cause you more pain.

### The Membership

I don't know. How does your website work? how does one request to be member of a group? many of these concerns are addressed by OG already.

### The registration workflow

Create another relationship *registered at* relation, from user to the entity type representing the event (the node if it is a node). Use the module rules\_link or rules\_pane. Create a rules component: *register at event* that takes two arguments: *event node* and *registering user*.

In this component you have to add:

* Action: Create a list of any entity type.

+ name it rel\_list.
* Action: Add an item to list.

+ list:rel\_list
    + item:node\_event from component arg.
* Action: Add an item to list

+ list:rel\_list
    + item:registering\_user from component arg.
* Action: Create an entity

+ of\_type:relation
    + of\_bundle:registered\_at

From your rules\_link or rules\_pane call this component and feed it current user and the corresponding node. The created relation entity is an indicator of membership, for leader only!
Add another component: Fetch team members, it's arg: leader user, it will provide: list of users-\>members. write a custom rule *fetch team members* and query all members using EntityFieldQuery or use the module efq\_rules to fetch team members. for each queried user, use the above component to create the relation.
you definitely want to have rules\_conditional installed.

### Central Place for storing memberships.

Instead of a direct relationship from leader to team members you might want to have a node representing the team and create relations from this node to users. this way if you needed to change the leader it can be easily done with removing the *is leader of* relation and creating a new one to the new leader. But then, having this central entity, why not make it an organic group?

I usually choose relation when I need a fine grained control over memberships.

---
Tags: 7, organic-groups, flags, users
---


# Question
Title: How can I embed view results right in the content region as if it's part of the content?
I have a node type with some entity reference fields that displays teasers. I also have a block view that takes a URL component to display related nodes that are not referenced on the node's entity reference field. What I want is for the view results to display right under the entity reference results display as if they were nodes being referenced on the field. The site is using display suite so there is a two column display.

# Answer
> 1 votes
Try adding Entity Views Attachment (EVA) in your view, then use it as a block-field in DS.

---
Tags: theming, views, entities, display-suite
---


# Question
Title: How to theme the separate page for editing profiles provided by Profile2
I'm using D7.
I'd like to theme the separate page for editing profiles provided by Profile2 module(whose URL is **MYWEBSITE.com/profile-MYPROFILE/\[uid\]/edit**).
I searched and found the way that somebody has already suggested. And, by reference to that, I tried the way below. But it doesn't work. Can anybody tell me where I made a mistake?

Here is the way I tried but that didn't work...

**1st: Create the customthem\_theme() below into template.php file of customtheme theme.**

```
function customtheme_theme() {
    $items = array();
    $items['user_profile_form'] = array(
        'render element' => 'form',
        'path' => drupal_get_path('theme', 'customtheme') . '/templates',
        'template' => 'user-profile-form',
        'preprocess functions' => array(
             'customtheme_preprocess_user_profile_form'
        ),
    );
    return $items;
}

```

**2nd: Create the template file user-profile-form.tpl.php and place it in the templates folder of custometheme.**

**3rd: Code the fields I want to display on user-profile-form.tpl.php**
for ex

```
<html>
<?php

print drupal_render($form['form_build_id']);
print drupal_render($form['form_id']);
?>

<div>
         <?php  print render($form['profile_MYPROFILE']['field_MYFIELD']); ?>
</div>
</html>

```

I'm still very new to drupal and, honestly, don't figure out how its system works yet. I'm sorry if this is a very easy mistake to you. Thanks.

# Answer
Change where it says `customtheme` to the actual theme name you are using.

for example if you are using bartik:

```
function bartik_theme() {
'path' => drupal_get_path('theme', 'bartik') . '/templates',
'preprocess functions' => array(
         'bartik_preprocess_user_profile_form'
    ),

```

The files should be located in your theme folder.
> 0 votes

---
Tags: theming, users
---


# Question
Title: How do I get an OG Group Menu block to appear in View?
Running Drupal 7 with `OG 7.x-2.3` and `OG Menu 7.x-3.0-rc4`. I have added a view to a Group Menu that lists all content in the group. All I want is for the group menu block to display when the view is executed.

I have added code in `hook_views_pre_view` to maintain the group context when view is executed.

I also attempt to utilize `OG URL Group Context Detection` by creating this URL path for the view:

`group/%/content`

I also added code in the view header/footer to detect if there is a group context when view executes. There is.

Despite all this, I can not get the Group menu block to display when the view is executed. Does anyone know of a way to accomplish this?

# Answer
Resolved my issue, more or less, here: https://www.drupal.org/node/2195889#comment-8493709

1. First, setting all group views to use this url format: group/%/(title)
2. Always set group context in hook\_views\_pre\_view() when arg(0) == 'group' and arg(1) is numeric. 3 .Use hook\_block\_info() to create my own block.
3. Use hook\_block\_view() to make my block content equal that generated by og\_menu\_block\_view().
4. Go into block settings, and set the block to only appear on views = group/%/(title).
5. Set the block to appear at the same weight (just above or below) as the OG Menu block.

And, voila! When I click on view from OG Menu, the OG group menu itself persists.
> 0 votes

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


title: How do I mimic the route handling?

text:
# Question
Title: How do I mimic the route handling?
In drupal 7 I have a chunk of code that gets the page content by mimicking what drupal does:

```
$router_item = menu_get_item($href);
if ($router_item['access']) {
  if ($router_item['include_file']) {
    require_once DRUPAL_ROOT . '/' . $router_item['include_file'];
  }
  $page_callback_result = call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
}

```

$page\_callback\_result will then hold the HMTL of the content region of that page.

I'm trying to port this to drupal 8 but I'm stuck. Anyone has a clue how to do this? I'm close, but I'm struggling on getting the controller:

```
 $request = Request::create('/' . $href);
 $controller_resolver = \Drupal::getContainer()->get('controller_resolver');
 //$controller = $controller_resolver->getController($request);
 $callable = $controller_resolver->getControllerFromDefinition('\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage');
 $arguments = $controller_resolver->getArguments($request, $callable);
 $page_content = call_user_func_array($callable, $arguments);

```

The problem is that $controller = $controller\_resolver-\>getController($request); returns FALSE. I'm trying to get the proper controller for a request, for some reason this won't work...

# Answer
I'm not sure what is the purpose of this, now in Drupal 8 Guzzle is available to creating external and internal request.

```
$this->httpClient->get($href)->getBody(TRUE);

```

The httpClient is a service in Drupal 8 api.drupal.org/api/drupal/core%21core.services.yml/service/http\_client/8

you need inject this service in your class.

if you need read the Route properties like callback, permissions, etc. you need use the routeProvider service.

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Routing%21RouteProvider.php/class/RouteProvider/8

maybe more information about that problem help us to understand what is the best way to porting for Drupal 8

UPDATE:

Thinking a little more, you want to make a sub-request?

something like https://gist.github.com/dmouse/4976461875a27689d155
> 1 votes

---
Tags: 8, routes
---


# Question
Title: How can I move a module block's title to display within the block's template?
When I give my module block a title it displays above my module block. How can I move this to display within my blocks template and not display above the template?

# Answer
You can do this by overriding the block template:

create a template called block--block-name.tpl.php OR override all block templates by using block.tpl.php and move the code the prints the title into the content div:

```
<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>

  <div class="content"<?php print $content_attributes; ?>>
    <?php print render($title_prefix); ?>
      <?php if ($block->subject): ?>
       <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
      <?php endif;?>
    <?php print render($title_suffix); ?>
    <?php print $content ?>
  </div>
</div>

```
> 1 votes

---
Tags: 7, theming, blocks
---


# Question
Title: How to get the CID number of comments from comment table?
If you check the comment table, you can see taht each comment has a CID number. For each article I need to have the CID number of all the comments for that article.

So I have written the following in node.tpl.php file:

```
 $result=db_select('comment', 'c')
 ->fields('cid')
  ->condition('nid', $node->nid,'=');

  $record=$result->execute()->fetch();

```

But I get error. So what is my mistake?

# Answer
```
  $result=db_query('SELECT cid FROM comment WHERE nid = :nid',array(':nid' => $node->nid));

```

Hope this helps you.
> 2 votes

---
Tags: comments
---


title: Entityform (block) redirect not working

text:
# Question
Title: Entityform (block) redirect not working
The redirect field within entityform doesn't seem to have any effect. I'm using the entityform block module, if it makes any difference.

I have also tried using hook\_form\_alter to copy to default submit action and hardcode it in, which also doesn't work:

```
function custom_edit_form_submit(&$form, &$form_state) {
   $form['actions']['submit']['#submit'][0] = 'custom_edit_form_submit';
}

function custom_edit_form_submit(&$form, &$form_state) {

$entityform = entity_ui_controller('entityform')->entityFormSubmitBuildEntity($form, $form_state);
  // Add in created and changed times. This must be added before preview to get time.
 if ($entityform->is_new = isset($entityform->is_new) ? $entityform->is_new : 0) {
global $user;
$entityform->created = time();

$entityform->uid = !empty($user->uid) ? $user->uid : 0;
}

$entityform->changed = time();
$entityform->draft = $form_state['clicked_button']['#entityform_draft'];
// Save the entityform and go back to the list of entityforms.
$entityform_type = entityform_type_load($entityform->type);
if (!empty($form_state['clicked_button']['#entityform_change'])) {
$form_state['entityform_preview_entity'] = $entityform;
$form_state['rebuild'] = TRUE;
drupal_set_message(t('Re-enter'));
return;
 }
else {
// If this entityform type has preview mode and we are in submit store preview.
if (empty($form_state['clicked_button']['#entityform_after_review'])
     && !$entityform->draft
     && !empty($entityform_type->data['preview_page'])
     && $form_state['entityform_form_mode'] == 'submit') {
  $form_state['entityform_preview_entity'] = $entityform;
  $form_state['rebuild'] = TRUE;
  return;
}
}

$entityform->save();
if ($form_state['entityform_form_mode'] == 'submit' || !user_access('edit any entityform')) {
if (empty($entityform->draft)) {
  $redirect_path = $entityform_type->get_path_property('redirect_path', $entityform);

  if (!empty($redirect_path)) {

    $form_state['redirect'] = 'my/path/here';
    // print_r($form_state); die(); This fires which shows that the function is being called
  }
  else {
    global $user;
    if (empty($user->uid)) {
      // For anonymous users we must store the id of their submission in the session.
      drupal_session_start();
      $_SESSION['entityform_submission'] = $entityform->entityform_id;
    }
    $confirm_path = entity_ui_controller('entityform')->confirm_path($entityform->type, $entityform->entityform_id);
    $form_state['redirect'] = array($confirm_path[0], $confirm_path[1]);
   }

  drupal_set_message($entityform_type->get_prop('submit_confirm_msg', $entityform));
  }
  else {
  // Saving a Draft.
  $form_state['redirect'] = $entityform_type->get_path_property('draft_redirect_path', $entityform);
  if (empty($form_state['redirect'])) {
    // Redirect to standard draft page.
    drupal_set_message(t('Your draft submission has been saved.'));
    $form_state['redirect'] = entity_ui_controller('entityform')->draft_path($entityform->type);
  }
  else {
    // Redirecting away from standard draft page. Show text as message.
    drupal_set_message($entityform_type->get_prop('draft_save_text', $entityform));
  }
}
}
else {
$info = entity_get_info('entityform_type');
$form_state['redirect'] = $info['admin ui']['path'] . "/manage/{$entityform_type->type}/submissions";
drupal_set_message($entityform_type->get_prop('submit_confirm_msg', $entityform));
}
}

```

# Answer
In addition to this code, you must use this code.

```
function custom_edit_form_submit(&$form, &$form_state) {
   $form['actions']['submit']['#submit'][] = 'custom_edit_form_submit';
}

```

whenever a submit is to be altered, we need not to override the index of default submit functionality instead we create a new one to perform a functionality on submit.

I hope, it will work for you!
> 0 votes

---
Tags: blocks, entities
---


# Question
Title: Problem to update a date_select field from a tableselect radio button via ajax callback. Other fields are well updated
Here is the corresponding code and a print screen of what happens when clicking a radio button (you can see it works well for type 'select' and 'textarea') I use Drupal core 7.31 and Date Date 7.x-2.8 (same problem with Date 7.x-2.x-dev).

Thanks in advance !

```
/**
 * Sample UI to update a record.
 */
function avf_crises_form_update($form, &$form_state) {
  $entries = avf_crises_entry_load();
  $keyed_entries = array();
  if (empty($entries)) {
    $form['no_values'] = array(
      '#value' => t("No entry founded."),
    );
    return $form;
  }
  foreach ($entries as $entry) {
    $options[$entry->pid] = t("@pid: @cdate @cduration @cintensity @ctreatment @ccomment @uid",
      array(
        '@pid'            => $entry->pid,
        '@cdate'          => $entry->cdate,
        '@ctime'          => $entry->ctime,
        '@cduration'      => $entry->cduration,
        '@cintensity'     => $entry->cintensity,
        '@ctreatment'     => $entry->ctreatment,
        '@ccomment'       => $entry->ccomment,
        '@uid'            => $entry->uid,
        )
      );
  $xdate = date('d-M-Y', strtotime($entry->cdate));
  $xtime = date('H:i', strtotime($entry->ctime));
  $xduration = date('H:i', strtotime($entry->cduration));
  $xcomment = br2nl($entry->ccomment);

    $rows[$entry->pid] = array(
      $xdate,
      $xtime,
      $entry->cintensity,
      $xduration,
      $entry->ctreatment,
      $entry->ccomment,
    );

    $keyed_entries[$entry->pid] = $entry;
  }
  $header = array(
    array('data' => t('Date'), 'field' => 'cdate', 'sort' => 'DESC'),
    array('data' => t('Time'), 'field' => 'ctime'),
    array('data' => t('Intensity'), 'field' => 'cintensity'),
    array('data' => t('Duration'), 'field' => 'cduration'),
    array('data' => t('Treatment'), 'field' => 'ctreatment'),
    array('data' => t('Comments'), 'field' => 'ccomment'),
  );
  $default_entry = $entries[0];

  $form_state['entries'] = $keyed_entries;

  $form['upd'] = array(
    '#type'  => 'fieldset',
    '#title' => t('Choose a crisis'),
    '#prefix' => '<div id="updateform">',
    '#suffix' => '</div>',
  );
  $form['upd']['table'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#title' => t('Table'),
      '#options' => $rows,
      '#multiple' => FALSE,
    '#js_select' => FALSE,
    '#empty' => t('No content available.'),
    '#ajax' => array(
      'wrapper' => 'updateform',
      'callback' => 'avf_crises_form_update_callback',
    ),
  );
  $form['upd']['cdate'] = array(
        '#type' => 'date_select',
        '#date_format' => 'd-M-Y',
    '#title' => t('Date'),
    '#required' => TRUE,
  );
  $form['upd']['ctime'] = array(
        '#type' => 'date_select',
        '#date_format' => 'h:i',
    '#title' => t('Time'),
    '#default_value' => '',
    '#required' => TRUE,
  );
  $dropdown_array = array(1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '6', 7 => '7', 8 => '8', 9 => '9', 10 => '10');
    $form['upd']['cintensity'] = array(
    '#type' => 'select',
    '#options' => $dropdown_array,
    '#title' => t('Intensity'),
    '#required' => TRUE,
  );
  $form['upd']['cduration'] = array(
        '#type' => 'date_select',
        '#date_format' => 'h:i',
        '#title' => t('Duration'),
    '#required' => TRUE,
  );
  $dropdown_array = array('None' => 'None', 'Imitrex full' => 'Imitrex full', 'Imitrex half' => 'Imitrex half', 'Imitrex one third' => 'Imitrex one third', 'Oxygen 15 lmin' => 'Oxygen 15 lmin', 'Oxygen 12 lmin' => 'Oxygen 12 lmin', 'Oxygen 9 lmin' => 'Oxygen 9 lmin', 'Other' => 'Other');
  $form['upd']['ctreatment'] = array(
    '#type' => 'select',
    '#options' => $dropdown_array,
    '#title' => t('Treatment'),
    '#required' => TRUE,
  );
  $form['upd']['ccomment'] = array(
    '#type' => 'textarea',
    '#title' => t('Comments'),
    '#rows' => 3,
    '#required' => FALSE,
  );
  $form['upd']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
  );
  return $form;
}

/**
 * AJAX callback handler for the pid select.
 * When the pid changes, populates the defaults from the database in the form.
 */
function avf_crises_form_update_callback($form, $form_state) {
  $entry = $form_state['entries'][$form_state['values']['table']];
  foreach (array('cdate', 'ctime', 'cintensity', 'cduration', 'ctreatment', 'ccomment') as $item) {
    $form['upd'][$item]['#value'] = $entry->$item;
  }
  $form['upd']['ccomment']['#value'] = br2nl($entry->ccomment);
  return $form;
}

```

# Answer
> 0 votes
Solution :

1) date must be set as array

2) strval(intval =\> prevent leading zero problem (if leading zero it do not work, except for minute and second ... why, I don't know ...)

```
function avf_crises_form_update_callback($form, $form_state) {
  $entry = $form_state['entries'][$form_state['values']['table']];
  foreach (array('cdate', 'ctime', 'cintensity', 'cduration', 'ctreatment', 'ccomment') as $item) {
    $form['upd'][$item]['#value'] = $entry->$item;
  }
  $form['upd']['ccomment']['#value'] = br2nl($entry->ccomment);

  // Set dates array
  list($zdate, $ztime) = explode(' ', $form['upd']['adate']['#value']);
  list($zyear, $zmonth, $zday) = explode('-', $zdate);
  list($zhour, $zminute, $zsecond) = explode(':', $ztime);

  $form['upd']['cdate']['year']['#value'] = strval(intval($zyear));
  $form['upd']['cdate']['month']['#value'] = strval(intval($zmonth));
  $form['upd']['cdate']['day']['#value'] = strval(intval($zday));
  $form['upd']['cdate']['hour']['#value'] = strval(intval($zhour));
  $form['upd']['cdate']['minute']['#value'] = $zminute;
  $form['upd']['cdate']['second']['#value'] = $zsecond;

  return $form;
}

```

---
Tags: ajax, datetime, forms
---


# Question
Title: Link in main menu does not point to specified path
I'm trying to add a link to my site's about page to the main menu as an "About" link. I have configured it in the following manner:

```
Menu link title: About
Path: node/2
Description: (none)
Enabled: selected
Show as expanded: deselected
Parent link: Main menu
Weight: 1

```

I do get an "About" link created in the main menu, but this points to `http://about/` and not to `http://{sitename}/node/2`. I know that I can add the full URL and adding the full URL does work, however, I'm interested to this with relative paths.

# Answer
Try setting the $base\_url variable in your settings file. Open settings.php, usually sites/default/settings.php, and search for '$base\_url', there are instructions within the comments about how to set it correctly.
> 0 votes

---
Tags: routes, navigation
---


# Question
Title: Admin user can't manage fields on custom content type
When in logged in to my Drupal 7 install as the administrative user, I can't access the "Manage fields" or "Manage Display" for my custom content types.

I've tried all the following with no joy:

* I've deactivated all my custom modules
* I've given the admin user all permissions
* I've flushed the cache, many, many times
* Logged out and back in

I'm pretty sure I'm not using the hook\_drupal\_break hook anywhere!

I've got NO IDEA what I've done wrong. It used to work, but now I can't access it.

# Answer
> 26 votes
I feel so stupid. But I'm leaving this answer so that the next person to have this same problem will save 3 days of development time:

The module that allows fields to be created on entities (nodes, user etc.) is creatively called "Field".

But, that doesn't mean you'll have a UI to create/edit them. There is another creatively named module called "Field UI". If this modules isn't installed AND enabled you won't have a user interface to edit your fields...

# Answer
> 2 votes
If you did the above answer, and it is still not working - check if you have disabled Developer Modules by hovering the "HOME" in the administration menu and see if it says "Enable developer modules".

Disabling developer modules will disable Fields UI and Views UI.. even if you activate the modules manually you wont be able to edit views or fields - so check if Dev. Modules is enabled.

---
Tags: 7
---


title: Add cropping option to an image form

text:
# Question
Title: Add cropping option to an image form
I've the next form.

```
$form['imagen'] = array(
        '#title' => t('Image'),
        '#type' => 'managed_file',
        '#upload_validators' => array('file_validate_extensions' => array('jpeg jpg png gif')),
        '#upload_location' => 'public://',
        '#progress_indicator' => 'throbber',
        '#status' => FILE_STATUS_PERMANENT,
        '#progress_message' => 'One moment while we save your file...',
    );

```

That generates something like this:

What I need is to give the user the option to see the image that he has upload, and resize the image. The functionality that I need, is the same that the ImageField\_crop module gives.

I'm totally lost. I don't know how to add this functionality to the form. It's totally necessary for the project to insert this form in a custom module, because I have a multistep form.

Does anybody know how to do this??

Thank you very much.

# Answer
Better you can go with implementing the field with "imagefield\_crop" module instead of doing customization further.
> 0 votes

# Answer
Is it not possible by adding the #widget attribute to the form? Something like:

```
    $form['imagen'] = array(
    '#title' => t('Image'),
    '#type' => 'managed_file',
    '#upload_validators' => array('file_validate_extensions' => array('jpeg jpg png gif')),
    '#upload_location' => 'public://',
    '#progress_indicator' => 'throbber',
    '#status' => FILE_STATUS_PERMANENT,
    '#progress_message' => 'One moment while we save your file...',
    '#widget' => array(
     'type' => 'imagefield_crop_widget',
  ),
);

```
> 0 votes

---
Tags: 7, forms, media
---


title: Link node/teaser to view

text:
# Question
Title: Link node/teaser to view
could anyone tell me how to link a node/teaser to a view?

I have an overview page to give a list of all models available (done with view and one content type) and from there I want to send the visitor to the model page that shows not just that initial node but the entire view with gallery section etc.

Help would be so much appreciated, since I have been unable to find anything helpful on the web for days now.

Many thanks in advance. Susanne

# Answer
Your description is a bit mixed up regarding the terms you use. Here's what I understand and how I would do it.

(1) You have a content type 'model' which is used to describe the individual model.

(2) You have a second content type 'gallery' which shows images or whatever other information. This content type also has entity\_reference field linking this content to a model.

(3) You have a view displayed as block which lists full content of galleries (content type) and uses a contextual filter on the node id of the parent model content type.

(4) You set the block to be displayed in main content region and restrict it to model content types.

(5) You should now see all gallery sections when you visit a model node page.

(6) You create a second view which lists teasers of models, the titles link to the individual model pages (which already include the galleries block).

EDIT: After more information provided, I think you can achieve your goal way easier. Taxonomy Terms have built-in view (you may need to activate it in the views overview). Drupal displays terms as a link by default. Clicking that link you'll be taken to a page where all content for that term is listed. Now, in your existing view of all boats, add the taxonomy field "boat type/model" to your fields list and place it after/below the title. Configure the title field to NOT link to the entity and exclude it from display. Next, change the taxonomy field and rewrite it by using "\[title\]" as the rewritten content. Under display settings you can optionally set the field style to use some headline tag (e.g. h3). The result should be the title of each node linking to the taxonomy term view of that node's model.
> 1 votes

---
Tags: views, nodes, navigation
---


# Question
Title: Views & colorbox trigger, make the colorbox image adapt to screen size
When I use a colorbox-trigger to open a colorbox, I have to specify the width and height of the overlay - unlike in a regular colorbox image field, where it adapts nicely to the screen size. Is there any way to get such a feature in views?

# Answer
The `colorbox-trigger` is normally only required when you want to display HTML in your colorbox. You are then required to set height and width as colorbox is not able to determine the dimensions of the HTML content before it is loaded.

If you want to display an image in a colorbox, there's no need to use the colorbox-trigger but instead just add the image field and use `colorbox` as image style. Within the field formatter settings of colorbox you can then define the image styles to be used for preview and inside the colorbox. If the colorbox image style exceeds the screen, colorbox will automatically resize the image to fit the screen/window.

In your case, you want to have the image displayed along with custom HTML captions. Thus, you need to define the colorbox content and then set height and width to 100%. The colorbox will then use up maximum available space. However, your image is still not diplayed at 100% width. To achieve that, you would need a quite large image to be displayed in the colorbox, eventually add a wrapper div to it and set a CSS rule like

```
div.wrapper img { max-width: 100%; }

```
> 2 votes

---
Tags: views, javascript
---


# Question
Title: Delay ajax from firing immediately (AJAX links api)
**Problem**

I'm trying to add a bunch of CSS3 page transitions to my site. To do this, I'm loading the pages with AJAX using the AJAX Links API module, but I want to delay the AJAX call to allow for the animations.

However the ajax click handler seems to come straight from jquery.min.js, rather than module as I expected so I can't work out how to delay it. Does anyone know how to delay the ajax link click handler? (i.e. wrap it in a `setTimeout`.)

**Details**

I can prevent normal link clicks with:

```
  Drupal.behaviors.dsmooth_state = {
    attach: function (context, settings) {
      $('a.notajax').click(function (e) {
        e.preventDefault();                   // prevent default anchor behavior
        var goTo = this.getAttribute("href"); // store anchor href

        // funky animations go here.

        setTimeout(function(){
             window.location = goTo;
        },800);
      });
    }
  };

```

However the Drupal AJAX framework, uses a separate click handler for AJAX which is obviously not effected by this.

The AJAX Links API module defines the following click handler, however wrapping it in a setTimeout does nothing. I'm presuming that somehow this click handler sets the other one? I'm not really sure.

```
var ajaxLoading = false;
  Drupal.behaviors.ajaxLinksApi = {
    attach: function () {
      var trigger = Drupal.settings.ajax_links_api.trigger,
        negativeTrigger = Drupal.settings.ajax_links_api.negative_triggers;

      // match the elements from the positive selector
      var $elements = $(trigger);

      // remove elements if the negative trigger is specified
      if (negativeTrigger) {
        $elements = $elements.not(negativeTrigger);
      }

      // add the click handler
      $elements.click(function(e) {
        e.preventDefault();
        var selector;
        if(!ajaxLoading) {
          ajaxLoading = true;
          var url = $(this).attr("href");
          var id = $(this).attr("rel");
          if(id) {
            selector = $(this).attr("rel");
          } else {
            selector = Drupal.settings.ajax_links_api.selector;
          }
          ajaxBefore(selector);
          ajaxLink(selector, url);
        }
      });
    }
  };

```

//EDIT removed chrome information. I think I misunderstood what Chrome was putting out. It seems to list all event listeners as coming from jquery.min.js

# Answer
Ok so this was in fact a JS problem and not related to Drupal, I was in the correct place and writing some bad JS.

If you are trying to delay the AJAX clicks on the AJAX Links API module, you need to add a `setTimeout` and an extra variable to the JS defined in `ajax_links_api.js`

```
  $elements.click(function(e) {
    e.preventDefault();
    //This gets altered by setTimeout function, so save now.
    var store = this;
    var selector;
    setTimeout(function(e){
      if(!ajaxLoading) {
        ajaxLoading = true;
        var url = $(store).attr("href");
        var id = $(store).attr("rel");
        if(id) {
          selector = $(store).attr("rel");
        } else {
          selector = Drupal.settings.ajax_links_api.selector;
        }
        ajaxBefore(selector);
        ajaxLink(selector, url);
      }
    },800);
  });

```
> 0 votes

---
Tags: 7, ajax
---


title: Refer a Node in Forum Post

text:
# Question
Title: Refer a Node in Forum Post
Is there a way to refer to a node in a forum post?

Like I want to put a hyperlink to the node with the node title as the display name. Is there any short handed variable that allows me to do that?

Thanks

# Answer
Have a look at Freelinking Casetracker.

Drupal.org itself also automatically converts \[#nid\] found in issue comments to Node links, but I'm not sure if they're using this module or another similar input filter.

Writing your own input filter is pretty straightforward if those don't exactly match your needs.
> 1 votes

# Answer
Have a look at Freelinking (you don't need the Freelinking Casetracking extension).

This project implements a filter framework for easier creation of HTML links to other pages on the site or to external sites. To refer to a node with nid 42, you write `[[nid:42]]`. This will produce a hyperlink to the node with the node title as the display name.
> 0 votes

---
Tags: nodes
---


# Question
Title: using hook_form_alter on a same form from 2 different modules
How will a predefined form behave if we have two different forms that implement hook\_form\_alter?

I would explain my question by an example, because currently I got a crash on it:

I have a predefined user\_login form in user.module

I created two new blocks called author\_login and creator\_login. Each of these module using the form user\_login and adding new validating properties for each form by using function hook\_form\_alter().

The new validating properties are:

For author\_login block: if user doesn't have author role, user will not be logged into system, error: "you don't have author role"

For creator\_login block: if user doesn't have creator role, user will not be logged into system, error: "you don't have creator role"

But the problem is: the new login block I created works fine if only one of two modules is enable. If I enable both modules, no user cannot log in to the system through these module.

For example, I have both modules enabled, I go to author\_login block and log an user named Mark, who has role Author, to the system, an error message displayed: "the user Mark doesn't have creator role". And similar to creator\_login block.

Why does this happen? I thought that the hook\_form\_alter will alter different properties to each new module we created, make each new form works separately. But from this case I encountered, it seem like the user\_login form validate all new properties that I added by using hook\_form\_alter. And how can I avoid this as I want these two form to work separately?

Notes: I am really sorry to post this question here because I posted the question on drupal.stackexchange but there was only one answer that couldn't help me much in finding the solution. I really need help on this question. Many thanks!

# Answer
> 1 votes
All implementations of the `hook_form_alter()` will alter the `user_login` forms you embed in your blocks. As you observed, your author\_login form alter will not be restricted to only altering the form in your author\_login block.

If you want your form alters to only alter the form in the context of their respective blocks, you have to find a way to observe the block context from them. There is no easy way to properly implement this, you will either have to add additional non-standard arguments to your form builder (the arguments passed to `drupal_get_form()` after the form ID), or uses some sort of global states.

A cleaner solution is to use `hook_forms` to define new author\_login and creator\_login forms that simply re-use the existing `user_login` form as callback but have a different form id:

```
/**
 * Implements hook_forms().
 */
function author_login_forms($form_id, $args) {
  $forms = array();
  $forms['author_login'] = array(
    'callback' => 'user_login',
  );
  return $forms;
}

```

You can then simply implement a form alter specific to your author login form.

```
/**
 * Implements hook_form_FORM_ID_alter().
 */
function author_login_form_author_login_alter(&$form, &$form_state) {
  $form['#validate'][] = 'author_login_validate';
}

```

And finally embed this form wherever you need it with

```
drupal_get_form('author_login');

```

Repeat for the creator login form.

---
Tags: forms
---


title: Special Sort in views

text:
# Question
Title: Special Sort in views
I have a series of image,each image has it's own thumbnail(because cropping and scaling not suitable for some of images ),when user upload a image, upload thumbnail too,also I provide a field "class size" ( it is select list with 4 values (180,240,300,360) that indicate thumbnail width). I want create a views that sort thumbnails like below picture (and if rows is more than 11 this sequence will be repeat)

**anybody has idea how can I do it?**

# Answer
> 2 votes
Drupal Isotope module (or Masonry)that uses the isotope jquery plugin with the Masonry plugin would work perfect in this situation. If the module does not work for you consider just using the plugin with a custom views template

---
Tags: views
---


# Question
Title: save cart for anonymous user after registration
I know drupal commerce let anonymous user create cart and in billing or shipping step create a user according billing or shipping information,But I want implement another policy,user can add product to his/her cart,then when he/she want checkout I want redirect him/her to registration form I provided then after he/she fill information(registration) then he/she can keep on shipping. I have idea I save cart information in temp variables,after he/she create user add that cart information to him/her,But I don't sure this is the only and best way,**anybody has idea about how can I achieve this task?**

# Answer
There is a module called Commerce Checkout Redirect, which redirects an anonymous user to Register or Login page and redirects to checkout on filling of either form, that would come handy for you.
> 3 votes

---
Tags: users, commerce
---


title: Make a direct database query

text:
# Question
Title: Make a direct database query
Basically I want to run this query against the current database and retrieve all node titles with node type of foo\_type.

```
SELECT title FROM node WHERE type='foo_type' ORDER BY title ASC

```

How can I do this using db\_query or any similar function? I tried doing the below but $result is empty.

```
$result = db_query("SELECT title FROM node WHERE type='foo_type' ORDER BY title ASC");

```

Please note any D6 and D7 differences if there are any.

# Answer
> 9 votes
For Drupal 6:

```
$result = db_query("SELECT title FROM node WHERE type = '%s' ORDER BY title ASC", 'foo_type');
$titles = array();
while ($row = db_fetch_object($result)) {
  $titles[] = $row->title;
}

```

For Drupal 7 you have a bunch of options

Static:

```
$args = array(':type' => 'foo_type');
$titles = db_query("SELECT title FROM node WHERE type = :type ORDER BY title ASC", $args)->fetchCol();

```

Dynamic:

```
$titles = db_select('node')
  ->fields('node', array('title'))
  ->condition('type', 'foo_type')
  ->orderBy('title')
  ->execute()
  ->fetchCol();

```

And a couple of less-direct methods...

EntityFieldQuery:

```
$query = new \EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->entityCondition('type', 'foo_type')
  ->propertyOrderBy('title');

$results = $query->execute();
if (!empty($results['node'])) {
  $nodes = node_load_multiple(array_keys($results['node']));
  $titles = array_map(function($x) { return $x->title; }, $nodes);
}

```

API (deprecated):

```
$nodes = entity_load('node', FALSE, array('type' => 'foo_type'));
$titles = array_map(function($x) { return $x->title; }, $nodes);

```

---
Tags: database
---


# Question
Title: Services module: What is 'Index' operation?
D7 / Services 3.2

retrieve / create / update / delete are very straightforward, make senses to me that matching 'CRUD', I don't understand what 'index' here does?

Thanks.

# Answer
'Index' in services module will list out an entity(node, users, taxonomy..) in descending Order of its created time, vid, name etc based on the arguments that are passed. The common arguments for the Index are

1. `page` \- Page number of results to return (in pages of 20).
2. `fields` \- The fields you want returned.
3. `parameters` \- An array containing fields and values used to build a sql WHERE clause indicating items to retrieve. (array)
4. `pagesize` \- number of items to be returned. (Integer)

In case of retrieve, it returns the complete entity object of the passed 'entity\_id'

**UPDATED:**

Sample URLS for Index is

For documentation you can see Services: An API for remote applications.
> 11 votes

# Answer
services module provides some endpoints with resources. `index` will return all the nodes depends on the resource you selected. in this case suppose `node` is a resource and URL looks like this - `http://domain/endpoint/node` with a `GET` Request will return all the nodes.
> 0 votes

---
Tags: services, 8
---


title: Drupal Commerce Multiple Prices

text:
# Question
Title: Drupal Commerce Multiple Prices
I'm trying to get a two tiered pricing structure into my store. Essentially I need every product to have two prices. There's the main price but there's also a secondary price that get's triggered if the customer has more than 14 products in their cart. I can't do an across the board discount, it has to be specific prices per product.

Say product one has a main price of $20 but a hidden secondary price of $15 and product two has a main price of $50 but a hidden secondary price of $30. This will be defined on the product itself. It's all arbitrary pricing set for every product.

I figured out how to set a rule where 14 products will trigger it but I can't work out how to add a secondary price to a product then activate that price.

# Answer
> 1 votes
Luckily you have figured the harder part, counting the 14 products on user's cart. Second part is easily done, and it's called 'dynamic price calculation' or similar terms if you would like to find further information on google.

* Create a rule
* **Event**: Calculating the sell price of a product
* Condition 0: (which is **very important**) *Entity is of bundle* or *Entity has field* or else you wont see the second price field added to the product type. It's rules assertion internal stuff and is needed, but somehow it's name is confusing.
* Condition 1: If there are 14 or more products in cart
* **Action**: Set the unit price to a specific amount
* The value you pass to the action above is simply the price value in the second field!

This page could be useful, Sell Price Calculation / The life of a Price Calculation

---
Tags: commerce, rules
---


# Question
Title: Contextual filter on taxonomy view using URL
I have a taxonomy

Bubble Clouds Flower

I also have a pages where I need to be able to pull a taxonomy term (and it's fields) into the page. if the site path is abc.com/features/bubbles

I need to be able to access blubbles and it's fields.

I've created a view of taxonomy terms that lists all my terms. I can not get the contextual filter correct to display just bubbles.

Any help is appreciated.

# Answer
Create a view, Create a page display and set it's path to `features/%`

Then add a contextual filter: *Taxonomy term: name*.

That's it! when you visit the page /features/blubbles page, if there is a taxonomy term named blubbles, the views will display the fields you have added. You may add a validation criteria (while adding the contextual filter) to limit terms to an specific vocabulary.

However you might want to consider using panels too. After enabling panels, page manager and views content panes modules, you can create a page and set it's path as features/%term (notice the arg is %term not %) set it's type as String.

* Add a display to your view of type `content pane`
* Add the contextual filter, taxonomy term: name.
* In configuration section of the views display there is a 'argument input', open it and set type of argument `from panels argumen`
* In the opened configuration popup, select **second argument** as the name is second parameter in your path. you may select from panels context too if you can configure the panels accordingly.
* Go to panels configuration page, add content to one of regions, select **views panes** not regular views!
* Visit the panels page, done.

This way you have more control over your page. you can create another views, such as a view directly showing nodes, filtered by a taxonomy. you can send the term name just like you sent in the views above.
In the first view it's not a good idea to show nodes if you are only planning to display the term fields only once.

This question : Contextual filter with a block view is about views blocks and contextual filters. I still suggest using pages. views content pane will play role if a block for you.
> 1 votes

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


# Question
Title: Does the LDAP module encrypt directory queries?
I'm using the LDAP module and do *not* have the Start-TLS box checked. Does this mean my directory queries are running over an insecure connection? Or are queries to the directory server always ran over SSL/TLS?

# Answer
As configured in your screenshot -- yes your queries are running in plaintext over the wire. This is similar to running MySQL on the default port and not running MySQL connections under SSL (which is also possible by sharing certs).

Securing network connections between Drupal and LDAP is dependant on your LDAP vendor. For instance your LDAP vendor may support `ldaps://` (ldap using SSL) connection strings to connect to your server and a secure port (such as 636) and not require Start-TLS.

For some gritty details see details from the Open LDAP FAQ: http://www.openldap.org/faq/data/cache/605.html

> The StartTLS extended operation \[RFC 2830\] is LDAPv3's standard mechanism for enabling TLS (SSL) data confidentiality protection. The mechanism uses an LDAPv3 extended operation to establish an encrypted SSL/TLS connection within an already established LDAP connection. While the mechanism is designed for use with TLSv1, most implementations will fallback to SSLv3 (and SSLv2) if necessary.
>
> ldaps:// is a mechanism for establishing an encrypted SSL/TLS connection for LDAP. It requires use of separate port, commonly 636. Though originally designed for use with LDAPv2 and SSLv2, many implementations support its use with LDAPv3 and TLSv1. Although there is no technical specification for ldaps:// it is widely used.
>
> ldaps:// is deprecated in favor of Start TLS \[RFC2830\]. OpenLDAP 2.0 supports both.
>
> For security reasons the server should be configured not to accept SSLv2.

For example at my job they say to use `ldaps://` and a secure port when connecting to our LDAP server. They say not to use start-tls. The configuration depends on your LDAP vendor and the version of LDAP you're using.
> 2 votes

---
Tags: authentication-authorization
---


# Question
Title: Master Detail webform or connecting/linking two webforms
I just got a project request that went from simple to complex.

the original project was just to collect basic user info, the complexity comes in, now they want the user to provide detail on his/her car or cars. So one submission could have 1 2, 5 detail entries.

is it possible to do a master/detail setup using drupal webforms? i need to create a webform that will have a general info in the top, ex: fname, lastname, age, location, range

there will also be a detail section of their webform that will contain: car type, partID, quantity, type, past requests for example.

Is there away to connect two webforms as there could be several details related to one submission?

**Example**: Were I doing this in straight php, i would have a master/detail tables one take holding the fname, lfname, age, location range date one table holding car type, partID, quantity, type, past requests the later table would have a key to connect the items to the first table, easy

How can I accomplish this, or can I accomplish this using webform?

I did a search on connect, link, combine webforms, but not getting anything concrete back, so want to see if i need to rethink the entire process before continuing down the rabbit hole.

Any ideas, advice suggestions would be greatly appreciated.

Thank you in advance.

# Answer
For those who come along with a similar issue - my solution here was to use the entityform and fieldcollection modues. the fieldcollection module allow you to attached a group of sub fields to the entityfield, then you can add more of the subfields as needed. Querying and views were also fairly easy to set up.
> 0 votes

---
Tags: webforms
---


# Question
Title: Devel output on hooks called during cron run
I'm implementing a hook that is called if certain conditions are met during a cron run.

(Specifically `hook_bounce_mails_blocked($mails)` from the Bounce module)

The hook is triggered, but any output from `dpm()` functions is never shown. I do see output from `var_dump()` after cron finishes.

Is this normal behaviour? Is there a way to get devel output shown once cron finishes?

# Answer
> 7 votes
You should use the function dd() to log something during cron.

Here is the doc: https://api.drupal.org/api/devel/devel.module/function/dd/7

It will log the output to a file, which later you can investigate. I think you must have private file path set.

you could use something like this, **But be careful about XSS!**

```
$export = var_export($var, TRUE) // TRUE will cause var_export to return the output not print it.
$export = nl2br($export); // Convert new lines to <br> tag for display in HTML
$export = strreplace(' ', ' '); // Again convert whitespace to HTML specific chatacter
watchdog('my_debug', $export); // That's it!

```

or even easier: **but again be careful about CSSF and XSS**

```
watchdog('my_debug', '<pre>' . var_export($variable) . '</pre>');

```

**dd** is the safe drupal way to go.

## Update

From comments so you wont miss:

> ... better than dd() is ddl(), from the drupal\_debug\_log module that enhances \> the devel module... – DrCord

# Important point to developers.

If you search drupal.org modules there are many more to make development easier. After you found and used them, it would sound impossible to go without them (devel\_themer to name one). An example search.

---
Tags: cron, debugging
---


# Question
Title: On User Creation, send user registration email in his language preference
Is there a way to send the welcome message to a new user in his preferred languages ?

As an Administrator of the website, I create all the users with their preferred languages. I Check the button to notify the user when the user is created. The email is sent correcly but not in the languages that I specify for a particular user.

I already install the I18n module and made the translation between each languages.

Thanks a lot

# Answer
> 0 votes
I think you need to change the way drupal detect the language of the current user.

You can do so by going to /admin/config/regional/language/configure and check "Follow the user's language preference.". You may need to move this option as the first detection method.

---
Tags: emails, i18n-l10n
---


# Question
Title: FontAwesome character added via CSS only appears when logged in
I'm pretty new to Drupal and CSS; I'm stumped with this issue. I have a FontAwesome camera character that I've written to appear before my caption div in Flexslider. Here's what I have:

```
div.flex-caption:before {
    content: "\f083";
    font-family: fontawesome;
    margin-left:10px;
    padding: 10px;
}

```

This works fine when I'm logged in as a user to the site, but the icon doesn't appear if I'm not logged in to my Drupal site. Not sure why—any ideas? I'm using Drupal 7.31

Edit: Just to clarify, all other FontAwesome characters are working fine. It's just this particular bit of code that isn't working.

# Answer
> 0 votes
Is it possible that your CSS rule is in the CSS for your administrative theme (by default "Seven"), but not in the theme for your public (non-logged-in) users (by default "Bartik")?

If so, you need to copy this CSS fragment into the public theme too.

---
Tags: users, theming
---


# Question
Title: Theming a node teaser to use its content types's custom tpl.php
I have a page--contenttype.tpl.php in a custom theme that displays a node exactly how I want it to display on its own node page. How do I make it so that the teaser for the node of that type displays the same as it displays in full view?

I want to add this in either template.php, page.tpl.php or page--contenttype.tpl.php of my custom theme but cannot figure out the best way of doing it

# Answer
> 2 votes
You can add template files in your template.php & then add files for them. In your case write something like this in your template.php -

```
function THEME_preprocess_node(&$vars) { //Replace THEME with your theme name.
  if($vars['view_mode'] == 'teaser') {
    $vars['theme_hook_suggestions'][] = 'node__' . $vars['node']->type . '__teaser';
  }
}

```

After that, your TPL file for teaser would be in the format of `node--[type]--teaser.tpl.php`. Don't forget to clear your cache after you do this..

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


title: Cannot install modules

text:
# Question
Title: Cannot install modules
I am very new to Drupal so please excuse me if this is an easily answered question.

Basically I wish to install CKEditor, however when I upload the module thorugh the online installer I am greeted with:

```
ckeditor_4.4.5_full.zip does not contain any .info files.

```

On trying to install from the URL another error:

```
The specified file temporary://files2sU5P could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.
http://ftp.drupal.org/files/projects/ckeditor-7.x-1.15.zip could not be saved to temporary://update-cache-ac727b57/ckeditor-7.x-1.15.zip.
Unable to retrieve Drupal project from http://ftp.drupal.org/files/projects/ckeditor-7.x-1.15.zip.

```

When I attempt to install a different module (weather module) to test to see if it is the module itself, again an ulgy:

```
weather-7.x-2.6.zip does not contain any .info files.

```

Finally, on an attempt to place the extracted .zip file on the webserver in the /sites/all/modules directory, nothing shows up, I only see the 'Core' modules listed.

Any suggestion as to what I should do? Any help greatly appreciated, \- Dylan.

# Answer
Try to check the settings of the "temporary directory" under File System (admin/config/media/file-system) admin page.

* Usually should be folder: `/tmp`
* Check if the folder has write access (specially for apache or the HTTP web server you are using).

You could find more info at Drupal documentation.
> 0 votes

---
Tags: 7
---


title: cant install themes after upgrade

text:
# Question
Title: cant install themes after upgrade
I've upgraded from D6.31 to D7 . few problems with block.tpl.php in te deafult theme, but sorted easily. Now when I install a theme i get a WSOD

```
select * FROM watchdog ORDER by wid DESC lIMIT 2;

```

gives an error of

```
The file %path was not deleted, because it does not exist. | a:1:{s:5:"%path";s:43:"temporary://marinelli-7.x-3.0-beta11.tar.gz";}

```

google hasnt thrown up any possible solutions. Anyone know ?

# Answer
hmmmm . When i try it today i get an error message in the browser. I thought I had turned on error reporting in php.ini yesterday.

OS ubuntu 14. all the webdirectory is chown www-data: www-data . ive tried chmodding the themes directory to 777 but I still get the error.

ive just got one user, I assume admin privileges havent changed with the upgrade

Warning: move\_uploaded\_file(/tmp/marinelli-7.x-3.0-beta11.tar.gz): failed to open stream: Permission denied in drupal\_move\_uploaded\_file() (line 1639 of /var/www/devsite.org/includes/file.inc). Warning: move\_uploaded\_file(): Unable to move '/tmp/phpgdOHHS' to '/tmp/marinelli-7.x-3.0-beta11.tar.gz' in drupal\_move\_uploaded\_file() (line 1639 of /var/www/devsite.org/includes/file.inc). File upload error. Could not move uploaded file.
> 0 votes

---
Tags: theming, installation
---


# Question
Title: Problem with equal height of columns in Display Suite
I\`ve got ***Fluid two column stacked*** layout in **Display Suite**. There is responsive picture in the first column, the second column contain some rendered fields. Below that columns is long text. My problem is with right column. I need to make the height of that column equal to height of the picture on left side. How to achieve that? Is there possibility to add some scrollbar in the right column? Anybody had the similiar situation? Some simple solution without coding or only small snippet ;) Maybe I need to add some view in the right column

# Answer
> 0 votes
Create your own layout for display suite and use CSS.

Add the folder 'ds\_layouts' to you theme folder root. Under that folder ad another folder: two\_col\_fluid\_stacked\_fixed\_height

Ie Must look like this: YOURTHEMEFOLDER -\> ds\_layouts -\> two\_col\_fluid\_stacked\_fixed\_height

Add the following files to two\_col\_fluid\_stacked\_fixed\_height folder:

**two\_col\_fluid\_stacked\_fixed\_height.inc**

```
<?php
function ds_two_col_fluid_stacked_fixed_height() {
    return array(
        'label' => t('two col stacked fluid fixed height'),
        'regions' => array(
            'header' => t('Header'),
            'left' => t('Left'),
            'right' => t('Right'),
            'footer' => t('Footer'),
        ),
        'css' => TRUE,
    );
}

```

**two-col-fluid-stacked-fixed-height.tpl.php**

```
<<?php print $layout_wrapper; print $layout_attributes; ?> class="<?php print $classes;?> ds-2col-stacked-fluid-fixed-height clearfix">
  <!-- Needed to activate contextual links -->
  <?php if (isset($title_suffix['contextual_links'])): ?>
    <?php print render($title_suffix['contextual_links']); ?>
  <?php endif; ?>

    <<?php print $header_wrapper; ?> class="group-header<?php print $header_classes; ?>">
      <?php print $header; ?>
    </<?php print $header_wrapper; ?>>

    <div class="center-wrapper">

    <<?php print $left_wrapper; ?> class="group-left<?php print $left_classes; ?>">
      <?php print $left; ?>
    </<?php print $left_wrapper; ?>>

    <<?php print $right_wrapper; ?> class="group-right<?php print $right_classes; ?>">
      <?php print $right; ?>
    </<?php print $right_wrapper; ?>>
    </div>

    <<?php print $footer_wrapper; ?> class="group-footer<?php print $footer_classes; ?>">
      <?php print $footer; ?>
    </<?php print $footer_wrapper; ?>>

</<?php print $layout_wrapper ?>>

<!-- Needed to activate display suite support on forms -->
<?php if (!empty($drupal_render_children)): ?>
  <?php print $drupal_render_children ?>
<?php endif; ?>

```

**two\_col\_fluid\_stacked\_fixed\_height.css**

```
.ds-2col-stacked-fluid-fixed-height > .group-header {
}

.ds-2col-stacked-fluid-fixed-height .center-wrapper > .group-left {
    float: left; /* LTR */
    width: 50%;
}

.ds-2col-stacked-fluid-fixed-height .center-wrapper > .group-right {
    width: 50%;
    height:99999px;
    position:absolute;
    right:0;
}

.ds-2col-stacked-fluid-fixed-height .center-wrapper {
    overflow:hidden;
    position:relative;
}

.ds-2col-stacked-fluid-fixed-height.group-one-column > .group-left,
.ds-2col-stacked-fluid-fixed-height.group-one-column > .group-right {
    width: 100%;
    float: none;
}

.ds-2col-stacked-fluid-fixed-height > .group-footer {
    clear: both;
}

/*delete this*/
.group-left {
    background:yellow;
}
.group-right {
    background:red;
}

```

Clear you cache and use this layout in display suite. Tweak CSS to your liking.

# Answer
> 0 votes
I use Omega 3.0 for prettymuch everything and it comes with the Equal-Heights-Library option installed (toggled on the theme settings page). I've never tried to implement equal heights on another theme, but I'm sure someone could answer that here.

When using Omega with equal heights option enabled, and Display Suite with a multiple column layout, you can add the 'equal-height-container' class to the layout wrapper, and 'equal-height-column' class to the layout's groups (group-left/group-right in your case), via the 'Custom Classes' tab at the bottom of the content-type's Display Settings page.

It works flawlessly.

Aside from that... the hack & slash would be to use **The One True Layout** method, which is what I tend to use when options are slim... though it messes with your styling a bit.

---
Tags: 7, views, display-suite
---


# Question
Title: Taxes not updated after manually adding a product to an order. Drupal Commerce
Using Commerce 7.x-1.10.

I created several tax rules to fit different countries. All of them works fine through the checkout process.

The problem is that if I (as admin user) manually add a product Line Item to the order at: `admin/commerce/orders/ORDER-ID/edit`, then the taxes are no re-calculated.

I already enabled the option: `Enable the local action link on order edit forms to apply pricing rules.` in this admin page: `admin/commerce/config/order`. Loop my capture bellow. I expected to see a link in the edit order form, but I see no link there. What's the goal of this feature??

```
To reproduce:
1) an order is created
2) as admin user I go to `admin/commerce/orders/ORDER-ID/edit`
3) add a new product to the order
4) save
5) the taxes are not re-calculated

```

**UPDATE 2**: changing the order status didn't work for me: https://www.drupal.org/node/1094266#comment-4269794, https://drupalcommerce.org/questions/4302/rules-not-firing-during-admin-order-editing

# Answer
We ran into the same issue which we worked around by using the Drupal Commerce Point of Sale module to manage manual orders.

As of now, the button "apply pricing rules" is working for us in the order editing form to apply the taxes but we found it easier to use Commerce POS. Your mileage may vary...

Hope this helps!
> 1 votes

---
Tags: commerce
---


title: Display a popup once in front page

text:
# Question
Title: Display a popup once in front page
Does any one know a good module I can use to set a nice popup (supporting html) on the front\_page when a user visit the website for the first time??

# Answer
> 8 votes
Zerolab is right! If disclamer module is not good for you, also try Splash (Splashify on D7)

# Answer
> 4 votes
You could give the Disclaimer module a try. It is quite easy to setup and can be used on any page.

# Answer
> 1 votes
Another minimal candidate is Tinybox

It is stripped down to the essential basics. Still it allows to choose which content type to display (node ID, Content Type or Views).

---
Tags: 7
---


# Question
Title: Drush - How to install a specific core base (language)
What is the syntax to download and install the **French** version of core? https://localize.drupal.org/translate/languages/fr

# Answer
> 1 votes
Have you looked at the drush help for `site-install`?

```
/etc/php5/apache2 > drush help site-install
Install Drupal along with modules/themes/configuration using the specified install profile.

Examples:
 drush site-install expert --locale=uk     (Re)install using the expert install profile. Set default language to Ukranian.
 drush site-install                        Install using the specified DB params.
 --db-url=mysql://root:pass@localhost:por
 t/dbname
 drush site-install                        Install using SQLite (D7+ only).
 --db-url=sqlite://sites/example.com/file
 s/.ht.sqlite
 drush site-install --account-name=joe     Re-install with specified uid1 credentials.
 --account-pass=mom
 drush site-install standard               Pass additional arguments to the profile (D7 example shown here - for D6, omit the form
 install_configure_form.site_default_coun  id).
 try=FR
 my_profile_form.my_settings.key=value
 drush site-install                        Disable email notification during install and later. If your server has no smtp, this gets
 install_configure_form.update_status_mod  rid of an error during install.
 ule='array(FALSE,FALSE)'

Arguments:
 profile                                   the install profile you wish to run. defaults to 'default' in D6, 'standard' in D7+
 key=value...                              any additional settings you wish to pass to the profile. Fully supported on D7+, partially
                                           supported on D6 (single step configure forms only). The key is in the form [form
                                           name].[parameter name] on D7 or just [parameter name] on D6.

Options:
 --account-mail                            uid1 email. Defaults to admin@example.com
 --account-name                            uid1 name. Defaults to admin
 --account-pass                            uid1 pass. Defaults to a randomly generated password. If desired, set a fixed password in
                                           drushrc.php.
 --clean-url                               Defaults to 1
 --db-prefix                               An optional table prefix to use for initial install.  Can be a key-value array of
                                           tables/prefixes in a drushrc file (not the command line).
 --db-su=                            Account to use when creating a new database. Must have Grant permission (mysql only).
                                           Optional.
 --db-su-pw=                         Password for the "db-su" account. Optional.
 --db-url=      A Drupal 6 style database URL. Only required for initial install - not re-install.
 --locale=                          A short language code. Sets the default site language. Language files must already be
                                           present. You may use download command to get them.
 --site-mail                               From: for system mailings. Defaults to admin@example.com
 --site-name                               Defaults to Site-Install
 --sites-subdir=           Name of directory under 'sites' which should be created. Only needed when the subdirectory
                                           does not already exist. Defaults to 'default'

Aliases: si

```

You want to set the `--locale` option, probably to `FR`.

---
Tags: drush, i18n-l10n
---


# Question
Title: Using the Sites module with a multiligual site
My multilingual site has three sets of (anonymous or logged-in) users: public, set1 and set2. They will all get the same site structure, but set1 or set2 will see slightly different content on some pages. Each group will be given a URL: http://example.com/mysite for public, and http://example.com/mysite/set1 or http://example.com/mysite/set2 for the others.

I can use the Views module with the Context module to help decide what content to show on the pages, but I need a way for the URL to retain, for example, "set1" in the URL path as they navigate around.

I tried Sites (which uses PURL), but it doesn't work with Internationalization: it prefixes the site name before the language, so when clicking the language selector back and forth, you can end up with page not found and a broken menu at http://example.com/mysite/set1/en/fr/fr/fr/en/en/en/en!

Is it possible to use Sites with i18n?

Or should I use another approach?

# Answer
You cannot use the PURL "path" method with i18n (Internationalization) because it conflicts with i18n outbound url rewrites - specifically the detection and maintaining of region and language using the path.

I'm not sure if PURL domain and query string methods will still work.

I too am looking at this because I have a project where we've used PURL to maintain a brand identifier with the commerce module, but we want to also use i18n in future. I've used i18n and Domain Access modules before, both separately and together and they play well. Domain Access though is not what you want.

My suggestion would be to treat your "set1" and "set2" like regions. The i18n module lets you specify a region and language that is detected from the path. This is so you can have things like

* Germany with German (DE-de)
* Germany with French (DE-fr)
* Germany with English (DE-en)
* United States with Spanish (US-es)
* United States with English (US-en)
* etc.

So, in these examples we have a country-code and then a language. The i18n module allows you to detect first the country code as a region and the language code for language and then customise the settings based on both.

I would suggest you use this method to specify custom languages where you have a "set1" for region and a standard language code for language, defaulting to English where no language is defined (ie. `LANGUAGE_NONE`).

I'm going to give this a go myself for my project. I'll let you know how I go.
> 0 votes

---
Tags: i18n-l10n, multi-sites, 7, subsites
---


# Question
Title: After drupal 6> 7 upgrade attached pdf links not visible
After upgrade fromn 6 \> 7 attachment information is not visible in nodes. Data exists in dbase. What is best approach to re-connecting pdf, mp3 and other attachments to specific nodes. (2000 or so)

# Answer
> 0 votes
Use CCK migrate module to migrate (import) the D6 fields to D7 . CCK migrate module is the part of CCK module in drupal 7.

Here is the documentation how to do it.

---
Tags: 7, entities
---