# Question
Title: Only enable SSL for specific websites (Aegir)
So Aegir has a manual page on SSL.

I need to enable for one website. I enable SSL for the server and then require the certificate on that website.

But now, if I go to any other website on the same server and try the address with https://, it will present that incorrect certificate and a big error message comes up.

How can I enable SSL only for that one website I need and disable it completely for other sites?

# Answer
> 0 votes
You have to create a separate IP address for each site that uses SSL. If you only have one IP address on the server and you assign it to SSL then the whole server is essentially using SSL.

So, solution is to assign a new IP address to the server and use that when you setup SSL for a site.

More info from this link: https://groups.drupal.org/node/74248

> all non-ssl sites will use the first ip address in the list.
>
> When a site has SSL enabled, it associates an IP address with the certificate it uses. Both the SSL and non-SSL versions of all sites using the same SSL certificate will use the assigned IP.
>
> You can only host as many SSL certificate addresses as IP addresses you have on the server.
>
> The site node also now provides you with the list of IP addresses the site is running on.

---
Tags: aegir, ssl
---


# Question
Title: Strategy for deploying Panels with features
I've been exporting Panelizer configuration to features and pushing up to production. My strategy so far has been:

* Config is created on local and pushed up via features
* Content, such as Fieldable Panels Panes instances are created directly on production.

However, this is now causing issues. When I revert a Panel/Panelizer feature, it reverts back to my local settings and removes any content panes I've added on production.

A couple of ideas I have for managing content panes:

* Use UUID features to push up any content panes. Trouble with this is that the content panes are now in the dev/stage/live workflow and any changes on production will be reverted with the next `drush fra`.
* Pull down a fresh copy of the database before doing any further edits to a feature, that way when a feature is recreated on local, it will contain the new content panes.

How do you manage content panes when using features?

# Answer
We have very similar problems - not only with features but in other areas as well. The best solution we came up with so far is close to your second one:

Drupal 6 & 7 - Yin/Yang Multisite Staging
https://www.drupal.org/node/942540

So here you'd switch with the new DB version into the Staging system and use the Staging as the new Live version. But I don't feel too comfortable about this + it might not work everywhere if the two Servers are different.

In a way less complex evironment with small changes I'm doing the following: Every night the DB will be copied from Live to Dev. In this environment I'm sure I only have small changes in Dev which take usually minutes to an hour max. and I've got a fresh DB every day and can start from there.
> 1 votes

---
Tags: panels, features
---


title: Default logo according to theme setting

text:
# Question
Title: Default logo according to theme setting
I'm creating the theme with two styles, dark and light. User can choose which style he wants in theme settings. My default theme logo is in the root of the theme.

Now I want to change default logo according to choosen style, so if the user choose dark style and doesn't set logo image, default logo is `logo.png` form theme root, but if user choose light style and doesn't set logo image, default logo is `logo_light.png` from theme root.

How can I override default logo according to result from `theme_get_setting`?

# Answer
> 0 votes
A cleaner solution would be using your theme `hook_preprocess_page`, for example in a multi skin theme i have:

```
function mytheme_preprocess_page( &$vars)
{
    //-> skin name, use default logo?, show logo?
    $skin = theme_get_setting("skin");
    $default_logo = theme_get_setting("default_logo");
    $toggle_logo = theme_get_setting("toggle_logo");

    $url = file_create_url(drupal_get_path('theme', 'mytheme'));

    if( $default_logo && $toggle_logo)
        if( empty($skin)) $vars['logo'] = "$url/logo.png"; //default style logo
        else              $vars['logo'] = "$url/skins/$skin/logo.png";

}

```

then inside the page.tpl just the standard

```
<div id="header-logo">
   <?php if( $logo): ?>
      <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
   <?php endif; ?>
</div>

```

# Answer
> 0 votes
I think you can by adding algorythm like this:

```
<div id="logo">
  <a href="<? print $front_page; ?>"><img src="<? if (theme_get_setting(theme)=="dark") print $logo; else print $logo_light; ?> border="0" alt="<? print $site_name; ?>"></a>
</div>

```

# Answer
> 0 votes
I fix it. I just check if the `default_logo` checkbox is checked. There is my code:

```
<div class="logo"><a class="logo-a" href="<?php print $base_url; ?>">
<img
<?php if(theme_get_setting('default_logo') == '1' && theme_get_setting('style') == 'light'): ?>
src="<?php print base_path() . drupal_get_path('theme', 'my_theme'); ?>/logo_light.png"/></a>
<?php else: ?>
src="<?php print render($logo); ?>"/></a>
<?php endif; ?>
</div>

```

---
Tags: files
---


# Question
Title: Assigned block system to an invalid region
I've renamed a region in my .info file by mistake. After clearing the cache with drush, the block I've attached to that region was disabled. Drush printed the following message:

`The block Nivo Slider was assigned to the invalid region slider and has been disabled.`

I corrected the false region, but still the block seems to be "disabled" somehow, see picture from structure -\> blocks, below.

Already enabled/disabled Nivo Slider Module, cleared cache with drush.

# Answer
> 1 votes
I can't explain why, but if somebody does the same by mistake and assigns a invalid region to the block. The following did the job for me. Just delete the entire region and add the block to another region. Clearh the cache and afterwards setup the region you had before again and assign the block to it.

---
Tags: 7, blocks
---


title: View displays only the title

text:
# Question
Title: View displays only the title
I've got a view for the content type article to display them. I'd like it to display the `full content` or the `teaser`.
As a format I've chosen unformatted list.

But whatever I choose (rendered entity/display suite/teaser/full content) I will only see the titles in my view and a read more link.

The body field is `Long text and summary` but I didn't use the summary so far.
Does anybody know this behaviour? I'm sure it's just a small setting somewhere but I didn't see this before and I ran out of ideas where to search for the solution.

Edit: Even in the content type, everything looks fine. In full content and teaser, all fields are beding displayed.

# Answer
> 0 votes
Just to be sure, navigate to admin/structure/views within your site. Then perform an "edit" of your view. On the next screen, select the "views display" for which you're having this issue. Then verify if all the "fields" that you want to be shown in your view are actually included.

E.g: if you'd only have field "Title" shown in the list of fields (and "Content: Body" is not in the list of fields to be shown), then that would explain your issue. In that case, use the "Add" button next to "fields" to add the fields you want to be added.

Curious to hear if this is the "*... small setting somewhere ...*" that you were looking for.

---
Tags: 7, views
---


# Question
Title: How to prevent showing background code in Drupal 7 admin?
I am seeing the following screen when i am saving or updating a node in drupal 7 admin.

I am using Drupal 7 with Seven theme.I am seeing the following texts in white screen.To get the actual i need to click back button.

> \[ {"command":"settings", "settings":{"basePath":"\u002F", "pathPrefix":"", "ajaxPageState":{"theme":"nbiz\_train", "theme\_token":"BVOiHIMf2BoQgMAltQtiv\_GRDGBYoFOGNn3hJ8eJRxw"}, "colorbox":{"opacity":"0.85", "current":"{current} of {total}", "previous":"« Prev", "next":"Next »", "close":"Close", "maxWidth":"98%", "maxHeight":"98%", "fixed":true, "mobiledetect":true, "mobiledevicewidth":"480px"}}, "merge":true} \]

How can i remove this error?

# Answer
> 1 votes
Sounds like it may be related to (caused by) JQuery Update, similar to what is described in "Cannot edit my views.. I get a JSON string?".

Maybe you want to (temporary) try any of these potential work arounds:

* Disable or change the settings within JQuery Update (to see if it solves the issue).
* Change the admin theme to any theme included in the Drupal version you downloaded.

---
Tags: debugging
---


# Question
Title: I can't fetch anything else than '1' to my PDO query
Here is my PDO request :

```
$query = db_select('review_ratings_table')
   ->fields('review_ratings_table',array('review_nid'))
   ->condition('loc_id', $loc_id, 'LIKE')
   ->condition('user_id', $user_id, 'LIKE')
   ->condition('valid', '1', '=')
   ->execute();
while($record = $query->fetchAssoc()) {
 drupal_set_message('<pre>test '.print_r($record).'</pre>');
}

```

I have tried many ways to get the result of this request (fetchAll, fetchField, fetchAssoc ...) and I keep printing "1" instead of the review\_nid or anything else.

Thanks for you help.

Will

=\> Hi, If I use dvm($query) I get that :

> DatabaseStatementBase::\__set\_state(array( 'dbh' =\> DatabaseConnection\_mysql::\__set\_state(array( 'needsCleanup' =\> false, 'target' =\> 'default', 'key' =\> 'default', 'logger' =\> NULL, 'transactionLayers' =\> array ( 'drupal\_transaction' =\> 'drupal\_transaction', ), 'driverClasses' =\> array ( 'SelectQuery' =\> 'SelectQuery', 'DatabaseTransaction' =\> 'DatabaseTransaction', ), 'statementClass' =\> 'DatabaseStatementBase', 'transactionSupport' =\> true, 'transactionalDDLSupport' =\> false, 'temporaryNameIndex' =\> 0, 'connectionOptions' =\> array ( 'database' =\> '\*******', 'username' =\> '\*******', 'password' =\> '\*******', 'host' =\> 'localhost', 'port' =\> '3306', 'driver' =\> 'mysql', 'prefix' =\> array ( 'default' =\> '', ), ), 'schema' =\> NULL, 'prefixes' =\> array ( 'default' =\> '', ), 'prefixSearch' =\> array ( 0 =\> '{', 1 =\> '}', ), 'prefixReplace' =\> array ( 0 =\> '', 1 =\> '', ), )), 'queryString' =\> 'SELECT review\_ratings\_table.review\_nid AS review\_nid FROM review\_ratings\_table review\_ratings\_table WHERE (loc\_id LIKE :db\_condition\_placeholder\_0 ESCAPE \\'\\\\') AND (user\_id = :db\_condition\_placeholder\_1) AND (valid = :db\_condition\_placeholder\_2) ', ))

and

> Error message Recoverable fatal error: Object of class DatabaseStatementBase could not be converted to string in review\_ratings\_table\_node\_presave() (line 52 of C:\Bitnami\drupal-7\apps\drupal\htdocs\sites\all\modules\custom\review\_ratings\_table\review\_ratings\_table.module).

and

dvm($query-\>fetchAssoc()); gives me that

> array( 'review\_nid' =\> '2', )

Which is what I want but I don't know how to access it.

Thanks

# Answer
With `drupal_set_message('<pre>test '.print_r($record).'</pre>');` you're putting the return value of `print_r` into a string, not printing the contents of `$record`.

You can acccess the value you need with:

```
$result = $query->fetchAssoc();

// make sure we found something
if (empty($result) || empty($result[0]['review_nid'])) {
  dpm("No result");
}

// load the noad we found
$node = node_load($nid)
dpm($node);

```
> 0 votes

---
Tags: database
---


title: show positive and negative votes

text:
# Question
Title: show positive and negative votes
i'm trying to make a 'top voted' view of nodes and I want it to appear like this:

title of node; 655 positive, 120 negative votes, total 775.

how do i do the '655 positive, 120 negative votes' part?

# Answer
> 0 votes
The Vote Up/Down module, while it supports Views 2 integration, only allows for a Voting Up/Down widget. With no support in the module for retrieving the vote count, you'll need to do one of the following:

1. Wait for the maintainer to add a views handler that supports up & down votes data.
2. Create your own patch that adds support for that data.

Given the current state of the project (seeking maintainer, 7.x version not released), you're probably going to have to go with #2.

---
Tags: theming, 6, rating
---


# Question
Title: EntityMalformedException: Missing bundle property on entity of type node
I'm doing a drupal 7 website, I've now started to experience a "EntityMalformedException: Missing bundle property on entity of type node. in entity\_extract\_ids() (line 7820 of C:\xampp----\includes\common.inc)." error whn I try to view a node in full view mode and only if I'm logged in as administrator.

This is happening here:

```
if (!empty($info['entity keys']['bundle'])) {
// Explicitly fail for malformed entities missing the bundle property.
if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
  var_dump($entity);
  throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
}

```

I found some pages about this error but none seems to apply to my case. I put a var\_dump just before the instruction throwing the exception and all I get is bool(false). I've checked all the bool fields of the node and they all have #bundle correctly set.

I think the problem might have started after installing the database optimization module. I found some information regardin this error and clearing the form\_cache but I didn't understand if this can apply to my case.

I guess these hints are enough to trace the problem for a drupal expert, unfortunately not for me.

Any suggestion? Thanks

# Answer
It was this: https://www.drupal.org/node/1888610 . . . . . . . . . . . . . . . .
> 0 votes

---
Tags: entities
---


# Question
Title: How to create a chart system with Date ranges like Google Analytics?
I want to create a chart system for my website, for the apparel trend forecasting company. To do so, I want to add trends of sales based on today, yesterday, this week, this month, and year trend.

I have created the chart, but can't find any module to solve my purpose. I tried the Date Facets module, but I don't know why I cannot get it to work, even though I have installed the Facet API too.

Is there any similar module to make this work?

Some more details about what I'm trying to do:

* suppose it's a chart about shirt trends.
* about these types of shirts: sleeveless, half sleeve, or full sleeve.
* filtered by Today, Yesterday, This week, This month, this year.

# Answer
Consider looking at the Comparison of Charting modules. Here is a quote from it:

> There are a variety of modules that facilitate the creation of charts. When it comes to charting in Drupal, the saying "There's a module for it" doesn't really apply. In this case, it's more accurate to say, "There are plenty of modules for it" ...
>
> These modules support for various charting libraries that may be desirable based on a site's desired appearance, feature-set, and licensing needs.

Using the Charts module is one of the options to consider. Here is part of what's currently included in that link (its project page):

> Transform **Data** into **Information**. Charts are a very good way to visualize a lot of data in a way that can be quickly digested.
>
> **Features**
>
> - **Wide chart type support**: Pie, Line, Bar, Column, Area or Scatter charts.
> - **API**: A Drupal-friendly syntax for creating charts easily, regardless of the underlying library.
> - **Views integration**: Display the Views results as charts.
> - **Examples**: The module includes lots of example charts for you to reference when building your own charts or chart library integration.
> - **Supported charting libraries**: out of the box, you may use either (the new) Google Charts (**GC** for short) or Highcharts (**HC** for short) as the charting library.

For 'documentation' about the charts module, you may want to start from its community documentation.

There is an issue also that might be worth looking at, about Graph node input over time (support date formatting on a continuous axis). In Comment #3 of that issue is stated: 'The trouble here is that neither Views nor Date modules provide aggregation options for date-based fields'.

Disclosure: I'm the author of the comparison (+ co-maintainer of the charts module), I hope this does not violate the site's policy on self-promotion.
> 1 votes

---
Tags: 7, datetime, charts
---


# Question
Title: Importing blog articles from a WordPress site
I am looking for a module to import any blog written on a WordPress site. Is there any module to do this?

# Answer
> 2 votes
If you're looking for periodic imports from a WP site to Drupal, then one module solution is the Feeds module. It allows you to do periodic imports of RSS feeds. You can point it at your WP **example.com/?feed=rss** RSS feed and have it import in your content.

# Answer
> 3 votes
Maybe WordPress Migrate is what you are looking for? Excerpt from its project page:

> supports migrating WordPress blog exports (WXR format) into Drupal using the Migrate module. Import of posts, pages, comments, attachments, tags and categories is supported. Imports can be rolled back completely.

---
Tags: 7, importing-exporting
---


title: Refreshing a block using AJAX

text:
# Question
Title: Refreshing a block using AJAX
I am trying to apply the example from \[the Flag API page\]\[1\] to refresh a block dynamically via AJAX. I am looking into customised jQuery code because my block is created via a module, not a view.

I have implemented the callback in the .module file and it works. It is when I try to copy `blockExistsOnPage()` where I fail. It talks about a component module which is necessary for the execution of the code, but this module is obsolete for drupal 7. I think that I stumble on the definition of `var domId`. This is my JavaScript code.

```
(function ($) {
 $(document).bind('flagGlobalAfterLinkUpdate', function(event, data) {
   alert('Object #' + data.contentId + ' (of type ' +
   data.contentType + ') has been ' + data.flagStatus +
   ' using flag "' + data.flagName + '"');

    if (data.flagName == 'myflag') {

        if (blockExistsOnPage('mymodule', 'mymodule_blockid')) {
            refreshBlock('mymodule', 'mymodule_blockid');
        }
    }
  });

// Attempt at refreshing the block
function blockExistsOnPage(module_name, block_id) {
  var domId = module_name + '/' + block_id;
  return $('#'+domId).length != 0;
}

function refreshBlock(module_name, block_id) {
  var domId = module_name + '/' + block_id;
  $.get(base_url + 'node/' + $nodeid + '/' + block_id, null, function(newHtml)  {
    // Replace the old block with the new one.
    var domElement = $(newHtml).insertAfter('#'+domId);
    $('#'+domId).remove();
    if (Drupal.attachBehaviors) {
       Drupal.attachBehaviors(domElement);
    }
 });
}

```

edit: I am trying to use a $.ajax request instead. It seems cleaner, but I am struggling to get my relative address of the type node/\[nid\]/module\_name/block\_id. Should I modify the block\_id in the menu hook? Or should I find a way to create a url in the jquery:

module hook menu: function get\_involved\_menu() {

```
// Ajax Callback. Returns updated content of block
$items['block_id'] = array (
 'title' => 'Content of module_name block',
 'page callback' => 'module_name_createcontent',
 'access arguments' => array ('access content'),
 'type' => MENU_CALLBACK,
 );

return $items;
}

```

jquery: $(document).bind('flagGlobalAfterLinkUpdate', function(event, data) {

```
  $.ajax({
     type: "POST",
     url: 'module_name/block_id',
     success: function (data){
        $('div.get-involved-divblock').html(data);
     }
   });
 });

```

the code below returns an empty block. If I am on node '57', and I put instead

```
 url: '57/module_name/block_id',

```

Then it returns the content. How can I make it a relative path? How do I obtain the node id in the jquery?

# Answer
> 1 votes
depending on how your module is setting up the block, you could look into Block Refresh:

> Block Refresh allows an administrator to configure a block to refresh it's content via 3 different methods: automatically via a timer (eg every 30 seconds) , manually via a 'refresh' link, and once on page load.
>
> Block Refresh uses jQuery/AJAX so the refresh happens "behind-the-scenes".
>
> Block refresh can be handy to serve fresh content in certain blocks on otherwise cached pages. You can opt to bypass drupal's cache for the refresh callbacks for each block.

**Edit**

I just ran into this exact problem and developed a simple little approach that works nicely:

* using Block Refresh

+ set up each of the blocks you want to refresh as manual - this would normally cause a link to appear in each block allowing a click refresh
* create some css to hide the ugly links:

```
.block-refresh-button
{
    display:none;
}

```
* then add a simple jQuery click to force block refresh to do all the work for you - this can be modified appropriately as necessary:

```
jQuery(".flag-wrapper").click(function()
{
    jQuery(".block-refresh-button").each(function()
    {
        jQuery(this).click();
    });
});

```

I found this will refresh ALL blocks on the page set up with block refresh, including Views.

---
Tags: 7, blocks, javascript, flags
---


# Question
Title: Can't click link added to header of a block
In Drupal 7 I created a views page, and I want users to have the option to view the results either as a list, or with thumbnails (like on a lot of websites). The only way I can think of doing that is creating one page with the results as a list, and having a link to another page with the results that have thumbnails.

But my question is, how do I add just a random link to the top of my block page that will direct users to the 'thumbnail' page?

I tried to use 'unfiltered text' in the header and put the html for a link in there, and when I went to the page it looked like a link, but I couldn't click it. Any suggestions?

# Answer
> 1 votes
If I understand the question correctly, this can easily be done using Views alone with a nice tabbed menu:

* Create your view page as normal, with the default information provided, except for the url - set that to whatever you want, in my example /tabs
* change the Display name under Page details to: Base (just to make things easier to read later on)
* Add a Page
* Change the Display name to the format type of the default page, presumably 'List View'
* set up the format, show, fields, filter, sort, etc. how you want the list view to be displayed - be sure to change the 'For' drop down from All displays to 'This page (override)' - or the changes you make will be set for all the pages, but you want different settings for each page
* set Path: tabs/list
* set Menu: Default menu tab, Title: View as List, Parent: already exists
* Add a Page
* Change the Display name to the format type of the second page, presumably 'Thumbnail View'
* set up the format, show, fields, filter, sort, etc. how you want the thumbnail view to be displayed - be sure to change the 'For' drop down from All displays to 'This page (override)' - or the changes you make will be set for all the pages, but you want different settings for each page
* set Path: tabs/thumbnail
* set Menu: menu tab, Title: View as Thumbnails, Menu: Navigation
This should create a tabbed menu at the top of your view for easy navigation by users:

# Answer
> -1 votes
You can remove title by setting it to `<none>` or leaving it empty. Then other block can be used to look like title with links on it.

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


title: webform validation integer value

text:
# Question
Title: webform validation integer value
I tried webform validation, I can validate textfield component for numeric value. However, I cannot find how to set it as integer value only. How can I validate numeric (integer) value.

# Answer
Webform Validation's numeric validator relies on PHP's is\_numeric. Thus, any numeric expression (e.g. 1.5) is going to be validated there. In order to validate integers only, you'll need to use Regex validation where only integers character can be valid (e.g. "^(\[0-9\]+)$").
> 2 votes

---
Tags: webforms, forms
---


# Question
Title: How can I insert a variable from a preprocess function in template.php to Block Body in admin
Seems like a pretty easy thing to do, but I am having a hard time in using a variable from `function theme_preprocess_block(&$variables, $hook)` in template.php in a Block body in admin.

For example, in template.php, I have:-

```
function theme_preprocess_block(&$variables, $hook) {
  $variables['theme_url'] =  base_path().drupal_get_path('theme', variable_get('theme_default', NULL));

}

```

From here, I want to use `theme_url` variable in Block Body in admin as shown:-

It's not happening through the shown way. Any idea how I can achieve that?

Thanks.

# Answer
> 1 votes
You can't do that.

The block content doesn't ahve access to variables you add in the block preprocess function. The block preprocess function code runs after the block content has been generated.

Since you have a PHP block just add that code from your preprocess function directly to it.

So put this at the top of your block content:

```
$theme_url = base_path() . drupal_get_path('theme', variable_get('theme_default', NULL));

```

# Answer
> 1 votes
Instead of using a PHP block I would recommend to use a template for that block – then you should be able to use your preprocessed variables.

The Community Documentation page about Drupal 7 Template (Theme Hook) Suggestions might be useful for finding the correct name for the block template.

---
Tags: theming, blocks
---


# Question
Title: Howto get ID on newly created content through Drupal 8 REST POST
I have a working decoupled/headless setup working using Drupal 8 beta 10 as a backend, and a html5/js webapp as frontend, on seperate servers.

For this scenario, I'm succesfully able to post new content (an article node) as an anonymous user, using the REST /entity/node endpoint.

This works fine, I receive a 201 "Created" response, but now I'm trying to figure out a way to get the ID of this newly created node so I can GET and render it.

The current documentation and response does not provide a return (N)ID. Am I overlooking something or is this a bug?

# Answer
Looking at the response code for POST requests, we can see that there's no body but a header set to the full URI of the node. You can save that URI or explode it/parse it to get just the nid.

```
  // 201 Created responses have an empty body.
  return new ResourceResponse(NULL, 201, array('Location' => $entity->url('canonical', ['absolute' => TRUE])));

```
> 0 votes

---
Tags: 8
---


# Question
Title: How do I disable a core installation profile?
There is the Allow install profiles to be uninstalled issue that doesn't allow installation profiles to be uninstalled. Is there any way to do this in D7? (With a little more effort if necessary.)

When you install D7, you typically have to choose an install profile; this could be the "standard" profile shipped with Drupal core. Once installed, the install profile will sit in the "system" table forever, with no obvious way to disable it.

Is there some more hackish way to disable the install profile.

To harmonize the question with the accepted answer even more, I extend the question to: If the install profile cannot or should not be disabled, then can it be *replaced* at least?

# Answer
> 9 votes
In Drupal 7, a install profile is like a module, but a special one, with two major exceptions:

* Any module required by a install profile can be disabled --as you have found-- except the ones required by drupal core (field, filter, node, system, user). See module\_disable() function for details, where the dependency on the install profile is explicitly discarded.
* The profile used to install a site is also a required module. This is hardcoded in drupal\_required\_modules().

So a profile can't be uninstalled, because it is a required module.

You can set status to 0 in system table, but you shouldn't, since:

* Drupal expects the install profile to be enabled, and rely on that for some operations, none if them critical afaik.
* it is a module, it may implement any hook (in its .profile file), or declare any function required by a profile's submodule. Disabling it the hard way may produce misfunction or a php fatal error in those scenarios.

Btw, the install profile used to install the site is stored in the `install_profile` variable

```
# drush vget install_profile
install_profile: 'minimal'

```

You can, if you find it useful for some reason, change the install profile by setting install\_profile to any other profile name and *enabling* it in the system table.

# Answer
> 2 votes
The Profile Switcher module for D7 may help: https://www.drupal.org/project/profile\_switcher

# Answer
> 1 votes
The following query would set the status of the install profile to 0 (disabled).

```
UPDATE `system` SET `status` = '0' WHERE `filename` = 'profiles/YOURPROFILE/YOURPROFILE.profile';

```

or

```
UPDATE `system` SET `status` = '0' WHERE `type` = 'module' AND `name` = 'YOURPROFILE';

```

or in an update script:

```
function YOUR_MODULE_update_7100(&$sandbox) {
  db_update('system')
    ->fields(array('status' => 0))
    ->condition('type', 'module')
    ->condition('name', 'YOURPROFILE')
    ->execute();
}

```

# Answer
> 1 votes
Habitat module is your option and I'm not using this before. The specified modules are enabled and disabled based on a variable you set in settings.php

> It provides settings to enable or disable certain modules on each environment (habitat). Just set a variable with e.g. $conf\['habitat'\] = 'local'; in your settings.php file (the actual variable to use there is configurable for your current workflow). The disabling/enabling modules is done on hook\_init.

---
Tags: installation-profiles
---


# Question
Title: Is it possible to assign an anonymous user's flags to a new user on registration?
So, I'm working on a sample request feature which allows anonymous users to flag items and submit sample/inquiry requests. I'm debating converting the form to automatically register the user on submission, but I'm wondering if anyone had a way of saving the anonymous user's flags to the newly created user?

# Answer
The flags module supports Rules integration and a flagging/unflagging event. I would look at that as a possible starting point for this feature. Rules has many different actions that should help you build out a workflow for such a scenario.
> 1 votes

# Answer
I am not aware of any module that already does this with flags. But you can take a look at Anonymous publishing. Its "Lazy Registration" mode will assign any *node* created by the anonymous user to a newly created user if that anonymous user later registers an account.

The method used is to require the anonymous user to submit and confirm an email address when creating a node. When somebody with that email register, the nodes tagged with that email address can be assigned to that newly created user.

It should not be difficult to use the same method to assign for flags/requests created by the anonymous user to a newly created user.

If you can allow for some errors, you can use something less intrusive than a confirmed email address to link the anonymous user to the newly created user, such as a persistent cookie (will fail when the cookie expires or the user moves to a different computer), or an IP-address (will fail if the user moves to a different computer, if two different users users use the same computer, or if a dynamic IP-address gets reassigned.)
> 2 votes

---
Tags: users, flags
---


# Question
Title: Apply custom css class while rendering an image
Here I want to add an attribute for custom css class, is this possible using field\_view\_value, `field_menu_image` is my image's machine name

```
$image = field_get_items('node',node_load($nid, NULL, TRUE), 'field_menu_image');
$output=field_view_value('node', node_load($nid, NULL, TRUE), 'field_menu_image',$image[0]);
print render ($output);

```

# Answer
field\_view\_value returns a renderable array so you should be able to just do.

```
$image = field_get_items('node',node_load($nid, NULL, TRUE), 'field_menu_image');
$output=field_view_value('node', node_load($nid, NULL, TRUE), 'field_menu_image',$image[0]);
$output['#item']["attributes"]["class"] = array('test');
print render ($output);

```
> 1 votes

---
Tags: 7
---


# Question
Title: What am I doing wrong when trying to set the default value for this radio button form element?
```
$options = array(
    'yes' => t('Yes'),
    'no' => t('No'),
    'maybe' => t('Maybe'),
  );

  $form['infx2670selig_kangaroo_eating'] = array(
    '#type' => 'radios',
    '#title' => 'Would you eat a kangaroo?',
    '#default_value' => t('No'),
    '#options' => $options,
    '#required' => TRUE,
  );

```

I don't see what's going wrong. By default, none are selected.

# Answer
> 6 votes
The `#default_value` is the `key` in the `$options` array. you want:

```
'#default_value' => 'no',

```

# Answer
> -1 votes
If you want to set default value that's you've chosen before submit the form or in multisteps form then

```
$kangaroo_eating = isset($form_state['infx2670selig_kangaroo_eating']) ? $form_state['infx2670selig_kangaroo_eating'] : ''; <br>
  $form['infx2670selig_kangaroo_eating'] = array(
    '#type' => 'radios',
    '#title' => 'Would you eat a kangaroo?',
    '#default_value' => t('No'),
    '#options' => $options,
    '#required' => TRUE,
    '#default_value' => $kangaroo_eating,
  );

```

---
Tags: 7, forms, webforms
---


# Question
Title: How to override Bootstrap theme files in sub-theme
I'm creating a sub-theme based off Bootstrap. I've followed the instructions here and is working ok.

Now I want to override the `tpl` files in `theme/block`, `theme/system`, etc.

In my sub-theme I've created the folder structure mimicking the one on Bootstrap (at least for the ones I want to override), yet it seems my files are not being used.

How can I override the aforementioned files (preferably) using the same structure?

Thanks for your help

# Answer
> 4 votes
You should put those files in yourtheme/templates/ (no sub-folder) and a quick cache clear after that.

See **bootstrap\_subtheme/templates/README.txt**:

> This folder is where you should place all your overriding template files. By default, the Bootstrap base theme provides all the necessary template files in various folders inside of sites/*/themes/bootstrap/theme. For example, the page.tpl.php template file is located at sites/*/themes/bootstrap/theme/system/page.tpl.php. To override any of these files, copy them from the Bootstrap base theme and place them in here.

---
Tags: theming
---


title: Drupal Field API - Settings List

text:
# Question
Title: Drupal Field API - Settings List
I'm trying to create a 'link\_field' in Drupal through a module, I've got the following code but I'd like to configure the field settings to do the following:

* Not require title
* Update the number of values to unlimited

I'm struggling to find any information around what setting key/pair values you can pass through for these, anyone able to offer some guidance on these?

```
    <?php
/**
 * Implements hook_enable().
 *
 * Create a field. Fields can be created without any needs to attach them to
 * entities.
 */
function youtube_carousel_enable() {
  $field = array(
    'field_name' => 'ytcarousel_field',
    'type' => 'link_field',
  );
  field_create_field($field);

  /**
  * Bind field to a entity bundle.
  */
  $instance = array(
    'field_name' => $field['field_name'],
    'entity_type' => 'node',
    'bundle' => 'homepage',
    'label' => 'YouTube Video'
  );
  field_create_instance($instance);
}

/**
 * Implements hook_disable().
 *
 * Remove field from node bundle (content type) and then delete the field.
 */
function youtube_carousel_disable() {
  $instance = array(
    'field_name' => 'ytcarousel_field',
    'entity_type' => 'node',
    'bundle' => 'homepage',
    'label' => 'YouTube Video'
  );
  field_delete_instance($instance);
  field_delete_field($instance['field_name']);
  print 'Removed ' . $instance['field_name'] . "\n";
}
?>

```

Cheers

# Answer
After viewing the HTML source to get key/value pairs I've managed to do something similar to the above with the following code:

```
<?php
/**
 * Implements hook_enable().
 *
 * Create a field. Fields can be created without any needs to attach them to
 * entities.
 */
function youtube_carousel_enable() {
  $field = array(
    'field_name' => 'ytcarousel_field',
    'type' => 'link_field',
    'cardinality' => -1
  );
  field_create_field($field);

  /**
  * Bind field to a entity bundle.
  */
  $instance = array(
    'field_name' => $field['field_name'],
    'entity_type' => 'node',
    'bundle' => 'homepage',
    'label' => 'YouTube Video',
    'settings' => array('title' => 'required')
  );
  field_create_instance($instance);
}

/**
 * Implements hook_disable().
 *
 * Remove field from node bundle (content type) and then delete the field.
 */
function youtube_carousel_disable() {
  $instance = array(
    'field_name' => 'ytcarousel_field',
    'entity_type' => 'node',
    'bundle' => 'homepage',
    'label' => 'YouTube Video',
    'settings' => array('title' => 'required')
  );
  field_delete_instance($instance);
  field_delete_field($instance['field_name']);
  print 'Removed ' . $instance['field_name'] . "\n";
}
?>

```

The **cardinality** controls have many instances the value can have, "-1" is unlimited.

```
'cardinality' => -1

```

The title attribute is controlled via the instance not the field itself, I believe, and it uses text based values rather than numeric.

```
'settings' => array('title' => 'required')

```
> 0 votes

---
Tags: entities
---


# Question
Title: mysql errors after upgrading php and mysql
recently upgraded server to php 5.6.5 and mysql 5.6.22. running drupal 7.

after the upgrade we started having issues.

the server seems to run well for a week or so before starting to throw error pages with:

```
Notice: PDO::__construct(): send of 128 bytes failed with errno=32 Broken pipe in DatabaseConnection->__construct() (line 307 of /path/to/site/includes/database/database.inc).
Notice: PDO::__construct(): send of 128 bytes failed with errno=32 Broken pipe in DatabaseConnection->__construct() (line 307 of /path/to/site/includes/database/database.inc).
Notice: PDO::__construct(): send of 128 bytes failed with errno=32 Broken pipe in DatabaseConnection->__construct() (line 307 of /path/to/site/includes/database/database.inc).
Notice: PDO::__construct(): send of 128 bytes failed with errno=32 Broken pipe in DatabaseConnection->__construct() (line 307 of /path/to/site/includes/database/database.inc).
Warning: Cannot modify header information - headers already sent by (output started at /path/to/site/includes/database/database.inc:307) in drupal_send_headers() (line 1233 of /path/to/site/includes/bootstrap.inc).
PDOException: SQLSTATE[HY000] [2006] MySQL server has gone away in lock_may_be_available() (line 167 of /path/to/site/includes/lock.inc).
Notice: PDO::__construct(): send of 128 bytes failed with errno=32 Broken pipe in DatabaseConnection->__construct() (line 307 of /path/to/site/includes/database/database.inc).

```

when this happens, not every page shows the error, more like 25% or so.

so far i have had no luck tracking down the cause of the error. it seems to 'reset' if i stop/start mysql. such that if i stop/start i can get another week of no problems and then it begins again. this was making me think that it is a problem with a mysql setting related to connections or something, but i am no expert in this area and so am asking here.

after googling and seeing many posts suggesting to increase 'max\_allowed\_packets', we tried this but still the same issue occurs.

# Answer
I added the following items to my.cnf which fixed my PDO broken pipe issues. I am using a homebrew installation of mysql on a macbook pro with 16GB RAM:

key\_buffer\_size = 384M max\_allowed\_packet = 100M table\_open\_cache = 512 sort\_buffer\_size = 2M read\_buffer\_size = 2M read\_rnd\_buffer\_size = 8M myisam\_sort\_buffer\_size = 64M thread\_cache\_size = 8 query\_cache\_size = 32M query\_cache\_size = 128M

# query\_cache\_size = 256M

# Try number of CPU's\*2 for thread\_concurrency

thread\_concurrency = 8 innodb\_buffer\_pool\_size=512M
> 5 votes

# Answer
The timestamps on those log entries would be helpful so we can see how much time went by before you received the "MySQL server has gone away..." message.

From the symptoms it seems MySQL is crashing, but it could be a connection issue between the client (Drupal/PHP/PDO) and the MySQL server; "send of 128 bytes failed" is an indication.

Log onto your MySQL server and tell us what's in your MySQL error log (typically in /var/lib/mysql but depends on your OS). Typically the error file is named mysql.err.
> 0 votes

---
Tags: database
---


# Question
Title: How do I get the database value of a text field with $content?
I need to output a raw link from within a text field, without all the "field-" divs, in node.tpl. I've tried `<?php print render($content['field_download_link']['LANGUAGE_NONE']['0']['value']); ?>` but nothing displays.

# Answer
The easiest way is to install and enable Devel module.

> A suite of modules containing fun for module developers and themers ...

After that add to your page.tpl.php file this:

```
<?php dpm($content); ?>

```

You need to be logged in as administrator and you will see debugger on the page. Find the value you want to print and double-click on it, you will see the exact "path" to the value and just print it as you wrote in your question.
> 0 votes

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


title: Site Map Menu are not translatable

text:
# Question
Title: Site Map Menu are not translatable
I have created sitemap page using sitemap module to include some menu for displaying on sitemap page. Now I am unable to translate menu titles, while all the links are translated.
Also I added the translation for menu title from Edit-Menu-\> Translate.

# Answer
Be aware of the Main Menu not translated issue, which states:

> When using the default 'Main menu' menu, and outputting that on the sitemap, the title, or menu name, isn't translated ...

I just double checked in a multi language site also where I have the **i18n Menu Translation** sub-module enabled (one of the Internationalization sub-modules).

I tried editing the Sitemap menu item to be translated, by navigating to admin/structure/menu/manage/navigation. From there I tried to use the "translate" link (for the Sitemap menu item), which one would expect that it can be used to **translate** that menu item.

However, after doing so, I only get something like "You are not authorized to access this page."

This issue appears to be fixed in the most recent dev version.
> 1 votes

---
Tags: 7, i18n-l10n
---


# Question
Title: Leaflet maps multiple icon types in views
I have a leaflet map for various attraction types which works fine with using the standard blue icon.

What I'd like is to be able to specify a different icon based on the attraction type field.

I thought this feature existed based on https://drupal.org/node/1882806 but I can't seem to get anything to work.

I've been trying to set it up through the Leaflet settings in views using the POINT ICON Field (html DivIcon) setup. However, whatever I try seems to end up with a page full of errors and no icons.

I can't find any documentation on using this feature so would really appreciated some help.

Thanks, Chris

# Answer
Here is what I did. You should be able to tweak it to fit your needs:

1. I created terms and uploaded images for them.
2. I created nodes and associated terms with them.
3. I went ahead and created my leaflet view, using the appropriate token in `Point Icon` in leaflet settings.

I hope that helps.
> 2 votes

# Answer
I created a patch a few months back that added the ability to set all map options via a textfield and also token support in the icon path. I used this on one of my own sites allowing nodes of different taxonomies to have different icons. Though you could use any token to differentiate between icons.

The patch was made a few months ago, and for some reason the maintainer did not like using a textfield to set all map options so would not commit the patch. you will be able to look at the patch and see how I did it though.

The thread is at https://drupal.org/node/2089209
> 0 votes

# Answer
I applied the patch in comment #14 of https://www.drupal.org/node/1918170 (to Drupal 7.37) - after that tokens worked in the Point icon - Icon URL field.

1. I set up a Taxonomy to describe the categories for which I wanted different icons.
2. I next added a simple text field to the terms in this vocabulary to contain the relative path to the .png file to use as a marker. This needs to be relative to the site name. I put my image files in the /leaflet/images folder, so these paths are like:

`/mysitename/sites/all/libraries/leaflet/images/mymarker.png`
3. I then added a term reference field to the content type I wanted to map and populated it using terms from the new Taxonomy.
4. When setting up the view to display this content, I clicked on the "settings" for Leaflet map, made sure the checkbox (added by the patch) was ticked to allow tokens to be used in the Point icon settings and then scrolled down to the Tokens list and found the necessary token to go in the Icon URL field. It is like:

`[node:<content_term_name>:<term_image_path_field>]`
5. Save, and then go to the map page. The map marker files specified in the Taxonomy terms should now be used.

I put a series of .png files in the /leaflet/images folder that were all the same shape, but differed in colour and pattern. They could therefore share the same shadow. So I specified a single, fixed path to my shadow image file in the Icon Shadow URL field and fixed values for x and y under Icon Anchor, Shadow Anchor and Popup Anchor.

\[N.B. The relevant patch was posted more than a year ago, RTBCed 8 months ago and there are comments from about 10 users in the thread confirming that the patch works. I checked whether it had been applied to the 7.x-dev version of the Leaflet module - it has not!\]
> 0 votes

---
Tags: views, javascript
---


# Question
Title: appling different styles based on taxonomy
I have a site with 120 categories of content. I've used taxonomy to make these categories. now I need to have some different styles base on the taxonomy which is used in nodes. OK? how can I do it.

I need something like page--article.tpl.php which you use to have different styles for different content types. but here I want to separate styles based on taxonomy

as my website is very big and heavy and has 700k visitors daily, I avoid using modules like panels or context! this modules will kill my site's performance and speed! so I need simple approach without using modules.

# Answer
> 4 votes
You can have specific template files by using theme hook suggestions. To change the **node template**, use the following:

```
function THEME_preprocess_node(&$vars) {
  $node = $vars['node'];

  // Perform this only on certain content types.
  if ($node->type == 'YOUR_CONTENT_TYPE') {

    // get the taxonomy term (node category)
    $tid  = $node->field_YOURTERM[LANGUAGE_NONE][0]['tid'];
    $term = taxonomy_term_load($tid);
    $term_name = drupal_html_class($term->name);

    // add a css class with the category's name
    $vars['classes_array'][] = 'node-category-' . $term_name;

    // make drupal search for category-specific node templates
    // template files need to be named node--nodetype--termname.tpl.php
    $vars['theme_hook_suggestions'][] = 'node__' . $node->type.'__' . $term_name;
  }
}

```

Say your categories are like "Drink Wine", the `$term_name` would be "drink-wine". Lowercarse, no spaces. You can remove `__$node->type` if you want.

To change the **page** template, use the following:

```
function THEME_preprocess_page(&$vars) {
  $node = (isset($vars['node']) ? $vars['node'] : null);

  // Perform this only on certain content types.
  if ($node && $node->type == 'YOUR_CONTENT_TYPE') {

    // get the taxonomy term (node category)
    $tid  = $node->field_YOURTERM[LANGUAGE_NONE][0]['tid'];
    $term = taxonomy_term_load($tid);
    $term_name = drupal_html_class($term->name);

    // add a css class with the category's name
    $vars['classes_array'][] = 'page-node-category-' . $term_name;

    // make drupal search for category-specific page templates
    // template files need to be named page--nodetype--termname.tpl.php
    $vars['theme_hook_suggestions'][] = 'page__' . $node->type.'__' . $term_name;
  }
}

```

# Answer
> 0 votes
You can use the "***taxonomy-term.tpl.php***" Theme Hook in Drupal 7. By copying the "***ROOT\_DIRECTORY\modules\taxonomy\taxonomy-term.tpl.php***" into your theme template directory will override, and rename the file with your Vocabulary Machine Name(taxonomy-term--machinename.tpl.php).

---
Tags: taxonomy-terms, theming
---


title: Acquia Dev Desktop Export to archive

text:
# Question
Title: Acquia Dev Desktop Export to archive
I'm a newbie, so please forgive me if this is a dumb question.

Exactly what files does the "Export to Drupal archive" feature of Dev Desktop actually back up? I have searched the web and didn't find anything that would answer this question.

My understanding, at this point, is that I need to export/backup the database and my Sites folder. PhpMyAdmin will do an export/backup of the database, but I have to manually copy & paste the Sites folder and fool with all the settings in phpMyAdmin. It would really be nice if the Export to Drupal archive does this with only one click .

Thanks!

# Answer
> 1 votes
It does what you almost exactly described. **Export to Drupal archive...** creates a tar.gz file (tarball) with a backed up docroot folder (your drupal site code) & a .sql file (DB dump). This is everything you need to export your site to any host that runs MySQL/MariaDB & Apache/PHP

---
Tags: importing-exporting, acquia-dev-desktop
---


title: Change certain parts of the layout

text:
# Question
Title: Change certain parts of the layout
Iam using Omega 4 and Drupal 7 and Iam wondering how to apply layouts just to certain parts to the website. My website almost stays the same, header and footer never changes, just the content area. I created a subtheme and applied a layout to it using panels or context, just to try both.

So whenever I create a new layout for instance for the basic article node, I need to setup the entire page structure within that tpl file again, how do I avoid such things?

I took a look in the omega theme folder under template, and there they just put the specific thing they want to change in the files, and dont rebuild the entire page strcuture.

# Answer
Found a solution. Just copy the entire templates folder of the omega base theme to your subtheme. Within that folder, just edit or add new tpl files. Those files will be injected to the specific block/content.
> 0 votes

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


title: Display submission history of a node?

text:
# Question
Title: Display submission history of a node?
Use case: This content type offers an Approval Status with three radion button options, Submitted, Approve, and Reject.

A node from this content type can go through all three in its lifetime.

And that "history" should be displayed at the bottom of the page.

How do I do this?

# Answer
You will need to make sure that the content type creates a new version with every edit. Then, you should be able to make a Views block that shows node versions and the status field.
> 0 votes

---
Tags: views
---


# Question
Title: Ubercart - Sale approval required before payment
Durpal 6, Ubertcart 6.x-2

We are selling table space to vendors at an upcoming convention. We want to let them apply but wait for admin approval before they can pay. I've been searching for several days but cannot find a solution.

Is there a way to require admin approval of a sale before moving to the payment process?

Edit: I have no way of telling that they are vendors until they purchase a vendor table.

# Answer
> 0 votes
There's many ways to go about this but I would use Rules & custom Role called **Vendor**. You can specify on Drupal load if a user doesn't have a Vendor role & is loading the **cart/checkout** page. That you can redirect them to your application form with a message prompting them to apply before checkout.

Here's an example rule:

```
{ "rules_check_vendor" : {
    "LABEL" : "Check Vendor",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "test" ],
    "REQUIRES" : [ "rules" ],
    "ON" : { "init" : [] },
    "IF" : [
      { "text_matches" : {
          "text" : [ "site:current-page:path" ],
          "match" : "cart\/checkout",
          "operation" : "starts"
        }
      },
      { "NOT user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "3" : "3" } }
        }
      }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "In order to become a vendor. Please contact us." } },
      { "redirect" : { "url" : "contact" } }
    ]
  }
}

```

---
Tags: ubercart
---


# Question
Title: Wrap a field in a link conditionally in views
I'm quite new to Drupal but I've been a developer for a few years. I'm struggling with what should be a very simple task. I have created a field 'field\_client\_link' that authors can use to enter a url to a portfolio content type about a client. If an author has entered a link I want to wrap a client logo in it, otherwise just display the image. I'm sure this is not as hard as I'm making it out to be. In WordPress I would just write something like this and be done with it:

```
<?php

    if (get_field('link')) {
        echo '<a href="' . get_field('link') . '">' . get_field('image') . '</a>';
    } else {
        echo get_field('image');
    }

?>

```

Here are my settings. I've set the link to be hidden because I don't want it outputting until I call it later. Hoping you can help me:

# Answer
Unfortunately, I know of no easy way to do this.

Let me be more specific -- you've provided a Views example where you're showing you can `Rewrite` the output, there are some `tokens` you can replace values with. You also show some custom `php` you'd write in wordpress.

Well, in order to do this in Drupal; so far as I know you have to use come custom `php` as well. Views is designed to make simple lists (read SQL queries) as output. Conditional values such as this are essentially out of the basic Views UI scope.

So you either use the Views PHP module, create a views template file and preprocessor function or use the module mentioned by @PatrickRyan.
> 0 votes

# Answer
There's a lightweight module that lets you attach a custom link to any image using the image formatter setting: Image Link Formatter

It will automatically detect any link field and make it an option to set that link for the image.

I usually just go this route instead of dealing with tokens or template modifications every time I want to link an image.
> 1 votes

# Answer
I hope you have a separate field for the logo (eg: client\_logo) and a link field (Eg: client\_link) in your content type. Now install and enable Views Conditional module.

Go to your view add whatever fields you want including the client\_logo and client\_link under FIELDS section. Exclude both of these fields from display (edit your field and tick Exclude from display). Set "Formatter" to "URL, as plain text" in link field (field\_client\_link)

According to above module guidelines do following steps 1.Click on "ADD" next to fields. Scroll down to "Views: Views Conditional", probably found near the bottom of the list.

2. Set "If this field..." to your link field (in this example field\_client\_link)
3. Set "Is..." to "NOT EMPTY"
4. Then add the out put using html tags and tokens (You can find tokens under "REPLACEMENT VARIABLES")

for this example under "Then output this..."

```
<a href='[field_client_link]'>[field_client_logo]</a>

```

and under "Otherwise, output this..."

```
[field_client_logo]

```

Note: You don't need to include tag to print the logo because the \[field\_client\_logo\] is already enabled with tag fron Drupal view.
> 0 votes

# Answer
So I've been playing around with this for a while and finally figured out a solution that is possible with views only (although in my example I use the Entity reference module). I thought I'd post it here since I took me ages to figure out and I hope I can save someone the hassle. It's actually not that hard in the end.

The aim here is to have a view that lists all client logos and if that client has a related project, link to that, otherwise don't.

Step 1 is to get the entity reference module.

Step 2 is to add an entity reference field to your client content type with an autocomplete widget. You'll want to target a specific content type. In my case I targeted a project. Make sure you set a maximum of 1 entry for this field/

Step 3 is to edit your client content and add references to projects in your newly created field.

Step 4 set up your view. You'll want to get your entity reference field that you just created and set it up. You need to exclude it from display and you select entity id from the field formatter option.

Step 5. Next you need to rewrite the output of your entity reference field. You'll want to use the format node/ + \[replacement\_token\] so you get a valid url. Importantly, you need to go into the No results behaviour tab and check hide rewriting if empty. Because we hid our entity field from display, it will now only be rewritten if someone has added a reference to a project in the client content type.

Step 6. Now we need to edit the settings for the logo field. Importantly, the field order must be entity reference field followed by logo field.

Step 7. In the logo field settings go to rewrite results and check output this field as a link. In the link path we can use replacement tokens and we want to use the field that we have just rewritten in step 5. In my case I rewrote \[field\_related\_client\_projects\]. Before it was just an entity id. e.g. 768 or whatever. Now however, this replacement token is node/nodeid so it can be used as a link

Step 8. Uncheck hide rewriting if empty.
> 0 votes

---
Tags: views
---


title: Content Region Not Displaying

text:
# Question
Title: Content Region Not Displaying
I'm relatively new to Drupal and am just squashing bugs on my first site.

I have a region that I declared in my theme.info file:

```
regions[alert] = 'Sitewide Alert'

```

and I have a block that has a custom template `block--alert.tpl.php` with some custom fields. Everything works great when I have my Sitewide Alert block assigned to my Alert region. But when I disable my Sitewide Alert block, no content renders in my content region. If I enable the Sitewide Alert block, or any other block in the sitewide alert region, all my content comes back.

Using the themer module, I can see that all the same variables are still available on the page, but it's like none of my templates are being called or something. Can anyone help me troubleshoot this or point me to some resources?

**UPDATE:**

I forgot that I was preprocessing my custom block. This is where my issue was. Within my theme\_preprocess\_block function, I was running the following code:

```
// Sets the character limit for the Custom Block
if ($vars['id'] == '2') {
    $vars['content'] = truncate_utf8($vars['content'], 170, TRUE, FALSE);
}

```

What I found out is that the `$vars['id']` changes depending on what blocks are called on the page. When my custom block was active, it's id was 2, but when it was inactive, my content block had the id of 2 and so was being truncated.

I changed this to:

```
// Sets the character limit for the Custom Block
if ($vars['theme_hook_suggestions'][0] == 'block__alert') {
    $vars['content'] = truncate_utf8($vars['content'], 170, TRUE, FALSE);
}

```

If anyone has a better way of selecting a block to preprocess I'd love to see it.

# Answer
> 0 votes
Well, just off the bat I haven't seen anyone use single quotes on the human-readable name. For instance, I'd change it to:

```
regions[alert] = Sitewide Alert

```

You might have a PHP if statement in your page.tpl.php somehow affecting your content region. I'd double-check the template file and see how it matches up with the default Bartik page.tpl.php

# Answer
> 0 votes
If your custom region is affecting your main content region, there is a really high chance that you have some faulty html in one of your custom templates or blocks. Check each for unclosed div's.

---
Tags: blocks, theming
---


title: How do I theme checkout pages?

text:
# Question
Title: How do I theme checkout pages?
how do I theme the cart and checkout pages in Drupal commerce? I have set content, account, billing, and payment parts. Is there any --.tpl.php file to create?

# Answer
For theming cart page add `page--cart.tpl.php` in your theme's templates directory.

For theming checkout page add `page--checkout.tpl.php` in your theme's templates directory. If you want to theme only the checkout review page add `page--checkout--review.tpl.php` in templates directory.

After adding tpl files do not forget to clear cache.

If you want to know about more hooks do a `dpm($variables)` inside `YOURTHEMENAME_preprocess_page` function and look into the `theme_hook_suggestions` array.

For details read this comment http://drupal.org/node/1142800#comment-5365466
> 13 votes

# Answer
The only template files in Commerce related to the checkout module are commerce-checkout-errors-message.tpl.php and commerce-checkout-help.tpl.php. These are located in the Commerce module directory under modules/checkout/theme.

The only template file related to the Cart module is commerce-cart-block.tpl.php, which is located in the Commerce module directory under modules/cart/theme.
> 7 votes

# Answer
Actually the easiest way I think is using hook\_form\_FORM\_ID\_alter() to alter the checkout form. If all you need is only change the part inside the checkout form.

As I see, most of the checkout & checkout review page content is inside the form. First is '**commerce\_checkout\_form\_checkout**', and second is '**commerce\_checkout\_form\_review**'. If you know how to use form API & how to alter the form by using hook\_form\_FORM\_ID\_alter(). That will be very easy to alter the form content. Like reorder them or insert/remove elements.

Here is a **simple example** for add a notice into the checkout page:

```
function my_module_form_commerce_checkout_form_alter(&$form, &$form_state, $form_id) {

  //If you have Devel module, uncomment to see what is the original form data
  //kpr($form);

  //uncomment to see current form_id
  //echo $form_id;

  //check form id
  if($form_id == 'commerce_checkout_form'){
    $form['my_test_notice'] = array(
      '#markup' => '<h1>Hello, this is a checkout test!</h1>',
      '#weight' => -1,
    );
  }
  elseif($form_id == 'commerce_checkout_form_review'){
    $form['my_test_notice'] = array(
      '#markup' => '<h1>Hello, this is a checkout review test!</h1>',
      '#weight' => -1,
    );
  }
  //You can add more ...

}

```
> 4 votes

# Answer
You can also use the body classes (depending on what base theme you use, these are often available). This allows you to give specific values to child items of the body with class .checkout, for example. This might be enough to jig the layout a little bit.
> 2 votes

# Answer
Have you tried Theme Develper module which gives you info about which theme hooks to implements and which themplate files to adopt.
> 1 votes

# Answer
Cart page is just a view, so style it as any other view:

1. Go to page when you are logged in as admin, find and click "Edit view" link.
2. On view edit page open "Advanced" view settings and click "Theming information"
3. There you can see how you should name your templates (i.e. views-view--commerce-cart-summary--default.tpl.php) and also if you at template name at beginning of the row (i.e. first is "Display output" you can see default template, copy it, save with other name in your theme's template dir and modify it as you like).
4. Or, you can build those pages (views) on your own. http://www.drupalcommerce.org/user-guide/modifying-shopping-cart-using-views
> 1 votes

# Answer
You can make your own .tpl files, and call them with a hook\_theme function:

```
function yourtheme_theme(&$existing, $type, $theme, $path) {
  return array(
    'commerce_cart_add_to_cart_form'=> array(
    'render element' => 'form',
    'template' => 'path/to/template/commerce_cart_add_to_cart_form',
  ),
    'commerce_checkout_form_review'=> array(
    'render element' => 'form',
    'template' => 'path/to/template/commerce_checkout_form_review',
  ),
  ...
  ...(more templates)
}

```

as these are forms, you then can hide the form, find what you need, and use your own markup in your template.

```
<?php
  hide($form);
  dpm($form);
?>

<div>
  print render($form[...]);
</div>

```

Or, you can leave it as it is and do stuff around it.
> 1 votes

---
Tags: theming, commerce
---


# Question
Title: Add Custom Bulk operations to an existing Views
I am creating a custom bulk operation using `hook_action_info` and I can see that the operation is created successfully. But however, I want to add this to an existing views. I can do this using Views UI with editing the view and editing "Selected bulk operations". So there I can select the custom operation that I have written.

So far doing this works for me but I want to automate this one. So once I enable my module with this custom operation I need to add this custom bulk operation to the existing view's "Selected bulk operations".

Is there any hooks or alters that do this?

# Answer
hook\_views\_default\_views\_alter() is the sauce you're after
> 1 votes

---
Tags: 7, hooks, views
---


title: Adding a product to cart using rules

text:
# Question
Title: Adding a product to cart using rules
How do I add a product to cart using Rules & Ubercart in Drupal? My aim is to add a product to cart when someone has an weight order total equal 1 kg during checkout.

# Answer
I think you can achieve it by this way. Get cart contents using **uc\_cart\_get\_contents();**. Then calculate total weight of products in your cart and add product using **uc\_cart\_add\_item();** according to your conditions.
> 0 votes

---
Tags: rules, ubercart
---


# Question
Title: How to show messages starting with "Debug : " to an administrator only?
I'm developing a lot of complex rules in D7 and for debugging reasons it is very handy to have different messages (the standard Drupal message) within the website. For this I use "showing a message on the site".

If a message of this starts with "Debug : " then I want it to only be displayed for the role of administrator. I do not want to add a condition to every message. That's is just to much.

How to achieve this?

**Note**: I wrote my first "Hello world" module last month, so I have a custom module in the site. I have to find the correct hook for this, so I looked into https://api.drupal.org/api/drupal/includes%21module.inc/group/hooks/7. But I cannot find a good hook for this.

# Answer
> 10 votes
# Option 1: Use the Disable Messages module

Use the Disable Messages module for this. Here is a quote from its project page:

> Gives a site owner options to disable specific messages shown to end users. The core drupal message system as offered by drupal\_set\_message is an excellent way for modules to send out messages to the end users. However not all drupal site owners are keen to show all the messages sent out by drupal core and all modules to their users. This module gives site administrators a reasonably powerful way to filter out messages shown to the end users.

Some of its features are:

> * Filter out messages that match a full text string exactly.
> * Filter out messages that match a regular expression.
> * Permissions to specifically hide all messages of a given type from any role.
> * Disable all filtering for specific users.
> * Disable all filtering for specific paths.
> * Apply filtering only for specific paths.
> * Debug system to get messages in the HTML without showing it to the end users.

Available for either Drupal 6 or Drupal 7 (and a DEV version for Drupal 8).

# Option 2: Write your custom code

Use a variation of the approach as explained on Hook into and Preprocess Drupal Messages? Here is a quote from it:

> The following example hides all error/warning messages from anonymous users and user's who don't have the 'administer nodes' permission. You can easily add your own conditions to filter out which message types should be displayed to who.

```
function mytheme_status_messages ($display = NULL) {

  $output = '';
  foreach (drupal_get_messages($display) as $type => $messages) {

    // skip all error/warning messages for anonymous users
    if (!user_is_logged_in() && ($type == "error" || $type == "warning")) { continue; }

    // skip error/warning messages for users who don't have the 'administer nodes' permission
    else if (!user_access('administer nodes') && ($type == "error" || $type == "warning")) { continue; }

    ...

```

---
Tags: 7, users, rules, debugging, status-messages
---


title: how to use if exists inside db_query

text:
# Question
Title: how to use if exists inside db_query
I try to create a condition that checks if user has already created a node.

I use this code which returns the last created node by the user. Adding simple if statement I can return true/false.

```
$xxx = db_query("SELECT nid FROM {node} WHERE (type = :type1) AND (uid = '123')", array("type1" => 'nodetype_x'))->fetchField();
return $xxx;

```

I tried to do it more efficient to check only for first result like this.

```
$xxx = db_query("
IF EXISTS(
      SELECT nid FROM {node} WHERE (type = :type1) AND (uid = '123')
)
SELECT 1
ELSE
SELECT 0", array("type1" => 'nodetype_x'))->fetchField();

```

But get syntax error. What would be the correct syntax? Thank you

# Answer
> 0 votes
There is no need to use `IF EXISTS()` with `db_query()`. Drupal core code never use it.

```
// comment_num_new()
return db_query('SELECT COUNT(cid) FROM {comment} WHERE nid = :nid AND created > :timestamp AND status = :status', array(
  ':nid' => $nid,
  ':timestamp' => $timestamp,
  ':status' => COMMENT_PUBLISHED,
))->fetchField();

```

```
  // aggregrator_cron()
  $result = db_query('SELECT * FROM {aggregator_feed} WHERE queued = 0 AND checked + refresh < :time AND refresh <> :never', array(
    ':time' => REQUEST_TIME,
    ':never' => AGGREGATOR_CLEAR_NEVER,
  ));
  $queue = DrupalQueue::get('aggregator_feeds');
  foreach ($result as $feed) {
    if ($queue->createItem($feed)) {
      // Add timestamp to avoid queueing item more than once.
      db_update('aggregator_feed')->fields(array('queued' => REQUEST_TIME))->condition('fid', $feed->fid)->execute();
    }
  }

```

```
  // aggregrator_feed_load()
  $feeds = &drupal_static(__FUNCTION__);
  if (!isset($feeds[$fid])) {
    $feeds[$fid] = db_query('SELECT * FROM {aggregator_feed} WHERE fid = :fid', array(':fid' => $fid))->fetchObject();
  }

  return $feeds[$fid];

// aggregrator_expire()
$iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid AND timestamp < :timestamp', array(
  ':fid' => $feed->fid,
  ':timestamp' => $age,
))->fetchCol();
if ($iids) {
  db_delete('aggregator_category_item')->condition('iid', $iids, 'IN')->execute();
  db_delete('aggregator_item')->condition('iid', $iids, 'IN')->execute();
}

```

In your case, the following code is enough.

```
if ($nid = db_query("SELECT nid FROM {node} WHERE type = :type1 AND uid = '123'", array("type1" => 'nodetype_x'))->fetchField()) {
  // There is such a node.
}
else {
  // There isn't such a node.
}

```

# Answer
> 0 votes
This is really not the ideal way to do this. Instead you may want to try something like:

```
$query = db_select('node', 'n')
  ->condition('n.type', $type)
  ->condition('n.uid', $uid)
  ->fields('n', array('nid'));

$count = $query->countQuery()->execute()->fetchField();

if ($count) {
  return true;
}

return false;

```

---
Tags: 7
---


# Question
Title: How to disable breadcrumbs by default and enable only particular ones with Path Breadcrumbs module?
I'm using Path Breadcrumbs module for displaying breadcrumbs on particular pages.

Is there a way to set breadcrumbs not to display by default for ANY page and enable only particular ones using rules created with Path Breadcrumbs module?

In module there's an option to disable breadcrumbs by creating a rule for each URL pattern and setting breadcrumb and title to "" but how can I trigger rule for ANY drupal URL - nodes, taxonomy, views, panel pages etc. And then make rules only for those URLs which really need breadcrumbs to be displayed?

# Answer
> 4 votes
There is a patch for the Path Breadcrumbs module that adds a setting to disable other breadcrumbs: https://www.drupal.org/node/2483091

The patch allows an easy one click disabling of other breadcrumbs.

Here is a screenshot of the setting on the patch breadcrumbs settings page (admin/structure/path-breadcrumbs/settings) as it is in the current version of the patch:

# Answer
> 2 votes
I'm not using 'path breadcrumbs' module but I did the same thing on Drupal original breadcrumbs. Hope following simple code will inspire you.

```
function MY_THEME_preprocess_page(&$variables) {
  // List nids allow breadcrumbs.
  $nids_show_breadcrumbs = array(2, 4, 5, 6, 8);

  if (!in_array($variables['node']->nid, $nids_show_breadcrumbs)) {
    // Remove breadcrumb for all node not in our list.
    $variables['breadcrumb'] = '';
  }
}

```

This is an example of how to use this technique to stop breadcrumbs on all pages not handled by the path breadcrumbs module:

```
function MY_THEME_preprocess_page(&$variables) {
  // Get path breadcrumbs for the current page.
  $path_breadcrumbs_data = path_breadcrumbs_load_variant(current_path());

  // If there are no path breadcrumbs for this page then
  // don't show any breadcrumbs at all.
  if ($path_breadcrumbs_data === FALSE) {
    $variables['breadcrumb'] = '';
  }
}

```

# Answer
> 1 votes
1. select URL:path under selection rules.
2. add it. and enter the listed pages on which you don't want to display breadcrumbs.
3. or list only those pages on which you need breadcrumbs.

# Answer
> 0 votes
The easiest way I know is to use the CSS "`display: none;`". Each content type page has their own ***body class***. For example, the basic page content type has "`body.node-type-page`" or any custom content type "`body.node-type-customcontenttypename`".

You will need something like this in your CSS file(replace "customcontenttypename" with your custom content type name).

```
body.node-type-customcontenttypename #breadcrumb {
display: none;
}

```

Another option is to use the Custom Breadcrumbs, as Viraj\_T mentioned. This module allow you to show breadcrumbs based on node type and or Vocabularies.

# Answer
> 0 votes
watch and learn Drupal 7 Path Breadcrumbs Module - Daily Dose of Drupal Episode 36

---
Tags: breadcrumbs
---


# Question
Title: How can I apply some value with HTML tags to a form element?
I've assigned some value with HTML tags to a form element, say the element is called `name`.

When it returns the form, it exactly prints the value along with the HTML. What I want in return instead, is the style applied to the text.

In this what I'm trying to do is hook\_form\_FORMID\_alter(). This is the page where comments are listed(admin/content/comment). In this, for each comment I'm showing the subject comment and author etc. Also a collapsible tree for editing the comment with pre filled values in the fields.

```
$form['name'] = '<b>Fazeela</b>'
return $form;

```

# Answer
> 1 votes
> Use css.

Example:

If your `$form['name']` is a div with an id `wrapper`,

```
<div id="wrapper">Fazeela</div>

```

Include a css file in your module file, particularly in hook\_init function.

```
function NameOfYourModule_init(){
   drupal_add_css(drupal_get_path("module", "NameOfYourModule") . "/mycss.css");
}

```

mycss.css file

```
#wrapper{
    font-weight: bold;
}

```

---
Tags: forms
---


# Question
Title: What is the Drupal's way of wrapping fields inside a field?
It seems that many Drupal gurus disfavor using Field Collection module to wrap fields inside a field. They say it's not the Drupal's way of doing it.

In my current scenario, I need a single field with *before* & *after* image subfields. I also need a recipe ingredients field, with *ingredient name*, *unit size* (using taxonomy reference) and *serving amount* subfields.

What is the preferred Drupal's way of doing such a thing? Should you have to code an entirely custom module for each field type?

## **Update**

It seems that the ideal approach is to use a custom field type. Optionally you can use Drupal modules to group fields, such as Composed Field and Multifield, and not-so-favored, architecturally cumbersome, Field Collection. Another solution is to create a content-type for each group of fields and use Entity Reference to reference the field to it.

**Ideally I'd like to see an example of a custom field type which implements a text and an image field, or something similar.**

# Answer
You can try https://drupal.org/project/composed\_field

> The Field collection uses a different approach for creating composed fields. Here are the main differences between this module and the "Field Collection": The host field created by "Field Collection" is in fact an entity that gets attached to the fieldable entities (nodes, taxonomy, comment, commerce products, etc). So, although you attach a Field Collection through the Field UI, what is being attached is not a field but an entity.
>
> Once you get your new entity (host field) attached to your fieldable entity (node, comment, taxonomy, commerce product, etc) then you have to attach the fields ( what would be the subfields ) into the host field ( Field Collection entity).
>
> Each subfield is actually a field on its own, that is, from the database point of view, each subfield is a single field.
>
> "Composed Field" on the other hand attaches a field (host field), not an entity, to your fieldable entities (node, comment, taxonomy, commerce product, etc) through the Field UI. At the end of the day, even if you set a field with say 4 subfields, you will end up having only one field and a single value saved into the database.
>
> Unless you have a very specific use case need "Composed Field" should do what you need with less effort and less resources.

One more module availabel to achive the similar task is https://drupal.org/project/multifield but it is currently in unstable status

> This project seeks to provide a true compound field solution for Drupal 7. As much as I love Field collection, it still has to save actual entities, and can cause performance problems due to having to load all the referenced field collection entities on node, or parent entity load.
> 1 votes

# Answer
https://drupal.org/project/composed\_field is working fine for wrapping field inside field. suppose, if you want to set phone no. with country code then
`$cntrcode = isset($form_state['cntrcode']) ? $form_state['cntrcode'] : '+358';
$pno = isset($form_state['phno']) ? $form_state['phno'] : '';
$passenger->field_phone_number[und][0]['composed'] = array('1' => $cntrcode,'2' => $pno);`
Above code wrapp both contry code and phone no. in single field
> 1 votes

# Answer
in such cases I change my way of analyzing the project. for example I separate the fields which I need to wrap and create another content type for theme and use entity reference to join theme together! as Drupal's views module is completely integrated with entity reference module, It has worked very nice for me.
> 1 votes

---
Tags: 7, entities
---


title: Custom form module

text:
# Question
Title: Custom form module
I have created a custom form named `user_form_expiry`, how can I access that form from the admin panel similar to other Drupal's built in forms like `user_register_form`?

# Answer
> 1 votes
You'll need to create a menu hook in your module and give the form name as your callback arg. Something like this:

`<?php
function MYMODULE_menu(){
 $items['admin/my-path'] = array(
 'title' => 'User expiry',
 'page callback' => 'drupal_get_form',
 'page arguments' => array('user_form_expiry'),
 'access arguments' => 'access content', // you probably want something more restrictive here
 'menu_name' => 'management',
 //'weight' => 1,
 );
}
function user_form_expiry($form, &$form_state){
// form API code here
}`

That said, I suspect that your use case would work better using hook\_form\_alter(). What are you trying to achieve here?

---
Tags: 7, forms
---


# Question
Title: Creating an iframe playlist that loops through urls (from a node field)
**Scenario**

A content type called "Playlist" exists. Playlist has a text field: field\_playlist\_sources. When a user creates the Playlist they can add multiple values for field\_playlist\_sources. Each value is a url like: http://somesite.com.

When the Playlist node is viewed, the field\_playlist\_sources field is displayed with a Custom Formatter (using the Custom Formatters module). The format for the display of this field is:

```
<iframe src="" name="frame" id="frame" width="100%" height="1080px" seamless frameborder="0" scrolling="no"></iframe>

```

Notice the empty src.

What I'd like to do is loop through the values provided for field\_playlist\_sources within the iframe.

With Javascript this would look like this:

```
var frameSRC = Array(
  'http://someurl.com', 60,
  'http://anotherurl.com', 60);
var i = 0, len = frameSRC.length;

function ChangeSrc() {
  if (i >= len) { i = 0; } // start over
  document.getElementById('frame').src = frameSRC[i++];
  setTimeout('ChangeSrc()', (frameSRC[i++]*1000));
}

window.onload = ChangeSrc;

```

As of right now, I'm not sure how to bring in the values from the field to this javascript file. Maybe there is a better approach?

Any help would be greatly appreciated.

# Answer
I'd probably do this in two steps (all within the formatter hook).

1. Separate the js processing into an external include, added via drupal\_add\_js();
2. Put the urls into Drupal.settings.mymodule.playlist and call these from your ChangeSrc() function.
3. If you're wanting to do it semantically, skip point 2 and just ouptput `<a href="src" data-something="60">` in your formatter markup. Then pull those hrefs with your js and inject them into the iframe.

---

Standard code for including custom js settings:

`$settings = array();
$settings['mymodule']['playlist'][] = array('url1','metadata1');
drupal_add_js($settings, 'setting');`
> 1 votes

---
Tags: 7, javascript
---


title: Change date format

text:
# Question
Title: Change date format
I am wondering how to format dates so that:

When the start and end date are in the same month, that the start and end date is displayed like 1 - 2 March 2015

When the start and end date are in different months display dates like 12 March - 4 June 2015

When the start and end date are in different years display the dates like 12 June 2015 - 4 June 2016

Any help will be highly appreciated Thanks

# Answer
> 0 votes
my preferred solution is to do it manually

1- install and enable views php module

2- add the start date and end date fields to the view but without display them

3- add the php global field after the date fields and write some little php code can achieve your target

# Answer
> 0 votes
In case anybody stumbles on this in future:

The date range formatter module does smart combination of start and end dates and allows for a wide range of formatting flexibility.

---
Tags: views, datetime
---


# Question
Title: How to add fields (variables) to users to be used in combination with data about events?
**About my site**:

I have a site about events where users can:

* post and rate events.
* confirm that they will attend (everyone can see who will attent).
* etc.

**Requirement 1**: I want to make it so that you can add fields (variables with some value) to users, which resembles what they did. For instance: "User Anon had a red jacket and was drunk".

**Requirement 2**: Then I would like to have a drop down list:

* that is unique PER event
* with these fields (variables) which the users can use to add the appropriate values to their own profiles.

That way everyone can see what they did/had at that specific event.

**Summary**:

The following should be the desired result:

* Add fields (variables) to users .
* Must be unique PER event.
* Multiple choices possible.
* Visible by other users.
* Visible on own profile.

**What I tried so far**:

* I tried to use the **Views** module with references and such. But it didn't work.
* Then I tried to achieve it with a poll, which would work but is not unique per event.

**My question**: Any ideas how I can get this done?

# Answer
How about using the Flag module for this? Excerpt from its project page:

> 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.

Possibly in combination with some of the Flag related modules also, such as (partial list):

* Views, to create lists of flagged content, users, etc, such as in the video about Creating global flags and listing flagged content in Views.
* Rules, to trigger rules for anything that is flagged, such as in the video about Triggering rules with Flag, or to set flags with the Rules module, such as in the video about Setting flags with Rules.
* Flag Lists, to allow users to create custom lists.
* Flag Weights, to add weights to Flags (to be used for sorting).
* DraggableViews, to make Views draggable (so that they can be rearranged by Drag'n'Drop.).
* Flag Friend, a pre-built flag for marking other users as friends (using the Flag module).
* Flag Abuse, a pre-built flag for marking offensive content, with some extra administrative features.
* Flag, Hide & Mute, for users to hide individual nodes, such as site-wide announcements or advertisements, and/or to suppress all posts by users they do not want to see.
* Flag Files, to flag media files.
* Flag Service, to allow Flag to be accessed via a web services interface through the Services module.
* DLike, provides a Facebook like "Like" functionality using the Flag and Lightbox2 module.
* Conditional Flags, provides an extra API to Flag module, for custom conditions between flags.
* Organic Groups Flag Integration, extends the flag module with organic groups support allowing the administrators of each group to override the global flag settings for their group.
* Context Flag, allows the use of Flags as conditional triggers for use with the Context module.

Refer to its community documentation for way more details (if you like to *read*), and/or various screencasts about the Flag module (if you like to *watch*).
> 1 votes

---
Tags: users, entities
---


title: SMTP settings not being used

text:
# Question
Title: SMTP settings not being used
I've been working on a existing drupal site I got from a client, and have been running into some problems when I try to change the smtp settings. The SMTP module was already installed, but when I change the settings in SMTP Authentication Support and send a test mail, it works, but it still keeps using settings from somewhere else (I presume). I've checked the config files for settings, but I can't seem to find anything. All cache has been turned off. I'm not an expert on drupal by any means, so is there some other place I should be looking or do I need to change some other settings?

# Answer
> 0 votes
Refer to the answer to How to configure webform with smtp , which includes:

> If you have SMTP module installed in your drupal site than you would have to configure the SMTP settings (/admin/config/system/smtp) for sending the email ...

It also includes an example for configuring SMTP.

---
Tags: emails
---


title: how to customize Registration form

text:
# Question
Title: how to customize Registration form
How to add a fields into custom registration form in drupal7 and how to give the link so that annonmous user can register.

# Answer
As an adminstrator, you can set additional user fields at:

*/admin/config/people/accounts*

Note the tabs **Manage fields** and **Manage displays**. You can control if and how these fields appear on the registration form, and also how they appear to the user via these tabs. You can even create non-visible fields for storing other kinds of hidden data against a user should you need to.

By default, the link to register is:

*user/register*

You would normally create a menu item if one doesn't exist already to appear somewhere on your site, or you can just output the link in a suitable location depending on your needs.
> 0 votes

---
Tags: forms, users
---


# Question
Title: How to create an Entity reference with taxonomy term selection?
I'd like to make an entity reference autocomplete field where I can only select the options which have a certain taxonomy term attached to it.

Example: I have a sports player who belongs to a certain team. The player is part of content type 'person' with taxonomy term 'player'. Other taxonomy terms which can be applied to this content type are 'referee' and 'trainer'.

I also have content type 'team' where I want to be able to select players for this team. I have used an entity reference field for this which refers to content type 'Person'. But now I can select all persons, so also referees and trainers.

What I did now was create a View with content type=person, term=player and saved this as an entity reference display. I can now select 'Views: filter by an entity reference view' in the reference field in Teams. This all works fine.

The problem however is, I'd like to quickly add a new player if the player isn't in the database yet. I installed the References Dialog module, which adds buttons to an entity reference field to add or edit nodes you're referring to. This module only works when you select the Simple entity reference and not the Views entity reference.

Any solution for my problem?

# Answer
Here, start with creating a new view and be sure to select taxonomy terms.

In short: \- Add new view \- Select: Show Taxonomy Terms -\> Save & Continue \- Fields: Entity Reference View Widget Checkbox: Taxonomy term \- And ofcourse Taxonomy Term

Go back to your contenttype page and be sure to select the right view with your entity referece field.

Cheers,
> 1 votes

---
Tags: taxonomy-terms, entities, ajax
---


# Question
Title: Show multiple content in a view in drupal 7?
I have a content-type named **Accessories**. Where I can create content related product i.e. Product name, product detail, etc. I have a view named **shop** where I can display all products of the content-type i.e. **Accessories**.

Now I want to create a view where I can show the product detail. I can't find-out how to do this.

Please help to create Views to show my product details.

# Answer
1. First you have to create second view of type page i.e. `product_detail` & add path to them i.e. `product_datail/%`.
2. Inside your first view `Content : Title` add **Rewrite Result**

* **Check** : Output this field as a link
    * **Link Path** : `product_detail/[title]`
    * **Check** : Use absolute path
3. In both your first & second view i.e. **shop** & **product\_detail**

Add Contexual Filter i.e. `Content: Title`

Save that view & run. I hope your issue will solved.
> 0 votes

# Answer
The "content related product i.e. Product name, product detail\*" in your question is a bit ambiguous ... (not sure how to correctly interprete) ...

**1st possibility**:

It may mean that you only have a single content-type (named "Accessories") with some fields added to it, i.e. product name, product detail, product image, etc.

In that case, you should the "add" button to the right of Views "Fields" (1st column of the Views UI). First to add a field like Product name, and then for product detail, product image, etc.

**2nd possibility**:

It may mean that you have a content type "Accessories", and another type like "Product" or something.

In that case, you should add a Views "Relationships" (3rd column of the Views UI).
> 0 votes

---
Tags: 7, views
---


# Question
Title: How to use flags to pass variables to users?
Backstory: Ok, I have a site where users can post events, rate them, attend them (everyone can see who will attent) and such. Now I want to make it so you can add variables to users, which resembled what they did. for instance: User: Anon had a red jacket and was drunk.

Then I would like a list that is unique PER event with these variables which the users can add to their own profiles. (so everyone can see what they did/had at that specific event)

for instance: List of events: Color run, Jumping, Racing "User goes to event "color run" and there is a list with: "what resembles you at this event: -Drunk -In a group -Red jacket"

Then they select "drunk and red jacket" and submit/bookmark.

Now I want this to be saved to their profile so when they go to their own profile it will look like this:

profile\>events\>color run\>

* red jacket
* drunk

and for a different event it could be that they chose something else and that would show up. Any ideas how to make this reality?

I was thinking about using blocks but I have no clue how to make the multiple select part.

# Answer
> 1 votes
Consider using the Profile 2 module. Excerpt from its project page:

> Designed to be the successor of the core profile module, which is deprecated for Drupal 7. In contrast to the deprecated module this module provides a new, fieldable 'profile' entity - leverage the power of fields.

That project page contains a lot more interesting info, such as these Features which might help for addressing this question:

> * Multiple profile types may be created via the UI (e.g. a general profile + a customer profile), whereas the module provides separated permissions for those.
> * Optionally, profile forms are shown during user account registration.
> * Similar to the deprecated core profile module, fields may be configured to be private - thus visible only to the profile owner and administrators.
> * By default the UI behaves similar to the deprecated core profile module, thus showing each profile type in each own tab below user//edit. Via the included "Profile pages" module profiles can be viewed and edited at their own page and get their own menu link, e.g. "My profile".
> * Thanks to the foundational entity API the module integrates well with Rules as well as Features - thus profile types and the associated fields can be exported into feature modules. Once the Entity tokens module (part of the Entity API) is turned on, there are also token replacements available.
> * You may use Views and/or the Search API to provide listings or searches for profiles.

Refer to its community documentation also for more details about this module.

---
Tags: nodes
---


# Question
Title: How can I organize my content using hierarchical taxonomy?
My question is rather simple, but I don't know how to do it ?

I want to display a content with various fields, but I want the user to browse "hierarchically". For instance :

* Choose brand : BMW
* Choose model : BMW / Z3
* Choose specific model : BMW / Z3 / 2.0 i

I already made a taxonomy "Brand", a taxonomy "Model", I have a view that shows all brands.

What can I do ?

Thanks for advice, it would help me a lot !

# Answer
> 1 votes
I had a similar implementation on a drupal 6 site using Hierarchical Select. The drupal 7 branch turned out to be working slightly differently when I first tried to make the move.

There is also Simple hierarchical select which was probably developed because of these 'differences' between d6 and d7:

> "This module has been inspired by Hierarchical select but is much simpler (…)."

I haven't tried *'Simple hierarchical select'* yet, but if I would re-build that d6 site again, I would probably go for *'Simple hierarchical select'*.

Both let you generate a taxonomy tree with dependend parent-child-relationships. So instead of having one taxonomy `brand`and one one taxonomy `model` you would have a taxonomy tree taht would contain all the branches down to `specific model`.

In my case is was `venues` which then also contained the upper branches like `city`and `country`.

PS: You could however also use entity references to build complex hierarchical content trees. You would then for example have a content type `brand` and a content type `model` referencing each other. Nowadays I find this approach more convenient than dealing with taxonomy trees – but that's of course depending on personal preferences and/or content structure.

---
Tags: taxonomy-terms
---


# Question
Title: How to increase the maximum upload size?
I'd like to increase the maximum upload size from 2MB to 5MB on my website (I'm using WAMP). My first attempt to do this was to set `Content types > MY CONTENT TYPE > Manage fields > MY IMAGE FIELD > Maximum upload size` to `5 MB`, but that didn't work. Next, (after reading this question and this article) I added

```
ini_set('post_max_size', '5M');
ini_set('upload_max_filesize', '5M');

```

to my `sites/default/settings.php` file, but that didn't solve the problem either.

What am I doing wrong? Why didn't my first approach work?

# Answer
> 2 votes
You need to make some changes in your **php.ini** file for **Post max size** and **upload max size**

Just follow this link for reference , Click here

# Answer
> 0 votes
I know the question has been asked a year back but still I make my answer below to benefit someone who is in need because I had the similar kind of issue which I resolved by changing in ".htaccess" file.

```
# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
...
php_value upload_max_filesize 30M
php_value post_max_size 30M
...
</IfModule>

```

Just add the above 2 lines (phpvalue) in .htaccess file and you are done!

Thanks to the Increase upload size in your php.ini where I finally got the solution.

---
Tags: 7, files
---