# Question
Title: How to show pending (unpublished) revision fields in views in Drupal 7?
I am using Drupal 7 and I have a CT with **revisioning** and workbench **moderation** enabled.

I want to create a view for administrators, showing the **latest revision** of the nodes **with various fields**, even if the latest revision is not published (pending).

I have created a node revisioning view with relationships on revision and revision node, but it seems to fetch field values only for the published/current revisions and not for the latest.

The administrators have access to unpublished content, and they can view the latest revisions with their fields through the revisioning interface.

To better understand how the revisioning works with views, I created a test view showing all the revisions of a specific node, having some archived revisions, then a published/current one and then some pending ones. I can view field values only for the published one.

**Is there any way to show field values for all node revisions in views?**

The view results are the following:

My view export code is the following:

```
$view = new view();
$view->name = 'test_revisions_2';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node_revision';
$view->human_name = 'test revisions 2';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'test revisions 2';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'view revisions';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '50';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['pager']['options']['quantity'] = '9';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['grouping'] = array(
  0 => array(
    'field' => 'nid',
    'rendered' => 1,
    'rendered_strip' => 0,
  ),
);
$handler->display->display_options['style_options']['columns'] = array(
  'title' => 'title',
  'body' => 'body',
  'nid' => 'nid',
  'vid' => 'vid',
  'name' => 'name',
  'state' => 'state',
  'state_1' => 'state_1',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
  'title' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'body' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'nid' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'vid' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'name' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'state' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'state_1' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
);
/* Relationship: Revision */
$handler->display->display_options['relationships']['vid']['id'] = 'vid';
$handler->display->display_options['relationships']['vid']['table'] = 'node_revision';
$handler->display->display_options['relationships']['vid']['field'] = 'vid';
$handler->display->display_options['relationships']['vid']['ui_name'] = 'Revision';
$handler->display->display_options['relationships']['vid']['label'] = 'Revision';
/* Relationship: Revision node */
$handler->display->display_options['relationships']['nid']['id'] = 'nid';
$handler->display->display_options['relationships']['nid']['table'] = 'node_revision';
$handler->display->display_options['relationships']['nid']['field'] = 'nid';
$handler->display->display_options['relationships']['nid']['ui_name'] = 'Revision node';
$handler->display->display_options['relationships']['nid']['label'] = 'Revision node';
/* Relationship: Country */
$handler->display->display_options['relationships']['field_ef_country_iso2']['id'] = 'field_ef_country_iso2';
$handler->display->display_options['relationships']['field_ef_country_iso2']['table'] = 'field_data_field_ef_country';
$handler->display->display_options['relationships']['field_ef_country_iso2']['field'] = 'field_ef_country_iso2';
$handler->display->display_options['relationships']['field_ef_country_iso2']['relationship'] = 'vid';
$handler->display->display_options['relationships']['field_ef_country_iso2']['ui_name'] = 'Country';
$handler->display->display_options['relationships']['field_ef_country_iso2']['label'] = 'Country';
/* Field: Content revision: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node_revision';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
$handler->display->display_options['fields']['title']['link_to_node_revision'] = TRUE;
/* Field: Content: Body */
$handler->display->display_options['fields']['body']['id'] = 'body';
$handler->display->display_options['fields']['body']['table'] = 'field_data_body';
$handler->display->display_options['fields']['body']['field'] = 'body';
$handler->display->display_options['fields']['body']['relationship'] = 'vid';
$handler->display->display_options['fields']['body']['type'] = 'text_summary_or_trimmed';
$handler->display->display_options['fields']['body']['settings'] = array(
  'trim_length' => '100',
);
/* Field: Content revision: Nid */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'node_revision';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
/* Field: Content revision: Vid */
$handler->display->display_options['fields']['vid']['id'] = 'vid';
$handler->display->display_options['fields']['vid']['table'] = 'node_revision';
$handler->display->display_options['fields']['vid']['field'] = 'vid';
/* Field: Countries: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'countries_country';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'field_ef_country_iso2';
/* Field: Content revision: State */
$handler->display->display_options['fields']['state']['id'] = 'state';
$handler->display->display_options['fields']['state']['table'] = 'node_revision';
$handler->display->display_options['fields']['state']['field'] = 'state';
$handler->display->display_options['fields']['state']['label'] = 'Revision state';
/* Field: Workbench Moderation: State */
$handler->display->display_options['fields']['state_1']['id'] = 'state_1';
$handler->display->display_options['fields']['state_1']['table'] = 'workbench_moderation_node_history';
$handler->display->display_options['fields']['state_1']['field'] = 'state';
$handler->display->display_options['fields']['state_1']['label'] = 'Moderation state';
$handler->display->display_options['fields']['state_1']['machine_name'] = 0;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['relationship'] = 'nid';
$handler->display->display_options['filters']['type']['value'] = array(
  'ef_national_contribution' => 'ef_national_contribution',
);
$handler->display->display_options['filters']['type']['group'] = 1;
/* Filter criterion: Content revision: Nid */
$handler->display->display_options['filters']['nid']['id'] = 'nid';
$handler->display->display_options['filters']['nid']['table'] = 'node_revision';
$handler->display->display_options['filters']['nid']['field'] = 'nid';
$handler->display->display_options['filters']['nid']['value']['value'] = '1405';

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'test-revisions-2';
$translatables['test_revisions_2'] = array(
  t('Master'),
  t('test revisions 2'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort by'),
  t('Asc'),
  t('Desc'),
  t('Items per page'),
  t('- All -'),
  t('Offset'),
  t('« first'),
  t('‹ previous'),
  t('next ›'),
  t('last »'),
  t('Revision node'),
  t('Country'),
  t('Body'),
  t('Nid'),
  t('Vid'),
  t('Name'),
  t('Revision state'),
  t('Moderation state'),
  t('Page'),
);

```

**Update 1:**

I'm posting a screenshot of my view UI:

# Answer
You have mentioned "published/current" as if both are same. But in workbench moderation **published** refers to the revision that is published and **current** refers to the revision that is latest.

So, if you want to show the latest revision then create a view of node revision as you have done and add the fields you want to display. The important thing is to add a filter `Workbench Moderation: Current` and select the value `Yes`, this will make sure only the latest revisions are displayed.

Edit: Normally if you create content revision view for your scenario you will get the values, **try removing all the relationship except `Content Revision: Content`**. If you do that you will get the values, title and other fields, but the problem will be that title will change as per revision but other fields will only display the published revision content. For eg: assume you had three revisions of a node, first: archived, second: published, third: review, then the result will look like this eg:

```
     Title V1, Field V2
     Title V2, Field V2
     Title V3, Field V2
```
To change, add a field with the label historical like `Content (historical data): Field` this will display the way you want
```
     Title V1, Field V1
     Title V2, Field V2
     Title V3, Field V3
```
> 0 votes

# Answer
Since I have been poking around for something similar, this post was helpful in clarifying the "Content (historical data)" :

How to pull node history into a view
> 0 votes

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


# Question
Title: How can I tidy up an auto increment field in a table from within a module?
How can I tidy up an auto increment field in a table from within a module, so that a table like this (the 'id' field being auto incrementing):

```
id title
1  foo
3  bar
7  fee

```

becomes:

```
id title
1  foo
2  bar
3  fee

```

Is there a function, like serial\_field\_tidy or something?

# Answer
You should never do that since the IDs are important for addressing to that specific row in other tables. You would never know which modules are also indexed this row with its id. So if you change the ID of a row, you will encounter unexpected things in your installation.
> 1 votes

# Answer
There's another option more easy, with views you can show a field with global usage (I'm not sure the name of this option) and print his row number or his row number plus 1st ID

But like other people told you, avoid change IDs
> 0 votes

---
Tags: database, theming
---


# Question
Title: Content Type and Fields programmatically
I make a module in Drupal 8 who create a new content type programmatically. Module name : Annonce

In config/install I add this file:

node.type.annonce\_type.yml

```
type: annonce_type
name: 'Ajouter une annonce'
description: 'Formulaire pour ajouter une annonce'
help: ''
new_revision: false
display_submitted: true
preview_mode: 0
status: true
langcode: fr

```

All is good, my new content type is create in backoffice. But now I want to add some fields programmatically, and I don't find a core module who are doing that.

# Answer
> 2 votes
I answered pretty much the same once already I think, but I can't find that answer anymore.

You add fields and their widget and formatter configuration in the same way. By adding all the relevant config entities.

You can find almost all of them by exporting configuration into the staging folder and then search for files that contain "announce\_type" in the file name. That gives you the fields, the form and view displays configurations.

Then you also need the field storages. These are shared across bundles, so they don't have the node type in them (unless you prefixes your fields with your node type/module, which is a good idea if you want to make them part of your module).

Put all those fields in `config/install` and you're done.

---
Tags: entities, 8
---


# Question
Title: SimplePie library is required for Feeds SimplePie Parser
The Feeds module is reporting a warning about needing a SimplePie parser and prompts the user download a compiled version of it, but it isn't clear how/where to do this.

Where can I find the compiled version of the required library?

# Answer
> 1 votes
You can pull a compiled version of the parse from http://simplepie.org/downloads/simplepie\_1.3.1.compiled.php. Rename this file simplepie.compiled.php and copy it in the directory sites/all/libraries/simplepie/; the module should stop reporting the error.

---
Tags: feeds, theming
---


# Question
Title: PDOException: SQLSTATE[42S02] - Base table not found
So I am in a bind and have no idea where to go. I get the following message now after I tried to add a new field to a content type:

```
Error message
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'wrrc-data.cache_field' doesn't exist: DELETE FROM {cache_field} WHERE (cid LIKE :db_condition_placeholder_0 ESCAPE '\\') ; Array ( [:db_condition_placeholder_0] => field\_info\_types:% ) in cache_clear_all() (line 167 of C:\data\htdocs\wrrc-data\includes\cache.inc).

```

I have looked everywhere and cannot seem to find the right answer for me, and am hoping someone who has dealt with this hellish nightmare might be able to help.

I have tried dropping the "non-existent" (even though I see it in the file directory) 'cache\_field' table, it "supposedly" works and so I go on to create a new table (to replace the failed one). All the sites I went to for this problem suggested the following code:

```
CREATE TABLE IF NOT EXISTS `cache_field` (

```

`cid` varchar(255) NOT NULL DEFAULT '' COMMENT 'Primary Key: Unique cache ID.', `data` longblob COMMENT 'A collection of data to cache.', `expire` int(11) NOT NULL DEFAULT '0' COMMENT 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.', `created` int(11) NOT NULL DEFAULT '0' COMMENT 'A Unix timestamp indicating when the cache entry was created.', `serialized` smallint(6) NOT NULL DEFAULT '0' COMMENT 'A flag to indicate whether content is serialized (1) or not (0).', PRIMARY KEY (`cid`), KEY `expire` (`expire`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Generic cache table for caching things not separated out...';

But after starting this sql command, I get the following error:

```
#1005 - Can't create table 'wrrc-data.cache_field' (errno: -1) (Details…)

```

Doesn't give me any more information (even the supposed "Details" page doesn't give me squat, all it talks about is the background for InnoDB, nothing to add to the error at hand.

Does anyone have any suggestions? I really don't want to recreate the site at all, as that is what some had suggested on other sites, but this is beginning to wear me down. If I do need to just create another site, is there a way to streamline the process of bringing over my data and formatting without having the error hitch a ride?

Thanks in advance, I really appreciate it. Matt

# Answer
> 1 votes
I already answered this question here and it solved the problem. Many people who work with Drupal face this problem. This is the answer:

> I had the same problem, and in my case the issue was the database tables engine: By default it is InnoDB and (for some reasons I still don't have to understand) Drupal reports this error.
>
> You must change the database engine to MyISAM. First off, you must be sure the tables that are going to be created by Drupal have MyISAM as engine: In `/includes/database/mysql/schema.inc`, look for `createTableSql($name, $table)`, and change InnoDB to MyISAM; then, save it.
> Since you have a few tables in your database they must be changed to `MyISAM` as well, so simply export the database as .sql file open it in a text editor and replace `Engine=InnoDB` with `Engine=MyISAM`. Now in the server `phpmyadmin` delete all the tables of the DB and import the new `.sql` file in there. In this way, all your tables and the tables that will be created by Drupal are MyISAM.

# Answer
> 1 votes
Chechout the link at https://www.drupal.org/node/2144205#comment-9288889 which suggests this:

> If your cache\_field table is corrupt, you should be able to clear it by running update.php or cc all from drush. If you want to empty the table contents without deleting and rebuilding the schema, you can delete from cache\_table or truncate cache\_table.

Another suggestion is in the same link, located at https://www.drupal.org/node/2144205#comment-8368871 ...

If neither of those links help (or don't work), then investigate which module creates that table as part of it's install/enable process. Then uninstall and re-install that module ...

# Answer
> 0 votes
When it's about designing content types, you shouldn't act on the database structure. My suggestion is to clone your content type and work on the new one. If this is not working, make a brand new one

---
Tags: entities, caching, database
---


title: Fetching Facebook posts

text:
# Question
Title: Fetching Facebook posts
I'm creating a custom module to deliver an amalgamated news feed from various sources, all ordered by date. One of these sources is FB, and I'm having real issues with it.

I'm using fbapp module as a dependency (https://www.drupal.org/project/fbapp), so that I can use it's authentication fbapp\_app\_authenticate() and fbapp\_graph\_request() without having to worry about the constant facebook graph updates making my own code obsolete.

I've created a facebook app, so authentication should be app token, using appid and app secret. This seems fine and I'm getting back access\_token. However, when I try to read posts from a publicly available page (the clients), I get the response:

```
"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api"

```

Here's my code:

```
$token = fbapp_app_authenticate(variable_get('my_module_fb_app_id', ''), variable_get('my_module_fb_app_secret', ''));
$type = variable_get('my_module_fb_query', -1); // this is "posts" in this case
$graphId = variable_get('my_module_fb_graph_id', '');
$target = "$graphId/$type";
$params = array('access_token' => $token['access_token']);
$data = fbapp_graph_request($target, $params);

```

As an update, here's the queries and responses it produces:

```
graph.facebook.com/oauth/access_token?client_id=<redacted>&client_secret=<redacted>&grant_type=client_credentials

array(1) {
  ["access_token"]=>
  string(43) "<redacted>|<redacted>"
}

graph.facebook.com/<page_id>/posts?access_token=<redacted>|<redacted>"

string(183) "{"error":{"message":"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100}}"

```

Does anyone know if this is a correct way to query Facebook, or if there's a better way of programmatically obtaining a page posts?

# Answer
> 1 votes
Here's the solution I got on the main stackoverflow site (https://stackoverflow.com/questions/31306242/facebook-graph-api-unsupported-get-request):

```
If page restrictions apply, the page's feed can only be retrieved with an user access token as far as I know (because FB needs to evaluate the visibility criteria, and setting your app to the same restrictions doesn't help here):

See

https://developers.facebook.com/docs/graph-api/reference/v2.4/page/feed#readperms

```

The alternative is to use page access tokens, but you need admin access to the site page to generate those. This means you will receive all posts, regardless of restrictions.

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


# Question
Title: Is it possible to understand and use Relationships and Contextual Filters without knowing SQL?
Are there any good, layman descriptions of contextual filters and relationships for those site builders that aren't developers?

Is it possible to be comfortable with Relationships and Contextual Filters without knowing SQL? If so, how?

# Answer
> 2 votes
By knowing SQL you can have better understanding but it is not necessary.

> Relationships give you information about entities that are not listed in the fields b joining current content with other entities. For example detail information about the author of the node is not in the fields, Only it's uid is in there, so by selecting author as relationships you can get the rest of the information.
>
> Contextual filters are similar to regular filters in that you can use mainly the same fields to filter the records on. Where contextual filters differ greatly is that you do not set the filtering value when you create the View, but it is taken from context. Contextual filters are great for when the View needs to display content dynamically depending on various contextual conditions

---
Tags: views
---


title: Rule iteration check

text:
# Question
Title: Rule iteration check
I am currently making a site that will implement a system of volume licenses and I am using a system of checking user registration info to check for certain rules. My rule works like this

i. On the event of a new user being generated

ii. Check for two conditions present in the user registration info

Check one AND Check two

iii. Grant the user a certain permissions role.

Problem: I need this rule to only work for X amount of users they have added with X being the amount of users that is allowed for with their volume license. I do not know a way nor can I find a way to check against how many times a rule is ran and then disables the rule if a certain number of users have received a role this way. Any ideas?

# Answer
> 0 votes
When the rule is ran a certain role is granted to the user. So in your rule's condition add a `PHP` (or any other way) and check for the number of users who have this role.

# Answer
> 0 votes
Try using the Flag module and the "***Fetch overall flag count***" functionality. Excerpt from comment #14 in issue #1396196:

> 'Fetch overall flag count' gets the total count of items flagged within a flag. It is not just the count of the total number of nodes that are flagged, but it grabs every entity type flagged within a flag, including nodes.

Here are some more suggestions related to it:

1. Create a flag, say "Licensed user", to be used for "users" (not nodes ...).
2. Expand the existing "Check one AND Check two" with something like "... AND 'Fetch overall flag count (for flag = Licensed user)' is less then X"
3. Add an extra action to the rule that already contains your existing action (="*Grant the user a certain permissions role."*). The extra action = "Set flag 'Licensed user' for this user".

# Answer
> 0 votes
With `php filter` enabled rules support PHP logic. You can store the number of times the Rule has successfully run in a variable using `variable_set` and get how many times it's run by `variable_get`. This way your Rule can track the status of this rule.

Another option I would consider is using a module like Data or the Relation module, or even a simple content type and using Rabbit Hole to hide the content type. Then in either a Data table or your custom content type add a field that is `number_of_volume_licenses`. Rules can then read and write this field like any other system content, you could track 1 or many of these volume licenses.

# Answer
> 0 votes
If I was to set up something like this, I would try this first - there is a caveat attached to this, as it is incomplete and requires some more information from you:

* create a content type for the license, adding whatever relevant information you want displayed to the end user, as well as a count field for licensed users - perhaps two fields, total granted, total left for easier reading
* Using permissions, restrict editing of this content type to admin only
* Create the nodes as licenses are granted and fill out the number of licensed users
* Use Rules to check the user count field quantity is above 0, and upon registration, decrease the total number left by one

It is in almost any answer a requirement that you decide how you relate the data, be it a flag, this method, something custom, etc. When a user is registering, how do they know which license to use (presuming you allow multiple licenses to be active at once)? you would need to include a reference to that in the Rule, regardless of your approach, or you won't know which license is being affected.

The nice thing about this approach is that it is quite simple in design, and allows a license information page to be created for the user to view status information about the license - it could include things like a list of the users for that license, etc. You could also use access control modules to restrict who can actually view the license page (owner)

---
Tags: rules, users
---


title: Create node from JSON

text:
# Question
Title: Create node from JSON
I'm looking to write the following module, any help, guidance, and advice would be greatly appreciated.

* User is logged into site.
* Site has two content types: page & note.
* Logged in user can create content type note only.
* User is viewing a node: /node/5.
* User selects some text in the body.
* Link/icon is shown above selected text.
* User clicks clicks and is taken to /node/add/note
* Some fields are pre-populated on Node edit page, including:
    + title, field\_source\_quote, field\_entity\_reference\_nid
* User adds his "note" to field\_user\_note and saves note

From my basic understanding of JSON, I should be able to create a JSON of the user selected text with something like:

```
var selectedText = "";
selectedText = window.getSelection().toString();

var noteData={
    "sourcePath": "/node/being/viewed",
    "selectedText": selectedText
};

```

How do I get noteData to a module? Better yet, how do I get nodeData to the node/add/note page and pre-populate the correct fields?

Any help would be greatly appreciated.

======= Updates Below =============

**Passing data through local storage (Andrew's Approach)**

I can confirm this approach is viable. There are a number of issues, however that this presents:

1. I'm sure this is not the most "drupal-ized" way to perform this.
2. If the node admin pages use a different theme, the js to retrieve and apply the data must be within the other them.
3. Need to have a persistent marker placed for the user ui (i.e. highlighting the text they have added a "note" to).

I've come across a library that might be helpful for #3: Rangy (https://github.com/timdown/rangy).

# Answer
> 2 votes
Here is a little working piece of code for you. You may extend it according to your needs

```
document.onselectionchange = function() {
    var selectedText = "";
    $('div').mouseup(function() {
      //Save selected text in localStorage.
      selectedText = window.getSelection().toString();
      if (selectedText.length > 10) {
        var noteData={
          "sourcePath": window.location.href,
          "selectedText": selectedText
        };
        localStorage.setItem('noteData', JSON.stringify(noteData));
        window.location.href = '/node/add/page';
      }
    });
  };

  // Get saved data from localStorage and insert in the form.
  var savedNoteData = JSON.parse(localStorage.getItem('noteData'));
  if (savedNoteData && savedNoteData.selectedText) {
    $('.form-item-title input').val(savedNoteData.selectedText);
    localStorage.setItem('noteData', '');
  }

```

---
Tags: 7, nodes
---


# Question
Title: How to save a new term with multiple fields while adding content?
Not only do I want to add terms as I create content through the UI, but I want to add terms that have multiple fields (i.e. more fields on the taxonomy besides the 'Name' that populates the list). How can this be done?

I'm mixing a few concepts here:

1. Add terms through the Add/Edit Content page
2. Display the different fields of a taxonomy on the Add/Edit Content page.

# Answer
You can use References dialog module with this patch

> This module extends reference fields like the user and node reference fields by adding links to add, edit and search for references through a dialog. This allows for a workflow where the user can create all the references to a node at the same time as she is creating it, a process which sometimes get's a bit backwards, when a user for instance needs to create all the facts for an article.
> 1 votes

# Answer
You can use fieldset field set module to create multiple fields with in a single field.
> 0 votes

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


# Question
Title: Not able to overwrite old value in Drupal.settings
I am facing Problems in overwriting old value in Drupal.setting.

**Problem Statement**

I am passing FID value from PHP to JS. At first it is getting correct value in JS.

Ex. When PHP is passing FID=59 to JS for first time then it is correctly received by JS. Next time when it is passing FID=60 then it is showing FID=59 in JS always. Drupal.setting is not refreshing with current value.

My sample php code is like this

```
 function TraverseSnap($nextFID)
 {
    $thm_slideshowimg .= '<input type="image" src="nxt.jpg" class="clsNextSnap" width="25" height="25">';

    $nxtSnapSetting = array(
            'fid' => $nextFID,
     );

    drupal_add_js(array('nxtSnp' => $nxtSnapSetting), 'setting');
 }

```

JS Code

```
(function($) {
 Drupal.behaviors.VidsImgsContent=
 {
      attach: function (context, settings)
      {
          var fileId = Drupal.settings.nxtSnp.fid;
          var dataNextSnap = 'fid=' +fileId;
          $.ajax({
                  url: 'nextsnap',
                  type: 'POST',
                  async : false,
                  dataType : 'json',
                  data : dataNextSnap,
                  success : updateMainNextDiv,
                  error : function(jqXHR, textStatus, errorThrown){alert("Some Error occured");},
                  beforeSend: function()
                  {
                  },
               });
               return false;
       }
  }
  })(jQuery);

```

My hook\_menu call

```
$items['nextsnap']=array(
   'title'=>t(''),
   'type'=> MENU_CALLBACK,
   'page callback' => 'nxt_snap_post',
   'access arguments' => array('access content'),
);

```

Page Callback

```
function nxt_snap_post()
{
    $fid=$_POST['fid'];

    $htmlResult = TraverseSnaps(60); //An arbitary Value for sake of this example
    drupal_json_output($htmlResult);
    exit();
}

```

So I believe when the button is clicked next time it will take FID=60 in JS but it is taking old value instead.

Please help here as my crucial logic depends on this.

# Answer
I think you can not do it this way. Data Drupal.settings only run in first load. This data store in tag head of page.

When you call ajax your function was execute, but tag head don't reaload. So Data.settings don't change.
> 1 votes

---
Tags: 7, ajax, routes, javascript
---


# Question
Title: How to check term ID present in database table before updating
I need to increment a counter on every taxonomy page load. I am adding the code in **taxonomy-term.tpl.php** file in my theme. I need to add a new entry if the term is not present and need to increment the 'totalview' if its already present. Here is my code, can any one help me to add the condition.

```
db_insert('custom_file_download_count')
->fields(array(
  'totalview' => 1,
  'tid' => arg(2),
  'timestamp' => REQUEST_TIME,
  'uid' => $GLOBALS['user']->uid,
))

db_update('custom_file_download_count')
->fields(array(
  'totalview' => 1,
  'tid' => arg(2),
  'timestamp' => REQUEST_TIME,
  'uid' => $GLOBALS['user']->uid,
))
->expression('totalview', 'totalview + 1')
->execute();

```

# Answer
Your compound key you need to check for is for `uid` & `tid`. You can check for a row's existance (thus, need to insert) with a `db_query` function call & `rowCount` method call.

```
if(db_query('SELECT totalview FROM {custom_file_download_count} WHERE tid = :tid AND uid = :uid', array(':tid' => $tid, ':uid' => $GLOBALS['user']->uid))->rowCount() == 0) {
  db_insert('custom_file_download_count')
  ->fields(array(
    'totalview' => 0,
    'tid' => arg(2),
    'timestamp' => REQUEST_TIME,
    'uid' => $GLOBALS['user']->uid,
  ))->execute();
}
db_update('custom_file_download_count')
->fields(array(
  'totalview' => 1,
  'tid' => arg(2),
  'timestamp' => REQUEST_TIME,
  'uid' => $GLOBALS['user']->uid,
))
->expression('totalview', 'totalview + 1')
->execute();

```
> 0 votes

---
Tags: taxonomy-terms
---


# Question
Title: How to set up path for library and include files
In Drupal 7, I am writing PHP from inside the Front Page module, say:

```
$page = include_once "templates/page.php";

```

I put the "templates/page.php" under /sites/all/modules/front and Drupal complains about file missing. Any suggestion where best to put up the files to be included?

Then, after installing the PHP Simple HTML DOM Parser, I wrote the following

```
$html = new simple_html_dom();

```

and was complained for Class 'simple\_html\_dom' not found. I have tried duplicating the library file to the same folder and home, but all cases not working. How to set up the correct path?

Many thanks.

# Answer
> 0 votes
If it's a theme function, guessing from the file name you mentioned, you should use them `theme()` function to get the themed output.

To get the path of a module relative to the Drupal root, use `drupal_get_path()` function.

If you want to `include` or `require` a file, you can use `module_load_include()`. However, note that if the including files print anything, they will be printed to the current output buffer (which means they will be printed on user browser).

Given the above available features, I think it's `theme()` that you are looking for.

---
Tags: 7, theming
---


# Question
Title: When creating a custom form, how does one store the data in drupal db and then retrieve for display?
I'm new to Drupal and things that seem easy are apparently abstracted to oblivion.

I've created a module that displays a survey form. I would like to collect the data and store it in the database, and then allow the admin of the site to view the data that has been collected.

What is the "Drupal way" to do this?

Thank you in advance!

```
<?php

function member_survey_menu() {

  $items['member_survey'] = array(
    'title' => t('Member Survey'),
    'page callback' => 'member_survey_form',
    'access arguments' => array('access content'),
  );
  return $items;

}

function member_survey_form(){

    $output = drupal_get_form('member_survey_my_form');
    return $output;
}

function member_survey_my_form($form_state){
    # the options to display in our form radio buttons
    $options1 = array(
      'Strongly Agree' => t('Strongly Agree'),
      'Agree' => t('Agree'),
      'Neutral' => t('Neutral'),
      'Disagree' => t('Disagree'),
      'Strongly Disagree' => t('Strongly Disagree'),
    );

    # the options to display in our form radio buttons
    $options2 = array(
      'Very Satisfied ' => t('Very Satisfied '),
      'Satisfied' => t('Satisfied '),
      'Neither Satisfied or Dissatisfied' => t('Neither Satisfied or Dissatisfied'),
      'Dissatisfied ' => t('Dissatisfied '),
      'Very Dissatisfied ' => t('Very Dissatisfied '),
    );

    $form['knowledgable'] = array(
      '#type' => 'radios',
      '#title' => t('Question 1'),
      '#options' => $options1,
      //'#default_value' => $options['Neutral'],
    );

    $form['satisfied'] = array(
      '#type' => 'radios',
      '#title' => t('Question 4'),
      '#options' => $options2,
      //'#default_value' => $options['Neutral'],
    );

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

  return $form;
}

// Validate the form submission
function member_survey_my_form_validate($form, &$form_state){
    if(empty($form_state['values']['knowledgable']) ||
        empty($form_state['values']['satisfied'])
    ){
        form_set_error('knowledgable',t('Please respond to all questions, thank you!'));
    }

}

?>

```

# Answer
> 2 votes
**A specific answer:** you can use `sumbit hook` to store data. see Submitting Forms: http://drupal.org/node/751826

**A general answer:** follow this guide related with creating, theming, validating, submitting, storing data, and understanding the flow in Drupal 6 forms: Form API Quickstart Guide http://drupal.org/node/751826

to retrieve data you can use these guidances:

db\_query documentation http://api.drupal.org/api/drupal/includes--database.pgsql.inc/function/db\_query/6

Database abstraction layer http://api.drupal.org/api/drupal/includes--database.inc/group/database/6

also you can review Examples module http://drupal.org/project/examples specifically the module dbtng\_example to database examples or page\_example to build a static page add your retrieved information. please note that dbtng\_example module is only for Drupal 7, but reviewing this module you will have more ideas about what to review in Drupal 6.

also could be useful the "Module developer's guide" to dive in tutorials/examples about how build forms and retrieve data using modules http://drupal.org/developing/modules

# Answer
> 2 votes
What you need is the form submission handler, which is the function called when the form is submitted. By default, Drupal uses a function that is named after the form build handler, with "\_submit" appended. In your case, that function is `member_survey_my_form_submit()`, and it takes the same parameters passed to `member_survey_my_form_validate()`.

As for saving the data, you first need to decide the structure of the database table you use to save the data; in particular you need to decide which primary keys to use.
Considering the form is for a survey, and supposing each user can submit just a survey, then I would use the user ID as primary key. The database table would have a structure similar to the following one:

* Fields
    + uid
    + knowledgable
    + satisfied
* Primary keys
    + uid

For the code, I am also making the assumption users are not allowed to edit their survey; the code just avoid saving the data if there is already data for that user ID.

```
function member_survey_my_form_submit($form, &$form_state) {
  $values = $form_state['values'];
  $values['uid'] = $GLOBALS['user']->uid;

  if (!db_result(db_query("SELECT 1 FROM {survey} WHERE uid = %d", array($values['uid'])))) {
    // There isn't a database row for that user.
    drupal_write_record('survey', $values);
  }
}

```

Replace "survey" with the database table name.

# Answer
> 1 votes
I don't know if you are still looking for anwser but Webform module covers your case. From docs:

> Webform is the module for making surveys in Drupal. After a submission, users may be sent an e-mail "receipt" as well as sending a notification to administrators. Results can be exported into Excel or other spreadsheet applications. Webform also provides some basic statistical review and has and extensive API for expanding its features.

To see what data is stored in DB just log to database and do a query `SELECT * FROM webform_submitted_data;`.

# Answer
> 1 votes
Make an install file first. Create your schema for form. Then in the `.module`-file, write insert query in submit handler of form:

```
function _my_component_add_form_store_edit_submit($form, &$form_state) {
  if(isset($form_state['values']['cid'])) {
    db_update('mid_components')
      ->fields(array(
        'title' => $form_state['values']['human_name'],
        'machine_name' => $form_state['values']['name'],
        'description' => $form_state['values']['description'],
        'options' => $form_state['values']['wizard_key'],
      ))
      ->condition('cid', $form_state['values']['cid'] )
      ->execute();
    drupal_set_message(t('Record has been updated.'));
  }
  else {
    // Here u can insert Your custom form values into your custom table.
    db_insert('mid_components')
      ->fields(array(
        'title' => $form_state['values']['human_name'],
        'machine_name' => $form_state['values']['name'],
        'description' => $form_state['values']['description'],
        'options' => $form_state['values']['wizard_key'],
      ))->execute();
    drupal_set_message("successfully saved details.");
  }
  //$form_state['redirect'] = 'admin/people/survey';
}

```

# Answer
> 0 votes
This is the PERFECT series tutorials about DRUPAL 6 form, module and table. I think, it will help you so much: http://webemania.com/blog/how-to-create-custom-form-in-drupal

---
Tags: 6, forms
---


title: Using Cron and CURL in a custom module

text:
# Question
Title: Using Cron and CURL in a custom module
I am using a hook\_cron (mymodule\_cron) in my custom module, but would like to know whether the cron run is successful or not and has sent the data using CURL, and from there, update a specific column value in my sql table. How to get this status?

Part of my codes:

```
$options=array(
    CURLOPT_URL            => $urlCron,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HEADER         => false
);

$CURL=curl_init();
curl_setopt_array($CURL,$options);
$content=curl_exec($CURL);
curl_close($CURL);

```

# Answer
You can utilise watchdog at the end of your hook\_cron implementation, then implement db\_update to update your desired table.
> 2 votes

---
Tags: 7, database, cron
---


# Question
Title: Delete/Edit selected record from rendered tabular form results
I have made a form and retrive form submissions into a tabular format. I put 2 links ahead every single submission - ***Edit/Delete***

Now, when I click "**edit**", its corresponding **edit form** should open. Similarly, when I click "**delete**", that particular entry should get delete from database.

I know it's pretty simple doing in php, but don't know how should i do in Drupal. Please help.

Some code that I practiced: first I created a menu to show results of my form.

```
$items[MID_MENU_PARENT . '/component/show'] = array(
    'title' => 'Component List',
    'description' => t('Records'),
    'page callback' => 'component_list',
    'access arguments' => array('administer site configuration'),
    'file'=>'component_list.inc',
  );

/**
   * My callback function
**/
  function component_list(){
       $query = db_select('mid_components', 'n')
               ->fields('n')
               ->execute();
       $rows = array();
       while($data = $query->fetchAssoc()){
      // Fill the table rows
       $data['operation'] = l(t('Delete'), 'admin/mid-modules/component' . $data['cid'] . '/delete');
       $data['operation'] .= "|";
       $data['operation'] .= l(t('Edit'), 'admin/mid-modules/component' . $data['cid'] . '/edit');
       $rows[] = array('data' => $data, 'style' => 'word-break:break-all;',);
  }

 // Prepare table header
  $header = array( t('S.No'),t('Component Name'));
  // Output of table with the paging
   $output = theme_table(
     array(
           "header" => $header,
           "rows" => $rows,
           "attributes" => array(),
           "sticky" => true, // Table header will be sticky
           "caption" => "",
           "colgroups" => array(),
           "empty" => t("Table has no row!") // The message to be displayed if table is empty
         )
      );
  return $output;
}

 /**
   * Menu href to edir particular entry
 **/
    $items[MID_MENU_PARENT . '/component/%show/edit'] = array(
          'title' => 'Edit Component item',
          'page callback' => 'component_list_edit',
          'page arguments' => array(3),
          'access arguments' => array('administer users'),
          'type' => MENU_CALLBACK,
     );

```

# Answer
Not sure what your real question is (there is no "question" in your question ...), so consider editing your question to make that clear.

But I would give it a try to add a `/` in front of the 2 (similar) lines containing `admin/mid-modules/component` (so that they are changed to `/admin/mid-modules/component`). So both for the "delete" and the "edit".
> 0 votes

---
Tags: 7, forms
---


# Question
Title: Custom currency in Drupal Commerce Shopping cart summary views
I need to display at the top of the default currency in drupal commerce view the specific currency at the Shopping cart summary view. Something like on the image

I tried to ad a custom field if footer tof that view but there is no currency options.

Any idea how to do that?

# Answer
> 1 votes
I manage to do this using Views PHP module. The variable $results contains the array of all the data.

For "Shopping cart form" and "Shopping cart summary" view you have to add to footer this to the output value of Global: PHP:

```
<?php
$amount = 0;
foreach ($results  as $result) {
$amount = $result->field_commerce_total[0]['raw']['amount'] + $amount;
}
$converta = commerce_multicurrency_conversion($amount, 'HRK', 'GBP');
$formatcu = commerce_currency_format($converta, 'GBP');
echo $formatcu;
?>

```

To the "Commerce add to cart confirmation" you haw to ad to fields Global: PHP output code:

```
<?php
$amount = $data->field_commerce_total[0]['raw']['amount'];
$converta = commerce_multicurrency_conversion($amount, 'HRK', 'GBP');
$formatcu = commerce_currency_format($converta, 'GBP');
echo $formatcu;
?>

```

---
Tags: views, commerce
---


# Question
Title: How to create new group for products in drupal commerce?
I am using the Drupal Commerce module (in Drupal 7) for products.

I need to create different-different group like phone and shirts. And need to add parameters for phones.

Also I need variation by using taxonomy.

Please refer to the image below for more details:

Some more details:

* I am using 2 attributes: **Color** and **Memory**, implemented as taxonomies (vocabularies). But they are not showing as a select list on the cart page.
* **Color** is a vocabulary, with terms in it like black, silver and red.
* I added Color on product type fields and checked 'attribute option'.
* But still this widget not showing up on the cart page (it's only showing the selected value).

Or to phrase it in yet another way: I need attribute on cart page. I have added attribute by using taxonomy, but it's giving me only a link. Which means that when I select 'black', then it only shows 'black color' on the cart page (it does not show a 'select option').

# Answer
> 1 votes
I guess you need to create a new product type (since you want to add "parameters", which I assume are "fields") :

```
/admin/commerce/products/types/add

```

Then add fields to your new product type (picture, size, screen resolution for phones...), choose chich fields will be used as attributes (like size for shirts), then create products using this new product type, then create a new product display (which is a regular node with a multiple product reference field) for this product type and reference your products with the product reference field on the product display. You can also use an existing product display to display all your types of product (in this case you have to allow the product display's product reference field to reference products of the new product type first).

Note that if you have several attribute fields, you need to create as many products as there is possible combinations. Say you have 3 sizes (S, M, L) and 2 colors (red, blue), you need to create 6 products :

* S blue
* S red
* M blue
* M red
* L blue
* L red

You may consider using Commerce Product Option or similar module for your use case.

It can be confusing at first, but the Drupal Commerce way of dealing with products is really effective.

Good luck

**EDIT**

To make a field act as an attribute on your add to cart form (i.e shirt sizes : a drop down with XS, S...), you need to define a field on your product type (see my URL), then on the manage field form (admin/commerce/products/types/your\_product\_type\_machine\_name/fields/your\_field\_machine\_name), you need to check the checkbox "Enable this field to function as an attribute field on Add to Cart forms".

Then you create your product, one with size S, one with size M, one with size L (so you have 3 products, one per size), on your product display you set up references to the 3 product variations (S, M, L), and there it is, on your product display page you'll find a drop down allowing to choose the size in the add to cart form. When selecting a size, the node fields are refreshed with AJAX (you can see it as an AJAX product selector).

This system allows you to have different SKUs and prices for each variations. Typically, everything that needs to be different across products variations (SKU obviously, but maybe price, maybe the product picture) needs to be represented by a field on the *product* (each product has its own field value). Everything that is the same across product variations can be represented by a field on the *product display* (which is common to several products.

See here for official doc.

Hope it helps and sorry for my english, not my first language.

# Answer
> 1 votes
# Option 1 - Use Commerce Backoffice

As mentioned also in one of the comments, managing products (and orders) can be confusing. However, the Commerce Backoffice module helps with that. Especially because of the ***auto creation of product display nodes***.

So consider using the Commerce Backoffice module. It provides the backoffice functionality present in Commerce Kickstart (V2). It contains these sub-modules:

* Commerce Backoffice **Product** (commerce\_backoffice\_product).
* Commerce Backoffice **Order** (commerce\_backoffice\_order).
* Commerce Backoffice **Content** (commerce\_backoffice\_content).

This module (and a few dependencies) provides the rich store owner experience that has made Commerce Kickstart 2 so popular (and prevents that you have to install the entire Commerce Kickstart distribution). And there is a great video introduction about it also.

**Note** (as suggested in a comment here also): if you use Commerce Backoffice, you most probably also want to use the Shiny administration theme, also used in Commerce Kickstart (V2).

# Option 2 - Roll your own cookies

If you're ready to possible get confused, and/or don't mind all the required effort (if you have a lot of "attributes" to configure), then you may want to go over the various steps as explained in these 5 videos.

---
Tags: 7, commerce
---


# Question
Title: How to remove the name of the language? Menu Language Icons
How to remove the name of the language? Use the module Language Icon, I want to make only the flags.

# Answer
On the configuration page of the Language Icons module, `admin/config/regional/language/icons`, you should set the option 'Icon placement' to 'Replace link'. If I'm not mistaken, choosing this option ensures only the flags are shown.
> 1 votes

---
Tags: i18n-l10n
---


# Question
Title: Migration is not able to find legacy database tables for some migrations
The hosting server I am using is Pantheon. I'm trying to migrate taxonomy over from D6 to D7 with a custom migration class. The problem is that I'm getting different behaviors on my local repo and the one on the server. On the server, I get an error saying that

> Migration failed with source plugin exception: SQLSTATE\[42S02\]: Base table or view not found: 1146 Table 'legacy\_database\_name.migrate\_map\_tdmchanneltermparent' doesn't exist, in /srv/bindings/3b34ee5b39e94f12ad1de632af512a5b/code/includes/database/database.inc:2171

I'm not sure why it is trying to connect to the legacy database for the map in this migration.

Here is my migration class:

```
class chalkTermParentMigration extends tdmTermMigration {
  public function __construct($arguments) {
    parent::__construct($arguments);
    $this->arguments = $arguments;

    $this->description = t('Chalk Term Parent Migration');

    $query = Database::getConnection('mig_dest', 'legacy')
      ->select('vocabulary', 'v');
    $or = db_or()->condition('v.vid', 10)
      ->condition('v.vid', 11, '=')
      ->condition('v.vid', 12, '=')
      ->condition('v.vid', 20, '=')
      ->condition('v.vid', 21, '=')
      ->condition('v.vid', 25, '=');
    $query->condition($or);
    $query->fields('v', array('vid', 'name'));

    $this->source = new MigrateSourceSQL($query);

    $this->destination = new MigrateDestinationTerm('chalk');

    $this->addFieldMapping('name', 'name');
    $this->addFieldMapping('field_legacy_id', 'vid');

    $source_key = array(
      'vid' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => 'Legacy Vocab ID',
      )
    );
    $this->map = new MigrateSQLMap($this->machineName, $source_key, MigrateDestinationTerm::getKeySchema());

  }

}

```

Here is how I have my legacy database connection information set up:

```
if (!defined(PANTHEON_ENVIRONMENT)) {
  $databases['mig_dest']['default'] = array(
    'database' => 'abc',
    'username' => 'abcdev',
    'password' => 'qwe123',
    'host' => 'localhost',
    'port' => '',
    'driver' => 'mysql',
    'prefix' => '',
  );
  $databases['default'] = $databases['mig_dest'];
} else {
  $databases['mig_dest']['default'] = array(
    'database' => $_ENV['DB_NAME'],
    'username' => $_ENV['DB_USER'],
    'password' => $_ENV['DB_PASSWORD'],
    'host' => $_ENV['DB_HOST'],
    'port' => $_ENV['DB_PORT'],
    'driver' => 'mysql',
    'prefix' => '',
  );
}

$databases['legacy']['default'] = array(
  'database' => 'legacy_db_name',
  'username' => 'uname',
  'password' => 'passwd',
  'host' => 'legacy_db_host',
  'port' => '',
  'driver' => 'mysql',
  'prefix' => '',
);

```

# Answer
> 2 votes
`legacy_database_name.migrate_map_tdmchanneltermparent` is a table typically made by the Migrate module to perform a mapping between source DB data and destination DB data. There is typically `migrate_map` table(s) and for instance `migrate_messages` table(s).

Be sure to properly `Import` or `Rollback` migrations. If you clearing the database by hand and dropping any of these tables, Migrate can get confused. Sometimes I occassionaly MySQL `Truncate` these tables by hand during my job workflow, but then you need to be careful and understand what migrate is doing -- how it's mapping processed data or registering migrations.

**EDIT**:

Then as a work around I suggest following the documentation for Map Tables heading section and *explicity* define the connection you want the mapping table created on. Since you have what looks like a local test migration setup and a Pantheon setup add this `... = new MigrateSQLMap( ... );` in an `IF` statement to point to the correct Drupal destination connection name.

> When you construct the MigrateSQLMap object, add a fourth argument to tell it explicitly the connection on which to create the mapping tables.

# Answer
> 2 votes
I had an error showing that:

> Migration failed with source plugin exception: SQLSTATE\[42S02\]: Base table or view not found: 1146 Table 'DESTINATION\_database\_name.migrate\_map\_migrationname' doesn't exist, in /code/includes/database/database.inc:2171 even though I have checked the database and the table is there... Was hitting my head against the wall for a while .. :)

Adding `map_joinable` option solved the issue for me:

```
$this->source = new MigrateSourceSQL($query, $source_fields, NULL, array('map_joinable' => FALSE));

```

Exception was gone and migration was running normally.

---
Tags: 7, migrations
---


# Question
Title: Couldn't avoid duplicates and merge rows on my views
I have a view of list of contents referenced in many others content types in my site. Lets talk about just 2 content types :
A content type called *container* is referenced in a content type *position*, so we say that the container has many positions.
*Container position* is a select list field in Position, for every item in this select list, there are some fields to fill.for example if I select 'on board' I have to fill the field 'date of loading', If I select 'in the shipper' I have to fill the field 'name of shipper'.
So in my view I want to display the list of containers with informations from the positions where they were: container;date of loading;port of loading; shipper.
When I created the view I get duplicated results for every container. I tried aggregation and distinct option, It not works, or it removes duplicates without merging the rows if use them both.

**Update:** My question is similar to this Views - adding relationship adds duplicate row for each relation

# Answer
> 0 votes
Consider using the Views Distinct module. From its project page:

> Relationships or other joins in Views often create "duplicate" results. For example, a node with a field that has multiple values may show up in the View once per value in the multi-value field. It's frustrating, and the "DISTINCT" SQL query option in the Views UI does not actually solve the problem because the result row is technically distinct. This module aims to give a simple GUI method to remove or aggregate these "duplicate" rows.

---
Tags: views
---


# Question
Title: how to get this functionality? views: Format options in ctool modal modify field data
In views module, when we edit view page and add fields to it, there is an option Format:unformatted-list and when we click on unformatted-list, a popup appears displaying radio buttons of grid, table,jump-menu, etc. Choosing any of the radio button, the field adjust themselves in either grid, table, whatsoever the option we choose.

I need the exact functionality of choosing radio buttons, modify my fields display output.

Thanks in advance.

# Answer
> 0 votes
You may use Display Suite module

> Display Suite allows you to take full control over how your content is displayed using a drag and drop interface. Arrange your nodes, views, comments, user data etc. the way you want without having to work your way through dozens of template files. A predefined list of layouts (D7 only) is available for even more drag and drop fun!

---
Tags: views, chaos-tool-suite
---


# Question
Title: Domain access - prevent redirecting to default domain on account creation
Drupal 7.36 & Domain access 7.x-3.x

I have 2x domains running curtesy of domain access. Each domain has been set up for 2 specific groups of users. The idea is that each group can create accounts, log-in and access content on their respective domain. Setting up the default domain worked fine. But, when users attempt to register on the second domain, they are redirected to the default domain instead, causing confusion.

I have Domain Strict enabled – plus I have tried Domain bonus, but the solution does not seem to be straight forward.

How you I prevent this from happening?

# Answer
> 1 votes
Apologies - it turned out that the default domain had been set as the base URL in the settings.php file. When a user requested an account, they were being returned to the default domain homepage

---
Tags: 7, domain-access
---


# Question
Title: Can the recently read module show multiple nodes?
I am working with the recently read module and it is only showing the last node visited. I want it to show the last 5 nodes visited and that seems like what the module is supposed to do. I have session API enabled so that I can have this available for anonymous users as well. Does anyone know why it is only displaying a single node?

# Answer
> 0 votes
From the content of your question, I have the impression that you misunderstand what the Recently Read module is about. More specifically (from its project page): it keeps track of "*... the history of recently read content (nodes) both to anonymous and authenticated users ...*".

Anonymous users is a special case, but for logged in users each user has his/her own "history".

Issue #1973526 also confirms that, here is part of what that says:

> Since you don't want your database getting forever more massive for no good reason (it is likely you will only ever be showing the last 5 or 10) it would be good to have an option to **limit the maximum number of entries in the recently read table for each user**.
>
> For example I can set it to 5 and the database would only ever have 5 entries per user at most.

It would be interesting to know, for your environment, how many nodes (more then one?) you visited with the user you are logged in with (if you are logged in). To remove any doubt about that, consider editing your question by adding some scenarios (+ results you get) like "user 1 visited node a, b and c; user 2 visited b, p, q, r, s, z, ..."; anonymous user visited k, l , m ..."

---
Tags: 7
---


# Question
Title: Q: How to control theme colors for Drupal 7 mass contact email
I'm using the *Corporate Clean* theme as the basis for my site. I've customized some theme colors to my liking. I have installed the *Mass Contacts* module to send bulk email. I've specified in the mail system configuration to use the *Corporate Clean* theme. The customizations do not appear to cause the following problem since I can't see any color settings that reflect what I'm seeing with the problem.

**Problem:**

The email that is received (via Thunderbird) is displayed with a dark gray background and light gray lettering. It is readable, although, I'd like to make it easier on the eyes. On my phone, it is unreadable - the text actually shows as black text on a dark gray background. I'm assuming that the color is specified somewhere in the theme or css. However, I have not been able to locate the settings that would allow me to change the color combinations. I've read a similar, but, old post but did not quite understand if there was a solution mentioned.

I'd like to get a better understanding of how to control the theme colors for email. Can anyone tell me how the colors are controlled and how I can change them?

# Answer
> 1 votes
After re-reading the post I mentioned several times, I found one of the comments to actually be the answer to my problem. That post, created by dwils03, indicated:

> In case anyone was looking for a quick and dirty fix, I just included a blank mail.css file in my theme's folder. The result is an html-formatted, NON-STYLED email.

I did the same and added an **empty** mail.css file in my theme folder and it solved my problem.

---
Tags: theming, emails
---


# Question
Title: problem with drupal_http_build_query output
am using drupal\_http\_build\_query and have part of my code as follows:

```
$or = db_or();
$or->condition('cid',$fField1);
$or->condition('cid',$fField2);
$or->condition('cid',$fField3);
$or->condition('cid',$fField4);
$or->condition('cid',$fField5);
$or->condition('cid',$fField6);
$or->condition('cid',$fField7);
$or->condition('cid',$fField8);

$querydata  = db_select('webform_submitted_data', 'wsd')
  ->fields('wsd',array('data'))
  ->condition('nid', $nodeID, '=')
  ->condition('sid', $sID, '=')
  ->condition($or)
  ->execute()
  ->fetchAll();

$result = array();
$i = 1;
foreach ($querydata as $qvalue) {
    $key = 'mapField'.$i;
    $result[] = array($$key => $qvalue->data);
    $i++;
}

$post_data = drupal_http_build_query($result,'', '&');

```

When printing the `$post_data` variable value, am getting something like this: `name=john&1[address]=street1&2[phone]=123456789`

Notice the `1[]` and `2[]` after the `&`in the printed value. Any fix to remove these so that I get `name=john&address=street1&phone=123456789`?

# Answer
You are getting that result because you build `$result` as an array whose values are array. Since `drupal_http_build_query()` contains the following code, the result you obtain is by design.

```
  foreach ($query as $key => $value) {
    $key = ($parent ? $parent . '[' . rawurlencode($key) . ']' : rawurlencode($key));

    // Recurse into children.
    if (is_array($value)) {
      $params [] = drupal_http_build_query($value, $key);
    }
    // If a query parameter value is NULL, only append its key.
    elseif (!isset($value)) {
      $params [] = $key;
    }
    else {
      // For better readability of paths in query strings, we decode slashes.
      $params [] = $key . '=' . str_replace('%2F', '/', rawurlencode($value));
    }
  }

```

You should change the code to the following one.

```
foreach ($querydata as $qvalue) {
  $key = 'mapField' . $i;
    $result[$$key] = $qvalue->data;
    $i++;
}

```
> 0 votes

---
Tags: 7, database, http-request
---


# Question
Title: Clean URL leads to duplicate URL after migration to another hosting
I have enabled clean URLs on the site after various article has been published on the site.

But when I migrate from Bluehost VPS to Bluehost Share hosting, the clean URLs is not accessible again. And when I remove `?q=` I will see the enable box, and it has lead to duplicate URL on articles on the site.

# Answer
To correctly enable/configure Clean URLs, refer to Configure Clean URLs in the installation guide.

If you're not familiar with Clean URLs yet, I suggest to review that documentation in the installation guide carefully (for the version of Drupal that you're using) and make sure your server is correctly configured before proceeding.

Here is a summary of common steps/issues:

* With Apache HTTPD as web-server, you have to enable `mod_rewrite` and configure the necessary rewrite rules in the `.htaccess` file.
* Usually, theses rules are applied automatically, when `mod_rewrite` is enabled. But in some cases, the `AllowOverride` directive is too restrictive to allow this.
> 0 votes

---
Tags: uri
---


# Question
Title: Is there a way to link a menu item to the edit page of the last article?
I want to create a **menu item** linked to the edit page of the **last article**.

I created a view and added filters to get the last article. I added only the field node path to the view.

But how can I get the value of that path field and put it in the URL of my menu item?

# Answer
> 1 votes
Yep!

Create a view that loads the single last published article, style the view to look like your regular node page and then add a link to the view in your menu.

you could get fancier, but this is the least amount of PHP.

# Answer
> 1 votes
Thank you DeveloperWeeks , i followed your instructions and made the below code , and it's working like a charm :

```
  <?php
/**
* @file
* Use this module to get the last NID of a defined Content Type
*/

/**
* Implementation of hook_menu().
*/

function lastnode_menu() {
$items['lastnode'] = array(
'title' => 'Edit ADS',
'page callback' => 'lastnode_edit',
'access callback' => 'user_is_logged_in' ,
'type' => MENU_CALLBACK,
);
return $items;
}

/**
* Page callback.
*/

function lastnode_edit ($content_type = '') {
$nid = db_query('select MAX(nid) from node where type = :type', array(':type' => $content_type))->fetchField();
drupal_goto('node/' . $nid . '/edit');
}

```

# Answer
> 0 votes
I like user5482's answer, and it is a good one. If you are logged in, and the view is using "rendered entity" instead of "fields", the Edit context link would be accessible from there and you would have your answer in two clicks and no code.

If you truly want one click that goes straight to the edit page, you will need a custom module. You will need to implement hook\_menu in your module, and register a static path. In that hook you should define the access callback as using the appropriate drupal permission; I think you want to find the edit instead of the generic access\_content.

You will also need to define a custom callback function that will have the dynamic query to find the most recent (published?) node from the database, construct the url, and execute a drupal\_goto to take the user there. This way you can have a static address (good for menus) link to a dynamic location (most recent node edit page).

But again, all this custom code work will only save you one click over user5482's answer. Since I cannot think of a reason you would want anonymous users editing nodes, I am guessing this is a menu item for admins only. That extra click shouldn't destroy the ux.

---
Tags: navigation, views
---


title: Views PHP is outputting incorrectly

text:
# Question
Title: Views PHP is outputting incorrectly
I'm trying to work with Views PHP but for some reason something is going completely wrong. I have a content field called telephone. In this field is a number "06-12345678" now I want to use Views PHP to remove the "-" so I get the number "0612345678".

What I do is I make a view with the field Telephone and a Global: PHP field underneath it. In this Global: PHP field I add the following code to see if it is working.

```
<?php print $row->field_telephone; ?>

```

So when I save this field I get the output: "11" instead of 06-12345678.

When I try `<?php print $row->field_title; ?>` it does give me the suspected output..? What am I doing wrong? How can I solve this?

# Answer
> 1 votes
```
$data->field_field_telephone[0]['raw']['value'];

```

This will give you your value from that field in `Views PHP`. If you use dpm() from Devel module it will show you that `$row->field_telephone` is 11. that's the NID.

Try to avoid using Views PHP unless you are doing something too complex for views. And even then you should try to write a custom module to interact with views instead of saving code in the DB.

---
Tags: views
---


# Question
Title: How to remove the caption in gallery caption module?
I'm using Gallery formatter, how to remove the caption? But I want to leave the title and alt parameters.

# Answer
> 0 votes
You can copy file galleryformatter.tpl.php from Gallery formatter module to your folder theme. And remove some code line 28-\>35

```
<?php if (!empty($data['title']) || !empty($data['alt'])): ?>
            <div class="panel-overlay">
              <div class="overlay-inner">
                <?php if ($data['alt']): ?><h4><?php print $data['alt']; ?></h4><?php endif; ?>
                <?php if ($data['title']): ?><h3><?php print $data['title']; ?></h3><?php endif; ?>
              </div>
            </div>
          <?php endif; ?>

```

And clear cache.

---
Tags: media
---


title: How can I run cron.php via crontab?

text:
# Question
Title: How can I run cron.php via crontab?
I'm trying to run cron.php via a cron job set up in crontab on my server via the following command (running every 2 minutes purely for testing while I try and get it working - it will be every 6 hours when fixed);

```
*/2 * * * * /usr/bin/php -q /var/www/www.mysite.com/crontab-cron.php >>/var/log/server-cron.log 2>&1

```

The crontab file was needed to work around an error with the include file locations and looks like this;

```
<?php
$doc_root = dirname($_SERVER["SCRIPT_FILENAME"]);
chdir($doc_root);

include_once './cron.php';
?>

```

However now I'm receiving the error (shown in the cron log file)

```
PDOException: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) in lock_may_be_available() (line 167 of /var/www/www.mysite.com/includes/lock.inc).

```

I've come across a few suggestions mentioning creating a new database user with the same permissions and changing those details in `settings.php` but that's not making any difference.

Any ideas how to get this working? I just need to run the cron job via crontab.

# Answer
You could run the cron URL that Drupal provides in *Administration \> Configuration \> System \> Cron*.

And in your crontab, instead of invoking the cron.php file individually (won't work), you just have to invoke a URL. This can be done with wget, lynx, curl, etc. E.g.:

With wget:

```
0 * * * * wget -O - -q -t 1 http://www.example.com/cron.php?cron_key=<key>

```

Configuring cron jobs using the cron command
> 6 votes

# Answer
If you go to Configuration \> Cron you can see a URL that can be used to trigger cron from outside the plattform without being logged in.

Use this URL in crontab so you do not need care about users etc.
> 3 votes

# Answer
See the documentation at http://www.drush.org/en/master/cron/

The relevent line:

```
10 * * * * /usr/bin/env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin COLUMNS=72 /usr/local/drush/drush --root=/path/to/your/drupalroot --uri=your.drupalsite.org --quiet cron

```
> 1 votes

# Answer
I'm using simple command

```
*/2 * * * * cd /path/to/your/drupal && drush cron

```
> 1 votes

---
Tags: database, cron
---


# Question
Title: How do I override a taxonomy/term/% list with a view?
I have a vocabulary attached to a content type. Only one term can be selected to categorize a node made with this content type. The vocabulary is called Vehicles and has terms 'cars, trucks, boats.' The content type is also named Vehicles.

I use path auto so that it shows \[vocabulary:name\]/\[term:name\] so when rendered it will show site.com/vehicles/trucks, for example, which will show all the trucks... typical Drupal stuff.. Ok...

Now, I have a View that is a page with a path 'vehicles.' It is setup to to display all of the items of content type 'vehicles.' This page view is also setup to take an argument 'taxonomy term id.'

Note that when the taxonomy term is present, the url alias generated for the taxonomy path is the exact same as as the Views page with an argument supplied:

URL Aliased taxonomy path = vehicles/trucks. Views page with argument = vehicles/trucks.

This is on purpose. My goal was to show all results of that content type when an argument was not present, and when it was present, it would most importantly filter the results based on that taxonomy term AND keep the same fields and structure as without the argument (same as site.com/vehicles).

The problem is, this is not working as expected. site.com/vehicles correctly shows my view and related filters. site.com/vehicles/trucks shows just the regular, unformated taxonomy list supplied by Drupal.

Is this because Taxonomy term ID argument is not configured correctly?

Is this a weight issue where taxonomy hooks are firing after Views? If so, how can I rearrange the weights here so that it fires correctly and gives me the results I need?

I know what you are going to suggest - that Views comes with taxonomy/term/% view to override drupal default views.

However, this is not going to work in my case. I have multiple content types each with its own vocabulary and each with its on view and distinct set of fields (houses and cars, for example have very different field sets). The taxonomy/term/% would work if all content types had the same fields, then I could just mimic those in that override, but since that is not the case, how can I correctly get my path with argument to show the results based on that vocabulary term and keep my field structure?

Sorry if that was confusing. A link to the site for reference http://www.buyagainbaby.com. The site does currently use taxonomy/term/% as an override, but again, that has to change so that each view is responsible for how it renders its result set based on taxonomy.

# Answer
All of these answers are great solutions, and thanks for taking the time to provide such infomative answers. Ashlar, your response taught me a lot about how taxonomy works works as well as the relationship between views and taxonomy.

I found a solution that works great for my situation, and I will share that in case it may help you guys too.

As I explained above, the my problem was that my view, with no argument, supplied the results I wanted, but the default taxonomy view with an argument, which was not what I wanted.

To solve this, I installed the module Taxonomy Display http://drupal.org/project/taxonomy\_display. I then reconfigured each view to have Taxonomy Term ID as an argument.

Taxonomy display lets you associate a vocabulary with a particular view. Now, when I click on vehicles/trucks, which is an alias for taxonomy/term/3, the view takes over and this is actually rendered correctly maintaining the integrity of the field structure.

If anyone wants to know more details about the configuration please let me know.
> 20 votes

# Answer
I believe there are several factors to consider in your setup:

* Every path must be unique to access a page, a term, a view, or a page panel If you have two pieces of content with the same address, you lose control of the display. Drupal gives taxonomy term precedence over Views so it will not be called. The View definition using taxonomy/term/# will intercept the taxonomy term, but as you indicated, does not display a meaningful URL.
* Views do not respond to aliases. That is because the first thing Drupal does with any request is to convert the alias to a node/nid format standard for all Drupal content. So in your case vehicles/trucks is converted to the node/# assigned to the view. View cannot take context from an alias directly.

To get what you want you do one of several things.

* Create a menu with the callbacks set to the path of your view. This will generate the correct URL and allow the View to respond.
* Use Panels with Page Manager (in Ctools Suite) enabled. If you define a Page Panel defined for the appropriate URL you can place your View in the panel pane or pass the context from the panel page directly to a Views content pane. A content pane does not have a path. Instead it takes the contexts such as the path, set by the page panel directly, to create its content. This video series at nodeone.se does an excellent job of demonstrating how to use panels and page manager effectively.
* Another way to get views content to the screen is to use quicktabs module. I don't think it fits your specific situation, but it also can directly tap into views by selecting the tabs you define for a page.
> 7 votes

# Answer
Views has a built-in view that emulates and overrides taxonomy terms. Simply enable it to override taxonomy listings with views.
> 4 votes

# Answer
I actually did a similar thing a few days ago. My solution isn't elegant but it works. What I did was to override the Taxonomy term display using Panels, not Views. I then added all of my different views for each term to the Panels content area. Since in my case each view has a filter that limits it to results of a particular vocabulary, when you visit the taxonomy term page, it shows only the view for that particular vocabulary.

Let me know if you need more information about how I implemented this.
> 2 votes

# Answer
A great solution has been proposed by WebbyKat, to set your page path to `/taxonomy/term/%` instead of `/categories/%`

It works, but it will rewrite all of your terms into one View.
> 1 votes

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


# Question
Title: How do I get clean output (without menus, header, footer, etc.) in Drupal?
I need only processed content of particular theme file (mytheme.tpl.php) using the theme() function. How do I get rid off header, footer and other stuff on the page? And it will be good not to touch main theme page.tpl.php or anything else except module internals.

Probably there is something like:

`return DRUPAL_CLEAN_OUTPUT(theme('my_theme',array('html' => $html)));` ?

# Answer
Just print it from your page callback rather than return it. Drupal will only invoke the theme wrappers for the html/page when you return something from your callback.

```
function MYMODULE_some_page_callback() {
  print theme('my_theme', array('html' => $html);
}

```

The other method is to set an explicit `delivery callback` for your menu item, to be used in place of the standard `drupal_deliver_html_page()` method. See the `hook_menu()` docs for more details.
> 3 votes

# Answer
Also used the delivery callback like this:

```
function HOOK_menu() {
  $items['mymodule/blah.xml'] = array(
    'title' => 'RSS Feed',
    'description' => 'RSS feed of blah blah',
    'page callback' => 'rss_feed',
    'delivery callback' => 'deliver_plain',
    'access arguments' => array('access content'),
    'file' => 'blah.inc',
  );
}

```

Then my callback looked like this, so it could skip calling drupal\_render\_page:

```
function deliver_plain($page_callback_result) {
  print $page_callback_result;
}

```
> 2 votes

# Answer
If you want to remove all regions except the *Content* one from some of your pages page, you can use `hook_page_alter()` to hide them:

```
function MODULE_hook_page_alter($page) {
  if (some_condition()) {
    foreach (element_children($page) as $region) {
      $page[$region]['#access'] = ($region == 'content');
    }
  }
}

```

The removed regions' contents will still be build, with any side effect they may have. But the content of the regions will not be rendered. So, for instance, `hook_block_view()` implementations for enabled blocks in the hidden regions will be called. Any CSS or JavaScript files added with `drupal_add_css()` or `drupal_add_js()` will be included in the page. But any CSS or JavaScript files added through the `#attached` property in their `content` (if returned as renderable arrays) will not be included in the page.
> 1 votes

# Answer
I was trying to create a custom menu callback without other regions for a splash page that would be viewed via an iframe for new site visitors, but I still wanted the theming for the site. Pierre's suggestion is perfectly fine, and easy to implement, but wanted to try another approach that would avoid having to loop over every region of every page for every page request. So instead I implemented my own "delivery callback" for my menu router item (https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook\_menu/7), which was basically a straight copy of drupal\_deliver\_html\_page() https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal\_deliver\_html\_page/7, with the exception of a single line

```
 elseif (isset($page_callback_result)) {
    // Print anything besides a menu constant, assuming it's not NULL or
    // undefined.
    print drupal_render_page($page_callback_result);
  }

```

Became...

```
 elseif (isset($page_callback_result)) {
    // Print anything besides a menu constant, assuming it's not NULL or
    // undefined.
    print my_custom_render_page_function($page_callback_result);
  }

```

My custom function pretty much stayed the same, except I added Pierre's foreach loop just before the return statement:

```
  // Hide all but the content area for a splash calback.
  foreach (element_children($page) as $region) {
    $page[$region]['#access'] = ($region == 'content');
  }

  return drupal_render($page);

```

This way I'm not repeating the same unnecessary logic on every page to support a use case for ~1% of page requests. Whether this is worth it is up to debate, it is a lot of re-implemented core code that would now have to be maintained outside of the Drupal community.
> 1 votes

---
Tags: theming
---


# Question
Title: How to theme views using Taxonomy Terms?
The site on which I'm working has a variety of views for multiple sections of the website. These different sections, which are defined by Taxonomy terms, use different themes. So, for example, sections 'X' and 'Y' each have views which we want to be displayed in themes 'X' and 'Y.'

Is there a way in Views to assign the page created by Views a taxonomy term, so that, using ThemeKey, it can be assigned a theme by it's taxonomy term, like the other nodes with that taxonomy term?

I'd really like to do this without using templates, so that it can be easily managed within Drupal's UI.

# Answer
In your comment you said : `Currently, it is configured to use the URL of a page to determine the theme that page will take` so by this assumption:

Use `hook_preprocess_views_view` as follow and suggest your theme

```
function YOURTHEME_OR_MODULE_preprocess_views_view(&$vars) {
$path = current_path();
$view = $vars['view'];
switch ($view->name) {

case 'SOME_VIEW_NAME' :
  if($path == "SOME_PATH1_OR_PATTERN1")
       $vars['theme_suggestion'][] = 'views_view__custom_blocks';

  if($path == "SOME_PATH2_OR_PATTERN2")
       $vars['theme_suggestion'][] = 'views_view__ANOTHER_custom_blocks';
break;

case 'ANOTHER_VIEW_NAME' :
  ;
break;

}
}

```

If the first condition get satisfied create file `views-view--custom-blocks.tpl.php` and theme your view.

you can also use `hook_preprocess_views_view_fields` to set the values of the variables of the view.
> 0 votes

# Answer
Are you saying that you are using the not-yet-stable 7.x module Taxonomy Theme? Terms are assigned by Term Reference fields on fieldable entities. Since drupal is open source, there is always more than one way to do something. If you wanted to build a site that can do exactly as you have asked here, then I suppose it is possible to make a new entity that has a term reference and also embeds the view in its custom theme processes to get the fusion you are requesting. You will have to crawl into the Taxonomy Theme module code and see if it is using hook\_node\_view to do the check/change. If so, it would not fire on a straight view anyway but this custom entity (maintenance nightmare) should trigger it.

An easier method would be the template files that you dont want. Use theme\_hook\_suggestions where you have different tpl.php files for the different views based on path or whatever else you want. Different templates by path alias. You then just have the different templates use the different theme styles. I would also recommend putting the taxonomy term values as body level css classes so you can have one theme, and it just trigger different stylesheets based on term classes. Option1 | Option2 This would relieve your dependence on the dev-version module.

Option 3. In whatever theme is your default, copy the relative style sheets over from the other themes and just use the view-specific css class for each one, applying it manually. This means that you have duplicated style commands, so it will be a little harder to maintain what is coming from where, but at least you dont have to code any php.

Option 4. Sareed's comment about using block displays and embedding the views on other pages that have the terms. (...I should have thought of that)
> 0 votes

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


# Question
Title: Aggregate & Compress CSS / JS Kills Metatag Fieldsets
I had to turn on aggregate and compress CSS and JS for my site as the performance was terrible and I was getting a lot of CSS errors (admin bar would disappear intermittently or not load correctly or other CSS errors)

Activating the aggregation improved page load times dramatically and solved all my other CSS issues, however, now I get an error with the metatag module in which the field sets for Open Graph, Facebook etc. won't load as hyperlinks which can be expanded, only plain text.

The issue seems limited to the blog content type.

Any ideas where I can look to solve the issue?

# Answer
> 0 votes
Most likely there is a parse error in a JS and or CSS file. Check the console for any error; fix them and try again.

---
Tags: theming, meta-tags
---