title: Fatal PHP error on Drupal 7 with IIS

text:
# Question
Title: Fatal PHP error on Drupal 7 with IIS
Logging as Admin user on Drupal 7 website stored on an IIS machine, I get the following error:

```
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]:
General error: 2006 MySQL server has gone away'
in E:\inetpub\wwwroot\teams\includes\database\database.inc:2139
Stack trace:
#0 E:\inetpub\wwwroot\teams\includes\database\database.inc(2139): PDOStatement->execute(Array)
#1     E:\inetpub\wwwroot\teams\includes\database\database.inc(664): DatabaseStatementBase->execute(Array, Array)
#2 E:\inetpub\wwwroot\teams\includes\database\database.inc(2318): DatabaseConnection->query('SELECT expire, ...', Array, Array)
#3 E:\inetpub\wwwroot\teams\includes\lock.inc(167): db_query('SELECT expire, ...', Array)
#4 E:\inetpub\wwwroot\teams\includes\lock.inc(146): lock_may_be_available('schema:runtime:...')
#5 E:\inetpub\wwwroot\teams\includes\bootstrap.inc(420): lock_acquire('schema:runtime:...')
#6 E:\inetpub\wwwroot\teams\includes\bootstrap.inc(442): DrupalCacheArray->set(Array)
#7 [internal function]: DrupalCacheArray->__destruct()
#8 {main} thrown inE:\inetpub\wwwroot\teams\includes\database\database.inc on line 2139

```

Any idea on how do I debug those statements? And how do I release locks?

# Answer
Indeed, setting maximum allowed packet size in MySQL worked like charm. To solve, we've went to the `[mysqld]` section of `my.ini` and added the following:

```
[mysqld]
max_allowed_packet=100M

```

then restarted the Windows server machine in order to restart MySQL.

The only difference in **IIS** is that the machine required a boot.
> 7 votes

---
Tags: database, iis
---


title: NFS Directories between 2 Servers

text:
# Question
Title: NFS Directories between 2 Servers
I have 2 parallel Drupal Web Servers running (serving for one Drupal Instance together) and now i need to install NFS. My experience in multi Drupal Servers is, each Drupal Instance (Server) uses their own Aggregated JS + CSS files (storing in: `sites/default/files/js` and `sites/default/files/css` folders) which can NOT be used as common. (Files can not be the same for both Servers. They use their own ones.)

Based on these issues, my questions are:

* How NFS actually works between Multi Drupal Servers?
* Which `directories` will be/need to be shared between?
* What will happen to Aggregated Files?
* What will happen to Web User Uploads paths and files? (Need any configuration in Drupal?)

Can anyone share these knowledge/experience please?

# Answer
> 0 votes
To prevent synchronization issues, you should mount the files directory as a shared folder over NFS between the drupal webservers, so that each Drupal instance has a symlink to the same file share

e.g:

`/var/www/drupal-site-mysite/sites/default/files -> /var/lib/sitedata/drupal-site-mysite/files`

where `/var/lib/sitedata/drupal-site-mysite/files` is a NFS mount/share.

---
Tags: css-js-aggregation
---


# Question
Title: Setting the mime-type for files stored in the private directory
How do I set the mime-type of files being served from the drupal private directory. I have a webm file in the private directory, and the I've added the `<video>` tag to the page using a *tpl* file.

I've tried adding

```
AddType video/webm .webm

```

to .htaccess. I've also tried installing the module "File Mime" to try to set the right mime type. I've tried adding

```
function mymodule_file_download($uri){
    return array('Content-type: '.'video/webm');
}

```

to my .module file. Nothing seems to work. Any help would be appreciated.

# Answer
Editing `includes/files.mimetypes.inc` is a core hack, which you should strive to avoid.

Instead, use hook\_file\_mimetype\_mapping\_alter():

```
function mymodule_file_mimetype_mapping_alter(&$mapping) {
  // Add new MIME type 'video/webm'.
  $mapping['mimetypes']['webm'] = 'video/webm';
  // Add new extension '.webm' and map it to the 'video/webm' MIME type.
  $mapping['extensions']['webm'] = 'webm';
}

```
> 4 votes

# Answer
Figured this out myself: I had to add the webm mimetype in the appropriate places in the `includes/files.mimetypes.inc` file to get drupal to serve private files with the correct mimetype.
> -1 votes

---
Tags: 7, files
---


# Question
Title: Only Show Nodes From Child Terms (-1 excluding parent)
Hello i have some nodes which i am using as to hold information on a taxonomy term (image, desc etc) and I have created some block views to pull that information to display on my taxonomy/term pages (yes om on D6 due to custom modules and upgrade problems)

Also ive made the term nodes appear on the parents term page in a node view.

* Sport
* -American Sports
* --Baseball
* --NFL
* -Football
* --England (etc)

This is in a View with tax depth of -1 (just show the immediate children) If i visit 'Sport' I only see my 'Sport' stuff and then below in the child term (node) View i see

* American Sports
* Football

Well in an ideal world thats all i see but because i am in 'Sport' I also see the node for the 'Sport' term that i am in.

* Sport
* American Sports
* Football

I want the -1 in depth but i dont want the '0' if that makes sense.

I have tried excluding the argument, like you do for for nodes with nid but it doesnt seem to work the same.

Its the same all the way down. If i go into 'American Sports' in my list of nodes that are referance (like that old drupal video from Bob (the christian) 'taxonomy on steroids) shows as-

* American Sports
* Baseball
* NFL

etc.

Aye so in a round about way i was wondering how to exclude...no how to only display, nodes of child terms (-1)

All help appreciated as its been annoying me for a while and ive been trying to sort it for ages.

thanks

# Answer
You could add an Node Nid as argument and check "Exclude the argument"

Select "Provide default argument" and select "Taxonomy Term ID from URL"

And then check "Load default argument from term page"

Thank should work for you.

Let me know if that helps.
> 2 votes

---
Tags: 6, views
---


title: content access alternative for drupal 7

text:
# Question
Title: content access alternative for drupal 7
I need exactly this module: http://drupal.org/project/content\_access which unfortunatly does not work anymore with drupal 7.18 and i dont want to search for the problem right now...

so is there any alternative? I need it to restrict users which are not in the role x to view certain sites.

# Answer
Simple Access module may come to your rescue. Do check it out.
> 3 votes

# Answer
You could try Context to see if it fits your needs.
> 0 votes

# Answer
Or just fix the problem in content\_access: http://drupal.org/node/1721758#comment-6676340

it does not fix the problem that content\_access is quite old and not regulary maintained but it fixes as long as it takes to migrate to another module
> 0 votes

---
Tags: 7, users
---


# Question
Title: Edit default views (books, basic page, etc)
I am using Views 3 with drupal 7. Views provide you some default views so you can edit them and customize them.

I want to do the same thing, for example, with book pages. I don't want to start from scratch with a new view. I just want to edit the default view of book pages.

Is there any way of editing it ? Or should I go directly to the code ? If so, which code is it ?

# Answer
> 0 votes
You can edit any existing view. Go to the views list and click on enable button that you would see on the view that you want to edit. Then you would get access to go inside the view and make your changes.

Hope that Helps.

Best Regards Shameem

---
Tags: views, nodes
---


title: Save as Draft functionality

text:
# Question
Title: Save as Draft functionality
I have created a content type, and while adding content under this content type I wanted to provide author, the facility to save this content as draft which he later can edit and publish, ideally, a button with "Save Draft" besides "Publish" button. Is there any drupal module that provides such functionality. I have gone through "Save Draft" module, but I don't understands it exact functionality, it is just providing a button with label, what exactly is is doing is not clear to me. Please help me if I am missing something.

Thanks for your time.

# Answer
What would the main use of this? If a content is kept as unpublished it is similar to saving the draft. It will not be visible to anyone else except the author and admin and any one else you have given permission to view the same. So this in itself is a good option. The save as draft module does the same thing it creates a button to uncheck or check the publish unpublish checkbox.

If you are looking for a workflow kind of feature then workflow module would be a better option. where you can define different workflow status and give different users permission to access the node in each workflow state.
> 3 votes

---
Tags: nodes
---


# Question
Title: What's $mask in file_scan_directory() to find all png files?
I try to find all png files in a directory inside my module using this code with no success:

```
$banks = file_scan_directory(drupal_get_path('module', 'order').'/images/gateways', '/^.*\png$/');

```

What mask should I used for getting all png files?

# Answer
The following mask should work for you:

`'/.*\.png$/'`
> 4 votes

---
Tags: 7, files
---


# Question
Title: Entity reference field to show translation of nodes
I have a content type "Genetic Test" which has an entity reference field (select list) where I can select nodes of the content type "Material". The Material nodes all have English set as their source language, but they are also translated in Dutch and French (entity translation).

The problem I'm having is, when I edit a node of the type "Genetic Test" with the interface language set to English, the select list shows the Material nodes, but when I change the interface language to Dutch or French the list is empty.

So my question is, how do I get the select list to show the Dutch or French node titles of the content type Material when I'm editing the Genetic Test node in said languages?

I hope I made myself clear a bit, English isn't my first language.

Thank you in advance for any help.

BTW: I'm working in Drupal 7.

# Answer
> 1 votes
I am not sure if you have already taken care of this but I think you would need to add title module as well since the title is not an entity by default and wont work with the entity translation module.

Another thing would to keep the language as neutral rather than keeping it English. Internally drupal would fetch the nodes with the lan

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


# Question
Title: If user requests page that is unpublished, gets permission denied and page dies with too many redirections
When users without permission to administer nodes want to see content that is unpublished, they get a redirect loop.
I would rather show them a "this content is not anymore available."

Why is the redirection loop happening?

# Answer
> 0 votes
The problem was, i had settings for user to redirect to user/login after permission check, so teh system somehow ended in loop. I set special node page for such occassions, and now everything went normal again. Gisle thanks for comment (which easily could be answer to question)

---
Tags: nodes
---


title: Print $Messages in node.tpl.php file

text:
# Question
Title: Print $Messages in node.tpl.php file
In Drupal 7, by default the `$messages` variable is printed in page.tpl.php.

Is there a way to print `$messages` in a node.tpl.php file (e.g. $node-mycontenttype.tpl.php).

Just putting `<?php print $messages; ?>` or `<?php print render($page['messages']); ?>` does not work.

There's a tutorial here for printing $messages in a block, but I would like to put it in my node.tpl.php file.

# Answer
> 31 votes
Actually, what you want to do is this:

```
function YOURTHEME_preprocess_page(&$variables) {
  // This disables message-printing on ALL page displays
  $variables['show_messages'] = FALSE;
}

function YOURTHEME_preprocess_node(&$variables) {
  $variables['messages'] = theme('status_messages');
}

```

How this works: Drupal core checks the value of show\_messages in theme\_process\_page. If it is TRUE (default) then it calls theme('status\_messages') as above, and effectively empties the messages storage, so calling the same theme function later will just return an empty string. However, if we set that variable to FALSE, this prevents said theme function from being called in process\_page, allowing us to get all the messages using the same theme function, in a template of our choosing.

# Answer
> 8 votes
The answer in How to display messages from a block separately from $messages in page.tpl.php which you referenced in your question is a fine way to go. Essentially you need something like this where YOURTHEME is the name of your theme and this function should be in your template.php. I haven't actually run this code but have a crack at it.

```
function YOURTHEME_preprocess_node(&$vars) {
  $output = '';
  foreach (drupal_get_messages(NULL, FALSE) as $type => $messages) {
    $output .= "<div class=\"messages $type\">\n";
    if (count($messages) > 1) {
      $output .= " <ul>\n";
      foreach ($messages as $message) {
        $output .= '  <li>' . $message . "</li>\n";
      }
      $output .= " </ul>\n";
    }
    else {
      $output .= $messages[0];
    }
    $output .= "</div>\n";
  }

  $vars['messages'] = $output;
}

```

You should then be able to output $messages in your node.tpl.php

---
Tags: theming
---


# Question
Title: Digest of suggested content based on user activity
Twitter acquired Summify that employs users' browsing activity, social trends, and other black magic to build email digests of suggested content that are very effective at drawing traffic back to their site.

I know in Drupal it should is relatively easy to build digest emails or suggest content blocks based on content or tags that the user follows, commented on or authored. I'm wondering how to take the next step towards calculating a relevancy score of suggested content based on the user's browsing on the site, and/or based on the activity of other active users (*trend makers*) on my site.

I'm asking for guidance to accomplish this using any or all of the following approaches:

* existing modules that uses browsing activity of authenticated user to score relevancy of a given piece of content. Or something like this.
* paid services that support Drupal and preferably have a module to interface easily with Drupal. One of Summify's competitors?
* could Apache Solr help in any way?

# Answer
> 0 votes
This wiki page on d.o has a review of some relevant contrib modules. http://groups.drupal.org/node/12347

---
Tags: 7
---


title: date ranges in view filter criteria

text:
# Question
Title: date ranges in view filter criteria
Drupal 7, Views node to be selected on date range.

I would like to have my view only return nodes that were created last month, no matter when I run the view this month. So as it's the middle of January, I want all nodes created in December last year, and next month I want all of January's

So the dates would be between first day of last month and the last day of last month.

In php I can use:

```
echo date('Y m d', strtotime('first day of last month'))

```

and

```
echo date('Y m d', strtotime('last day of last month'))

```

to get the correct date range.

However, in Drupal, the SQL does not create the correct ranges.

Viewing the view and sql logs at 11:55 on Jan 16th 2013 I see :

```
(node.created >= 1358337264-2678400

```

which works out as 2012-12-16 11:54:24, so it is a month ago, but not the first day of that month.

Any thoughts.

# Answer
> 1 votes
If possible, it might be beneficial to create a separate Date field for your content type. I often find that if I need to do custom filtering in a view, filtering by the date field instead of node post date is much easier. Being able to collect different granularity such as day and month can be helpful also.

# Answer
> 0 votes
The following seems to work. It must be a bug in views

first day of -2 month for the min

last day of -2 month for the max

# Answer
> 0 votes
Try to set your granularity to month and set the filter only to

equals = last month

This works for me.

Edit: Geoff Charlton is using node post date for filtering and not a date field. No granularity can be set on post date.

---
Tags: views, datetime
---


# Question
Title: Verifying that Webforms Hooks are firing
I'm new to Drupal but relatively proficient in PHP. I'm attempting to use the Webform module as a ticketing system. What I'd like to do is hook into the webform submission insert (hook\_webform\_submission\_insert) and create an object of type 'support\_ticket' each time a webform is saved. For now, I'm just trying to make sure that I'm hooking in properly, and it looks like I'm not. I'm using the code below in a template.php file of a custom module:

```
function pvfk_webform_submission_insert($node, $submission){
   drupal_set_message("IN Insert");

   //Declare a new StdObj

   $new_node = new StdObj();
   //Set the type
   $new_node->type='support_ticket';

   //Set the Title
   $new_node->title='NEW TICKET';

   //Set the body
   $new_node->body = 'TICKET BODY';

   //Set other content fields
   // $new_node->field_name[0]['value'];

   //Finally use functions to save, submit, and insert the new_node
   $new_node = node_save($new_node);
   node_submit($new_node);
   content_insert($new_node);

```

I've cleared my cache and created new webforms - but neither a new piece of content is created nor do I see the message. Am I missing something here?

# Answer
> 0 votes
Hook functions are run only when they are put inside a .module file.

So you should move your function into your pvfk.module file. Then visit your /admin/build/modules list so Drupal will refresh hooks list.

# Answer
> 0 votes
Moved it to the module as suggested by ermannob. Still wasn't firing, finally realized the prefix should have been pfvk and not pvfk...lesson learned.

---
Tags: hooks, webforms
---


# Question
Title: In Drupal 7, how to prevent *.php files from being upload to the /files folder when its required to have 777 permissions?
Hi one of the sites im working on just recently got comprised and a bunch of php files got upload somehow or someway into the files folder and started sending out alot of spam. I know during installation they ask for the files folder to be set at 777 permissions, but is there a way to prevent any php scripts from ever running in that directory if they were ever to get uploaded.

# Answer
> 9 votes
Drupal file uploads (in core or modules) should use file\_save\_upload which itself also calls file\_munge\_filename. Together those two functions should ensure that even if a file contains php it is not named in a way that a typically configured webserver would execute them. They also have protection against pl|py|cgi|asp|js files which can often contain code.

Since you seem to have .php files in that directory you have to start considering other ways the files might have landed there.

1. A vulnerability in a module that is allowing arbitrary file uploads
2. A vulnerability in some other code running on the server (outside of Drupal)
3. An insecure configuration (allowing users to run php) was used to download these files directly, avoiding Drupal's API.
4. An attack that used a virus to read stored passwords (e.g. out of Filezilla) on your local computer - these are more common than you'd think, but they usually don't target the files directory.

I suggest doing a few things:

* Check the permissions and ownership on the files, that will help you know which webserver user uploaded the files and from there you can hopefully narrow which code was used to upload them. Or if, you notice they are owned by a specific unix user other than the webserver then you should worry about that account.
* Check when the files were created - go through backups to find when they appeared or check the file timestamps (though on most OS you can only the file last modified and not the file created timestamp)
* Check the apache logs for all accesses to these files and see which IP is accessing them and when (especially the first date of access)
* Check the apache logs for other accesses to your site from those IPs and on those dates

These investigation steps are meant to help narrow down how the files were uploaded. Ideally you'll find some specific event (e.g. a POST to some url on your site that you investigate and see is a way to execute php, something like the CKeditor/FCKeditor module issue, then you can know that's how your site was exploited.

If you *do* find out how the site was exploited, please report it as a security issue: http://drupal.org/node/101494

---
Tags: security, advertising, files
---


title: How to use views argument in drupal?

text:
# Question
Title: How to use views argument in drupal?
I am using views arguments for filtering jobs list.

I am taking state as argument.

Previously, state argument was accepting single value and it was filtering jobs correctly.

Now I made state field multivalued it means it accepts multiple states as input separated by comma.

here is my code for assigning arguments

```
$arg[0]=$filters['title_nodes'];
$arg[1]=$filters['company'];
$arg[2]=$filters['city'];
$arg[3]=$filters['state'];
$arg[4]=$filters['zip'];
$arg[5]=$filters['types'];
$arg[6]=$filters['categories'];
$arg[7]=$filters['industries'];
$arg[8]=$filters['beverages'];
$arg[9]=$filters['user'];

```

previously, `$arg[3]=$filters['state'];` this `$arg[3]` is filled with single state as New York etc. and for single value filter was working fine.

now, `$arg[3]=$filters['state'];` this argument is containing multiple states.

because of multiple states jobs are not getting filtered.

now suppose we entered 3 states, then in `$arg[3]` 3 states get stored and for each job,

argument checks whether there is any job who is having all 3 states in single job which is not possible.

Now how can I make this filter works for multiple states??

Thanks in advance.

any help will be appreciated.

# Answer
> 0 votes
If this is a contextual filter, you can specify `AND` or `OR` logic for the multi-values.

Views says:

> Allow multiple values
>
> If selected, users can enter multiple values in the form of 1+2+3 (for OR) or 1,2,3 (for AND).

So your querstring would have `&state=CA+NY+TX` to `OR` California, New York, and Texas states.

---
Tags: views
---


# Question
Title: Migrated data via XML doesn't import to nodes
Link to my previous question, which has info on data structure etc.

Now I've gotten my XML read into Migrate and content type and fields set up right (I think), but now I can't get the nodes to save. The import has the correct number of nodes, but they don't ever get imported. The wine examples in the documentation didn't say anything about using prepareRow() or anything when you are using XML. Where are my nodes? Can I pull out that data with Views even if nodes don't import? My end use for this is to arrange everything with Views.

**EDIT**

Here is my class:

```
<?php

class ItemNodeMigration extends XMLMigration {
public function __construct() {
parent::__construct(MigrateGroup::getInstance('itemnode', array('default')));
$this->description = t('Grab data in XML');

// There isn't a consistent way to automatically identify appropriate "fields"
// from an XML feed, so we pass an explicit list of source fields
$fields = array(
   'id' => 'ID',
   'type' => t('Description of producer'),
   'Owner' => t('Owner'),
   'Text' => t('Text'),
   'modifiedAt' => 'Date last changed',
);

$this->map = new MigrateSQLMap($this->machineName,
  array(
    'id' => array(
      'type' => 'varchar',
      'length' => 6,
      'not null' => TRUE,
    )
  ),
  MigrateDestinationNode::getKeySchema()
);

// This can also be an URL instead of a file path.
$xml_folder = 'http://example.com/item/';
$list_url = 'http://example.com/CompanyID/Items.xml';
// Each ID retrieved from the list URL will be plugged into :id in the
// item URL to fetch the specific objects.
$item_url = $xml_folder . ':id/desc.xml';

$this->source = new MigrateSourceList(new MigrateListXML($list_url),
  new MigrateItemXML($item_url), $fields);

$this->destination = new MigrateDestinationNode('migrate_module_itemnode');

$this->addFieldMapping('id', 'id')
     ->xpath('/@id');
$this->addFieldMapping('body', 'Text')
     ->xpath('/Text');
$this->addFieldMapping('type', 'type')
     ->xpath('/@type');
$this->addFieldMapping('owner', 'Owner')
     ->xpath('/@Owner');
$this->addFieldMapping('created', 'modifiedAt')
     ->xpath('/@modifiedAt');

}
}

```

**EDIT2:** I have determined that my problem lies here:

```
    $this->map = new MigrateSQLMap($this->machineName,
         array(
                 'id' => array(
                 'type' => 'varchar',
                 'length' => 6,
                 'not null' => TRUE,
               )
         ),
         MigrateDestinationNode::getKeySchema()
    );

```

This isn't correctly mapping to my source's ID, which lies at Item/@id. How can I correct this?

# Answer
> 1 votes
As per this issue -- I think you need to tell `MigrateSourceList` where your item id's are, as an example (from isssue):

```
    // As with MigrateSourceMultiItems, this applies where there is not a separate
    // list of IDs to process - the source XML file is entirely self-contained.
    // For the ID path, and xpath for each component, we can use the full xpath
    // syntax as usual. However, the syntax to select the elements that correspond
    // to objects to import is more limited. It must be a fully-qualified path
    // to the element (i.e., /producers/producer rather than just //producer).
//  $item_xpath = '/producers/producer';  // relative to document
    $item_xpath = '/FMPXMLRESULT/RESULTSET/ROW';
//  $item_ID_xpath = 'sourceid';          // relative to item_xpath
    $item_ID_xpath = 'COL[1]/DATA';

    $this->source = new MigrateSourceXML($items_url, $item_xpath, $item_ID_xpath,
      $fields);

```

You only have 3 values in your constructor. I haven't done alot with migrating XML (just CSV and SQL). This issue is for D7 -- I think it should apply to D6.

---
Tags: views, nodes, 6, migrations
---


# Question
Title: How to make a complex grid layout with the Omega theme?
How do I make a complex grid layout with the Omega theme where regions can be embedded in regions? I included an image of how I want the page layout to be set. Right now I'm thinking that I will use the CSS property in the Views UI to manually set the grid-\[columns\] and alpha or omega properties of the Views block. Is there a better way of doing this so the code is in a logical place and not a hack?

# Answer
> 2 votes
For something like this, I will simply use the Block Class module and for the blocks I'm placing inside a region, add a grid-X and alpha/omega appropriate classes as needed.

I've never found the reason (even in really advanced layouts/designs/grids) to do anything more than that...

# Answer
> 0 votes
Use the views\_column\_class module (http://drupal.org/project/views\_column\_class).

This lets you add alpha, omega and other settings to views so that they don't break your grid.

---
Tags: theming
---


# Question
Title: What module to edit theme css in my drupal site
Is there a module that allows me to edit the theme css files within the drupal admin?

# Answer
Live CSS is the module you are looking for:

> Edit CSS live within the page, and save the changes back to any css file if you have write access.
>
> Additionally, this module enables the ability to render and perform live editing of LESS stylesheets, included just like css files. Users without the live editing permission will still see properly rendered LESS displayed.
> 1 votes

---
Tags: 7, theming
---


title: How do I Send HTML Emails via Rules?

text:
# Question
Title: How do I Send HTML Emails via Rules?
The Rules module provides a value field for the "send mail" action. Since I also have the PHP filter module, I have the ability to add PHP code there. I want to add HTML formatting to my email. Is there a more "correct/Drupal way" of sending HTML based emails via rules other than pasting my code there?

The pet module looks like a decent candidate, but has low-ish usage numbers.

# Answer
> 3 votes
Mimemail or HTMLMail both look like they support Rules.

---
Tags: rules, emails
---


# Question
Title: Is it possible to find which user created an account?
I currently have a Drupal 7 site set up to allow users with the *Doctor* role to create users with the *Patient* role, via admin/people/create.

Does Drupal store data about which user created a specific account? If the answer is *yes*, how can I display this information in a view?

# Answer
You have to create a custom module for this.

* First you have to add a user field here *admin/config/people/accounts/fields*. Add a field that will check whether the user has been created by user with role "doctor". A *boolean* field would suffice. Mark the field as **non-mandatory**
* Create a custom module. This module will provide an interface that only the users with role "doctor" can access. In the interface provide a button, clicking that button will create user with role "patient", also flag the field you created above.
* Now in views create a page or block that will display the users, in the filter criteria of the view check whether the boolean field is flagged for that user.
> 0 votes

# Answer
On admin/reports/dblog, if you filter the log messages by type, and select "user" as log type, you see who created a user.

* The "Message" column will contain a message starting with "New User"
* The "User" column will contain a link to the user account of who created the user, or it will not contain a link when the user has not been created from a logged-in user

>

>

The same is true for who deleted a user account, as visible in the first screenshot.
> 0 votes

---
Tags: 7, users
---


# Question
Title: Multiple page versions and caching for anonymous users
Is there a standard, or well accepted, method for allowing page caching when you have multiple versions of page, that don't involve using Page Manager?

For example, if you render out different versions of a page based on IP address, User-Agent, etc., page caching renders the code-based decisions useless, so some users may see the wrong pages.

The only method that I know about involves adding code to settings.php to alter `$_SERVER['REQUEST_URI']` to make the code-based decision and then to tack on extra variables, but gets messy.

# Answer
$\_SERVER\['REQUEST\_URI'\] is the simplest way. The other option is to modify the key used in the cache. There is a 6.x memcache patch that I've been using http://drupal.org/node/942914

The latest version of http://drupal.org/project/authcache might be able to do it.
> 1 votes

---
Tags: caching
---


title: Localize a date

text:
# Question
Title: Localize a date
How can I localize a date? I use PHP to output a custom date format, and I want to translate the components, such as the name of the month.

I am using the following code. Is there a better code I should use with Drupal?

```
global $language;
if ($language->language == 'ar') {
  setlocale(LC_TIME, 'ar_CA.UTF-8');
  echo strftime("%B %e, %G");
}
else {
  setlocale(LC_TIME, 'en_CA.UTF-8');
  print(date("l,F j, Y");
}

```

# Answer
Using format\_date(), the following format character are localized by Drupal:

* %A (In English, AM and PM)
* %a (am, pm)
* %e (e.g. UTC, Atlantic/Azores)
* %D (e.g. Mon, Sun)
* %l (e.g. Monday, Sunday)
* %M (e.g. Jan, Dec)
* %T (e.g. EST, MDT)
* %F (e.g. January, December)

Notice also that on admin/config/regional/date-time/locale, it is possible to change the long/medium/short formats used from `format_date()`.

Clicking on the "edit" link, you can change those formats for every language.

Instead of the code you are using, you should simply use:

```
$date_str = format_date(time(), 'short');  // the short format, such as 01/16/2013 - 20:37

```

```
$date_str = format_date(time(), 'medium');  // the medium format, such as Wed, 01/16/2013 - 20:37

```

```
$date_str = format_date(time(), 'long');  // the long format, such as Wednesday, January 16, 2013 - 20:37

```

The effective format used for the long, short, and medium formats are the ones set on admin/config/regional/date-time/locale for the language currently used to display the page.
> 5 votes

---
Tags: datetime, i18n-l10n
---


# Question
Title: Is a content type or profile a better choice?
I am working on a new site where I want to show information for art galleries, artists, museums, public art installations and art education.

I understand both the content type and profile differences but can't decide which is better in the long run. I know the artists will need a profile and I would like to give the rest of the "types" the ability to edit their own content if they desire.

I have done a lot of research and can't seem to find an answer on how to link a content type entry with a user profile and am leaning toward profiles for everybody. However, this has drawbacks because of need for authentication info (which I don't know) as I create the profile.

Am I missing a magic module or some other clue?

# Answer
> 0 votes
You can use a profile, or a content type to expose information about a person. The difference between them is that a profile is always about an existing user account on the site.
For example, if your site is about emergent artists that will have a user account on your site, then a profile can be used from those artists to expose information about themselves. If your site is about famous past artists, then a content type can be used to expose information about them.

The other difference is that profiles are usually created from the users who want to add information to their own account. (The other alternative could be a user with the permission to administer users that adds a profile for another user.)
With nodes, out of the box, it's more difficult to limit who can create a node associated to the account of another user.

As for linking content types to a user profile, it is possible to use the Views module to show a page that, for example, on user/%user/profile shows those specific nodes that contain information about a user.

---
Tags: nodes, users
---


# Question
Title: Form API: Form field not being translated
I'm implementing a gender field in a custom registration form.

The gender field also exists as a user field, so I'd like to call the label and allowed values from the existing instance. I've written it as a conditional override just in case...:

```
$form['gender'] = array(
    '#title' => t('Gender'),
    '#type' => 'radios',
    '#options' => array('female' => t('Female'), 'male' => t('Male')),
    '#required' => TRUE,
);
if($field = field_info_field('field_gender')) {
    $form['gender']['#options'] = $field['settings']['allowed_values'];
    $info = field_info_instance('user', 'field_gender', 'user');
    $form['gender']['#title'] = t($info['label']);
}

```

Everything's working great, except for the multilingual part: despite having translated the field instance at the admin account settings using i18n, the extracted options and title of the existing field are not being translated upon changing the front-end language. They DO get translated however when visiting the user account page in a different language.

It seems my custom form doesn't send its strings through i18n...?

Can anyone point me out the pitfall please?

Thanks

**UPDATE**

I used

```
$func = function($val) { return t($val); };
$form['gender']['#options'] = array_map($func, $field['settings']['allowed_values']);

```

as suggested by Shameem to translate the options. But now it seems t() is fetching translations from the Locale module repository. How to direct t() to fetch it from i18n?

# Answer
> 0 votes
I managed to set up a working solution. Could somebody possibly point out please if it is actually good practice to use those i18n functions per direct in the code?

```
    $form['gender'] = array(
    '#title' => t('Gender'),
    '#type' => 'radios',
    '#options' => array('female' => t('Female'), 'male' => t('Male')),
    '#required' => TRUE,
);
if($field = field_info_field('field_gender')) {
    $instance = field_info_instance('user', 'field_gender', 'user');
    $form['gender']['#title'] =
        module_exists('i18n_field') ? i18n_field_translate_property($instance, 'label') : t($instance['label']);
    // Define this t() function for the array_map just in case i18n_field isn't enabled.
    $func = function($val) {
        return t($val);
    };
    $form['gender']['#options'] =
        module_exists('i18n_field') ? i18n_field_translate_allowed_values($field) : array_map($func, $field['settings']['allowed_values']);
}

```

# Answer
> 0 votes
the field options are not going through the t function.

you would need to take each value from the following array and make it go through the t() function

$field\['settings'\]\['allowed\_values'\];

and please check that $info\['label'\] is a plain text and not an array.

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


# Question
Title: Filter Content Cronologically Based on Current Month
I'm working on a project where the user wants to display upcoming shows. They want to display these shows in three blocks. Each block would list shows for the nearest month, in order.

For example, if the the current month is January, and the upcoming shows were in February, April and June each block would list the shows in the month. (Block 1 = February, Block 2 = April, Block 3 = June)

I was originally thinking of creating three block views. I would filter the first view's date field so that it is equal to the month, the second view's date field so that it is one more than the month, and the third view's date field so that it is two more than the month.

However, since the client's shows are not every month, the shows would only appear until they fit that specific filter. The example above would not show any upcoming shows until it was February, and would leave the second and third columns blank.

All I could think of was to create a block view for each month, but the client would have to arrange them every month.

# Answer
> 0 votes
I can't think of a 'clean' way of doing it within the Drupal interface, but it should be doable by using a template. An override of views-view-table.tpl.php (or the list version of that) and then test the dates as they come through. It would be a little tricky to know which block has been previously put up (and therefore where to start the next block) but I think it is possible.

In more detail.

* Create a view with the listing that you want (for all months).
* Create three blocks within that view (they can be the same).
* Using the Theme Information tab, find the name of the template that handles the rendering of the rows.
* Put code in that template to only take a months worth of dates at a time.
* Set a flag that 'Feb' is done, so next iteration will be 'Apr'.

---
Tags: views, datetime
---


title: Ubercart-based POS / Kiosk

text:
# Question
Title: Ubercart-based POS / Kiosk
I have a Drupal 6/Ubercart 2 website with a desktop-specific theme. I intend to create a POS/Kiosk theme for the site, to be used when the site is accessed via a tablet (and possibly via smartphone). That theme would be bare-bones... a couple of Views showing products, probably the AJAX cart module, and very little informational pages. The POS concept would involve a kiosk with an ipad that public customers in a retail location would be able to use to place orders right then and there.

I suppose I just want to see if anyone out there has done a setup like this, or whether anyone has any ideas on things to avoid, issues that may be encountered, etc. Ideally, the end result of this port would be a recipe of sorts, that everyone else could use for similar situations.

So far, potential issues I have come up with are:

1. Must auto-log out users upon successful order completion. Is there a way to do this in Drupal/Ubercart via stock settings or an existing module?
2. Some type of auto- or manual-logout for when a customer walks away from the POS without completing the order (so that the "next person up" can start with an empty cart, or can at least easily clear the cart and start their own shopping experience). I suppose this can be accomplished with a large "Click here to start a new session" button that would basically be a "rebranded" log out button...
3. ...I'm hoping other viewers of this question might be able to point out any other issues I may not have thoughts of yet.

Looking forward to any input anyone out there may have!

# Answer
> 0 votes
I'm working on a similar problem. I have an ubercart based shopping system that a customer wants to have available on a public computer in his store. We need to change themes, branding etc and auto-logout users. His users will also be ordering from home, so we have to identify that particular computer and change the behavior and look of the site when we know they are ordering from the in-store kiosk.

Kiosk module that may help

*This module allows an administrator to put selected computers into "Kiosk Mode". "Kiosk mode" simply means that a given computer will have an extra flag set for template files, which allows a themer to exclude certain page elements, such as off-site navigation.*

I'm installing this on my test server and we'll see how well it goes. I'm hoping to figure out how to get that variable (if $kiosk) into ubercart checkout conditions and trigger some actions based on it. It seems like themeing is pretty easy with this module but as for changing behavior, I'm not super sure how it will work.

Please let me know if you find any magic bullets as we're both trying to do a similar thing and i'd be great to share a solution.

UPDATE: I've been working with kiosk mode module (drupal 7 version) for a bit and have been able to create custom rules by calling the kiosk\_is\_kiosk function defined in the module. Simply use custom php condition in rules with this code:

```
 return kiosk_is_kiosk();

```

And you can have different workflows for kiosk terminals than for regular on-line users. So for example, once an order is finished the kiosk will log out the user, but not a person using the same site from the home.

-Zachary

---
Tags: ajax, ubercart
---


# Question
Title: Easy noob custom PHP question in views... Editing recent news stories view
```
<?php
$href = $data->node_data_field_news_external_link_field_news_external_link_value;
if($href == ''){
    $href = 'node/' . $data->nid;
    $href = url($href, array('absolute' => TRUE));
}
echo '<h3><a href="' . $href . '">' . $data->node_title . ' (' . date("F j, Y", $data->node_created) . ')</a></h3>';
?>

```

I'm sorry but I've searched for something that can help me with this. I know it is simple, but I've already spent hours while trying to teach myself PHP in the process. I hope that this will take someone 30 secs and allow me to keep learning.

Anyways... I have an attribute (field\_successdate) in the News content type that I'm trying to use. It's a date of when the News happened. In the view, the customPHP field uses the node's created date and appends it to the node's title to create a link to the object. I'm trying to replace the node's created date with my field\_successdate. I've added it to the fields and then referencing it in the customPHP code, but no luck. Do I have to add the field\_successdate to the fields in the view and then add an argument? (I've tried that too)

Can any one help?

Thanks!!!

# Answer
It's probably easier to add the field to the field list (`field_successdate`). Then use Views `rewrite` display option to write the `node: title` link to include the date from `field_successdate`.

The rewrite will require the Token module to be enabled. rewrite the title as: `[node:title] [node:field_successdate]`

Be sure you hide `field_successdate` if you dont want it literally shown in the view by itself somewhere. You may or may not need to move `field_successdate` to the top of the field list so its gets made into a Token to be used in the title properly.

I'd make a pic of this .... but that'd take like minutes....
> 0 votes

---
Tags: views, entities
---


# Question
Title: how to use a relative path with form API image_button?
I'm building a module in D6 that renders a form to a custom template (also within the mod). I need to use an image for the submit button, but I'm having trouble with the path to the image.

```
$form['submit'] = array(
'#type' => 'image_button',
'#src'  => 'sites/all/modules/custom/mymodule/images/show-my-score-button.png',
'#value' => t('Show My Score'),
'#submit' => array('mymodule_submit'),
'#redirect' => '',

```

);

This is the code I have in place, and it is functional. However I can't use the path as it's shown since I don't know where my module will end up.

How can I make the image show in my module while using an image path that is relative to my module? I'd love to have something like "/images/show-my-score-button.png" but it doesn't work.

# Answer
> 1 votes
You need to define an absolute path, a relative path won't work. But you can use the `drupal_get_path()` method to retrieve the path to your module, so you don't have to worry about where it will end up in the filesystem.

For example:

```
$image_path = drupal_get_path('module', 'mymodule') . '/images/show-my-score-button.png';

```

---
Tags: 6, theming
---


title: Comments for each image in a gallery

text:
# Question
Title: Comments for each image in a gallery
I'm trying to setup a gallery where users can comment under each image. What is the best way to do this? Thank you.

# Answer
Here is a simple setup:

You need two content types:

* Gallery
* Image

The gallery content type will contain a body (gallery description) field.

The image content type will contain:

The reference field will reference a gallery content type.
> 1 votes

---
Tags: 7, comments, media
---


# Question
Title: Pre-populate default values into a form to edit a new entity
In a Drupal 7 site, I have created a new entity called "atomyx\_portal\_metadata". This entity works great in all respects. I allow people to define their own entity types (much as you can create your own node types).

While allowing someone to fill out a form to enter values for such an entity type (much like filling out the form for an article for example), I use the following code:

```
// Get the metadata blob for this job
$metadata = atomyx_portal_metadata_load($job->mid);

// Save the metadata entity in our form array so we can pick it up in the validation routine
$form['metadata'] = array(
    '#type' => 'value',
    '#value' => $metadata,
);

// Add form elements for all attached fields
field_attach_form('atomyx_portal_metadata', $metadata, $form['container'], $form_state );

```

The "field\_attach\_form" call correctly adds all necessary form elements for editing the form, and I can validate and save those values correctly in the database afterwards. However, the form elements do not contain the default values defined in the field definition and I don't seem to be able to figure out how to correctly fill in the default values of all fields into the form.

I assume I could do this by looping over all fields myself, and trying to figure out with help of the field api what the default value for that field in the given entity-type is, but that seems like a very ... un-field-api-ish way to do it.

Is there something I'm missing? Is there a call in the field attach api that would allow me to have the fields filled in with default values correctly?

Any and all hints greatly appreciated!

# Answer
> 0 votes
I think I found what the problem was. From the documentation and Drupal code it became clear that what I did in the form ought to be correct: field\_attach\_form *should* properly load all fields.

Which led to the fact that it must be the creation of the entity that is incorrect and not the actual form loading of the entity fields.

While examining the entity class I use, I came to the conclusion that the example code I used to build this entity wasn't complete. Upon first creating an instance of the entity, the code should not only save the entity data itself, but it should also call field\_attach\_insert. Just as it should call field\_attach\_update whenever the metadata entity exists already but is saved again (updated).

Upon adding this, the field\_attach\_form call now "magically" loaded the proper default values into the form.

Eureka.

---
Tags: 7, entities
---


# Question
Title: how to use cookie to protect other node pages in Drupal
some bots are grabbing my site's content everyday,I confirm if I set cookie protection the bots will not work again.

My question is how to use cookie to protect my content? if someone has no cookie then he can't go to next page.

# Answer
> 0 votes
Sounds like a case for user authentication?

The problem is the first page request will never have a server-side set cookie as it will be set on the subsequent request and you don't want to deny access on your homepage.

You could set the cookie with javascript, but then you risk blocking users with js disabled.

Requiring user login would be the easiest solution.

---
Tags: cookies
---


# Question
Title: Allow users to publish content to their profiles
I want my users to be able to upload content to their own profiles. then when people view their profile they see a list of links which lead to what the user has uploaded.

Is this possible?

# Answer
You can create a block view (Optional with a filter to show the type of content you want to show) Add the Content title fields and any other field you want to add.

Then You have to set a Contextual Filter of the type Content Author. Select the "provide default" option and from the type dropdown select user id from url.

Place this block in the user profile page.
> 3 votes

---
Tags: users
---


title: Registration database - Wiki

text:
# Question
Title: Registration database - Wiki
I am looking for a good theme or module in which users can set up their own profiles on the page. I want them to fill out a form, so that their profile answers my questions, and I want to be able to approve their page first. Also, I would like to be able to grant other people admin rights to just some of the (geographic) profile pages; so that they may approve them. Is this possible?

In addition, I would need the answers from the forms to be transferred to a database so that people can find the profiles with specific answers. Also the profiles (after checking specific tags should be placed on the pages of these tags, when approved.

All quite complex and I am not sure if Drupal can help?

# Answer
> 2 votes
Everything you mentioned in the post is achievable by Drupal.

But not with just one module or a theme. Each functionality has its own module

1) Theme There are lots of themes available in drupal download section which you can go through and decide on the theme that matches your requirement or you could build one on your own.

2) The profile page with in the Drupal has option to add the required fields. But if you want to extent it you can go for http://drupal.org/project/profile2

3) These additional two modules can show the percentage of the profile completed and if the profile needs to be completed. http://drupal.org/project/pcp and http://drupal.org/project/complete\_profile

4) User approval is in build in Drupal.

5) To achieve the admin type you are looking there are two options one is organic groups and make each geographic location a group and give group admins the right to admin the members of that group. Another option would be to create a user role per geographic location and have the user select the role during the registration process using the autoassign role module and the use http://drupal.org/project/administerusersbyrole module to assign admin rights per role.

6) Once you use profile2 each profile is a content with in drupal and you can do all the searching that is default to drupal or you could also create views with exposed filter to do the searching on specific fields.

7) You could add a tag field to the profile and create a view to display the profiles with the tags as the argument to the view page.

---
Tags: webforms, users
---


# Question
Title: Views Accordion not working when other Jquery plugins are used
I am having problem with Views Accordion when I am using Views Accordion and the Isotope Jquery plugin both on same page.

Isotope Jquery plugin seems to be working fine, but the Views Accordion looks crashed no CSS and functionality is working.

# Answer
There is a module called http://drupal.org/project/views\_isotope

Using that would be better as it would play well with the rest of the js.

The js behavior with in drupal 7 has changed a bit and placing the js directly might not work well in many cases.
> 1 votes

---
Tags: 7, views, javascript, navigation
---


# Question
Title: Custom block displayed via Contexts not being shown to anonymous users
I am running a Drupal 6 site and I have created a custom block to display a banner ad. The site uses Contexts to display blocks. However I noticed that the block was not getting displayed for anonymous users for some reasons event though I have not set it that way in the reactions. It is getting displayed for user 1 though.

Anyone have any ideas regarding the cause for this scenario?

Also the current block does not have a title? I doubt that but it could be the reason for it not displaying for anonymous users.

# Answer
> 1 votes
I found the source of the problem.

I had used hook\_block to create the block. I had specified BLOCK\_CACHE\_GLOBAL for the cache settings of the block which means the blocks were cached the same way irrespective of the page or the user.

I changed the cache setting to BLOCK\_CACHE\_PER\_PAGE and it solved the problem. (The block hosted an openx ad which was only displayed on pages with certain taxonomy terms.)

---
Tags: 6, blocks
---


# Question
Title: Undefined offset: 1 in gcm_action_send_message()
I am using Google Cloud Messaging for one of my projects. I think I have configured everything correctly. I am getting the following error when I tried to send some message.

> Notice: Undefined offset: 1 in `gcm_action_send_message()`

I can't find any information in the module documentation.

# Answer
I found the answer by looking the code used from the module.

```
function gcm_action_send_message($tokens, $keyValues, $delay_while_idle, $time_to_live, $collapse_key) {

    $gcm_message = array();
    foreach (explode(",", $keyValues) as $keyValue) {
      $temp = explode("=", $keyValue);
      $key = $temp[0];
      $value = $temp[1];
      if (isset($key) && isset($value)) {
        $gcm_message[$key] = $value;
      }
    }
    gcm_send_message(array_unique(explode(',', $tokens)), $gcm_message, $delay_while_idle, $time_to_live, $collapse_key);
}

```

So we need to use for key-values a value like 0=\[site:name\], 1=\[site:mail\].
> 4 votes

---
Tags: 6
---


title: Triggering the Feed Import module

text:
# Question
Title: Triggering the Feed Import module
I have a `Drupal 7` website that is intend to be fed by a `JSON` file. This file, is actually processed and updated by a `ETL` tool that runs periodically (each 3 hours by example).

Once my `ETL` tool has processed the output JSON file, I need a way to tell the Drupal `Feeds` module to start the import.

Is it possible ? Or do I need to do this with `CRON` ?

Ideally, this job would be trigged by a specific URL call (just like the CRON can be called manually by visiting a specific url).

# Answer
Based on @Gaydabura clues, I've created a module. Here's the answer :

**1. use hook\_menu to define you own path**

```
function toot_menu() {
  $items = array();
  $items['toot/import'] = array(
    'page callback' => 'toot_callback',
    'title' => 'Import tool',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK
  );
  return $items;
}

```

**2. write function using docs to parse your data**

```
function toot_callback($key = '') {
  if ($key != 'defined_key') {
    return t('Unauthorized access');
  }
  else {
    $myFeed = feeds_source('feed_unique_id');
    while (FEEDS_BATCH_COMPLETE != $myFeed->import());
    return t('Import successfull');
  }
}

```
> 3 votes

# Answer
For triggering a feeds importer programmatically -

1) Load the feeds source using feeds\_source() \- by passing argument importer id \[it is the machine name of the importer; you can find it in the table 'feeds\_source'\]

```
$feeds_source = feeds_source([importer_id]);

```

2) Set up the configuration -

```
$feeds_config = $feeds_source->getConfigFor($feeds_source->importer->fetcher);
$feeds_config['source'] = $url;//url of file | url of site

```

3) Set configurations to feeds source

```
$feeds_source->setConfigFor($feeds_source->importer->fetcher, $feeds_config);
$feeds_source->save();

```

4) Start the import

```
$feeds_source->startImport();

```

I have implemented this for fetching data from url. Haven't tried with file, but this should work with may be some minor changes in the config part.

Else I think you can trigger the feeds using cron too. Elysia Cron is a great module which gives 'fine grain control over each task and several ways to add custom cron jobs to your site'.

I hope this is of help.
> 2 votes

---
Tags: 7, feeds, cron, rules
---


title: menus as a block in drupal7

text:
# Question
Title: menus as a block in drupal7
i have created a navigation menu like

home, services, about us, so on and then contact us .. each parent has many child and their own child . it was created sucessfully.

Now what i want to show menu navigation on left side bar expect home and contact us . but all menu is display as a header too.

i want to show only parent item. when i click on parent then it's child automatically open.

Is there is any module for this. Or their is any other way to achieve this

Thanks a lot

# Answer
> 1 votes
Have you tried Dhtml Menu?

> Ordinarily in Drupal, in order to see the sub-items in a menu, you need to click the link of this item and wait for a full page load. After enabling DHTML Menu, clicking a menu link once will expand it to reveal its sub-items without reloading the page. A double-click on the item will load the page normally. Additionally, a cookie stores which menus are open and which are closed, so that the state of the menus remain consistent as you navigate around the site.

# Answer
> 0 votes
Try using Megamenu module. Here is a quote about it (from the module's project page):

> Mega menus are a type of drop-down, which seeks to overcome some of the usability drawbacks to traditional style drop-downs. Primarily, mega menus have two advantages:
>
> 1. The information architecture of your navigation is made clearer and is visible all at once
> 2. The amount of clicking, searching, and navigating is reduced
>
> This module allows you to build mega menus by leveraging jQuery and the existing Drupal menu system. Megamenu takes a Drupal menu that is 3 levels deep, and converts it into a categorized 3-level mega menu, which is placed into your site as a block.

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


# Question
Title: 7 - Sorting in a view seems to not be alphabetical?
I've set up a Drupal 7.18 site with Views 7.x.35. I've created a content type "Course" and included it's content type as an entity reference in a "Product" content type.

I have a view for listing courses and it sorts alphabetically just fine. However, I have another view products, with a course column, and its alphabetical sort is not alphabetical. I would like advice on 1) why this is so and 2) how to make it alphabetical.

Things I've tried: * Clearing caches via Admin section * Removing all other sort criteria from view * Removing and re-adding the field

I am attaching an image depicting the behavior and another showing the view setup. I'm happy to provide more detail as appropriate. TIA!

Here's links to the photos (sigh, first post, lack 10 points to post images) Error behavior: http://www.flickr.com/photos/24745111@N00/8389442182/in/photostream

View admin pane: http://www.flickr.com/photos/24745111@N00/8389442184/in/photostream

# Answer
Since the course field is an entity reference the sort would be working on the node id and not the node name. can you check this.

What you could do is add the node title instead of the node entity field. and create a relationship to the node title to the entity reference field. Now the sort should work properly.

EDIT : Adding the steps mentioned in comment

1. Add Content:Title to the view.
2. Go to advanced, add a relationship to the content type.
3. Go back to that title field configuration and select the relationship from the drop down.
4. Go the the format settings and make the new field sortable.
> 2 votes

---
Tags: views
---


# Question
Title: Best way to trigger multiple Feeds importers?
I have three importers set up and working fine; all creating nodes from an XML file using HTTP fetcher.

The created nodes reference each other (using Node Reference), so the importers must run in a certain order.

To automate this, I'm not using the periodic import option as it won't keep things in sync. Instead, I created a simple Rules action:

```
<?php
function my_import_action_import($importer_name, $feeds_node) {
  while (FEEDS_BATCH_COMPLETE != feeds_source($importer_name, $feeds_node)->import());
}
?>

```

Then I created a rule that runs on cron with three actions (one to trigger each importer).

As far as I can tell, it seems to work. But I get a warning notice that doesn't happen when I run the importers manually:

> Notice: Undefined offset: 2 in references\_feeds\_set\_target() (line 203 of /home/mysites/drupal7/sites/default/modules/references/references.feeds.inc).

I also have a feeling that Feeds was meant to use job scheduler for a reason, and not run on cron in this way?

Thanks!

# Answer
I had almost the exact same need where I had to import data from xml files usinf HTTP fetcher. I had 5 importers and had to run one after the other.

I declared a function that triggered the importers programmatically one after the other.

For triggering each importer this is what I did -

```
$feeds_source = feeds_source($importer_id);
$feeds_config = $feeds_source->getConfigFor($feeds_source->importer->fetcher);
$feeds_config['source'] = $url;
$feeds_source->setConfigFor($feeds_source->importer->fetcher, $feeds_config);
$feeds_source->save();
$feeds_source->startImport();

```

where $importer\_id is the machine name of the importer; you can find it in the table 'feeds\_source' and $url is the url where you have your xml file. feeds\_source()

And there's this awesome cron module - Elysia Cron which gives in its own words 'a fine grain control over each task and several ways to add custom cron jobs to your site'.

With Elysia's hook\_cronapi() you can set up a cron job which calls your function at your set up intervals.

Though it seems really a long since your question.....I hope this is of some help.
> 5 votes

---
Tags: 7, rules, feeds, cron
---


title: Use JQuery Cycle with custom Javascript

text:
# Question
Title: Use JQuery Cycle with custom Javascript
I have build a view with a HTML-list were all my images are listed. Goal is to create a JQuery Cycle with those images, but for some reason, my custom Javascript isn't working...

Here is the HTML generated by Drupal:

```
<div class="homepage-slider">
  <ul>
    <li class="views-row views-row-1 views-row-odd -views-row-first>
      <div class="views-field views-field-field-front-slider-image">
        <div class="field-content">
          <img src="image.jpg" />
        </div>
      </div>
    </li>
    <li class="views-row views-row-2 views-row-even>
      <div class="views-field views-field-field-front-slider-image">
        <div class="field-content">
          <img src="image.jpg" />
        </div>
      </div>
    </li>
    <li class="views-row views-row-3 views-row-odd -views-row-last>
      <div class="views-field views-field-field-front-slider-image">
        <div class="field-content">
          <img src="image.jpg" />
        </div>
      </div>
    </li>
  </ul>
</div>

```

And here is my custom Javascript I wrote:

```
(function ($) {
    Drupal.behaviors.initFrontPageSlider = {
        attach: function(context, settings) {
            $('body').once('initFrontPageSlider', function() {
                $('.homepage-slider').cycle({
                    fx: 'fade'
                });
            });
        }
    }
}(jQuery));

```

But for some reason, my image-list isn't picking up my javascript. What's missing on this?

# Answer
If you want to cycle the `<li>`'s then you need to call `.cycle()` on the `<ul>` element. At the moment looks like you're trying to cycle the `<ul>` elements inside the `<div class="homepage-slider">`. If there's only 1 child element cycle doesn't progress further since there's nothing to cycle.
> 3 votes

# Answer
The jquery cycle needs to define the tag that the child is going to use this is set by defining `data-cycle-slides="tag"`.

So in your example it should be `data-cycle-slides="li"`
This should be placed in the tag that wraps the `li` in this case it is `ul` so the `ul` should be `<ul data-cycle-slides="li">` or you could place the slideshow class also within this like `<ul class="homepage-slider" data-cycle-slides="li">`

In the first case the it would be `$('.homepage-slider ul').cycle({` and in the second case it should be `$('.homepage-slider').cycle({`

EDIT : This one is for cycle2 and might not be correct in the said question. I guess the as Clive mentioned $('.homepage-slider ul').cycle({\` should be enough.

For reference
> 1 votes

---
Tags: 7, javascript
---


# Question
Title: The condition for the 2 fields sort criteria
the problem is this. I have the representation of 2 fields ordered by 1. Discount - open for all users 2. weight I need to sort was originally on 2 field - weight and if one is already busy 1 field - Discount, then sorting is conducted by him and 2 field-weight was not used, how can I achieve this?

I think possible to accomplish this if 1 field - Discount add independent the default value is not sorted, just outputs the data views, but how do I set the value of 3 in the sort of the same type as the group filters arbitrary value -Any-. When I do the idea to 1 field value - Discount will not be involved and receive the following 2 field - Weight. But how do I do this? After all, when you create a sort field has 2 radio buttons - ASC and DESC.

# Answer
> 1 votes
The problem has been solved using the Better Exposed Filters module.

> The Better Exposed Filters module replaces the Views' default single- or multi-select boxes with radio buttons or checkboxes, respectively. Description fields and Select All/None links can be added to exposed filters to make for a better user experience.

---
Tags: views
---


# Question
Title: In drupal 7 how to add a link to a node which creates another node related to the previous being visible only if a user has not yet done so?
I have a node #1 of content type A. If the user equals a certain role AND has not yet done the following, show a link within node#1 saying "create node of type B".

If the user clicks this link, he may create a new node of type B. Then, when looking at node#1 again, the link disappears (or changes), since the user has already created another node from within node#1.

If you would delete that last created node and visit node#1 again, you would again have the possibility to create a node of type B which would automatically be related to the respective node, in this case node#1.

How can you do that?

# Answer
I can see couple of ways to do it.

1) add the module http://drupal.org/project/node\_limit

2) Create a menu with node/add/contentA

3) add this block to the node of the type content A

4) to do the third step you would need to add alias to the content A nodes by following method

Setup a URL alias pattern for content A Click on Configuration in the admin menu, and look for "URL Aliases". One of the tabs is called "Patterns" - this is where you can adjust the automatic URL alias settings for your content. In the "Content Paths" section you'll see the default is set to "content\[node:title\]" -- just below that you'll want to set "Pattern for all Blog entry paths" to "contenta/\[node:title\]" and save your new configuration. This means all of your future Content A content will have URLs like: http://yoursite.com/contenta/your-contenta-title.

(Thanks to Jonathan Webb http://www.drupalgardens.com/content/block-not-showing)

That should do it.

This assumes that the user can only add one node.

EDIT : An update with the requirement mentioned in the comment

Instead of step 1 and 2 do the following

1) Enable php filter

2) Create a view of the type block with just one field may be nid of the node. Remove the label. Rewrite the out put to some thing like so that nothing is displayed.

3) Add contextual filter of the type content:author and select provide default value and from the drop down select User ID from logged in user

4) In the header section add a field of the type gloal:textarea click on "Display even if view has no result" so that it would be displayed even if there is no result.

5) Select PHP code as the filter and paste the following code with the changes that suite your requirement such as changing the url to the one that adds your content type.

```
<?php
  $view = views_get_current_view();

   if (!count($view->result))
   {
       print "<a href='" . base_path() . "node/add/book'>Add Node</a>";
   }
?>

```

Follow step 3 and 4 to add the block to the node.
> 2 votes

---
Tags: nodes, entities
---


# Question
Title: Photos in views taking a long time to load
We have views with multiple cck image fields http://screencast.com/t/UOGxa9Jr6 with 'Group multiple values' And we have a theme function to add the needed classes for a script to display these photos in fancybox

```
function mytheme_content_view_multiple_field($items, $field, $values) {

  if($field['field_name']=='field_photos_images'){
    $output = '';
     $i = 0;
    foreach ($items as $item){
      if(!empty($item) || $item == '0')
        {
          if($i == 0) {

            $output .= '<p><a class="" data-fancybox-group="thumb"  href="/' . $item . '"><img src="/' . $item . '" alt="" width="200" height="150" /></a></p>';

          }
          else {
            $output .= '<p><a class="hid" data-fancybox-group="thumb"  href="/' . $item . '"><img src="/' . $item . '" alt="" /></a></p>';
          }
          $i++;
        }
    }
    return $output;
  }
}

```

each node has many images so it takes some time for the nodes to load, you can see each image load one by one taking about 10 seconds to complete

# Answer
If you can see the images loading one by one then this doesn't have anything to do with the View rendering slowly.

Slow running PHP generally means you have to wait longer before *anything* displays, not that individual parts of the page render slowly.

Slow loading images means the file size is large or you have a bad internet connection between you and the server.

You've mentioned that you're using CCK so I assume you're using Drupal 6.

Might I recommend using imagecache to pre-process the images to be scaled on the server to the right dimensions *before* they are sent to the user.

http://drupal.org/project/imagecache

Instead of printing the image tag directly, setup an imagecache preset in Drupal then you call theme() to generate the image markup.

Example:

```
<?php
  print theme('imagecache', 'mypresetname', 'path/to/file.jpg');
?>

```

Documentation on the theme function can be found here: http://drupalcontrib.org/api/drupal/contributions!imagecache!imagecache.module/function/theme\_imagecache/6
> 1 votes

---
Tags: views
---


title: how do robots find node urls

text:
# Question
Title: how do robots find node urls
I appear to be getting quite heavily crawled by robots that are seeing urls like

?q=node/668

1) how are robot's able to find these urls?

The robots are referring too are not google or popular search engines. Are there anyway apart from robots.txt to defend against these. The amount of traffic i'm getting is quite intense.

I'm using drupal 7

# Answer
Robots can find urls by following links either on-site or offsite.

You could use a link scanner as suggested by Clive, or look in google analytics to see where referrals are coming from to see if you have a lot of inbound links.

Alternatively, if a robot has figured out (or guessed) that your site is Drupal based then it's a pretty simple matter to start trying ?q=node/1, ?q=node/2, etc... and see what you don't get a 404 from.

I'd say a likely reason that the robot is using "?q=blah" instead of just "blah" is because the former will always work whereas the latter requires you to have clean URLs configured.

As well as robots.txt there are free services like Cloud Flare http://www.cloudflare.com/ that attempt to filter known-malicious bots for you before they can access your server.

You could also add rel="nofollow" to links on you're site that you're suspicious might be generating the traffic, which tells crawlers to not follow that link. Be careful with this as it also stops search engines, meaning it can harm your SEO if used unwisely.
> 1 votes

---
Tags: 7
---


# Question
Title: How to start migration with migrate module
I'm trying to make the migrate module to work, but I can't find where the dashboard is located.

In this url: www.foo.com/admin/content/migrate

I have the list of all available content that can be migrated into the DB (screenshot below).

However there must be another screen where you can actually initiate the import process.

I've tried this other url: www.foo.com/admin/content/migrate/dashboard

But it gives a 404 page not found error.

Any suggestions?

# Answer
> 0 votes
Is the Migrate UI module active? If yes, please try to clear the menu cache.

---
Tags: 6, importing-exporting, migrations
---


title: Add weight parameter in a custom module

text:
# Question
Title: Add weight parameter in a custom module
I created a content type and it has many nodes. And I wrote a custom module to show nodes on the front page.

My nodes order:

```
 $themeurl = '/drupal/'.path_to_theme().'/images';
    $sql = "SELECT * FROM `node`
            LEFT JOIN `field_data_field_anasayfa_catwalk` ON `field_data_field_anasayfa_catwalk`.`entity_id` = `node`.`nid`
            WHERE type = 'designers_albums'
            AND `node`.`status` = 1
            AND `node`.`language` = '".$language->language."'
            AND `field_data_field_anasayfa_catwalk`.`field_anasayfa_catwalk_value` = 1
            ORDER BY `node`.`created` ASC";

```

But now, I installed the Weight module and want to sort by weight. How can I change this option?
Thank you.

# Answer
> 0 votes
You'll just have to add another JOIN to the weight\_weights table on your query.

The weight\_weights table stores the entity\_id, entity\_type and the weight value.

EDITED

Here goes an example:

```
$sql = "SELECT * FROM `node`
        LEFT JOIN `field_data_field_anasayfa_catwalk` ON `field_data_field_anasayfa_catwalk`.`entity_id` = `node`.`nid`
        LEFT JOIN `weight_weights` ON `weight_weights`.`entity_id` = `node`.`nid`
        WHERE type = 'designers_albums'
        AND `node`.`status` = 1
        AND `node`.`language` = '".$language->language."'
        AND `field_data_field_anasayfa_catwalk`.`field_anasayfa_catwalk_value` = 1
        ORDER BY `weight_weights`.`weight` ASC";

```

---
Tags: 7
---


title: HTML template for Custom Content Type

text:
# Question
Title: HTML template for Custom Content Type
I'm reasonably new to Drupal... I've known about it for quite a number of years and have played around with it in the past, but only in the past 4 months have I started to make a serious website with it. Possibly a bit harder to configure than say WordPress, but so much more worth it when it's finished!

One thing that I'm trying to do is work with custom content types. What I am trying to do is create a custom content type called "Talk." In this I want to be able to specify a small description, an embed video URL and a link to PDF notes. I am having a really hard time to try and work out how to do that, and be able to customise it in a way I want.

What I want ultimately to be able to do is specify a HTML template for a custom field. That HTML then specifies where the fields appear (which may become problematic when there can be an undetermined number of entries for a particular field, but there could always be some way.)

Basically, let's say I specified the following

```
Summary: This is my summary
Embed: http://player.vimeo.com/video/51254497?title=1&byline=1&portrait=1
Notes: http://link/to/notes.pdf

```

I then want to be able to take those values and put them somewhere in HTML. For example...

```
<iframe src="" width="900" height="506" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="[Embed]" allowfullscreen=""></iframe><br>
<em>[Summary]</em><br>
<a href="[Notes]">Download corresponding notes</a>

```

Is there any way that I can create a custom content type that would give me that much control over my field? I've had a look but haven't been able to find any way, even with a module (though there's a good chance I haven't seen the right module!)

Thanks for any help, Josh.

# Answer
> 3 votes
Think your looking into this a bit too deep for what it is.

For your fields you use the following:

* Summary: Default field with any content type
* Embed: http://drupal.org/project/youtube (not sure if theres something for vimeo)
* Notes: Create a field that accepts PDf file extension

You then have loads of options for how you can present your content type. How about just creating a template file for that content type so...

```
node--type.tpl.php

```

You can then manipulate the output of the fields, for example...

```
<div class="somewhere-over-there">
    print render($content['youtube_field']);
</div>

<div class="somewhere-down-there">
    print render($content['pdf_field']);
</div>

```

# Answer
> 1 votes
You can create a unique page.tpl.php for a content type.

in your template.php file, add the following:

`function yourtheme_preprocess_page(&$variables) {
$variables['theme_hook_suggestions'][] = 'page__node_' . $variables['node']->type;
 $nodetype = 'page__node_' . $variables['node']->type;
}`

You can then create a template file: page--node-contenttype.tpl.php

If your content type was "talk" it would be: page--node-talk.tpl.php

---
Tags: nodes
---


# Question
Title: Block Settings not applying to Zen sub theme
I've created a Zen sub theme using the Starter Kit enabled it, and set it as the default (I've changed very little from the Starter Kit). If I go to Structure \> Blocks there is only a tab for the Zen theme (which is enabled, but not set to default). I can set blocks into different regions and save, but the changes are not reflected on the page. If I switch to the base Zen theme, the changes are there, but switching back to my sub theme shows just the default layout.

I'm new to Drupal, so should the sub theme be inheriting the base Zen theme's settings, or should there be a separate tab for the sub theme? And what do I need to do get the tab to show up? I've gone through numerous examples and tutorials without finding an answer.

Thanks.

# Answer
> 0 votes
I solved the problem, but don't know exactly what the issue was.

While troubleshooting, I noticed some Warning

> site:drupal.org Invalid argument supplied for foreach() in element\_children()

As well as the tabs not changing names regardless of which themes were enabled. Disabled and uninstalled all of my custom modules, but nothing changed. Disabled and deleted all the custom themes I had installed, and the errors disappeared and the Block Settings menu started behaving properly again. I copied all the themes back in, and it's still working properly, so I am not sure what the problem was.

I will be reinstalling several of the modules and checking to see if the problem reoccurs, but for now all is well.

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


# Question
Title: Convert a SQL database design to a drupal schema installation file
I have a, rather big, application that I would like to integrate into Drupal reusing the current database design / logic.

Is there a tool out there that can help me to build the PHP part of the hook\_schema definition taking the current database model or an SQL file with the DB declaration as a starting point ?

From what I know it should be pretty trivial to convert a SQL file to a PHPish definition compatible with drupal.

The utility should convert SQL types to Drupal types and declare primary keys, unique keys and index ala drupal.

# Answer
I knew of a few possabilities, only 2 may work. I haven't tried:

dbtng\_migrator \- migrates a drupal db to different DBMS engines at will. no schema export support.

Data \- module to move data into and out of drupal databases.

> The Data module provides
>
> an API for dynamically allocating tables for single-row records. an API for insert/update/delete operations and describing how tables join to each other. automatic views integration. **a way to export table definitions to code.**

Schema \- `drush dl schema` Includes the following functionality not found in Core:

> Schema structure generation: the module examines the live database and creates Schema API data structures for all tables that match the live database.

I have a drupal DB with other database connections defined in `settings.php`. You can go into Schema settings and tell to look at any named database connection (by default drupal is `default`). Here I select `dew_remote_sources` -- a "remote" (non drupal) database of data. The `inspect` tab then lists the SchemaAPI `hook_schema` defintion for each table with dummy comments to fillin.

Lastly views\_schema is pretty cool. It creates the hook\_views\_data for drupal tables based on their schema api definition.

Honestly I dont think you looked at @4Life answer close enough because given a db connection string, Schema does what you want.
> 7 votes

# Answer
Have you tried the schema module.

The Schema API allows modules to declare their database tables in a structured array (similar to the Form API) and provides API functions for creating, dropping, and changing tables, columns, keys, and indexes.

http://drupal.org/project/schema
> 3 votes

---
Tags: database
---


# Question
Title: Ubercart payment option without gateway?
I'm new to this forum, and I'm maintaining a Drupal 6.x webshop using Ubercart 2.4 for a client. The client wants to add a new payment option for business to business customers. These customers wouldn't need to pay at all, but would be invoiced manually from the client.

The client would have to check weather the customer is actually a valid customer for this "payment method", and decide if they can take the order or not, but this would be a separate issue.

**How can I add a new payment method that just stores the order with shipping and billing address to my database, no more?**

**Could I refactor the "Other" option from Payment Pack?**

# Answer
> 1 votes
I ended up copying the "Other" option from payment pack. Then I changed all references to "busniess\_invoice". Works like a charm!

---
Tags: ubercart
---


# Question
Title: How do I get debug_backtrace() to fire on the endpoint site of a Deployment process?
I'm trying to work through this UUID features bug with the deploy module. On the receiving site, I see errors in that log like

```
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'fc661e5c-62de-fa34-2557-0f6f5a2acbfe' for column 'fid'

```

I've followed the example laid out here to have a backtrace show for any error on both the sending and receiving installations. However I can' seem to find a way to get the backtrace to show for the error on the receiving site after the deploy process completes. I can see the service error in /admin/reports/dblog but that's it.

Any help is greatly appreciated!

-adbo

# Answer
note the following: **fc661e5c-62de-fa34-2557-0f6f5a2acbfe** and then... **General error: 1366 Incorrect integer value:**

the number or UUID is not an integer.

therefore you'll get that sort of error message. I'm assuming deploy has either a bug in it or you've forgotten to run **update.php** on your DB the FID field is marked in the DB as an integer when it should be a varchar / string field.

Take a look at the schema and see what needs to change. that should at least give you an indication of where things have gone wrong.
> 2 votes

---
Tags: debugging, deployment
---


# Question
Title: How to programmatically add menu for content type?
E.g. article has main menu as default, I want to add (and remove) second menu as available to article content type in my unit tests, how can I do it?

# Answer
Anyway I win with my lazyness and read Menu module source, you can add menu to available menus list of selected node like:

```
$type = 'article';
$curr_list = variable_get('menu_options_'.$type);
variable_set('menu_options_'.$type, array_merge($curr_list, array('new_menu')):

```
> 0 votes

# Answer
In hook\_menu and set 'access callback' to custom function and then:

$node-\>type == 'my\_node\_type'

and/or user type that can access this node...
> 0 votes

---
Tags: 7, routes, nodes
---


# Question
Title: How to set the behavior for Pathauto when a duplicate exists?
I'm creating a Drupal 7 site which will consist of information about many different organizations across North America. The profiles will be submitted by the organizations themselves and it is very likely that there will be duplicate names.

What I'd like to do is have Pathauto create the url: `orgs/OrganizationName` for the first such organization and after this create: `orgs/OrganizationName-City`.

Is there any way to change how Pathauto behaves when duplicates are found?

# Answer
You could create a module and use the hook\_pathauto\_alias\_alter function to override the path alias before saving it.

```
function mymodule_pathauto_alias_alter(&$alias, &$context) {

  $temp = $alias;
  $newalias = pathauto_alias_uniquify($temp, $context['source'], $context['language']);
  if ($newalias !=$alias)
  {
    $alias .= $context['data']['node']->field_city[$context['data']['node']->language][0]['value'];
  }

}

```

The pathauto\_alias\_uniquify function checks if there is an alias already existing and if it does then would return the updated alias and if not return the same alias. now the one you get it different from the one we already have then we would could append the city name to the alias.

I have created a field called city with a field machine name field\_city you will have to change your values accordingly.
> 1 votes

---
Tags: 7, path-aliases
---


# Question
Title: Issues with custom redirect url using tokens when form field is empty
I am trying to use Drupal webforms with tokens to build out a redirect url for my form submissions. Everything works great when all fields are populated, but if a field is left empty the redirect does not happen. Promo code is an optional field. This is with Webform 6.x-3.14

**Redirect URL**: `%value[app_url]/user/new?email=%value[email_address]&first_name=%value[first_name]&last_name=%value[last_name]&promo_code=%value[promo_code]`

# Answer
> 0 votes
I ended up writing a custom module to do the post using the following code as a starting point http://www.midwesternmac.com/blogs/jeff-geerling/integrate-webform-3x-paypal

---
Tags: 7, webforms
---


# Question
Title: How To Create Combined Search Filters In Views?
I am currently working on a view that allows me to search "title" of a content type along with 3 other exposed filters. But now I want users to not only be able to search "title" but also "category" field of the same content type, except "title" and "Category" fields need to be one filter.

I tried using contextual filters but I'm afraid I don't quite understand the best method. I'm currently using global:combine fields filter but instead my views results (which worked fine previously) no longer works. I'm trying to avoid complicated coding. Any suggestion?

# Answer
The newest version of Views integrates this feature without the need for Views filter populate. It's a filter called ***Combine fields filter***.

To make use of it you first need to add all of the fields you want to filter on. You may check *Exclude from display* if you want to search for it, but don't want to display it.

Once all of the fields are there, add a *Combine fields filter*, and choose to Expose it. Choose **Single field** for the *Filter type to Expose*

This is a different approach than Views populate filter, but as this is integrated into Views I find it much more intuitive.
> 15 votes

# Answer
We use this module all over the place, it works just like it says. Only limitation is that it only works on String fields (Node Reference, Taxonomy ID, etc. won't work).

Views filters populate

> This is an utility module. Its sole purpose is to fill in one blank that seems not easy to be done using normal views, which is to use one exposed string filter to search on multiple fields.
> 4 votes

---
Tags: views
---


# Question
Title: Change wording of history (member since)
Is there a way to change the wording of "Member since" to something else?

# Answer
You could put this in your settings.php

```
$conf['locale_custom_strings_en'][''] = array(
   'Member since'      => 'Your new label',
);

```

Or you could change it in the form by preprocessing that form. I think there are also language modules that allow you to change phrases/labels site-wide.
> 2 votes

# Answer
The module String Overrides: http://drupal.org/project/stringoverrides lets you replace virtually any string with another string.

Some of its features (from project page):

> * Easily replace anything that's passed through t()
> * Locale support, allowing you to override strings in any language
> * Ability to import/export \*.po files, for easy migration from the Locale module
> * Note that this is not a replacement to Locale as having thousands of overrides can cause more pain then benefit. Use this only if you need a few easy text changes.
> 2 votes

# Answer
If you want to replace any occurrence of that string, then you can use the following method:

* In Drupal 6, add the following code to the settings.php file.

```
$conf['locale_custom_strings_en'] = array(
  'Member since' => 'The string you would use',
);

```
* In Drupal 7, add the following code to the settings.php file.

```
$conf['locale_custom_strings_en'][''] = array(
  'Member since' => 'The string you would use',
);

```
* For Drupal 6, and 7, you can use the String Overrides module, which has the pro of not requiring to edit the settings.php file. It is quite simpler to change the strings from a administration page, than editing a file present in the webserver, and to which few people should have access.

In Drupal 7, it would be possible to alter only the string used in the user profile with hook\_user\_view\_alter(), such as with the following code added to a module.

```
function mymodule_user_view_alter(&$build) {
  if (isset($build['summary']['member_for']['#title'])) {
    $build['summary']['member_for']['#title'] = 'The string you would use';
  }
}

```
> 1 votes

---
Tags: users
---


title: Debugging a module upgrade

text:
# Question
Title: Debugging a module upgrade
In "Status report" I have message saying that some modules have database schema updates to install. However, when I run update.php nothing happens. I just get the standard error message that "Some of the pending updates cannot be applied because their dependencies were not met."

Reports -\> log messages does not have anything relevant.

How should I debug this?

# Answer
It is possible that a module that you just updated now has a new module dependency. Go to your module listing page and see if any enabled modules now have a dependency listed as missing. Download the missing dependencies, enable and run update.php
> 0 votes

---
Tags: debugging, upgrading
---


# Question
Title: How to keep multiple drupal websites up to date
I do a lot of web consulting and drupal is my preferred tool of choice. But as I grow, it seems like drupal gets more and more needy. At least once a week, if not more, my inbox gets messages that drupal needs updating, and I have to go and update the dev server, verify nothing broke, and then update the production server, and again verify that nothing broke.

I'm using drush to help me with this, but this is still taking considerable time away from my business, time I could be billing to the customer.

Does anyone have a solution to this? Some way to automate the updates and then a regression test, and if successful, do the same on production?

# Answer
You could write scripts to do this. You'd probably want to tie in to the Drupal unit testing module as well.

I can't provide you with any actual examples, because I'm not sure how it would be done reliably.

In my opinion, you're looking at a business problem that can't be fixed with a programming solution. If I were in your shoes, I would start charging customers an ongoing maintenance fee for upgrades.
> 0 votes

# Answer
I use the following script:

https://github.com/greg-1-anderson/utiliscripts/blob/master/drupal-backup-all

n.b. not guaranteed to be bug-free. The "verify nothing broke" and "update the production server" are manual steps, but at least my update sites are available for testing when I want to do it.
> 0 votes

---
Tags: updating
---


# Question
Title: wysiwyg + ckeditor - failed to open stream sites/default/files/js/wysiwyg/wysiwyg_ckeditor_XXX.js
I am using WYSiWYG with CK editor. I am getting this error whenever i am trying to access a form with ckeditor.

> file\_get\_contents(MYSITE/sites/default/files/js/wysiwyg/wysiwyg\_ckeditor\_lMF9rzHK588\_LcHaW11FHc\_RkSCpdKrS7MgWsyqXXEM.js)
>
> \[function.file-get-contents\]: failed to open stream: HTTP request failed!
>
> HTTP/1.1 404 Not Found in drupal\_build\_js\_cache() (line 4846 of /var/www/html/dev3/wifh/includes/common.inc).

This file "wysiwyg\_ckeditor\_lMF9rzHK588\_LcHaW11FHc\_RkSCpdKrS7MgWsyqXXEM.js" exist with content

```
window.CKEDITOR_BASEPATH = '/MYSITE/sites/all/libraries/ckeditor/';

```

# Answer
> 2 votes
This bug should be fixed in the latest dev snapshot of wysiwyg:

See also http://drupal.org/node/1802394 (which essentially provides a patch for the previous response above).

# Answer
> 0 votes
1. Edit `wysiwyg.module` file
2. Find this `drupal_add_js(file_create_url($uri), $default_library_options)`;\`
3. Replace with this `drupal_add_js($uri, $default_library_options);`

---
Tags: 7, wysiwyg
---


title: Creating an RSS from Scratch

text:
# Question
Title: Creating an RSS from Scratch
I'm converting a site to D7 that does not currently have an RSS feed. I'm trying to find a way to create something that will help me avoid having to manually move over each and every page, but I'm coming up empty.

I thought of wanted to try to generate a feed, with the goal being to use the Feeds module to import the feed as pages, but I've not found anything to do that sufficiently.

Right now all the pages are stand-alone pages meaning that none of them are stored in a database, but it's all written up in PHP & HTML and it's a bit of a mess. So I'm having to work with the raw pages. That's why I thought creating a feed would be the way to go.

If I could get the existing pages in to a CSV or XML file I could work with them a little easier, but there are numerous pages and it would take forever to do that.

Thanks in advance for any help/advice you can offer!

# Answer
Maybe try Goutte. I thought there was a similar Migrate module + Goutte frontend out there ... but can't find it.
> 0 votes

---
Tags: feeds
---


title: Resolving data in hook_views_data

text:
# Question
Title: Resolving data in hook_views_data
I have a custom table defined in hook\_views\_data(). One of my fields is an integer, which maps to some defined constants. When they are queried and displayed by views, I'd like to change them to their string name that's represented by the integer.

So, my question is how can I manipulate values returned by views?

# Answer
If you're using hook\_views\_data, you can also specify a custom field handler for the output, using a function in the field handler such as views\_handler\_field-\>render($values)

See also: views\_handler\_field for the base class that is extended by the field handler.

That way your field in your custom table can have its own field handler.
> 1 votes

# Answer
You can theme (you dont want to change the value stored in the DB, just change its *displayed* value) the view row value by using a template suggestion:

I prefer using a `preprocessor` function to do this on the field. This blog post covers how to do this for a specific `view_name` and `field`.

From the blogpost:

> There is an issue to let Drupal 7 and 8 themes implement a preprocess/process function per view as it is possible in Drupal 6, but it is in development (see issue).
>
> Until it is fixed there is a way to achieve that behaviour:

```
<?php
/**
  * Generic preprocess that is still working on D7
  */
function MYTHEME_preprocess_views_view_fields(&$vars) {
  if (isset($vars['view']->name)) {
    $function = __FUNCTION__ . '__' . $vars['view']->name . '__' . $vars['view']->current_display;

    if (function_exists($function)) {
     $function($vars);
    }
  }
}

/**
  * Then the specific preprocess that worked without the above code for D6
  */
function MYTHEME_preprocess_views_view_fields__VIEWNAME__DISPLAY(&$vars) {
  // my specific preprocess code
}
?>

```

There's also like views\_custom\_styles (sandbox project) and views\_php which will let you do the same thing -- but for what you're asking (to my knowledge) you're gonna have to write code.

The preprocessor example I give is a clean solution re-using the Theme API (suggestions) and hooks.
> 1 votes

---
Tags: 7, views
---