# Question
Title: OR condition in Views Contextual Filters
I have a Content Type named "Match" which has a local and visitor. Both are node references to a Content Type named "Team".

In Views I need to ask for matches of a specific team, no matter if that team is the local or the visitor. In contextual filters I can set a value for "local" and for the "visitor" each one in particular. So I guess I need an OR condition in this case.

Does anyone know how to solve that problem?

**Edit**: I found Views Contextual Filters OR module already but that's the problem, my website is too big and currently in production so we don't want to have problems because of bugs or something.

# Answer
> 2 votes
## Drupal 7:

If using D7, then consider module Views Contextual Filters OR (which only has a dev version today). Excerpt from its project page:

> ... provides a views plugin which modify query to support OR conditions for contextual filters.

A few issues on Drupal.org that may be of some help:

There is also this comment in the support forum.

StackOverflow.com contains yet another approach to consider as an alternative.

Maybe you should look at Alter a Views query to use "OR" through the user interface also (it might help to change change your mind about the Views Contextual Filters OR module anyway). Because 3,855 reports installs of that module is not nothing, right?

## Drupal 6:

If you're still using D6, then maybe module Views OR is what you are looking for? Excerpt from its project page:

> By default, each record in a view must match all filters. Sometimes records need to be included if they match one or more filters in a list of alternatives. Views has the ability to combine filters only with AND. If one filter is false, the combined list will be false. Views Or adds the ability to combine blocks of filters with OR. If one of the filters in the block is true, the combined block will be true.

## Note about the "my website is too big" ...

That's perfectly understandable. But that also implies that you should really invest in setting up some kind of testing / staging environment where you have like a mirror of your production environment. So that in THAT environment you can safely experiment / review / finetune what's needed, without impacting your production environment. And after you found the fix in that environment, you should have a process in place to actually MIGRATE it to the production environment ...

A pretty forward (simplistic) approach to this is to transform your existing production site into a multi site setup, whereas you do not change anything to the production site version, but you just add 1 (or more) sites like 'test', 'QA', 'User Acceptance Testing'. These extra sites mostly use the same code base (as production), but with their own copy of the Drupal database. And code changes (or extra modules to be added), first go in site specific subdirs. After they get approved, they are "promoted" to the "all" subdir.

---
Tags: views
---


# Question
Title: How do I PUT update on a node using services 3
I have a node with field\_order\_status field(not required) in list(text) type and radio button widget and I want to update a node(nid:95) but my sample JSON PUT content(application/json) throws Status 406 Error:

```
{"form_errors":{"field_order_status][und":"An illegal choice has been detected. Please contact the site administrator."}}

```

my content is:

```
{
  "field_order_status":{
    "und":[
      {
        "value": "1"
      }
    ]
  }
}

```

sample url:

```
http://localhost/caesarschickencms/createorder/node/95

```

Services 3.4, Drupal 7.22

**Notes:** When I tried replacing und with other values like 'en', it accepts but not updates, refer to drupal 7 + services 3 - inserting nodes with select fields

And Devel page vars dump:

What would be missing?

# Answer
What Services version do you use?

Since Services 7.3.4 we deen to set **Cookie** & **X-CSRF Token** on header for every (PUT/POST) execution

Please check this comment too https://drupal.org/comment/6491362#comment-6491362
> 2 votes

# Answer
I don't think it's an issue with X-CSRF Token because the error send by server will be different.

But Drupal expect a value like "payment\_to\_valid", "order\_shipping", "checkout\_login" or "Pending".
> 0 votes

---
Tags: javascript, users, services, 8
---


# Question
Title: Same View, different displays, One page, same exposed filters. Possible?
I want to list my content categorically within view. The problem is that I want all of it to be filtered through exposed filters.

Here is what Content Type looks like:-

## Content Type (MyContent)

* Title
* Body
* Category `(it has three categories in it "Category1, Category2 and Category 3". User has to selects one when entering the content)`

Now I created a view which lists all of the content linearly (like a normal list) and I have exposed filters on top, which filter the content, but now I am not sure how to proceed when I have to show the content as:-

Any Idea what I should do to achieve this? What should I do in this scenario?

I'll be grateful to you valuable assistance.

Best.

# Answer
So I solved this by using Attachments in my view.

Each attachment had a separate filter.
> 0 votes

---
Tags: views
---


# Question
Title: Is there a trick to deploying Commerce Kickstart 2
When I deploy my commerce kickstart 2.0 site, it doesn't display correctly. Namely, it doesn't seem to be using the themes. But really, I am not sure what is going on. I have done development using Acquia Dev. I exported my database using the Backup and Migrate module.

This is the site http://twelvebasketstech.com

I can't even log in, but it is accessing the database because I see some of my product categories.

I am using PHP 5.4. The server is running the following: Server version: Apache/2.4.12 (Unix) Server version: 5.5.42-cll MySQL Community Server (GPL)

I have set the sites/default/files folder to chmod -R 775

# Answer
> 1 votes
Missing display/designs/CSS rules are typically a symptom of missing stylesheets or other CSS style rules. If you browse to your login page, Drupal reports many errors about not being able to create files.

It looks like your intuitions are likely correct; the server is probably having trouble writing aggregated CSS files to the files dir. Try turning off CSS/JS aggregation to confirm this. If that fixes it, check ownership of the files dir/subdir to make sure it's the same owner as the web server process.

---
Tags: commerce
---


# Question
Title: How to customize my front page with background image?
I have site for which I need to design a custom front page using my sub-theme with page page--front.tpl.php.

I need to place a background image and on title at left alignment and little bottom thre image background buttons and in that bottom center need to place on caret with hyperlink which will take you to rest of the half page.

Any suggestion?

# Answer
> 0 votes
Try eiher of hese searches:

Pick any of the proposed answers that fits best your needs. Such as a solution that is based on using something like firebug to find the CSS file that allows you to adapt your background to fit your needs.

---
Tags: 7
---


title: How to rollback jQuery Update module?

text:
# Question
Title: How to rollback jQuery Update module?
I accidentally update jQuery version from 1.5.2 to 1.82 using Drupal's jQuery update module. Is there any way to rollback the update and go back to my 1.5.2 version?

Changing the option exists only in the dev version. So I downloaded the dev version and set it to 1.5.2. However, now, I am getting this message:

> jQuery could not be replaced with an uncompressed version of 1.4.4, because jQuery 1.5.2 is running on the site.

Don't know what that means, because I am not trying to run 1.4.4.

# Answer
The following error comes from the Devel module. In the case you'd like to get rid of the message on every page, you should go to the Devel settings page (/admin/config/development/devel) and disable the *Use uncompressed jQuery* option.

> jQuery could not be replaced with an uncompressed version of 1.4.4, because jQuery 1.7.1 is running on the site.

To rollback the module, you need to disable and uninstall the old module, and install another one.

### Source

This is on EVERY single page in my installation.
> 1 votes

# Answer
Uninstall and then do a fresh start.

jQuery update won't break any of your existing code by uninstalling.
> 0 votes

---
Tags: javascript
---


# Question
Title: Services can not create an user with role
I follow this answer How to create user with role(s) through REST service?

```
{"name":"user343","pass":"kes35@r4","mail":"user343@sample.com","status":"1", "roles":["4"]}

```

But When I check the created user, It role still is '2' (authenticated user)

# Answer
> 0 votes
Just install `Auto Assign Role` Module.

Then use this following json code:

```
{"name":"user3431","pass":"kes35@r4","mail":"user343@sample.com","status":"1", "user_roles":{"6"}}

```

# Answer
> 0 votes
Same issue occured with me. I used rules module to assign a role on user account creation based on certain field data.Hope it helps

---
Tags: services
---


# Question
Title: Can I set Commerce to accept floats for quantity rather than just integers?
I have a specific requirement for a certain product type in Commerce to accept the line-item quantity as a float rather than an integer. Is this possible?

For example 5.34 rather than 5.

**The context**

* Product Type 'Tile' is sold in sqm (squared meters)
* User chooses required quality in sqm when they add to cart
* Drupal works out the minimum amount of tiles required for the chosen sqm value
* The sqm value is then adjusted based on number of whole tiles required
* Therefore sale price may be 5.12 sqm, if 5 sqm is required (because that is the specific sqm for X whole tiles.

# Answer
> 1 votes
Drupal Commerce supports decimal quantities, there just isn't a UI based configuration mechanism for using that vs. integer quantities. You have to alter the Add to Cart form and Shopping Cart form to change the #datatype property on quantity text fields to 'decimal' (or whatever you prefer) and then add appropriate validate handlers to ensure valid decimal values are being submitted. Search the code for *datatype* and you'll see the integer example code.

---
Tags: 7, commerce
---


title: Search API vs. Apache Solr Search

text:
# Question
Title: Search API vs. Apache Solr Search
I have been using the Apache Solr Search module in Drupal 6 and am looking at the Search API for a Drupal 7 install. I have seen some discussion here but I am looking for any reasons for choosing one or the other.

Is there a reason to choose one over the other? If so, why or why not? I have heard there may be complexity issues and/or performance issues with Search API. Is this true?

# Answer
> 19 votes
As of 2015, we can compare Search API vs Apache Solr Search modules with the numbers:

```
                   | Apache Solr Search  | Search API
Posted in:         | 2007                | 2010
Downloads:         | >2k                 | >20k
Reported installs: | >21k                | >64k
Total bugs:        | >1200               | >600
Active bugs:       | >200                | >170
Commits:           | >1.3k               | >1.5k

```

which indicates the clear choice. Search API was developed 3 years after and it managed to take advantage of its competitor.

Further more, Search API provides a very different and more flexible architecture and it's being maintained more actively. What is more important, it has already support for the newest Drupal 8 and Solr 5.x which Apachesolr doesn't have yet.

Search API started fresh and it's more flexible in its configuration including Views support (for Apachesolr you need the extra module). There are also plenty of modules which extend its functionality.

Secondly to avoid some problems being solved twice by the community due to differences in architecture of these modules, currently there are some combined efforts between these two projects such as:

* creating the common way to show facets blocks via Facet API (also know as filters),
* a common schema and solrconfig.xml configuration files,
* both maintainers worked together and migrated the connection classes from the Apache Solr Search module into Search API.

Source: Battleplan for Search & Solr in Drupal 8 at Acquia

Note, it's not advised to use both modules in the same environment.

For further technical analysis of differences, please check the details below.

## Search API

API Overview:

* Framework for easily creating searches
* Abstracts from data sources and backend implementations
* Large ecosystem with extensions, e.g. backends
* Facet API integration
* Heavily based on Entity API

+ Provides metadata
    + Used for index and server configurations

Extension features:

* Search API Autocomplete
* Attachments
* Saved Searches
* Location
* Pretty Facets Paths
* Slider (Search API Ranges)
* and many more.

Basic structure:

Index features:

* Different datasources
* One datasource: entities
* Based on Entity API:

+ Each property can be indexed
    + Properties of related entities can be indexed

How to configure your index - fields:

Search API Views:

* Full Views support
* Display any property of an entity
* Use any indexed field as filter, argument or sort
* Most code based on Entity API's views integration
* By default: data retrieved via entity load

+ Can be bypassed ("Retrieve data from Solr" setting in server)
* Alternative: Search API pages

Search API Recipes:

* CRUD hooks for indexes and servers
* Hooks for adding

+ data sources
    + backends
    + data alterations
    + processors
* Hook fired when indexing items
* Hook fired when executing a search

## Apachesolr

Extension features:

* Attachments (no media support, custom coding for attachments to other entities)
* Location (Apachesolr geo, Apachesolr location)

Apachesolr Recipes:

* Open Source Enterprise Search Platform
* Apache Foundation
* Full-text search, highlighting, faceted search, clustering, rich document handling
* Distributed
* Replication/scalable
* Java
* REST HTTP and answers in XML/JSON and some others
* Not Relational

Source: Search API vs Apachesolr slideshow

---

See also:

# Answer
> 24 votes
I've tried using both and I can say this: it depends on your situation.

Currently, the stable 7 release of the ApacheSolr Integration module can only index nodes. So if you have non-node entities that you need to index, you have to use the still in progress multientity patch for it. ApacheSolr Integration can store a lot of different data of content when configured properly.

The Search API does index entites and has a lot of wonderful stuff written for it. However, Search API only fetches the id of the data you are searching for. This means to load any more data other than the ID will require an entity\_load, hitting your database or whatever caching layer you put in place. For search-heavy sites, this might not be the most optimized solution.

Here is a great presentation given at drupalcon chicago about the ApacheSolr Integration module, minute 16 for mentions to Search API.

# Answer
> 2 votes
I think you really have to try both and make an informed decision. But consider strongly that apachesolr still does not have a beta for Drupal 8.

In Search API you cannot combine entities on the same SearchAPI index. So Profiles, Users, Nodes are on different indexes. There is a module to allow multiindex searches, it did not cover my needs, but YMMV. If you have many content types and many fields on the same index, the index definition can become quite unwieldly. (NB SearchAPI D8 reports to support multi index searching)

Apachesolr allows editing of fields on a per content basis which may be easier, but does not have the ability to add related content to a document, in fact expect to have to write some custom code to include information from field collections, references and some other fields. Apachesolr D7 does not support ajax, unless you use views, but using views you lose facets. That said ... modifying the information stored in the index is fairly easy if you are happy coding in hooks.

The idea of searching for entity ids and then rendering each one individually (can be used by both modules) would seem to be a performance nightmare, but, if you cache your entity displays it might well be more efficient than rendering from the solr response.

---
Tags: search
---


# Question
Title: how to add next and previous link on content full display page on tpl file in drupal 7?
I have a content type called flower and I have created a node--flower.tpl.php for displaying products.

I am also using category of flowers. I need to add next and previous links on this page for a specific category. For example if I'm on rose page then all roses are needed to show on next and previous link, not other category data.

# Answer
You will have to write this logic yourself in a `hook_preprocess_node()`. This code should be added to the `template.php` file of your front end theme.

Here's an example:

```
function YOUR_THEME_preprocess_node(&$variables) {
  // Perform the logic for selecting prev/next terms here. Install and use
  // the Devel module to see what is available to you and to debug the code.

  // See what's available:
  dpm($variables);

  // Load a sample term. Note: this should be different if your website is
  // in multiple languages. Below is just an example.
  $term = taxonomy_term_load($variables['node']->field_term[LANGUAGE_NONE][0]['tid']);

  // Pass a variable to the node--flower.tpl.php file. Code below will make
  // the $previous_category and $next_category variables available in the
  // node--flower.tpl.php file.
  $variables['previous_category'] = 'Your link here';
  $variables['next_category'] = 'Your link here';
}

```
> 0 votes

# Answer
Are you trying to get the previous and next node with a specific category? I'm not pretty sure but looks like in this case you have to do something like this in your node template

**(i haven't tasted it)**

```
$prev_nid = db_query("SELECT nid FROM {term_node} WHERE nid < :nid AND tid = TID ORDER BY nid DESC LIMIT 1", array(':nid' => $node->nid, ':tid' => $node->TAXONOMY_FIELD['und'][0]['tid']))->fetchField();

$next_nid = db_query("SELECT nid FROM {term_node} WHERE nid > :nid AND tid = TID ORDER BY nid LIMIT 1", array(':nid' => $node->nid, ':tid' => $node->TAXONOMY_FIELD['und'][0]['tid']))->fetchField();

if (@$prev_nid > 0) {@$prev_link = l('Previous', "node/$prev_nid");}
if (@$next_nid > 0) {@$next_link = l('Next', "node/$next_nid");}

print @$prev_link . ' - ' .@$next_link;

```
> 0 votes

---
Tags: theming
---


# Question
Title: Separate statistics on sites from Domain Access
Is it possible to separate statistics (like number of views) on shared node on few sites while using Domain Access module, so the same node can be viewed like 50 times on site1 and like 80 times on site2, etc.?

# Answer
I haven't actually tested this but you could maybe use separate database tables with different prefixes for the tables that the statistics module provides (accesslog, node\_counter).

So your tables might be something like:

* site1\_accesslog
* site1\_node\_counter
* site2\_accesslog
* site2\_node\_counter

The domain\_prefix module handles that. This module was a sub-module included in the main domain access module for Drupal 6 but was separated in Drupal 7.

There is also an issue here which seems to indicate you can use a small snippet of code in a custom module for this instead of using this drupal.org module, which is seemingly not well supported currently.

Keep in mind this is a fairly advanced usage of Drupal so I advise caution and lots of testing. Having said that though the tables you want to split are low risk compared to say the node or users tables.
> 0 votes

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


# Question
Title: Advice on how to fix Workbench Moderation error messages
(n00b drupal person)

I seem to be suffering the problems described in https://drupal.org/node/1966908 and https://drupal.org/node/1966920.

Basically I have installed the following:

```
drupal-7.26.tar.gz
media-7.x-1.4.tar.gz
views-7.x-3.7.tar.gz
ctools-7.x-1.3.tar.gz
workbench-7.x-1.2.tar.gz
workbench_access-7.x-1.2.tar.gz
workbench_media-7.x-1.1.tar.gz
workbench_moderation-7.x-1.3.tar.gz

```

It all seems to be configured OK, but when I switch to My Workbench -\> Create Content I get the following warning/error message:

> Notice: Undefined index: #contextual\_links in contextual\_pre\_render\_links() (line 140 of /home/apache/drupal-7.26/modules/contextual/contextual.module).
>
> Warning: Invalid argument supplied for foreach() in contextual\_pre\_render\_links() (line 140 of /home/apache/drupal-7.26/modules/contextual/contextual.module).
>
> Notice: Undefined index: #contextual\_links in contextual\_pre\_render\_links() (line 140 of /home/apache/drupal-7.26/modules/contextual/contextual.module).
>
> Warning: Invalid argument supplied for foreach() in contextual\_pre\_render\_links() (line 140 of /home/apache/drupal-7.26/modules/contextual/contextual.module).
>
> Notice: Undefined index: #contextual\_links in contextual\_pre\_render\_links() (line 140 of /home/apache/drupal-7.26/modules/contextual/contextual.module).
>
> Warning: Invalid argument supplied for foreach() in contextual\_pre\_render\_links() (line 140 of /home/apache/drupal-7.26/modules/contextual/contextual.module).

Would very much appreciate some help with:

1. Confirmation I've got the right bugs
2. Some advice on fixing it... should really be using `git patch` rather than installing the updated modules to fix ?

# Answer
> 0 votes
OK, so I found a workaround, which is good enough for the timebeing... enable Views UI modules - https://drupal.org/comment/6971496#comment-6971496

# Answer
> 0 votes
certainly enabling views UI solve the problem but a more suitable solution is provided in this patch\[#1727284-1\]

# Answer
> 0 votes
Enable Views UI and error goes away.

---
Tags: 7, workbench
---


# Question
Title: View with nodes but pull only one field from collection
I have a node type of `photo-gallery`. Each node has a field collection which contains multiple `photo` fields and `caption` fields. I want to create a view showing the 5 most recent `photo-gallery` nodes but I only want to display one `photo` field from each without the `caption` field. How would I do this? I can't seem to figure out how to get only one field from the field collection in the view.

# Answer
> 2 votes
There is another solution mentioned in the issue that you reference in your answer that I would say is a good solution.

1. Add a new view mode. You could use the entity view modes module if you didn't want to code it yourself.
2. Configure that view mode for your field collection so that it only shows the photo and not the caption.
3. Don't add a relationship to the field collection because it will cause rows per field collection item.
4. Configure your view to display the field collection as one of the fields. Select the view mode you created. In the "Multiple field settings" part of the field definition configure it to Display 1 value(s) starting from 0 to just show the first one.

# Answer
> 1 votes
To achieve your goal you can create a view with following settings:

SHOW: Field collection item
Display: your display type

then, in new created view:

1. Relationship: Field collection item: Entity with the \[your image field name\](your field mashine name)
2. filter criteria: content type is on of: photo gallery
3. Fields: field with the image

At that moment your view should showing all images associated with your photo gallery content type and field collection.

to display one photo field from each query just set the pager and sort criteria

Please comment of you face any problems with these settings.

# Answer
> 0 votes
I've solved my issue by applying this patch: http://drupal.org/node/1883946#comment-6918878 Seems like there should be a less hackish way though.

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


# Question
Title: Add class to Menu Block UL unique to each Menu Block instance?
I've seen lots of answers, but they only allow you to add classes to all Menu Blocks, or to specific Menus.

I have multiple menu blocks with the same menu behind them (1st level block, 2nd level block, etc.)

I need each menu block to have a unique class based upon the name of the Menu Block. Is this possible?

# Answer
> 0 votes
Unless your theme changes the usual behavior then each of your menu blocks will have its own unique ID so you can use CSS like this (note the ID/class I used here might not be the ones you have to use, they're just an example):

```
#block-menu-block-2 ul.menu

```

This way you don't have to worry about overriding the markup of the menu to add classes in.

---
Tags: routes, blocks
---


# Question
Title: What is wrong with my JQuery UI datepicker option code?
I have an AJAX view using Views 3 and Better Exposed Filters (and therefore jQuery UI datepicker). One of the exposed filters is dates between \[post-date\] (core).

The form works fine, but when dates are entered and submitted (via AJAX) the visible entries in the input fields disappear.

Before:

After:

It doesn't happen to other text fields, only date fields, and it stops happening when I change the Exposed Form type to 'Basic'. I'm sure it's BEF causing the issue but what's really puzzling is that the input values are *there* in the HTML after submit:

```
<input ... value="2015-05-01" ...>

```

Why isn't it showing in the input field?

\[edit:\] I tried to reproduce this on a blank site and couldn't. No longer certain the root cause is in BEF.

---

Additional information:

I've tracked the problem down to some custom JQuery code to add options to the datepicker post-render. The options are added no worries, I just can't figure out why it breaks the inputs.

```
(function ($) {
Drupal.behaviors.myPageFilters = {
  attach: function (context, settings) {

    $("label[for='edit-post-date-max']", context).once('changeBetweenText', function(){
        $(this).text("to");
    });

    // This is the culprit, commenting out this block stops the weird behaviour
    $(".bef-datepicker", context).once('changeDatePickerFormat', function(){
        $(this).datepicker("option", "changeYear", true).datepicker("option", "changeMonth", true);
        $(this).datepicker("option", "dateFormat", "yy-mm-dd").datepicker("option", "showButtonPanel", true);
        $(this).datepicker("option", "buttonImage", "/sites/all/themes/mytheme/images/exposed-filter-calendar.png").datepicker("option", "showOn", "both");
    });

    $(".bef-secondary-options", context).once('createSecondarySubmit', function(){
        $(this).append('<input type="submit" id="bef-secondary-submit" value="Apply" class="form-submit">');
    });

  }
};
}(jQuery));

```

---

It's this:

```
$(this).datepicker("option", "dateFormat", "yy-mm-dd");

```

I placed it there to change the date format away from the US format provided in BEF code (AUS site).

I just discovered the **jQuery UI Datepicker option** field in BEF. /facepalm

I'll leave this question here in case anyone ends up with the same issue.

# Answer
Put your datepicker options in via the Views UI rather than custom jQuery.
> 0 votes

---
Tags: ajax, javascript, views
---


title: How to add Breadcrumbs in views pages?

text:
# Question
Title: How to add Breadcrumbs in views pages?
I have a page which list some products in a particular category and I have passed taxonamy term as contextual filter. Here is an example of my url: `www.example.com/prod_category`.

I want to show breadcrumb in my page like `home > prod_category` where `prod_category` is category of product. I have used Custom Breadcrumbs module but couldn't find a solution.

# Answer
> 1 votes
You can create custom breadcrumb by adding this code :

```
<?php
global $base_url;
$breadcrumb[] = l('Home', null);
$breadcrumb[] .= l('Product Category', 'prod_category');
$breadcrumb[] .= l(drupal_get_title(), $base_url.$_SERVER['REQUEST_URI']);
drupal_set_breadcrumb($breadcrumb);
?>

```

Refer to LINK1, LINK2 & LINK3

---
Tags: views
---


# Question
Title: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1532856' for key 'PRIMARY': INSERT INTO {watchdog}
I am worried about a big error found on my website.Yesterday it was working and today morning i found the issue.Please help me to solve it.

Error message:

> PDOException: SQLSTATE\[23000\]: Integrity constraint violation: 1062 Duplicate entry '1532856' for key 'PRIMARY': INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db\_insert\_placeholder\_0, :db\_insert\_placeholder\_1, :db\_insert\_placeholder\_2, :db\_insert\_placeholder\_3, :db\_insert\_placeholder\_4, :db\_insert\_placeholder\_5, :db\_insert\_placeholder\_6, :db\_insert\_placeholder\_7, :db\_insert\_placeholder\_8, :db\_insert\_placeholder\_9); Array ( \[:db\_insert\_placeholder\_0\] =\> 0 \[:db\_insert\_placeholder\_1\] =\> php \[:db\_insert\_placeholder\_2\] =\> %type: !message in %function (line %line of %file). \[:db\_insert\_placeholder\_3\] =\> a:6:{s:5:"%type";s:6:"Notice";s:8:"!message";s:46:"Undefined index: field\_enter\_module\_name\_here";s:9:"%function";s:9:"include()";s:5:"%file";s:112:" example.com\sites\all\themes\nexus\templates\field-collection-item.tpl.php";s:5:"%line";i:37;s:14:"severity\_level";i:5;} \[:db\_insert\_placeholder\_4\] =\> 5 \[:db\_insert\_placeholder\_5\] =\> \[:db\_insert\_placeholder\_6\] =\> http://example.com/ \[:db\_insert\_placeholder\_7\] =\> \[:db\_insert\_placeholder\_8\] =\> 195.229.241.186 \[:db\_insert\_placeholder\_9\] =\> 1432102144 ) in dblog\_watchdog() (line 160 of example.com\modules\dblog\dblog.module).

# Answer
There are 2 things going on here.

1. The PDOException is because Watchdog is trying to insert a duplicate primary key, 1532856. Your auto increment value could be off or some other table corruption could be going on there. A simple fix is to truncate the watchdog table if you don't care about maintaining old log data. Otherwise, you could try to repair the table or fix the auto increment value if you want to retain old log data.
2. The error being logged has to do with your **field-collection-item.tpl.php** template in the Nexus theme on line 37. A key called `field_enter_module_name_here` is being referenced when it doesn't exist. It looks to be a custom template addition to the theme (it doesn't exist in the 7.x-1.3 release). Given, the key name, it sounds like some sort test code dropped into this template. This is warning so it shouldn't be a critical problem, but you should fix it to clean out extraneous errors from filling up your logs.
> 1 votes

---
Tags: debugging
---


# Question
Title: Disable image autoscale when dimensions are bigger than my settings
As you may know, in Drupal 7 you can set max and min dimensions for an image field, when you upload a small image, Drupal returns an error, but when you upload a bigger file it resize the image automatically instead of return the error "Your image is too big...".

I was looking for the reason of that autoscale configuration but looks like it will never be fixed. I need to override it because some of my users still uploading pictures with other dimentions, even with a different aspect ratio.

I found the condition in **includes/file.inc** line **1809** ... it tries to scale the image if it's bigger. I know that i can comment that condition and it will work, but is not a good idea, so: Does anyone know how to override that condition using a custom module, hooks or something?

# Answer
You don't want to return the message "your image is too big" as people nowadays are uploading directly from their mobile phones and do not have (or know) a way of resizing/cropping themselves before uploading.

So you should try it via another way: do not impose restrictions on the original image, but use an image style to display the uploaded images and add some smart/user/custom crop effect to that image style. There are a number of modules that let users/editors custom crop images, e.g:

Also see Comparison of image cropping and resizing modules.
> 1 votes

# Answer
You need to go to manage fields and click edit on your image field.

you should see Maximum image resolution and Minimum image resolution. Try setting both of these fields to 500x500

**Note:** if you are using the default Drupal user pictures in admin/config/people/accounts you would have to turn them off, since you can't give them a max/min resolution. Then just add an image field in admin/config/people/accounts/fields and use that as user pictures.
> 0 votes

---
Tags: media
---


# Question
Title: How to implement some super admin feature to facilitate password retrieval for existing users?
I'm aware that *Drupal 7* saves the user's password in a more compact way and it's really hard (impossible?) to convert such password back to a human readable text format (even not into database).

Actually I do not want to implement any hack to *Drupal*, but it's a requirement that a super admin can somehow view the `username` along with its `password` for any user. Super admin is a trust worthy role and actually will help through secured communication media to other users after forgetting their password.

So there is a need to create a block to show all the usernames with their corresponding password, which can only be used by a super admin.

Any suggestions about how I could implement all this?

**Note:** Users are not allowed to **reset** passwords, I just want only super admin can access their usernames and passwords and then re-assign to other user if any of them forgot his password.

# Answer
You can't. Drupal passwords are *hashed*, not *encrypted*, the key difference being hashes are **one-way**.

With Drupal 6's non-salted MD5 hashes, a rainbow table might get you there, but with D7's salted SHA512 hashes would be much tougher. The time spent trying to do this would be better spent trying to find an alternative to your need of listing all user/pass.
> 4 votes

# Answer
You can't.

Passwords are saved encrypted so that they can't be easily recovered in their clear format.

Beyond that you could use the password reset mechanism and reset the passwords. That's the closest that you will get to what you want.
> 2 votes

---
Tags: users
---


# Question
Title: Send email when entity field value is changed
I have used Rules module for notification when node is created, edited or deleted.

My site is in three languages and I use Entity Translation for translating node's field.

Now I want notification when node's or entity field is changed/updated. Can I achieve it with Rules module?

# Answer
Yes, you can use Rules to achieve this.

Here's how:

1. Create new rule that will react on "After updating existing content" event.
2. Use the following conditions: data comparison: `node:field-your-field` and `node-unchanged:field-your-field` and select "Negate: FALSE"
3. Create whichever actions you want, e.g. send mail, show message, etc.
> 2 votes

---
Tags: rules
---


title: Views, Pathauto and contextual filters

text:
# Question
Title: Views, Pathauto and contextual filters
My question is rather simple, but I didn't manage to find anything that can help.

Summary of my setup :

So I have various custom content types, which I want to organize using views. But for SEO reasons, I want them to use simplified URLs, generated by Pathauto.

These content types are all cross-referenced using Entity Reference, and when I try to configure my View "Page" using the node ID as contextual filter, it works. But when I try to use Pathauto, nothing happens.

So how can I use Views, basically when going to http://example.com/fruits/banana and pass "banana" argument to Views, to filter my content ?

I am searching for it for almost a week, and I am lost.

# Answer
> 0 votes
I couldn't understand what you exactly need but i guess that "banana" is the title of your node, the same value that you are using when you set up the pattern in pathauto settings, right?

So in this case you would have to set Node Title has a contextual filter, and then on "When the filter value is NOT available" you have to set Provide default value \> Raw value from URL \> specify the position of your argument in the URL.

It would be nice if you give us more information about what do you need, please

# Answer
> 0 votes
After extended search and help from user xstean, I went with the idea of overriding node/% of Drupal with a custom View, for my specific content type. This way, I would have more control on what is shown or not.

I managed to get myself out with help from this post : What are the issues with overriding nodes with views?

So basically what I did was :

* Created my View, without any display mode, only "Master". I checked with the preview function and a node ID, it works. It doesn't works with pathauto alias, but it's not a problem yet.
* Went to my templates folder, and edited node.tpl.php to copy the one proposed at the end of the post and embedded my view directly in it :

```
<?php if ($node->type=='FANCYTYPE'): ?>
    <?php print views_embed_view('name_of_fancy_view', 'default', $node->nid); ?>
<?php else: ?>
    // the rest of the normal node.tpl.php stuff here
<?php endif; ?>

```

In fact, I understood you can't override the node/% view for one content type without causing trouble for the others, so this snippet helped a lot.

So i'll go that way, it's a bit "clumsy" but works like a charm.

Somehow, if someone has a better technique to override node view for a specific content type, I'll be OK to try :)

Thanks xstean for great help !

---
Tags: 7, entities, views, path-aliases
---


# Question
Title: Why can't I reinstall my module after uninstall?
With last beta version of Drupal 8, I have this error:

> Error message Unable to install Nature Theme - Structure and configuration, block.block.kyna\_block\_aboutus, block.block.kyna\_block\_blog\_more\_content, block.block.kyna\_block\_navbar, block.block.kyna\_block\_user\_login, block.block.kyna\_block\_user\_menu\_account, field.field.node.article.field\_kyna\_article\_slideshow, field.field.node.kyna\_folio.body, field.field.node.kyna\_folio.field\_kyna\_folio\_client, \[...\] image.style.kyna\_image\_medium, node.type.kyna\_folio, system.menu.kyna-navbar, taxonomy.vocabulary.kyna\_client, views.view.kyna\_blog, views.view.kyna\_folio, views.view.kyna\_home already exist in active configuration.

Why can't I reinstall my module? I don't have this error with previous version of Drupal 8 when I try to install my module after an uninstall.

How share my site configuration (block, field, view, etc.) without this problem please?

# Answer
> 3 votes
This is not so easy right now.

One way to do it is to put a forced dependency in those configurations, then they will be uninstalled together with a module. Core might even switch to doing that automatically, as I just discussed with @alexpott.

I'm not really sure how you are using that module. I have a feeling that is *not* what you want.

> How share my site configuration (block, field, view, etc.) without this problem please ?

Share how? With whom? Multiple separate sites, or dev/staging/production of the same site?

If the second, then do **not** use a module for this. Use the configuration staging folder and the configuration sync API/UI, that is designed to deal with updated default configuration.

If the first, keep in mind that default configuration is only designed for one use case: Initial default configuration when a module is installed for the first time. Modules are not meant to be re-installled to install updated configuration, the only way to do it like that would be first *remove* all the configuration and then create it again. That will *not* work for things like fields, because you will lose your data.

# Answer
> 2 votes
1 . Devel + Drush

Devel + Drush command for module re-installation :

```
drush devel-reinstall modulename

```

Drush alias for above command :

```
drush dre modulename

```
2. Devel

If you don't have access to shell then you can re-install module in following manner.

```
www.example.com/devel/reinstall

```

---
Tags: 8, installation
---


# Question
Title: 7.26 /admin, /user not found on Localhost
I am new to Drupal. I developed a site on a server and now migrating it on my personal computer (Windows 8.1). The site is working fine as it should.

My problem on localhost is that when I log in to my site (using this url: localhost/drupal\_site/user/login) with an admin userid, it redirects me to the "404 Page(url: localhost/drupal\_site/user)" on submission of correct username/password, And neither the admin menu bar occurs on the site.

I've tried modifying .htaccess, httpd.conf, cleaned cache tables in database and clean urls etc.

In .htaccess i've write:

```
'RewriteBase /drupal_site'

```

In httpd I've wrote:

```
<Directory "C:/xampp/htdocs/drupal_site">
    AllowOverride All
</Directory>
AccessFileName .htaccess

```

Its ironic that I've tried various solutions found with drupal community, but none of them really worked for me.

My Drupal Version is 7.26.

Xampp: Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3

Can anyone help me resolving this?

# Answer
This issue might be a variation of the question about "drupal /?q=user is working but /user not working". So verify if you can use an URL containing ?q=user or ?q=admin. If that gets you going, then probably tuning RewriteBase in your .htaccess (as described in the accepted answer of that question) should help.

It might be worth trying to further enhance your .htaccess file, by adding a line after that existing RewriteBase, which looks like so:

```
RewriteRule . index.php [L]

```

For more details on the above line, refer to the (accepted) answer in this question on StackOverflow.

Another option for debugging is to retry using another browser. If via that brower you are able to login, then it's probably a cookie problem (in your original browser).

If none of these suggestons help, then re-edit your question by adding more details about which modifications to your '.htaccess file, httpd.conf, etc' you already tried (and didn't work).

PS: Are you aware of the security issue fixed in Drupal version 7.32? Hurry to get your "site on a server" (as in your question) upgraded to the most Drupal core version!
> 1 votes

---
Tags: uri, users
---


title: Translate strings in custom module

text:
# Question
Title: Translate strings in custom module
I'm working on a module for a D7 site that generates a block. Unfortunately all the HTML is hard coded and I need to make it translatable. I have done the following:

Changed

```
$output = "<h3>Page title here</h3>";

```

to

```
$output = "<h3>".t('Page title here')."</h3>";

```

but no amount of clearing caches or refreshing strings gets "Page title here" to appear in the translate interface. I've loaded the page and even changed the text but it does not show up. I'm aware of the case sensitivity of the search

Is there something I'm missing?

# Answer
> 1 votes
As usual, I work it out shortly after posting a question. Here's what I needed to do if anyone else has this issue.

1. The block I was trying to translate was only configured to display on the **en** version of the page, so I enabled it to be displayed on the other language's page as well.
2. I enabled translation for the block as a good measure.

After that the string popped up in the translation interface.

---
Tags: i18n-l10n
---


# Question
Title: Call a drupal behavior method from inside another behavior
How do you call a drupal behavior method from inside another behavior? My example below

```
(function ($) {
  Drupal.behaviors.exampleOne = {
    attach: function (context, settings) {
      $('.example', context).click(function () {
          $(this).next('ul').toggle('show');
      });
    }

    exampleMethod: function (context) {
      console.log('test');
    }
  };

  // call exampleOne from inside exampleTwo
  Drupal.behaviors.exampleTwo = {
    attach: function (context, settings) {
      $('.example-link', context).click(function () {
          Drupal.behaviors.exampleOne.exampleMethod(context);
      });
    }
  };
})(jQuery);

```

See how I try to call `exampleMethod()` that belongs to behavior exampleOne inside behavior exampleTwo? I would think I can call it like that but I keep getting `undefined` when I call it. Though if I call it like this `console.log(Drupal.behaviors.exampleOne.exampleMethod);`, I get the function written out.

# Answer
> 9 votes
Working example from https://web.archive.org/web/20150320092121/http://dropbucket.org/node/943:

```
1. ) Be sure you have included JS files in your Drupal module files.

  $form['#attached']['js'][] = drupal_get_path('module', 'module_A') . '/module_A.js';
  $form['#attached']['js'][] = drupal_get_path('module', 'module_B') . '/module_B.js';

2. ) module_A.js file

(function ($) {
  Drupal.behaviors.module_A = {};
  Drupal.behaviors.module_A.my_function = function(selector) {
    // Your code.
  }
})(jQuery);

3. ) Call the function in module_B.js file
(function ($) {
   Drupal.behaviors.module_B = {};
   Drupal.behaviors.module_B.attach = function(context) {

   // This is the main part here. You have to respect the namespace of module A.
   Drupal.behaviors.module_A.my_function('.my-selector');
  }
})(jQuery);

```

# Answer
> 1 votes
This is not related to Drupal. Its purely related to JavaScript Closures/Scope. If you want to call a method in JavaScript it should be available either in the current Scope(Closure) or Global Scope.

That's why you get undefined when you called the exampleMethod from another Scope.

Check following references for more info

---
Tags: javascript
---


# Question
Title: Grab Data from non form elements and send as POST using AJAX
I am looking for an alternative solution to the way my form is being submitted right now. The problem is that the validation function does not work because I gave the submit button on the form an attribute of `onclick=return(false)` and added the following AJAX code to listen for the submit button being pressed.

```
jQuery("#edit-submit-order").click(function() {
        var orderForm = jQuery("#order-form-form").serialize();
        var orderTable = JSON.stringify(hot.getData());
        var extraOrderTable = JSON.stringify(hot2.getData());
        var formType = jQuery("input:radio[name=form-type]:checked").val();

        jQuery.ajax({
            type : "POST",
            url : '/sites/all/modules/order_form/post-order.php',
            data : orderForm + "&orderTable=" + orderTable + "&extraOrderTable=" + extraOrderTable + "&formType=" + formType + "&orderTotal=" + parseFloat(updatePricing()).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'),

            success : function(result) {
                if (result) {
                    jQuery('#order-form-form').empty();
                    jQuery('#order-form-form').append(result);
                    //jQuery("#order-form-form").html("<div class='success'>Submitted Order Form Successfully</div>");
                } else {
                    jQuery(".message").html("<div class='error'>" + result.message + "</div>");
                }
                jQuery(".message").children().fadeOut(5000);
            }
        });
    });

```

The `orderTable` and `extraOrderTable` are the elements I need to send with the POST request. They are part of an HTML table I am using called Hands on Table. It is a very nice excel like table editor. The `getData()` command returns an array of all values in the tables.

Ideally I would like to remove the `onclick=return(false)` from my submit button and have the order form submit using Drupal's AJAX method, making sure to validate the fields I marked as required but also submitting the table data in a single POST request. Can this be done or is the solution I have already made the best way to do it?

# Answer
> 3 votes
Hopefully this answer will help someone else looking for the same thing. I found a solution and it works great.

The way that I solved it was by creating two hidden elements with id's in my form. One hidden element for each table that I have in my form.

Below is how I created the hidden form element

```
$form['orderTable'] = array(
        '#type' => 'hidden',
        '#attributes' => array('id' => 'orderTable')
);

```

Below is how I created the container that holds the table and is used to generate the table from the Java Script file.

```
$form['middle']['order-table'] = array(
        '#type' => 'container',
        '#attributes' => array(
            'id' => array(
                'testing-table',
            ),
        ),
    );

```

The Excel like table that I used Handsontable has an excellent method called `afterChange` this gets fired after something on the form changes. So what I did is create another Java Script function that gets fired each time inside of the `afterChange` function.

```
 function updateHiddenFields() {
    var orderTable = JSON.stringify(hot.getData());
    jQuery("#orderTable").val(orderTable);
}

```

What this does if your not familiar with Java Script is turn the data from Handsontable into a JSON string and places it in the value field of the hidden element. By doing it this way all of the data is accessible when the form is submitted just like I wanted and I was able to use the validation function.

---
Tags: 7, forms, ajax
---


title: My radio buttons don't show

text:
# Question
Title: My radio buttons don't show
I have tried to set up an online example of a form using Drupal 7.

When I run it, the radio buttons do not show at all.
I also get the following errors:

> Notice: Undefined index: #title\_display in form\_pre\_render\_conditional\_form\_element() (line 3090 of /var/www/sandbox7/includes/form.inc).
> Notice: Undefined index: #title\_display in form\_pre\_render\_conditional\_form\_element() (line 3090 of /var/www/sandbox7/includes/form.inc).
> Notice: Undefined index: #id in drupal\_process\_states() (line 4549 of /var/www/sandbox7/includes/common.inc).
> Notice: Undefined index: #id in drupal\_process\_states() (line 4549 of /var/www/sandbox7/includes/common.inc).
> Notice: Undefined index: #id in drupal\_process\_states() (line 4549 of /var/www/sandbox7/includes/common.inc).

# Answer
> 6 votes
Is the form running through drupal\_get\_form? This type of error can occur when using the generic render() fuction on a form that hasn't been prepared by drupal\_get\_form(). Check your hook\_menu settings and make sure your page callback is set to drupal\_get\_form() with the form id as the page arguments(encapsulated in an array)

if you must use a custom page callback, make sure that you're piping the form based output through drupal\_get\_form() like so...

$output = drupal\_get\_form('form\_id');

# Answer
> 0 votes
ok the correct form for do it this is this

```
   $items['examples/form_example/states'] = array(
    'title' => '#states example',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('form_example_states_form'),
    'access callback' => TRUE,
    'description' => 'How to use the #states attribute in FAPI',
    'file' => 'form_example_states.inc',
  );

```

the wrong form is this

```
   $items['examples/form_example/states'] = array(
    'title' => '#states example',
    'page callback' => 'form_example_states_form',
    'access callback' => TRUE,
    'description' => 'How to use the #states attribute in FAPI',
    'file' => 'form_example_states.inc',
  );

```

and working :)

---
Tags: 7, forms
---


# Question
Title: Change font color in unsorted list in Views Drupal
I'm using Drupal with Views, which outputs an unformatted list of news titles (accompanied with dates). Example output of my View:

Some of the news titles need to change font color or size. For example, if the chosen taxonomy term is "hot" then the font size of title should be 8px.

I think I need a CSS class to be inserted for tagged news, but I can't figure out how to do this.

# Answer
> 1 votes
Views supports tokens to generate CSS classes in the HTML output of a field. Below a screenshot depicting an example where I have added the fields 'Tags' and 'Title' from the default Article content type. In this way, the chosen taxonomy terms are added as CSS classes and you can apply the appropriate styling using CSS.

In order to see the list of available tokens in your View, checkout the section 'Rewrite results' -\> 'Rewrite the output of this field' -\> 'Replacement patterns' in the configuration screen of the field (you don't need to actually rewrite the output, however, this is the location where you can find the list of supported tokens for the particular field).

# Answer
> 0 votes
You can do this by using CSS Injector.

> Allows administrators to inject CSS into the page output based on configurable rules. It's useful for adding simple CSS tweaks without modifying a site's official theme. The CSS is added using Drupal's standard drupal\_add\_css() function and respects page caching, etc. The 2.x brach leverages CTools so CSS can be included with Feature changes (ie. CSS that improves the look of a View can be packaged with the View).

**HOW TO USE ?**

---
Tags: views
---


# Question
Title: Variable storing payment method in ubercart order
Seems easy but I am not able to figure it. I am using ubercart module in drupal 7, I am few payment methods like paypal, innovate and free method. All the 3 payment methods are activated, When a user places any order he has to choose which payment method he want to go for, if he is going for free method,

I need to know which variable is storing this payment method value,it should be like $order-\>method or $order-\>type same like other variables like $order-\>order\_id,$order-\>billing\_first\_name.

In short I should come to know which payment method is chosen for a particular order.

If any buddy knows please help me.

# Answer
The variable you're looking for is is `$order->payment_method`.
> 0 votes

---
Tags: ubercart
---


# Question
Title: How to set up a field to provide a publish/unpublish feature?
For layout reasons, I need a **field** providing a publish/unpublish feature.

We already have something very close with the Publish Content module.

Still, it looks like there's no option for setting it up as field.

Which alternative do we have here?

# Answer
I would use the Flag module. Excerpt from its project page (bold markup added here):

> ... Flag is a flexible flagging system that is completely customizable by the administrator. Using this module, the site administrator can provide any number of flags for nodes, comments, users, and any other type of entity. Some possibilities include bookmarks, marking important, friends, or flag as offensive. With extensive views integration, you can create custom lists of popular content or keep tabs on important content.
>
> **Flags may be** per-user, meaning that each user can mark an item individually, or **global, meaning that the item is either marked or it is not marked, and any user who changes that changes it for everyone.**
>
> In this way, additional flags (similar to published and sticky) can be put on nodes, or other items, and dealt with by the system however the administration likes.

So by using a "global flag" (whatever you'd call such flag), you could just "mark or do not mark" something as published. If appropriate, you could also consider Attaching fields to flags.

If you're not familiar with the Flag module, checkout the set of 8 video tutorials about the flag module.

Refer to Flag's Community documentation for (way) more details.

PS: near the bottom of the Flags setup is an option '`Display link as field`', which will include it as a field, for views, Panels, etc (if that's why you want a field).
> 1 votes

---
Tags: entities, nodes
---


# Question
Title: How to display the form submission results in a custom page?
How to display the form submission results in a custom page or a view ?

I want to display it in a custom style with table , and want to do custom php coding too .

where i have to create custom page , or is there need a custom module for this ??

# Answer
> 0 votes
Display Webform Submission Data using Views is a bit challenging. As an alternative to installing Webform MySQL Views (which depends on Data and Schema), consider the Forena module. Here is a quote about it:

> ... built of the idea of using SQL to get data out of a database and use XHTML and CSS to format it into web reports.

So in this case you'd use Forena to report about the Webform data stored in the Webform tables, which are contained in your Drupal database.

Disclosure: I'm a (co-)maintainer of this module,
I hope this does not violate the site's policy on self-promotion.

---
Tags: views, webforms, 7
---


# Question
Title: save and generate pdfs nodes with options
I have a view that list a content type A with few fields, For PDFs generation I choose views\_pdf it works perfectly and it can generate for me pdfs with the desired fields.

Im behind two problems now that I don't know how to solve them :

1. I want to save the PDF in my server first, so when the user click on pdf link inside the view, it save the PDF first then download it.
2. The PDF should be generated following options chosen by user : "download a short version", "Download a long version", ... ( inside the view I thought to make different links and for each option I create its own view. is it the best idea, or I can pass arguements to the pdf ? )

What's your advice, should I continue with `views_pdf` or I must switch to pdf for example...

Thanks in advance for your suggessions.

# Answer
> 0 votes
Part 1: Rules should allow you to save a PDF to the server. Step 4 on this page explains how to do so using Webforms (and Webform Rules), but it should work for node-generated PDFs: http://areatype.com/blog/create-email-pdf-files-drupal-webforms

Part 2: You can absolutely pass arguments to a Views PDF. Aren't you already doing that with the NID?

---
Tags: 7, views, files
---


title: getStorage('block')

text:
# Question
Title: getStorage('block')
I try to load the body field from a custom block in Drupal 8.

```
$block = \Drupal::entityManager()->getStorage('block')->load($block_id);

```

The result in $block is NULL.

A similar code for a node does work:

```
$node = \Drupal::entityManager()->getStorage('node')->load($node_id);
$body = $node->get('body')->value;

```

getStorage should work for all entities, why not for blocks?

What is wrong?

# Answer
> 5 votes
Block is the wrong machine name, that is a placed config entity, you want custom\_block or block\_content, can't remember which off the top of my head, check the ID in the entity type annotation in block content module

---
Tags: 8
---


title: Categorizing Contents

text:
# Question
Title: Categorizing Contents
I am creating a Drupal Commerce website in which I have created 4 Product Types and 4 Product Displays as following

1. Health
2. Eye / Sunglasses
3. Contact Lenses
4. Sports

To classify the products I have created several vocabularies, some vocabularies are common in all product display types and some are available in one or two product display types.

Now I want to use default Taxonomy Term view provided by the views module and add those vocabularies as exposed filter in that but in the way that if Health Taxonomy page is being viewed it must show the vocabularies as exposed filter related to Health Only and so on

# Answer
It seems to me that what you are looking for is not a view, but a search result page with facets.

If you want to use views, as @milkovsky said in comments, you will need a separate view for each product type. That way is undoubtedly the easiest approach.

However, if you want to direct your visitors to a *single URL* that dynamically adjusts to the kind of thing they're looking for, take a look at the Facets API module. That module effectively scans the results on a search page looking for categories and shows them in blocks, allowing you to narrow down the search.

As it says on the module page, you can use it with the Search API or Apache Solr Search modules which significantly improve upon Drupal's core search. I found the latter suitable to my needs, but they're both pretty good. Installing Solr on your server is the "fun" part...

For an example of what facets are, look no further than eBay. Just go to the home page and type something in the search box: the criteria that show up on the left hand side are facets (pictured below). They're not Drupal facets, and they vary wildly in their rendering, but the function is the same: narrow down the search.
> 0 votes

# Answer
give the module hierarchical\_select or it's simpler approach a try.

or see here how to programmatically play with the exposed filter(s): https://drupal.stackexchange.com/a/96769/3218
> 0 votes

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


# Question
Title: how to react on file save using rules module
How is it possible to react on newly uploaded file with rules? Is there any trigger like file upload or file update? Thank you.

# Answer
You can use Entity Rules I believe for this.

From the module page:

> Entity Rules provides a page for selecting and creating Rules components that will be executed when different operations happen to an Entity of a particular bundle. This provides an alternative method of triggering Rules. Instead of adding entity related events to Reaction Rules you are able to select which Rules will fire from the bundle management page.
>
> Currently the operations supported are create, update, delete, validation and form access. You are also able to pass different arguments to the Rules per bundle.

In Drupal 7 the de facto module is typically file\_entity used alongside the media module so if you are using those then the above should work but if you are not you may at least need the file\_entity module.

I also noticed an issue in the Entity Rules issues page that listed a bug with file\_entity but has been fixed in dev, so if the normal version does not work I would try the dev version to see if that works.

Hope that helps!
> 0 votes

---
Tags: 7, rules
---


# Question
Title: How to add delete button to file field upload widget that actually deletes the file (not just association with content)?
After uploading a file with the File widget for the File field, the file is on the server and remove only disassociates the file from the field (and the content that the field belongs to).

I would like to add a button to actually delete the file. I've considered a number of options: \- via hook\_form\_alter - but unsure as to what to insert into the $form or $form\_state array for the content edit form, regarding new array elements and at what position \- by providing a theme .tpl file (based on what devel\_themer suggests - tried a few possibilities by the themes did not 'fire' (execute) \- making use of the API in https://www.drupal.org/project/extended\_file\_field to write a hook or otherwise in a custom module

Which of the above would be the standard programmatical approach for extending the file widget to provide direct deletion of the file?

**Update** I set my debugger to fire on the function `file_managed_file_submit($form, &$form_state)` that Geoff mentioned. On clicking the Remove button to the right of the file...

The function `file_managed_file_submit($form, &$form_state)` *is* called BUT the `status` is not zero, so the if fails and the delete does not happen - see debug screen below showing all of this:

This commenter has also seen the problem it seems: how to delete the files uploaded in the file field?

**Update 2** I think I know what's going on: We have Workbench Moderation on the site. So, it would make sense to *not* delete the file but rather the remove just disassociates the file from the *Current revision* of the content. This makes sense if in previous revisions, they did actually need to refer to the file. So by keeping the file present means those previous revisions "integrity" is intact in that they still refer to the file and the link is not broken. So in summary this is 'as design' I think. Thoughts?

(There is a way to properly delete the file through `admin/content/file`)

# Answer
> 0 votes
The file should be deleted, if it isn't there is something going on. When a submit button fires, file\_managed\_file\_submit($form, &$form\_state) is triggered:

```
// No action is needed here for the upload button, because all file uploads on
  // the form are processed by file_managed_file_value() regardless of which
  // button was clicked. Action is needed here for the remove button, because we
  // only remove a file in response to its remove button being clicked.
  if ($button_key == 'remove_button') {
    // If it's a temporary file we can safely remove it immediately, otherwise
    // it's up to the implementing module to clean up files that are in use.
    if ($element ['#file'] && $element ['#file']->status == 0) {
      file_delete($element ['#file']);
    }
    // Update both $form_state['values'] and $form_state['input'] to reflect
    // that the file has been removed, so that the form is rebuilt correctly.
    // $form_state['values'] must be updated in case additional submit handlers
    // run, and for form building functions that run during the rebuild, such as
    // when the managed_file element is part of a field widget.
    // $form_state['input'] must be updated so that file_managed_file_value()
    // has correct information during the rebuild.
    $values_element = $element ['#extended'] ? $element ['fid'] : $element;
    form_set_value($values_element, NULL, $form_state);
    drupal_array_set_nested_value($form_state ['input'], $values_element ['#parents'], NULL);
  }

```

---
Tags: 7, files
---


# Question
Title: How can I create a view that displays the most popular nodes based on an outgoing link?
The link is a text field that's value is pulled directly in **node.tpl**:

```
<a class="list-parent-link" href="<?php echo $node->field_download_link['und'][0]['value']; ?>">

```

I'd like to be able to track how popular each node's link is, and display the 5 most popular nodes in a views block. Is that possible?

# Answer
> 0 votes
yes it can be done in a number of ways... some options:

1) add a JS onclick="" to the link which goes to a function that causes an ajax call to the server. The server would then take in node information and using something like the Flag Module:

> Flag is a flexible flagging system that is completely customizable by the administrator. Using this module, the site administrator can provide any number of flags for nodes, comments, users, and any other type of entity. Some possibilities include bookmarks, marking important, friends, or flag as offensive. With extensive views integration, you can create custom lists of popular content or keep tabs on important content.

to trigger a counter which can then be easily used in Views.

2) adjust the link direction to an internal proxy page:

```
<a href="/mymodule/proxy?url=<?php echo $node->field_download_link['und'][0]['value']; ?>">

```

The proxy page would have a callback function that again uses Flag or similar to track the click and then redirect the page to the provided url.

Option 2 is probably the better of the two, but it depends on the set up, and whether or not you want a redirect, etc.

I can give more specific guidance if you decide to go with one of these.

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


# Question
Title: Using panels and\or contexts to build simple blog w/ static menu
My goal is to build a simple blog that has a vertical list containing a library of blog titles and then the "meat" of a selected bog entry on the left. I want the library list to be static such that it is always there whenever the user selects different blog articles.

This seems to me to be somewhat simple but for the life of me, it's got me stumped.

Any help is appreciated - Thanks.

# Answer
> 0 votes
It is simple to do:

* set up your panel as normal - include the 'block' of information you want visible in the section you want it
* click on the settings icon and select Visibility: Add new rule:

This allows you to set the conditions under which that particular block of information will be visible. You can have it appear only on nodes of a particular type for example.

---
Tags: views, panels, nodes
---


# Question
Title: How to print You have new private message, You have no new messages
I'm using Privatemsg module and I want to print simple *"You have new message"* and *"You have no new messages"* for given user how to do that?

# Answer
> 0 votes
Assuming you want to do this programmatically, or be able to easily customise it in a block, it can be done easily - I have not done this in 6, only 7 so some other steps may be necessary:

```
<?php /* check privatemsg for unread messages */ ?>
  <?php $unread = privatemsg_unread_count(); ?>

  <?php if($unread > 0)
  { ?>
    <a id="message_notify" href="/messages" title="<?php echo $unread; ?> new messages">
      <img src="/sites/all/themes/myTheme/images/envelope_green.png" style="display:inline-block; vertical-align:top; height:18px; margin-left:5px;">
    </a>
  <?php } else { ?>
    <a id="message_notify" href="/messages" title="no new messages">
      <img src="/sites/all/themes/myTheme/images/envelope_grey.png" style="display:inline-block; vertical-align:top; height:18px; margin-left:5px;">
    </a>
  <?php } ?>

```

This should work with any version of privatemsg but does require php be enabled - or in a custom block. adjust as desired - in my example I use two images of envelopes, one grey for no messages and one green for unread messages - that's just UI, and doesn't need to be there if desired.

# Answer
> 1 votes
The module automatically does that when a user logs in who has the message waiting. It DOES NOT print you have no new messages - because that is redundant. It did it that way when we use it on our site - Drupal 6 - have not enabled and used it however yet on Drupal 7

---
Tags: 6
---


title: User profile private public toggle

text:
# Question
Title: User profile private public toggle
I'm searching for a way to let users chose if they want their user profile to be public or to be private (just the owner and admin). I'm not picky if this can se set for the whole profile or for every profile field.

I already looked at User Field Privacy but this one conflicts with Field Permissions (this site needs fields permissions). And I'd rather not use Profile2 for this functionality since I'm only using the standard profile fields.

I thought about using Field Conditional Formatters but this seams rather complicated to set up for every field.

Any ideas?

# Answer
> 0 votes
Easiest way would be to change the access callback to the user page (user/%user) via hook\_menu\_alter. The new access callback would use the value of a user field to determine or the page is accessible or not.

Code to give you an idea of the structure, not a fully functioning example

```
YOUR_MODULE_menu_alter(&$items){
  $items['user/%user']['access callback'] = 'user_profile_is_private';
}

function user_profile_is_private($user){
  // Check the content of the user field here and return true/false.
}

```

This tells drupal to use the `user_profile_is_private` function to determine or people can access the user page or not. This function should return true/false. The user object is passed to this function via the core user module already.

You'll need to add the core user access function `user_view_access`in there somehow to prevent this change to override all other access settings.

# Answer
> 0 votes
If you're looking for a ready to go solution, take a look at nodeaccess module:

> Nodeaccess is a Drupal access control module which provides view, edit and delete access to nodes. Users with the 'grant node permissions' permission will have a grant tab on node pages which allows them to grant access to that node by user or role. Administrators can set default access controls per content type, and also define which roles are available to grant permissions to on the node grants tab.

---
Tags: users
---


# Question
Title: Change URL to meaningful name when I use hyperlink target
Scenario:

```
<a href="#block-block-1">Book</a>

```

When I click book, it will scroll down to the block and url will be www.example.com/#block-block-1. Is there anyway to change url to something meaningful like www.example.com/#book?

I've tried suggestions from How to give meaningful id names to blocks?, but it is not really what I want.

# Answer
The Block Attributes module will let you add a meaningful `id` attribute to any Drupal block.

> The Block Attributes module allows users to specify additional HTML attributes for blocks, through the block's configuration interface, such as class, id, style, title and more.
> 1 votes

---
Tags: 7, blocks, uri, navigation
---


# Question
Title: Upload file in system_settings_form in Drupal 6
I have a code that was supposed to upload 2 files:

```
function lafemme_background_images_form() {

    $form = array();

    $form['#attributes']['enctype'] = "multipart/form-data";

    $form['background_left'] = array(
        '#type' => 'file',
        '#title' => 'Obrázok na ľavej strane',
        '#required' => TRUE,
    );
    $form['background_right'] = array(
        '#type' => 'file',
        '#title' => 'Obrázok na pravej strane',
        '#required' => TRUE,
    );

    return system_settings_form($form);
}

function lafemme_background_images_form_submit($form, $form_state) {

    $validators = array(
        'file_validate_extensions' => array('jpg','jpeg','bmp','png', 'gif'),
    );

    $file_left = file_save_upload('background_left', $validators, '/sites/default/files/lafemme/backgrounds/');
    $file_right = file_save_upload('background_right', $validators, '/sites/default/files/lafemme/backgrounds/');

    if ($file_left) {
        drupal_set_message('Obrázok na ľavej strane je nastavený');
    } else {
        drupal_set_error('background_left', 'Chyba pri uploade ľavého obrázka');
    }

    if ($file_right) {
        drupal_set_message('Obrázok na pravej strane je nastavený');
    } else {
        drupal_set_error('background_right', 'Chyba pri uploade pravého obrázka');
    }

}

```

But it doesn't work. Form is acting like there are no files selected on submit even if they are. Later I found out that it doesn't work probably becouse of `system_setting_form` function. In drupal 7 there is a `managed_file` type of input. But what about Drupal 6? It is possible to upload a file in system\_setting\_form()?

# Answer
I found the problem: https://www.drupal.org/node/64984

**Drupal 6 won't upload a file if file field is required.**

Such an enormous bug. No mention in documentation about that, you have to find it yourself. Drupal can be really disappointing...
> 0 votes

---
Tags: files, media
---


# Question
Title: What way should I use to load a file from a module?
What way should I use to load a file from a module?

I am writing a module which is divided into 3 parts

* Custom core will be in the module which contains basic functions required for project
* Custom notification section will handle the notifications to show on site (It has a section on site where user can see all notifications.)
* Custom mail will handle mail (Users will get email on each activity.)

So I have now a module file and 2 include files, but I am confused on how to include them in .module file.

There are 3 different methods available, but I am not sure which one is best and what the major differences between them are.

1. `require_once drupal_get_path('module', 'custom_module')`
2. `files[] = mail.inc`
3. `module_load_include('inc', 'custom_module', 'mail.inc')`

I tried them, and they all are working fine for now; I don't have much experience to guess future issues.

# Answer
`module_load_include()` is a wrapper around `require_once`, with some sugar, so those are essentially equivalent. In the Drupal world, it would make sense to use the Drupal-specific function.

The files\[\] directive is for class autoloading - you don't use it to include files as such, just to make classes in those files available automatically when you need them.

You shouldn't use `module_load_include()` at the top of a module (or any other) file, it should be used only after Drupal has been bootstrapped. From the docs:

> Do not use this function in a global context since it requires Drupal to be fully bootstrapped, use require\_once DRUPAL\_ROOT . '/path/file' instead.
> 2 votes

# Answer
The best way for drupal to know you have included files is having it in the `files[]` directive, as Clive says this is perfect for classes, but you can also use it for any files.

Using `module_load_include()` you can add some loading logic, you can load also files from another module, and for best performance you can load them from within a function or a conditional structure. That way is only loaded when you are using it.
> -1 votes

---
Tags: 7
---


title: How to show users with the same term?

text:
# Question
Title: How to show users with the same term?
I added a term reference field (field\_department\_term\_ref) to user entity (/admin/config/people/accounts/fields), then I need use Views to list all the users with the same term as current logged in user (including current logged in user himself). I referenced this post, But unfortunately there are 2 differences:

1. Contextual filter "User: field\_department\_term\_ref" can not get the right default value.
2. If I don't select the "Exclude" checkbox in the MORE section, it will only show current user himself; if not, it will show others users but no current user.

# Answer
By default it provides a way to pass the term from current node and not from user. But there are two different ways to do this :

1. By Custom Code : Get the term id using `$user` variable and pass term id to the views\_embed\_view function which is used to render the views.
2. Create two views :

* **First view** : User list with contextual filter `term` field that is added in account settings.
    * **Second View** : User view with contextual filter `uid` that filters the current logged in user.

    -- In field section add `term id` field and `exclude` it from there.

    -- Next field would be the first view which prints the list of users by taking the term argument.

    -- Pass the token of `tid` in argument section of view field.

To add a views as a field you need a module : Views Field View.
> 2 votes

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


# Question
Title: Unique file system for multiple domains in Domain Access
I have created five domains using domain access module like

* test1.com
* test2.com
* test3.com
* etc,

Now i want each users from different domains have to use unique file system in order to upload media. From that i don't what users from other domains can access remaining domain's file system.

for example test1.com users can access only their own file system called test1.

Is there any way to do this in Domain Access Module? or any other module & Coding is needed?

# Answer
There is a sandbox module that appears to do what you need: https://github.com/markwk/domain\_files

Essentially it extends the DrupalPrivateStreamWrapper class to provide a file path for each domain.

There is more discussion on d.o here with other methods people have tried: https://www.drupal.org/node/198131
> 0 votes

---
Tags: domain-access, files
---


title: How to know Active sessions in Drupal?

text:
# Question
Title: How to know Active sessions in Drupal?
Is there any way to find my opened/active sessions and close them in Drupal? If there is already a session for the logged-in user, a notification like the following should be shown.

> Open in 1 other location - Details

Similarly as administrator user, I would like to view active sessions for all users. I know that all sessions are stored in the *sessions* table. I can retrieve them by creating a custom module, but I wonder if there is a module available for this.

# Answer
> 1 votes
There exists a module for that called Active Sessions

> Active Session is a module that allows a user to see if there is more than one session opened for their user and allows them (with permissions) to end other sessions belonging to their user. There is also an interface where a user with permissions can view all active sessions and close them.
>
> Active Session creates a block that, by default, is placed in the footer of the page for users with 'view own sessions' or 'view all sessions' permissions to see and get more details about the sessions.

Images from module page

---
Tags: 7, sessions
---


# Question
Title: In Scald, is there a way to link a scald atom shown using an image style to the original image?
I still haven't figured out how to link to the original atom from a display context. For instance, if the context for an image is to downscale to a specific Image Style, I want to be able to link to the full size image (this is what users with prior exposure to WordPress expect).

So far I've tried the following:

**1.** Finding a way to autopopulate the link field when I edit atom properties (see screen shot below).

However, I've been informed that this option is not for the automatic link purpose, so I've abandoned this approach.

**2.** Setting "Link to content" to "yes" in the Manage Field display tab (see screenshot below). That does not seem to make a difference (the image does not become linked to anything).

I've tried both Scald 7.x-1.3 and 7.x-1.4 - and yes: I have cleared the cache.

Do anyone know where to find the setting for this?

# Answer
This option is not for the automatical link purpose.

What you want is always to link to the original image. This is configurable in the Manage Field display tab.

In your 2nd setup, enable "Link to content" will link to the *content* (the host entity, not the atom itself). If you want the image is linked to the atom, then there are two options:

1. Write a custom player and use it (the current player has no "link" option)
2. Configure qt the Manage display of the atom (admin/structure/scald/image/display), hide the atom itself and show the image field, with the link option.
> 0 votes

---
Tags: scald
---


# Question
Title: How to link (a menu item) to the RSS feed?
In our Drupal installation there is a menu item for the RSS feed, pointing to path *de/rss* for the German feed.

This path appears unchanged in the frontend and is invalid, hence results in a 404.

The correct URL is /de/rss.xml or just /rss.xml.

Weird thing is, that Drupal accepts the non-working path, while it rejects the correct ones:

> The path 'de/rss.xml' is either invalid or you do not have access to it.

What's going on?

**Note**: I'm using the i18n module. And when I call /de/rss.xml it gets redirected to /rss.xml.

# Answer
> 1 votes
If you're using i18n module, and after you have installed module Variable, you should enable the `i18n_variable` module (one of the i18n submodules that requires the Variable module, among others).

Then navigate to `/admin/config/regional/i18n/variable` (= the Variables tab within ' Multilingual settings'). There you'll be able to specify all sorts of variables for which you want multi language support enabled also, using an appropriate sub-tab there, such as for "Site information", "Menu settings", etc.). Within sub-tab **other**, there is also "RSS feed for front page" (=The RSS feed for the front page, default is rss.xml). That "other" sub-tab should be between "Menu Settings" (1st sub-tab) and "Site Information" (3rd sub-tab).

I'd be curious to hear if your issue is resolved after you enable that option (by checking the checkbox).

---
Tags: routes, feeds, i18n-l10n, navigation
---


title: Unable to get PDFPreview working

text:
# Question
Title: Unable to get PDFPreview working
I have installed and setup PDFPreview module according to the instructions. The PDF attachment file name has disappeared from the article pages with nothing in its place. When I examined the HTML, there's an img tag pointing to the preview image, but it doesn't work.

When I access the preview image directly, it produces a 500 error with a (translated) error message indicating an error while producing the image. The Drupal log at Reports \> Recent log messages contains the error message

```
Unable to generate the derived image located at public://styles/medium/public/pdfpreview/3b350fd949abe27c0778b0f857ffa352.jpg.

```

I found this error report and tried the steps instructed in message #2. I created the directory sites/default/files/styles/medium/public/pdfpreview/, have tested directory permissions up to 777, and tried switching the 'Image style' preference back and forth with no success. The web server has ImageMagick 6.7.7-10 installed.

I have no idea how to even debug the issue further. The Apache error logs contain nothing, and the Drupal error message doesn't provide any indication on what has caused the failure.

How can I further debug the issue?

Detailed Drupal error log:

(I have since reverted the configuration, so that users at least have the file name link visible.)

# Answer
> 2 votes
Its possible that there is an issue with ImageMagick.

1. Check your Drupal status report. Does it show any issues? Check the Image Toolkit page at admin/config/media/image-toolkit. Does it show any issues?
2. Check your PHP error log. More detail or a stacktrace may have been logged there.

# Answer
> 1 votes
According to this thread, if you visit the configuration page of PDFPreview at admin/config/media/pdfpreview first and click Save, even if you haven't changed anything, it will work. It did in my case.

---
Tags: files
---


# Question
Title: Show system message to user when node is published
I'm looking for a way to show a system message to the author of a node, when the node gets published (by an administrator)

I think this must be achievable with Rules, but browsing the web and searching on stackoverflow did not help me out (yet).

This is what I did in Rules so far:

EVENT:After updating existing content of type Event

CONDITIONS: Content is published

ACTIONS: Show a message on the site

# Answer
System messages are displayed only once and for the current user. In your case it would be more appropriate to send an email when the node has been published.

To do so, create a following Rule:

1. Event: `After updating existing content`; restrict it by content type if necessary.
2. Condition: `User has role(s)`, select administrator role and check `Negate` to make sure this rule does not get triggered for administrators.
3. Condition: `Data comparison`, for `Data to compare` select that `node-unchanged:status` equals to `Unpublished`. This is to make sure old node was unpublished.
4. Condition: `Data comparison`, for `Data to compare` select that `node:status` equals to `Published`. This is to make sure new node is published.
5. Action: `Send mail` and configure it the way you want.

Hope this helps.
> 1 votes

---
Tags: rules
---


# Question
Title: How to download webform data to an Excel file?
I'm using the Webform module (version 7.x-4.8), which I only enabled (I didn't change any configuration). I have 10 records in the database.

I want to download the data from Webform to an Excel file, using the typical screen to do so, as in this screenprint:

I tried using these **Export Formats**:

* **Microsoft Excel**: I can't open the download with with Microsoft Excel 2007.
* **Delimited text**: No data in the file.

I also tried using these **Download Range Options** (which didn't help either):

* Set `All submissions (10 total)`.
* Set `Submissions by number from '1' and optionally to:(blank)`.

Any suggestions about what the problem might be?

# Answer
> 1 votes
Above the Download button,you can select range option from here.

# Answer
> 0 votes
Have you try to configure the "Download range options"? I'm not sure but the default config is "Download element that never have been downloaded yet" or something similar.

---
Tags: 7, webforms
---


# Question
Title: Merge 2 collumn (Display suite) to one collumn depending on resolution
In a situation with display suite and two columns (left and right) I would like to accomplish to move everything to the left column and have the ability to reorder the fields. In a classic situation the whole right column is moved under the left. For example in the left column I have field1,field2,field3 in the right field4,field5,field6 When resolution is \< 800 px I want to end up with a left column with field1,field4, field2,field5,field3,field6. Not sure how I can make this happen, and any example or suggestion is welcome.

I think one option is to start with one collumn to begin with and build a 2 collumn situation like this: http://demos.wpmission.com/strong-testimonials/examples/two-columns-via-css-column/ But maybe there is other solution to use code to move and rearange the fields from the right to left ds column?

Thx a lot !

# Answer
I would use a combination of 2 view modes plus Context Mobile Detect to trigger the different view mode
> 0 votes

---
Tags: display-suite, theming
---


# Question
Title: Complete clueless how does Facebook OAuth (FBOAuth) work
I follow this video to get my Facebook App Id and secret :https://www.youtube.com/watch?v=wyDXlSUHaE8

Drupal module: https://www.drupal.org/project/fboauth

In the setting I added Facebook App Id and secret

In block: I add in my content page.

When I click on Facebook logo and I manage to register.

As a result, I receive this error.
After that this error message appear as well. The account with username example and email example@gmail.com is not yet activated.

I not sure do I need to continues change setting in Facebook App or I need to do any setting in drupal. Need help.

Many thanks

# Answer
The message comes from the FBOauth module:

```
function fboauth_login_user($account) {
  global $user;

  if ($account->status) {
    $form_state['uid'] = $account->uid;
    user_login_submit(array(), $form_state);
  }
  else {
    if ($account->access) {
      drupal_set_message(t('The account with username %name and email %mail ' .
        'is blocked.',
        array('%name' => $account->name,
        '%mail' => $account->mail,)), 'error');
    }
    else {
      drupal_set_message(t('The account with username %name and email %mail ' .
        'is not yet activated.',
        array('%name' => $account->name,
        '%mail' => $account->mail,)), 'error');

    }
  }

  return !empty($user->uid);
}

```

So the user you're trying to log in with has not yet been activated *within Drupal*. Once the administrator has activated the account, the user will be able to log in using Facebook.

This is the correct behaviour; un-approved accounts should not be accessible just because they've been signed up through Facebook.
> 1 votes

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


title: Webform Download Results not working

text:
# Question
Title: Webform Download Results not working
I have been trying to get the download results of a webform and it has'nt worked

Here are the steps I have followed

I have checked the temp folder and .tmp files have been generated

# Answer
> 2 votes
I have selected third option of 'Download Range Options' and its working properly.

---
Tags: webforms, files
---


# Question
Title: How to pass argument into markup (renderable array)?
I'm doing a Drupal 7 module course. We're building a function in an include file that takes and argument from the URL. It then prints the value to the page. Seems simple enough, but then he does this in the example:

```
function good_morning_extra($wildcard) {
$content = array(
'#type' => 'markup',
'#markup' => '<p>' . t('The wildcard contains the value "%wildcard".', array('%wildcard' => $wildcard)) . '</p>',
);

return $content;
}

```

It's this part that has me confused, and the instructor glossed over it: `'The wildcard contains the value "%wildcard".', array('%wildcard' => $wildcard)` Why not just `'The wildcard contains the value "' . $wildcard .'"</p>'`?

It prints out the same, but I'm wondering if there's something to learn here. I'm still learning the whole "renderable array" syntax and exactly what that means. I have a feeling understanding this may be key to me understand how Drupal passes data around.

# Answer
The docs for `format_string()` should clear up the confusion:

> * **@variable**: Escaped to HTML using check\_plain(). Use this as the default choice for anything displayed on a page on the site.
> * **%variable**: Escaped to HTML and formatted using drupal\_placeholder(), which makes it display as *emphasized* text.
> * **!variable**: Inserted as is, with no sanitization or formatting. Only use this for text that has already been prepared for HTML display (for example, user-supplied text that has already been run through check\_plain() previously, or is expected to contain some limited HTML tags and has already been run through filter\_xss() previously).

So in the specific case you've provided, `%wildcard` is used to ensure that the value is :

> Escaped to HTML and formatted using drupal\_placeholder(), which makes it display as *emphasized* text.

The different placeholder types are simply used in different situations, depending on what you need to do with the value, and whether or not you trust its source.

The docs for `t()` are also worth a read for extra context.
> 2 votes

---
Tags: theming
---


title: Drupal 7 search form

text:
# Question
Title: Drupal 7 search form
I am using drupal's 7 built in search form and need to add placeholder property just for this form, in my template.php my snippet is like below:

```
function mytheme_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'search_form') {
$form['some_element']['#attributes']['placeholder'] = t('Search');
}
}

```

How can I add this in my module file as I am using built in module?

# Answer
> 0 votes
Almost there. Look at the HTML of your search form. The ID is usually search\_form. This snippet goes into the template.php of your current active theme, replace mytheme with the name of your theme.

```
function mytheme_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'search_form') {
    $form['search_form']['#attributes']['placeholder'] = t('Your new placeholder here.');
  }

```

# Answer
> 0 votes
It's very similar. Like this

```
function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'search_form') {
    $form['some_element']['#attributes']['placeholder'] = t('Search');
  }
}

```

---
Tags: 7
---


# Question
Title: Get the return value of a hook defined in a module?
Is there a way to get the return value of a hook defined in a particular module for eg:

```
$views_theme_hook = module_invoke('views', 'theme');

```

By using `module_invoke` function, I got an array of themes declared in views module. Is this proper way of doing it?

But this function needs arguments for some other hooks for eg: `hook_tokens`.

How could I get the result for `hook_tokens` and other similar hooks requiring arguments?

# Answer
> 0 votes
`module_invoke()` is a very simple function:

```
function module_invoke($module, $hook) {
  $args = func_get_args();
  // Remove $module and $hook from the arguments.
  unset($args[0], $args[1]);
  if (module_hook($module, $hook)) {
    return call_user_func_array($module . '_' . $hook, $args);
  }
}

```

As you can see, it passes the arguments straight through to the hook function by way of `call_user_func_array()`.

So, you just need to pass the extra arguments with the call to `module_invoke()`. For example, to invoke `views_block_view()` with a specific block delta, you would use:

```
$block = module_invoke('views', 'block_view', 'some_block_delta');

```

---
Tags: 7, hooks
---


# Question
Title: Access values from multiple field forms as elements of one form
I'm trying to create entities from my custom form. To do that, I created "Add more" button, where I'm dynamically adding new elements that I'm attaching fields to by using:

```
field_attach_form('myentity', $entity, $form['wrapper']['myentities'][$key]['fields'], $form_state);

```

I would like to create entities in submit callback with field values from those elements.

The problem is, that when I have a multiple elements, inputs for the same type of fields of different entities have the same "name" attribute (eg. `field_myfield[und][0][value]`), which means that I can access only the value from the field of the last entity in the submit callback, which means that I cannot fill my entity with proper values before saving. I tried to put '#tree' =\> TRUE up the form tree, and unset this value on field level, but it didn't change an input name, and "values" structure.

How can I have in my submit callback access to all of the field values, so I could use them for creating entities?

# Answer
> 0 votes
You need to use the #parents variable as documented in the field\_attach\_form page. See field\_attach\_form

---
Tags: entities
---


title: How to grow block menu on hover

text:
# Question
Title: How to grow block menu on hover
I am trying to make secondary menu grow on mouse hover. just like this site

we can see on the bottom of the page. menu block can grow bigger and show more menu.

any idea what technique used to make something like that. or maybe a module or maybe jQuery. right now i'm still googling but still got no clues. Please let me know some idea about this.

Regards

mbahlol pardon for my english

# Answer
> 0 votes
Here is a jsfiddle that will show 3 different techniques. http://jsfiddle.net/3rYCs/

# Answer
> 0 votes
I just set up something very similar on my site using the TB Menu module - https://www.drupal.org/project/tb\_megamenu

---
Tags: routes, javascript
---