how to modify the confirmation email in Ubercart? I'm trying to modify the format and text of the confirmation email in Ubercart and I don't know from where....can anyone give me hint?
for example including some images or custom links in some parts of the email, quit the horrible yellow background of the site name , etc, etc...
I'm using Drupal 6

Here's what I'm receiving at the moment...

You'll want to override the file 'uc_order-customer.tpl.php' found in the ubercart module. The way you do this is:

You need to copy two files from sites/all/modules/ubercart/uc_order/templates
The files to copy are uc_order.tpl.php and uc_order-customer.tpl.php

Then just edit uc_order-customer.tpl.php to your liking.


Write form value to database I need to save this to database, but could not find a way to make it work.
Now this paypal_email is only saved to current user. Apparently it is saved somehow to the database under user table, but it can not be read there? Or use views to read it.

function commerce_funds_manage_withdrawal_method_paypal($form, &$form_state) {

  $enabled_methods = variable_get('commerce_funds_withdrawal_methods', array());

  if (!$enabled_methods['paypal'])
    return FALSE;

  global $user;

  $form['paypal_email'] = array(
      '#type' => 'textfield',
      '#title' => t('Paypal Email'),
      '#description' => t('Withdrawals using Paypal will be sent to this email'),
      '#default_value' => $user->data && array_key_exists('paypal', $user->data) ? $user->data['paypal']['paypal_email'] : '',
      '#size' => 40,
      '#maxlength' => 64,
      '#required' => TRUE,
  );

  $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save'),
  );

  return $form;
}

function commerce_funds_manage_withdrawal_method_paypal_submit($form, &$form_state) {

  global $user;

  user_save($user, array('data' => array('paypal' => $form_state['values'])));
}

I don't think the $user->data value can be read by views.  You are probably better off creating a field to store the email value.


How to concatenate all token values of a list in a single field within a Rules loop? I am attempting to send a list of uploaded files on a newly created node via email.

In a content type, I have a File Field that allows unlimited values.

Within Rules, I created a loop calling the current item "current_file".

I am trying to concatenate all of the values into one longtext field called "file_list".

I intend to use the token for the value of "file_list" in the body of an email.

Unfortunately, I am unable to do so.

While in Data Selection mode, I can access the tokens created by the loop:

However, while in Direct Input mode, the tokens are not available to me. They are not listed in the "Replacement patterns" section.

When I attempt to fill the value with the following, I have no success:

[node:field-file-list]
[current-file:file:url]

What can be done to make the tokens available to me in Direct Input mode?

If I am doing this incorrectly, is there a different way for me to concatenate all of the URLs of each file so that I can put it in the body of an email action?

If what you're looking for is not available, then just make it available, which is "a different way to concatenate all of the URLs of each file" (as in your question). Read on for more details ...

Have a look at this example of a Rule (in Rules export format), which is a variation of what you're asking for:

{ "rules_show_list_of_fields" : {
    "LABEL" : "Show list of fields",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_insert" : [], "node_update" : [] },
    "IF" : [
      { "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "article" : "article" } } } }
    ],
    "DO" : [
      { "variable_add" : {
          "USING" : { "type" : "text", "value" : "StartOfList-" },
          "PROVIDE" : { "variable_added" : { "email_list" : "List of eMail IDs" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "node:field-email-addresses" ] },
          "ITEM" : { "current_email" : "Current eMail" },
          "DO" : [
            { "data_set" : {
                "data" : [ "email-list" ],
                "value" : "[email-list:value][current-email:value]-"
              }
            }
          ]
        }
      },
      { "data_set" : { "data" : [ "email-list" ], "value" : "[email-list:value]EndOfList" } },
      { "drupal_message" : { "message" : "The value of the email_list variable is: [email-list:value]." } }
    ]
  }
}

Here is a summary of what this rule does:

Add a new variable email_list.
Init the email_list value with some prefix.
For each item within the loop, append the value of that item, followed by a separator character.
Add a suffix to the email_list value.

In my case I'm using a multi value text field with machine name field_email_addresses, which contains eMail Ids, and just want to dispay a Status message with a concatenation of those eMail IDs, separated by a "-", and with a prefix (=StartOfList) / suffix (=EndOfList). And I also use Rules Events "Update existing node".

Replace the machine name of my list field to your list field, and replace all 'eMail' by 'file' and you should be able to import this rule in your own site (if you have the Rules UI enabled).

Not sure if you want the prefix or suffix, and/or the separator character (="-"). Adapt or remove any of these to fit your needs.

Voilà ...

Demo

Here is how the Status message looks like after you create a new node, or update an existing node (of type Article):

  The value of the email_list variable is: StartOfList-user2@example.com-user4@example.com-EndOfList.


How do I add an external link in a module? I'm attempting develop a module in drupal-8 that provides a link to an external password reset system. Specifically on the login page I'd like a reset my password link that points to a link such as https://reset.my.password/

I've tried adding my module.links.task.yml file. What else do I have to create to add an external link?

There seems to be very little information on this matter, maybe it's not that common to try to achieve something like this, but I stumbled across this thread while searching for a solution and I'd like to add my thoughts.
The comments stating that links.task.yml is for local tasks is right, but when it comes to external links, it's not that simple. As far as I know, you need routing to add links that way, and routing is for internal links, right?
So in the end I did it this way in Drupal 9:
  function my_module_menu_local_tasks_alter(&$data, $route_name) {
    $data['tabs'][0]['node.extra_tab'] = array(
      '#theme' => 'menu_local_task',
      '#link' => array(
        'title' => t('Extra tab'),
        'url' => Url::fromUri('https://theurl.com', array('attributes' => array('target' => '_blank'))),
        'localized_options' => array(
          'attributes' => array(
            'title' => t('Extra tab'),
          ),
        ),
      ),
    );
  }

You can also add something like if ($route_name == 'entity.node.canonical') to narrow it down and also if (\Drupal::routeMatch()->getParameter('node') == 'my_content_type') in case you want this to work only on certain content type(s).


How can you automatically add CSS classes to  tags in the post body? I'm trying to build a new Drupal site using the Tailwind CSS framework, which relies on inlining CSS classes onto HTML tags.

This is fine in Twig template files where I have direct control of the output and can add the required classes directly, however I'd like to automatically add classes to <p> tags (and probably some other, but <p> is a good start) within the body of certain post types.

Any idea where I should be looking?

I'm not entirely clear on what the correct terminology to search is, and Google returns plenty of results that are at least a decade old and not relevant for Drupal 8.

I have found how to resolve this specifically if using the Tailwind framework, which I am.

You can use the @apply function of the framework to add classes based on common Drupal class names, or ones you specify in your custom html.twig files.

Documentation here: https://tailwindcss.com/docs/functions-and-directives/#apply
I am using the Tailwind Starter theme which also uses this function https://www.drupal.org/project/tailwindcss

For example, to apply the text-xl utility class to node paragraph tags, I can use the following code in my stylesheet

.node-content p {
  @apply text-xl
}


How to create Embedded Media Field: Video with custom resolution per Views field Is there a way to apply a custom resolution to an Embedded Media Field: Video at the time of building a View? Alternatively, a way to define more than the just the Full / Preview presets?

You can set it in the template_preprocess_node()

depending on your view mode you can set the first element :

if ($vars['view_mode'] == "full") {

   $node->video_field_name[0]['#settings']['width'] = '300';
   $node->video_field_name[0]['#settings']['height'] = '150';

}

dont forget to set all elements, not just the first one

other settings you can set:

#settings
  controls (Boolean) TRUE
  width (String) 300
  height (String) 150
  download_link (Boolean) FALSE
  download_text (String) Download

Edit:

template_preprocess_views_view_field is what you need for views probably. there you can access to the $vars['row'] with all data you need. maybe you will need to rerender the field.

If this does not work there is a workaround:
the embedded-media-field sets its settings in the drupal js-settings.
get the js settings with drupal_add_js(), find the element mediaelement and set the settings manually.


The database connection is not serializable I'm getting this error. The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection

I'm using Lightning 2.1.6.
I set up a media upload field on my page content type using reference to content/ reference media. It also uses the media browser to upload images. This field allows a single image upload. I get the error when you try to upload an image. And the image doesn't get added. If i allow multiple upload instead of single the error goes away. Also If I disable the "Interface Translation" module the error goes away and the images can be uploaded.

I experienced this issue after manually deleting some translated configuration files. From then on I was not able to successfully config import anymore without being interrupted with the fatal error from your question.

I then tried to run config import after uninstalling locale, which worked but have also deleted lots of translation from the database. Bad.

I could restore the configs in question and then remove them from the UI before exporting them again. Boring.

So I deleted the original configuration objects from an update function (and thereby also deleted the translations), and afterwards run configuration import again, where the original configs then got restored automatically (as their files still existed) WITHOUT translation.

/**
 * Remove unwanted translations.
 */
function MYMODULE_update_8005(&$sandbox) {

  $configs = [
    'image.style.crop_thumbnail',
    'views.view.user_admin_people',
  ];

  foreach ($configs as $config) {
    Drupal::configFactory()->getEditable($config)->delete();
  }
}

EDIT: Only shortly after I had the same problem again. Again it was a missing config (I deleted manually, don't do that) and took me hours to find out which one exactly. This time it was menu_item_extras which required menu_item_extras.utility.yml. Actually I uninstalled menu_item_extras but maybe menu_item_extras can't be uninstalled that simply. But that's a different issue.

What's left to conclude now is: Did you manually delete some config files prior to getting this error?


Need help optimizing a site for speed and response time In my Drupal 6 site (fairly busy about 200 anonymous users on average at at time) I have the following setup to speed up the site.

Caching Mode - normal
Optimize JavaScript files
Gzip enabled via .htaccess
Cloudflare - normal setting
Disabled database logging

Can I add memcached or Varnish into this setup? Which one will work better for this site? Should I even care about Varnish and memcached in this setup?

You can use both as per my knowledge.

For Drupal generally, Varnish works for unauthenticated users traffic and memcached will cache authenticated users traffic.

Memcache saves your DB from doing a lot of read work, Varnish saves your dynamic web server from CPU load by making you generate pages less frequently.

But in your case I think Varnish is better option.


db_delete on click on a link in module contents display I've made a module displaying a set of fields from the database.
I would like to add a "delete" link at the end of each row be able to delete the row in the database on click. I made it in my module with the following code :

The tests.module code :

<?php

function tests_menu(){
$items = array();

$items['tests'] = array(
    'title' => 'Tests',
    'page callback' => 'tests_contents',
    'access callback' => TRUE
);

$items['tests/delete/%'] = array(
    'title' => 'Delete',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('tests_delete_form', 1),
    'file' => 'tests_form.inc',
);
return $items;
}

function tests_contents(){
$delete_path = current_path();

$query = db_select('form', 'f');
$result = $query
        ->fields('f')
        ->execute()
        ->fetchAll();

foreach($result as $key){
    $output .= $key->id;
    $output .= $key->name;
    $output .= 'id.'">download';
    $output .= 'id.'">delete';
}
return $output;
}

And the tests_form.inc code :

<?php

function tests_menu(){
$items = array();

$items['tests/delete/%'] = array(
'title' => 'Delete',
'page callback' => 'drupal_get_form',
'page arguments' => array('tests_delete_form'),
'access callback' => TRUE
);
return $items;
}

function tests_delete_form_submit($form, &$form_state) {
$path = current_path();
$rest = substr($path, 13);

$query = db_select('form', 'f');
$result = $query
  ->condition('f.id', $rest, '=')
  ->fields('f')
  ->execute();

$testid = $result->fetchField();

db_query("DELETE FROM {form} WHERE id = %testid", $testid);
}

How can I make this db_delete function on click in my module ?

Add path to delete your elements to hook_menu().

$items['something/%/delete'] = array(
  'title' => 'Delete',
  'page callback' => 'drupal_get_form',
  'page arguments' => array('mymodule_delete_form', 1),
);

In mymodule_delete_form(), use confirm_form(). It will generate "are you sure?" form for you. Then, just write mymodule_delete_form_submit() to perform actual deletion.


Forward user email address I use Webform with Commerce product skus field. Now I have a rule to send out an email to customer if webform is submitted. That works fine. But I would like to set a rule to send the email when the customer check out. My problem is that i don't know the token which I have to set in this Drupal Commerce rule. In Webform rule, I use this [data:e_mail-value], but in the Drupal Commerce rule I have [commerce-order:mail] which is not the same, is it?

How can I forward the right user email address from webform submission to the final Drupal Commerce confirmation email?

The "commerce-order:mail" token will only show the user email associated with whoever is logged in and submitting the order, while the webform email value from the token [data:e_mail-value] is a component in the webform submission and generally stores the submission with the author/owner being "anonymous".

If your webform automatically redirects to the commerce cart/checkout, then I'd suggest forcing the user to be logged in before they even fill out the webform and hit submit. Then you can set the default value of the webform email field with a token for the email of current user and hide it from view.
Otherwise, you'll need to write custom functionality to somehow store and pass the webform submitted data:e_mail-value to a hidden field associated with the order itself in the checkout process.

Also as a reminder for the "To" address field in the workflow rule for sending an email, you need to format it to comply with RFC 2822- by wrapping the email address string with <>.  For example:

Should you want to send to multiple recipients, then you'll want a comma separated list of emails, each wrapped in <>.


Could not find package with stability dev in a version installable using your PHP version When I want to install Drupal Commerce using Composer via Git Bash terminal and using the following command:

$ composer create-project drupalcommerce/project-base mystore --stability dev

I get the following error:

  [InvalidArgumentException]   Could not find package
  drupalcommerce/project-base with stability dev in a version
  installable using your PHP version 5.6.40.

  create-project [-s|--stability STABILITY] [--prefer-source]
  [--prefer-dist] [--repository REPOSITORY] [--repository-url
  REPOSITORY-URL] [--dev] [--no-dev] [--no-custom-installers]
  [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs]
  [--remove-vcs] [--no-install] [--ignore-platform-reqs] [--]
  [] [] []

So what can I do?

The package that triggers the error is  drupalcommerce/project-base. If you check the composer information for that package you see:

  "require": {
        "php": ">=7.0.8",
        "ext-curl": "*",
        "composer/installers": "^1.2",
        "cweagans/composer-patches": "^1.6.5",
        [...]

As you see, it requires PHP 7.0.8 or higher. You have PHP 5.6.40. You should upgrade your PHP, not only because this package but also because PHP 7.x is much faster and PHP 5.6 is not recommended anymore, not to forget that PHP 5.6 end of life was hit a year ago, on the beginning of 2019.


Custom validation for views exposed form using form alter I want to add my custom validation to the views exposed filter form for that I have added below code in hook_form_alter

$form['#validate'][] = 'xxxx_custom_form_validate';

But its being called for form load also, is there any specific way to add custom validation function for views exposed filters form.

To form alter a specific view exposed filter form, you need 2 conditions to check: the form id & the form's '#id' element.

function MYMODULE_form_alter(&$form, $form_state, $form_id) {

  // @NOTE: $form['#id'] will vary based on your your view & display machine names.
  // Here the view machine name is 'view' & display machine name is 'display'.
  // Use Devel's dpm() to inspect or the Views administration UI
  // to find your own form's values.

  if ($form_id == 'views_exposed_form') {
    if ($form['#id'] == 'views-exposed-form-view-display') {
      // @TODO: Add form alter code.

    }
  }
}


How to get list of contents of a particular content type programattically How can i get a list of contents of a particular content type for example "Basic Page". I want basic page title list in a drop down.

I want list of nodes in a drop down and while selecting each will show the content body. How can i do this?

To create a list of content with filters (e.g. by type) you probably want to use either Views or, if you have a reason to load whole entities by ID rather than individual fields, an EntityFieldQuery.

Since there may be a large number of nodes, this type of use case usually uses an autocomplete field by entity title rather than a dropdown.

To create a dropdown, you'll want to use the core Form API to create a form, and the #options array for the dropdown field would be provided by either the View or EntityFieldQuery you create.


Drush 8 database connection issue I'm having trouble connecting to my databases. It worked a few days ago but can't seem to figure why it doesn't work now. It's a D8-site. Drush version is 8.1.12.

I've double-checked both the alias-file and settings.php-files (both on server & local) and database settings all appear correct. My local site runs on Mamp 4.1.1. and network access is allowed.

Here's the error I get when running sql-sync drush sql-sync @local @dev. Rsync works fine.

Unable to load class Drush\Sql\Sql                                                                                [error]
exception 'Drush\Sql\SqlException' with message 'Unable to find a matching SQL Class. Drush cannot find your database connection details.' in /vendor/drush/drush/commands/sql/sql.drush.inc:541                [error]
Stack trace:
#0 /vendor/drush/drush/commands/sql/sql.drush.inc(252): drush_sql_get_class()
#1 [internal function]: drush_sql_dump()
#2 /vendor/drush/drush/includes/command.inc(422): call_user_func_array('drush_sql_dump', Array)
#3 /vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#4 [internal function]: drush_command()
#5 /vendor/drush/drush/includes/command.inc(199): call_user_func_array('drush_command', Array)
#6 /vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#7 /vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#8 /vendor/drush/drush/drush.php(12): drush_main()
#9 {main}
sql-dump failed.

And here's the aliases.drushrc.php (my local copy of course includes credentials:))

<?php

/* Tambourhinoceros Site */

$aliases["local"] = array (
 'root' => '', // local path
 'uri' => 'local.tambourhinoceros.net',  // local uri
 'path-aliases' =>
 array (
   '%dump-dir' => '/tmp',
   '%drush' => '/usr/local/bin',
   '%site' => 'sites/default',
 ),
 'remote-user' => 'tamb_dev',
 'ssh-options' => '-T',
 'databases' =>
 array (
   'default' =>
   array (
     'default' =>
     array (
        'database' => '', // local database
        'username' => '', // local database user
        'password' => '', // local database pw
        'host' => 'localhost',
        'port' => '8889',
        'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
        'driver' => 'mysql',
        'prefix' => '',
      ),
    ),
  ),
);

$aliases["dev"] = array (
  'root' => '', // remote path
  'uri' => 'drupal-85630-297475.cloudwaysapps.com', // remote uri
  'path-aliases' =>
  array (
  ),
  'remote-host' => '', remote IP
  'remote-user' => '', remote User
  'command-specific' =>
 array (
   'rsync' =>
   array (
     'mode' => 'rlptzO',
     'verbose' => true,
     'no-perms' => true,
   ),
 ),
 'databases' =>
 array (
   'default' =>
   array (
     'default' =>
     array (
        'database' => '', remote database
        'username' => '', remote  user
        'password' => '', remote pw
        'host' => 'localhost',
        'port' => '',
        'driver' => 'mysql',
        'prefix' => '',
      ),
    ),
  ),
)
?>

It will be Solved by adding

--root=/full/path/to/your/webroot

to the drush command.


How to leverage a DB query with views? I have three things:

A user (User entity)
A league (Node)
A league entry (Node, with a numerical field for time and a noderef field to a league)

A user can create a league entry node, and set a time value and a node reference to a league node.

I want to produce a view that takes the league node id as an argument, and produces a table row for each user that has submitted a league entry node. The columns will be the user name, a user field that states the user's team, and finally, for every league entry node raised by them as author, that contains a node reference to the current league nid, a sum of the matching league entries numerical fields.

Now as you can imagine, doing this in views is very problematic because of aggregation issues on a single field; so a simpler alternative is to simple create a new DB table that stores the data I want to display in distinct fields.

So if I have a DB table like:

username, league, total of league entry nodes time value so far

How can I get this info into views so I can take advantage of table display, column sorting, and all that good stuff?

There are a couple of ways of doing this. You can create an entity. This requires the writing of a custom module to do so. Entities can be challenging if you have never done them before.

Another way and slightly simpler (still requires a custom module). Is to use the Views API. The first thing you would implement is hook_views_data(). This is a really good example of hook_views_data borrowed from Drupal Commerce.

Lastly, there are some modules out there that might help. One of them is Schema Views.


What is the equivalent of calling drupal_lookup_path()? drupal_lookup_path() have been remove in Drupal 8. However, I cannot find a way to achieve the same functionality. All, I'm trying to do is to provide Drupal with a path and he is going to look to see if exist, if exist is going to provide me the node id. If does not exist that path he going to give me an error or null/0.

How can I achieve this on Drupal 8?

Drupal 7:

$path .= drupal_lookup_path('alias', $path);

Drupal 8:

$alias =
  \Drupal::service('path.alias_manager')
    ->getPathAlias($path);

if (strcmp($alias, $path) == 0) {
  $alias = '';  // No alias was found.
}

$path .= $alias;

Reference Link

8 calls to drupal_lookup_path()

drupal_get_normal_path
drupal_get_path_alias
purl_get_normal_path
rules_condition_path_alias_exists
rules_condition_path_has_alias


How do I search partial words? I'm working on a site with the Search API Solr module.

I notice that, in fulltext searches, the system gives results only for entire word. If I've a title like "Beautiful", if I search "eautiful" it doesn't find something.
Is there a way to solve this?

Set up Solr with the class EdgeNGramFilterFactory. This will not catch 'eautiful' instead of 'beautiful', but will give results on bea, beau, beaut and so on depending on minGramSize and maxGramSize. IMO this will be sufficient for most searches.


How to show the following n events with respect to the current date or the past events to always ensure n elements in the view? I have an agenda on my homepage, and I want to always ensure 5 events.

If there are 5 or more following events (including the current one), show the nearest 5 from the start date.

If there is less, show X past events in such a way that the following and the past are 5 in total.

Examples:

Today is March 12.

a) List of events (more than 5 futures):
- March 10th
- March 11th
- March 12
- March 13
- March 14
- March, 15th
- March 16
- March 17
- March 18th

Show in the view
March 12, 13, 14, 15 and 16.

b) List of events (mix, p past events, q future events):
- March 9
- March 10th
- March 11th
- March 13
- March 14
- March, 15th

Show in the view:
March 10, 11, 13, 14 and 15.

c) List of events (no future events, show recent events).
- March 1st
- March 2
- March 3rd
- March 8
- March 9
- March 10th
- March 11th

Show in the view:
March 3, 8, 9, 10 and 11.

You will need to develop a custom module with a custom views sort plugin as views don't have something for this.

Read the Custom Views Sort Plugin for Upcoming Events blog post that will help you.


how to set the author of the feed item to the author of the feed source in feed importer? I have created a feed importer.
I do not know how to set the author of the feed item to name of the original author of the feed?
Is there any method to do it?
Or will apply any patch?
Any patch for this functionality will be welcome.

I had a hard time getting this to work.

My current settings work.

Feed Importer
-attached to Feed (content type)
-RSS parser
-Mapping: Description to Description, Title to Title, Item GUID to GUID (Unique), Item URL to URL (Unique), Published Date to Published Date, and Feed Node: User ID to User ID.  It is important to have a unique identifier or you get duplicate imports.

The Feed Itself
-Set "Authored By" to a Drupal user on your site.   This lets you custom the user. Create a new user if necessary. I created a couple dummy users just to get their names to appear as feed item authors.


How can I delete a poorly named vocabulary? I've created a couple of vocabularies programmatically, and accidentally included some spaces in the machine names (caused by bad data in an input CSV). I can't delete these vocabularies with Vocabulary::load($vid)->delete();, even though I can see the vocabularies names with
dsm(taxonomy_vocabulary_get_names());, while load($vid) returns NULL.
Any ideas on how I can delete these vocabularies? I was able to delete all the terms in a vocabulary, but the reference remains under admin/structure/taxonomy.

Where are you calling that code? Is the $vid really right? You say it has spaces in it? Did you try to delete them from the UI?
Under /admin/structure/taxonomies where you have all vocabularies listed, open the operations dropdown and click "Edit vocabulary".

On the next page click "Delete".


When making a new core release, how do mantainers tag the core modules and update their info files? When Drupal maintainers make a new core release, how do they tag the core modules and update their info files?
I have noticed that all the core modules of Drupal 7.43 have a section in their info files that looks like this:

version = "7.43"
project = "drupal"
datestamp = "1456343506"

Is there an automated procedure that runs GIT to merge branches, tag releases and updates the info files accordingly?

Yes, it is an automated process, check below:

  The version string will be added by drupal.org when a release is
  created and a tarball packaged. However, if your module is not being
  hosted on the drupal.org infrastructure, you can give your module
  whatever version string makes sense (eg. see Release naming
  conventions).

NOTE: The above description is exact copy paste from Drupal.org link.


How to hide country in Address Field display? Using Drupal 7 with Address Field module.  How to prevent the country part of the address field from displaying on a node with an address field?

For example, address is:

123 Main St
Somewhere, NY 10001
United States

I want the node to show:

123 Main St
Somewhere, NY 10001

I overrode the field.tpl.php file as described in this video:

Drupal 7: Theming Fields and Nodes with Templates by linwclark

I copied the field.tpl.php file from <site_root>/modules/field/theme/field.tpl.php and put it into the templates directory of my zen subtheme (<site_root>/sites/all/themes/somezentheme/templates/field--field_address.tpl.php)

In that template I used the hide() function on country:

  <div class="field-items"<?php print $content_attributes; ?>>
    <?php foreach ($items as $delta => $item): ?>
    <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>><?php hide($item['country']); print render($item); ?>

    <?php endforeach; ?>


A View for Referenced and Referencing Nodes Possible Duplicate:
  How to implement two way node references?

I am working on an employee directory, with the data being imported from Active Directory.  I am creating profile content nodes, and using a node reference field to indicate who the employee's manager is.

I can create a view that will show me the emplyoee's manager, and information from the manager's node (through a relationship), but I do not seem to understand how to make a view that will display a manager's employee's.

Help, pointers, doc's or examples are greatly appreciated!


CCK fields revisions (D6) I have a node type with its revisions set to ON
I am not sure this is a bug on my copy or Drupal 6 doesn't save any revisions for CCK fields in the node and only does that for title and body?

CCK stores values against the vid, so you should be able to see the history of your fields (you can look in tables like content_% to check that the raw data's there). Otherwise a revert would be fairly useless for most situations involving fields. Can you confirm the results of the following?

Create new content type with revisions turned on.
Add text field.
Create a node of this new type (add some text to the field).
Edit the node and update the title, body and field.
Revert the node to its first state.


Unflagging (by rule) doesnt show rightaway I have 3 flags in my custom content type "Movie"
Seen , Unseen , Want to see...

these 3 flags are mutually exclusive , that is if a user has "seen" a movie he cant "unseen" the movie..

To make the flags mutually exclusive I have added rules , so whenever one of the flags are flagged, the other 2 are unflagged.

Now my problem is, when i flag a movie with say "seen" , the other 2 flags "unseen" and "want to see" are unflagged internally, but that unflagging effect is not visible on that page right away. When i refresh the page , then i can see those changes.

How can , i see the changes right away ??

I am assuming you are using flag's javascript toggle to set these flags, and if that's correct, you could hook into flag's flagGlobalAfterLinkUpdate event and refresh the portion of the page where your flags are set.  More details are here:  http://drupal.org/node/336122.  If you don't want to do this, you could always set the flag link to a normal link, which would refresh the page for you in of itself.


Add custom files/file-fields to panels pages I would like to add content from a set of file fields to particular pages (via panels/panels everywhere/panelizer) with the ability to change the files by panels IPE editor or backend form.

Ideally, I would like to just add a custom content pane, or minipanel (or whatever it needs to be) to specific panels pages, and have that widget be able to upload files that print to the page, and that page only. It would also be nice to reuse the widget for other panels pages for different sets of files. I'm trying not to involve a whole other set of node/content types just to do this.

Could anyone point me in the right direction? Thanks.

Detail: The purpose is to upload files and add file paths to an element on some pages which is the image/video source for a fullscreen image/video background script.

What you are looking for is a customized fieldable panel panes. You can also check Panopoly Widgets for a similar example. It contains a lot of custom widgets which can be embed in panel panes and customized.
Fieldable panels panes makes your widget data as fieldable entities instead of node/content types(which is what you want).

If you want dynamic background images on a specific page context, you could check the dynamic background module.


Can't change my custom logo for Bartik-theme. How to fix this? Have newly installed Drupal 7 . Tried to change my logo to a custom logo. Worked the first time. Theme Bartik was activated. Now wanna change the logo a second time, can't do it. Can't disable it. Appearence->Settings->Custom Logo won't change or when i uncheck Logo nothing happens. Switched appearance to Stark,   everything worked as expected. Switched back to Bartik no logo-change-feature anymore / still the old logo.

Any suggestions/help? Thank you in advance.

Silly me. There exists global settings / bartik settings etc. I was convinced i used global settings all the time but nope, and if you specify a bartik logo, it overrides the global one. Thank you for trying to help me.


User authentication handled by a web service I seek your help and advice. By default, Drupal manages user authentification using the user module that resides in the "core/modules" and through the main Drupal Database. In my case, the user is authenticated through an external webservice, the process is as follow:
1- The user enters his credentials and click submit
2- the credentials are then sent to the webservice
3- the webservice checks the data(credentials) to the one he has in his database
4- upon validation the webservice sends a token (JWT) otherwise it sends 401 Unauthorized

PS: the admin will have normal login (through Drupal Database)

The question is how can I proceed to elaborate this process of authentification?

Is there some existing modules that could help with this?
should I override the existing user module or create a new module?

Any info will be of great help.

Remote authentication can range from moderately complex to major complex.

In general, you will need Drupal users that match your external DB users.  Drupal security and coding is tied to this.  The easiest way is to create users that match your remote DB and then only do authentication.

How you syncing the remote to the local can quickly add complexity.

Other things you will need to deal with are overriding the password reset functionality.  Changing it in Drupal will not change it in your remote DB.

Some reference material / modules to look at:

Authentication API (incomplete)

The LDAP Project - A full featured implementation with dynamic provisioning (creates local Drupal id's if user authenticated) and other stuff.

The External Auth Module - Just ran across this.  May or may not be applicable.


How to get the current question's NID? When taking a quiz with multiple questions, how do I get the current question's NID? The URL only contains the quiz' NID (node/1234), even when I started the quiz there only this NID is available (node/1234/take/1). When I node_load(arg(1)) there also is no clue of how and what questions are mapped to a quiz.

quiz-7.x-5.0-alpha10

Thanks a lot @J.Reynolds for pointing me in the right direction!

/**
 * Helper function to get current question's NID.
 * @return string node ID
 */
function _current_question_nid() {

  // Presume a URL node/1234/take/2 meaning we are at the second question
  // of a quiz, where arg(1) is the quiz NID

  // Now let's look inside SESSION. There's our current quiz NID.
  if (array_key_exists(arg(1), $_SESSION['quiz'])) {

    // Inside there is the current result ID.
    $result_id = $_SESSION['quiz'][arg(1)]['result_id'];

  } else {

    // A little bit different to get the current result ID at last question.
    $result_id = $_SESSION['quiz']['temp']['result_id'];

  }

  // Now we can load the quiz results from that result ID.
  $result = quiz_result_load($result_id);
  // There all question NIDs are inside, nicely ordered, yay!

  // Finally let's take the question number and get its NID.
  $current = $result->layout[arg(3)];
  return $question_nid = $current['nid'];
}


Get field (list type) label in a twig template I have a content type (appel_offre) with a field_categorie_avis field, which is a list type with these values.

ouvert | Ouvert toute l'année
restreint | Restreint 24h
concurrence | Appel public à concurrence

In the node--appel-offre.html.twig template, I want to print this field but I only get the key, not the value. For example, for Appel public à concurrence, I always get concurrence.

I am using node.field_categorie_avis.value. Is there another way to get the same value?

You can use

{{ content.field_categorie_avis[0]['#markup'] }}

to display label.

Dont miss the [0] because drupal always store items in array in case of field size limit change.


How do I remove  from output? I'm trying to theme the output of a Drupal 8 view to use via a token for email recipients of a YAML form. I'm on the latest Drupal 8 core release and using a Bootstrap subtheme.

I have successfully removed all of the other views markup with the following TWIG theme override templates:

views-view-fields--ts--page_1.html

views-view--ts--page_1.html

views-view-unformatted--ts--page_1.html

For some reason, I keep getting the following markup added:

I have tried using the views UI options to strip HTML and/or customize the markup output and this does nothing. I've also tried using the TWIG filters like striptags, but this either removes the entire views output (a comma separated list of email addresses) or doesn't work at all.

How do I remove
?

Okay, I figured it out. After setting the services.yml file debug to "true" and enabling comments in my Firefox console, I was able to get the theme output for the particular set of divs that was adding the unwanted markup (I tried this earlier, but I think I forgot to rename default.services.yml to services.yml).

Anyway, I found that the markup was coming from Bootstrap's container.html.TWIG template. Of course, this is one of the templates that doesn't come with override suggestions, just the hook theme_container() theme function. So I copied the default function into my [subtheme name].theme file at the top of my subtheme's directory and modified it thus to suit my needs:

<?php
// Implements hook_container().
use Drupal\Core\Template\Attribute;

function vatheme_container($variables) {

  $request = \Drupal::request();

  if ($route = $request->attributes->get(\Symfony\Cmf\Component\Routing\RouteObjectInterface::ROUTE_OBJECT)) {
    $title = \Drupal::service('title_resolver')->getTitle($request, $route);
  }

// Special handling for form elements.
$element = $variables['element'];
 // Ensure #attributes is set.
$element += array('#attributes' => array());

        if (isset($element['#array_parents'])) {
            // Assign an html ID.

            if (!isset($element['#attributes']['id'])) {
                $element['#attributes']['id'] = $element['#id'];
            }

            // Add the 'form-wrapper' class.
            $element['#attributes']['class'][] = 'form-wrapper';
        }

        if($title == 'Contact Tech Support'){
            return $element['#children'];
        }
        else{
            return '<div' . new Attribute($element['#attributes']) . '>' . $element['#children'] . '</div>';
        }
}

So, that seems to do the trick. This was my first stab at doing theme work in Drupal 8 and there are a lot of not insignificant changes from Drupal 7 here, so I thought I'd go through the details of my solution. Hopefully this helps someone else out there.


How to select Views as a Context reaction block? I would like to create a new Context (Drupal 7.39) and choose Blocks as reaction. In blocks, I would like to choose a specific View and add it to a region. However, 'Views' is not in the list on the right (where it says nodes, search, system, users, etc). In other sites I manage, Views is part of that reaction>blocks list.

Does anyone have any idea why it might not be listed here?

To achieve you requirement please follow the steps below.

In view configuration, under advance settings select Exposed form in block as a Yes.

Now you can see your view listed at right side.

  Please remember, only blocks can be place into region, thats why you
  have to first expose your view as block.


Hot to pass an argument to #ajax['path'] I have a form with a radio buttons (inside div#edit-field-nomination-und). I need to call a following AJAX callback:

function _onfit_ajax_get_term_description_callback($term) {
  return array(
    '#type' => 'ajax',
    '#commands' => array(
      ajax_command_html('#nomination-desc', $term->description)));
}

function onfit_menu() {
  // ...
  $items['ajax/onfit/taxonomy/term/%taxonomy_term/description'] = array(
    'title' => 'Get taxonomy term description by AJAX',
    'page callback' => '_onfit_ajax_get_term_description_callback',
    'page arguments' => array(4),
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
    'delivery callback' => 'ajax_deliver',
  );
  return $items;
}

Here is an attachment code (I dislike it and I want to use #ajax['path']):

Drupal.behaviors.onfitExampleBehavior = {
  attach : function(context, settings) {
    $('#edit-field-nomination-und input', context)
        .once('edit-field-nomination-und', function() {
          var url = '/ajax/onfit/taxonomy/term/' + $(this).val() + '/description'
          new Drupal.ajax('nomination-desc-wrapper', $(this), { url: url, event: 'change' });
        });
  }
};

Is it possible to attach AJAX callback to a radio buttons by the means of hook_form_alter? I don't want to use #ajax['callback'], because the entire form will be send during each AJAX call. I think #ajax['path'] must be a more lightweighted. But the problem is that I don't understand how to pass a selected radio item id to a #ajax['path'].

From the docs:

  It is possible to replace ajax_form_callback() with your own functions. If you do so, ajax_form_callback() would be the model for the replacement. In that case, you would change #ajax['path'] from the default 'system/ajax' and set up a menu entry in hook_menu() to point to your replacement path.

So you need to

Set up a menu callback (looks like you've already done that)
Copy ajax_form_callback() to that path's page callback function
Make the changes you need to. The function is very short so it should be obvious which bits you need.
In your form elements use this:

$form['foo'] = array(
  ...
  '#ajax' => array(
    ...
    'path' => 'path/to/new/callback',
  ),
);

You shouldn't write any JS code to invoke this manually, Drupal takes care of that for you.

Note that this method does load the full form; that's unavoidable using Drupal's built-in AJAX functionality.


How to check if a menu exists programatically in Drupal 8 I have a script where I instantiate and fill menus with menu items programmatically.

Whats the best way to check if a menu already exists if I already know it's ID.

A menu is a config entity, which means you can use standard entity API to load it.

\Drupal\system\Entity\Menu::load() or \Drupal:entityTypeManager()->getStorage('menu')->load()


What if nid reaches the maximum ? What if my nid reaches the maximum allowed value of MySql int type

I have made a drupal.org site search that ends up Here. And also i found Integer Types (Exact Value). In an app that i am about to build is a contact manager for students. Which is supposed to pull gmail, fb contacts in future. My plan is to make each contact a node. Is it a good idea to keep each contact as separate node? Can you suggest any other brilliant mechanism to handle this?

I am worried about the overflow of nid as i made a test run using may own gmail id, which ends up in a 1025 new nodes.

I am using typical Drupal 7.14 installation.

If nid reaches the maximum your site will no longer be able to create new nodes as there will be SQL errors whenever Drupal tries to insert a new nid.

Chances are though, that drupal.org will hit this limit before you do, regardless of what you're doing to your site in any useful real-world application.

If drupal.org gets anywhere close to 4 billion nodes, there definitely will be a workaround readily available for you.


How to get the node from the url referer? I have a custom entity named Application that has an Entity Reference field named Product.

When I am on an Apllication page and click on a Product to see it, I would like to know that I come from the Application page and know its ID.

This would allow me to display information from the Application page on the Product page.

But how to do it ?

This method works for me:

use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Url;
// Getting the referer.
$request = \Drupal::request();
$referer = $request->headers->get('referer');
// Getting the base url.
$base_url = Request::createFromGlobals()->getSchemeAndHttpHost();
// Getting the alias or the relative path.
$alias = substr($referer, strlen($base_url));
// Getting the node.
$params = Url::fromUri("internal:" . $alias)->getRouteParameters();
$entity_type = key($params);
$node = \Drupal::entityTypeManager()->getStorage($entity_type)->load($params[$entity_type]);

//to use dpm you need the devel module
dpm($node->id());
dpm($node->title->value);


Count words of a body field using PHP views field I'm looking for a way to count the amount of words in my body fields, using Views PHP. I am totally new to PHP and this looks so easy, but I must be missing something.

So I have a View for Content, containing a body field (hide display, HTML trimmed) and a Global: PHP field.

I have this in my "Value Code"-field inside the Global: PHP field settings:

$count = print $row->body;
$result = str_word_count("$count");

And this in my Output:

<?php echo $result ?>

Seems I must be missing something, but I get no error, nor any result. Just nothing happens.

So, after a long research, I stumbled at this issue post. It seems that field data are not present in the result set of Views PHP, so instead of print $row->bodyI needed to use print $data->_field_data['nid']['entity']->body['nl'][0]['value'] to access the data.  This solved my problem.


Drupal ignores check_markup() It seems like Drupal is ignoring check_markup(). What is wrong with the code below?

print check_markup($node->body, 'microblog', TRUE);

Site's default input format filter is = 'Filtered HTML'. All users have access to the 'microblog' filter, but I see my 'microblog' filter is kind of not working, and it uses filtered HTML.

What am I doing wrong?

In Drupal 6, the second argument of check_markup() is the value of the "format" field in the "filter_formats" table; it is a serial field, which means it can contain only numbers.

The documentation for the function doesn't specify what you should pass; it uses a phrase that could be misunderstood, but it doesn't talk of format name.

  $format The format of the text to be filtered. Specify FILTER_FORMAT_DEFAULT for the default format.

Looking at how the function is called in node_prepare(), I noticed the code that calls the function is the following one:

  if ($teaser == FALSE) {
    $node->body = check_markup($node->body, $node->format, FALSE);
  }

The content of $node->format is always a number, in Drupal 6.

In a standard installation of Drupal 6, without any extra modules installed, these are the values for the format ID to pass to check_markup():

Format ID     Input format
---------------------------
1             Filtered HTML
2             Full HTML
3             PHP code

To get the format ID knowing the name (e.g. "Filtered HTML"), you should use code similar to the following one:

$format_id = db_result(db_query("SELECT format FROM {filter_formats} WHERE name = '%s'", $format_name));

The format ID required from the function is different from a filter ID: An input format is a set of input filters that are used together to filter out or change what entered from users. What the modules implement are input filters.


error message when installing drupal 8 When I was installing Drupal 8 (Macos, nginx, php7.0, mysql5.6), the following error occurred, Can someone help me?

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /core/install.php?langcode=zh-
hans&profile=standard&continue=1&id=1&op=do_nojs&op=do
StatusText: OK
ResponseText:
Warning:  Declaration of
Drupal\Core\DependencyInjection\ContainerBuilder::callMethod($service,
$call) should be compatible with Symfony\Component\DependencyInjection\ContainerBuilder::callMethod($service, $call, SplObjectStorage $inlinedDefinitions) in /Users/xile/code/drupal/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php on line 22
Drupal\Core\Config\UnmetDependenciesException: Configuration objects (block.block.bartik_help, block.block.bartik_search,
block.block.seven_help, contact.form.feedback,
core.entity_form_display.node.article.default,
core.entity_form_display.node.page.default,
core.entity_form_display.user.user.default,
core.entity_view_display.node.article.default,
core.entity_view_display.node.article.teaser,
core.entity_view_display.user.user.compact,
core.entity_view_display.user.user.default,
field.field.node.article.field_image,
field.field.user.user.user_picture, field.storage.node.field_image,
field.storage.node.field_tags, field.storage.user.user_picture,
rdf.mapping.comment.comment, rdf.mapping.node.article,
rdf.mapping.node.page, rdf.mapping.taxonomy_term.tags,
taxonomy.vocabulary.tags) provided by standard have unmet dependencies in Drupal\Core\Config\UnmetDependenciesException::create()(line 89 of /Users/xile/code/drupal/core/lib/Drupal/Core/Config/UnmetDependenciesException.php).

Install drupal console and then try to install the site using drupal console

https://drupalconsole.com/articles/how-to-install-drupal-console

drupal si


How can I get the full content of a PHPUnit test truncated response? I'm writing a Functional test (extending BrowserTestBase) for a Drupal REST resource.  My resource works fine in real life, but the test (running with --verbose and --debug options) throws a server error

...resulted in a '500 500 Service unavailable (with message)' response:
The website encountered an unexpected error. Please try again later.

Drupal\Component\P (truncated...)

This happens when I make the request, before I can try to catch it in an assertion.  I'm pretty sure that truncated output has the information I need to solve this, but I'm having no luck getting to it.  Drupal console docs say there's a test:run command but when I try that (v1.8.0), it tells me that's not a valid command name.  I've tried running my test through the debugger but no help there, either.

Is there any way I can get to see what's in the truncated part of the response?

My problem stemmed from trying to use GuzzleHttp to make my request, instead of BrowserTestBase::drupalGet().  I still don't know about getting to that truncated output, but using drupalGet() returns the output without truncating.


How to set ajax event to onkeypress event? $form['name'] = array(
        '#type' => 'textfield',
        '#title' => t('Name'),
        '#size' => '27',
        '#inline' => 'true',
        '#required' => TRUE,
        '#prefix' => '
',
        '#suffix' => '

',
        '#ajax' => array(
          'effect' => 'fade',
          'callback' => 'ajax_textfield_callback',
          'wrapper' => 'ajax-display',
          'event' => 'onkeypress',   /////////////////Want to add event
        ),
    );

Here in example i have to add event (slashed location). By Default it takes on change event. I want to change that event to onkeypress event.

See this link.

You can specify any valid jQuery event.

So, you need to change 'onkeypress' to 'keypress'.


Queue Implementation for third party api In my website I have a form and which submits data to third party website. that api is available some time and not available some time. I need to create a queue mechanism to insert failed api calls and show them in admin panel.

Once admin wants to process the queue then that data needs to be resubmit to the third party site.

I need to know how to setup a cron job for the same , if we have more records then we can run cron for every 10 mins.

Any suggestions? I am new to this drupal8 queues.

I think this is what you want:

'If any failure occurs, you can revert the item back to queue to process that again'

The queue API of Drupal 8 which is known as Queue Worker

http://www.tothenew.com/blog/how-to-implement-queue-workerapi-in-drupal-8/


Page Manager on a variant of the node url I have overriden the default /node/%node layout using panels and the page manager, now I need to add some different content when the URL is /node/%node/step2.

I have added a variant, and on the selection rules I added the URL path on /node/*/step2. I also tried different URL paths like /node/%node/step2 or even */step2.

But if I go to that URL it doesn't show up, and returns me a 404. This seems odd since that, if no other variant would be found (like my new /node/%node/step2), the default /node/%node page should be shown instead of a 404.

So my question is: why am I receiving a 404 instead of my "step2" variant, or even the default node page?

I'm using Page Manager 7.x-1.12.

I don't know if this is the only way to do it but I just add custom pages at /admin/structure/pages like:

/node/%node/admin

I guess there are some benefits to doing it separately instead of as a variant of the main /node/%node because now your selection rules etc. are easy to manage for different content types, for example.

Your arguments page should look like this:


Find out which theme is loaded in a given page I am trying to do some theming for Drupal 8 and I was trying to understand what theme is being used on a given page. I remember using theme developer module in Drupal 7, and using dpm() of the page array after theme developer started having issues.

How can I achieve the same with Drupal 8?

In Drupal 8, you can do two things from custom code:

\Drupal::theme()->getActiveTheme();

\Drupal::theme()->getActiveTheme()->getName();

The first will return a theme object, the second will return just the theme name.

See the ThemeManager docs for more details.

You can also install Devel/WebProfiler for more information about the current page request and other variables.


Is there a way to create a Rules component programmatically? Is there a way to programmatically create a Rules component?

I mean a component like the ones listed on /admin/config/workflow/rules/components.

Rule components can be programmatically created- although they can be quite cumbersome to code from scratch.  I'd recommend building a component with some conditions, actions, and rulesets and exporting it.  Then you can analyze the exported php to determine how to define your custom component set.

You'll most likely want to reference:

A list of the hooks available for the D7 version of the Rules module can be found here:  http://www.drupalcontrib.org/api/drupal/contributions%21rules%21rules.api.php/group/rules_hooks/7
A good set of Developer Documentation for custom rules (albeit an old set of documentation for the D6 version of Rules) can be found here:  https://www.drupal.org/node/298486


How to embed username and password in a URL? We have a form that users need to fill out, but it is accessible only to authenticated users. We want to send a mass email to all users with an username and a password embedded in an URL, so that users can just click on that URL and log in to Drupal. The username and password will be common for all users.

Is it possible to log in to Drupal through this way?

There is currently a sandbox module called URL Login waiting to get approved to become a full project. See the project page and the full project application issue.

That module provides a secure way to log in through an URL. If that module is useful to you, I suggest you mention that in the linked issue so that it can become a full project soon.


How to show hidden fields when using Display Suite module to manage display? I'm an addicted user of the fantastic Display Suite module to manage the displays of content types. But it sometime happens that after changing the layout of a content type (e.g. Two stacked column) some field doesn't show up. This happened with the location node field solved in this issue by its author.

Now, I'm using the Ubercart Auction module which create a content type called 'product'. When you add a product you fill some auction settings. Then when you load the node it shows a form with auction info and links. This one:

So far so good. Now if I go to admin/structure/types/manage/product/display and change the Layout to Two stacked column I get no field to show this form. I get all other fields (body, title, images,...) but no one to show that auction form.

I know that the field is a form but I don't know how make available as field.

How can I solve this?

@lance:
Maybe I should show where are the auction setting in the node. Look this picture:

You need to enable Extra Fields, which allows Display Suite to manage module-created fields.


How to download files through IMCE file browser? I found the IMCE has upload and delete buttons, but not download. Is there a way to add download feature, if so how?

There isn't one built into the module. One work around is to use IMCE user file browser (/user/[uid]/imce) and click on the preview image. It will open up the image URL in a new tab/window where you can download it through your browser.


Create a view which shows related staff members based on taxonomy I wish to show relevant staff members when users a viewing a particular page. For example when certain pages about membership are being viewed i wish to show the staff members designated as a 'Member Relations Officer'. I have a taxonomy called 'selected job roles', in which 'Member Relations Officer' is a taxonomy term. At the moment I have set up the staff members as users on the site, therefore they are not a distinct content type. I have added a 'selected job roles' term reference to the user fields within Account Settings.

I also added the 'selected job roles' term reference to the basic page content type. I have created a view block called 'selected job roles' in which I am trying (and failing) to set up a contextual filter correctly to show the staff members. I have a basic page with 'selected job roles' set as 'Member Relations Officer' and also a user with 'selected job roles' set as 'Member Relations Officer'. I have been trying to get it to work by doing things like setting up the contextual filter get the 'taxonomy term from url' when the 'Filter Value is not available'. However none of the contextual filter settings i have tried work.

Could somebody please advise me what settings i should using in the contextual filter? Was setting up the staff as users a mistake that is stopping this from working properly? Thank you in advance.

I have now got this to work! While I don't fully understand what is going on I thought I'd share it here in case it helps somebody else.

I created a content type 'staff profile' to work with rather than using users. The staff profile content type has the field 'selected job roles' added to it.

In views I made a new view with a display of block. I added a new contextual filter for 'Content: Nid' and set 'when filter is not available' to 'provide default value' and selected the 'content ID from URL' for the type.

Then I added three relationships.

The first was 'Content: Taxonomy terms on node', selecting my vocabulary 'Selected Job Roles' and ticked the 'require this relationship' checkbox.

The second relationship I added was '(term) Taxonomy term: Content using Selected Job Roles' and ticked the 'require this relationship' checkbox.

The third and final relationship I added was the field itself '(field_selected_job_roles) Field: Selected Job Roles'.

I then added a filter criteria 'Content: Type (=Staff Member Profile)' so that only staff member profiles would be displayed.

Now, having done all of this i clicked on the contextual filter for 'Content: Nid' that I set up earlier. I think that because of the relationships that were added there is now an extra option here that was not there before. This new option is a Relationship drop down. I changed this from 'do not use a relationship' to 'field_selected_job_roles'.

The 'auto preview' at the bottom of the page did not return any results when I added an appropriate contextual filter. However going to my test page everything was working correctly!

I would appreciate it if anyone can provide an explanation on why this works. However in the mean time I am just happy to have resolved the issue.


How to modify the class names of socialmedia module I am using social media module. When I inspect the page in chrome, I see some div classes. My css is conflicting with module css classes. I was thinking to modify module's div classes. I was looking for the tpl file inside social media folder but I could not find it.

Which file in social media module has the div classes so I can modify the div classes?

As you can see here https://jsfiddle.net/81kbx4f4/, if you do an inspect element, you will see them here too.

Those are added by facebook and it's not something that you can control.


Make some text of the calendar module multilingual? I instaled and got running fine the 'calendar' module. I just need to make some texts multilingual.

This module generate a view which shows a monthly calendar, then you can change to weekly canlendar, day calendar and so on.

To switch between this display this module show some links above the calendar. The text for these link are what I need to make multinlingual (see picture 1)

These links are taken from the name of the display of the view (see picture 2)

How can I accomplish this.
Thanks

The calender links are defined in the calendar/theme/theme.inc in the function function template_preprocess_calendar_main(&$vars) here you can see that the $calendar_links  use the function date_t() as found in the date_api.module and can be translated. In other words, if i am correct, you can translate this through the translate interface, as found on admin/build/translate.


How to programatically convert nodes from draft to saved Is there a way I can convert all my imported nodes into "saved " status instead of "Draft" programmatically? Can this be done in a hook and what would the code for doing this be? If it can be done with Rules how exactly would this rule be created?  This has to be something that is done without any user interaction, so Views Bulk operations is not the answer.

I am using workflow module, and it has two states, the first one is draft, the second one is "Done"

Thanks,

You can change Workflow status for all nodes using Views Bulk Operations module
Here is a little manual how to accomplish this task:

Download and install Views Bulk Operations module
Create a view that will show content of necessary content type in table format.

Add in this view next fields: Content: Title, Workflow history: New state name, Workflow history: Old state name and Bulk operations: Content.

Open created view page, select all nodes, choose "Change workflow state of post to new state" operation and click on the "Execute" button

Choose new node state and click on the "Next" button

On the next page press on the "Confirm" button


Allow User Role To Schedule Content As Different User I am creating a "submitter" user role which should be allowed to post articles as different users - what permission do I need to set for this on the "Permission" page under "People" to grant access to the "author" field?

If thats not possible is there a module for it?

That would be Administer Content. Be careful with this, because the permission provides a lot more than simply control over the node Author identity.

The alternative would be the Masquerade module, which would allow the user to pretend they were a different user, and post content as that user. A little more involved for the posting user, but safer for your site.


How to check if node is being rendered inside view? I need to check inside node template if its contents are being rendered through view or not. What is the best approach to do it?

You can check to see if $view is set and is an object in the template file; if it does, it means the node is being rendered in a View. From there you can even check that the View is the correct one if you need to.

if (isset($view) && is_object($view)) :
  // Do something
endif;


How to fix the unresolved dependency in the Flag module about Flag Friend? I am trying to update my modules and I am getting this error line:

  Fatal error: Class 'RulesEventHandlerEntityBundle' not found in
  /home1/kctd/public_html/community/sites/all/modules/rules/modules/node.rules.inc
  on line 147.

I am in the Update.PHP screen (see photo near the bottom) and I have a few unresolved dependencies. I would normally retro install some of those modules, but when I try to check manually, or even go to my modules screen, I get the error listed above. I am locked out.

What should I do?

According to your "unresolved dependency" error messages, you are currently using the 2.2 version of the Flag module. While the Flag Friend module requires the 2.1 version of it.

It's worth trying to replacing the entire flag folder in your modules directory as follows:

backup your flag module folder (to somewhere outside your Drupal root).
delete the flag module folder and its entire content.
download the 7.x-2.1 release of the flag module and unpack that version in the very same "flag" module folder.

Then try again and see if that helps. If not restore your backup directory (to try some other approach).


What is your recommended Banner/Slider module for D7? I am searching for module that create banner/slider effect for D7.

Have a check on this page:
http://drupal.org/node/418616

Mostly not yet port to D7.

What are your recommend modules?

I have used Views Slideshow a couple of times and it was quite easy to use. It's based on the jQuery Cycle Plugin. The port to D7 is in alpha, so you might want to give it a go and contribute back to help the module reach a stable state.

That said, a module is not strictly necessary to do things like this. It's surprisingly easy to implement the (well documented) jQuery Cycle Plugin yourself, directly from your theme. Just add the plugin and write about 10 lines of jQuery in a custom .js file.


How to validate fields with the Rules module? I have created a Rule with the Rules module to validate the form on submission.

I try to compare the values of two fields to ensure one not higher than the other. But I couldn't find the appropriate Rules Actions to stop the form submission and prompted an error message.

Please advise.

Event: After saving new content of type Article

Condition: Data comparison
Parameter: Data to compare: [node:field-price-A], Operator: is greater than, Data value: [node:field-price-B]

Actions: ??

It sounds like you don't have the supporting module Rules Forms: https://www.drupal.org/project/rules_forms

This module adds form validation for existing (core) forms and custom forms from contrib modules.

The documentation states that Rules Forms can:

Validate the values of form elements during form validation.
Set form errors when rule-based validation fails.


Conditionally unpublish nodes for feeds We have a content type that up until today was 100% driven by a feeds importer on a D7 site from an XML file (from a third-party system). This importer ran nightly and was set to "Unpublish non-existent nodes" which worked perfectly to remove items not available anymore.

Due to a business needs change we now need to manually create a couple of nodes of this specific content type and we don't want the importer to unpublish these specific nodes. Modifying the third-party system is not an option so the only possibility that we've come up with is to create a local file (CSV/XML/whatever) and create a new importer to run after the original importer to re-publish them.

We could also locally consume the original file and merge it with our custom node list but this seems like more things could break.

Is there another solution to this problem that we're missing?

You seem to be using a version of feeds that is fairly recent (perhaps version 7.x-2.0-beta2). Having said that, the process function of the FeedsProcessor class is fairly inflexible when it comes to modifying the list of imported nodes that it wants to clean out of Drupal, in that it does not provide a hook to modify that list.

Having said that, your best bet is probably to extend the FeedsNodeProcessor class and only override the initEntitiesToBeRemoved function to then exclude "potentially unpublished" node ids from $state->removeList. You'll need to determine how all of the nodes from $state->removeList were created.

How you determine a manually created node from a feeds imported node is up to you but I would recommend querying the feeds_item table. If a node's nid is not found in that table then it's safe to assume that the node was manually created.


How can I avoid that users vote for their own posts? I want to avoid that users can vote for their own posts, as it happens on Stack Exchange sites. For this, I created the following rule:

ON event "User votes on a node", the condition is "execute PHP code" and the code is the following one:

global $user;
return $node->uid != $user->uid;

Still, users can vote on their own posts. What should I do?

Using the following code, I get an error message given below.

global $user;

dpr($user);
dpr($node);

return $node->uid != $user->uid;

The rate module allows you to do this in its settings. You have to create a widget for this : admin/structure/rate (just add a new one and then you'll see the option).
You will be asked to choose the content type and the position of the widget in the page that you need to define to see the vote system. I didn't try nor with views integration, neither with Drupal 6.


How do I get the plain text value for the {{ label }} field in a twig node template? Very simply put, I want to print the plain text from the title field of my node without any additional html. Currently I have this in my node--custom-template.html.twig file

      {{ label }}

but it outputs it like this

          My Title

I'd like it like this

My Title

I've tried using some of the twig filters like |striptags and |raw, but then nothing displays. I'm wondering if there is a template I could edit for this field, or any other way to just get the plain text string of the node title.

You can get the unformatted title from the node object:

{{ node.label  }}


How to add Parent and Child to a Views 3 table format using Groupping Field? Working with views and a taxonomy list is a popular subject at DA. Many of the examples I've found refer to making a jump list of taxonomy terms and parent terms similar to what you may see with a nested vocabulary on your site's core taxonomy page [1] (following the list terms link on any given vocabulary). My Views view goal is just as simple and I'm nearly there except for two important requirements.
My Views view is a catalog of node content titles and truncated descriptions categorized by a two level vocabulary. (Think of finding something at a hardware store). The goal is a single page without a sorting requirement (think of it as a very small hardware store, so I skipped the answers suggesting wild card sorting in the URL). I'm nearly there using the table format where I've used the setting Groupping Field Nr. 1: Content: My_Taxo to organize the node content. This creates a separate table for each group and a caption element for each category.
The first missing requirement is the parent term.
The instructions for a simple vocab list say to add the Relationship, Term parent. This adds several new items to Fields: add list page. Unfortunately, none in this list are distinguished as parent term, which means I can't easily add a parent taxonomy term field, add a child term field, go back into Table: Settings set Groupping Field Nr.1 to be the parent and Nr.2 to child and be done with it. (9_9)

Content: All taxonomy terms
Taxonomy term: Name
Taxonomy term: Rendered Taxonomy term
Taxonomy term: Term description
Taxonomy term: Term edit link
Taxonomy term: Term ID
Taxonomy term: Weight
Taxonomy vocabulary: Description
Taxonomy vocabulary: Machine name
Taxonomy vocabulary: Name
Taxonomy vocabulary: Vocabulary ID

The second missing requirement, which may only be correctly answered by the first problem, is the captioned tables do not sort in the same order as the weights set on the taxonomy page list. To try to set this requirement I added, Sort criteria: (menu_category) Taxonomy term: Weight (asc)

Starting from scratch with a dummy content type that contains just a title and a taxonomy term.

1) Create the simple taxonomy: Category_hierarchy {i.e. 1, 1.1, 1.2, 2, 3, 3.1};

2) Create the simple content type. {title, taxonomy [Category_hierarchy];

3) Create the view:

  Format: Table
   + Settings
  - Grouping field Nr.1: Category_hierarchy

  Fields
  + Content: Title
  + Content: Category_hierarchy
      -- Exclude from display.

  Sort criteria
  + Content: Title (asc)

  Relationships
  + Content: Taxonomy terms on node [1]
      -- Vocabulary: Category_hierarchy
      -- [custom] Identifier: Category_hierarchy_child

[1] This is the only taxonomy-type Relationship available.

Results show the node titles grouped by the child relationship as expected.

4) Revisiting the View now that we see what we can simply construct, we try to get the parent term added to the display. Now, under the Relationships section is a whole new list of options titled "Taxonomy term". So we add one more to get the missing relationship, parent.

  Relationships
  + Taxonomy term: Parent term
      -- Relationship: Category_hierarchy_child
      -- [custom] Identifier: Category_hierarchy_parent

If we peek into Table's settings, we would hope this might make the new relationship an available option under Grouping field Nr.1. But the grouping field options are still only Category_hierarchy and Title.

Just to be sure I added Grouping filed Nr.2 with Category_hierarchy to see if Views can do something magical and sort out the relationships automatically.

Nope. But it was worth a try. Its clear there must be some other way to populate that menu. Maybe Views has made some kind of magical field we can add from under Fields?

And that's just what has happened. We now have a new type of available field, 'Taxonomy term':

Taxonomy term: Name
 - The taxonomy term name.
Taxonomy term: Rendered Taxonomy term
 - The Taxonomy term of the current relationship rendered using a view mode.
Taxonomy term: Term description
 - The description associated with a taxonomy term.
Taxonomy term: Term edit link
 - Provide a simple link to edit the term.
Taxonomy term: Term ID
 - The tid of a taxonomy term.
Taxonomy term: Weight
 - The term weight field
Taxonomy vocabulary: Description
 -The taxonomy vocabulary description
Taxonomy vocabulary: Machine name
 - Machine-Name of the vocabulary a term is a member of. This will be the vocabulary that whichever term the "Taxonomy: Term" field is; and can similarly cause duplicates.
Taxonomy vocabulary: Name
 - Name of the vocabulary a term is a member of. This will be the vocabulary that whichever term the "Taxonomy: Term" field is; and can similarly cause duplicates.
Taxonomy vocabulary: Vocabulary ID
 - The taxonomy vocabulary ID

I've crossed out the unlikely candidates. And added each, in turn, to the Field section and looked for the field in Table's settings. Good gravy. They both worked!

I certainly don't expect tutorial answers. But I was already writing up a bug report for another problem I encountered so, my bug is your gain.


Add Google Plus link to head I'm trying to add a Google Plus html tag via direct linking (see here) to my head but can't get it to work. What I'm trying is this inside my template.php file:

$googleplus = array(
    '#tag' => 'a',
    '#attributes' => array(
        'rel' => 'publisher',
        'href' => 'https://plus.google.com/+MyPage'
    )
);
drupal_add_html_head($googleplus, 'googleplus');

Nothing shows up for me. Is there a better/working way of doing this?

Create block and place in Header Top. Go to Structure -> Block -> Add Block, then in Block body, write custom HTML. Below block body, Text format should be in "FULL HTML" to display the image.

I think it will work.


block--[region].tpl.php not working I Copied the file

bootstrap\theme\system\block.tpl.php

to my subtheme

bootstrap_subtheme\templates\block.tpl.php

I made another 2 copies and renamed them to

bootstrap_subtheme\templates\block--sidebar-first.tpl.php
bootstrap_subtheme\templates\block--sidebar_first.tpl.php

In the subtheme.info file it says
regions[sidebar_first]  = 'Primary'

The block.tpl override works but the sidebar-first.tpl.php does not get overridden.

What am I doing wrong?

The name of your template block--sidebar_first.tpl.php is correct. Clear the cache to override the template.
OR
Put this function in template.php and clear the cache. You will get the suggested template for your block.

On suggested name replace double underscore with double dash for your tpl file, and clear the cache.

function THEMENAME_preprocess_block(&$variables) {
    print_r($variables['theme_hook_suggestions']);
}


When using the webform module, is it possible to get information on the submitter's device (Mac/Win/Android), browser version, etc.? I'm using Webform 3 on Drupal 7.  I have a form on my site for people to report problems with the website itself.  Many of these reports ultimately turn out to be browser- or OS-specific, but often users do not add such information in their initial report.

Is there any way to automatically capture the browser and OS information, etc. in Webform upon submission?

It appears webform allows a default value using %server variables, but only for authenticated users.

  In addition to %get and %post, the following super tokens may be used,
  though only with logged-in users: %server, %cookie, and %request. For
  example %server[HTTP_USER_AGENT] or %session[id].

For authenticated users, try adding a User Agent field with a default value of %server[HTTP_USER_AGENT]

If your form submissions come from anonymous users, you may need an alternative way to add the %server tokens.

Other $_SERVER variables documented here: http://php.net/manual/en/reserved.variables.server.php


Checking if referenced fields are empty in commerce product display node.tpl I have a list of fields in a product display node.tpl that are references from different product types, any one of which has a combination of some of the fields of the list.
I pass the list of fields through a check to see if they exist (already answered in Check if referenced field exists in commerce product display ) and then I need to find a solution to check if any of this field is empty to avoid showing it in a dynamic accordion.
In that tplfile I reach the fields with $content['product:field_name']

I'm a little lost here, I've tried using some of field_*_field() drupal functions but I can't seem to get to the product.

Is there a way to achieve it?

you can render the field in advance, and save the html for your accordion.

the html variable will be empty if the field is empty:

$html = render($content['product:field_name']));
if (!empty($html)) {
  // accordion stuff
}


"Add content" button on related content node? Let's say I have 2 content types "Shopping center" and "Shop".

"Shopping center" is a OG group.
"Shop" has node reference field "Shopping center".

I would like to allow moderators to add shops to shopping centers on the shopping center node screen.

How to add "add shop" button on "Shopping center" node view ?

You are doing redundant work by having a node reference field. If "shop" is set up as a group post, you should be able to add new shops when in a shopping center context. There should be some kind of "group options" block that will give you these options. (Haven't done this exact thing in 7 yet but it must be similar to the way it works in 6).


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

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

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

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

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


PHP fatal error on server after deactivating modules Today our site went down with only white pages showing. The logs from the nginx server looks like this:

[01-Sep-2016 10:33:15] WARNING: [pool www0] child 26970 said into stderr: "NOTICE: PHP message: PHP Fatal error:  Class 'MigrateSimpleFieldHandler' not found in /srv/www/mysite/public_html/sites/all/modules/entityreference/entityreference.migrate.inc on line 18"
[01-Sep-2016 10:33:15] WARNING: [pool www0] child 26970 said into stderr: "NOTICE: PHP message: PHP Fatal error:  Class 'MigrateUIWizard' not found in /srv/www/mysite/public_html/sites/all/modules/migrate_d2d/migrate_d2d_ui/migrate_d2d_ui.migrate.inc on line 18"
[01-Sep-2016 10:33:20] WARNING: [pool www1] child 26712 said into stderr: "NOTICE: PHP message: PHP Fatal error:  Class name must be a valid object or a string in /srv/www/mysite/public_html/includes/common.inc on line 8026"
[01-Sep-2016 10:33:24] WARNING: [pool www1] child 26710 said into stderr: "NOTICE: PHP message: PHP Fatal error:  Class name must be a valid object or a string in /srv/www/mysite/public_html/includes/common.inc on line 8026"
[01-Sep-2016 10:34:27] WARNING: [pool www1] child 27190 said into stderr: "NOTICE: PHP message: PHP Fatal error:  Class name must be a valid object or a string in /srv/www/mysite/public_html/includes/common.inc on line 8026"
[01-Sep-2016 10:34:40] WARNING: [pool www1] child 26712 said into stderr: "NOTICE: PHP message: PHP Fatal error:  Class name must be a valid object or a string in /srv/www/mysite/public_html/includes/common.inc on line 8026"
[01-Sep-2016 10:34:56] WARNING: [pool www0] child 23319 said into stderr: "NOTICE: PHP message: PHP Fatal error:  Class name must be a valid object or a string in /srv/www/mysite/public_html/includes/common.inc on line 8026"

This happens as soon as I try to update the database, I also get a "502 Bad Gateway" message from the server just before the screen turns white.

Should I activate the deactivated modules again or uninstall them?

EDITED: I can also mention that according to the status report there are database updates waiting to be run, but when I do that locally (wamp) I get the message that no database update is required. When I try to do this db update on the web server (nginx) I get 502 bad gateway error and then the pages go blank.

Finally the problem is solved thanks to this thread.
The database update wasn't possible for the Field collection module (but it could have been any number of modules), but with the help of all the people that contributed to the solution in the thread above, I was able to get the db update to run as expected. After that everything seems to work.


Display a product with two columns I want a two-column page layout to display my products which I create with 'drupal commerce'.
The layout is basically the picture and similar articles on the left. Description on the right.

Now, I can manage the display of the product in two column with 'display suite' and then create a node view that is just a dummy page which really all it does is having one big field with the reference of the product.

I almost have what I want now because I have the picture on the left and the description on the right. How do I put the similar products block (I suppose it could be a block, right?) under the picture on the left?

It seems very dirty to add it as a field into the product. But I can’t add it to the column from the view node since I have no granular access on the single columns or fields.

What do?

You can use EVA module. With that it is possible to have a views block as a field in DS.


Limit the Link field to certain domains I'm looking for a module that will let me limit users to certain domain names when they edit a Link field.

For example, only let users enter a URL if the domain name is facebook.com, twitter.com or plus.google.com.

This list must be easily editable by admins.

Does such a module exist?

(Also: See my other question, if there is some a module that can do both it'll be great)

You can use the Field Validation module

  This module adds an extra tab to each field instance, allowing you to specify validation rules for your field instances.

From there you could a custom PHP function/regular expression to match the URLs against the field value.

This will only editable by admin in the sense that they can also edit the PHP code/regular expressions in the field validation rule. I'm not aware of a specific module that will do everything that you want without any customisation.


Drupal admin area and login, Securing them with HTTPS I've been reading a lot about this and trying many of the methods I've found and haven't yet been able to get anything working properly.

I want to be able to secure the admin area and associated login pages. So anything in example.com/admin/* or example.com/user/* etc, needs to go over SSL/TLS. We'd like this to apply to each site withing the multisite setup. So example1.com, example2.com, example3.com are all on the same server/user account.

The Setup

Drupal 7 multi site
Clean URLs enabled
PHP 5.3
MySQL v14 d5
Apache2

Notes

Securepages is not an option, as there's no stable Drupal 7 release, and using the existing dev version requires patching Drupal Core, which goes against our policy
Have tried Session 443 with no success
Have tried Secure Login with no success
An SSL cert (a self-signed one for now, while testing) is installed and works on the server for other purposes, just not Drupal.
I've read all the docs on Drupal.org about enabling HTTPS and have attempted to follow the directions there with little success
I've toggled the $conf['https'] setting in settings.php with no discernable results.

The Questions

If I enable HTTPS for everything on a site, I get a 404 for anything attempting to go through https://, which leads me to think that the rewrite rules aren't applying for the https pages. What am I missing here? Is there a rewrite condition/rule I can add to htaccess to fix this?

Is this not a solved problem in the Drupal community? Are people just leaving their admin areas unsecured, with user passwords being sent in the clear? I find this hard to believe, yet it seems that there's no built-in or commonly known solution to the problem.

It's not the question you asked, but the simplest answer is you should just change your policy.

"Hacking" core (patching it) and running unstable releases is reality of running a website.

The two patches needed for securepages frequently need re-rolls, reviews, or improvements. Get involved in that cycle and help get them stable.


How to check node permission rules? I'm using drupal commerce and I added a new product (and product display).
I can see it in the listing, but when a user click on the product page, it's saying : permission denied.
All the other products works fine, it's only the last one which doesn't.

I tried to rebuild the permissions but that doesn't changed anything. How can I check what is "denying" the page ?

Devel module has a submodule called Devel node access, it is really useful to evaluate and track permission problems on nodes. Enable it and place the blocks on a region you're using in your template.


How to show a block on the user profile page but not the user edit page? I have added a block to a region and set it so that it shows on user profile pages.

However, I want the block to be displayed only on the profile pages, not on the profile edit pages.

Is that possible?

First, enable the PHP filter module and give yourself permissions to use PHP in order to input PHP on the Block visibility settings page.

On the Block visibility settings page, you can check for an argument like this:

<?php
if(arg(0) == 'user' && arg(2) != 'edit' )
return true;
else
return false
?>

Also, see my answer on Stack Overflow.


D7 : Upload to a folder outside of "files" folder? Specifically outside of the Drupal installation folder...

I have a folder in my WWW folder that I'd like place files into through Drupal. However, it looks like, by default Drupal prefers to only upload into the "files" folder.

Has anyone encountered something like this?

I have tried making a custom upload field point to "/var/www/uploads" and the FilePath module, but neither work.

Any suggestions. Is this a case of creating a custom module that points to that folder? If anyone has come across a tutorial regarding custom upload paths that would be awesome.

Thanks for any help.

It is impossible by design, for security reasons. Imagine your users being able to overwrite your /etc/password or apache.conf - horror.

If you need outside storage, you need to use operating system methods, like:

hard links
symbolic links
mount -o bind
junctions
and probably many other


How do I count the number of items of same product class in cart? I'm a newbie to PHP, I and can't figure out how to do this.

I'm trying to alter the  price of each items depending on the quantity of the items of same product class in the cart. Let's say I have a product class "fruit" and 10 items like "apple" ,"orange", "banana" and so on. And no matter which combination, I would like to make the first item $10, the second one $0, the third one $0. So I tried this code by using UC Custom Price but doesn't work.

$firstPrice = 10;
$secondPrice = 0;
$thirdPrice = 0;

if ($item->qty = 1) {
  $item->price = $firstPrice;
}
elseif($item->qty = 2) {
  $item->price = $secondPrice;
}
elseif ($item->qty = 3) {
  $item->price = $thirdPrice;
}

It obviously seems that $item->qty is the quantity of a single item (the same node).  So how can I call do this with the number of the items of this product class "fruit "in the cart?  $item->price is the final price which will be used.

Your code is wrong because, instead of comparing the value of $item->qty, you are setting them in each control statement. Replace = with ==.

if ($item->qty == 1) {
  $item->price = $firstPrice;
}
elseif($item->qty == 2) {
  $item->price = $secondPrice;
}
elseif ($item->qty == 3) {
  $item->price = $thirdPrice;
}

The code you wrote works because an assignment statement is also an expression that have the assigned value as its value.

Instead of writing an IF-statement, you could used a SWITCH-statement.

switch ($item->qty) {
  case 1:
    $item->price = $firstPrice;
    break;

  case 2:
    $item->price = $secondPrice;
    break;

  case 3:
    $item->price = $thirdPrice;
    break;
}


Non-autocomplete Widget for Term Reference Fields on Content Type The available options at the moment are Autocomplete term widget (tagging), Select list and Check boxes/radio buttons, but I'd like to use a widget without autocomplete.

Thanks in advance.

EDIT: To clarify: I'd like to use a widget where you're able to add comma separated tags, just like the current one, but without ajax.

The code for the @2pha suggestion:

function MODULENAME_form_CONTENTTYPE_node_form_alter(&$form, &$form_state, $form_id) {
  $form['field_name']['#ajax'] = FALSE;
}


Using Boolean Module as filter in Views We are trying to use Boolean module inside Drupal 7 to define a boolean field for a custom content type , news .

the module seems to be enabled without any visible issues . the issue comes when we wish to use that boolean field's data for Filtering in a view.

e.g The boolean field is called editor-choice , in the View we wish to get all news content type that is published and has Editor's choice value to true.  please see below screenshots of the three steps being performed.

kindly assist what can be the possible issue, or if possible, suggest some other plugin that may be used foe this purpose.

If you are using Drupal latest version, boolean field is available by default in core.

Goto your content type => Manage field => Add new field => Select field type

In the manage field configuration, give 'on' value and 'off' value. Here I have given, Yes and No.

In the views filter, select the option you wish to filter. Thats it.