# Question
Title: Using "Model Entities" Module to Create Custom Entities
Model Entities: http://drupal.org/project/model

I've been trying to use this contrib module to create my own entity (the "client" entity). Steps I've undertaken:

1. Search and replaced "model" with "client", "Model" with "Client".
2. Upon enabling the module, the "client type" appears in "admin/structure", and I create a "client type" from the UI.
3. Go to "admin/content/clients" and added a new client, but the new "client" entity does not appear.

So far debugging has gotten me this far:

1. The database is being populated correctly - so the creating functions (and rest of CRUD - tested via direct calling) is working.
2. I checked entity\_load('client') and it's loading the client entities properly as well.

So I suspected it's something to do with the custom "views" that the module is implementing. And indeed, it did not register the custom view properly since it did not appear in "admin/structure/views".

I can't seem to pin-point the error here. Any idea why the view isn't registering?

# Answer
> 2 votes
I know this question is a little old, but just in case you (or others) still need assistance... Make sure the **hook\_views\_default\_views()** was renamed properly. If your module name is "client" then it should be client\_views\_default\_views().

I was recently working with the Model Entities module and ran into the same issue. Turns out I missed renaming that function.

If it's named correctly, then I suggest comparing your file to the model.views.inc file to find the difference.

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


# Question
Title: How to change form_set_error() message in captcha module
I need to reset the default error message in the captcha module when you enter the wrong answer.

captcha.module line 616

```
form_set_error('captcha_response', t('The answer you entered for the CAPTCHA was not correct.'));

```

I'm not quite sure where this needs to be done. Preprocess function?

Thanks, Josh

# Answer
> 2 votes
Check out String Overrides module. It allows you to override any translatable string (anything that uses `t()`) and is very convenient for overriding some text that is shipped with other modules.

If you want to do it without installing new modules - uncomment and edit this in the `settings.php` file (line ~458):

```
# $conf['locale_custom_strings_en'][''] = array(
#   'forum'      => 'Discussion board',
#   '@count min' => '@count minutes',
# );

```

---
Tags: captcha
---


title: Jump to navigation link

text:
# Question
Title: Jump to navigation link
I would like to add a "Jump to navigation link" to the Utility menu at the top.

Setting the path to "#main-content" doesn't seem to work.

The path '' is either invalid or you do not have access to it.

If I view the source of my page the anchor is there:

Jump to navigation

Why can't I link to #main-content?

# Answer
You would need to use the Menu token module in order to get the path to the current page as you first need a valid path, and then add your anchor to the path.

The tokenized path for the menu item should be something like:

```
[current-page:url:path]#footer

```
> 0 votes

---
Tags: routes, 7
---


# Question
Title: How to add Title attribute to Menu links?
Is it possible to add Title attribute to Menu items? If so, how?

# Answer
Just enter text in the description field and it will be rendered as the link title.
> 8 votes

---
Tags: routes, navigation
---


# Question
Title: DS link to content - how to change the link?
I am using D7. I want to do simple thing with Views and DS: I have view with list of content type teasers and another view with list of the same content type full articles. In DS there is an option to link teaser's Title to it's content, so when pressed user can get the full content of that content type. But I want all teaser titles to link to the same page - to the View with all content types listed.

Do I have to alter any tpl for this, or is there any other way to do this? Maybe it will sound silly, but I really don't get it, so please help me :)

thank you! Ben

# Answer
Maybe display suite extras can help you achieve this with a combination of tokens.

1. After you enable the Display Suite Extras you could go to admin/structure/ds/fields and create a new code field.
2. Label your code field and tell you will be using tokens.

3 In manage Display of your content type disable the title and enable your new field that it was created by Display Suite Extras.

This tutorial helped me in doing something similar that you are trying to do. Customize ULR/link display suite and tokens . I hope it helps :)
> 1 votes

---
Tags: views, display-suite
---


# Question
Title: Find current layout name for a Panels Node?
I'm using Panel Nodes for a layout, one of which is a specialized layout that will change the overall theme design (Namely hiding the header and footer).

However, I cannot seem to find a way to detect what the current layout being used is -- at least with Panel Nodes (panels\_page\_get\_current() works only with Panels Pages, not Panels Nodes). See: http://groups.drupal.org/node/12565

**Anyone have a clue how to detect whether a specific layout is being used by Panels -- and then, preferably, pass that on to theme suggestions?**

Thanks!

# Answer
The function panels\_get\_current\_page\_display() is what you're looking for:

```
$panel = panels_get_current_page_display();
$layout = $panel->layout;

```
> 4 votes

# Answer
This is one possible idea suggested by a co-worker. It's not very elegant, but it works.

That said, there *has* to be a better way of doing this. Leaving question open in case anyone has a better solution.

```
function sitedesign_preprocess_html(&$variables) {

/**
 *  This outputs the markup for the node as one big string and searches for the existence
 *  of a unique class specified in the Panel layout settings.
 *
 */
$var_txt = (string) print_r($variables['page']['content']['system_main']['node'], true);

  if (strpos($var_txt, 'panels-flexible-content_page_main_middle')!==false) {
    $variables['classes_array'][] = 'panels-flexible-content_page_main_middle';
  }

}

```

**Worth noting:** This does *NOT* work with Panelizer!
> 0 votes

---
Tags: 7, nodes, theming, panels
---


# Question
Title: Images not displaying on site (or in view source) after uploading them with ckeditor
I've manually added the filtered Html option because it wasn't there with my drupal 7 installation. In the editor view I get the upload image option etc, and I am able to browse and insert images. However, after hitting save, the images aren't displayed on the site.

I am using IMCE file uploader.

What am I doing wrong?

# Answer
The text format needs to allow `<img>` tags, otherwise they will be stripped out by default.

For example, add `<img>` to the allowed tags here:

`admin/config/content/formats/filtered_html` \> "*Limit allowed HTML tags*"

Alternatively, try the "*Full HTML*" text format, if available and applicable as it will allow images by default.
> 2 votes

---
Tags: wysiwyg, files
---


# Question
Title: Custom node template with related node teasers
I have a custom node (article) template file working fine, and I want to show related nodes (events) in their teaser format. I have been doing this in my node--article.tpl.php file like this:

```
foreach ($field_related_event as $event_node){
    print render(node_view(node_load($event_node['nid']), 'teaser'));
}

```

I wanted to add a second teaser format for events (`teaser_fancy`) and downloaded "Entity view modes" thinking I would be able to do something like this:

```
foreach ($field_related_event as $event_node){
    print render(node_view(node_load($event_node['nid']), 'teaser_fancy'));
}

```

But now I read that node\_view can only use teaser and full, and it's probably not a good idea to render relationships in my template this way. What's the recommended way to go about this? Should I create an Events Fancy view and use views\_embed\_view instead?

# Answer
> 0 votes
A valid "view\_mode" should work with node\_view and that approach looks reasonable.

However, if it's proving problematic, you can also use Views with `views_embed_view`

e.g

```
print views_embed_view('viewname', 'display_id', $node->nid); // node id contextual filter

```

---
Tags: theming
---


# Question
Title: How to disable payment cart pane when discount brings total to $0
I am using the uc\_discounts\_alt module on a Drupal 6 / Ubercart 2 site to provide specific dollar amount discounts for specific products. The discounts bring the product price down to zero, and conditional actions check for that discount code and, if found, make the shipping cost $0 as well.

I enabled the Ubercart Free Payments Module to allow these free orders to check out, but the cart states that the credit card info is missing when I to proceed to the order confirmation page. Apparently the Free Payments Module is not working as expected.

Is there any way I can hide or otherwise disable the payment panel when a certain discount is being applied... or any other options that may give me the functionality I need? Unfortunately, I am in a bit of a time crunch as we have a big promotion starting tomorrow, and this issue was masked by another payment method.

Thanks!

# Answer
> 2 votes
I was able to fix the problem by modifying the "Free Order" payment method's Conditional Action. Free Order is the payment method associated with the Ubercart Free Payments Module and comes pre-loaded with a CA that checks the cart total to see if it is more than $0.01... if it is more than that, it negates that condition and does not allow the Free Order payment method in the cart.

I changed that CA to instead check whether the cart had the discount(s) in question. If the discount(s) was used, the cart pulls in the Free Order payment method, and it all works as expected.

---
Tags: ubercart
---


# Question
Title: Multiple aliases, context and menu items (Drupal 7)
I have a site with 2 sections of content, A and B. I have a node, 'Z' that needs to appear in each area. I also have a different menu for each area, e.g.

```
Section 'A'
link 1
link 2
link Z -> should show menu 'A'

Section 'B'
link 3
link 4
link Z -> should show menu 'B'

```

I am using context to load the correct menu block, depending on which section a user is viewing (each node is either in an Organic Group, or the Group has a taxonomy term identifying the section which is the ultimate source of the section).

How can I display the content in node Z and also show the correct menu?

I've tried Node Hierarchy and it doesn't appear to be able to do what I'm looking for (it's also left some menu entries I can't delete).

Update: taking a step back and looking fit aaa simple solution, I think that the patch here will allow me to append a simple query string to my URL and thus avoid having the appearance of duplicated content. Assuming of course that I can add the query string to the menu item.

# Answer
I was able to create an acceptable solution by adding a query string to my menu links and adding an additional test to my PHP conditions. Now I've got something like:

```
return $_SERVER["QUERY_STRING"] == 's=pt';

```

and I get the context I'm looking for. The actual implementation is a little more complicated (due to having taxonomy also defining context, but needing to override it when a query string is passed so as to avoid ending up displaying both menus) but that should give you the idea in case anyone else is looking to solve the same problem.

I'd like to see the patch in http://drupal.org/node/904416 make it's way into the official context release. For me, maintaining a custom PHP condition is much easier than remembering I need to patch a module every time I update it if it doesn't get in there.
> 1 votes

---
Tags: taxonomy-terms, routes, organic-groups, path-aliases, 7
---


# Question
Title: Is using Views overkill to display a single image above the footer of all pages on my site?
I would like to add a banner type image above the footer. I'd like it to be present on every page. Would adding a gallery, and then creating a block using Views be overkill for just a single image? Should I just include it as a block and then add the image via the ckeditor? Or should I add a content type and field specific for this block/image?

# Answer
> 6 votes
If you need a static image, just use a block. If you want a slideshow or something, Views is better.

Unless your site is going to get a huge amount of traffic, I wouldn't worry about the performance differences between these two options. The main concern is how much harder is it going to be for you to set up a view versus setting up a block.

I don't know why you would created a content type and field specific for the image. If you just want to stick a piece of content in the same place on every page, that is one of the things that the blocks system was designed to do.

# Answer
> 4 votes
If you want a static image above the footer on every page, and it doesn't need content management, consider adding the `<img>` HTML directly to `page.tpl.php` for a lightweight solution.

---
Tags: views, media
---


title: Image Styles and Effects

text:
# Question
Title: Image Styles and Effects
Once I've created different Effects under Image styles. How do I flip between them in the Manage Display/Manage Fields windows for the content type?

I can't figure it out.

Or am I just meant to create Different Image styles for each different effect I might like to use?

# Answer
The display formatter for an image on "Manage Display" allows you to select which image style to use.

The image style itself contains the relevant effect(s)
> 1 votes

---
Tags: media
---


title: set maximum length to image title

text:
# Question
Title: set maximum length to image title
I'm trying to figure out how I can limit the maximum length of an image title to 40. I have enabled title from the image field in my content and it works fine except that it seems to take unlimited number of letters. I want to reduce the maximum length of image title to 40.
Does anyone have any idea how to do it?
Thanks

# Answer
Something like this may work:

```
/**
 * Implements hook_field_widget_form_alter
 */
function mymodule_field_widget_form_alter(&$element, &$form_state, $context) {
  if ($context['field']['type'] == 'image' && $context['instance']['widget']['type'] == 'image_image' && !empty($context['instance']['settings']['title_field'])) {
    foreach (element_children($element) as $delta) {
      $element[$delta]['#process'][] = 'mymodule_image_field_widget_process';
    }
  }
}

/**
 * Image field process callback
 */
function mymodule_image_field_widget_process($element, &$form_state, $form) {
  // Set title maxlength, if accessible
  $maxlength = variable_get('imagefield_maxlength', 40);
  if ($element['title']['#access']) {
    $element['title']['#maxlength'] = $maxlength;
  }

  return $element;
}

```
> 2 votes

---
Tags: entities, media
---


title: Menu token module is causing errors

text:
# Question
Title: Menu token module is causing errors
When creating one of the menu items I accidentally left the "Use tokens in title and in path." option checked while setting the path to .

It is now causing the following error on every page:

Notice: Undefined index: path in menu\_token\_translated\_menu\_link\_alter() (line 160 of /home/mysite/public\_html/sites/all/modules/menu\_token/menu\_token.module).

I am now trying to delete this menu item and create a new one in its place but I am unable to delte it. It times out. I was able to disable but it is not preventing the error message from displaying. How would I go about deleting this menu item?

# Answer
> 1 votes
Disabling the Menu Token module, then deleting the corrupted link, and re-enabling the module did the trick.

Thanks.

# Answer
> 0 votes
If you can run:

```
variable_set('menu_token_enabled', array());

```

Then that will disable menu\_token support for all menu items.

You could then reconfigure those items.

---
Tags: 7
---


# Question
Title: Can't find the "Create prev/next controls" option
I created a slideshow using the Field slideshow module. However, I can't find the Create prev/next controls. Any tips on where they are located?

Oh, and I can't see the "Slideshow" option under Format in the Manage Display window for the newly created content type of Slideshow...

# Answer
You can find it in the **manage display** tab of desired content type.

Choose the format to Slideshow.

Here is a Great Tutotrial
> 0 votes

---
Tags: javascript
---


# Question
Title: Module that provides Rules action to create node?
Is an Action to create a node available in any module? I tried searching but couldn't find it. I was hoping something as basic as a node create action would be available.

# Answer
In Rules 2.x on Drupal 7, there is a "Create entity" action built-in to the Rules module itself. You can use this action to create a node (Content), which is one type of entity.
> 4 votes

---
Tags: nodes, rules, actions
---


# Question
Title: Passing node id as contextual filter to field collection view
I'm trying to create a view of flagged field collections, filtered by the currently viewed node. I don't seem to be able to add either a relationship nor contextual filter to limit the field collections to those belonging to a single node.

Has anyone managed to do something similar?

# Answer
> 12 votes
Please try the following.

1. Add a relationship "Field collection item: Entity with the `{Field Collection name (field_collection_machine_name)}`" You should change the one in {} with your filed.
2. Now you should get the content nid in the contextual filter which could be used to filter using the node id.
3. To limit it to show only the flagged fields you should select the "Flags: Field collection item flag" from the relationships and select the flag you want to filter it by and select if it should be for the current user or all users

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


# Question
Title: How to troubleshoot edit node page timeout errors?
When I try to update the body of a basic page, Drupal 7 times out after I press the "Save" button and wait for a while. Surprisingly, I can successfully update my other pages through Drupal forms.

I cleared all caches but that didn't help.

I tried to update the content by editing the database directly, but, my changes to the database tables "field\_data\_body" and "field\_revision\_body" didn't affect my web page.

How I can troubleshoot the timeout error when I try to update the contents of a basic page in Drupal 7?

# Answer
> 0 votes
I'd guess that a module is performing some task in either form processing or Node API Hooks. It *might* be communicating with a remote service, or simply taking a long time to perform some action. It might also just be that the DB communication is slow. If such an action takes too long, you'll hit the PHP timeout and the script will terminate.

You could identify which module by several means -

* Debugging (eg add debug code with times to `module_invoke_all()` to see which hooks take a long time)
* Understanding the purpose of your modules (*I wonder if "Submit To Myspace" module is slowing things down?*)
* Process of elimination (turn off likely candidates until the problem goes away, turn them back on one by one until it recurs)

Note that the last approach is *not* the most dependable; if you have a 180s timeout, and module A takes 160s, module B takes 15s, and the rest of Drupal takes 6s, you could easily be mistaken in seeing the issue go away when you disable module B, despite A being the guilty party.

If the issue affects a single page, then sit back and study what might make that specific page different. Eg LinkChecker module (if installed) tries to retrieve linked images or URLs; and if those sites timed out, your node edit might also.

---
Tags: nodes
---


# Question
Title: Ubercart : How to display product information ( of certain brand ) as XML?
Can the Ubercart module display product information of certain brand as XML ?

I have looked into Ubercart module settings, but I can't find anything useful.

# Answer
> 1 votes
Find the steps to create XML for certain product:

* Enable the catalog module
* add Brand as a term
* Create products and assign it to certain brand
* uc\_catalog view is available for to show the listed product in certain brands
* make that view as RSS feed using View RSS module

---
Tags: ubercart
---


title: Profile as in a Social Network Site

text:
# Question
Title: Profile as in a Social Network Site
i am creating a social network site. I want when the users clicks join after entering his initial details such as name, email and password (the user does not need admin approval for account to be created) he or she is taken to a user registration page which looks like: https://i.stack.imgur.com/GvYaK.jpg

i know how to add fields from admin/settings/people but should i use profile 2 module? if so how exactly...also once the user clicks save profile (as in link above) then he or she is taken to his profile page where he can view his profile

# Answer
> 0 votes
You can control how the user is redirected after login using the Rules module. Create a rule using the event *User logs in* and action *Redirect to page*. You can create as many redirect rules as you need to get the user to go to the appropriate destination.

For example, for my social networking site, I do the following:

* redirect users who haven't completed their profiles to a page telling them they need to do that (condition: user doesn't have profile\_completed role)
* redirect users who have completed their profiles and have new messages (from private message module) to the message inbox (condition: custom PHP condition)
* redirect all other users to the search screen

In my implementation, I actually implemented this as a rule set (component) instead of a bunch of individual rules so that I could easily achieve the third option ("redirect all other users").

---
Tags: users
---


title: Libraries module. Where to extract?

text:
# Question
Title: Libraries module. Where to extract?
Where should I be extracting the Libraries module, sites/all/modules or sites/all/libraries?

# Answer
As all the modules, it goes in site/all/modules, or in $config/modules, where $config is the directory containing the settings.php file currently used for the site. (See drupal\_system\_listing() to understand where Drupal looks for modules.)

sites/all/libraries is the directory where the third-party library files should go. (Although, that is not the only directory where the Libraries module looks for them.)
> 4 votes

# Answer
Put it inside *site/all/modules*.

Also, there's no need to create a new *libraries* folder in *site/all/libraries*.
> 1 votes

---
Tags: theming
---


# Question
Title: How to get a complete list of blocks that are active content on current page?
I'm trying to get a full list of blocks that are active content on the current page. Preferably it would include details of what type of content is displayed in the block.

I need this information to display ads in the blocks. The ads need to be loaded through the javascript snippet, that I can place in the header (through drupal\_add\_js). But first I need to know if the block that contains the ad is active and that's why I need this list of blocks.

I'm using Drupal 7.

# Answer
> 0 votes
Follow the instruction to get the details of block for current page

* In this template\_preprocess\_page function You can get a variable in that u have all region and it's block array
* Using the above function we can get all the information of blocks note(if u want to see know the regions list see this function system\_region\_list

# Answer
> 0 votes
If you want dump out all the blocks on page then do the following:

```
function THEME_preprocess_block(&$vars) {
   var_dump($vars);
   // dsm(); // If Devel module installed.
}

```

You do this in your themes template file, replacing THEME (above) with your theme.

---
Tags: 7, blocks, advertising
---


# Question
Title: Print taxonomy information based on the link that is clicked
Lets say I have a taxonomy called fruits. I have 3 links on my front page and the href-s are:

fruits/bananas fruits/oranges fruits/apples

I made a custom module to do this but I am not really sure what to do next...

```
function mymodyle_menu() {
    $items['fuits/%'] = array(
      'page callback' => 'mymodule_fruits',
      'access callback' => TRUE
    );
    return $items;
  }

  function mymodule_fruits() {
  //what to do?
}

```

I also have a template file for them. How to do this?

# Answer
If you just want a custom pattern for the URL then you are better of with Pathauto module

Once you enable the module if you go to Admin -\> URL Alias you will get a new TAB Pattern. In that you can define the pattern that you want to give to the taxonomy page. By default it would be `[term:vocabulary]/[term:name]`

So if your vocabulary name is **fruits** and your term name is **apples** then the url will automatically be turned into fruits/apples

After you enable the module you might have to do Bulk Update from URL aliases for the urls to take effect.

If the requirement is to add more information regarding the taxonomy terms or nodes with in the taxonomy term then you should use the views module

If you are simply trying to learn the how things work with in drupal then you should check the examples module it has got all sorts of modules to get you started with.
> 1 votes

---
Tags: taxonomy-terms, hooks, theming, routes
---


# Question
Title: How to show an image instead of a tab title for a field group?
How can I show an image instead of the tab title of a field group?

# Answer
Each tab has a unique CSS id or class you can use CSS background-image and text-indent to hide the text of a field.
> 2 votes

---
Tags: entities
---


title: Link views page to taxonomy term page

text:
# Question
Title: Link views page to taxonomy term page
1. I have created a views block and page to display nodes based on term of a taxonomy vocabulary (contextual filter).
2. From this block I have a more link enabled and linked to the page.
3. Here how to make the views page path linked to corresponding taxonomy term pages?

# Answer
> 2 votes
1. Provide the path as taxonomy/term/%
2. Install the pathauto module and override the path using the required patterns.

# Answer
> 0 votes
you can add the link manually to the footer section, your code could be something like this:

```
<a href="<?php print url('news'); ?>" class="bottom-block-button"><span><?php print t('Read More'); ?></span></a>

```

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


title: Views - field template vs php field

text:
# Question
Title: Views - field template vs php field
What should be considered the optimal way of creating a custom field in views?

For example:

```
if($content_type == 'article'){
  print 'something';
}
else{
  print 'something else';
}

```

I either create a Custom Text field and write my php code in its template, or, lately, I've started using views\_php field.

The disadvantage with the templates is that if your site is kinda big, you end up with tons of template files that are sometimes hard to manage, and also (obviously) cannot be managed from someone without server access. Furthermore it cannot support sorting/filtering of some kind. Apart from that, it's "fail safe", it's robust, it doesn't add to complexity via an extra module.

The (possible) disadvantage of the php field is that it's an extra layer of complexity to the site and thus an extra bug possibility. Apart from that, it's easily manageable and it can even be used for filtering/sorting!

So, what would you guys suggest? What do you usually do in such cases?

# Answer
Here are some advantages of using templates instead of a custom PHP field.

1. Templates can be naturally version-controlled just like the rest of your code. (You could version-control the custom php field with Features, but that is an additional layer of complexity.)
2. Since the code for templates is in files, you can use UNIX commands like grep, etc. to search them. You can also batch edit them easily if necessary.
3. If you accidentally misconfigure your site permissions and give a role access to Views administration that shouldn't have it, they still won't be able to insert PHP into your site if you're using templates (eliminates a security risk). Consider that one of the security enhancements in Drupal 7 over Drupal 6 was hiding the PHP filter and making it harder to enable.
4. The Views PHP module is still in dev and thus not subject to audit by the Drupal security team. There may be (are) bugs in the module and since it is not in widespread use they may not be found for some time (avoids another security risk).

Yes, templates might be a little inconvenient, but from a security and maintainability standpoint I think they are clearly superior.
> 3 votes

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


title: Content types accessible to a role

text:
# Question
Title: Content types accessible to a role
I have a requirement to return a list of content types accessible to a user in JSON format using services module.

I have followed this approach:

1. Used Content Access Control module to set the access permission to a particular role to which the user belongs.
2. Set up a custom resource type for the services module to send the content list in JSON format.
3. Implemented oauth to authorize the request.
4. I could send all the content types present in the drupal setup using my custom resource for services module.

Now I want to check the permissions as declared by the Content access module for a role to access the content types.

I am a beginner with drupal and php programming. I am just trying to ready a module which communicates with my android client. Any help would be greatly appreciated.

EDIT:

I followed RajeevK's advice to get the list of permissions from the role\_permission table (actually I accessed this using phpmyadmin inerface).

But the permissions declared by the `content_access` module such as `view any <content-type> content` are not listed in the role\_access.

Since I have accepted the answer here, I will spawn a new thread and rephrase this question.

# Answer
Good. I hope you are using D7.

So lets start with the finding the machine name of the permission which get saved with the user\_role when you enable the permission for particular user type.

These are them -

administer services, get any binary files, get own binary files, save file information, get a system variable, set a system variable, perform unlimited index queries.

Get you RID from the table ROLE by searching your NAME.ROLE

Get the list of PERMISSION from table ROLE\_PERMISSION by RID.ROLE\_PERMISSION

List anywhere and do what you want...

Enjoy :)
> 0 votes

---
Tags: nodes, services, 8
---


title: certain drupal modules not working

text:
# Question
Title: certain drupal modules not working
I've installed drupal several times and I'm still having the same problem. Some modules aren't working.

E.g:

Admin menu \- They don't always appear. It only shows in random moments.

Wysiwyg and CKeditor - is not visible when I'm creating the content.

These are the modules I have installed and I'm using Marinelli theme:

* admin menu
* Wysiwyg
* IMCE Wysiwyg bridge
* IMCE - this is for images
* IMCE Mkdir
* Pathauto
* Chaos tools
* insert
* Mega menu

# Answer
You might have a JQuery version conflict. Do you have the JQuery Update module? Or did you include some script not compatible with Drupal's version of JQuery?
> 0 votes

---
Tags: 7, wysiwyg
---


# Question
Title: drush pm-update of 6.27 to 6.28 yields this error: Allowed memory size of 67108864 bytes
> **Possible Duplicate:**
> “Allowed memory size” errors on common tasks

we put our site into maintenance mode, temporariliy removed some symbolic links that have confused drush in the past, and tried to do this: \[~/drupal-6.25\]# drush pm-update

where we got this error:

Refreshing update status information ...

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 199690 bytes) in /home/kettles/drupal-6.25/modules/update/update.module on line 549 Drush command terminated abnormally due to an unrecoverable error. \[error\] Error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 199690 bytes) in /home/kettles/drupal-6.25/modules/update/update.module, line 549 \[~/drupal-6.25\]#

The directory is called drupal-6.25 but really holds a 6.27 install.

Thanks,

# Answer
> 0 votes
See this thread.

What you need to do basically is to increase the memory in your `php.ini` file. Start with `128M` and if you are still getting that error, try with more.

---
Tags: updating
---


title: Separate all my content

text:
# Question
Title: Separate all my content
I have one page structure. This is my menu:

```
<ul id="creamenu" class="menuHolder">
    <li><a id="news-1-menu" href="#/news-1">news 1</a></li>
    <li><a id="news-2-menu" href="#/news-2">news 2</a></li>
    <li><a id="news-3-menu" href="#/news-3">news 3</a></li>
</ul>
<ul id="mainmenu" class="menuHolder">
    <li><a id="about1-menu" href="#/hakkimizda">about 1</a></li>
    <li><a id="about2-menu" href="#/haberler">about 2</a></li>
    <li><a id="about3-menu" href="#/galeri">about 3</a></li>
    <li><a id="about4-menu" href="#/referanslar">about 4</a></li>
    <li><a id="about5-menu" href="#/iletisim">about 5</a></li>
</ul>

```

And this is content structure:

```
<div id='news-1'>
    <!-- content -->
    <!-- content -->
</div>
<div id='news-2'>
    <!-- content -->
    <!-- content -->
</div>

```

When I click a menu item goes to content in same page, but my site is slow. I think if I separate all tpl.php files maybe I'll improve my site performance. But I don't know how can I do it.

For example, click news-1 item go to news-1.tpl.php file.

# Answer
Separating your tpl.php files in that manner won't improve your site's performance in the way that you hope, unless your current base node.tpl.php file is doing something *really* weird right now.

Loading more tpl.php files in a single page generally makes things *slower* not faster, as more hooks are invoked for preprocessing, etc...

Chances are, that if you have a 1-pager the tpl.php file being processed is not slowing your site down. It will be something in the database layer or excessing php processing, or incorrect caching setup.

If you still really want to do it, try Nikhil M's link to get the template naming suggestions.
> 0 votes

# Answer
You could use Drupal Services to get your Content via AJAX calls.

After setting up your service, bind with jQuery a clickhandler to your links and replace your content with your AJAX Response.

If you don't know the Services Module, study it's code and the documentation. Once you know how to do it, it's very easy!

With this solution, you must initial load just one node, this give your site a good Performance
> 0 votes

---
Tags: theming, performance, 7
---


# Question
Title: How to define a non-database relationship for the Views module
Basically, I have an array of nids (node ids) stored in a `$_SESSION` variable, which is updated according to user actions (it holds a history of visited node pages). Now, I would like to create a view which displays a list of nodes, filtered by nids given in a `$_SESSION` variable.

For example:
if `$_SESSION['my_nids'] == [1,5,6]`
=\> I want to display nodes 1,5,6 in the view.

Storing the nids in a db table is not an option due to performance reasons.

Can someone point me how to create such a non-database relationship views handler?

# Answer
You can use the views php module. And you can get the `$_SESSION['my_nids']` with in view. Actually you can do anything there that can be done with PHP.

Please note that this will again have a performance hit if the code is large. for simple things you go this route.
> 1 votes

# Answer
You can just make a normal views field handler but give it a key/machine name that isn't a database table. This is explained in the Views advanced help.
> 0 votes

---
Tags: views
---


# Question
Title: how to get rid of descriptions that are linked to input types?
I've got a question about the descriptions that are linked to input type options. How do I get rid of it?

I've inherited a site that, for some reason, when I mouse over the options they start twitching as the text adjusts and tries to move to the second line. As a result is a pain to make the PHP selection. I've seen other drupal sites that have the option without the description, but when I went to "Site configuration \> Input formats" I didn't see any way to remove those descripts.

any suggestions or links to documentation would be welcome!

# Answer
The Better Formats module is your friend here, you can use it to remove all or part of the format descriptions/options:

> Better formats is a module to add more flexibility to Drupal's core input format system.
>
> ...
>
> * Set the default format per role.
> * Set the default format per content type.
> * Control allowed formats per content type.
> * **Hide format tips.**
> * **Hide more format tips link.**
> * **Hide format selection for nodes, comments, and blocks seperately, forcing the default to be used.**
>
> ...

(emphasis mine)
> 2 votes

---
Tags: 6, input-formats
---


# Question
Title: Custom PHP code to create a node with rules
I am trying to create an Automatic Registration with rules. Basically when a new asset is created a rule will kick off and create a new registration node with custom PHP but the new node is not being created. I don't see any errors in the reports. Here is the code:

```
$node = new stdClass;
$node->type = 'asset_event';
$node->title = 'Automatic Registration';
$node->[field_first_name]['und'][0]['value'] = [site:current-user];
$node->[field_asset_event_type]['und'][0]['tid'] = 791;
$node->[field_asset_additional_informati]['und'][0]['value'] = 'Event created by automatic registration';
$node->[field_link_to_asset_id]['und'][0]['value'] = [node:field-link-to];
node_object_prepare($node);
node_save($node);

```

Thanks for any help.

# Answer
> 1 votes
In Rule:

1. Create a new entity
2. Of type Node
3. At the end of your action, the "Provided variables" section will give you the label of the entity created
4. Use that entity, already fetched, to set fields (with "Set a value") of that node.

Enjoy !

# Answer
> 0 votes
I did something like that, but I was on Drupal 6.

Anyway I can spot some strange things in your code. I will try to rewrite it as I believe it is correct.

```
$node = new stdClass(); //please note the ()
$node->type = 'asset_event';
$node->title = 'Automatic Registration';
$node->field_first_name['und'][0]['value'] = [site:current-user]; //field names without []
$node->field_asset_event_type['und'][0]['tid'] = 791;
$node->field_asset_additional_informati['und'][0]['value'] = 'Event created by automatic registration';
$node->field_link_to_asset_id['und'][0]['value'] = [node:field-link-to];
node_object_prepare($node);
node_save($node);

```

I'm not sure this qualifies as an answer, but I hope it helps a bit.

---
Tags: 7, rules
---


# Question
Title: Compare two same fields with time difference in Views, using node revisions
I'm trying to build a view containing two columns: first is the actual value of a (integer) field, second is the same field with its old value from two weeks before, using the revision. I suppose I would need a relationship for the second one but can't figure out how do to so.

The great Diff module help comparing one node at a time, but I would need to compare a list of nodes, reason why I want to do it in a view.

Any help would be more than welcome!

# Answer
This is a bit of a hackish solution.

What you need to do it create a field which would be unique per node on all the revisions. You could use the Computed Field instead of the normal field to crate this field and use the code below to computed the field

```
if (!$entity->nid)
{
 node_save($entity);
}

$entity_field[0]['value'] = $entity->nid;

```

This would set the value of the computed field to the nid of the node so that you dont have to bother about setting a unique value.

Now in the views create a view of the type content revision. (This would be done by selecting content revision from the dropdown near **Show**

Add the fields for which you want the revision data. Use the one which says **(historical data)** at the end of it.

Now add the contextual filter with the computed field we created earlier. make sure the select the one with **(historical data)** at the end of it.

In the filters you can choose **Content revision: Updated date** and select the date range you want. you can also provide relative values such as -7 days to get the all the values before 7 days.

The computed field was used because I was not able to get the nid of the revisions. If any one has a work around on that please do make the required changes.
> 1 votes

---
Tags: 7, datetime, views, nodes
---


title: adding open graph metatags to head

text:
# Question
Title: adding open graph metatags to head
Doe's anybody know how to add metatags such as fb:admins or fb:app\_id into drupal 7 ? I use meta tags module for D7 but for some reason theese tags are not included. Thank you for answers.

# Answer
The drupal 7 Metatags module has built-in Facebook opengraph support as an add-on module. If your specific metatag is not covered, the Meta tags module allows you to add it manualy.

Although not recommended, if you need custom code for specific pages, you may use the theme's preprocess hook. For example, here is the one I wrote on the preprocess-page.inc file on the preprocess directory of my Omega sub-theme (for other themes, you may need to write the code in a hook\_preprocess\_page function on template.php):

```
<?
  // Add og:title and og:description for the front page
  if($vars['is_front'] == TRUE){
    $element = array(
      '#tag' => 'meta',
      '#attributes' => array(
        "property" => "og:title",
        "content" => t("Druvision - Drupal News"),
      ),
    );
    drupal_add_html_head($element,'og_title');

    $element = array(
      '#tag' => 'meta',
      '#attributes' => array(
        "property" => "og:description",
        "content" => t("Druvision is a team of web solution experts focused on enterprise systems, open source development, responsive design and Drupal project management."),
      ),
    );
    drupal_add_html_head($element,'og_description');
  }

  // Add og:image
  global $base_url;
  $img =  $base_url.base_path() . drupal_get_path('theme', 'MYTHEME') . "/logo.png";
  if($vars['is_front'] != TRUE){
    if(isset($vars['node']->field_image['und'][0]['uri'])){
      $img = file_create_url($vars['node']->field_image['und'][0]['uri']);
    }
  }
  $element = array(
    '#tag' => 'meta',
    '#attributes' => array(
      "property" => "og:image",
      "content" => $img,
    ),
  );
  drupal_add_html_head($element,'facebook_share_image');
?>

```

Note: The question is old, but I've found it in search so other people are looking for it, so I answer it for the completeness of this thread.
> 12 votes

---
Tags: social-network, meta-tags
---


# Question
Title: How to bulk update text filter format on fields in drupal 7
I have multiple fields across my site, and multiple text filters. I need to delete one of the filters, but I know that it will result in users getting that whacky permission denied error when they try to edit the field.

Is there a way to bulk update all fields input filters? I started looking at field\_update\_field in the field CRUD api, but I'm at a loss.

# Answer
Turns out this was solved in a different question, the answer is below:

> Try this way, by making a loop for all nodes of certain type:
>
> ```
> $node = node_load(nid);
> $node->body[$node->language][0]['format'] = 'full_html'; // plain_text
> node_save($node);
>
> ```

Kudos to Ek Kosmos for sorting this out.
> 1 votes

---
Tags: 7, entities
---


# Question
Title: Querying for user's whose birthday is today plus other OR conditions
We have a date field attached to the user entity. It stores values for year, month and day, in the following format (looking at the field\_date\_of\_birth\_value column in the DB): 1987-06-08T00:00:00.

We are using EFQ and wish to return users who's birthday is today OR some other conditions on another field also attached to the user entity (field\_babys\_date\_of\_birth, which doesn't necessarily have a value for every user and has is stored in the same format as the other field).

Is there a way to compare the stored month and day with the current ones using EFQ? If not, how would you approach this problem?

### Pseudocode specification

```
  FETCH every account where:
    date_of_birth == TODAY (month and day only)  OR
    babys_date_of_birth == TODAY + 6 MONTHS OR
    babys_date_of_birth == TODAY + 3 MONTHS
  END FETCH
  FOREACH accounts as account
    // Custom logic (always the same).
  END FOREACH

```

### Implemented code

```
<?php
// Fetch users whose birthday is today.
$today = new DateTime('today');
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'user')
  ->fieldCondition('field_date_of_birth', 'value', $today, '=');
$result = $query->execute();
$uids = array_keys($result['user']);
foreach ($uids as $uid) {
  $account = user_load($uid);
  // Custom logic (always the same).
}

// Fetch users where babys_date_of_birth == today + 3months.
$after_three_months = new DateTime('today + 3 months');
$after_three_months = $after_three_months->format('Y-m-d\T00:00:00');
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'user')
  ->fieldCondition('field_babys_date_of_birth', 'value', $after_three_months, '=');
$result = $query->execute();
$uids = array_keys($result['user']);
foreach ($uids as $uid) {
  $account = user_load($uid);
  // Custom logic (always the same).
}

// Fetch users where babys_date_of_birth == today + 6 months.
$after_six_months = new DateTime('today + 6 months');
$after_six_months = $after_six_months->format('Y-m-d\T00:00:00');
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'user')
  ->fieldCondition('field_babys_date_of_birth', 'value', $after_six_months, '=');
$result = $query->execute();
$uids = array_keys($result['user']);
foreach ($uids as $uid) {
  $account = user_load($uid);
  // Custom logic (always the same).
}
?>

```

Known problems with the code:

1. We think it should be better to have only one query to return all the accounts, as the custom logic to be executed is the same for all of them.
2. The first condition should only check for month and day (excluding year).

Maybe EFQ doesn't support ORed conditions, and we should use something else?

# Answer
About using `OR` conditions, you can read the answers for Using OR with EntityFieldQuery.

For the code to use to check only the month, and the day, I would use the following query.

```
$today = new DateTime('today');
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'user')
  ->fieldCondition('field_babys_date_of_birth', 'value', $today->format('-m-d\T'), 'CONTAINS');

```

Basing on EntityFieldQuery::addFieldCondition(), the method called by `EntityFieldQuery::addFieldCondition()`, `$operator` can be one of the following: `=`, `<`, `>`, `<=`, `>=`, `STARTS_WITH`, `CONTAINS`, `IN`, `NOT IN`, `BETWEEN`.

If `LIKE` is supported, I would write the field condition as:

```
$query->entityCondition('entity_type', 'user')
  ->fieldCondition('field_babys_date_of_birth', 'value', '%' . db_like($today->format('-m-d\T')) . '%', 'LIKE');

```
> 2 votes

# Answer
If you want to filter in your efq, you'll have to compare strings:

```
   $today = new DateTime();
   $today = $today->format('Y-m-d\T00:00:00');

```

Then add in your query the condition

```
'field_date_of_birth_value', $today, '='

```

I can't tell more unless you show us your code.
> 2 votes

---
Tags: 7, database
---


# Question
Title: Need To Update One Entity Through Another
I've been trying every angle I can, but I keep running into Revision ID errors when I try to update a referenced or related entity of another entity. I believe this might be on the right track? I'm not sure why these are occurring. I just need a simple field to be updated when the related entity is updated.

It also throws this error: DatabaseTransactionNoActiveException

Is there any documentation on how to update one entity when another is updated? I just need to be pointed to the right track on this one.

# Answer
Okay figured it out. I needed to patch the Redhen module I'm using which was causing a Revision ID error. Im using the Relation, Rules Redhen modules together (and of course the Entity API). Here is the export of the Rule that did it:

```
{ "rules_update_employment_status" : {
"LABEL" : "Update Employment Status",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "relation" ],
"ON" : [ "relation_update" ],
"IF" : [
  { "entity_is_of_type" : { "entity" : [ "relation:endpoints:0" ], "type" : "redhen_contact" } },
  { "entity_has_field" : {
      "entity" : [ "relation:endpoints:0" ],
      "field" : "field_employment_status"
    }
  }
],
"DO" : [
  { "relation_rules_fetch_endpoint" : {
      "USING" : {
        "relation" : [ "relation" ],
        "entity_type" : "redhen_contact",
        "number" : "1"
      },
      "PROVIDE" : { "endpoint_fetched" : { "endpoint_fetched" : "Fetched Endpoint" } }
    }
  },
  { "data_set" : {
      "data" : [ "relation:endpoints:0:field-employment-status" ],
      "value" : "20"
    }
  },
  { "drupal_message" : { "message" : "[endpoint-fetched:full-name]\u0027s Employment Availability has been changed to [endpoint-fetched:field-employment-status]." } }
]
  }
}

```

This let me access whatever fields on the endpoint that I wanted then change them if I needed to.
> 1 votes

---
Tags: 7, entities
---


# Question
Title: Using Rules to Update the Data of a Relations Endpoints (Referenced Entities)
I have a Rule which triggers on a Relation update. It then checks for the Entity type of the first endpoint of the Relation. Then checks for a specific field. When I try to set an action to change this specific field, I get these errors related to the **Revision ID** which I can't seem to figure out.

Notice: Undefined property: stdClass::$revision\_id in drupal\_write\_record() (line 7030 of ...\www\includes\common.inc).

Notice: Undefined property: RedhenContact::$revision\_id in EntityAPIController-\>saveRevision() (line 525 of ...\www\sites\all\modules\entity\includes\entity.controller.inc).

Notice: Undefined index: revision\_id in EntityAPIController-\>saveRevision() (line 528 of ...\www\sites\all\modules\entity\includes\entity.controller.inc).

Notice: Undefined index: revision\_id in EntityAPIController-\>saveRevision() (line 533 of ...\www\sites\all\modules\entity\includes\entity.controller.inc).

DatabaseTransactionNoActiveException: in DatabaseConnection-\>rollback() (line 1024 of ...\www\includes\database\database.inc).

Simply put, I need a specific field on an Entity to update when a related **Relation** is updated. This seems simple, but for some reason I cant get it worked out...

# Answer
Just in case someone happens upon this, I did find a patch that provided the solution for this error. Turns out the Redhen module had some revision conflict with the entity API, so this patch here fixed the error, and it should be included in further Redhen updates
> 1 votes

---
Tags: 7, rules, entities
---


# Question
Title: Custom tpl for view mode for all contenty type
I've saw How to provide template for particular view mode?, but I don't to create a single tpl for every content type for a particular view mode, but a tpl used for every content type for a particular view\_mode, something like node--search-results.tpl.php

Is it possible?

# Answer
> 5 votes
Certainly, just add the following code to your theme's template.php file (replacing `MYTHEME` with the name of your theme):

```
function MYTHEME_preprocess_node(&$vars) {
  $vars['theme_hook_suggestions'][] = 'node__' . $vars['view_mode'];
}

```

And remember to clear the caches

---
Tags: 7, theming, entities
---


# Question
Title: How to add checkbox to existing administration page
For a custom module i would love to add a checkbox to "BANDWIDTH OPTIMIZATION" under "admin/config/development/performance". I know how to add a new admin page but this is just one checkbox and i think it would fit more there.

Can anyone tell me how to do that?

# Answer
To alter a form implemented by another module, you just implement hook\_form\_alter(). You probably need to change the #weight property of the form element you are adding, to avoid it is rendered in the wrong place.

```
function mymodule_form_system_performance_settings_alter(&$form, &$form_state) {
 // Add the checkbox to $form.
}

```
> 3 votes

# Answer
To add another item on the performance settings form you must implement the hook\_for\_alter or the hook\_form\_FORM\_ID\_alter.

To get the form id you just need to inspect the form an get the id attribute of the form tag:

In your custom module you will have the form alter function like this:

```
function mymodule_form_system_performance_settings_alter(&$form, &$form_state) {
   $form['bandwidth_opt'] = array(
      '#type' => 'checkbox',
      '#title' => t('BANDWIDTH OPTIMIZATION'),
    );

   return $form;
}

```

Notice that the hyphens of the element id in the HTML are replaced by underscores in the function declaration.

Another good tip is the Form API reference page.
> 2 votes

---
Tags: 7, forms
---


title: Omega footer navigation

text:
# Question
Title: Omega footer navigation
I'm making a footer menu. The base-theme I use is Omega. Now I'm looking for the best way to add a CSS value to each menu-item, so Omega places them next to eachother.

Basicaly, what I would like to do is adding "grid-3" to the parent menu items... In the example you can see class="nolink" (from the module special\_menu\_items), I also want to add the class "grid-3".

```
<li class="first expanded"><span title="" class="nolink">Web Design</span>
  <ul class="menu">
  <li class="first leaf"><a href="/geek.screamingsilence.be/" title="" class="active">Drupal Design</a></li>
  <li class="leaf"><a href="/geek.screamingsilence.be/" title="" class="active">Graphic Design</a></li>
  <li class="last leaf"><a href="/geek.screamingsilence.be/" title="" class="active">Logo Design</a></li>
  </ul></li>
  <li class="expanded"><span title="" class="nolink">SEO Services</span><ul class="menu"><li class="first leaf"><a href="/geek.screamingsilence.be/" title="" class="active">Google Adwords</a></li>
  <li class="leaf"><a href="/geek.screamingsilence.be/" title="" class="active">Great Keywords</a></li>
  <li class="leaf"><a href="/geek.screamingsilence.be/" title="" class="active">Link Submission</a></li>
  <li class="last leaf"><a href="/geek.screamingsilence.be/" title="" class="active">SEO Link Building</a></li>
</ul></li>

```

# Answer
> 0 votes
You have to use hook\_menu\_link\_HOOK

For example if your menu is the main menu you could use this example code in your template.php to add class to tag li.

```
function YOUTHEME_menu_link__main_menu(array $variables) {

  $element = $variables['element'];
  $sub_menu = '';
  /* add classes to balise li */
  $element['#attributes']['class'][] = 'grid-3';
  /*$element['#attributes']['class'][] = 'depth-' . $element['#original_link']['depth'];*/
  $element['#attributes']['class'][] = 'menu-' . $element['#original_link']['mlid'];

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }

  $title = $element['#title'];

  $element['#localized_options']['attributes']['id'] = $title ;

  $output = l($lien, $element['#href'], $element['#localized_options']);
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . "</li>\n";

}

```

To add the class only to the parent menu, you should use a condition to see if the menu item has children. Or make a condition to see if the tag li has the class depth-1 and then add the class grid-3.

The module Menu attributes seems to do the job too.

---
Tags: 7, routes, theming, navigation
---


title: User-profile and Profile2 related

text:
# Question
Title: User-profile and Profile2 related
on my front page the user registers by typing in his username, email, password..once he clicks submit he log ins and is redirected to his profile edit page (not account settings)..i am able to do that using rules..i am using Profile2 and adding new fields..however i also want the old fields such as username, password,and email id to appear there ... it would be the same password or username and email id that the user entered while registering but i just want to create/display these fields on this edit profile page for completeness.they may have the earlier entered values copied and the user may enter/edit it here again and be able to save (ofcourse he should get an error if he enters a new email id on that page)

what i want is something like this: https://i.stack.imgur.com/GvYaK.jpg

# Answer
Well i think you could do a hook\_form\_alter and alter the edit page when they go there. You would need to do a user\_load($user) to get the information and then alter the form with those values. The tricky part is the password is encrypted so that may be an issue.

Example of user load

```
global $user
$user_info = user_load($user);

```

Example of hook alter on profile page

```
function mymodule_form_user_profile_form_alter(&$form, &$form_state)
{
 //Code here
}

```

http://api.drupal.org/api/drupal/modules%21user%21user.module/function/user\_load/7 http://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook\_form\_alter/7
> 0 votes

---
Tags: users
---


# Question
Title: How to approach implementing a custom page header for each page
I am building a site that gives the content managers the ability to craft a masthead image, teaser text, and headline text for each individual page. This will appear in an area outside of node.tpl and -- anyway -- can also appear on taxonomy index pages, etc.

My current approach involves creating a Header content type and adding an EntityReference field to each entity I use in the site, then modifying page.tpl.php to look for and render that field. But is there a smarter approach?

**Edited**

The site is a multilingual site, so I'm looking for something that supports i18n. That lets Field Collection out, unfortunately.

# Answer
You might want to look at a solution using Minipanels.

Minipanels are basically Panels (shipped together) that can be used as a block.

You could create a minipanel with the required content and assign that block to the header region for a particular page.

Alternatively, you could set it up as a content type with an image, title and teaser and then a template or view mode to render it in the header.
> 0 votes

---
Tags: theming, entities, i18n-l10n
---


# Question
Title: Does DrupalWebTestCase::drupalGet() use the permissions of DrupalWebTestCase::$loggedInUser?
I'm trying to test the permissions of a particular role, and this code:

```
$this->drupalLogin($this->editor_user);
$this->drupalGet($node->path['source']);

```

returns a 200 (OK) status, when I'm expecting a 403 (forbidden).

Does DrupalWebTestCase::drupalGet() ignore the permissions of the currently logged-in user, and if so, how can I test page view permissions?

# Answer
Permissions to access the page are considered. ContactPersonalTestCase::testPersonalContactAccess() uses the following code to check users has permission to access the right contact pages.

```
  // Test allowed access to user with contact form enabled.
  $this->drupalLogin($this->web_user);
  $this->drupalGet('user/' . $this->contact_user->uid . '/contact');
  $this->assertResponse(200);

  // Test denied access to the user's own contact form.
  $this->drupalGet('user/' . $this->web_user->uid . '/contact');
  $this->assertResponse(403);

  // Test always denied access to the anonymous user contact form.
  $this->drupalGet('user/0/contact');
  $this->assertResponse(403);

  // Test that anonymous users can access the contact form.
  $this->drupalLogout();
  user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access user contact forms'));
  $this->drupalGet('user/' . $this->contact_user->uid . '/contact');
  $this->assertResponse(200);

```

`$this->web_user`, and `$this->contact_user` are initialized using the following code.

```
$this->web_user = $this->drupalCreateUser(array('access user contact forms'));
$this->contact_user = $this->drupalCreateUser();

```

If the permissions assigned to the test user would not be considered, the first test would fail, as only users with the "access user contact forms" permission can see the contact page of another user, and by default users don't have that permission.
> 0 votes

---
Tags: users, testing
---


# Question
Title: Is there a module that creates a taxonomy of the world's languages?
Before I go creating my own taxonomy with the worlds languages as terms, I just wanted to see if there was a module out there that is already handling this?

EDIT:

I did lots of searching for a module before posting here but just wanted to make sure I didn't miss anything before going my own way.

# Answer
> 4 votes
I searched for such a module fairly extensively but was unable to find anything.

In the end, I used the Taxonomy CSV Import/export module, which allows you to create a list based on a CSV (comma-separated value) file, which is very easy to prepare. I then referenced one of the lists of languages on Wikipedia. I would share my list with you except that mine is specific to my site; it doesn't list all human languages, but instead just the most popular ones in Asia.

---
Tags: taxonomy-terms
---


# Question
Title: Error when activating the View Mode Page module
I am trying to activate the View Mode Page module because I need to use URLs to jump from one view mode to another. From teaser to presentation to full node. Every time I try to activate the View Mode Page it gives me an error and after that I am unable to view the Manage Display section for any of my content types. It mentions there is an error in the view\_mode\_page.module (or something similar). Does anyone know if this module is incompatible with some other modules or what the problem might be?

Thanks in advance.

> PDOException: SQLSTATE\[42S02\]: Base table or view not found: 1146 Table 'drp\_obdcbn7hei.view\_mode\_page' doesn't exist:
>
> ```
> SELECT view_mode_page.* FROM {view_mode_page} view_mode_page WHERE (content_type = :db_condition_placeholder_0) AND (view_mode = :db_condition_placeholder_1) ; Array ( [:db_condition_placeholder_0] => tu_mooc [:db_condition_placeholder_1] => default )
>
> ```
>
> en view\_mode\_page\_get\_patterns() (línea 281 de /hermes/waloraweb021/b1678/moo.blasbray/sites/all/modules/view\_mode\_page/view\_mode\_page.module).

# Answer
I don't know about the View Mode Page module specifically, but here's how you can find out yourself.

1. Check the issue queue for the module. You can find a link to "all issues" on the module's project page (in this case, here). In this case, there aren't many issues; if there were a lot, you can use the search function. If searching, make sure to set the status to all issues, not just open issues, as if you're lucky your issue will already have been reported and fixed.
2. If step 1 doesn't solve the problem, create a fresh install of Drupal 7 on your local machine or another server and install the Views Mode Page module and its dependencies. Make sure it works properly by itself when you have no other modules enabled. (For a small module like View Mode Page which has less than a few hundred installs, this step is especially important; for an extremely common module like Views itself, you can assume that someone has already done this and it's your problem.)
3. If step 2 doesn't solve the problem, you'll need to start disabling the modules on your site one by one. Of course, don't do this on your live site-- do it on a backup site. Just guess which module might be causing the problem, disable it, and then clear the cache. Then try to enable Views Mode Page. If it doesn't work, choose another module to disable and repeat.

Yes, this is really painful and frustrating, but sometimes it is necessary if a search of the issue queues on drupal.org doesn't turn up anything. If you do have to do this and find the source of the problem, **please don't forget to create an issue on drupal.org and report what you found**!
> 1 votes

---
Tags: 7
---


# Question
Title: When running DB updates, in what order are module update hooks called?
I'm watching a Drupal 6 to 7 upgrade run, wondering at the order these updates are called.

Aside from being in numeric order per each module, it seems that the module updates have been combined and I can't discern the pattern. Why does the system stop at `system_update_7027` and resume at `system_update_7029` after firing updates from several other modules in between?

```
    Performed update: system_update_7015                  [ok]
    Performed update: system_update_7016                  [ok]
    Performed update: system_update_7017                  [ok]
    Performed update: system_update_7018                  [ok]
    Performed update: system_update_7020                  [ok]
    Performed update: system_update_7021                  [ok]
    Performed update: system_update_7027                  [ok]
    Performed update: taxonomy_update_7004                [ok]
    Performed update: taxonomy_update_7005                [ok]
    Performed update: taxonomy_update_7005                [ok]
    Performed update: taxonomy_update_7005                [ok]
    Performed update: taxonomy_update_7005                [ok]
    Performed update: taxonomy_update_7006                [ok]
    Performed update: taxonomy_update_7007                [ok]
    Performed update: taxonomy_update_7008                [ok]
    Performed update: taxonomy_update_7009                [ok]
    Performed update: taxonomy_update_7010                [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7006                    [ok]
    Performed update: node_update_7007                    [ok]
    Performed update: node_update_7008                    [ok]
    Performed update: node_update_7009                    [ok]
    Performed update: node_update_7010                    [ok]
    Performed update: node_update_7011                    [ok]
    Performed update: node_update_7012                    [ok]
    Performed update: node_update_7013                    [ok]
    Performed update: comment_update_7005                 [ok]
    Performed update: comment_update_7006                 [ok]
    Performed update: comment_update_7006                 [ok]
    Performed update: comment_update_7006                 [ok]
    Performed update: comment_update_7006                 [ok]
    Performed update: comment_update_7006                 [ok]
    Performed update: comment_update_7006                 [ok]
    Performed update: comment_update_7006                 [ok]
    Performed update: comment_update_7006                 [ok]
    Performed update: comment_update_7006                 [ok]
    Performed update: comment_update_7006                 [ok]
    Performed update: comment_update_7006                 [ok]
    Performed update: comment_update_7006                 [ok]
    Performed update: comment_update_7006                 [ok]
    Performed update: comment_update_7006                 [ok]
    Performed update: comment_update_7007                 [ok]
    Performed update: comment_update_7008                 [ok]
    Performed update: comment_update_7009                 [ok]
    Performed update: system_update_7029                  [ok]
    Performed update: system_update_7032                  [ok]
    Performed update: system_update_7033                  [ok]
    Performed update: system_update_7034                  [ok]
    Performed update: user_update_7012                    [ok]
    Performed update: system_update_7036                  [ok]
    Performed update: system_update_7042                  [ok]
    Performed update: system_update_7044                  [ok]
    Performed update: system_update_7045                  [ok]
    Performed update: system_update_7046                  [ok]
    Performed update: system_update_7047                  [ok]
    Performed update: system_update_7048                  [ok]
    Performed update: system_update_7049                  [ok]
    Performed update: system_update_7050                  [ok]
    Performed update: system_update_7051                  [ok]
    Performed update: system_update_7052                  [ok]
    Performed update: system_update_7053                  [ok]
    Performed update: system_update_7054                  [ok]
    Performed update: system_update_7055                  [ok]
    Performed update: system_update_7057                  [ok]
    Performed update: system_update_7058                  [ok]
    Performed update: system_update_7059                  [ok]
    Performed update: user_update_7013                    [ok]
    Performed update: user_update_7014                    [ok]
    Performed update: user_update_7015                    [ok]
    Performed update: webform_update_7301                 [ok]
    Performed update: user_update_7016                    [ok]
    Performed update: mollom_update_7000                  [ok]
    Performed update: user_update_7017                    [ok]
    Performed update: webform_update_7302                 [ok]
    Performed update: mollom_update_7001                  [ok]
    Performed update: user_update_7018                    [ok]
    Performed update: webform_update_7303                 [ok]
    Performed update: webform_update_7304                 [ok]
    Performed update: system_update_7060                  [ok]
    Performed update: mollom_update_7002                  [ok]
    Performed update: system_update_7061                  [ok]
    Performed update: apachesolr_update_7000                                                                                [ok]
    Performed update: mollom_update_7003                  [ok]
    Performed update: webform_update_7305                 [ok]

```

# Answer
> 6 votes
The order in which updates are executed is influenced by hook\_update\_dependencies(), which is described as:

> This can be used to indicate update functions from other modules that your module's update functions depend on, or vice versa. It is used by the update system to determine the appropriate order in which updates should be run, as well as to search for missing dependencies.

For example, the implementation done from the Node module is the following one.

```
function node_update_dependencies() {
  // node_update_7006() migrates node data to fields and therefore must run
  // after all Field modules have been enabled, which happens in
  // system_update_7027(). It also needs to query the {filter_format} table to
  // get a list of existing text formats, so it must run after
  // filter_update_7000(), which creates that table.
  $dependencies['node'][7006] = array(
    'system' => 7027,
    'filter' => 7000,
  );

  // node_update_7008() migrates role permissions and therefore must run after
  // the {role} and {role_permission} tables are properly set up, which happens
  // in user_update_7007().
  $dependencies['node'][7008] = array(
    'user' => 7007,
  );

  return $dependencies;
}

```

That code is telling to Drupal that `node_update_7006()` is executed after `system_update_7027()` is executed, which is what you notice. Similarly, taxonomy\_update\_dependencies() tells Drupal that `taxonomy_update_7004()` needs to be executed after `system_update_7027()`.

The function that handles the dependencies between update hooks is update\_resolve\_dependencies().

---
Tags: drush, updating
---


title: colorbox not loading images in lightbox

text:
# Question
Title: colorbox not loading images in lightbox
I have dloaded libraries 7.x-2.0 in my modules folder and installed colorbox 7.x-2.2 in modules and installed 1.3.26 plugin to sites/all/libraries folder and enabled colorbox in manage display for fields. ALL OF THIS WAS WORKING BEFORE UPGRADE. So started from scratch but when I click on an image it opens lightbox and the image never loads.

# Answer
The latest version of the colorbox plugin uses a different version string in its js file ( `sites/all/libraries/colorbox/colorbox/jquery.colorbox-min.js` ) so it doesnt get recognised by the colorbox module requirements check.

If possible look at the version string from the previous file, it's the first line, and copy that over, incrementing the number in the new file.
> 1 votes

---
Tags: javascript
---


# Question
Title: Parsing bad dates automatically with feeds and date api?
My company is trying to load an event calendar with events from another company's online calendar's web service. I'm using the Feeds Module and everything's working, except the dates because their service returns dates in a text format like so: 'MM/DD/YY\[ - Ongoing\]'. The Dates API doesn't seem to know how to handle this, so it just defaults to today's date.

I've tried using the Partial Date module, but there doesn't seem to be a way of feeding Feeds results into a partial date field. I've also tried talking the other company into fixing their service and returning proper dates, but they have no idea what they're doing.

Any ideas?

# Answer
I am not certain if Feeds can handle this, but if you are importing CSV files, maybe OpenRefine is the quickest fix.
> 0 votes

---
Tags: 7, entities, feeds, datetime, services
---


title: Help me with hook_views_data

text:
# Question
Title: Help me with hook_views_data
I create a simple module to test `hook_views_data` but may I get some errors this is my code

in `tungcan.module` file

```
function test_views_api() {
  return array(
    'api' => '3'
  );
}

```

and in `tungcan.views.inc` file

```
function tungcan_views_data() {
  $data = array();
  $data['tungcan']['table']['group'] = t('TungCan');
  $data['tungcan']['table']['basic'] = array(
    'field' => 'tungid',
    'title' => t('Tungcan'),
    'weight' => -100,
    'defaults' => array(
      'field' => 'tungname',
    ),
  );

  $data['tungcan']['tungname'] = array(
    'title' => t('Tung Name'),
    'help' => t('Display name of Tung')
  );

  return $data;
}

```

but when I clear cache, in my Views (add new views or add new Field) doesn't change anything.

Can somebody point out what is wrong in my code?

# Answer
> 3 votes
If the module is tungcan.module, then the implementation of hook\_views\_api() (necessary to load the include files used from the module to integrate with the Views module) should be `tungcan_views_api()`, not `test_views_api()`.

If, vice versa, the module is test.module, then `tungcan_views_data()` should be renamed to `test_views_data()`.

---
Tags: views
---


# Question
Title: How to display a newly created node (created using a form) in the view using ajax (without page reload)?
I have created a "Share update" form using form API. Below the form, I am displaying a view "feeds" of all the published nodes of content type "updates". On submit, the form saves the data entered in the form as a node of content type "updates". It reloads the page and displays the recently saved node in the view below the form.

I want the node to appear in the view list without page reload. How to do that?

My form API code looks like this -

```
function add_update_page($form, &$form_state) {
  $form = array(
   '#prefix' => '<div id="update-div">',
   '#suffix' => '</div>',
   '#title' => t('Latest update:'),
   '#description' => t('Add status update'),
  );

  $form['update'] = array(
    '#title' => t('Share an update...'),
    '#type' => 'textarea',
    '#resizable' => '0',
    '#format' => 'update_feed_text',
    '#label' => t('Share an update...'),
  );

  $form['submit'] = array(
    '#id' => 'update-submit-button',
    '#type' => 'submit',
    '#default_value' => t('Share'),
  );
  return $form;
}

function add_update_page_submit($form, &$form_state) {
  $update = $form_state['values']['update'];
  $node = new stdClass();
  $node->type = 'updates';
  node_object_prepare($node);
  $node->status = 1;
  $node->uid = $GLOBALS['user']->uid;
  $node->language = LANGUAGE_NONE;
  $node->created = time();
  $node->changed = $node->created;
  $node->title = 'Automatic status update';
  $node->body[$node->language][0]['value']   = $form_state['values']['update'];
  $node->body[$node->language][0]['summary'] = "";
  $node->body[$node->language][0]['format']  = 'filtered_html';
  node_save($node);
  drupal_set_message($form_state['values']['update']);
  $form_state['redirect'] = '<front>';
}

```

I have looked up everywhere, but the proposed solutions are incomplete, making it harder to follow the logic.

# Answer
> 1 votes
As mentioned by wwwWRX you should use the #ajax property for your submit button and with in your function make a few changes. Before that you would want to remove your view from the block because we would be putting that here using code.

the submit button would become

```
$form['submit'] = array(
    '#id' => 'update-submit-button',
    '#type' => 'submit',
    '#default_value' => t('Share'),
    '#ajax' => array(
        'callback' => 'add_update_page_submit',
        'wrapper' => 'update-list',
        'method' => 'replace',
        'effect' => 'fade',
    ),
  );

```

Add one more element to your form of the type #markup like below

```
$form['update_list'] = array(
 '#prefix' => '<div id="update-list">',
   '#suffix' => '</div>',
  '#markup' => views_embed_view('views-machine-name','block_name', $arg);

);

```

you should replace views-machine-name with the actual machine name of the view and block\_name with the name of the specific block in the view and $arg would be the argument passed to the view which can be left blank if you dont have one.

with in the function you need to make a few changes towards the end.

you need to get rid of `$form_state['redirect'] = '<front>';`

and add

```
return views_embed_view('views-machine-name','block_name', $arg);

```

That should do it.

# Answer
> 0 votes
I assume Drupal 7 (in D6 this would be an inconceivable nightmare)?

Basically you want to add the #ajax property to your submit button:

```
    '#ajax' => array(
        'callback' => 'ajax_example_autocheckboxes_callback',
        'wrapper' => 'checkboxes-div',
        'method' => 'replace',
        'effect' => 'fade',
    ),

```

You use the callback to throw in whatever content and the form and the content swap (or some other div and the content swap)

http://drupal.org/node/752056

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


# Question
Title: How to add text over Slideshow/carousel?
I've been able to create a simple slideshow using field slideshow, jcarousel and libraries.

But how would I go about add text in the rhs of the images? I would like the text to change depending on the slideshow image.

# Answer
First of all you are using views \+ views slideshow for the slideshow, correct?? And you are using a slideshow content type.

No =\> use views \+ views slideshow to show your slideshow contents as a slideshow. You can find instructions in its documentation and many videos to help you out(google knows best!! :))

Yes =\>

* in views : should show fields and not content
* so you will have 2(or more per your need) fields : image and text(custom text area or say your title)
* Using css you can position your text.

Hope it helps....keep posting your problems in comments...the community will always help you out.
> 0 votes

---
Tags: views, javascript
---


# Question
Title: Attempt to charge recurring fee 2 failed
Attempt to charge recurring fee 2 failed.I am getting this error when i want to charge via developer a/c authorize.net. Normal payments going well but recurring is the porblem..Any idea to fix this error..D7 i am trying.....

# Answer
Authorize.net renewals cannot be tested while your authorize.net account is in "Test Mode". I have tested and confirmed this. It will work if you set the account to live mode.

You can see the relevant discussion here: http://drupal.org/node/812922
> 1 votes

---
Tags: ubercart
---


# Question
Title: Rules: after saving new content + after updating existing content both triggered on node create
I have two rules -

1. Triggers - after new content is saved
2. Triggers - after updating existing content

**Problem**

* When I create a new node both rules are getting triggered together.

**Probable Cause**

However, there must be some solution to this. Please any suggestions, workarounds, solutions...anybody?

Thanks.

# Answer
You could add a condition in both rules to check whether the `$node->created` and `$node->changed` timestamps are same.

For a newly created node `$node->created` and `$node->changed` time will be same, while for an updated node both will be having different timestamps.

You probably need to add an **Execute custom PHP code** in rule condition to do this.
> 5 votes

---
Tags: rules
---


# Question
Title: Why can't I edit "Settings" on rules components in the Rules UI?
When I click to edit a rule in the Rules UI, "Settings" is displayed in blue and upon clicking "Settings" the "Name", "Tags", "Active" and "Weight" options are presented.

However, when I click to edit a rules component, "Settings" is displayed in black and I cannot edit the name of the rule nor the arguments.

Before, I solved this problem by:

* clearing the Drupal cache (twice)
* clearing the cache in my browser and restarting it
* switching to a different browser (e.g., from Firefox to Safari)

However, this time none of the above worked. How can I edit the settings for rules components?

# Answer
I had this problem when using entity-rc1. Upgrading to entity 1.0 resolved the issue for me.
> 0 votes

---
Tags: 7, rules
---


# Question
Title: Unable to override Superfish styles in Zen theme
I am using a zen subtheme and a superfish menu. I am trying to override the background colours of the menu but am not having luck in IE8. I've tried clearing the cache but still no luck.

Do you have any idea why? Why isn't IE8 recognising the pages.css style sheet?

This style sheet is being picked up by IE8.

### superfish/style/default.css

```
.sf-menu.sf-style-default li,
.sf-menu.sf-style-default.sf-navbar {
  background: red;
}

.sf-menu.sf-style-default li li {
  background: pink;
}

.sf-menu.sf-style-default li:hover,
.sf-menu.sf-style-default li.sfHover,
.sf-menu.sf-style-default a:focus,
.sf-menu.sf-style-default a:hover,
.sf-menu.sf-style-default a:active {
  background: green;
  outline: 0;
}

```

While this style sheet is being picked up by FireFox (this is what I want).

### mytheme/css/pages.css

```
.sf-menu.sf-style-default li,
.sf-menu.sf-style-default.sf-navbar {
  background: orange;
}

.sf-menu.sf-style-default li li {
  background: yellow;
}

.sf-menu.sf-style-default li:hover,
.sf-menu.sf-style-default li.sfHover,
.sf-menu.sf-style-default a:focus,
.sf-menu.sf-style-default a:hover,
.sf-menu.sf-style-default a:active {
  background: grey;
  outline: 0;
}

```

# Answer
> 1 votes
It was just a matter of selection the Aggregate and compress CSS files option under Bandwidth optimization

---
Tags: theming, navigation
---


# Question
Title: Drupal Commerce Adding fields to Add To Cart page
I need some suggestion to add some fields to the "Add to cart" page.

Out of many products, one of the product requires some user information to be filled before proceeding to "Add to cart" process. I am selling a product of type "Exam". Before buying Product of type "Exam" (Before adding to cart), user has to input his person details like name, address, DOB and other mandatory details without which he is not able to proceed.

Could you please guide me, how to achieve this?

Update:

Shall I use Product Attribute fields to capture user inputs over product display page? As this information is not associated with the Product, but with the order and need to be captured before Add to Cart button is clicked.

# Answer
Thanks all of you for your valuable time and suggestions. More or less all suggestions 'll be required in near future. I have up-voted all of you for your help. However on other side I got the answer, what I was looking for.

> It sounds like you need the Customizable Products module.
>
> Once you have that module installed, you can go to Administration \> Store \> Configuration \> Line item types. Add a custom line type and add as many custom fields there as you'd like. You'll see - the interface for adding fields to the custom line type is the same as when you create a content type, so it's easy to use.
>
> Then, when you've added all the customer info you need in your new line item, go ahead and modify your 'Exam' product to include those fields in the product display. Hit the 'Display' settings for the content type, and configure the settings for the 'Add to cart' field. Make sure you choose the correct line item for it to use and Save!
>
> Helpfull screencast could be found at http://vimeo.com/36106455
> 2 votes

# Answer
Try this:

```
/**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if (strstr($form_id, 'commerce_cart_add_to_cart_form')) {
    // Add the required form elements here.

    // Add your custom validation function.
    $form['#validate'] = array('mymodule_custom_form_validation');
  }
}

function mymodule_custom_form_validation($form, &$form_state) {
  // Do your validation here.
}

```

Help links: http://api.drupal.org/api/drupal/developer%21topics%21forms\_api\_reference.html/7#validate, http://drupal.org/node/732108
> 1 votes

# Answer
I would say you need to rethink that checkout process.

The order is created *after* the first product is added to a cart for that user.

The information you are looking to add belongs on a Commerce Customer Profile on the Commerce Order (e.g "Billing information").

You can create a customer profile type with:

or else:

For example, a new customer profile type called "Personal information".

That way, the data is stored for each customer with the order itself, as part of the customer profile, where it belongs.

Alternatively, you *might* be able to do something with adding a field to the line item type, maybe even referencing a commerce customer profile entity, but that would need more evaluation.
> 1 votes

---
Tags: 7, commerce
---


# Question
Title: Is there a way to insert a view in a node form?
I have created a content-type based form (contact form) for anonymous users. One of the fields in the form must displays a view. This view is a slideshow view that displays different persons (site employees).

I want them to select an employee to where their comments will be delivered.

# Answer
> 0 votes
Found it i can use Markup module to use php code in the field and use this code;

WHATEVER is the name of your view.

# Answer
> 0 votes
With module\_invoke(), you can display a view block wherever you like.

# Answer
> 0 votes
You need to use

```
<?php
views_embed_view($name, $display_id = 'default')
?>

```

to embed a view. Here is the doc for that.

# Answer
> 0 votes
There are a number of modules that might do it (quotes included are from their project pages):

* EVA: Entity Views Attachment:

> ... provides a Views display plugin that allows the output of a View to be attached to the content of any Drupal entity. The body of a node or comment, the profile of a user account, or the listing page for a Taxonomy term are all examples of entity content.
* View reference:

> ... defines a field type View reference which creates a relationship to a Views display and allows the view to be displayed as the content of the field.
>
> This module is modelled on Node reference and usage is similar.
>
> Additionally, you may enter arguments for each view by a delimiter seperated list with support for PHP generated arguments.
* Viewfield:

> ... provides a field that holds a reference to a View and renders it whenever the entity containing the field is displayed.

---
Tags: views, nodes, forms
---


title: PDOException does not show my sql table

text:
# Question
Title: PDOException does not show my sql table
Hello Every body I have an SQL Query to DB

```
function darkSiteContent($delta){
     switch ($delta) {
     //SQL Query to find the title , nid of the node and its body
     case 'popup_dark_screen':
      $result = db_query("
        SELECT n.title , n.nid , b.body_value
        FROM {dot_node} as n , {dot_field_revision_body} as b , {dot_node_type} as t
        WHERE t.type = 'dark_sit' AND n.type = t.type and b.bundle = t.type
        order by n.title desc LIMIT 1
        ");
        $items = array();
        foreach ($result as $row) {
        print_r($row);
        $items[] = l(t($row->title, 'node/' . $row->nid )).'
'.$row->body_value;
        }
      return array('#markup' => theme('item_list', array('items' => $items)));
      break;
    }

}

```

But it show this error

```
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'APIG01JO2012039.dot_dot_node' doesn't exist: SELECT n.title , n.nid , b.body_value FROM {dot_node} as n , {dot_field_revision_body} as b , {dot_node_type} as t WHERE t.type = 'dark_sit' AND n.type = t.type and b.bundle = t.type order by n.title desc LIMIT 1 ; Array ( ) in darkSiteContent() (line 71 of C:\AppServ\www\APIG01JO2012039\sites\all\modules\darksite\darksite.module).

```

I am sure of my table name but it still show this error

# Answer
> 3 votes
When using database with in {} you don't need to add the prefix of the table it is automatically added by drupal in your case since you have placed it between {} it is adding another dot\_ so the table name is becoming dot\_dot\_node instead of dot\_node.

Note the relevant section from Drupal Database API documentation

> **Prefixing**
>
> In static queries, all table names must be wrapped in {}. That flags them so that the database system can attach a prefix string to them if appropriate. Prefixing allows for running multiple sites from the same database or, in limited cases, for sharing selected tables between sites.

---
Tags: 7, blocks
---