title: Display Solr search form on every pages

text:
# Question
Title: Display Solr search form on every pages
I'm working on a site which uses Apache Solr for the site search which is on the URL /search/site/.

What I want to do is add a form to every page on the site which allows the user to entered text in & submit it. The form will then take the user to the /search/site/ page displaying the results for their search term.

This sounds like it should be simple but I cannot see how to do it, I cannot find a way of creating a block for it & when I try to use the code below to programmatically display the form it is presented to the user but when submitted they are taken to the correct page (/search/site/) but the results of their search are not displayed.

```
$search_form = drupal_get_form('search_form');
$search_form_box = drupal_render($search_form);
print $search_form_box;
print render(drupal_get_form('search_form'));

```

I wasn't 100% sure that "search\_form" was correct but when submitted it does take you to the correct search results page (/search/site/) but no terms or results are displayed.

I'm quite new to using Drupal & Solr so if there's any information you need that I missed out please ask.

# Answer
I managed to work this one out, to get the block ready to be displayed I used preproccess\_region (see code below)

```
function THEMENAME_preprocess_region(&$variables){
    $site_search_block = module_invoke('search', 'block_view', 'search');
    $variables["site_search_block"] = render($site_search_block);
}

```

Then in in my region .tpl file (region--menu.tpl.php for me) I put the following code to display it.

```
<?php if($site_search_block){ print $site_search_block; } ?>

```

As an additional bit of information if you want to edit the output of the form as I did, although I didn't ask about it here, this function should help you:

```
function THEMENAME_form_search_block_form_alter(&$form, &$form_state, $form_id) {
    $form['#id'] = 'siteSearchForm'; //Set form element ID

    //The form elements (I think)
    $form['search_block_form']['#title'] = t('Search'); // Change the text on the label element
    $form['search_block_form']['#title_display'] = 'invisible'; // Toggle label visibilty
    $form['search_block_form']['#size'] = 10;  // define size of the textfield
    //$form['search_block_form']['#default_value'] = t('SEARCH'); // Set a default value for the textfield

    //Submit button element values
    $form['actions']['submit']['#value'] = t('GO!'); // Change the text on the submit button
    $form['actions']['submit'] = array('#type' => 'image_button', '#src' => base_path() . path_to_theme() . '/img/search-icn.png');

    //Add extra attributes to the text box
    //$form['search_block_form']['#attributes']['onblur'] = "if (this.value == '') {this.value = 'SEARCH';}";
    //$form['search_block_form']['#attributes']['onfocus'] = "if (this.value == 'SEARCH') {this.value = '';}";

    //Prevent user from searching the default text
    //$form['#attributes']['onsubmit'] = "if(this.search_block_form.value=='SEARCH'){ alert('Please enter a search'); return false; }";

    //HTML5 placeholder attribute instead of using the javascript
    $form['search_block_form']['#attributes']['placeholder'] = t('SEARCH');
}

```
> 1 votes

---
Tags: 7, search
---


# Question
Title: Should a fresh install of Drupal have failing tests and what to do with the failing tests?
I'm delving into the world of SimpleTest in Drupal. I started off by doing a fresh installation of Drupal 7 and running all the tests. I noticed there are a few tests that are failing, along with 1 test throwing an exception. Should a completely fresh install of Drupal 7 (or Drupal in general) have failing tests? I understand that in HEAD not all tests are going to pass. But, does Drupal get released along with a test suite that includes still failing tests?

I've tried searching the Drupal Core issue queue for some of the failing tests but haven't really found anything.

## Edit

Based on comments so far, it seems that it is not intentional that a release of Drupal would include failing tests, even if for known issues that haven't been resolved as part of that release. Given that assumption, what is the best thing to do from there?

# Answer
> 2 votes
All tests are run on every patch that is posted on drupal.org, fully automated. Nothing is commited unless all tests are passing (It happens that something is commited that breaks the tests (for example if the tests only fail sometimes or the fail was not triggered on the patch for some other reason. However, development comes to a complete halt in such cases until the tests are working again.

But, these automated tests are run on equally configured, highly tuned linux servers (they currently run all of the core tests in ~40 minutes, I'm not going to ask how many hours it took you :)).

So, what is possible is that your system is somehow configured differently, uses different version of PHP, MySQL, the OS or something else. The tests should of course pass on every supported environment, so what I would recommend is creating a core issue, list the not-working tests (including the exact failures, e.g. with screenshots) and a detailed description of your set-up including your versions of PHP, MySQL, Apache, OS, extensions and so on.

I know that DamZ does regularly run all tests on different setups, including PostgreSQL, Windows and so on and I'm pretty sure that most except the Linux/MySQL env still have known failures. Edit: The site for this is on http://drupaltesting.org/, but it looks like it's been broken (the test environment, not the tests) for a few months now..

# Answer
> 0 votes
As already stated, Core tests should **not** fail. In a stable version, no patch against Core is allowed if it breaks any test what so ever. Generally, this requirement is even upheld against the current -dev version, current 8. If you supply a patch that intentionally breaks a test, you are are supposed to supply a new test as well.

There are instances where this requirement can simply not be held up when it comes to large Core re-writes, and exceptions are made, but I *strongly* doubt this would ever be accepted in a stable version.

Most likely, this is caused by something in your environment instead. I have that issue myself. Tests (in a contrib project) that are known to work by several others, and myself of a different system, randomly fail. I have never taken the time to figure out why.

Since the number of reasons why a test could fail is near inifinite, all the way from a hacked Core to faulty hardware, the only general advice I can give is to whip up a debugger, or, if convenient, replace your server.

# Answer
> 0 votes
I know this is three years old, but the fix for me ended up being elusive, but embarrassingly simple.

My particular dev environment is an Ubuntu 14 Server distro running on a VM on my MacBook. In order to access my sites, I modify my Mac's hosts file to point my servers's IP to my site's host name.

After several hours futile troubleshooting, I realized that I needed to make a similar edit to the hosts file on my server, pointing localhost to my site's host name. As soon as I made that update - BOOM! All green.

Hope this helps someone else!

---
Tags: testing
---


# Question
Title: Is there a way to hand-code a reference to a block?, in a .tpl file?
Is there a way to hand-code a reference to a specific block?, in a .tpl file?

Specifically what i’m trying to do is this. I have a Drupal commerce site and the shopping cart contents are displayed via a block view. The contents are nicely hidden until the user mouses over a link. This is accomplished via the Ajax commerce cart module.

My global nav is hand-coded via a block-myNav.tpl.php file. So within the nav UL the pseudo code might look like

```
<li><?php print $my_block_reference here ?></li>

```

is that crazy? is there a way to accomplish this?

# Answer
> 2 votes
I'm guessing the down vote to what probably should be the correct answer to this post is b/c the answer did not have any code.

The way to render a block is:

```
<?php
  //D7
    $block = module_invoke('module_name', 'block_view', 'block_delta');
    print render($block['content']);
?>

```

That can be placed in the template file that you want the block to show. See here for information on what the vars are in that snippet of code.

# Answer
> 1 votes
There are a couple of modules that you should look at. Context and Display Suite.

Context....

> Context allows you to manage contextual conditions and reactions for different portions of your site. You can think of each context as representing a "section" of your site. For each context, you can choose the conditions that trigger this context to be active and choose different aspects of Drupal that should react to this active context.

As for Display Suite....

> Display Suite allows you to take full control over how your content is displayed using a drag and drop interface. Arrange your nodes, views, comments, user data etc. the way you want without having to work your way through dozens of template files.

Between these two modules, you will probably never have to hack a template file again.

# Answer
> 1 votes
You can see here. This way to placing the contents of a block in any location

---
Tags: theming, commerce
---


title: Get the CCK field value using dbquery

text:
# Question
Title: Get the CCK field value using dbquery
I have a content type called user registration under this one cck field called regid. i would like to fetch the entered values of this particular field through programmatically probably by using dbquery() functions and print it. Anyone guide me how to achieve it.

# Answer
Here is a little example, how to make requests in Drupal 6. You may change table name and field name and it should work for you.

```
$query = db_query('SELECT n.nid, regid.regid_FIELD_VALUE
   FROM {node} AS n
   JOIN {regid_FEILD_TABLE_NAME} AS regid ON regid.vid = n.vid
   WHERE n.type = %s AND n.status = %d, $your_node_type, 1);

$result = array();
while($node_data = db_fetch_object($query)) {
  $result[] = array(
    'nid' => $node_data->nid,
    'regid' => $node_data->regid_FIELD_VALUE,
  );
}

```
> 1 votes

---
Tags: entities, database
---


# Question
Title: Full name field on node using Display Suite
I am using Display Suite for layout and arrangement of nodes. I would like to display the full name of a node author (a field I have added to the user entity). Display Suite will only show the author username.

How do I display the full name field on a node, instead of the author username?

# Answer
> 0 votes
It sounds like you need a field formatter. You have a few options:

1. Use Drupal's mechanism and create one yourself.
2. Use the *Custom Formatter* module to create a custom formatter.
3. Use Display Suite to create a custom code field.

If you aren't comfortable with coding, options 2 and 3 are good choices. Option 1 is leaner since if you already have a custom module it wouldn't add the overhead to your site of enabling another module.

---
Tags: display-suite
---


# Question
Title: Creating custom node aliases inside a simpletest
I am attempting to write simpletests to replicate the steps to reproduce on this d.o issue.

I need to create a test node with a custom alias, as if I had unchecked the "Generate automatic URL alias" checkbox and supplied my own value.

Currently, attempting to insert it with

```
$edit = array(
  'title' => $this->randomName(),
  'path' => array(
    'source' => 'node/1',
    'alias' => 'qwerty',
  ),
);

```

fails, and generates errors, as does

```
 $edit = array(
    'title' => 'asdf',
    'path[alias]' => 'qwerty',
  );

```

So, I tried:

```
$path = array('source' => 'node/1', 'alias' => 'qwerty');
path_save($path);

```

The above successfully creates an alias, but when I inspect `$node->path[
alias']` it shows me something other than `qwerty`.

`drupal_lookup_path('alias', "node/".$node->nid)` also returns only the Pathauto-generated alias, and not any alias that was created manually, even in the node edit form.

Additionally, if I create a new alias from the same source, my original alias is not replaced, as it would be if I had manually entered a new alias into the field on the node edit form.

As I am attempting to exactly duplicate the steps to reproduce in the linked d.o issue, it matters how the alias gets created. Is there any way to more exactly replicate the manual creation of an alias on the node edit form, inside a test?

# Answer
It turns out that

```
$edit = array(
  'title' => 'asdf',
  'path[alias]' => 'qwerty',
);

```

was correct, but that I needed to add the permission `'create url aliases'` to the drupalCreateUser array.
> 1 votes

# Answer
You can create custom alias using this code:

```
$path = array(
  'source' => 'node/' . $node->nid,
  'alias' => "content/' . $node->title,
);
path_save($path);

```

Use this code in your test just after you create the node.

And then you can retrieve the alias using this `drupal_get_path_alias('node/' . $node->nid)` in your test case.
> 1 votes

---
Tags: path-aliases, uri, testing
---


# Question
Title: How do I make my site "notice" things to index?
The built-in search feature in my Drupal site is not working. After looking online, the only solutions I've seen are to "`0% of the site has been indexed`" but with "`x items left to index`" (x\>0).

My question is how do I make my site "notice" things to index?

Here's a picture of the error I get:

***Update:*** I'm working with Drupal 7.

# Answer
Here are a few things you should check:

* On the Search settings page (located at `admin/config/search/settings`), make sure `Node` is checked (enabled) as an Active Search Module.
* On `admin/reports/status`, verify when your cron job was last executed. And use the link '*run cron manually*' on that page to manually trigger the cron job to be run.
* Disable the "PHP Filter" module (used for nodes that use the "PHP Code" input format), to not get stuck because of some bad PHP code stored in a node. Because nodes containing PHP can cause problems with search indexing.
* Clear the cache.
* Check the Drupal log for possible errors related to it.

Some more excerpts from Search module: an internal site search system, related to Re-indexing:

* **Content-related actions** on your site (creating, editing, or deleting content and comments) automatically cause affected content items to be marked for indexing or reindexing at the next cron run. When content is marked for reindexing, the previous content remains in the index until cron runs, at which time it is replaced by the new content.
* Unlike content-related actions, **actions related to the structure** of your site do not cause affected content to be marked for reindexing. Examples of structure-related actions that affect content include deleting or editing taxonomy terms, enabling or disabling modules that add text to content (such as Taxonomy, Comment, and field-providing modules), and modifying the fields or display parameters of your content types. If you take one of these actions and you want to ensure that the search index is updated to reflect your changed site structure, you can mark all content for reindexing by clicking the "Re-index site" button on the Search settings page (administer \>\> site configuration \>\> search settings in Drupal 6, or administer \>\> configuration \>\> search and metadata \>\> search settings in Drupal 7).

If none of this helps, then you may also want to look at issue # 1715366 (which started in D7 ...) for other possible causes of your issue.

PS: what happens if you run the cron job, eg by triggering it from the admin screens?
> 2 votes

---
Tags: 7, search
---


# Question
Title: File Transfer failed, reason: Unable to change to directory
I'm work on updates modules in my drupal site. When i access `localhost/authorize.php` after linked in config, i recieve this:

```
Update failed! See the log below for more information. Your site is still in maintenance mode.

```

the log is...

```
views

    Error installing / updating
    File Transfer failed, reason: Unable to change to directory /drupal/sites/all/modules/views

views_bulk_operations

    Error installing / updating
    File Transfer failed, reason: Unable to change to directory /drupal/sites/all/modules/views_bulk_operations

webform

    Error installing / updating
    File Transfer failed, reason: Unable to change to directory /drupal/sites/all/modules/webform

jquery_update

    Error installing / updating
    File Transfer failed, reason: Unable to change to directory /drupal/sites/all/modules/jquery_update

simplenews

    Error installing / updating
    File Transfer failed, reason: Unable to change to directory /drupal/sites/all/modules/simplenews

entityreference

    Error installing / updating
    File Transfer failed, reason: Unable to change to directory /drupal/sites/all/modules/entityreference

ctools

    Error installing / updating
    File Transfer failed, reason: Unable to change to directory /drupal/sites/sites/all/modules/ctools

entity

    Error installing / updating
    File Transfer failed, reason: Unable to change to directory /drupal/sites/all/modules/entity

```

I have tried to fix permissions in folder using: `sudo chmod a+w` and `sudo chown root sites/default` and `chmod 777` , every using folder sites/default and sites/all/modules, but i canot successfuly updates my modules using ftp and automatic.... how i fix this? thanks in advance

# Answer
Try executing your `chown` command recursively, and also assign an explicit user and your web server's group, like so: `sudo chown my_user:www-data sites/all/* -R` where `my_user` is your id and `www-data` is your web server's group. This will recursively apply ownership to your entire directory tree.

It might also be worth pointing out that you mention assigning ownership and privileges to `sites/default`, but your error messages indicate that the problem is in `sites/all`. :-)

In my experience, failed uploads or updates are almost always due to incorrect ownership.
> 0 votes

---
Tags: 7
---


# Question
Title: Do I need to run Captcha and Mollom simultaneously?
Just wondering if I have Mollom installed and running successfully on a D7 site, if I still need to keep Captcha enabled?

I'm getting double captcha forms with both enabled.

# Answer
If you're satisfied with the Mollom module, then I don't think it makes sense to also leave the Captcha module enabled/installed.

However, **if** you're looking for some kind of extra protection/layer but without those double captcha forms, **then** you may want to consider replacing Captcha with the Honeypot module. Because of the technique used by Honeypot, you don't risk to have double captcha forms in that case.

Some more details about the Honeypot module (from its project page):

> ... uses both the honeypot and timestamp methods of deterring spam bots from completing forms on your Drupal site (read more here). These methods are effective against many spam bots, and are not as intrusive as CAPTCHAs or other methods which Punish the user.

**Note**: even if you don't want to consider using the Honeypot module (for whatever reason), **keep "the message" in mind** about what that link quoted from its project page (Punish the user) is trying to explain whenever your researching similar modules.
> 2 votes

---
Tags: 7, advertising, captcha
---


# Question
Title: Can I control what caches are flushed via "Flush all caches"?
I use the module Boost and anytime I click "Flush all caches" it deletes all the cached pages already built. Is there any way to make "Flush all caches" to flush all cache instead of the Boost-created **.html.gz** cached pages?

# Answer
If you're using the admin menu module you can selectively target which cache to flush by hovering over the the *Flush all cache* menu under the home icon. The *Class registry* and *Page and else* will wipe out the Boost cache, but everything else will leave it intact.
> 1 votes

---
Tags: caching
---


title: Drupal website was hacked?

text:
# Question
Title: Drupal website was hacked?
What is the hack that can cause my Drual website to be blank, without showing any message error.. Not be able even I enter .../users, -\> blank. It was absolutely brilliantly showing fine.

If you want to see this Drupal website URL, go ahead:

http://fightforhongkongdemocracy.net

Thanks.

# Answer
> 2 votes
There is a guide on drupal.org with multiple troubleshooting methods to resolve white screens with no ouputs: https://www.drupal.org/node/482956

# Answer
> -1 votes
It is not finding it on the server. Reboot the server and try again quickly.

---
Tags: users
---


title: Make Wysiwyg Use CKEditor CDN

text:
# Question
Title: Make Wysiwyg Use CKEditor CDN
Is it possible to make the Wysiwyg module use the CKEditor's CDN for delivering the editor to the browser client?

# Answer
> 3 votes
If all you're using the wysiwyg editor is for ckeditor, you can use the ckeditor module instead.

> This module will allow Drupal to replace textarea fields with the CKEditor - a visual HTML editor, usually called a WYSIWYG editor. This HTML text editor brings many of the powerful WYSIWYG editing functions of known desktop editors like Word to the web. It's very fast and doesn't require any kind of installation on the client computer.

you can tell ckeditor to use the CDN in the Advanced settings of the Global Profile:

---
Tags: 7, hooks, wysiwyg, cdn
---


# Question
Title: How do I print the output of a field as a link on node.tpl.php?
How do I print the output of a field as a link on node.tpl.php? I'm able to print the raw output of a field using this:

```
<?php $display = array('label' => 'hidden');
$view = field_view_field('node', $node, 'field_podcast_url', $display);
print drupal_render($view);?><?php $display = array('label' => 'hidden');?>

```

The problem occurs when I try to make it as a link using this method:

```
<?php $display = array('label' => 'hidden');
$view = field_view_field('node', $node, 'field_podcast_url', $display); ?>
<a href="<?php print drupal_render($view); ?>">text</a>

```

The output looks like this:

http://www.podtrac.com/pts/redirect.mp3/feeds.soundcloud.com/stream/211653270-scott-johnson-27-tms-846.mp3 "\>text

and the link points to this:

```
http://controldaily.dev/<div class=

```

I've looked around at solving this issue and can't find a solution. Anything else just shows nothing.

# Answer
> 1 votes
This looks like it's happening because you are trying to input the entire rendered field (including styling) into the links href.

As per the description:

> The field\_view\_value() function can be used to output a single formatted field value, without label or wrapping field markup.

To use field\_view\_field, try something like:

```
if($node->type == 'article')
{
    $link_field = field_view_field('node', $node, 'field_href');
    print l(t($link_field['#items'][0]['safe_value']), $link_field['#items'][0]['safe_value']);
}

```

This example assumes a node of article type, and a field with a machine name field\_href. running it through l() (despite using the safe value) will help ensure it is sanitised properly before being output.

You can also take a look at the Link field module:

> The link module can be count to the top 50 modules in Drupal installations and provides a standard custom content field for links. With this module links can be added easily to any content types and profiles and include advanced validating and different ways of storing internal or external links and URLs. It also supports additional link text title, site wide tokens for titles and title attributes, target attributes, css class attribution, static repeating values, input conversion, and many more.

---
Tags: theming
---


# Question
Title: Display a View Block multiple times in a region with each view using a different filter
Here's a visual representation of what I wanted to happen.

```
<my-region>

    <article-list-view filter=article-type-1 />

    <article-list-view filter=article-type-2 />

    <article-list-view filter=article-type-3 />

</my-region>

```

Now I can actually just go ahead and create a separate region and a separate view block for each type of filter but it doesn't look like good design since It's going to be repetitive.

Is my goal doable? If not, what's the common approach to accomplish this task?

# Answer
Based on what you have described, yes. It is not only doable, it is quite easy.

You can add different pages, blocks or even attachments. When you creating/editing a view, click on "Add" then select what you would like.

With an attachment, you can select before, after or both for each attachment.

The key to making this work is to only set criteria for that display only. In the example below, I am in the "Add Fields" dialog. If you want a separate filter for this particular page/block/attachment, make sure to select "This Page (Override)"

When you do this, anything in this view will be restricted to this display only.
> 1 votes

---
Tags: views, theming
---


title: Add new field to node form on validate

text:
# Question
Title: Add new field to node form on validate
I am performing a hook\_node\_validate() and would like to add a new field (e.g. a textfield) during the processing of this function. Is this possible? If so could someone let me know how to do it. I am tried to following so far w/ no luck:

```
function hook_node_validate($node, $form, &$form_state) {
    $form['content_type_node_form'] = array(
        '#title'    => t('Phone'),
        '#type'     => 'textfield',
        '#required' => TRUE,
    );
    form_set_error('time', t('Stop submission to add new field'));
}

```

Thanks, Derek

# Answer
> 0 votes
I'm guessing what you actually want (from a user story perspective) is if a certain condition is met another, otherwise hidden, field is shown. As @geoff points out that field would need to exist on the content type.

I believe the correct way to do this within the Form API is with the #states parameter in order to conditionally show/hide the phone field. https://api.drupal.org/api/drupal/developer!topics!forms\_api\_reference.html/7#states

---
Tags: forms, nodes
---


# Question
Title: How to animate set of titles of a View using JQuery
There is a View of latest news title linked to the node page and I need to display them like this Effect.

I've trying to do it by creating a new template file for my views named:

> views-view-list--latest-news--block.tpl.php

and this is the code I was trying to set to work:

```
<?php print $wrapper_prefix; ?>
  <?php if (!empty($title)) : ?>
    <h3><?php print $title; ?></h3>
  <?php endif; ?>
  <?php print $list_type_prefix; ?>
    <div class="type-wrap">
        <span id="typed" style="white-space:pre;"></span> //this is where it shoul be typed...
     </div>

  <?php print $list_type_suffix; ?>
<?php print $wrapper_suffix; ?>
<?php
$setOfTitles = "";
foreach($rows as $id=>$row)
     $setoftitles.="'".$row."'".",";
$setoftitles = rtrim($setoftitles , ','); // to remove the last `,`
print_r ($setoftitles); // and it says I have all of you node titles
?>
<?php print_r($setOfTitles); ?>
    <script type="text/javascript">
    var stitles = "<?php $setoftitles;?>"; </script>
    <script type="text/javascript">
    alert(stitles); //but its alerts is empty (means variable is not passed to js)
    $(function(){
        ;
        $("#typed").typed({
            strings: [stitles],
            typeSpeed: 30,
            backDelay: 500,
            loop: false,
            contentType: 'html', // or text
            // defaults to false for infinite loop
            loopCount: false,
            callback: function(){ foo(); },
            resetCallback: function() { newTyped(); }
        });

        $(".reset").click(function(){
            $("#typed").typed('reset');
        });

    });

    function newTyped(){ /* A new typed object */ }

    function foo(){ console.log("Callback"); }

    </script>

```

but it is not a true answer!! because my alert in js is empty and means I couldn't pass variable form php to js. Where is the problem? and how can I solve it? or is there a better way to do it?

# Answer
> 1 votes
Salam :). You need no new Views display type. Create a view of the latest news called it *lnews* and display it in a block, suppose it's machine name is *block\_0*. select the titles as the *Fields*. You have to use PHP code inside that block (enable `PHP Filter` module). Use this code

```
 <div class="type-wrap">
        <span id="typed" style="white-space:pre;"></span>
</div>
<?php
$views = views_get_view("lnews");
$views->set_display('block_0');
$views->execute();

```

Now to get the titles use this code (to get the accurate code use `kpr($views)`)

```
$setOfTitles = "";
foreach($views->result as $view)
     $setOfTitles .= $view->node_title."*";
$setOfTitles = rtrim($setOfTitles , "*"); // to remove the last `*`

```

So far you created a string of all of the titles which they are separated by a `*` sign. There is one more step left, Send this variable to a .JS file that contains

```
$(function(){

    $("#typed").typed({
        strings: [HERE IS YOUR STRING],
        typeSpeed: 30,
        backDelay: 500,
        loop: false,
        contentType: "html",
        loopCount: false,
        callback: function(){ foo(); },
        resetCallback: function() { newTyped(); }
    });

    $(".reset").click(function(){
        $("#typed").typed('reset');
    });
});

```

code, then explode the string to an array and send it to the `strings` object.

To send `$setOfTitles` variable from the above block to the JS file here is a few tutorials

Now I assume you have successfully sent the variable to .JS file, call it's name `var titles`. use split() function to convert the string in to an array. Now this code should work:

```
var array_of_titles= titles.split("*");
$(function(){
    $("#typed").typed({
        strings: [array_of_titles],
        typeSpeed: 30,
        backDelay: 500,
        loop: false,
        contentType: "html",
        loopCount: false,
        callback: function(){ foo(); },
        resetCallback: function() { newTyped(); }
    });

    $(".reset").click(function(){
        $("#typed").typed('reset');
    });
});

```

This solution wont link the titles to the node page. The

```
foreach($views->result as $view){
     $setOfTitles .= $view->node_title."*";
     $setOFNIDs .= $view->nid."*";
}

```

creates list of node IDs. You can also pass the node IDs to the JS file and with some js processing link the titles to the `/node/nid`.

For example in the JS file instead of creating array of title create array of `<a href="/node/nid">TITLE</a>`

---

**UPDATE:**

Sounds you had problem with sending the `$setOfTitles` variable to the javascript file. Use the following method:

In the PHP code I gave you above add this code

```
drupal_add_js(array('variableName' => $setOfTitles), 'setting');
drupal_add_js(path_to_theme().'/js/js.js');

```

Create a file in `/js` directory of your theme folder and rename it to `js.js` and in the `js.js` use this code

```
(function($, Drupal){
  Drupal.behaviors.backgroundAnimation = {
    attach: function(context, settings) {
      alert(Drupal.settings.variableName);
      alert(Drupal.settings.basePath);
    }
  };
})(jQuery, Drupal);

```

I tested this solution and it successfully alerted the `variableName` and `basePath`. So just insert the rest of the Javascript code I gave you above in the `(function($, Drupal)` function.

# Answer
> 1 votes
thanks to @Drupalist helpes I could do it and it was the code I use to do it:

```
<?php
$views = views_get_view("latest_news");
$views->set_display('block_0');
$views->execute();
$setOfTitles = "";
foreach($views->result as $view)
     $setOfTitles.= $view->node_title.",";
$setOfTitles = rtrim($setOfTitles , ","); // to remove the last `,`
?>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="sites/all/themes/mycorolla/scripts/typed.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
var $stitles="<?php print $setOfTitles; ?>"; </script>
<script type="text/javascript" language="javascript">

var $test=$stitles.split(",");
$(function(){
    $("#typed").typed({
        strings: $test,
        typeSpeed: 30,
        backDelay: 500,
        loop: false,
        contentType: "html",
        loopCount: false,
        callback: function(){ foo(); },
        resetCallback: function() { newTyped(); }
    });

    $(".reset").click(function(){
        $("#typed").typed('reset');
    });
});
 </script>
 <div class="type-wrap">
<span id="typed" style="white-space:pre;"></span>
</div>

```

---
Tags: views, theming, javascript
---


title: Custom search results

text:
# Question
Title: Custom search results
I am using drupal 7 built in search module. In my custom content type, I have multiple products for `Industrial`,`mechanics` and `sports` categories. I need to apply search restriction on some products for my `mechanics` category. Means If `mechanics_product1`, `mechanics_product2` and `mechanics_product3` are mechanics products then I need to apply search restriction on all products for only `mechanics_product2`. Only authorize user will be only able to search this particular product.

# Answer
Try

**1. Search configuration**

This module has five main functions.

1. Alter the appearance of the core node search form
2. Group content types for more meaningful searching
3. Restrict search results by the content type. This is a role based restriction.
4. search results from showing individual items.
5. Alter the pager limit (aka number search item results per page).

**2. Custom Search**

> This module alters the default search box in many ways. If you need to have options available like in advanced search, but directly in the search box, this module is for you.
> 3 votes

---
Tags: 7, search
---


title: How to show fid with slideshow image

text:
# Question
Title: How to show fid with slideshow image
I have very specific requirement. I want to show images in slideshow. I have created content type **"User Slideshow Snaps"** and two fields

* Slideshow Snaps
* Node Id

I want to show slieshow of images in field **Slideshow Snaps** which belongs to Node Id passed in URL.

The slideshow is working perfectly and I have used Modules **Views Slideshow** & **Views Slideshow: Cycle** for this.

Now I want to link Slideshow to external page which will pass FID of current image in slideshow like this:-

But I am facing problem in passing fid of clicked image in slideshow. This configuration is always passing FID of first image in slideshow even if user clicked on 8th image in slideshow.

Thanks in advance for your help.

# Answer
You may use views template files. If your view name is `gallery` and it's machine name is `block_0` then in your theme folder create a file and name it `views-view-fields--gallery--block-0.tpl.php`.

There are two fields in the content type, an image with the machine name `field_image` and a text that is address of some where else with the machine name `field_link`.

In the `views-view-fields--gallery--block-0.tpl.php` file the following variables are available

```
1. $fields['field_image']->content;
2. $fields['field_link']->content;

```

To create a slideshow like this

with a string on it you can easily use html tags and css absolute positions to set the string on the image. Anyway you can display it in any way you want. Don't forget to clear the cache.
> 1 votes

# Answer
1. Try creating view for files entities (not for nodes).
2. Add relationship to parent node
3. Add contextual filter for node id using "relationship to parent node"
> 0 votes

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


# Question
Title: How can I use the Freelinking module for creating links to external sites?
How can I use the Freelinking module in order to create links to external websites? I'd like to find an example.

What I found online says that external links should look like this:

```
[[/^http$|^ext/":site-name-here:Title]]

```

But that hasn't worked for me.

# Answer
Whatever documentation you've "found online" is wrong.

**Freelinking** does not use (or understand) regular expressions. The module's documentation tells you that this is how you link to an external site:

```
[[http://site-name-here|Title]]

```

It also works using "https" instead of "http".
> 1 votes

# Answer
The indicator for an external address is `http`, not `/^http$|^ext/"`. I think MathJax gave me some problems on the page.
> 0 votes

---
Tags: navigation
---


# Question
Title: How do I show the size of an Image file in media2 after selecting the image?
After selecting an Image field using the media browser, in the edit form the selected shows image, an edit button, a delete button, and an "include file in display" checkbox.

How Do I add the size of the image in the same display?

Q2: In a colourbox popup display, which seems to only pick the "title" , I cant get this to read html. Is there a way of enable html as I need some text in Italics, and in Bold?

Thanks.

# Answer
I found the solution. Somehow undocumented is the fact that this uses the "Preview" view mode. Editing that and ensuring its the one selected in image view changed everything to working normally.

Thanks.
> 0 votes

---
Tags: media
---


title: How to show nodes with a flexible grid?

text:
# Question
Title: How to show nodes with a flexible grid?
For a website I need to show nodes with a flexible grid. There will be several rows (no specific number) and each row can contain:

* 1 full width image
* 2 50% width images
* 1 50% width image (left/right) and 1 50% width text block
* 1 full width text block

The administrator should be able to change the order of these blocks easily. I'm planning to do this with the Field Collection module, I think with this I can get this to work. But i was wondering, is there a better way to do this?

Here are two examples of what the node could look like, but ofcourse there are hundreds of different options.

# Answer
> 3 votes
You could try Paragraphs which is an alternative to Field Collection.

# Answer
> 0 votes
Seems like you should be looking at the Panels module also. Excerpt from its project page:

> The Panels module allows a site administrator to create customized layouts for multiple uses. At its core it is a drag and drop content manager that lets you visually design a layout and place content within that layout. Integration with other systems allows you to create nodes that use this, landing pages that use this, and even override system pages such as taxonomy and the node page so that you can customize the layout of your site with very fine grained permissions.

Possibly also with 'mini-panels' added to that.

Be prepared however to invest some time in learning about this amazing modules. A great resource for learning about Panels is the (free) video training about Learn Page manager. *Panels* uses 'Page manager', which is one of the sub-modules of Chaos tool suite (ctools)).

---
Tags: entities
---


title: Drupal content type text value

text:
# Question
Title: Drupal content type text value
I've created a content type that contains a form. In this form, there is a textfield that i want to make only readable + a specific value on it (if user A is editing this form, he can write on all textfields except this textfield that will contains : user A)

In the other side, I've a custom module that deals with users, so I have users with users ID, usernames..ect the username is the text that I want to automatically set on the content types textfield

I can't show you any code because as I said, it's a content type

Any help is great

# Answer
It sounds like you're looking for Field Permissions.

> The Field Permissions module allows site administrators to set field-level permissions to edit, view and create fields on any entity.
> 0 votes

# Answer
If this field is only used by modules and its existence doesn't make any change in your user's life , then you can make this field hidden in form . you also can fill its data using rules easily .
> 0 votes

---
Tags: nodes
---


title: target=_blank for links in view

text:
# Question
Title: target=_blank for links in view
I've got a view and one of the fields is displayed as a link. (`Output this field as a link` is cheked). But now i want those links to have `target=_blank` attribute.

How can i achieve this?

# Answer
When you check `Output this field as a link` there is a `Target` input box available (Further down). In that input box you can write `_blank`. (D7)
> 4 votes

# Answer
edit: I just saw the answer whitefleaCH gave you - I never use the output settings as i prefer to style my views using templates to clean up the code - so i didn't know that option existed, though I presumed it did..

---

You can either use the themeing part of view and create your own template for the row style and simply hardcode the link attribute into it there (click the 'theme: information' part in the advanced settings of your view to see how to name your theme template).

Or which is probably easier - depending on how much themeing you'll be doing to your view - is to use jquery by doing the following:

Create a .js file and paste the following in into it (create a new textfile and save as yourfile.js):

```
(function($) {

$(document).ready(function() {

      $('.CLASS a[href]').attr({
          target: "_blank",
          title: "Opens in a new window"
        })

});

}(jQuery));

```

Change the CLASS bit with the class surrounding your link and save the file.

Upload your YOURFILE.js to your theme directory (eg: sites/all/themes/YOURTHEME/) Open YOURTHEME/template.php file and tell it to load your .js file by adding the following line

```
drupal_add_js(drupal_get_path('theme', 'YOURTHEME').'/assets/js/YOURFILE.js');

```

Clear your cache and all links surrounded by

```
  <div class="CLASS"><a href="">Link</a></div>

```

will automatically open in a new window.

Of course you can do a lot more with the above script, like add a special class to the links so you can use .css to style them differently, or append some symbol or image etc etc ...

I hope this helps.
> 2 votes

# Answer
Linked Field module with Tokens.

Just brilliant!

After that in your View you may select **Show:Content | Teaser** (Teaser or any other preferable display)

The same but kinda verbose way give us the Image Link Formatter module, but only for images.

@whitefleaCH gives good solution too! (only for Views module)
> 1 votes

---
Tags: views, navigation
---


# Question
Title: Get the value of a form element returned from an ajax callback function
I have a select element and submit button in my form :

```
$form = array();

$form['myid_template'] = array(
    '#type' => 'fieldset',
    '#title' => t('Select Template'),
    '#suffix' => '<div id="myid_dynamic_input_information"></div>',
);

$form['myid_template']['template_options'] = array(
    '#type' => 'select',
    '#options' => array(
         1 => t("Student"),
         2 => t("Employee"),
     ),
     '#default_value' => 1,
     '#title' => t('Select'),
     '#ajax' => array(
         'callback' => 'myid_select_template',
         'wrapper' => 'myid_dynamic_input_information',
     ),
);

 $form['submit'] = array(
     '#type' => 'submit',
     '#value' => 'Save',
     '#ajax' => array(
         'event' => 'click',
         'callback' => 'myid_user_page_form_ajax_submit',
     ),
 );

```

My select form element calls an ajax function `myid_select_template` that adds a field and updates the form.

```
function myid_select_template($form, $form_state){
      $form = array();
      $form['form']= array(
          '#type' => 'fieldset',
          '#title' => t("Employee's Information"),
      );

      $form['form']['template2_field1'] = array(
          '#title' => t('GSIS No.'),
          '#type' => 'textfield',
          '#description' => "Government Service Insurance System number.",
          '#attributes' => array(
              'id' => $template . '_field1' ,
          ),
      );
      return $form;
}

```

My problem is, after `myid_select_template` is called, whenever I click the submit button , I cant access `$form['form']['template2_field1']` from `myid_user_page_form_ajax_submit` callback function.

```
function myid_user_page_form_ajax_submit($form, &$form_state) {
    dsm($form);
    dsm($form_state);
}

```

I did try to display my `$form` and `$form_state` variables but I cant find the value of `$form['form']['template2_field1']` in it. What should I do? Does it have connection in rebuilding the form? Do I have to rebuild the form to update the `$form_state`variable? If yes, how?

# Answer
I too not sure why the name attribute is not adding to the field. but you can bring by explicitly defining the name in the field.

```
 $form['form']['template2_field1'] = array(
      '#title' => t('GSIS No.'),
      '#type' => 'textfield',
      '#name' => 'template2_field1',
      '#description' => "Government Service Insurance System number.",
      '#attributes' => array(
          'id' => $template . '_field1' ,
      ),
  );

```
> 2 votes

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


title: Custom validate function not working

text:
# Question
Title: Custom validate function not working
I'm sure there's some simple reason that my custom validate function isn't executing.

Here's my code:

```
function MYMODULE_form_message_ui_instance_message_manage_alter(&$form, &$form_state, $form_id) {
  array_unshift($form['#validate'], 'MYMODULE_validate_relationship');
  watchdog("form", "<pre>" . print_r($form, true) . "</pre>");
}

function MYMODULE_validate_relationship($form, &$form_state) {
  watchdog("validate form state", "<pre>" . print_r($form_state, true) . "</pre>");
  watchdog("validate form", "<pre>" . print_r($form, true) . "</pre>");
}

```

On form submission, the first watchdog - "form" is being exected, however the second and third are not. Why is this? I can't find any information on why a custom validate hook wouldn't execute.

EDIT per Pierre's request:

I am writing a custom validation function that I am trying to execute before the other validation functions. I am doing this using array\_unshift. This seems to be working, as my #validate array looks like this:

```
[#validate] => Array
    (
        [0] => MYMODULE_validate_relationship
        [1] => message_ui_instance_message_manage_validate
        [2] => message_private_form_message_private_instance_message_manage_validate
    )

```

However the code in MYMODULE\_validate\_relationship is never executing.

As far as I can tell, $form and &$form should be irrelevant in the validate function, because once you're at the validation stage, nothing should actually be modifying the form (I think?). And most examples I was seeing did not including passing the $form by reference. And I've tried both ways, and in neither way is the validate hook firing.

# Answer
The answer is that the submit button was being generated by the actions array item.

Simply changing my form value to this:

$form\['actions'\]\['submit'\]\['#validate'\]\[\] = 'MYMODULE\_validate\_relationship';

Correctly allowed it to be executed.

https://api.drupal.org/api/drupal/developer!topics!forms\_api\_reference.html/7#actions
> 2 votes

---
Tags: forms
---


# Question
Title: Can't get Jcarousel to work, followed the instructions
This what I have done.

1. Get Jcarousel module and install.
2. Got Jcarousel Pluggin zipped files
3. Created the sites/all/libraries/jquery.jcarousel folder
4. Moved the content of the downloaded folder into the sites/all/libraries/jquery.jcarousel folder

Now this is where there is a problem.

> When this is done there should be a file sites/all/libraries/jquery.jcarousel/lib/jquery.jcarousel.js **or** jquery.jcarousel.min.js

There is no such file.

Where do I get those files?
I've tried to copy-paste the files from sites/all/libraries/jquery.jcarousel/dist, but it does not work.

# Answer
> 0 votes
I have installed Jcarousel module and it works. The directory in the `libraries` folder is like this

and it works. I downloaded the module's library from

> https://github.com/jsor/jcarousel

and Those files are under `dist` and `src` directory

# Answer
> 0 votes
There is an error in the documentation.

> When this is done there should be a file sites/all/libraries/jquery.jcarousel/**lib**/jquery.jcarousel.js or jquery.jcarousel.min.js

*lib* should be *libs*.

---
Tags: javascript
---


# Question
Title: How to create a sort features In Drupal?
I'm new to Drupal and want to create a sort option (to sort some Forum topics) so that a user can select any topic and apply it.

Here is an image to better illustrate this:

How to make such sort option?

# Answer
Use advanced\_forum module. See the image attached, it provides sort option.
> 0 votes

# Answer
You could transform the **tabular** display by using the DataTables **module**, which uses the datatables **plugin**.

In doing so, you get all the typical dataTables widgets available, such as sorting for appropriate columns, but also a search box, pagination, etc.
> 0 votes

---
Tags: users
---


# Question
Title: How do I install sandbox module 'Filedepot multiupload'?
I am new to Drupal and I am unable to install the sandbox module called Multiupload, it is an add-on module for Filedepot but there are no installation instructions that I can see. I am unsure where to put the files.

Steps I have taken so far:

1. Installed filedepot and it is working.
2. Installed plupload.
3. Overwritten `filedepot-mainpage.tpl.php` with the multiupload version.

# Answer
> 0 votes
The link you provided for the sandbox module 'Filedepot Multiupload' is actually an issue (request) for Drupal.org Project Applications.

The actual sandbox project is located at https://www.drupal.org/sandbox/e.ruiter/2290395 . On that page, wihin resources, there isn't any link mentioned (yet) with title "Read documentation", which typically points to either available "Community documentation", or to the "Readme.txt" that comes with the module.

The module's `Readme.txt` appears to be the best documentation currently available. To review/browse it, you have 2 options:

1. Browse the module's source code that you downloaded, which should contain that readme.txt.
2. Follow the "Browse code repository" on the project page of the sandbox project. Next visit the "Tree" tab and click on the Readme.txt link there.

Here is the content of that readme.txt:

> * **Introduction**: This module extends the filedepot module with multiple upload support. Files can be uploaded with the plupload module which supports drag and drop.
> * **Installation**: Just install the module by copying the module to site/all/modules directory or install with drush. If you get some errors about files missing and plupload is not loading, you are probably missing the plupload library. Find the README file of the plupload module and follow the instructions.

**Note**: while you're reviewing the Readme.txt and experimenting / testing that module, consider either (or both) of these approaches:

* enhance the readme.txt with anything you learn/discover about it, and then contribute an updated version of readme.txt back to this sandbox project. E.g. by creating a documentation issue, and attaching a copy of the updated readme.txt.
* create a community page containing such documentation, and then create a documentation issue for this sandbox project, requesting the module owner to update the project page to point to this new community documentation.

---
Tags: files
---


# Question
Title: Show related nodes of category selected in current node (using static select list)
I created a content type containing a select list field (ie Fruit, Food, Jewelery etc).

I am not using any node reference nor any taxonomy vocabulary.

I have added a static select list. I want to show related nodes under the current node. I.e if I visit a node containing the *fruit* category, then all the other nodes containing fruit category should be shown below the current node.

# Answer
Your persistence on not using taxonomy is interesting . any way to make it happen you will need to use Panels , create a view of type content pane , add a contextual filter , filter your content based on your field , then you will need an argument for your filter , in the pane settings you will find a argument setting , pass your content field as argument , then in page manager in node view add your created pane . (don't forget to restrict node view to your content type) Check The views Context for more help.
> 0 votes

# Answer
I recommend converting your select list field to Taxonomy and use a module like Similar By Terms.

> This Drupal module attempts to provide context for content items by displaying a block with links to other similar content. Similarity is based on the taxonomy terms assigned to content. Blocks are available based on similarity within each of the defined vocabularies for a site as well as a block for similarity within all vocabularies.
> 0 votes

---
Tags: nodes, views
---


title: How to set and retrieve cookies?

text:
# Question
Title: How to set and retrieve cookies?
After several days and more hours I only found issues and patches about what to do once a cookie is set, but not one is mentioning how you get a cookie set in the first place.

Our intention would be to set a (session) cookie of the landing page (for ALL user roles) and retrieve that cookie on certain pages, through views, to use in the URL of an outbound link. This would be very simple in standard programming (even I understand) but I am starting to have considerable doubt if this is actually possible in Drupal.

# Answer
> 5 votes
Drupal already sets a session cookie when a user logs in: see the function drupal\_session\_regenerate().

Can you use this session Id for your purposes? If not, then you just need to create a new value in the cookie the same way that you will do in PHP, `$_COOKIE['my_value'];`. Place this code in the `hook_init()` of a custom module, adding a `if()` to filter the landing page.

Later, you retrieve it and use it in your view; you can use some of the hooks of Views depending on your needs. You can also use the module Views custom field, and embed your PHP code there.

# Answer
> 2 votes
You can set a cookie with: `setcookie('cookiename',$valueOfCookie);`

You can retrieve the cookie value with: `$_COOKIE['cookiename']`

---
Tags: 7, sessions
---


# Question
Title: How to reverse the sort order of the data shown on the X-axis of my chart?
My question is about Charts sorting. Newest entries (assume they are days within a month) are on the left, as shown in this chart:

But I want those newest entries to be on the right side, so I need to reverse the order.

Is there a way to do this?

# Answer
I'm assuming you're using the Charts module. In that case, refer to Steps to create charts using the views UI, especially the "Bonus tip" in it, which states:

> You may find it easier to start with a "Table" display and convert it to a chart display after setting up the data. It can be easier to visualize what the result of the chart will be if it's been laid out in a table first.

In this specific case: after you succeed in creating a view that is a table display (with the correct sorting), it should be straight forward to also do so for the Charts-display.

With only the limited details provided, it appears that you should **sort the data to be sorted using the field that you also used to create the X-axis of the chart** (whereas this sorting should be "ascending").
> 2 votes

---
Tags: 7, views, charts
---


# Question
Title: Why are the CSS files in my .info not applied (scripts work fine)?
I have a list of CSS files from a premade theme called artifical reason

they are listed in my .info file as such

```
stylesheets[all][] = assets/css/style.css
stylesheets[all][] = assets/css/preload.css
stylesheets[all][] = assets/css/style-aqua.css
stylesheets[all][] = assets/css/style-blue.css
stylesheets[all][] = assets/css/style-blue2.css

```

..... Et Cetera for all the files in the assets/css/ folder

I also have scripts listed in the info file

```
scripts[] = assets/js/app.js
scripts[] = assets/js/carousels.js
scripts[] = assets/js/coming.js
scripts[] = assets/js/coming2.js
scripts[] = assets/js/commerce.js

```

et cetera

I have the style and script variables in my html.tpl.php

```
<?php print $styles; ?>
<?php print $scripts; ?>

```

However, when I go to my site the styles are not applied and there is no reference to them in the HTML. There IS however reference to all the scripts as seen below

```
<script src="http://WEBSITENAME/sites/all/themes/SITEDIREC/assets/js/app.js?nqtizi">

```

I get a couple style sheets being pulled from modules, but most of the CSS left is pulled from this

```
<link media="all" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" rel="stylesheet" type="text/css">

```

Does anyone have ideas on why this is not working? I am fairly new to Drupal, so I'm proobably overlooking something fairly major.

I should have mentioned it before: I have cleared cache many times, and turned the CSS/JS aggregation on and off to see if it would work with no success.

Here are the errors i get when i launch the site

```
[Thu Jul 02 08:34:40.847061 2015] [fcgid:warn] [pid 3816:tid 416]        mod_fcgid: process 5448 graceful kill fail, sending SIGKILL
[Thu Jul 02 08:34:46.941527 2015] [fcgid:warn] [pid 3816:tid 416] mod_fcgid: process 7124 graceful kill fail, sending SIGKILL
[Thu Jul 02 08:34:50.401630 2015] [fcgid:warn] [pid 3816:tid 416] mod_fcgid: process 2324 graceful kill fail, sending SIGKILL

```

Here is the FULL info file

```
name = ART REASON sub-theme
description = based on artifical reason
core = 7.x
base theme = bootstrap

 ;;;;;;;;;;;;;;;;;;;;;
 ;; Regions
 ;;;;;;;;;;;;;;;;;;;;;

 regions[navigation]     = 'Navigation'
 regions[header]         = 'Top Bar'
 regions[highlighted]    = 'Highlighted'
 regions[help]           = 'Help'
 regions[content]        = 'Content'
 regions[sidebar_first]  = 'Primary'
 regions[sidebar_second] = 'Secondary'
 regions[footer]         = 'Footer'
 regions[page_top]       = 'Page top'
 regions[page_bottom]    = 'Page bottom'
 regions[social]            = 'Social'

 ;;;;;;;;;;;;;;;;;;;;;
 ;; Stylesheets
 ;;;;;;;;;;;;;;;;;;;;;

 stylesheets[all][] = assets/css/style.css
 stylesheets[all][] = assets/css/preload.css
 stylesheets[all][] = assets/css/style-aqua.css
 stylesheets[all][] = assets/css/style-blue.css
stylesheets[all][] = assets/css/style-blue2.css
stylesheets[all][] = assets/css/style-blue3.css
 stylesheets[all][] = assets/css/style-blue4.css
 stylesheets[all][] = assets/css/style-blue5.css
 stylesheets[all][] = assets/css/style-fuchsia.css
 stylesheets[all][] = assets/css/style-gray.css
stylesheets[all][] = assets/css/style-green.css
stylesheets[all][] = assets/css/style-green2.css
 stylesheets[all][] = assets/css/style-green3.css
 stylesheets[all][] = assets/css/style-green4.css
 stylesheets[all][] = assets/css/style-green5.css
 stylesheets[all][] = assets/css/style-orange.css
 stylesheets[all][] = assets/css/style-orange2.css
stylesheets[all][] = assets/css/style-orange3.css
 stylesheets[all][] = assets/css/style-pink.css
stylesheets[all][] = assets/css/style-red.css
 stylesheets[all][] = assets/css/style-red2.css
 stylesheets[all][] = assets/css/style-red3.css
 stylesheets[all][] = assets/css/style-violet.css
stylesheets[all][] = assets/css/style-violet2.css
 stylesheets[all][] = assets/css/style-violet3.css
stylesheets[all][] = assets/css/style-yellow.css
stylesheets[all][] = assets/css/style-yellow2.css
stylesheets[all][] = assets/css/vendors.css
stylesheets[all][] = assets/css/width-full.css
 stylesheets[all][] = assets/css/width-boxed.css
 stylesheets[all][] = assets/css/syntaxhighlighter/shCore.css
 stylesheets[all][] = assets/css/syntaxhighlighter/shCoreDefaulter.css
 stylesheets[all][] = assets/css/syntaxhighlighter/shCoreDjango.css
stylesheets[all][] = assets/css/syntaxhighlighter/shCoreEclipse.css
stylesheets[all][] = assets/css/syntaxhighlighter/shCoreEmacs.css
stylesheets[all][] = assets/css/syntaxhighlighter/shCoreFadeToGrey.css
 stylesheets[all][] = assets/css/syntaxhighlighter/shCoreMDUltra.css
stylesheets[all][] = assets/css/syntaxhighlighter/shCoreMidnight.css
stylesheets[all][] = assets/css/syntaxhighlighter/shCoreRDark.css
stylesheets[all][] = assets/css/syntaxhighlighter/shThemeDefault.css
stylesheets[all][] = assets/css/syntaxhighlighter/shThemeDjango.css
stylesheets[all][] = assets/css/syntaxhighlighter/shThemeEclipse.css
stylesheets[all][] = assets/css/syntaxhighlighter/shThemeEmacs.css
stylesheets[all][] = assets/css/syntaxhighlighter/shThemeFadeToGrey.css
 stylesheets[all][] = assets/css/syntaxhighlighter/shThemeMDUltra.css
stylesheets[all][] = assets/css/syntaxhighlighter/shThemeMidnight.css
  stylesheets[all][] = assets/css/syntaxhighlighter/shThemeRDark.css

;;;;;;;;;;;;;;;;;;;;;;
;; JS
;;;;;;;;;;;;;;;;;;;;;;

scripts[] = assets/js/app.js
scripts[] = assets/js/carousels.js
scripts[] = assets/js/coming.js
scripts[] = assets/js/coming2.js
scripts[] = assets/js/commerce.js
scripts[] = assets/js/e-commerce_product.js
scripts[] = assets/js/home_full.js
scripts[] = assets/js/home_inverse_navbar.js
 scripts[] = assets/js/home_login_full.js
scripts[] = assets/js/home_plain.js
scripts[] = assets/js/home_product.js
scripts[] = assets/js/home_profile.js
scripts[] = assets/js/home_services.js
scripts[] = assets/js/html5shiv.min.js
scripts[] = assets/js/index.js
scripts[] = assets/js/jquery.min.map
scripts[] = assets/js/lightbox.min.map
scripts[] = assets/js/page_charts.js
scripts[] = assets/js/portfolio.js
scripts[] = assets/js/respond.min.js
scripts[] = assets/js/slidebars.js
scripts[] = assets/js/styleswitcher.js
scripts[] = assets/js/vendors.js

 ; For information on choosing the desired method, please read the Drupal
 ; Bootstrap sub-theme "how-to" documentation:
; https://drupal.org/node/1978010

; ;----------------------------------
; ; METHOD 1: Bootstrap Source Files
; ;----------------------------------
;
 ; ;;;;;;;;;;;;;;;;;;;;;
; ;; Scripts
 ; ;;;;;;;;;;;;;;;;;;;;;
;
; scripts[] = 'bootstrap/js/affix.js'
; scripts[] = 'bootstrap/js/alert.js'
; scripts[] = 'bootstrap/js/button.js'
 ; scripts[] = 'bootstrap/js/carousel.js'
; scripts[] = 'bootstrap/js/collapse.js'
; scripts[] = 'bootstrap/js/dropdown.js'
; scripts[] = 'bootstrap/js/modal.js'
; scripts[] = 'bootstrap/js/tooltip.js'
; scripts[] = 'bootstrap/js/popover.js'
; scripts[] = 'bootstrap/js/scrollspy.js'
; scripts[] = 'bootstrap/js/tab.js'
; scripts[] = 'bootstrap/js/transition.js'

```

SOLVED: Such a simple problem for how much work I put into trying to solve it. I did not have the correct filepath specified on the .info file, because I thought, incorrectly, that the filepath was relative to the template instead of the .info file. so i had to go templates/assets/css instead of assets/css. I had tried this solution before, but I guess I forgot to clear my cache first. Thanks for the help

-Matt

# Answer
> 1 votes
SOLVED: Such a simple problem for how much work I put into trying to solve it. I did not have the correct filepath specified on the .info file, because I thought, incorrectly, that the filepath was relative to the template instead of the .info file. so i had to go templates/assets/css instead of assets/css. I had tried this solution before, but I guess I forgot to clear my cache first when applying that fix. Thanks for the help

-Matt

# Answer
> 1 votes
Consider checking the various answers to the question about Can't disable css caching and aggregation ... it includes some hints that may help in your case also, such as:

* Try clearing the cache?
* CSS / JS aggregation turned on?
* Any caching mechanisms (like Varnish) installed on the server?
* Could it be a module or a theme that hard coded the CSS caching?

Since none of these are mentioned in your question, I thought it's worth pointing to them ...

---
Tags: javascript, theming, .info
---


# Question
Title: How to display comment status with radio buttons?
How can I display the comment status (open and close) with radio buttons in the comment submit page? I want it be selectable during comment submission by the user.

---

Actually, I have a content type which has an comment field with two radio buttons:

1. Satisfied
2. Unsatisfied

My goal is that, when users select the "Satisfied" button, the comment will be closed automatically; when the "Unsatisfied" button is selected, the users are able to send the next comment.

# Answer
I think you have to use rate module for your comment, then use Rules module to close the comment on specific node.
> 1 votes

---
Tags: views, nodes
---


# Question
Title: Image field upload shows a broken preview until I reload the page
When I upload an image it does an AJAX upload and then tries to show the thumbnail but the thumbnail style of that image is not available, so it shows up as a missing image. If I save and come back to the form, then it displays fine.

# Answer
make sure the "image style" of your image field exists. for example to make sure about our "Article" content type, we check the path below:

> http://yoursite.com/admin/structure/types/manage/article/fields/field\_image

find your "image style" name and then go the path below:

> http://yoursite.com/admin/config/media/image-styles

check the image styles name and make sure "Article" image style is here. if it's not, you have to change image style of your content type.
> 1 votes

---
Tags: 7, media
---


# Question
Title: How to increase the value of the field nid in the node table in database?
I'm using Feeds to import nodes from another system. This system uses very long number for its node id, like: **17675272378**. As you can see this number has 11 digits. The problem is that Drupal only allows a nid value up to 10 digits, then the import just fails.

I thought of changing the **length** value for **nid** for the **node** table directly in the database. But it is not that simple there are a **lot** of other tables which has this field like: the **entity\_id** field for the **field\_data\_body** table.

Maybe I can get to change the values in the database if I export the table and then find and replace the value '10' for '15' and then after I replace the database which the new one. But my question is: will I get other problems if I do this?

How can I sort this out?

Here are my captures:

# Answer
> 3 votes
Forcing the import to use the ID of the other system will break the sequential nature of the drupal nid. You should add a textfield on the receiving site to hold the old site id and let drupal assign new ones.

# Answer
> 2 votes
You must alter your table to change your data type from `INT` to `BIGINT` because your number `17675272378` is not suported by the `INT` data type:

```
ALTER TABLE `node` CHANGE `nid` `nid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `field_data_body` CHANGE `entity_id` `entity_id` BIGINT UNSIGNED NOT NULL;

```

> INT - A normal-sized integer that can be signed or unsigned. If signed, the allowable range is from -2147483648 to 2147483647. If unsigned, the allowable range is from 0 to 4294967295. You can specify a width of up to 11 digits.
>
> BIGINT - A large integer that can be signed or unsigned. If signed, the allowable range is from -9223372036854775808 to 9223372036854775807. If unsigned, the allowable range is from 0 to 18446744073709551615. You can specify a width of up to 20 digits.

For more details, refer to MySQL Data Types.

---
Tags: nodes, database
---


# Question
Title: How to get the Drush output of "drush l10n-update" from the command line with PHP in Linux?
I am trying to print from PHP the list of my updated translations, I know that I can obtain this info using `drush l10n-update` (I have installed the l10n-update module) from the command line but I want put this command a php script, I try to obtain the info with following codes but I can't see anything:

```
//this works and I can see my enabled modules
echo passthru('drush pm-list | grep "Enabled"', $o);
// I can't see anything with this
echo passthru('drush l10n-update', $o);

//this works and I can see my enabled modules
echo exec('drush pm-list | grep "Enabled"', $o);
// I can't see anything with this
echo exec('drush l10n-update', $o);

//this works and I can see my enabled modules
echo system('drush pm-list | grep "Enabled"');
// I can't see anything with this
echo system('drush l10n-update');

```

Is there any way to achieve this?

I am using Drush 5.10.0 from the repo of Ubuntu

**Edit after** Pierre answer:

From the command line output of `drush l10n-update-status` :

```
 Project                               Español status
 auto_nodetitle 7.x-1.0                Actualizado
 drupal 7.28                           Actualización local disponible
 serial 7.x-1.3                        Actualizado
 taxonomy_container 7.x-1.1            Actualización local disponible
 taxonomy_manager 7.x-1.0              Actualizado

```

From the command line output of `drush l10n-update` :

```
Fetching update information for all projects / all languages.                                                                                [status]
Found 2 projects to update.                                                                                [status]
Actualizando traducción.                                                                                [status]
Descargando e importando archivos.                                                                                [status]
WD locale: Disallowed HTML detected. String not imported:                                                                                [warning]
WD locale: Disallowed HTML detected. String not imported: En UNIX, Linux, y Mac OS X, el archivo /etc/syslog.conf define la configuración de      [warning]
enrutamiento. Los mensajes pueden ser marcados con los códigos LOG_LOCAL0 hasta LOG_LOCAL7. Para más información sobre utilerías de Syslog,
niveles de severidad y cómo definir un archivo syslog.conf, consulte, la página del manual, de la linea de comando de syslog.conf.
WD locale: Disallowed HTML detected. String not imported: OpenID sugiere el uso de cualquiera de las  GMP matemáticas (recomendado para           [warning]
rendimiento) o  bibliotecas matemáticas BC para permitir asociaciones de OpenID.
WD locale: 3 disallowed HTML string(s) in sites/all/translations/drupal-7.28.es.po                                                                 [warning]
Imported: drupal-7.28.es.po.                                                                                [ok]
Imported: drupal-7.28.es.po.                                                                                [ok]
Imported: taxonomy_container-7.x-1.1.es.po.                                                                                [ok]
Imported: taxonomy_container-7.x-1.1.es.po.                                                                                [ok]
2 projects updated: drupal, taxonomy_container.                                                                                [status]
Spanish translation strings added: 10, updated: 0, deleted: 0.
3 translation strings were skipped because they contain disallowed HTML. See Mensajes recientes del registro for details.                          [warning]

```

As you can see the output is different, because the command `drush l10n-update` runs the batch process and import the translations.

So, I test in my php script this code:

```
exec('drush l10n-update-status', $output) . '<br>';

echo '<pre>';
print_r($output);
echo '</pre>';

```

And I can see the same output that come from the execution of `drush l10n-update-status` from the command line.

However with this code:

```
echo exec('drush l10n-update', $output);

echo '<pre>';
print_r($output);
echo '</pre>';

```

Nothing is printed just a empty array:

```
Array
(
)

```

# Answer
Keeping track of the various Drush version IDs is not obvious, especially when it's about "which version of Drush can be used with which version of Drupal".

But nevertheless, I think it's worth looking at "Rework drush l10n-update commands", especially Comment #9 in it, which says:

> ... There're two new commands. In summary they are:
>
> 1. **l10n-update-refresh**
> 2. **l10n-update-status** // prints a table
> 3. **l10n-update** // not limited to a number of imports as before but runs the batch process.
>
> Commands 2 and 3 accepts `--languages=es,fr,de`.
>
> l10n-update also accepts `--mode=keep|overwrite`.
>
> Those options are validated.

So if these commands are available in your version of Drush, I'd give it a try to use `l10n-update-status` instead of `l10n-update`. If they are not available, then maybe the patch in the comment #9 somehow helps to at least understand why it's not working yet (any maybe you can think of a way to backport it also).
> 2 votes

---
Tags: 7, drush
---


# Question
Title: How handle large number of images in gallery node Drupal 7
I have some gallery nodes with a large number of images (100+), the upload with Plupload integration module works fine, but after save the node and edit it again the node edit form loads 20+ seconds! How can I reduce the loading time of the form? Somebody have any suggestion for this problem? Lazy Loading of Fields possible? Pagination? Some Module?

Thanks

# Answer
> 0 votes
I do not know the intended site behaviour, or interface, for your galleries. However, I would restructure the site. Have you looked at each gallery "entry" being a node with 1 picture field and 1 taxonomy term reference? The terms would then be your "galleries", you could use views to build the pages any way you want, even lazy load. You could add sorting, and since you would not have 100+ field entries on any one entity, loading the entity into a variable for the various page build tasks would be far faster. Gallery nodes work fine if they have less than 30 entries, but it sounds like your data management could use some revision.

---
Tags: nodes, media, files
---


# Question
Title: Is it possible to prevent a View from executing until the user has chosen filters?
I have a rather complicated View (created with the Views module) with about a dozen filters on it, all exposed to the user. The View is very heavy on CPU, and I would like to prevent it from running until the user has applied his filter choices.

One suggestion for dealing with this is to make a filter "Required": then the exposed filter will be empty when the View is first run and as a result will force the user to apply filter values explicitly.

The problem is that the filters are almost all dropdown lists, so they get a value applied automatically and don't therefore stop the View from running. Does anyone know some other way to do this?

# Answer
> 1 votes
I'm assuming that for suggesting an answer to your "Does anyone know some other way to do this?", it's OK to also suggest another "module" (instead of just another "way") ...

The Forena module might possibly be a valid alternative for you to consider. For more info about this module, refer to either of these links:

In this specific case, you could consider transforming your "complicated View" into appropriate Forena data blocks (SQL queries) and custom reports (and/or charts ...). And for those reports to be generated (and the SQL queries to be executed), you could consider using the various Forena features related to "*Report Parameters*". A few more details about these Report Parameters:

---
Tags: views
---


# Question
Title: More multiple add to cart buttons drupal commerce
I want to be able to have multiple add to cart buttons on 1 page for example for selling music like this. Example!

# Answer
It appears that you're looking for something that is decribed in detail in Multiple products per Add To Cart form (product kits/packages) also.

And that issue is what was the inspiration for the Commerce Product Bundle module (available for D7, but only as an alfa version for now). Here is a excerpt from its project page:

> You can define products that consists of other products. They are all combined in one add to cart form. The form works like the core add to cart form with all the fancy selection and ajax magic. So the customers can make their selections as usual. The difference is, that the products from mulitple reference fields were presented on one add to cart form.
>
> The bundle is then represented by one order line item. This allows the maximum compatibility with other modules such as shipping or payment modules.
> 1 votes

# Answer
Thinking of showing view of related products on product page with add to cart button may make it simpler if not killing specific use case.
> -1 votes

---
Tags: 7, views, commerce
---


# Question
Title: Why does external js only appear in header? D7, in a block, via custom module
I'm trying to add a box.com file upload widget to certain pages in a block. The upload widget is an external js script. I'm adding it via a custom module, using hook\_block\_view,

```
switch ($delta) {
    case 'box_com_photo':
    $block['subject'] = t('Box File Uploads: Photography');
    $block['content'] = array(
        '#attached' => array(
        'js' => array(
            'scope' => 'content',
            'data' => 'https://app.box.com/embed/upload.js[custom widget code]',
            'type' => 'external',
          ),
        ),
      );
      break;

```

Regardless of the scope, it always shows up in the page header.

Suggestions??

# Answer
> 1 votes
Content isn't a valid region for scope, it can only be header or footer. See this documentation: https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal\_add\_js/7

The render process runs drupal\_add\_js/css based on items inside of #attached.

# Answer
> 1 votes
AdvAgg supports scripts in various regions. But the way you're trying to use is not supported (JS in a block).

In settings.php add this.

```
$conf['advagg_scripts_scope_anywhere'] = TRUE;

```

This allows for scripts to be put in any scope outside of the header and footer.

Anyway to answer you question I would put raw js with the script tags into the block.

```
switch ($delta) {
    case 'box_com_photo':
    $block['subject'] = t('Box File Uploads: Photography');
    $block['content'] = '<script src="https://app.box.com/embed/upload.js[custom widget code]" type="text/javascript"></script>';
      break;

```

I created a feature request for this, since we want something similar here at my work.

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


# Question
Title: "_blank" target attribute for links in views
I have a custom view that lists a specific content type. I have fields output for each node and have set them to "Link to: Content".

Simply, is there a way to now set the target to "\_blank"?

If you are "Rewriting Results" you have the option to specify the target attribute, however I am not rewriting the result (this requires a separate declaration of link path).

# Answer
> this requires a separate declaration of link path

If you are talking about node title it doesn't require a declaration of link path. Just leave this field empty and link will be made with default link path (e.g. node/NID).

For other fields you need to override link path. The easiest way is to add *nid* field and exclude it from display. Then you can use `node/[nid]` as link path. In this case you need not use link formatter in field settings.
> 1 votes

# Answer
I think more comfortable approach is the answer "target=\_blank for links in view"

1. By using Linked Field module (or one other) and the teaser display in View (Show:Content | Teaser)

2. By using and configuring fields in View module (not any content's display).
> 0 votes

---
Tags: views
---


# Question
Title: How to make "Announce on LinkedIn" on by default?
I am using Linkedin module.

I want "Announce on LinkedIn" turned on by default. I am using Feeds module for RSS. It automatically created Feed and Feed Item Content types. RSS content is automatically saved as new node. But that node is not posted in Linkedin. I have to edit the content and manually check "Announce on LinkedIn" to have it posted:

I want it posted automatically. How can I achieve that? Please anyone help to me. Thanks in advance

# Answer
The issue here is the LinkedIn post functionality is tied to the node form; the form is altered to add the form component & submission hook. However, Feeds isn't using this form so it will never get a chance to process the submission handler.

If you look at the submission handler you can pull out the relevant function, `linkedin_put_profile_field()`, to make this happen. Combine this with hook\_feeds\_after\_import(), and you can come up with an implementation that will trigger a LinkedIn post upon a feed import:

```
function MYMODULE_feeds_after_import(FeedsSource $source) {
  if(function_exists('linkedin_put_profile_field') && isset($source->feed_nid) && $node = node_load($source->feed_nid) {
    $status = variable_get('linkedin_default_format_'. $node->type, '');
    linkedin_put_profile_field($node->uid, 'current-status', $status);
  }
}

```

Note: there will probably need to be more checks & altercations here based on your needs (e.g. setting the right UID to post as, throttling posting so your feed importing doesn't get marked as spam on LinkedIn).
> 1 votes

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


title: Exposed filter with Load more

text:
# Question
Title: Exposed filter with Load more
I have 2 problems with drupal.org/project/views\_load\_more & exposed filter:

1. When I change the exposed filter selection, it only filters the result which is in first lot (e.g if I have given a limit of 8 and then change exposed filter selection it filters among those 8 results only).
2. I get duplicate records; if I remove the load more limit I get distinct records

Please help.

# Answer
To address the 2nd bullet of your question, consider using the Views Distinct module. From its project page:

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

---
Tags: views
---


# Question
Title: add a block of related products to any search result item
What I want is , when a user searches for a special product , for each single search result a block of similar products show up (containing products image and product title as images alt).

I do have a taxonomy vocabulary called usability with terms gaming , light weight and ... ,

so if a search result is of kind product , the block of related products should be seen under it

So my questions are :

1. how to alter search result view so I can place my block
2. how can I fetch data of an result item to pass it to view filter

# Answer
> 1 votes
you should be able to do with a combination of these:

Views Field View Module

> This module allows you to embed a view as a field in a view. A new field handler is made available, so this can also be used in area (header/footer/empty) handlers as well as rows.
>
> This view handler can accept arguments from fields of the parent view using tokens and pass them into the child view for each row. Raw or rendered token values can be used, as well as static values.

and

Views Related Content Module

> Views Related Content is an extension to the Views module. It helps show the related contents, related nodes on the content detail page. This module makes it easy for you to work with contents, nodes by adding the filter criteria by Author, Content Type, Taxonomy Terms in the Views configuration.

Adding the related content view as a field in the primary view should show the results for each row. Exactly how to integrate them depends on your set up.

---
Tags: search, views
---


title: Drupal modules to help with user story

text:
# Question
Title: Drupal modules to help with user story
Hey my team is planning on moving our current project to Drupal and we're looking for what modules would help with our current functionalities. Here's a user story for more insight:

"User 1 has an inventory of items. Each item has a certain number of "points" attached to it. User 2 desires an item from User 1's inventory and has the appropriate amount of points to give User 1 for the item. An transaction occurs in which the desired item from User 1's inventory is sold to User 2 and the corresponding amount of points for the item are deducted from User 2's total points and added to User 1's point total."

I'm thinking we might have to end up adding our own custom code but if anyone knows of a Drupal module or anything that would make things easier, that would be greatly appreciated.

# Answer
> 1 votes
While custom code seems to be good option to achieve the transaction of item ownership, User Points module may help in transaction of items.

In custom way I would have created item as content type with user reference field for item ownership, I would have turned on revision on item content type so to get detailed report of transfer of ownership and on every transaction of item would have updated the ownership field with new owner, maintaining the revisions. User Points module provides handy api's custom integration and it also provides rules integration which looks more robust system to expand user points in future also.

---
Tags: 7, users
---


# Question
Title: ubercart: finding order id when admin is editing order
I have a custom shipping quote module which adds freight costs to the orders admin comments:

```
$order_id = intval($_SESSION['cart_order']);
uc_order_comment_save($order_id, 0, t($shippingquote_text), 'admin');

```

This works correctly when the user goes through the checkout process.

**Problem:** How do i find the order id when the admin is manually editing a users order?

For example: admin is on **admin/store/orders/3845/edit** and clicks get shipping quote button - which fires freight quote module

**Want:** comment is saved to order 3845 w shipping quote details.

My answer below is valid for Ubercart 7.36 as the page doesn't use Ajax.
**UberCart 7.38 Uses Ajax, and the same variable isn't available. Still looking for an answer**

# Answer
I found the answer after posting the question: (Valid for Ubercart 7.36)

```
if (in_array('administrator', $user->roles)) {
dpm (" do fancy stuff");
dpm($_SESSION['ucga_order_id']);

$order_id = $_SESSION['ucga_order_id'];
 uc_order_comment_save($order_id, 0, t($admin_text), 'admin');

dpm ("end admin fancy");

}

```
> 1 votes

---
Tags: ubercart
---


# Question
Title: How to get main menu to highlight the link to the current page?
My theme, Riley, highlights menu item of the page that you're on. (for example). I suspect this is a function of Drupal and not specific to the theme. First question: is this generally true?

If the answer to the first question is no and it is theme specific, then I can try to ask the theme makers the next question. Otherwise, my next question is, when I have multiple menu links that link to the current page, it will highlight the last link. How can I get it to highlight the first link instead? I am comfortable modifying PHP code.

For example, Menu Tab 1 contains link to current page P1 and deep within Menu Tab 2 also contains a link to P1, then it will only highlight the P1 link in Menu Tab 2.

Any thoughts / suggestions would be appreciated!

Setup: Apache 2.2, PHP 5.3, Drupal 7.34, PostgreSQL 9.2

# Answer
normally this is accomplished via css in the theme, with the active attribute:

```
li a.ctive {
  ...
}

```

it is not core functionality. You could look at the different -child pseudo-elements to tweak it, or use some JS, but I think that portion of the question would be off-topic here - you are better off asking on stackoverflow
> 1 votes

---
Tags: routes
---


# Question
Title: Using one view for multiple Content Types
So I have four content types in each there is a field called offer, I intend to make a view to display all nodes of those four content types with offer value equal yes.

I have tried the following: I have made a view of the four content type and add the four fields as filters and make a new filter group but I can not separate content types so that I can group each content type with its field.

Is my approach right? What do I need to do?

Thanks in advance!

# Answer
> 2 votes
If you are using the same field for all content types and want to display them all on the same view and grouped by content type. Here is the step by step.

1. Create a view for all content type in **Unformatted list** or **table**.
2. In **Filter Criteria**: Add the "**Content: Type**" and check the content types you wish to display
3. In **Filter Criteria**: Add the "**Offer**" is equal to "**Yes**"
4. In **Fields**: Add any field you wish to display, and add "**Content: Type**" set that **exclude from display**
5. In **Format** *Settings*: Set "**Grouping field**" by "**Content: Type**"

This way, The view will list all those node content type with Offer equal to yes, and grouped by content type.

# Answer
> 1 votes
You need to add your `offer` field in single content type and add that existing field in all other three content types.

Then you may have different fields in every content types. So you may have to use display different format style for each content type. So for this add your custom format style in views. In screenshot I have given the example of teaser.

The you need to customise the format style. Go to Admin \> Structure \> Content Types \> Your Content Type \> Manage Display \> Your Format.

# Answer
> 0 votes
You should create a view, as you have done, to display all nodes where offer == yes.

Next you want to look under Format and click settings (the gear icon) next to 'Format'. The first field will allow you to select the grouping field. Try that.

# Answer
> 0 votes
Try the "Grouping field" select box, it does a visual group based on a field. Look for it the 'settings' for the display's format(1st column, 'format' heading). You'll probably want to add a "Content: Type" field to group by.

---
Tags: nodes, views
---


# Question
Title: My local site directs to install.php after update from production site af drush sync
Just set up drush for a site, database and site root set up in MAMP. I've updated the local directory using these drush commands:

```
drush rsync @alias.production @alias.local
drush sql-sync @alias.production @alias.local

```

The terminal doesn't display any errors and I can see in my local phpmyadmin + in the site folder that both files and database entries are synced. Still the local URL directs me to /install.php (also after running `drush cc all`)

I've done this several times before without difficulties. Any ideas how I should debug this behaviour to find my error?

# Answer
> 0 votes
Settings.php was there, but thanks to @Peter's answer I took a look at it and discovered that the `$databases = array();` sequence on line 213 wasn't followed by my database login info for some reason. I edited line 213 to the following and it works again:

```
    $databases = array(
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'mydatabasename',
      'username' => 'myusername',
      'password' => 'mypassword.',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

```

# Answer
> 1 votes
Is settings.php there? It is not synced by default with drush rsync.

The redirect to the install page also indicates that you are missing settings.php.

# Answer
> 0 votes
This problem can also be caused by incorrect permissions or ownership on the files copied by rsync. You might want to do this in your docroot after running `drush rsync`:

```
sudo chown www-data:www-data -R /path/to/www/*
sudo chmod u+r -R /path/to/www/*
sudo chmod u+rw -R /path/to/www/drupal/files/directory

```

... assuming that www-data is your web server user (default under Apache2 on Debian)

---
Tags: installation, drush
---


title: Display popup message on submit button

text:
# Question
Title: Display popup message on submit button
For my contact form using form api and for my Drupal 7 built in user registration form, I need to display messages in a popup window.

> E.g: when user clicks on submit button on a contact form the `Thank you message` should display in a popup.

I have installed Popup Message module but unable to figure out how can I configure to set messages for my different forms.

# Answer
> 1 votes
You may use Better Messages module

> Better Messages is a very simple module that provides "Popup-like" Drupal messages.

Or

Purr Messages

> Do you want a more interestingly themed system message from Drupal? Enjoy Growl messages on OS X? Then this module is for you.

Or

Nice messages

> The Nice messages popup module changes how Drupals status, warning and error messages are showing up by giving flexible stylable nice looking fading little jQuery-popups like on Social networks at hand, provided by the small and fast jQuery jGrowl plugin. It can be activated globally or partially for certain pages / users and prevents the typical cluttering caused by error messages getting in the way by moving the grid and layout of a website up and down.

---
Tags: 7, javascript
---


title: Restrict block visibilty based on menu

text:
# Question
Title: Restrict block visibilty based on menu
I want to display a block only on a particular menu-link.

For example I have a main menu link name: *about us* and the link: */about*

If I restrict the block based on pages and give link as */about* , In future the client may change the menu link as */about-us*.

So instead of restricting it based on pages, is there any other module which restrict block visibility based on menu's or How can I custom code it?

# Answer
I created a contrib module Blocks per menu that you could use for this purpose.

```
Blocks per menu extends the block visibility interface in Drupal 7 and
allows the user to control block visibility based on the menu links.

```

The module page also states:

* when the module is enabled, a new vertical tab is added to the block configure admin settings as shown in the snapshot.
* If only a parent menu is selected and no child menu item is selected, then the restriction is applied to all the child menu links.
> 1 votes

# Answer
```
if (arg(0) == 'node' && is_numeric(arg(1))) {
  $active_trail = menu_get_active_trail();
  end($active_trail);
  $nid = 1; // change to nid of parent node you want to check
  if ($active_trail[1] && $active_trail[1]['link_path'] == 'node/'.$nid) {
    return true;
  } else {
    return false;
  }
}

```

You can use the above code to achieve it in Drupal 7.
> 1 votes

# Answer
Use the Context module for what you're wanting. Add a new context (**Structure \> Context \> Add**), select a *Menu* condition with the menu item on which you want the block to appear, then select a *Block* Reaction with the selected block you want displayed and the region to display it in.
> 0 votes

---
Tags: 7, blocks
---


# Question
Title: How to add custom settings / attributes to a field
I want to be able to add custom settings / attirbutes to field instances.

I can create a custom field with custom settings no probs, but is it possible to get rid of the custom field and just add the settings so that the settings are stored per instance?

For example:

I create a content type, let's call it *vehicle*. I add a field called *wheels* which is a basic textfield where you can specify the number of wheels. Now I would like to add a few settings to the *wheels* field such as brand, model, etc. These settings would be specific to the content type but if you re-used the field wheels on another content type the settings could have different values... now this is a bit contrived but you get the idea!

Any ideas on how this could be achieved? My current solution is to create a separate field called something like Wheels meta information with the settings but I would rather a cleaner solution.

# Answer
Ok, this is done with third party settings in hook form alter:

```
function my_module_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  $entity = $form_state->getFormObject()->getEntity();

  $form['third_party_settings']['my_module']['my_field_setting'] = array(
    '#type' => 'textfield',
    '#title' => t('My custom field setting'),
    '#default_value' => $entity->getThirdPartySetting('my_module', 'my_field_setting'),
  );
}

```

...and that's it. So awesome.
> 2 votes

# Answer
You can use field collection module and create group of fields to add attributes like as you mentioned in your example and reuse it for other content types as well with different values.

Hope this will help you.
> 0 votes

---
Tags: 8, entities
---


# Question
Title: Conflict between Omega and Views 3 exposed sort (Ajaxified)
I have made a subtheme out of the Omega 4 with the responsive structure. I tried to use exposed sort for views inside the layouts of the subtheme.

The exposed sorts are not working under the activation of AJAX inside the views, but the exposed filters are working.

Any recommendations?!

# Answer
I found the solution, it seems to be a database problem for Drupal, and nothing to do with Theme or Views!

---

> Just remove that specific view from the layout inside your Panel/Page design in Pages section, and add it another time.

---

It will update the Drupal database and everything starts to work!
> 1 votes

# Answer
* This Issue may come from **Omega's responsive grid** Try Deactivating it.
* Check this Link which replicates your question
> 0 votes

# Answer
Replace your Views theme file with the original, that you get from Views.

For me; copying `views-view.tpl`, to my custom theme (e.g. `views-view--locations--contact-us.tpl`) helped to solve the issue.
> 0 votes

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