# Question
Title: How to let an OG administrator contact (via email) all group members?
I've a request to set up an email form where by a OG administrator can send a message (via email) to all persons subscribed to that group.

I've seen a few modules OG Contact, OG Notify, and Organic Groups Email, but these seem out of date.

# Answer
> 1 votes
Using the Forena module, you could start from one of the Sample reports and solutions that come with it. I.e. the **Active Users Email**, which is a ***demo of the ability to send email to all active users of a Drupal site***.

The idea is that those users who have access to it, actually get a FORM to have Drupal send an eMail to all users selected via the query. To do so, you just have to "submit the report".

The easiest way to see the out-of-the-box example at work, is to (temporary) install the module in some dev environment you have available (for obvious reasons this sample report is NOT available to anonymous users in a Forena demo site ...).

Here is what would be needed to transform (clone) this sample to fit your needs:

* Adapt its data block (an SQL query) to list "all persons subscribed to an organic group" (instead of all "active users of a Drupal site").
* Adapt the actual content of the delivered eMail template to fit the actual eMail content (message).
* Optionally you may want to make the "Organic group" to be selected a report parameter.
* Secure "access" so that only the OG administrator can send such eMails. Depending on how your OG group(s) security is setup, you may want to adapt the Forena permissions accordingly.

**Note**: the above approach can be used for all sorts of eMails towards any set of users of a Drupal site. Whereas that "set of users" is just a matter of writing some (basic) SQL statement to select the users you want to target. E.g: (a) users with a selected role or (b) users who didn't login for X days anymore or ... And the actual eMail content (message to be delivered) is actually anything you can format as an XHTML document.

Disclosure: I'm a co-maintainer of the Forena module.

# Answer
> 2 votes
This question have been answer at - How to loop over a list of Organic Group users using Rules

and at - How to send an email to Drupal 7 Organic Groups Role Members? in here is going to show you how to do it with a custom module.

There other alternatives:

1- You can use views\_bulk\_operations

> I would think you should be able to do it by adding views\_bulk\_operations to the mix-- that should give you the ability to email users in a view which you can setup with the criteria you need via filtering.

Source

2- You can do it with Rules

> Looping over a list can only be done in Rules (i.e. for Drupal 7).

Source

# Answer
> 1 votes
I would have thought that Rules would be your best option

# Answer
> 0 votes
I think that module og\_mailinglist will help you with the most functionality you need But still you have to do some customization.

**First**: It lets any member to send mail to all group users, And in your case you need only the group admin so I see you need to create a custom menu item with access checking for group admins only which navigates the admin to where he will send the module.

**Second**: reply to the email will create content which is not needed and considered a **security risk** you have to take care and prevent that functionality

**Finally**: Read the module documentation carefully and check its API well to achieve you goal with the optimal way.

**Also** message\_notify deserves to give it a try But I think it may need extra configuration and customization.

# Answer
> 0 votes
If you aren't willing to use those OG specific modules, I'd suggest using an entity form with entity reference prepopulate to make it cleaner.

1. Create an entity form with the required fields such as email title and body.
2. Add an entity reference field with prepopulate (and hide) enabled.
3. Construct a url that fills the entity reference field with the group nid using tokens.

Using rules on entity form save, you can then loop through the subscribed members to the group referenced in the entity form and construct your email using the entity form fields.

Some benefits to using the above as a base method..

* You can load the entity form inside a colorbox to give a very nice UI.
* You can add extra fields as needed.
* You can get a bit fancier and make the email get sent to users from certain roles etc.

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


title: Views title instead of id

text:
# Question
Title: Views title instead of id
I have create new view showing all content referenced by given tag using contextual filter `(field_tag: Content) Content: ID zawartości`. Now I struggle how to overwrite the view page title with id of tag instead of node id provided as argument of contextual title.

In the contextual filters menu I have only following tokens avaliable:

while I am looking for the token allowing me to use "tag title" instead of "tag id" in the view page title.

The general idea is to have a page listing all content which is referenced by a tag given as a url argument.

I have read answers for similar questions here, but can't really find working solution.

# Answer
At the end I benefited from both @No Sssweat and @Neograph734 answers.

First of all I added `(field_tag: Content) Content: Title [nie pokazuj]` field. Than I entered `Content: Title` field marked "modify output value" and get replacement token from there.

At the end I inputed the replacement token in contextual filter menu.

As @Neograph734 mentioned my problem was that the contextual filter did not proper list all available tokens.
> 3 votes

# Answer
Add (field\_tag: Content) Content: ID to your fields.

You must **move field\_tag above the title**, so the field\_tag token becomes available.

Then click on the title field and re-write the results. click on Available tokens, and you should see the field\_tag token which you then copy and paste it on the rewrite box.

**If you are re-writing the link**, make sure you **unchecked** the `Link this field to the original piece of content` box, other wise your re-write won't apply.
> 2 votes

---
Tags: views, 8
---


# Question
Title: Drupal commerce auto login during checkout process
I have created a e-commerce site, in that when anonymous user purchase a product during checkout process it should automatically created a account and assign order to the user. For existing user it should it should log in and assign order to him. Is there any module to do this or else how can achieve this.

I have tried https://www.drupal.org/project/commerce\_checkout\_complete\_registration it works fine for new user. When I enter existing user email site goes to Maintenance mode.

# Answer
Commerce Checkout Login includes this functionality.

If you just want a rule action to automatically log a user in, then use simongeorge's wonderful sandbox. It provides a rule action that allows you to do just that.
> 0 votes

---
Tags: 7, commerce, users
---


# Question
Title: DrupalQueue worker callback in separate file
This is my first time using the DrupalQueue class, and I have two questions.

Does hook\_cron\_queue\_info() HAVE to go in my mymodule.module file? I had some weird behavior before finally trying that, and it seems to be the culprit.

Can I put the queue worker callback in a separate file? I'm trying to keep all my queue functions in their own file, but it doesn't seem like I can do a file attribute like with a lot of other callback types; I just keep getting function undefined errors.

I tried...

```
function mymodule_cron_queue_info() {
  $queues['autopilot'] = array(
    'time' => 60,
    'worker callback' => '_mymodule_queue_handler',
    'file' => array('type' => 'inc', 'module' => 'mymodule', 'name' => 'includes/mymodule.queue'),
  );
  return $queues;
}

```

and

```
function mymodule_cron_queue_info() {
 module_load_include('module', 'mymodule', 'includes/mymodule.queue.inc');
  $queues['autopilot'] = array(
    'time' => 60,
    'worker callback' => '_mymodule_queue_handler',
  );
  return $queues;
}

```

but neither seem to work.

# Answer
I was looking for this too. Turns out that it is not supported, judging from source in drupal\_cron\_run(). If your queue worker is sizable, one option is to create an intermediary worker callback in your .module file, then include and execute the mymodule.queue.inc worker from that function.
> 3 votes

---
Tags: 7, queue
---


# Question
Title: Creating a view that excludes entity referenced nodes
Say I have a Content type of Fruit. I have an Entity Reference on the User Profile to Fruit nodes. I want to create a view that shows all Fruit nodes that are NOT referenced by the Entity Reference on the current user profile.

(More details: I can create a view that *includes* Fruit nodes on the current user profile, by creating a view of Fruit nodes with a Relationship to the Entity Reference on the User Profile. Alternatively, by creating a View of users, filtering by current users, and then using the entity reference to show the data from the Fruit nodes. However, I haven't found a way to create a view of Fruit nodes that are NOT referenced on the current User Profile.

# Answer
Views Reference Filter might help you:

> This module provides the feature missing in Views module - subquery filter for IN (NOT IN) condition, such as (quite informal):
>
> SELECT n.title FROM node n WHERE n.nid \[IN | NOT IN\] (SELECT n2.nid FROM node n2 WHERE ...)
>
> or
>
> SELECT n.title FROM node n WHERE n.node\_reference\_field \[IN | NOT IN\] (SELECT n2.nid FROM node n2 WHERE ...)
> 0 votes

---
Tags: views, entities, users
---


title: Adding team information to migrate_d2d

text:
# Question
Title: Adding team information to migrate_d2d
I expect this is a trivial question for those familiar with OOP/PHP. The migrate\_d2d module provides an example module that demonstrates implementing a D6 -\> D7 migration. I'm making great progress in defining the migration as I need. However, I am stumped on how I can add team information to my custom migration. The provided beer examples show performing this step when extending the Migration class.

```
abstract class BasicExampleMigration extends Migration {
  public function __construct($arguments) {
    parent::__construct($arguments);

    $this->team = array(
      new MigrateTeamMember('Liz Taster', 'ltaster@example.com',
                            t('Product Owner')),
      new MigrateTeamMember('Larry Brewer', 'lbrewer@example.com',
                            t('Implementor')),
    );

    $this->issuePattern = 'http://drupal.org/node/:id:';
  }
}

```

With migrate\_d2d, the chain of dependency starts with the migrate\_d2d class definitions:

```
Migration > DrupalMigration when then forks to:
DrupalUserMigration > DrupalUser7Migration
DrupalTermMigration > DrupalTerm7Migration
DrupalRoleMigration > DrupalRole7Migration
...etc

```

For my purposes, I'd like the DrupalMigration object to have the team properties set.

How do I modify DrupalMigration class properties so that I can set the team's properties and have all the children classes inherit this property?

# Answer
> 1 votes
I just followed the dependency chain of the example module:

* ExampleNodeMigration extends DrupalNode6Migration
* DrupalNode6Migration extends DrupalNodeMigration
* DrupalNodeMigration extends DrupalMigration
* DrupalMigration extends Migration

That means that as long as your class, like ExampleNodeMigration, extends a class down the chain from class Migration, your team implementation should be as in the example you gave.

In light of the changes you made:

> How do I modify DrupalMigration class properties so that I can set the team's properties and have all the children classes inherit this property?

You insert your own custom class that extends the lowest class in the chain that has what you need, then have your migration modules extend **it**. So if you are migrating users, you would extend DrupalUser7Migration in some custom class, then have your various user migration classes extend DrupalUser7Migration, and so on for each variety of thing that migrate\_d2d can migrate. That may be the best you can do because PHP is single-inheritance.

There is another way to get around single-inheritance and not repeat yourself. You can create a trait, called, for example, MyMigrationSettings.

```
trait MyMigrationSettings {
  function setTeam() {
    $this->team = array(
    new MigrateTeamMember('Liz Taster', 'ltaster@example.com',
                        t('Product Owner')),
    new MigrateTeamMember('Larry Brewer', 'lbrewer@example.com',
                        t('Implementor')),
    );
  }
}

```

Then, use the trait in your migration classes:

```
class ExampleNodeMigration extends DrupalNode6Migration {
  use MyMigrationSettings;
  public function __construct($arguments) {
    parent::__construct($arguments);
    $this->setTeam();
    // ...
  );
}

```

I have not tested this code and I am just literally typing it into the comment box.

---
Tags: migrations
---


# Question
Title: Activate menu item with preprocess_page function
Hi my international friends!

I work in Drupal 7.38.

If the current page belongs to a specific content type, I want to activate a specific menu item. By ***to activate a specific menu item*** I mean that this menu item has the class ***active***.

I try to do this with **preprocess\_page()** function within template.php. It does not work **:(**.

Here is the code.

```
function MY_THEME_preprocess_page(&$vars) {
  if( !empty($vars['node']) ) {
    switch ( $vars['node']->type ) {
      case 'machine_name_my_content_type':
        menu_tree_set_path('machine_name_menu','path_menu_item');
        break;
      default:
        menu_tree_set_path('machine_name_menu','path_menu_item');
    }
  }
}

```

I have also tried a variation. Instead of putting:

```
menu_tree_set_path ('machine_name_menu' 'path_menu_item')

```

I put `menu_set_active_item ('path_menu_item')`

**Nothing works!**

Can you help me. Thanks in advance.

# Answer
I would suggest looking at the Menu position module
> 0 votes

---
Tags: routes, theming
---


# Question
Title: How to change url webform entry textfiled to link in views?
I have url data (for example http://testtt.infoo) submitted from webform (component textfield).

When I display by using Views, this looks like text. I hope I can click it and open the url site.

What should I do to make that url data displayed as clickable link.

# Answer
> 1 votes
Add the component value which stores the URL to your View. Configure the field and choose to 'exclude from display'. Add a new custom Global: custom text field to your view. Choose Rewrite results -\> output this field as link. In the link path field choose the URL component value from the replacements values list.

---
Tags: webforms
---


title: altering user tag input

text:
# Question
Title: altering user tag input
I have a content type that allows users to make their own tags, for me to be able to properly search through these tags I need them to be in a specific format.

Rather than burden users with my strict formatting guideline I would like to just alter the input to my format before creating the tag. Is such a thing possible?

# Answer
Implement hook\_taxonomy\_term\_presave in a custom module and alter the terms according using PHP's string manipulation functions.
> 1 votes

---
Tags: taxonomy-terms, input-formats
---


# Question
Title: Ajax div update to insert JS for subsequent asynchronous request to external site
I wanted to use the postscribe library (https://github.com/krux/postscribe) to make an asynchronous request to google trends, which would update a div with a graph without requiring a page reload.

Using the library on its own through a few methods (drupal\_add\_js or a custom block) works just fine, but I wish for the js code to be reloaded everytime the appropriate ajax callback is initiated.

```
$form['trends-visual'] = array(
  '#prefix' => '<div id="trends-ajax-wrap">',
  '#suffix' => '<div id="trends-visualization-container"></div></div>',
  '#ajax' => array(
    'effect' => 'fade',
  ),
);

$form['trends-graph'] = array(
  '#prefix' => '<div id="trends-graph",',
  '#suffix' => '</div>',
);

$form['submit'] = array(
  '#type' => 'submit',
  '#value' => 'Submit',
  '#ajax' => array(
    'callback' => 'trends_ajax_submit_callback',
  )
);

```

The callback

```
function trends_ajax_submit_callback($ajax, &$form, &$form_state)  {

 $form_state['rebuild'] = TRUE;
 $commands = array();
 $commands[] = ajax_command_html('#trends-visualization-container',
   '<script>
     (function ($) {
       Drupal.behaviors.trends_ajax = {
         attach: function (context, settings) {
            postscribe(\'#trends-graph\',
            \'<script src="//www.google.com/trends/embed.js?hl=en-US&q=Stephen%20Harper&tz=Etc/GMT%2B4&content=1&cid=TIMESERIES_GRAPH_0&export=5&w=500&h=330">
            </script>\');
         }
       }
      })(jQuery);</script>');

return array('#type' => 'ajax', '#commands' => $commands);

```

Triggering the Ajax with $form\['submit'\] results in the following JS error:

```
Uncaught SyntaxError: Unexpected token ILLEGAL

```

This is referencing my JS code, specifically this line:

```
postscribe('#trends-graph', '<script src="//www.google.com/trends/embed.js?hl=en-US&q=Stephen%20Harper&tz=Etc/GMT%2B4&content=1&cid=TIMESERIES_GRAPH_0&export=5&w=500&h=330">

```

Through googling it is suggested that there is an illegal hidden character somewhere, but after having looked at the code in VIM, EMACS, KATE, OKTETA, ATOM, JSBin, JSFiddle, and CodePen I am unable to find any strange hidden characters. The closest anomaly I can find are 0A characters through the hexeditor (Okteta), but I don't think those should be causing any problems.

Could someone provide some info as to how I can continue to troubleshoot?

Thanks a lot!

# Answer
I managed to solve this by escaping one more character and removing one semicolon.

In the 2nd argument of ajax\_command\_html I was attaching a string which had two script tags, one inner and one outter. The inner closing script tag wasn't being passed unless I escaped its forward slash, like this:

```
<\/script>

```

Lastly, I had to remove the semicolon that was following "(jQuery)", just prior to closing the outter script tag, like this:

```
})(jQuery)</script>');

```

Hopefully this can be of use to someone!
> 0 votes

---
Tags: forms, ajax
---


# Question
Title: Construct a View-Grid from fields of the same node?
I understand that naturally it's not possible to **grid** fields from a single node, when using Views, and we could only display a grid if each field is coming from a different node.

Is there a module that will allow Views, somehow, to make a grid based on fields from the same\single\unique node?

I would surly prefer a way to do it with views-only, but if there is no easy\automatic way to so without installing an external module than so be it.

# Answer
You could use a combination of Display Suite and Views. This is not a perfect grid... but it's close. These are the steps I followed. I created a Content Type with 6 **Long text** fields.

1. Install Display Suite and enable Display Suite and Display Suite UI
2. Go to **Manage Display** of your Content type, click on **Custom display settings** and enable **Full content**
3. Click on the **Layout** tab and select a layout. I selected a **Three column stacked - equal with** layout.
4. I distributed the fields into the three columns (Left, Middle, Right), and added the node **Title** in the Header area
5. Create a **View** of Content. In display format be sure to select Unformatted list of **full posts**
6. Click on the **Content** link under **Format**. Be sure to select **Display Suite**. Select **Full Content**
7. Visit your View. This is what it looks like (I am showing two nodes, with 6 fields each):

Now, if you want to make it look nice (e.g. more space between columns), you will have to use css - no way around it.
> 6 votes

# Answer
**For ALL your fields you need to do this**

* Customize field HTML
* Select SPAN as your HTML element
* type your class name. Example: cool `(use the same name for all your fields)`
* Uncheck Add default Classes

For **FORMAT**

* use Unformatted List

For **Show**: click on settings

* Uncheck provide default field wrappers elements

**Now all you need is to add css to your drupal theme `.css` file**

## **To Make it Mobile friendly**

Add a class name to your entire view (ex: test) (see screenshot below)

In css, for width use %, ex:

```
.test { border: solid red; width: 90%; }
.cool  { border: solid green; width: 200px; float: left;  }

```

### BONUS

If you want to add a class for each row.

* Format click on settings
* Enter a name for row class
* Then in CSS

```
.example { border: solid blue; }

```
> 5 votes

# Answer
I usually do this manually but I believe you could use Display Suite for this (free video on drupalize.me).

Many responsive starter themes provide "display suite layouts" out of the box now.

There's even this: https://www.drupal.org/project/ds\_bootstrap\_layouts
> 1 votes

# Answer
**Option 1.** Edit the field, under Style Settings check "Customize field and label wrapper HTML" and add your class.

**Option 2.** Add a new "custom text field" in your view and add html for your other fields using "replacement patterns". i.e.

```
<article class="grid6">
  <header><h1>[title]</h1</header>
  <div class="my-class">[body]</div>
</article>

```

**How to add a custom text field**

The custom text field gets added to the result by Views. You don't add it to your content type. You add it to your view as usual.

1. Edit your view and click "add" field.
2. Search for "Global: Custom text" and click Apply.
3. On the text area for this field add your html and replacement patterns.

For each field that you reference in your "custom text field" you will most probably want to select "Exclude from display".

Note: You can only reference fields that are listed 'before' your custom field.
> 1 votes

---
Tags: views, 8
---


title: I function and menu_link

text:
# Question
Title: I function and menu_link
I need to put an id in menu links i have this code from here https://api.drupal.org/api/drupal/includes!menu.inc/function/theme\_menu\_link/7.

```
function theme_menu_link(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}

```

And have found the code i need but am struggling where to place it in the function. This code https://api.drupal.org/comment/45408#comment-45408:

```
l( t('Refresh Page'), $path . '/getdata', array(
              'attributes' => array(
                'id' => '',
                'class' => 'btn-small btn-primary '
              ),'query' => drupal_get_destination() , 'html' => TRUE)),

    );

```

Where would it go, i know what i need, but i am having difficulty doing it.

Thanks

# Answer
You can use this module to place different menu attributes to your menu links:

**Menu Attributes**

> This simple module allows you to specify some additional attributes for menu items such as id, name, class, style, and rel.
>
> You should use this module when
>
> * You want to "nofollow" certain menu items to sculpt the flow of PageRank through your site.
> * You want to give a menu item an ID so you can easily select it using jQuery.
> * You want to add additional classes or styles to a menu item.

You can also add the ID using theme\_menu\_link like you were using above, you would place that code in your template.php of your theme.

If you use the Devel module you can print out the `$variables` array and see the different parts of the array there. You would basically want to use the mlid and the attributes part of the link to build out the ID (see code snippet below).

```
$element['#attributes']['id'] = 'menu-' . $element['#original_link']['mlid'];

```

If you need any other information just let me know, thanks!
> 1 votes

---
Tags: theming
---


# Question
Title: How to add fields while creating a node?
I am looking for a module which allows a user to create a new field while adding a new node.

Is this possible, or should I resort to comma separated values in a big text area?

# Answer
> 0 votes
In your content type, Edit the the field, scroll all the way down, and select unlimited for number of values.

---
Tags: 7, nodes
---


# Question
Title: Auto remove white background and add alpha channel to images?
I use Drupal 7.41 and created a "customers" view. This view get's nodes from the content-type (also called) "customers".

When I add images, some of them contain white background that conflicts with the sites gray-brick background; Is there a way to automatically make all uploaded images' white background removed and added an alpha channel so there won't be such a conflict?

Note: I can do that process manually with GIMP\Photoshop but looking for a module that does that automatically.

Thanks.

# Answer
> 2 votes
I think you will need something like https://www.drupal.org/project/imagecache\_actions if this is in fact not a CSS border added to the image. I would definitely check that first but the above module does do some alpha blending and you can also run your own PHP/GD code during an image cache action so if they don't include it you can find code that does and run that code to perform the change.

You could also put a border around the image with CSS that would separate the image from the site background to solve something like that.

---
Tags: media
---


# Question
Title: How to create a custom node template in drupal8 rendering a view within a node page?
I am trying to create custom node template in **Drupal8**. I would like my users accessing "tag" node to be able to view all related content. Therefore I have already created a view presenting all content relating to given tag. Now **I want to render this view in a "tag" node page**.

Following the https://www.drupal.org/node/2165673 I have create a custom theme. I have created `themes/bartikUzbrojeni` directory with the following `bartikUzbrojeni.info.yml`:

```
name: bartikUzbrojeni
type: theme
description: Modifications to the default Bartik theme
core: 8.x
base theme: bartik

```

I have also created `templates` directory within `themes/bartikUzbrojeni` with file `node--tag.html.twig` (being generally copy of node.html.twig from bartik directory).

This seems to more or less work (modifications done within `node--tag.html.twig` are visible within the page) but I have following problems:

1. The page does not look like Bartik one (the bartik theme does not seem to be used even though I have marked it as a "base theme"). Please see screen below.
2. I don't know what is the proper way to edit `node--tag.html.twig` so that it renders a view.

# Answer
Here is how you can add the view, use a block view.

Then go to Blocks, and place a block in content.

Select your view block

In configure click on pages, then type the url of the pages you want it to show. So you put your tags url here. Use the `*` so it shows in all of them.

**Just noticed I missed a `/` at the start, so it should be `/taxonomy/term/*`**
> 1 votes

---
Tags: theming, 8
---


# Question
Title: Migration multibyte images file name issue
I have a Drupal website that I transferred it from host A to host B. I have some images uploaded with its Arabic file name, it works fine on host A, but after zipping Drupal files into a zip archieve, sending it to host B, extracting it there and finally run my website there, I found that the file names have been corrupted. the following screen shot demonstrates the issue:

What's the cause of this issue? How could I keep correct multiple byte file names correctly during zipping and unzipping?

By the way, the two hosts are Linux.

# Answer
> 1 votes
The solution is, simply, to compress the folder or files as **tar** not zip. **Tar** does not encode file names so it keeps it as it is in the filesystem. This is the **Reference**

# Answer
> 0 votes
Are the two hosts the same host? If not, its highly likely host B does not support arabic writting.

Transfer 1 arabic file, without ziping it, to prove my theory.

---
Tags: files, migrations
---


# Question
Title: How to get list of blocks for region on current page?
I have a template of my custom function and I am display certain number of items per row in this template.

For this reason I need to figure out if there are any blocks on the current page in any of the sidebars of my theme(left and right) so I can adjust the number of visible items.

So my question is **how to get the list of blocks that are displayed on the current route in certain region and their visibility conditions were already processed**?

I do not need to have exact information, ie. if some blocks have #access set to false or if they return empty render arrays are not important.

# Answer
There's a block.repository service with a getVisibleBlocksPerRegion() method. You can either use that or look at what it's doing.

This will cover access checks as well but not empty blocks.

This is however quite a bit of an overhead as all blocks are loaded and access checked twice. There is an issue to add caching there.

Alternatively, you can use preprocess of the region templates I guess.
> 0 votes

---
Tags: 8, theming
---


title: db_query and condition in custom field

text:
# Question
Title: db_query and condition in custom field
on my website, i have articles. All of them have custom field named event date. I want to select 50 nodes of type article with event date value "2016-07-29 16:25:00". How to do this?

I tried following code, but it looks like query cannot find any custom field column.

```
$nids = db_select('node', 'n')
->fields('n', array('nid'))
->fields('n', array('type'))
->fields('n', array('field_event_date'))
->condition('n.type', 'article')
->condition('n.field_event_date', "2016-07-29 16:25:00")
->range(0, 50)
->execute()
->fetchCol();

```

# Answer
You cannot find any custom fields because fields created using the field API are not stored in the *node* table, but in a different table. In code, you should use the `EntityFieldQuery` class.

```
  $query = new EntityFieldQuery();
  $entities = $query->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'article')
    ->propertyCondition('status', 1)
    ->fieldCondition('field_event_date', 'value', '2016-07-29 16:25:00')
    ->fieldOrderBy('field_event_date', 'value', 'ASC')
                    ->execute();

  $nodes = node_load_multiple(array_keys($entities['node']));

```
> 1 votes

# Answer
You could use the Views module which wouldn't require you to do any coding to achieve this.

* Enable views
* Ebale views UI

**Add a new view** and select **Create a Block**

in **FIELDS** add all the fields you want

in **FILTER CRITERIA** **add your event date field**

Go to Blocks `/admin/structure/block`

* Under **Disabled** look for your View Block, click configure.
* Assign your block a region and in Visibility settings you may want to only show it in certain pages.
> 0 votes

---
Tags: nodes, entities
---


title: How do I render a field template?

text:
# Question
Title: How do I render a field template?
I have problems with rendering twig templates inside my block theme. Is it possible to display default template for a field that I've fetched with entity manage query?

I've got a custom carousel slider module which uses 'Banner' node type. It has a banner image, link URI fields. Everything works fine, but I would like to display the responsive image template instead of building my own HTML.

Here's how I do it right now.

```
<div id="Carousel" class="glide">
    <div class="glide__arrows">
        <span class="glide__arrow prev" data-glide-dir="<"><</span>
        <span class="glide__arrow next" data-glide-dir=">">></span>
    </div>

    <div class="glide__wrapper">
        <ul class="glide__track">
            {% for item in baners %}
                <li class="glide__slide">
                    <div class="box">
                        <img src="{{ file_url(item.field_baner.0.entity.uri.value)}}" alt="{{ item.field_baner.alt}}" />
                        <div class="box2">
                        {% if item.field_url.uri %}
                            <h2>
                                <a href="{{ item.field_url.uri }}">
                                    {% if (item.field_description.value) %}
                                        {{ item.field_description.value }}
                                    {% endif %}
                                    {% if (item.field_url.title) %}
                                        <br /><span class="goto">{{ item.field_url.title }} ></span>
                                    {% endif %}
                                </a>
                            </h2>
                        {% endif %}
                        </div>
                    </div>
                </li>
            {% endfor %}
        </ul>
    </div>
    <div class="glide__bullets"></div>
</div>

```

I am fetching banners this way.

```
$storage = \Drupal::entityManager()->getStorage('node');
$nids = $storage->getQuery()
    ->condition('type', 'baner')
    ->condition('status', 1)
    ->execute();
return $storage->loadMultiple($nids);

```

What I would like is to find a way to display a responsive image, such as in the following way.

```
{{ responsive_image(item.field_baner) }}

```

Or render them in module class so I could display them in my template.

```
$banerBuildParams = [
      '#theme' => 'responsive_image',
      '#width' => $variables['width'],
      '#height' => $variables['height'],
      '#responsive_image_style_id' => $variables['responsive_image_style_id'],
      '#uri' => $variables['uri'],
  ];
  //render template
  $template = $this->getTemplate($banerBuildParams);

```

**\[edit\]**

I think I've found a solution to render all the view I can use this code to pretender nodes (not sure it's the best approach to the problem):

```
node_view($baner, 'teaser');

```

The problem I've still got is that I use external jquery library which requires some specific html formatting which not comply with the default generated tags. Maybe somebody more experienced with Drupal could suggest something? I know I can create my own plugin for field type. It seems a lot trouble for just one not reusable element. What if I need to group two fields in specific DIV and some others in different one? Using node\_view I am loosing the way my code looks like:/

# Answer
In general, you don't access templates directly as an API, you build render arrays. To get the render array of a field, each field item and item list class has a `view` method. That method accepts either the name of a view mode and uses that configuration or you can also directly pass in the configuration you want to use (Basically the array that you have in view display config entities for each component).

You can try calling that from twig directly, e.g. {{ item.view('teaser') }} or prepare it in preprocess of your template.
> 0 votes

---
Tags: blocks, 8, theming
---


# Question
Title: How to import image using Feeds which doesn't have a correct file extension?
I am using Drupal 7 and Feeds to import an image field into a content type article and it does work when the image URL is a direct link to the image.

However images that are linked to image handlers, like:

> http://business.iafrica.com/apps/imageUtil/view/article/1008937/1/630x385/

are not importing.

I have tried:

* to use the *Feeds Tamper* module and *Feeds Tamper PHP* and alter the image name, but this resulted in an invalid URL loading,
* to use *Field Image Grabber*, but I have an XML source, not HTML.

Here is my *source feed URL*:

> http://resource.thumbtribe.mobi/ds1.portal/portal/1/4/resource/view/maximized/9500187?format=atom\_extern

and my *Image: URI XPath* mapping is:

```
string(link[@rel="enclosure"]/@href)

```

# Answer
I managed to solve this by using the feeds tamper module with the following php snippet to save the image and then reference the path on my server.

```
$checkext = substr($field, -5);

if (strpos($checkext,'.') == false)
{
  $filename = str_replace(".","_",microtime(true)).".jpg";
  $output = "public://field/image/".$filename;
  file_put_contents($output, file_get_contents($field));
  return  $output;
}
else
{
  return $field;
}

```
> 1 votes

# Answer
The problem is that current version of Feeds gets the filename from the URL (last part separated by `/` without anything after `?`) where the logic is basically (in *FeedsParser.inc*):

```
// Strip any query string or fragment from file name.
list($filename) = explode('?', $this->getValue());
list($filename) = explode('#', $filename);
$filename = rawurldecode(drupal_basename($filename));

```

so it doesn't detect the extension automatically.

So the solution is to patch Feeds by fetching the file name either from headers (*Content Disposition*, check this patch) or based on its mime type:

```
$filename = $this->getLocalValue();
$filemime = file_get_mimetype($filename);

if ($filemime != $this->mime_type) {
  include_once DRUPAL_ROOT . "/includes/file.mimetypes.inc";
  $mapping = file_mimetype_mapping();
  if ($ext_id = array_search($this->mime_type, $mapping["mimetypes"])) {
    $extensions = array_keys($mapping["extensions"], $ext_id);
    foreach ($extensions as $extension) {
      if (in_array($extension, explode(' ', $this->allowedExtensions), TRUE)) {
        $filename .= ".$extension";
        break;
      }
    }
  }
}

```

Please check the following Drupal issues which have appropriate patches fixing it:

which should be included soon into Feeds.

---

Alternative solution could be to rename the file before it gets saved.
> 0 votes

---
Tags: media, feeds, files
---


title: how to use intersection in a db_query?

text:
# Question
Title: how to use intersection in a db_query?
i want to select elements that exist on table\_A and not in table\_b, in other words, how to make the sql "intersect" in a drupal select query please ?

# Answer
> 0 votes
I've got it, just using :

```
$check = db_query("SELECT DISTINCT A.something FROM {table_A} as A
    where something not in (
    SELECT  B.something FROM {table_B} as B)
    ")->fetchField();

```

---
Tags: database
---


# Question
Title: Timefield [entityform:field-name:value_formatted] token not working in Rules
I am having troubles using token replacement for the `Time field` field type provided by the module Timefield in Rules.

The **token pattern** `[entityform:field-name:value]` works just fine (it gets replaced by the raw "offset value" of the field - I'm using this field in an Entityform), but I just can't figure out how to display the **formatted value**.

I've followed directions in the pattern replacement help text, and tried different combinations of hyphens and low hyphens to no avail: `[entityform:field-name:value_formatted]`, `[entityform:field_name:value_formatted]` and `[entityform:field-name:value-formatted]` \- none work.

I've already posted a request for support in the Timefield issue queue, but was wondering if anyone here has had a similar issue, and can point me in the right direction? Thank you in advance.

**EDIT:** After some additional testing, I've discovered that the `[entityform:field_name:value_formatted]` token DOES work in some situations, such as inside a Rules **Component**. It does NOT work if the Rule is triggered by the event `After saving new content`(for nodes) or `After saving a new entityform submission` (for Entityforms). Obviously this seems to be a bug, but I don't have the time to figure out where this problem happens. Apparently the `value` token of the field is built right away, but the `value_formatted` is not readily available when the Rule is triggered right after creating a new entity. Any thoughts?

# Answer
> 0 votes
Since this problem seems to be a bug, and just in case someone else runs into this issue, there is a workaround you can do within Rules to get the formatted value of the time field. It involves:

1. Enable the module **PHP filter**
2. Use the action `Execute custom PHP code` to run a PHP snippet that calculates the formatted value using the raw value provided by the token

---
Tags: 7, entities, tokens
---


# Question
Title: Different Terms&Conditions on multi-site
I use Legal module to display terms & conditions to the user, but now I need to create different T&C text for different sites created with Domain Access. Is it possible?

# Answer
In Drupal 7 Domain Variable module will help you, in Drupal 6 this is not supported probably.

**Domain Variable:**

> This module aims to be a replacement variable handling module for Domain Access, allowing mixed variable realms (domain x language) to be configured.
>
> In other words, it allows setting different variable values for each domain and for each language at the same time.
>
> This module supports almost all of the functionality provided by Domain Configuration, Domain Settings and Domain Theme. Differences are listed in the documentation.
> 1 votes

---
Tags: multi-sites, domain-access
---


# Question
Title: Hide user fields on profile2 registration form
I am working on multi-user website with 3 roles in Drupal 7 website. I'm using profile2 module for custom fields for different users, also profile2 path for profile/user registration.

Problem came up with Location module because I need 3 different location cck (different fields from location cck are allowed) fields from every user/profile role. I got stuck with this more than 2 months. It would be nice that I can use Profile2 and Location cck but it's not possible because Views module does not extract different Location fields for my Profile2 CCK fields in different profiles (for example I need only phone or city field from location in some view).

The only way to achieve this (so far) is to make 3 location cck fields in user account fields and with field permission module grant privileges for specific roles.

But! I need to expose that location fields on profile2 registration paths with all other fields from specific profile and they need to be required.

Is there a way to hide location cck fields on the registration form based on user type (buyer, seller, etc)?

# Answer
to hide and show fields on user registration form while using Profile2 path - try the following in hook\_form\_alter in template.php.

```
if ($form_id == 'user_register_form') {

// get current path
$request_path = request_path();

// check if current path corresponds to your registration form for a particular role
if (strpos($request_path,'buyer') !== false) {

// removes the field that should be hidden
$form['field_1']['und'][0]['value']['#access'] = FALSE;

// or
unset($form['field_1']['und'][0]['value']);

// set the state of the field to required
 $form['field_2']['und'][0]['value']['#required'] = TRUE;

}
}

```

simple warning - you may find that Location module fields that utilize ajax (same goes for Address Field module) have a bug that breaks the user reg. form produced by Profile2 Path if it is submitted with errors and exposes fields hidden with method described above. Look for insight in this issue (https://www.drupal.org/node/2558335).
> 1 votes

---
Tags: 7, users, location
---


title: Php block messing with the page tittle

text:
# Question
Title: Php block messing with the page tittle
I've added the privatemsg module send message form in a php block, it's working fine but the page tittle and the metatag tittle now shows "write a new message to(user uid)" instead of the node tittle.

this is the code in the php block:

```
`<?php
 module_load_include('pages.inc','privatemsg');
 $node = node_load(arg(1));
 $recipients = strip_tags($node->uid);
 $subject = 'custom subject';
 print '<div class="custom-msg">';
 print drupal_render(drupal_get_form('privatemsg_new', recipients,
 $subject));
 print "</div>";`

```

I can't figure out why this could be happening, i'm new to Drupal.

Thank you.

**UPDATE**

I've created a custom module as @burnsjeremy suggested, it works but the same error is happening. Check the comment line in the code.

```
<?php
module_load_include('pages.inc','privatemsg');
function seb_privatemsg_block_info(){
    $block['seb_msg'] = array(
       'info' => t('Seb Private Msg'),
       'cache' => DRUPAL_NO_CACHE
    );
    return $block;
}
/**
* Implements hook_block_view().
*/
function seb_privatemsg_block_view($delta = '') {
    $block = array();
    $block['subject'] = '';
    $block['content'] = seb_privatemsg_content();
    return $block;
}
function seb_privatemsg_content() {
    $node = node_load(arg(1));
    $recipient = strip_tags($node->uid);
    $subject = 'custom subject';
    $output = '';
    // if i comment the following line the title is correct
    $output .= drupal_render(drupal_get_form('privatemsg_new', $recipient, $subject));
    return $output;
}

```

Any help would be greatly appreciated.

# Answer
> 0 votes
So I found an issue about this in the privatemsg issue queue, basically they are overwriting the page title when the form is embedded like this. So you need to use the code below to save the title before the form call and then set the title back to the saved one afterwards.

```
// Save the title.
$stored_title = drupal_set_title();
// Call the form.
print drupal_render(drupal_get_form('privatemsg_new', $recipients, $subject));
// Set title back to the saved version.
drupal_set_title($stored_title);

```

Here is the link to the issue if you want to do more research: https://www.drupal.org/node/1621198

---
Tags: blocks, privatemsg
---


# Question
Title: How do I change position of a "fixed" element/header to go below Admin toolbar when in Admin view?
*New to JS / CSS*

How do I change / control the position of a sticky navigation bar to go below Admin toolbar when in Admin mode?

Site uses:

1. Subtheme of Omega / Commerce Kickstart
2. Through subtheming, I have two sticky "zones": (1) user (contains login/checkout); (2) menu-super (main menu)
3. User zone is sticky and came as part of the Commerce Kickstart theme and works in both regular user and admin mode.
4. My new "Menu-Super" works in regular user mode, but disappears behind the admin toolbar when viewing as an admin. (less than ideal.)

In the js file, I found the following:

`// Handle user toolbar when user is admin and have admin toolbar enabled.
 Drupal.behaviors.commerce_kickstart_theme_custom_toolbar = {
 attach: function(context, settings) {
 if ($('body').hasClass('toolbar')) {
 $(window, context).resize(function() {
 var toolbarHeight = $('div#toolbar').height();
 $('.zone-user-wrapper').css('top', toolbarHeight + 'px');
 });
 }
 }
 }`

I tried repurposing this code to handle my new zone, but no dice. When I clear cache, I can see the zone built and then pop up under the admin bar. What am I missing here?

`Drupal.behaviors.commerce_kickstart_theme_custom_toolbar = {
 attach: function(context, settings) {
 if ($('body').hasClass('toolbar')) {
 $(window, context).resize(function() {
 var toolbarHeight = $('div#toolbar').height();
 var zoneuserHeight = $('div#toolbar').height()+ $('div#zone-user').height();
 $('.zone-menu-super-wrapper').css('top', zoneuserHeight + 'px');
 });
 }
 }
 }`

where the css file specifies

User Zone (Working)

`.zone-user-wrapper {
 background-color: #666666;
 height: 32px;
 width: 100%; }`

Super Menu Zone (Not working)

`.zone-menu-super-wrapper {
 background-color: #9E4934; /*Monkey brown*/
 height: 36px;
 width: 100%;
 position: fixed;
 top: 32px;
 z-index: 99;}`

# Answer
**In drupal you need to use jquery like this**

```
(function ($) {
 $( document ).ready(function() {

      // custom code here

     });
  });
}(jQuery));

```

**So try**:

```
(function ($) {
  $( document ).ready(function() {
      Drupal.behaviors.commerce_kickstart_theme_custom_toolbar = {
        attach: function(context, settings) {
          if ($('body').hasClass('toolbar')) {
            $(window, context).resize(function() {
              var toolbarHeight = $('div#toolbar').height();
              $('.zone-user-wrapper').css('top', toolbarHeight + 'px');
            });
          }
        }
      }
    });
  });
}(jQuery));

```

If that doesn't work, all you have to do is check if the toolbar div class or id exists.

```
if ($('#toolbar').length > 0) {
    // dostuff
}

```

So if there is a wrapper that wraps everything on your site **except** the admin toolbar. that would be more ideal to use. So all you do is move everything down by 10 or so pixels

Using CSS with jQuery

```
(function ($) {
 $( document ).ready(function() {
          if ($('#toolbar').length > 0) {
           $('.zone-user-wrapper').css({"position": "relative", "top": "10px"})
           }
     });
  });
}(jQuery));

```
> 0 votes

# Answer
> The new js I added is within the function callout with the other code that came with Kickstart. The js code that I provided for 'zone-user-wrapper' works. I created a second zone / region ("menu-super") that sits below the "user" zone and want it to be handled in the same way. When I try to add identical code for the second zone, nothing happens.

highlight the second zone / region and right mouse click and select inspect element. double check that the div wrapper is indeed `.zone-menu-super-wrapper` perhaps you have the wrong name?

**you don't need 2 separate codes** just add the

```
var zoneuserHeight = $('div#toolbar').height()+ $('div#zone-user').height();

```

and

```
 $('.zone-menu-super-wrapper').css('top', zoneuserHeight + 'px');

```

lines to your first code

```
   Drupal.behaviors.commerce_kickstart_theme_custom_toolbar = {
        attach: function(context, settings) {
          if ($('body').hasClass('toolbar')) {
            $(window, context).resize(function() {
              var toolbarHeight = $('div#toolbar').height();
              var zoneuserHeight = $('div#toolbar').height() + $('div#zone-user').height();
              $('.zone-user-wrapper').css('top', toolbarHeight + 'px');
              $('.zone-menu-super-wrapper').css('top', zoneuserHeight + 'px');
            });
          }
        }
      }

```

Also, make sure that your `.zone-menu-super-wrapper` has `position: relative;` or `position: absolute;` otherwise the `top: zoneuserHeight` won't work.

Example: Does Not Work
Example: Works

**PS:**

perhaps this line

```
var zoneuserHeight = $('div#toolbar').height() + $('div#zone-user').height();

```

needs to be

```
var zoneuserHeight = $('div#toolbar').height() + $('div#zone-user-wrapper').height();

```
> 0 votes

---
Tags: commerce, javascript, theming
---


title: Quick Edit setup and usage

text:
# Question
Title: Quick Edit setup and usage
I added quick edit to my site. Made sure all the correct libraries are in place and see the **quick edit** button in the gear next to the content, but am not getting any way to save the changes.

The screenshot shows what I see when I click in the content area.

I have CKEditor in place. Have tried CDN and Libraries version without success.

Is there a certain type of field or class I need to add to fields?

# Answer
> 0 votes
Looking at the errors you are reporting, it seems that you haven't downloaded the actual javascript ckeditor library.

You can do it manually, as described in http://docs.cksource.com/CKEditor\_for\_Drupal/Open\_Source/Drupal\_7/Installation.

or you can script it (update the version if needed):

```
wget http://download.cksource.com/CKEditor/CKEditor/CKEditor%204.5.4/ckeditor_4.5.4_standard.zip
unzip ckeditor_4.5.4_standard.zip
mv ckeditor $SITENAME/sites/all/libraries
rm ckeditor_4.5.4_standard.zip

```

---
Tags: 7, nodes
---


# Question
Title: How to back up one site and restore to different site
I have follow the below steps to back up source and then restore to target site.

1) On the source server, upload the backup and migrate module

2) On the source server, take a backup of the database using the B&M module

3) Copy all the site files - Drupal core, modules, themes, and your files folder, and migrate them to the target server in the exact same folder structure as the source server.

4) After migrating all the files to the target server, delete settings.php, and make a copy default.settings.php called settings.php

5) Install Drupal as a new installation on the target server

6) Enable the backup and migrate module on the target server

7) Use the B&M module to import the database backup you took in step 2

8) Clear the cache.

9) Run cron

10) Ran Update.php

Problem: My target site is not updated. When I go to admin\>find content, I dont see any content there.

I accessed the target site database and noticed that total of 9,970 records exist.

Do you know why target site is not being updated even though database has records?

---

Update #1

1) Source site database has 165 tables and target database has 243 tables after I complete the above steps.

2) In target database, Checked all tables \> selected Empty \> now target site has 0 records but all the tables exist.

3) In source database, I exported the database.

4) In target database, I imported the database. I get this error:

> Error SQL query:
>
> -- -- Dumping data for table `drup_block` -- INSERT INTO `drup_block` (`bid`, `module`, `delta`, `theme`, `status`, `weight`, `region`, `custom`, `visibility`, `pages`, `title`, `cache`, `css_class`) VALUES (1, 'system', 'main', 'bartik', 1, 0, 'content', 0, 0, '', '', -1, ''), (2, 'search', 'form', 'bartik', 1, -1, 'sidebar\_first', 0, 0, '', '', -1, ''), (3, 'node', 'recent', 'seven', 1, 10, 'dashboard\_main', 0, 0, '', '', -1, ''), (4, 'user', 'login', 'bartik', 1, 0, 'sidebar\_first', 0, 0, '', '', -1, ''), (5, 'system', 'navigation', 'bartik', 1, 0, 'sidebar\_first', 0, 0, '', '', -1, ''), (6, 'system', 'powered-by', 'bartik', 1, 10, 'footer', 0, 0, '', '', -1, ''), (7, 'system', 'help', 'bartik', 1, 0, 'help', 0, 0, '', '', -1, ''), (8, 'system', 'main', 'seven', 1, 0, 'content', 0, 0, '', '', -1, ''), (9, 'system', 'help', 'seven', 1, 0, 'help', 0, 0, '', '', -1, ''), (10, 'user', 'login', 'seven', 1, 10, 'content', 0, 0, '', '', -1, ''), (11, 'user', 'new', 'seven', 1, 0, 'dashb\[...\]
>
> MySQL said: Documentation
>
> # 1054 - Unknown column 'css\_class' in 'field list'

5. When I refreshed my page, I get this:

> fatal error: Class 'SelectQueryExtender' not found in /home/content/48/8466248/html/godrupal/includes/pager.inc on line 15

Now, I can not access my site because of the error in #5.

---

Update #2

1) In target site, I created a new database.

2) In target site, I imported the database from source. I got same number of tables (165 each).

3) In target site, I updated the settings.php as below:

```
$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'xxx',
      'username' => 'xxx',
      'password' => 'ppp',
      'host' => 'xxxxxxx',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

```

Note- That is only thing I have updated in settings.php.

4) When I go to front page, I get the below error. Also I can not access the site.

```
Error

The website encountered an unexpected error. Please try again later.
Error messagePDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'xxx.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/content/48/8466248/html/xxx/includes/lock.inc).
Uncaught exception thrown in shutdown function.
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'xxx.semaphore' doesn't exist: DELETE FROM {semaphore} WHERE (value = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => 1416485260563fafa04406f8.10064213 ) in lock_release_all() (line 269 of /home/content/48/8466248/html/xxx/includes/lock.inc).

```

---

Solution

When I installed drupal at source site in my cheaper domain server, I saw 'prefix' =\> 'drup\_' in settings.php. When I installed drupal at target site in go daddy server, I saw 'prefix' =\> '' in settings.php. I simply updated the settings.php file in target site (added `drup_` prefix). I dropped all tables from target site and then re-imported the database. Now, I am able to see both sites identical. Source site. Target site.

# Answer
> 1 votes
**It's important that you empty the database (by droping all the tables: Check all \> Drop) and start all over again. You basically have 2 drupal databases one with drup\_ prefix and the other one with out it.**

**Then go to `yourwebsite.com/install.php`**

**In the install there is a prefix field, you need to put `drup` in that field.**

# Answer
> 1 votes
Looks like your source database used a table prefix `drup`. That's why your target installation looks empty.

Adjust the database-config in your settings.php

---
Tags: backups
---


# Question
Title: How to Display "Tabbed" content from Views in Panel / Pane in Node Template
I would like to add a pane with tabbed content to a specific content type/Product display.

Using the guidance provided on drupal.org/node/2209747, I built a series of tabbed content in Views, using "Menu Tab" and creating new pages. (No problem, but not where I want to display the views.)

My goal is to embed this tabbed content into a pane (in Panels Node Template). However, when I select the view, I am required to specify either "Master", "Page 1", "Topic A", or "Topic B".

These options remove the tabs and either show all content (Master/Page 1) or filter content (Topic A or Topic B).

1. Is there a way to embed the tabbed view using only the Views module?
2. Should I create a Content Pane, instead of a page?
3. Can I avoid using an additional module like Quicktabs?

I assume that I am running into trouble because the tabbed view depends on the url path differentiation and cannot work when dropped into a pane. (At least with my current approach.)

Any help is appreciated! keb

# Answer
In the end, I used the "Panel Tabs" module. It is available in dev version, which gave me pause, but it works well on the main platforms (Chrome / iE / Firefox); I haven't played around on Safari.

With a little css, this will be a good working solution, but I would be interested to know if others have a more standard approach.

Thanks, keb
> 0 votes

---
Tags: views, routes, panels
---


# Question
Title: How do I set "Add to Cart form" css globally using Commerce Kickstart as basis?
My goal is to borrow the Add to Cart form style from Commerce Kickstart on a site where:

1. Panels: Node Templates controls the Product Displays
2. Subtheme of Commerce Kickstart sets the CSS / template

Questions:

* How do I find the CSS controlling the standard Commerce Kickstart Add to Cart form?
* How do I use that CSS to control all "Add to Cart" widgets on the site?
* Do I need to call out each Product Display type? Or is there a way to call it globally?
* Related question: Why is the parent theme CSS being called? (There seems to be two levels of the Commerce Kickstart theme. One in `.../themes/contrib` and one in `.../themes/commerce_kickstart_theme` What's the difference? Are there two to share between the admin theme and site theme?

I am new to css, so am using "Inspect Element" to figure out how styles are applying to a given item. However, I can't figure out how to repurpose the css from Commerce Kickstart to apply to all "Add to Cart" widgets that are sprinkled throughout the site and control on a product-type basis through several Panels: Node Templates.

\**These css callouts seem to be coming from the Kickstart theme, instead of the subtheme. I have enabled the subtheme and see changes I am making in the subtheme work, so I'm lost on why it is calling from the parent theme. `.../profiles/commerce_kickstart/themes/contrib/omega_kickstart/css/omega-kickstart-alpha-default-normal.css`

From Inspect Element, I see that Commerce Kickstart shows:

For the attribute label:

```
.node-product-type .field-name-field-product form.commerce-add-to-cart label {
    float: left;
}

```

For the attribute drop-down:

```
element.style {
    width: 44.7778px;
    margin-right: 17px;
    text-align: right;
}

```

# Answer
> 0 votes
My solution is not elegant, but it got the job done:

1. Using inspect element, identified css that dictating styling of the "Add to Cart" form elements that I wanted to keep. This css was buried in the subtheme\_style.css file associated with "Product" only: `.node-product-type`.
2. Copied css to start of subtheme\_style.css file
3. Removed the references to `.node-product-type`. This set all the select widget fields and all the "Add to cart" buttons to the desired style/look.

This seems like an odd way to go, but also means that I don't have to differentiate among all product display types, as I build out panel displays that are unique to each one. What would you have done differently?

This is the css that I repurposed and generalized by deleting the reference to `.node-product-type`:

`.field-name-field-product form.commerce-add-to-cart label {
 float: left;
 margin-right: 5px;
 width: 45%;}`

`.field-type-commerce-product-reference form.commerce-add-to-cart .form-submit {
 background-color: #9E4934; /*CG Add to Cart button*/
 background-image: url("../images/bg_add_to_cart.png");
 background-position: 90% 50%;
 /* LTR */
 background-repeat: no-repeat;
 border: 0;
 -moz-border-radius: 8px;
 -webkit-border-radius: 8px;
 -khtml-border-radius: 8px;
 border-radius: 8px;
 color: #ffffff;
 font-family: "Open Sans", sans-serif;
 font-size: 17px;
 font-weight: 400;
 float: right;
 margin-top: 40px;
 margin-left: 5px;
 /* LTR */
 padding: 5px 50px 5px 10px;
 /* LTR */ }`

`.field-type-commerce-product-reference form.commerce-add-to-cart .form-submit:hover {
 cursor: pointer; }`

---
Tags: theming, commerce
---


title: Creating a Time Elapsed Field

text:
# Question
Title: Creating a Time Elapsed Field
Simple way to calculate the time from the nodes creation to now?

A lot of the time based modules don't seem to do this. (duration, time period, date, interval field, etc.)

Would Rules Scheduler be the best solution and have it react when a node is viewed?

# Answer
> 2 votes
> Would Rules Scheduler be the best solution and have it react when a node is viewed?

**No, that's the worst way to do it.**

All you need is jQuery to do it.

Lucky for you, there is a module that does this already, the Timeago module. Some more details from its project page:

> Uses the jQuery timeago plugin to create dynamically updating "time ago" dates. That is, the plugin turns static dates like "October 10, 2011" into "10 minutes ago" and updates the time ago every minute. This allows you to include "time ago" dates in cached content for most users while degrading gracefully for users with JavaScript disabled.

**PS**: In your Content Type, when you create the time field, you need to select Timeago as your format instead of Date.

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


# Question
Title: Attach a webform into faq module content
I'm looking for a FAQ module where users can answer the "Did you find this answer useful? Yes-No" after reading help and I need a page where operators can check all responses.

Any idea?

# Answer
> 1 votes
https://www.drupal.org/project/faq

> The Frequently Asked Questions (faq) module allows users, with appropriate permissions, to create question and answer pairs which they want displayed on the 'faq' page. The 'faq' page is automatically generated from the FAQ nodes configured. Basic Views layouts are also provided and can be customised via the Views UI (rather than via the module settings page)

.

---
Tags: 7
---


# Question
Title: Long Ajax error using Date module Views and Fullcalendar
I have searched for many posts and i am already doing the suggestions. Nothing is fixing this.

Fullcalendar module says to use the "use ajax" option within views but it throws a huge error.

> Notice: Undefined index: date in date\_text\_element\_process() (line 322 of /var/www/html/drupal/sites/all/modules/date/date\_api/date\_api\_elements.inc).
>
> \[{"command":"settings","settings":{"basePath":"/","pathPrefix":"","ajaxPageState":{"theme":"seven","theme\_token":"M0zPUqa2WJ22nPMH1OUnLDQwPXU0b8nwseud8PJfMbg","jquery\_version":"1.7"},"urlIsAjaxTrusted":{"/admin/structure/views/ajax/display/event\_calendar/page/use\_ajax":true}},"merge":true},{"command":"viewsDismissForm"},{"command":"viewsShowButtons","changed":true},{"command":"viewsTriggerPreview"},{"command":"insert","method":"html","selector":"#views-tab-page","data":"\u003Cdiv id=\u0022edit-display-settings-details\u0022\u003E\u003Cdiv id=\u0022edit-display-settings-top\u0022 class=\u0022views-ui-display-tab-actions views-ui-display-tab-bucket clearfix\u0022\u003E\u003Cdiv class=\u0022ctools-no-js ctools-button ctools-dropbutton\u0022\u003E\u003Cdiv class=\u0022ctools-link\u0022\u003E\u003Ca href=\u0022#\u0022 class=\u0022ctools-twisty ctools-text\u0022\u003Eopen\u003C/a\u003E\u003C/div\u003E\u003Cdiv class=\u0022ctools-content\u0022\u003E\u003Cul class=\u0022horizontal right actions\u0022\u003E\u003Cli class=\u0022duplicate\u0022\u003E\u003Cinput type=\u0022submit\u0022 name=\u0022op\u0022 value=\u0022clone Artist Show Schedule Page\u0022 class=\u0022form-submit\u0022 /\u003E\u003C/li\u003E\u003Cli class=\u0022delete\u0022\u003E\u003Cinput type=\u0022submit\u0022 name=\u0022op\u0022 value=\u0022delete Artist Show Schedule Page\u0022 class=\u0022form-submit\u0022 /\u003E\u003C/li\u003E\u003Cli class=\u0022disable\u0022\u003E\u003Cinput type=\u0022submit\u0022 name=\u0022op\u0022 value=\u0022disable Artist Show Schedule Page\u0022 class=\u0022form-submit\u0022 /\u003E\u003C/li\u003E\u003C/ul\u003E\u003C/div\u003E\u003C/div\u003E\u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting odd clearfix\u0022 \u003E\n \u003Cspan class=\u0022label\u0022\u003EDisplay name:\u003C/span\u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/display\_title\u0022 class=\u0022views-ajax-link \u0022 title=\u0022Artist Show Schedule Page\u0022 id=\u0022views-page-display-title\u0022\u003EArtist Show Schedule Page\u003C/a\u003E \u003C/div\u003E\n\u003C/div\u003E\u003Cdiv id=\u0022edit-display-settings-main\u0022 class=\u0022clearfix views-display-columns\u0022\u003E\u003Cdiv class=\u0022views-display-column first\u0022\u003E\u003Cdiv class=\u0022views-ui-display-tab-bucket title\u0022 \u003E\n \u003Ch3\u003ETitle\u003C/h3\u003E\n \u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting overridden even clearfix\u0022 title=\u0022Overridden\u0022\u003E\n \u003Cspan class=\u0022label\u0022\u003ETitle:\u003C/span\u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/title\u0022 class=\u0022views-ajax-link \u0022 title=\u0022Change the title that this display will use.\u0022 id=\u0022views-page-title\u0022\u003EShow Schedule\u003C/a\u003E \u003C/div\u003E\n\u003C/div\u003E\n\u003Cdiv class=\u0022views-ui-display-tab-bucket format\u0022 \u003E\n \u003Ch3\u003EFormat\u003C/h3\u003E\n \u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting overridden odd clearfix\u0022 title=\u0022Overridden\u0022\u003E\n \u003Cspan class=\u0022label\u0022\u003EFormat:\u003C/span\u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/style\_plugin\u0022 class=\u0022views-ajax-link \u0022 title=\u0022Change the way content is formatted.\u0022 id=\u0022views-page-style-plugin\u0022\u003EFullCalendar\u003C/a\u003E\u003Cspan class=\u0022label\u0022\u003E\u0026nbsp;|\u0026nbsp;\u003C/span\u003E\u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/style\_options\u0022 class=\u0022views-ajax-link views-button-configure\u0022 title=\u0022Change settings for this format\u0022 id=\u0022views-page-style-options\u0022\u003E\u003Cspan\u003ESettings\u003C/span\u003E\u003C/a\u003E \u003C/div\u003E\n\u003C/div\u003E\n\u003Cdiv class=\u0022views-ui-display-tab-bucket fields overridden\u0022 title=\u0022Overridden\u0022\u003E\n \u003Cdiv class=\u0022ctools-no-js ctools-dropbutton ctools-button views-ui-settings-bucket-operations\u0022 id=\u0022ctools-button-1\u0022\u003E\u003Cdiv class=\u0022ctools-link\u0022\u003E\u003Ca href=\u0022#\u0022 class=\u0022ctools-twisty ctools-text\u0022\u003Eopen\u003C/a\u003E\u003C/div\u003E\u003Cdiv class=\u0022ctools-content\u0022\u003E\u003Cul class=\u0022actions horizontal right\u0022\u003E\u003Cli class=\u0022add first\u0022\u003E\u003Ca href=\u0022/admin/structure/views/nojs/add-item/event\_calendar/page/field\u0022 class=\u0022icon compact add views-ajax-link\u0022 title=\u0022Add\u0022 id=\u0022views-add-field\u0022\u003EAdd\u003C/a\u003E\u003C/li\u003E\n\u003Cli class=\u0022rearrange last\u0022\u003E\u003Ca href=\u0022/admin/structure/views/nojs/rearrange/event\_calendar/page/field\u0022 class=\u0022icon compact rearrange views-ajax-link\u0022 title=\u0022Rearrange\u0022 id=\u0022views-rearrange-field\u0022\u003ERearrange\u003C/a\u003E\u003C/li\u003E\n\u003C/ul\u003E\u003C/div\u003E\u003C/div\u003E \u003Ch3\u003EFields\u003C/h3\u003E\n \u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting page-field-title even clearfix\u0022 \u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/config-item/event\_calendar/page/field/title\u0022 class=\u0022views-ajax-link\u0022\u003EContent: Title\u003C/a\u003E \u003C/div\u003E\n\u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting page-field-field-event-date odd clearfix\u0022 \u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/config-item/event\_calendar/page/field/field\_event\_date\u0022 class=\u0022views-ajax-link\u0022\u003EContent: Event Date\u003C/a\u003E \u003C/div\u003E\n\u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting page-field-field-event-description even clearfix\u0022 \u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/config-item/event\_calendar/page/field/field\_event\_description\u0022 class=\u0022views-ajax-link\u0022\u003EContent: Event Description\u003C/a\u003E \u003C/div\u003E\n\u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting page-field-field-where odd clearfix\u0022 \u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/config-item/event\_calendar/page/field/field\_where\u0022 class=\u0022views-ajax-link\u0022\u003EContent: Where\u003C/a\u003E \u003C/div\u003E\n\u003C/div\u003E\n\u003Cdiv class=\u0022views-ui-display-tab-bucket filter-criteria\u0022 \u003E\n \u003Cdiv class=\u0022ctools-no-js ctools-dropbutton ctools-button views-ui-settings-bucket-operations\u0022 id=\u0022ctools-button-2\u0022\u003E\u003Cdiv class=\u0022ctools-link\u0022\u003E\u003Ca href=\u0022#\u0022 class=\u0022ctools-twisty ctools-text\u0022\u003Eopen\u003C/a\u003E\u003C/div\u003E\u003Cdiv class=\u0022ctools-content\u0022\u003E\u003Cul class=\u0022actions horizontal right\u0022\u003E\u003Cli class=\u0022add first\u0022\u003E\u003Ca href=\u0022/admin/structure/views/nojs/add-item/event\_calendar/page/filter\u0022 class=\u0022icon compact add views-ajax-link\u0022 title=\u0022Add\u0022 id=\u0022views-add-filter\u0022\u003EAdd\u003C/a\u003E\u003C/li\u003E\n\u003Cli class=\u0022rearrange last\u0022\u003E\u003Ca href=\u0022/admin/structure/views/nojs/rearrange-filter/event\_calendar/page/filter\u0022 class=\u0022icon compact rearrange views-ajax-link\u0022 title=\u0022Rearrange\u0022 id=\u0022views-rearrange-filter\u0022\u003EAnd/Or, Rearrange\u003C/a\u003E\u003C/li\u003E\n\u003C/ul\u003E\u003C/div\u003E\u003C/div\u003E \u003Ch3\u003EFilter criteria\u003C/h3\u003E\n \u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting page-filter-status even clearfix\u0022 \u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/config-item/event\_calendar/page/filter/status\u0022 class=\u0022views-ajax-link\u0022\u003EContent: Published (Yes)\u003C/a\u003E \u003C/div\u003E\n\u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting page-filter-type odd clearfix\u0022 \u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/config-item/event\_calendar/page/filter/type\u0022 class=\u0022views-ajax-link\u0022\u003EContent: Type (= Calendar Artist Shows)\u003C/a\u003E \u003C/div\u003E\n\u003C/div\u003E\n\u003Cdiv class=\u0022views-ui-display-tab-bucket sort-criteria\u0022 \u003E\n \u003Cdiv class=\u0022ctools-no-js ctools-dropbutton ctools-button views-ui-settings-bucket-operations\u0022 id=\u0022ctools-button-3\u0022\u003E\u003Cdiv class=\u0022ctools-link\u0022\u003E\u003Ca href=\u0022#\u0022 class=\u0022ctools-twisty ctools-text\u0022\u003Eopen\u003C/a\u003E\u003C/div\u003E\u003Cdiv class=\u0022ctools-content\u0022\u003E\u003Cul class=\u0022actions horizontal right\u0022\u003E\u003Cli class=\u0022add first\u0022\u003E\u003Ca href=\u0022/admin/structure/views/nojs/add-item/event\_calendar/page/sort\u0022 class=\u0022icon compact add views-ajax-link\u0022 title=\u0022Add\u0022 id=\u0022views-add-sort\u0022\u003EAdd\u003C/a\u003E\u003C/li\u003E\n\u003Cli class=\u0022rearrange last\u0022\u003E\u003Ca href=\u0022/admin/structure/views/nojs/rearrange/event\_calendar/page/sort\u0022 class=\u0022icon compact rearrange views-ajax-link\u0022 title=\u0022Rearrange\u0022 id=\u0022views-rearrange-sort\u0022\u003ERearrange\u003C/a\u003E\u003C/li\u003E\n\u003C/ul\u003E\u003C/div\u003E\u003C/div\u003E \u003Ch3\u003ESort criteria\u003C/h3\u003E\n \u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting page-sort-created even clearfix\u0022 \u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/config-item/event\_calendar/page/sort/created\u0022 class=\u0022views-ajax-link\u0022\u003EContent: Post date (desc)\u003C/a\u003E \u003C/div\u003E\n\u003C/div\u003E\n\u003C/div\u003E\u003Cdiv class=\u0022views-display-column second\u0022\u003E\u003Cdiv class=\u0022views-ui-display-tab-bucket page-settings\u0022 \u003E\n \u003Ch3\u003EPage settings\u003C/h3\u003E\n \u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting odd clearfix\u0022 \u003E\n \u003Cspan class=\u0022label\u0022\u003EPath:\u003C/span\u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/path\u0022 class=\u0022views-ajax-link \u0022 title=\u0022/users/%/Show-Schedule\u0022 id=\u0022views-page-path\u0022\u003E/users/%/Show-Schedule\u003C/a\u003E \u003C/div\u003E\n\u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting even clearfix\u0022 \u003E\n \u003Cspan class=\u0022label\u0022\u003EMenu:\u003C/span\u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/menu\u0022 class=\u0022views-ajax-link \u0022 title=\u0022No menu\u0022 id=\u0022views-page-menu\u0022\u003ENo menu\u003C/a\u003E \u003C/div\u003E\n\u003C/div\u003E\n\u003Cdiv class=\u0022views-ui-display-tab-bucket access\u0022 \u003E\n \u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting overridden odd clearfix\u0022 title=\u0022Overridden\u0022\u003E\n \u003Cspan class=\u0022label\u0022\u003EAccess:\u003C/span\u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/access\u0022 class=\u0022views-ajax-link \u0022 title=\u0022Specify access control type for this display.\u0022 id=\u0022views-page-access\u0022\u003ERole\u003C/a\u003E\u003Cspan class=\u0022label\u0022\u003E\u0026nbsp;|\u0026nbsp;\u003C/span\u003E\u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/access\_options\u0022 class=\u0022views-ajax-link views-button-configure\u0022 title=\u0022Change settings for this access type.\u0022 id=\u0022views-page-access-options\u0022\u003E\u003Cspan\u003EArtist\u003C/span\u003E\u003C/a\u003E \u003C/div\u003E\n\u003C/div\u003E\n\u003Cdiv class=\u0022views-ui-display-tab-bucket header\u0022 \u003E\n \u003Cdiv class=\u0022ctools-no-js ctools-button views-ui-settings-bucket-operations\u0022 id=\u0022ctools-button-4\u0022\u003E\u003Cdiv class=\u0022ctools-content\u0022\u003E\u003Cul class=\u0022actions horizontal right\u0022\u003E\u003Cli class=\u0022add first last\u0022\u003E\u003Ca href=\u0022/admin/structure/views/nojs/add-item/event\_calendar/page/header\u0022 class=\u0022icon compact add views-ajax-link\u0022 title=\u0022Add\u0022 id=\u0022views-add-header\u0022\u003EAdd\u003C/a\u003E\u003C/li\u003E\n\u003C/ul\u003E\u003C/div\u003E\u003C/div\u003E \u003Ch3\u003EHeader\u003C/h3\u003E\n \u003C/div\u003E\n\u003Cdiv class=\u0022views-ui-display-tab-bucket footer\u0022 \u003E\n \u003Cdiv class=\u0022ctools-no-js ctools-button views-ui-settings-bucket-operations\u0022 id=\u0022ctools-button-5\u0022\u003E\u003Cdiv class=\u0022ctools-content\u0022\u003E\u003Cul class=\u0022actions horizontal right\u0022\u003E\u003Cli class=\u0022add first last\u0022\u003E\u003Ca href=\u0022/admin/structure/views/nojs/add-item/event\_calendar/page/footer\u0022 class=\u0022icon compact add views-ajax-link\u0022 title=\u0022Add\u0022 id=\u0022views-add-footer\u0022\u003EAdd\u003C/a\u003E\u003C/li\u003E\n\u003C/ul\u003E\u003C/div\u003E\u003C/div\u003E \u003Ch3\u003EFooter\u003C/h3\u003E\n \u003C/div\u003E\n\u003Cdiv class=\u0022views-ui-display-tab-bucket pager\u0022 \u003E\n \u003Ch3\u003EPager\u003C/h3\u003E\n \u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting defaulted even clearfix\u0022 \u003E\n \u003Cspan class=\u0022label\u0022\u003EUse pager:\u003C/span\u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/pager\u0022 class=\u0022views-ajax-link \u0022 title=\u0022Change this display\u0026#039;s pager setting.\u0022 id=\u0022views-page-pager\u0022\u003EDisplay all items\u003C/a\u003E\u003Cspan class=\u0022label\u0022\u003E\u0026nbsp;|\u0026nbsp;\u003C/span\u003E\u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/pager\_options\u0022 class=\u0022views-ajax-link views-button-configure\u0022 title=\u0022Change settings for this pager type.\u0022 id=\u0022views-page-pager-options\u0022\u003E\u003Cspan\u003EAll items\u003C/span\u003E\u003C/a\u003E \u003C/div\u003E\n\u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting defaulted odd clearfix\u0022 \u003E\n \u003Cspan class=\u0022label\u0022\u003EMore link:\u003C/span\u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/use\_more\u0022 class=\u0022views-ajax-link \u0022 title=\u0022Specify whether this display will provide a \u0026quot;more\u0026quot; link.\u0022 id=\u0022views-page-use-more\u0022\u003ENo\u003C/a\u003E \u003C/div\u003E\n\u003C/div\u003E\n\u003C/div\u003E\u003Cdiv class=\u0022views-display-column third ctools-collapsible-container ctools-collapsible-remember ctools-collapsed\u0022 id=\u0022views-ui-advanced-column-event\_calendar\u0022\u003E\u003Ch3 class=\u0022ctools-collapsible-handle\u0022\u003E\u003Ca href=\u0022\u0022\u003EAdvanced\u003C/a\u003E\u003C/h3\u003E\u003Cdiv class=\u0022ctools-collapsible-content\u0022\u003E\u003Cdiv class=\u0022views-ui-display-tab-bucket contextual-filters\u0022 \u003E\n \u003Cdiv class=\u0022ctools-no-js ctools-dropbutton ctools-button views-ui-settings-bucket-operations\u0022 id=\u0022ctools-button-6\u0022\u003E\u003Cdiv class=\u0022ctools-link\u0022\u003E\u003Ca href=\u0022#\u0022 class=\u0022ctools-twisty ctools-text\u0022\u003Eopen\u003C/a\u003E\u003C/div\u003E\u003Cdiv class=\u0022ctools-content\u0022\u003E\u003Cul class=\u0022actions horizontal right\u0022\u003E\u003Cli class=\u0022add first\u0022\u003E\u003Ca href=\u0022/admin/structure/views/nojs/add-item/event\_calendar/page/argument\u0022 class=\u0022icon compact add views-ajax-link\u0022 title=\u0022Add\u0022 id=\u0022views-add-argument\u0022\u003EAdd\u003C/a\u003E\u003C/li\u003E\n\u003Cli class=\u0022rearrange last\u0022\u003E\u003Ca href=\u0022/admin/structure/views/nojs/rearrange/event\_calendar/page/argument\u0022 class=\u0022icon compact rearrange views-ajax-link\u0022 title=\u0022Rearrange\u0022 id=\u0022views-rearrange-argument\u0022\u003ERearrange\u003C/a\u003E\u003C/li\u003E\n\u003C/ul\u003E\u003C/div\u003E\u003C/div\u003E \u003Ch3\u003EContextual filters\u003C/h3\u003E\n \u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting page-argument-uid even clearfix\u0022 \u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/config-item/event\_calendar/page/argument/uid\u0022 class=\u0022views-ajax-link\u0022\u003E(author) User: Uid\u003C/a\u003E \u003C/div\u003E\n\u003C/div\u003E\n\u003Cdiv class=\u0022views-ui-display-tab-bucket relationships\u0022 \u003E\n \u003Cdiv class=\u0022ctools-no-js ctools-dropbutton ctools-button views-ui-settings-bucket-operations\u0022 id=\u0022ctools-button-7\u0022\u003E\u003Cdiv class=\u0022ctools-link\u0022\u003E\u003Ca href=\u0022#\u0022 class=\u0022ctools-twisty ctools-text\u0022\u003Eopen\u003C/a\u003E\u003C/div\u003E\u003Cdiv class=\u0022ctools-content\u0022\u003E\u003Cul class=\u0022actions horizontal right\u0022\u003E\u003Cli class=\u0022add first\u0022\u003E\u003Ca href=\u0022/admin/structure/views/nojs/add-item/event\_calendar/page/relationship\u0022 class=\u0022icon compact add views-ajax-link\u0022 title=\u0022Add\u0022 id=\u0022views-add-relationship\u0022\u003EAdd\u003C/a\u003E\u003C/li\u003E\n\u003Cli class=\u0022rearrange last\u0022\u003E\u003Ca href=\u0022/admin/structure/views/nojs/rearrange/event\_calendar/page/relationship\u0022 class=\u0022icon compact rearrange views-ajax-link\u0022 title=\u0022Rearrange\u0022 id=\u0022views-rearrange-relationship\u0022\u003ERearrange\u003C/a\u003E\u003C/li\u003E\n\u003C/ul\u003E\u003C/div\u003E\u003C/div\u003E \u003Ch3\u003ERelationships\u003C/h3\u003E\n \u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting page-relationship-uid odd clearfix\u0022 \u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/config-item/event\_calendar/page/relationship/uid\u0022 class=\u0022views-ajax-link\u0022\u003EContent: Author\u003C/a\u003E \u003C/div\u003E\n\u003C/div\u003E\n\u003Cdiv class=\u0022views-ui-display-tab-bucket no-results-behavior\u0022 \u003E\n \u003Cdiv class=\u0022ctools-no-js ctools-button views-ui-settings-bucket-operations\u0022 id=\u0022ctools-button-8\u0022\u003E\u003Cdiv class=\u0022ctools-content\u0022\u003E\u003Cul class=\u0022actions horizontal right\u0022\u003E\u003Cli class=\u0022add first last\u0022\u003E\u003Ca href=\u0022/admin/structure/views/nojs/add-item/event\_calendar/page/empty\u0022 class=\u0022icon compact add views-ajax-link\u0022 title=\u0022Add\u0022 id=\u0022views-add-empty\u0022\u003EAdd\u003C/a\u003E\u003C/li\u003E\n\u003C/ul\u003E\u003C/div\u003E\u003C/div\u003E \u003Ch3\u003ENo results behavior\u003C/h3\u003E\n \u003C/div\u003E\n\u003Cdiv class=\u0022views-ui-display-tab-bucket exposed-form\u0022 \u003E\n \u003Ch3\u003EExposed form\u003C/h3\u003E\n \u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting even clearfix\u0022 \u003E\n \u003Cspan class=\u0022label\u0022\u003EExposed form in block:\u003C/span\u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/exposed\_block\u0022 class=\u0022views-ajax-link \u0022 title=\u0022Allow the exposed form to appear in a block instead of the view.\u0022 id=\u0022views-page-exposed-block\u0022\u003ENo\u003C/a\u003E \u003C/div\u003E\n\u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting defaulted odd clearfix\u0022 \u003E\n \u003Cspan class=\u0022label\u0022\u003EExposed form style:\u003C/span\u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/exposed\_form\u0022 class=\u0022views-ajax-link \u0022 title=\u0022Select the kind of exposed filter to use.\u0022 id=\u0022views-page-exposed-form\u0022\u003EBasic\u003C/a\u003E\u003Cspan class=\u0022label\u0022\u003E\u0026nbsp;|\u0026nbsp;\u003C/span\u003E\u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/exposed\_form\_options\u0022 class=\u0022views-ajax-link views-button-configure\u0022 title=\u0022Exposed form settings for this exposed form style.\u0022 id=\u0022views-page-exposed-form-options\u0022\u003E\u003Cspan\u003ESettings\u003C/span\u003E\u003C/a\u003E \u003C/div\u003E\n\u003C/div\u003E\n\u003Cdiv class=\u0022views-ui-display-tab-bucket other\u0022 \u003E\n \u003Ch3\u003EOther\u003C/h3\u003E\n \u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting even clearfix\u0022 \u003E\n \u003Cspan class=\u0022label\u0022\u003EMachine Name:\u003C/span\u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/display\_id\u0022 class=\u0022views-ajax-link \u0022 title=\u0022Change the machine name of this display.\u0022 id=\u0022views-page-display-id\u0022\u003Epage\u003C/a\u003E \u003C/div\u003E\n\u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting odd clearfix\u0022 \u003E\n \u003Cspan class=\u0022label\u0022\u003EComment:\u003C/span\u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/display\_comment\u0022 class=\u0022views-ajax-link \u0022 title=\u0022Comment or document this display.\u0022 id=\u0022views-page-display-comment\u0022\u003ENo comment\u003C/a\u003E \u003C/div\u003E\n\u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting overridden even clearfix\u0022 title=\u0022Overridden\u0022\u003E\n \u003Cspan class=\u0022label\u0022\u003EUse AJAX:\u003C/span\u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/use\_ajax\u0022 class=\u0022views-ajax-link \u0022 title=\u0022Change whether or not this display will use AJAX.\u0022 id=\u0022views-page-use-ajax\u0022\u003ENo\u003C/a\u003E \u003C/div\u003E\n\u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting defaulted odd clearfix\u0022 \u003E\n \u003Cspan class=\u0022label\u0022\u003EHide attachments in summary:\u003C/span\u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/hide\_attachment\_summary\u0022 class=\u0022views-ajax-link \u0022 title=\u0022Change whether or not to display attachments when displaying a contextual filter summary.\u0022 id=\u0022views-page-hide-attachment-summary\u0022\u003ENo\u003C/a\u003E \u003C/div\u003E\n\u003Cdiv class=\u0022views-display-setting views-ui-display-tab-setting defaulted even clearfix\u0022 \u003E\n \u003Cspan class=\u0022label\u0022\u003EHide contextual links:\u003C/span\u003E\n \u003Ca href=\u0022/admin/structure/views/nojs/display/event\_calendar/page/hide\_admin\_links\u0022 class=\u0022views-ajax-link \u0022 title=\u0022Change whether or n

# Answer
In installations instructions it says you need to download this plugin

* Unzip the plugin.
* Upload the **fullcalendar** folder to `/sites/all/libraries`

So in the end you should have `/sites/all/libraries/fullcalendar/`

You may need to manually create the `/libraries` folder inside `/all` folder if you haven't done this before.
> 0 votes

---
Tags: views, datetime, javascript
---


# Question
Title: Updating a term reference programatically
I've written a module that - among other things - automatically categorizes uploaded files based on their file extension. The idea is simple: the module programatically sets up a taxonomy and automatically adds new terms to it whenever it stumbles upon a new file extension (i.e. pdf, .doc, .jpg etc.).

I cannot get it to work, however. The taxonomy terms are succesfully added to the taxonomy and I can go and investigate them in the admin interface, but the term reference between the node and the term is never saved to the database. I use `$node->computed_file_extension[$node->language][0] = $term->tid`to save the reference and I'm pretty sure that I've done this with sucess in the past.

I'm actually a bit confused about using `'und'` or `$node-language`. I suppose `$node->langugage` is the more universal of the two, but it seems it does not always work - in this case I've tried both without success.

When I inspect my node object I can see that the reference is on the node object, but there are no records added to the table `taxonomy_index` in the DB when `node_save()` is triggered.

I'm triggering this function on either node update, node insert or node delete and only if changes have been made to the field where I store the uploaded file (i.e. a file has been added or removed).

```
function _uvp_fields_update_field_file_extension($node) {

// Load the vocabulary called 'file extensions'.
  $vocabulary = taxonomy_vocabulary_machine_name_load('file_extensions');

  if (!empty($vocabulary)) {
    if (!empty($node->field_file['und'][0]['fid'])) {
      $file = file_load($node->field_file['und'][0]['fid']);

// Split the filename and grab the last part to get the file extension.
      $extension = array_pop(explode('.', $file->filename));

      $term = current(taxonomy_get_term_by_name($extension));

// If there is not already a taxonomy term with the given extension, create it.
      if (empty($term)) {

// Build taxonomy term object.
        $term = (object) array(
          'vid'  => $vocabulary->vid,
          'name' => $extension,
        );

// Save the taxonomy term.
        taxonomy_term_save($term);
      }

// Add taxonomy term reference.
      $node->computed_file_extension[$node->language][0] = $term->tid;
//$node->computed_file_extension['und'][0] = $term->tid;

    }
    else {

// If the file has been removed, remove the tag.
      unset($node->computed_file_extension['und'][0]);
    }

// Save the node.
    node_save($node);

    return TRUE;

  }
  else {

    watchdog('uvp_fields', 'The vocabulary "file_extensions" does not exists.');

    return FALSE;
  }
}

```

# Answer
You're one level off; this:

```
$node->computed_file_extension[$node->language][0] = $term->tid;

```

Needs to be this:

```
$node->computed_file_extension[$node->language][0]['tid'] = $term->tid;

```

Without specifying the field column (`tid` in this case), Drupal doesn't know which DB field the data should be stored in.
> 1 votes

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


# Question
Title: How to display eck edit form in ctools modal or in other page?
I need to display my custom eck edit form in ctools modal. How can I load the form I need in ctools modal or other page?

```
function edit_education_form_callback($ajax){
  if ($ajax) {
    ctools_include('ajax');
    ctools_include('modal');

    $form_state = array(
      'ajax' => TRUE,
      'title' => t('Education'),
    );

    $output = ctools_modal_form_wrapper('resume_education_edit_form', $form_state);

    if (!empty($form_state['executed'])) {
      // We'll just overwrite the form output if it was successful.
      $output = array();
      ctools_add_js('ajax-responder');
      if (isset($_GET['destination'])) {
        $output[] = ctools_modal_command_dismiss();
      }
      else {
        $output[] = ctools_ajax_command_redirect('my-account');
        drupal_set_message(t('successfully added.'));
        $output[] = ajax_command_after('.modal-title',theme('status_messages'));
      }
    }

    print ajax_render($output);
    drupal_exit();
  }
  else {
    return drupal_get_form('resume_education_edit_form');
  }
}

function resume_education_edit_form($form, &$form_state){
  // How can I call the eck edit form I created?
  // $output = ctools_modal_form_wrapper('eck_edit_form', $form_state)
  // Should I use drupal_get_form('eck__entity__edit')?
}

```

# Answer
> 1 votes
The right way to load the edit form of a custom entity bundle created with ECK is by using the `eck__entity__edit` function provided by the ECK module.

Usage example:

```
$output = eck__entity__edit($entity_type_name, $entity_bundle_name, $entity_id);

```

---
Tags: database, entities
---


# Question
Title: How to identify and target a form element?
A similar question has been asked before: How do you identify a form element?

I am using the Devel module and `dpm($form)` outputs the object nicely:

But I can't set/change the default value of a custom field. How do I target set the default value to 164 in this case?

```
$form['question_node_form']['field_points']['und']['0']['value']['#default_value'] = 164;

```

The above does not work and the points\_field is blank.

EDIT (complete function):

```
function custom2_form_question_node_form_alter(&$form, &$form_state, &$form_id) {
    drupal_set_message("Form ID is : " . $form_id);
    dpm($form);
    $form['question_node_form']['field_points']['und']['0']['value']['#default_value'] = 164;
}

```

# Answer
You're calling the explicit `hook_form_FORM_ID_alter` for a start so `$form_id` will never be anything except `question_node_form`.

However the problem is you are trying to target a child of the form array. The top level array **is already** `question_node_form`. Your code should look like this:

```
function custom2_form_question_node_form_alter(&$form, &$form_state, $form_id) {
    $form['field_points']['und']['0']['value']['#default_value'] = 164;
}

```

*Debugging removed for clarity. Noticed we removed `['question_node_form']`.*

Also note you can't pass `$form_id` by reference (not that it matters) as it can't be changed.

https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook\_form\_FORM\_ID\_alter/7
> 2 votes

---
Tags: 7, forms, debugging
---


# Question
Title: Search page shows empty fields of unpublished content
How can I make a filter to my search page that hides unpublished content?

In filter criteria I only have global, indexed and search.

# Answer
> 1 votes
In your view, besides FILTER click on add, select Content Published (YES)

---
Tags: views, search
---


# Question
Title: Sort Filter updates both block and page within single view
I had this working, but can't seem to figure out what I did. I have a view that contains a block and a page. I have embedded the block into the page and exposed sort criteria on both. I want to be able to sort either the block by clicking on the title and have it update the block table and the page or click the sort criteria drop down on the page to update the block table and the page. How do I do this?

# Answer
The default setting is that it will apply to all displays- make sure you choose only the specific one you want.
> 0 votes

---
Tags: views
---