texts: How can I show country icons in the select list provided by the countries module on the edit page?

texts:
I am using the 2.x series of the Countries and Country Icons modules.  They are both installed properly on my site.

I have a country field called "Nationality" on the user profile page.  I would like to show the flags in the drop-down list (the select widget) when users are editing their profiles.

There is an example of how to show countryicons with user info in the Country Icons documentation but this is for displayed comments, not an edit form.

Basically, what I want is to give the look that the Language Switcher Dropdown module does (screenshot on module page), but for a country field.


texts: How to select by default nodes of a content type in admin/content through a link?

texts:
I'd like to make a link to admin/content/, but when the page was displayed I'd like to have it filtered by a certain content type.

The link can be like this admin/content/house so when I click it, the admin/content page is already filtered by house Content Type.

Is this possible?

Is something like this How to link to dblog filtered by type? but for the admin/content path.

Edit: If I click in a link that can be like this admin/content/house I can have in the admin/page the Content Types filtered by House, something like this picture


texts: D6 - Rule to simply redirect path to login

texts:
Currently I'm trying to add create a rule that simply redirects anyone from /node/add to /user/login. It's intended to be part of a larger rule, but I'm having No luck with this

Steps of the rule are

Trigger - User is going to view a page
If path has alias(es) - /node/add
Do page redirect to - /user/login

Instead, it just goes to the /node/add page as usual. Why is this simple rule is not working?

Here is the rule exported.

array (
  'rules' =>
  array (
    'rules_30' =>
    array (
      '#type' => 'rule',
      '#set' => 'event_init',
      '#label' => 'Redirect to login if accessing /node/add',
      '#active' => 1,
      '#weight' => '0',
      '#categories' =>
      array (
      ),
      '#status' => 'custom',
      '#conditions' =>
      array (
        1 =>
        array (
          '#weight' => -1,
          0 =>
          array (
            '#weight' => 0,
            '#info' =>
            array (
              'label' => 'Path has alias(es)',
              'module' => 'Path',
              'eval input' =>
              array (
                0 => 'src',
              ),
            ),
            '#name' => 'rules_condition_url_has_alias',
            '#settings' =>
            array (
              'src' => 'node/add',
            ),
            '#type' => 'condition',
          ),
          '#type' => 'OR',
        ),
      ),
      '#actions' =>
      array (
        1 =>
        array (
          '#weight' => 0,
          '#info' =>
          array (
            'label' => 'Page redirect /user/login',
            'label callback' => false,
            'module' => 'System',
            'eval input' =>
            array (
              0 => 'path',
              1 => 'query',
              2 => 'fragment',
            ),
          ),
          '#name' => 'rules_action_drupal_goto',
          '#settings' =>
          array (
            'path' => '/user/login',
            'query' => '',
            'fragment' => '',
            'force' => 0,
            'immediate' => 0,
          ),
          '#type' => 'action',
        ),
      ),
      '#version' => 6003,
    ),
  ),
)


texts: How to pass a file id (or fid) as a Views argument through a Panel?

texts:
I'm trying to create two block views in a panel variant, in order to create a photo gallery ("Stage" view plus "All Thumbnails" view).  The main problem I have right now is the "Stage" view which takes two contextual filter arguments: /node-id/file-id

Some background:
Each gallery is a content type I've created called "Media Collection", which has the following fields: Title, Description, Media.  The "Media" field is a multi-value field which allows me to attach multiple images (or other files) thanks to the D7 Media module.  Therefore, my plan is to have the URL send two arguments to generate the 1) correct "Media Collection" node and 2) the correct image (file) from that node's Media field, hence: /node-id/file-id URL arguments.

So, when I set it all up in the Views UI, everything works fine.  I pass in 1745/2899 or whatever and I get the correct image attached to that media collection that I am targeting.  It is when I try to set this up in the Panel that things don't work out.  The reason is because the Panel Pane view config window does NOT reveal a file-id as a possible Contextual Filter (CF) for the 2nd CF dropdown.  The closest I can get to this is "Media" which appears as a field of the node context.  So basically I need to get more granular and be able to tell the panel that I am passing not a field but an entity reference or file ID.  If I could do it via a Media field: Delta, I would do that as an alternative approach, but that doesn't show up in the Panels pane config either.

What do I do?


texts: How to access the order total amount in Drupal commerce?

texts:
I'm trying to make a block with an image that would change when there is something in his or hger basket (empty basket image when basket is empty, full basket when it's full)
My understanding of PHP is weak, but I found this topic :

http://www.drupalcommerce.org/discussions/787/simple-shopping-cart-summary

and I wrote that:

<?php
global $user;
$order = commerce_cart_order_load($user->uid);
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$order_total = $wrapper->commerce_order_total->value();
if ($order_total['amount']>0) echo ('   ');
else echo ('   ');
?>

Now on my home server everything worked as expected. On the reomte one i got several show-stopping errors.

If i put the whole thing, I get

EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. w EntityDrupalWrapper->set() (line 744 of /profiles/commerce_kickstart/modules/entity/includes/entity.wrapper.inc).

By trial and error, I detected that leaving the first two lines

global $user;
$order = commerce_cart_order_load($user->uid);

are 'innocent'. It's the third one

$wrapper = entity_metadata_wrapper('commerce_order', $order);

that generates the error.
So actually it's the code from that commerce thread that seems to generate the error. To me it seems pretty innocent, though.

As I said, I know very little about PHP, not to mention the internals of Drupal Commerce. I'd be grateful for any suggestions.


texts: Use Rules to create new content and fill the corresponding node_reference field

texts:
I want to use a button to create a new article.

I write two rules to do the following work

snapshot 2

snapshot 3

The snapshot 2 creates a new content; the snapshot 3 fills the field of the content just created.

I can't fill the node reference field; how can i do that?

The button I put is on a different kind of content type.

I hope some body can help me fix this article.


texts: How do I see the ID of a content type record?

texts:
Using Entity Reference, I'm able to create a Field in a Content Type (Person) which references another Content Type (Story). When I go to input link data, I see a list of Title(s) of Story(ies).

How do I know that I have the right story? There are many crime fiction stories with the same title.

Is there a way to expose the Content Type record ID?


texts: Hide form fields unless 'add node image (etc) link is clicked

texts: I have content type with many fields. I'd like to simplify the form as best I can and hide un-needed text boxes/checkboxes/options whenever possible. Is there a module you know of which will replace an entire field with an 'add this field' hyperlink. When clicked that field would obviously become visible.


texts: How to get page argument of hook_menu as a parameter in a form generated by ajax url request?

texts:
I have an url : abc/def/1/add. This url has some elements:
title
blah
blah blah

When I click "title", an ajax request gets generated which opens a form in dialog box.This hit is on another url. I want above page id to get used in a form generated by ajax request.How can I do this. Basically I am trying to run update query on each ajax submit form request.But when I update, instead of updating single record, all records of that column gets same value which I changed.


texts:
I have run into a scenario where I am getting an 'Permission Denied' error when attempting to run anything that uses batch, with the sole exception being CRON.

First off, this error is NOT related to the max_allowed_packet issue referred two in every other thread regarding this scenario. First off, my max_allowed_packet is set to 16M, and second, my batch table shows valid requests waiting to be run:

my.cnf:

max_allowed_packet = 16M

drupal.batch table:

15456   ba_Tu-5BZEcFUq3RH37zvx6bvCWJGvlUUtYgADfOlPY 1406048062  ...

The requests being attempted are very small as well, I'm only trying to delete 1 user.

This happens with the primary admin account (UID 1) as well as all other administrators, so it does not appear to be account or access specific.

I am uncertain where to look next for more clues.

MySQL logs do not show any warnings or errors, and the only line in PHP is this:

php drupal: https://www.example.net|1406048063|access denied|X.X.X.X|https://www.example.net/en/batch?op=start&id=15456|https://www.example.net/en/admin/people|1||batch

IP and Domain censored from above log.

I have also confirmed that there is no '/batch/' folder in my Drupal route that could be messing with the url.

UPDATE

I have continued to investigate this as I do patching and upgrading to my network. As part of this overhaul, the backend DB was just switched from MySQL to PostgreSQL, and the issue persists on both databases. So database can been completely ruled out.

I have had success with disabling 'Clean URLs' in my config. If I disable them all batch operations work as expected, however I cannot leave them disabled for obvious reasons. Disabling them every time is not a great option either, as content admin do not have access to this setting and cannot delete spammers as a result.


texts: How to programmatically translate/localize taxonomy terms?

texts:
I want to use Google Translate for translating taxonomy terms. I have the "Talking to Google" part done, but I can't find much documentation on translating terms & their descriptions programmatically.

Please help!


texts: How to autoupdate quiz question to newest version?

texts:
We have round about 200 quizzes with 5-10 questions. And most of the questions were updated by us. But we realized that quiz shows only the old versions.

Only solution so far is to check quiz by quiz and click updated to newest version question by question.

In settings I didn't find any possibility to auto switch to newest version as soon as the question got updated.

Any ideas to solve this problem?

Of course, we can switch every question to newest version as soon as we update them. But what about all the aprox 1000/2000 questions in system that still run on old version instead of newest?

quiz.info: version = "7.x-5.0-alpha8+14-dev"


texts: How to use HTML tags in form error messages

texts: I'm using \Drupal\Core\Form\FormState::setError() in a form validation hook to display a message if the validation fails. I want to include some HTML on it, but the second parameter of setError(), the error message, is escaped. As a result, the HTML code is visible in the message box. How can I avoid this and have HTML in the box?


texts:
I created a basic page which has a basic form and implements ajax, or attempts to do so. My issue is that it doesn't seem to be functioning as it should. What might be Ajax, only works after I press enter in the textfield, which submits the data and refreshs the page, although I don't think it's ajax at work, rather the form functioning normally, I changed the #event to blur and the #keypress to false but everything is still entirely the same. Ultimately ajax isn't working, if anyone can clear this up that'd be grand.

<?php
/**
 * @file
 *  Creates form page which implements ajax
 */

/**
 * Implements hook_menu();
 */
function formajax_menu() {
    $items['formexample'] = array(
      'title' => 'Form Ajax Example',
      'description' => 'This is a page generated via hook menu
                        which displays a form with ajax support',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('formajax_form'),
      'access callback' => TRUE,
    );
    return $items;
 }

function formajax_form($form, &$form_state) {
  // create a fieldSet
  $form = array();
  $form['data'] = array(
      '#type' => 'fieldset',
      '#title' => t('Form Ajax Example'),
    );
 // Create textfield
    $form['data']['textinput'] = array(
      '#title' => t('Name'),
        '#description' => t('Your Name Here'),
        '#type' => 'textfield',
      // add ajax property with callback and wrapper
      '#ajax' => array(
          '#callback' => 'formajax_callback',
          '#wrapper' =>  'replace_this',
          '#effect'  => 'fade',
          '#event' => 'blur',
          '#keypress' => FALSE,
        ),
    );
    // create item dependant on textfield
    $ajax = (!empty($form_state['values']['textinput']))
             ? $form_state['values']['textinput'] : 'John';
    $form['data']['ajax_response'] = array(
      '#type' => 'item',
      '#title' => t('Ajax Response'),
      '#markup' => t('Your Name is' . $ajax),
      // prefix item with div id of wrapper
      '#prefix' => '
',
      '#suffix' => '
',
    );
    return $form;
 }
// create callback which will return data
function formajax_callback($form, &$form_state) {
    return $form['data']['ajax_response'];
}


texts: How to investigate arrayFlip errors in Commerce

texts:
I get periodic errors telling me that something expects a parameter to be an array. But the messages are too vague, and don't tell me which piece of code is feeding that information to Drupal. Here's an example:

Warning: array_keys() expects parameter 1 to be array, null given in inline_conditions_field_widget_form_validate() (line 353 of /Users/newman/Sites/visionart/sites/all/modules/inline_conditions/inline_conditions.field.inc).
Warning: array_filter() expects parameter 1 to be array, null given in inline_conditions_field_widget_form_validate() (line 353 of /Users/newman/Sites/visionart/sites/all/modules/inline_conditions/inline_conditions.field.inc).
Warning: array_flip() expects parameter 1 to be array, null given in inline_conditions_field_widget_form_validate() (line 353 of /Users/newman/Sites/visionart/sites/all/modules/inline_conditions/inline_conditions.field.inc).
Warning: array_intersect_key(): Argument #1 is not an array in inline_conditions_field_widget_form_validate() (line 353 of /Users/newman/Sites/visionart/sites/all/modules/inline_conditions/inline_conditions.field.inc).

Most of these are in connection with array_flip(). I can see that this one in particular is being flagged but inline_conditions, bit it's such a core module that it's impossible to find out what's triggering it. How can I do that and how can I fix?


texts: How to add back to top using drupal behaviors?

texts:
I have added the following Drupal behaviors below to my main.js file which is already included in my theme and renders on the page with the correct main.js file. The purpose of this behavior is to scroll the user to the top of the page and it is not working. I cannot even get it to log an alert('clicked'). Need help figure out what i am missing.

main.js

Drupal.behaviors.scrollToTop = {
  attach: function (context, setting) {
    $('#back-to-top', context).on('click', function(){
        alert('clicked'); //does not work
        $('body,html').animate({scrollTop : 0}, 500); //does not work
    });
  }
};

html

div is used to insert up arrow


texts: Views: how to achieve automatic pagination?

texts:
I currently have a view that shows some content displayed in the right sidebar but now I have a pager that shows 4 items on every page. The user has to click next every time he wants to see the next 4 items but I want that this paging goes automatically. So instead of clicking next each time, the next page has to show after 30seconds for example.

Any ideas?


texts: How can I name the template file for the edit page of a certain content type?

texts:
I would like to override only the edit page of a certain content type.
Theme developer module says:

page-"content_type".tpl.php < page-node-edit.tpl.php < page-node-"nid".tpl.php < page-node.tpl.php < page.tpl.php

If I use page-"content_type".tpl.php, it also overrides the node view page and if I use page-node-edit.tpl.php it overrides the edit page of all content types.

Update:
I tried the code below, and put it in my template.php but it doesn't work.

function my_theme_preprocess_page(&$vars) {
 if (isset($vars['node'])) {
   $edit_or_add=basename($_GET['q']);
    if ($edit_or_add=='edit' || $edit_or_add=='add') {
      $vars['template_files'][]='page-' . str_replace('_','-',$vars['node']->type . '-' . $edit_or_add);
    }
    else {
      $vars['template_files'][]='page-' . str_replace('_','-',$vars['node']->type);
    }
  }
}


texts: Why 'Failed to start the session' when RedirectResponse is sent?

texts:
When this code is executed, I have an error message logged.
The code is in shared_node_access(NodeInterface $node, $op, AccountInterface $account)

if ($node->get('nid')->value == 1) {
  if ($account->isAnonymous()) {
  }
  else {
    $path = Url::fromUserInput('/node/25')->toString();
    $response = new RedirectResponse($path);
    $response->send();
  }
}

The error message:

  RuntimeException : Failed to start the session because headers have
  already been sent by
  "/home/lejardindf/JdP8/vendor/symfony/http-foundation/Response.php" at
  line 377. dans
  Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
  (/home/lejardindf/JdP8/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php
  ligne 150)


texts:
Is there a way of creating lists of categories dynamically?

For instance, say I currently have 2 TVs on the site. If I then add a DVD player product, is it possible to automatically generate a DVD player link (in a block etc)?

I've been playing with Views as I thought it may have done the trick, but I've had no success. Any pointers would be great.


texts:
I've been using Drupal full-time for over six years and I always thought you could use the [content type] create, edit and delete permissions to allow users to create, edit and delete nodes AND use the 'Publishing options', 'Authoring information' etc settings on the node/#/edit page.

Looking at my most recent build today, this is not the case. Additionally, the 'Update options' dropdown and corresponding checkboxes are missing on the admin/content page.

I know there are third party modules like Override Node Options but I'm sure the above was possible.

Additionally, using the 'Administer content' permission is too aggressive because the user can then administer all content types, not just the ones you specify.

Has 'Administer content' permission always been required to expose publishing, authoring etc options? And is there a way around this other than using third-party modules?


texts: Why file name and uri of the file in database are different?

texts:
I am uploading the files to the folder by using file_save_upload and file_move to achieve this. Its working fine but a problem arises while saving in database.  I have used FILE_EXISTS_RENAME argument, so in file_managed table filename column and uri column file name is not same. In filename column its not appending the integer value, but in uri column its appending the integer value since the file is already exist. Below is my code:

  for ($i = 0; $i < $num_files; $i++) {
      $file = file_save_upload($i, $validators, FILE_EXISTS_RENAME);
      if ($file) {
        $file->status = FILE_STATUS_PERMANENT;
        if ($file = file_move($file, 'public://feed-files/' . $foldername, FILE_EXISTS_RENAME)) {
          $form_state['values']['file'][$i] = $file;
        }
        else {
          form_set_error('file', t('Failed to write the uploaded file to the selected folder.'));
          return FALSE;
        }
      }
      else {
        form_set_error('file', t('No file was uploaded.'));
        return FALSE;
      }
    }

below is the database values:

So how can achieve that filename and uri  column file name should be same. Any suggestions will be appreciated.


texts: Creating a list of child taxonomy terms with Views

texts:
I have a a taxonomy with 2 levels:

Parent 1

Child 1
Child 2
Child 3

Parent 2

Child 4
Child 5

When I am on /taxonomy/term/parent1 I want to display a view of a list of child terms in a block:

Child 1
Child 2
Child 3

I have been through similar questions on this site, some with accepted answers, but it did not help me. Here is my Views settings.

For now, it displays the term name for each node containing the parent or child term, causing a lot of duplicates.

parent 1
parent 1
child 1
child 1
child 2
child 2

I'm using Views 3 and Drupal 7
If someone has a hint to share it would help me a lot :)
Thanks in advance


texts:
I'm using Field group Module, I have created 3 groups with name & ID as given below:

Group Name    | Machine ID
Stake Holders | group_sh1
Trends        | group_td1
Organization  | group_org1

I want to retrieve the group name in a custom module. By using "ctools" I'm able to retrieve the id  of the group, but couldn't get name of the group. Please find the code below for your reference.

ctools_include('export');
$objects = ctools_export_load_object('field_group', 'conditions', array(
    'entity_type' => 'node',
    'bundle' => DIGITAL_IQ,
  ));

$object = array_shift($objects);
if ($object && isset($object->data)) {
  dpm(field_group_unpack($object)children);
}

  --Result---
  0 (String, 9 characters ) group_sh1
  1 (String, 9 characters ) group_td1
  2 (String, 10 characters ) group_org1

How can I retrieve the group name?


texts: Cannot update modules with drush – needs higher bootstrap level

texts:
As stated in this answer Drush needs to find the settings.php file in order to work. My problem is that the settings.php file is indeed in the right folder (and I have navigated to the Drupal root folder before issuing the Drush commands), but it still does not work to update modules with drush. I just get the message that Command pm-update needs a higher bootstrap level to run. It even states itself that the Drupal settings file is located in sites/default/settings.php.

This is the error message:

C:\wamp\www>drush ups
Command pm-updatestatus needs a higher bootstrap level to run - you      [error] will need to invoke drush from a more functional Drupal environment
to run this command.
The drush command 'ups' could not be executed.                           [error]

Drush was not able to start (bootstrap) the Drupal database.             [error]

I have also followed the instructions in this post, with no luck.

What else can I try?


texts: The calendar_style style requires a Date argument error when Using CCK as a date argument

texts:
Can´t use a date CCK field when setting up a calendar as a view
When I want to save the view I´m getting this error message:

The calendar_style style requires a Date argument.

I´ve added the same CCK field to the fields so views would stop complaining about another error message that in the new versions of views was added..that the same argument has to be present on the fields

Still ..the date type of the CCK isn´t recognized as a valid date argument...
Works with node updated date though...

I have Drupal

Date 6.x-2.7
Calendar 6.x-2.4
Views   6.x-2.12
and Drupal 6.22


texts: How can I create my desired template name suggestion?

texts:
For example, Imagine that I designed two main-menu with different style and template one for the header region (top bar, primary menu section)
and another for the footer region as a "footer map" on my site as it's common in the most sites.

Since Drupal 8 it's not possible with template naming conventions to load a specific block template according to the region it is placed in ("Per-region block markup and per-region block templating feature removed").

  In Drupal 7 it was possible to specify separate block templates per
  region, such as block--header.tpl.php and block--footer.php to output
  different HTML for blocks placed in the header and footer regions. It
  was also possible to adjust variables based on the region in
  hook_preprocess_block(). Both of these features have been removed.

I decide to use below code, by using the below code I can add block region and id to the block template name suggestion:

function MYTHEME_theme_suggestions_block_alter(array &$suggestions, array $variables) {
  if (!empty($variables['elements']['#id'])) {
    $block = Block::load($variables['elements']['#id']);
    $suggestions[] = 'block__' . $block->getRegion() . '__' . $variables['elements']['#id'];
  }

If I have considered tree or even more footer region in my theme then my theme users should have this freedom to change the order
of displaying this designed footer menu independent of which sub-footer region that's inserted in;
It is more useful if we design in LTR languages (Like English) and RTL languages(Like Persian)Simultaneously.
But what's that become outputted from above code is something like this:
block--footer-1--mainnavigation-2.html.twig

I think it's a good idea to design the different menu with different semantic name template separately.
It's quite obvious if I need multi instances of a block then Its must probably be in different region, therefore, this difference in positioning make a good and sufficient semantic name convention to assign name to templates and get rid of complication.

for this reason, I want to remove the numbers from the end of block identifier because I think this is very dedicated and I want to achieve something like this:

block--footer--mainnavigation.html.twig

Something else that I want to pay attention to it is if I choose another footer names for example:
footer_menue instead of footer_1 then this hasn't necessary dynamics in theme layer due to the above reasons.

Anyway, the name convention that I like and follow out is:
What's this?(Most common part) it's block or page or....
Where should be placed? header, footer....
What is his name or usage? main-menu, Search Block,...
Like:Block+Region Name without Number+ Block(id) name without number


texts: I'd like to know if there's a way to assign a default value in the Price field in Drupal Commerce. Currently, there are no field settings available.


texts: How to generate an unique serial ID based on a select value

texts:
I am Drupal beginner. I have created one webform with some fields (name, college, branch, address, email, contact number etc.). And when this form gets submitted I need to generate a unique registration number based on the selected college code and a serial number).

I also installed Webform Rules module but I don't understand how to achieve that.

Can anyone please help me to generate unique serial ID based on a field value during the Webform submission?


texts: Entity Reference - Not required to be in database

texts:
I have a content type Proposal with a entity reference field Proposed by. This is an autocomplete field that targets Users in the application. You can give in multiple users that are in the application.

But now I would like to give the possibility to the user that they can give in user that are NOT in the application. So they can enter email addresses from random persons, they will receive an email with a link to register. But how can I get this data? Because it's not saved when the user isn't in the application.

I tried to do this with hook_node_validate but this is the result I get:

array (size=1)
'und' =>
  array (size=4)
    0 =>
      array (size=2)
        'target_id' => string '26' (length=2)
        '_weight' => string '0' (length=1)
    1 =>
      array (size=2)
        'target_id' => null
        '_weight' => string '1' (length=1)
    2 =>
      array (size=2)
        'target_id' => string '' (length=0)
        '_weight' => string '2' (length=1)
    'add_more' => string 'Add another item' (length=16)

So no email address that I gave in.. Just a target_id = null. How could I do this?


texts:
I could need some help! (Newbie)
After updating a couple of modules on my local site, the jquery modules are behaving really weird or stopped working at all (Masonry, Chosen and Sidr). Masonry and Chosen don't work at all, Sidr just works on those pages where Masonry isn't on. Infinite Scroll stopped working, too and is replaced by the regular pagination. There are no error messages displayed or in the drupal report.
What should I do now?
(the site is running Drupal 7.28 on Acquia Dev Desktop php 5.2.38)


texts: How do I set variables for variable_get()?

texts:
I am trying to understand variable_get(). I read so far that you can set variables in the settings.php using the $conf array and retrieve them later in code by using variable_get(). I have read that you can also use variable_get() to retrieve values from the database.

How does this work?
Is there a table that is automatically built?
How would you set variables if this feature is possible?


texts: add "items_per_page" number in title tag and meta tag

texts:
I created a view which has set up "Exposed items per page options." I used "24,48,72" as my options. Here is my view "Exposed setting":
When I choose "items per page" as 72, the url of that page will change to "https://www.domain.com?items_per_page=72". Here is a test page screenshot:

My question is how can I add the number to "title" tag in order to distinguish "title" for SEO. There are some websites suggest to used [current-page:page-number] token, but this is not working in my case.  Does anyone have any idea?


texts: hook_form_alter won't save options cck field from custom form

texts:
I have created content type named "site_profile", and form named "add_website_form".
The content type includes cck fields and one of the fields is "field_operators" which is select box field.
I have hooked options of the field to display variable that contains array of specific users with some mechanism.
The hook_form_alter is:

function lcm_form_site_profile_node_form_alter(&$form, &$form_state, $form_id) {
    $relevant_users = lcm_get_relevant_users();
    $form['field_operators']['und']['#options'] = $relevant_users;
}

Now I am trying to get functionality that stores data into the node through node_save() function from the "add_website_form" (costume form).

the code that supposed to insert the data is:

function lcm_add_website_form_submit($form, &$form_state){
    $website_name = $form_state['values']['website_name'];
    $url = $form_state['values']['url'];
    $operators_for_site = $form_state['values']['operators_for_site'];
    lcm_add_website_form_insert_to_db($website_name, $url, $operators_for_site);
}
function lcm_add_website_form_insert_to_db($website_name, $url, $operators_for_site){
    // Create a node object, and add node properties.
    $new_website = new stdClass();

    $new_website->type = 'site_profile';
    $new_website->title = $website_name;
    $new_website->uid = $GLOBALS['user']->uid;
    $new_website->field_url['und'][0]['value'] = $url;
    $new_website->field_operators['und']['value'] = $operators_for_site;
    $new_website->created = strtotime("now");
    $new_website->changed = strtotime("now");
    $new_website->status = 1;
    $new_website->comment = 0;
    $new_website->promote = 0;
    $new_website->moderate = 0;
    $new_website->sticky = 0;
    $new_website->language = 'und';

    node_object_prepare($new_website);
    // Save the node.
    node_save($new_website);
}

the problem is that the data that supposed to save on field_operators doesn't save...
Any ideas?


texts:
After installing 8.4, updated step by step to 8.5.3, now I have in Status Report the following error: Field revision_default must be updated at several entity types, Node, Media, etc.
Checking the database, I have that field in the tables *_field_data and *_field_revision but not in the tables *_revision, though apparently it should be there.

drush entity_updates lists these error but does not fix them.

Searching several hours I did not find any solution. We have a lot of content and media so uninstall and install again is not an acceptable solution.

Any idea?


texts: After enabling utf8mb4 on 7.50, cannot enable update module

texts:
I upgraded to 7.50, ran the utf8mb4 convert drush commmand, and enabled utf8mb4 in settings.php.  Before running the utf8mb4 convert drush command, I did have to convert several columns manually like this:

ALTER TABLE commerce_order CHANGE order_number order_number VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

I tested my site and as far as I can tell everything is working fine.

However, when I try to enable the update module (which had been uninstalled on the site), I get the following error:

cpu:update pk$ drush @mysite en update
PTY allocation request failed on channel 0
The following extensions will be enabled: update
Do you really want to continue? (y/n): y
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1071    [error]
Specified key was too long; max key length is 767 bytes in
/srv/bindings/d767913ee30941f3847c9361d2d787ba/code/includes/database/database.inc:2204
Stack trace:
#0
/srv/bindings/d767913ee30941f3847c9361d2d787ba/code/includes/database/database.inc(2204):
PDOStatement->execute(Array)
#1
/srv/bindings/d767913ee30941f3847c9361d2d787ba/code/includes/database/database.inc(683):
DatabaseStatementBase->execute(Array, Array)
#2
/srv/bindings/d767913ee30941f3847c9361d2d787ba/code/includes/database/schema.inc(664):
DatabaseConnection->query('CREATE TABLE {c...')
#3
/srv/bindings/d767913ee30941f3847c9361d2d787ba/code/includes/database/database.inc(2753):
DatabaseSchema->createTable('cache_update', Array)
#4
/srv/bindings/d767913ee30941f3847c9361d2d787ba/code/includes/common.inc(7109):
db_create_table('cache_update', Array)
#5
/srv/bindings/d767913ee30941f3847c9361d2d787ba/code/includes/module.inc(479):
drupal_install_schema('update')
#6 /opt/pantheon/drush-8/commands/core/drupal/environment_7.inc(143):
module_enable(Array)
#7 /opt/pantheon/drush-8/commands/pm/pm.drush.inc(1167):
drush_module_enable(Array)
#8 /opt/pantheon/drush-8/includes/command.inc(366):
drush_pm_enable('update')
#9 /opt/pantheon/drush-8/includes/command.inc(217):
_drush_invoke_hooks(Array, Array)
#10 /opt/pantheon/drush-8/includes/command.inc(185):
drush_command('update')
#11 /opt/pantheon/drush-8/lib/Drush/Boot/BaseBoot.php(67):
drush_dispatch(Array)
#12 /opt/pantheon/drush-8/includes/preflight.inc(66):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#13 /opt/pantheon/drush-8/drush.php(12): drush_main()
#14 {main}

When I enable the update module, it isn't able to create the update or cache_update tables.  How can I fix this?


texts: I have a website which does lot of work on financial data. It involves operations on large volumes of data most of the time. Hence I find it useful to do those operations in MySQL stored procedures. I have stored procedures in my database. I want to know how can I execute stored procedures in Drupal? Is there any good method to execute stored procedures in Drupal? How does Drupal handle stored procedures in general? Or we just have to use the PHP to execute stored procedures?


texts: How to allow all commerce customers to use their billing address as their shipping address, in Commerce Shipping 2.X?

texts:
Almost all shopping sites have a feature to allow customers to use their billing address as their shipping address, to save them typing it in twice in the very common case of a customer having the same shipping address as their billing address. This should be possible both for customers with accounts, and for anonymous customers.

Looking for this feature in Drupal Commerce, I find some hacks suggeested in 2012, and a long issue report that seems to suggest this feature has been implemented.

However, the steps listed in that issue seem to be for the 1.X branch only, not the 2.X branch, and seem to no longer apply:

  For people who are a little lost like me, this is where you will find the settings:

  store/customer-profiles/types/billing
  store/customer-profiles/types/shipping

  Halfway down the page, under Format Handlers, you'll see a checkbox with the following text:

  "Copy billing address (required to be activated on billing profile along with the profile you want to copy the address on to. In order to work properly, the two addresses need to be on the same page.)."

  Check this on for both the billing and shipping profile types. Save both. I'd imagine you also need to make sure the other format handlers are identical between the two profile types--though I haven't tested it.

Those pages have moved, and I can't find any such checkbox in their new equivalent. Likewise this related question is 1.X only.

How do we enable this common feature in the 2.X branch of Commerce Shipping?


texts: Drush Connects to Wrong Database in Nested Site Directories

texts:
Drush is not connecting to the correct database in a nested site structure. What can I do to debug and fix?

We have a website that consists of several nested Drupal installs/sites. I.E. The domain example.com points to a top level Drupal Site, and example.com/schools is a completely seperate Drupal install in the directory structure.

/var/www/html/example.com -> Root level website at example.com
   |
   |-> ./schools/ -> example.com/schools
   |
   |-> ./staff/ -> example.com/staff

On our live install we have Drush 9 installed on each of these sites via Composer. Each one was able to connect to their correct databases. After we updated one to Drupal 8.7 on dev, it longer connects to the correct database.

For example if I am in /var/www/html/example.com/schools and run php vendor/bin/drush status this is the output:

 Drupal version   : 8.7.8
 Site URI         : http://default
 DB driver        : mysql
 DB hostname      : localhost
 DB port          : 3306
 DB username      : kpp_user
 DB name          : kpp_drupal
 Database         : Connected
 Drupal bootstrap : Successful
 Default theme    : kpp
 Admin theme      : adminimal_theme
 PHP binary       : /usr/bin/php
 PHP config       : /etc/php.ini
 PHP OS           : Linux
 Drush script     : /var/www/html/example.com/vendor/drush/drush/drush
 Drush version    : 9.7.1
 Drush temp       : /tmp
 Drush configs    : /var/www/html/example.com/vendor/drush/drush/drush.yml
 Install profile  : standard
 Drupal root      : /var/www/html/example.com
 Site path        : sites/default
 Files, Public    : sites/default/files

So it is incorrectly using the settings.php file from the directory above it. I also tried forcing the directory root and uri with these commands but get the same output:

php vendor/drush/drush/drush --root=/var/www/html/example.com/schools status

php vendor/drush/drush/drush --uri=example.com/schools status

EDIT:
I did just notice that after the update there is no /core/ folder in the schools site, so it may be that the installation is just incorrect and drush jumped up a level to find any valid Drupal install.


texts: Buiding TABS with Quicktabs, Views and Entity References

texts:
I'm trying to build a tabbed content for node using  Entity Reference  , Quicktabs and Views in this way:

1- Create 2 content type: simple-page and tab

2- In simple-page content type I added a entityreference field to reference tab node

3- I created a simple-page and inside it I added 3 tab nodes

So far so good.Now I want to show this tab nodes as tabs. The title of the node will be the tab title and the body will be the content of the tab.

Now, I know that I can create a Quicktab instance which can take the Title and the Content of each tab from Views

The idea is to create the View with 2 blocks, one for the title and one for the body of the referenced tab node. But I don't know how to do it. I need help to buil this view blocks.

Then after I will add a contextual filter set to the NID in the url.
Lastly I will put the Quicktab instance block in the node so that I can get only the tab pages referenced for that node.


texts:
I'm using Group field in views. There are several events in one month. How can i limit my events. 2 events should be displayed in every month.

July
Event 1
Event 2
Event 3
Event 4

August
Event 1
Event 2

Thanks.


texts: Use the same image 2 times in image styles

texts:
A tricky question regarding image styles.

I need to do a thumbnail with 2 layers:

background: a cropped picture with a blur effect.
foreground: overlay with the same picture and scale effect.

If you have some hints, or you know how to do it programmatically in a custom ImageEffect plugin I would appreciate any help.

This is an example how the image should look like:


texts: Translating fields in node.tpl.php file with drupal 7

texts:
I have a drupal English/French website. I have a custom content type called 'ad' with all sort of fields. I have created the file 'node--ad.tpl.php' in my theme directory to customize the display of the 'ad' content. I use pixture reloaded theme and DRUPAL 7.
In node--ad.tpl.php fields are displayed with this code:
  print render($content['field_my_field_name']);

I am trying to translate fields (both labels and values) by using 'field translation' module.

Field translation works when I CREATE or MODIFY a content via admin.

However, when I DISPLAY a content of type 'ad', fields are not translated. This is because drupal calls to 'node--ad.tpl.php' and the translation module is probably not invoked. When deleting 'node--ad.tpl.php', drupal calls the default node.tpl.php with a similar results.

Any help would be appreciated, Thanks in advanced,

Notes :

I correctly activated every dependencies for the module.
User interface translation correctly works.


texts:
When I check my users list via by ID, I get IDs like these:

User: admin
Id: 1
User: second user
ID: 11
User: another user
ID: 21

I want them to be consecutive numbers from 1 to N.

What's my problem? How can I fix it?


texts: Attempt to create an instance of field that already has an instance of that field

texts:
how can i check if an instance of a field has already been created so that the my_module condition doesn't try to create it again?
something like

if(!instance_exist){
//do abc
}


texts: How to change the output of a multiple image field for a node?

texts:
I have a content type (called Gallery)  with a image field  (called field_gallery) which allows to upload and show 10 images.

Now I create a node and upload the images. The output shows those images wrapped with a div tag. Like:

Instead of this I need it to be something like:

How can I accomplish this. Should I use an alter function? How?
thanks


texts: How can I print something only when cck field has certain value on node.tpl.php?

texts:
I need to print something conditionally in my node.tpl.php depending on the cck value of a field on my content type.

For example, if field_color has "red" or "blue", then print "It has color" and if it has other values print empty text.


texts: How can I override the field in my view?

texts:
I have a view for a content type with a number of fields. For one of the fields (List, text) (node_field_type) I would like to override the output result. It can be either type_1 or type_2 . In the database the type is stored in node_field_type table in field_type_value column.

So in the settings of the field under "Rewrite results" tab I picked "Override the output of this field with custom text"

But it doesnt assign any class to html tag.
Could you please help me?


texts: Views all data export included image name/path

texts:
I have a View. In my view Image, Product Id, etc are shown. I want to export all the data of that View in the form of doc file or CSV or excel sheet, in the tabular form if it store the data in the form of doc or csv.

My condition is that : For image field atleast image name/image path stored.

Is there any module?


texts: Manage config translations programmatically

texts:
My module creates and manages some config_entities programmatically (ie. not through an EntityForm) in response to associated content entities being saved.

In order to handle multi-language content entities, I see two options:

create one config entity and add translations for it
create a unique config entity for each translation

The first seems cleaner - however, I don't see how to actually transparently manage translations for config entities. Translating an entity with the config_translation module appears to create a new entry in the config table with collection = language.xx, but I don't see how to access a translated entity explicitly (rather than it being automatically mapped by the site's interface language). Is this even possible?


texts: What to do if we want a input format for select options of a webform?

texts:
I have a web form with select option field whose value is quite long. I cannot use css to configure this. I need to use input format so that I can break this option using HTML code. Is there any module or something?

Additional Info:
We don't have input format option in case of webform module's select fields. My value in select field option is quite long. I have three values like below:

  Session 1: PwC
  11:30am
  Sourcing Strategies for the Next Decade

  Presented by:
  Damon Paling, Partner, PwC China
  Anthony Tennariello, Partner, PwC New York
  Maytee Pereira, Director, PwC New York.

I would like show the user like this but this is not possible since we don't have input format (HTML) to select.


texts: Select all checkboxes of an entity reference field on creating a node

texts:
Drupal 8.7.x

For one of my content types I have an entity reference field referencing a taxonomy vocabulary. I have a lot of terms in this vocabulary which makes it tedious to check all the checkboxes if you practically need all of them checked. I would like to integrate a single checkbox at the top of the field in the node creation form that allows you to check/uncheck all the terms at once.

I found a few modules that do this in drupal 7 but so far I had no luck finding anything related to drupal 8.

How would I go about integrating this functionality myself ?

At the moment I have a jquery function in my theme that adds a checkbox at the top of the fields like so:

(function ($, Drupal) {

  /**
   * Check all checkboxes.
   */
  Drupal.behaviors.initFootnotes = {

    attach: function (context, settings) {

      $(".form-checkboxes").prepend($('<input type="checkbox" class="form-checkbox shield-select-all" /><label class="option shield-select-all-label"> Select / Deselect all </label>'));

      let selector = $(".shield-select-all");
      selector.on('click', function (event) {

        console.log("the checkbox is clicked");
        let $options = $('.form-type-checkbox');

        $(".form-checkboxes").closest().find($options).each(
        console.log("I'm an option"),

        $(this).find("input[type=checkbox]").click(),

        )
      })
    }
  };
})(jQuery, Drupal);

The select all checkbox is added but the checkboxes aren't changing their state when the select all checkbox is checked. I noly get "I'm an option" once in the console.

Thanks in advance,
Geordi


texts: add render array to custom entity in controller

texts:
I have a custom entity, with a controller class that extends EntityViewController much like the node module does in core. The view method in this class returns a render array $build and it is called by the router for my entity.

I would now like to attach some more content to this render array, specifically some articles from another site. I have a class of my own that I am able to implement like this inside the view() function:

$client = new FrontpageArticlesBuilder();
$articles = $client->toRenderArray();

Where $articles is a render array. I would like to know how I can append this render array to my existing $build render array returned by view() method in my controller.


texts: Sorting rows and return the value as a simple array using EntityFieldQuery

texts:
I have a drupal custom entity_type. I am trying to do to things, find the row that is the oldest and return with a simple array. I currently have the following:

function oldestTicket(){
   $query = new EntityFieldQuery;
   $ticketTime = $query
  ->entityCondition('entity_type', 'as_ticket')
  ->propertyCondition('status','new')
  ->fieldOrderBy('updated', 'value', 'ASC')
  ->pager(1)
  ->execute();
  $entities = entity_load('as_ticket', array_keys($ticketTime['as_ticket']));
  return $entities;
}

This results with an error saying that updated is not a valid column field (it is in the db) and the return array is a complex multidimensional array. I would prefer something a little simple. In fact I would prefer that the returning result was just a string with updated timestamp value.


texts: How to alter the name of downloadable excel sheet of webform

texts:
Issue:

When I click on the link ofwebform Download as shown in below screenshot the default name of excel sheet before save to local disk appears like localhost_worklog.xlsx but I want something like localhost_worklog_02172017.xslx which is appended with _<current time>.

SCREENSHOT:

EDIT: After using iLLin's answer

Problem: How can I alter the name of localhost_worklog.xlsx before save?

I am using drupal 7.53.


texts: Display value not key of list after loading of node

texts:
I've created a controller and I'm loading a node.

$variables['contest'] = Node::load(12);

return [
    '#theme' => 'theme_contest',
    '#variables' => $variables,
];

In this node there is a field "field_contest_things" of type list (text):

0|Dance
1|Read
2|Playing

In the twig file if I'm doing

{{ variables['contest'].field_contest_things.value }}

this will display the key and not the "value".

Is there any way that I can display the value and not the key in the twig ? Or should I change something in my controller ?

Thanks


texts:
I used Drupal multisite approach. When I go to mydomain.com the default site is loaded and if I deleted sites/default/settings.php file, it is creating again.

How do I disable the default site so that, not even the installation page is shown?


texts:
I created a view that I called gallery (in Drupal 7) which links to a number of sub galleries (http://quaaoutlodge.com/gallery). The sub galleries are of content type gallery.
So, I installed the nodeaccess module because the galleries and the gallery main page should only be accessible by my GalleryViewer  (and GalleryEditor) so I set the Gallery node type up accordingly (no checks for anonymous user). I saved grants and rebuilt permissions. Now, even tho I did the above, any user caan browse my gallery types that are linked from http://quaaoutlodge.com/gallery. Why is this? What am I doing wrong? :o


texts: How do I use print to generate a PDF of all entities referencing a specific node?

texts:
I'm trying to use the Print module to generate pdf's and epubs of the stories on my site. However, I need to get Print to generate these files from the story page and then generate the pdf with ALL nodes that reference the story, the chapters. I'm not sure how to do this as I've never really done tpl.php's before. I need some help here.

Can print be made to work with a panels layout that shows what I want in it? I have a panels layout working mostly for an example of what I'm trying to achieve.

http://fanbards.net/print/stories/13008

How do I make the tpl.php file I need to make that end up as my print selections for Stories?


texts: How to alter $form_state before render a form?

texts:
I want to render a Custom Form from a Controller class. So i've written the code like this

class MyController extends ControllerBase {

  public function content() {

    $form = \Drupal::formBuilder()->getForm('Drupal\MyModule\Form\CustomForm');
    return $form;
  }
}

but i want to put some values in $form_state i.e. set #default_values.But here $form is a renderable array, not an object so there is no $form_state object. So, what to set default values ?


texts: Custom validate exposed filter on a view

texts:
I have a view with a single exposed taxonomy field that requires the user to click apply before any results are shown.

The options in the list appear like this

Please Select (All label overridden with form alter, also the default option)
option 1
option 2

if the user clicks apply when please select field is highlighted I would like to show an error message rather than all of the results I have tried the following.

Form:

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

Function:

function MY_MODULE_forms_claims_validate(&$form, &$form_state) {
  if($form_state['values']['user_category'] == 'All') {
    // $form_state['values']['user_category'] = 0;
    form_set_error('user_category', 'please enter a value');
  }
}

It does set a form error message but also throws the follwoing warning, it also does this on the first page load which I don't want it to do either.

Notice: Undefined index: nid in views_handler_field_term_node_tid->pre_render()

It throws this error the first time the page is loaded which is a


texts: Import latitude and longitude from XML to Location field for GMap, for Views display

texts:
From my XML data which I have imported into nodes, I have CCK fields for Latitude and Longitude. I want to import those values into Node Location so that I can have two Gmap integrations:

Show a GMap on each node to show where it is located
Show all matched locations on a Views page with an exposed form

Is there something I have to do with mapping the fields correctly inside of Migrate, and if so, how would I define the Location fields as destination fields? I also found this on Migrate Extras that seems to have integrated it with Location, but that was for D7.

Then, how do I integrate the GMap with my Views page and get items to filter correctly?


texts: Suggested theme hook doesn't get applied

texts:
The custom theme hook (abacus-product.html.twig) I've appended via a hook function doesn't get applied. But it shows up in the suggestions.

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'page' -->
<!-- FILE NAME SUGGESTIONS:
   * abacus-product.html.twig
   * page--taxonomy--term--5.html.twig
   x page--taxonomy--term--%.html.twig
   * page--taxonomy--term.html.twig
   * page--taxonomy.html.twig
   * page.html.twig
-->
<!-- BEGIN OUTPUT from 'themes/abacus/templates/page--taxonomy--term--%.html.twig' -->

abacus-product.html.twig is in the same directory as page--taxonomy--term--%.html.twig

Edit
This is the hook function:

function abacus_theme_suggestions_page_alter(array &$suggestions, array $variables) {
    $path = \Drupal::service('path.current')->getPath();
    if (0 === strpos($path, '/taxonomy/term/')) {
        $weight = \Drupal::routeMatch()->getParameter('taxonomy_term')->getWeight();
        if ($weight == 0) {
            $suggestions[] = 'abacus-product';
        }
    }
}


texts: Field with type 'Term Reference' (only if I use View as data source) display N/A as first value

texts:
I have a field with type 'Term reference' and widget 'Check boxes/radio buttons'.
As a first value I have a N/A and I've no clue why it appears there.

Term reference works fine if I do not use View.
It's not required to be filled.

Is it possible to remove it in proper way?

Thanks.


texts: Filter for all terms in a "dynamic vocabulary"

texts:
I would like to add a filter in a view to search only nodes related to terms in a specific vocabulary. The problem is that the editors continuously add terms to the vocabulary and consequently I cannot select once and for ever which are the possible terms.

I would need a filter like this:
positive if the term searched, or its translation, is in the vocabulary "myVocabulary".


texts:
I am writing my own 403 page, and would like to redirect the user to the login page if the user is not logged in. I use this code in a page callback, but when I am viewing an unauthorized page (say /user/1) as anonymous user, I got infinite redirect to /user/1.

function MODULE_membercheck() {
    global $user;
    if (!$user->uid) {
        //drupal_goto('user/login', array('query' => array('destination' => 'member/check')));
        drupal_goto('user/login'); //these two lines won't work
        return;
    }
    // other stuff.
}

update

It is quite easy to reproduce the problem. Just create a module and add a menu (member/check), and redirect anonymous user to login page in the page callback function. Then set the default 403 page to this menu entry, and try to open an unauthorized page.


texts: Rules: action before a user gets deleted

texts:
I'm trying to fetch a user's profile before the user account gets deleted.

I'm using the rule 'when user get's deleted' but once it gets deleted i cannot obviously access his profile.

Is there a way to get the profile 'before' the user gets deleted ?

Pulling my hairs out; any ideas ? Thanks folks !

(i'm using drupal 6)


texts: How do I change the ajax loading behaviour in Views?

texts:
I have a view with some exposed filters in a block; it uses AJAX and the auto-submit feature so the view is re-loaded as soon as a filter option is changed.

In the short delay between selecting an option and the view being re-loaded, the familiar blue AJAX throbber is shown somewhere at the bottom of the form (I think where the hidden submit button is currently located).

I know I can customise this image by overriding the CSS for the throbber element, but I'd prefer not to use it at all.

What I'd much rather do is temporarily fade out the exposed filter form (and ideally the main view as well), using a jQuery animation. They would then fade back in when the AJAX call is complete.

Failing that, I'd like to use the same method that the Views UI module uses when it's updating, namely placing this icon in the middle of the page:

As that is already built in I just assumed there would be a setting somewhere to change the style/location of this loading behaviour; no such luck though.

How do I implement either of these methods?

I'm using Drupal 7 with Views 7.x-3.3.


texts: Rules Fetch entity by property using fixed User Role

texts:
Versions
Drupal 7
Rules 2.9
Problem
I am trying to loop through all users with a given role. I am trying to pull the users using the action "Fetch entity by property" with property "User Roles" But the value does not allow me to enter a static role. It forces me to select some available variable using tokens. If I enter a static value and save it returns a validation error.
How do I set the property to a static role?
Note the role is not the same as the user creating the node.
Rule
I would include a serialized copy of the rule but frankly none of the rest of the rule matters. Roughly:
Trigger: node create.
Condition: node is published.
Action: Grab all users with editor role.
Action: loop through all users and send e-mail or add to a nodequeue (havn't decided which yet).
More info
The documentation seems to indicate I should use "direct" input mode. However that option does not appear to be available on this form. Am I missing something? is this maybe a bug?


texts: use two formatter for single field in view

texts: I want to use two formatter 'url,as plain text' and 'count the click happened on this link' for single field in view page


texts: How to use in a view an argument like gids[0]=

texts:
I have a custom content type that is associated to groups. When I create a new item, the URL is /node/add/content_type?gids[0]=xxx, where xxx is the node id of the organic group whose this content will be associated.
One of the field of this content type is a user reference. I wanted that this reference is restricted to only members of this group.
This should be accomplished easily using "select list" as the widget for the user_reference field and selecting a view which returns just the members of the group as the "View used to select the users:". og_members views seems perfect, but unfortunately it works with urls like /xxx and not ?gids[0]=xxx.
I googled a lot and tried several things, even create a new view from scratch, without success.
Any help would be appreciated...


texts: Creating an Editor Role and Reusing the Admin Menu and Overlay in Drupal 7

texts:
I, like so many other Drupal users, wish to add an Editor role into my website.  I have already done this.  I want the Editor to be responsible for editing and publishing certain content, as well as create certain types of content.

I use the Admin Menu module so I get that very nice flyout-menu administrator toolbar.  Well, I want the editor to be able to use the same menu, only with certain items missing.  Not only do I want them to use the same menu, but I want it to appear in the same bar.  I also want the editor to be able to use the overlay as well, just as it appears for the administrator.

How do I do this?

Cheers.


texts: D6/views - Multiple nodes in one slide grouped by taxonomy

texts:
I have the following taxonomy:

food

fruits

apples
pears
bananas

vegtables

tomatoes
carrot
cucumber

meat

chicken
beef
duck

...and a view that brings all those items, currently as an html list grouped by taxonomy term. I use fields for each item.

I need to change my view in order to split them in slides (or pages with prev/next) so that each slide/page will hold all the items of a food subcategory (the whole group). Ideally with a slider but pagination will also suffice.

To be precise I'd like a similar result as in this question. But in my case I have the above taxonomy tree to help distinct nodes I need in each slide

Thanks in advance!


texts: Have I understood correctly? - Drupal Slider\carousel modules

texts:
Why in Drupal, so much is needed just to insert a picture into a slider?...

I understand that in the typical Drupal slider modules, we can't just upload a picture into the slider - We MUST choose from and existing photo in the site and it MUST also be an existing photo from an existing View... This is (allegedly) a problem because it forces one to upload the picture to somewhere in the site even if there is no such necessity and also forces him to use Views even if he has no need to.

Why all of this way just to use a picture and are there really no shorter ways to do image sliding in Drupal?

Please correct me if I was wrong in anything here.


texts: How to get Views Selective Filters working with Country Field from Address Field Module?

texts:
When I expose the country field from the address-field module as a selective exposed filter (to only show countries that are in the results of the view), the "selection" works, which means only the appropriate countries are shown in the dropdown of the filter. But after clicking "Apply" the results are zero.

I have tried to rewrite the field but to no avail. I think the problem is, that the country is taken from the core. If i try other fields from the address field, it works.

Any help appreciated! Thanks!

EDIT: I just found out about the checkbox on the field itself called: "Display the localized country name instead of the two character country code". If this is unchecked, the view and the filter are working. But now i have a unreadable list of country abbreviations in my dropdown.

Is there something i can do about this?


texts: Validation error on back button in Multistep Form

texts:
Validation errors with a back button on Multistep form.

I used form alter for this but this is also not working below are my code.

function mymodule_form_alter(&$form, &$form_state, $form_id)
{ if($form_id=='dataset_node_form')
{
 $form['actions']['previous']['#submit'][] = array();
 $form['actions']['previous']['#limit_validation_errors']=array();
}
}


texts: Why do I get the wrong path with sql-sync on windows using cygwin?

texts:
I have drush 8 up and running ok on windows 10 with cygwin, except for running an sql-sync command.
When running the command to sync from stag(remote) to dev(local), it generated the dump file on the remote server fine but then has a problem pulling it down to my local machine.
Adding the -verbose option to the sql-sync command reveals that the path that it tries to put the database dump file is wrong.
eg.
/cygdrive/C/wamp/www/kev//cygdrive/C/Users/2pha/AppData/Local/Temp
as you can see the path is wrong.

You will delete files in /cygdrive/C/wamp/www/kev//cygdrive/C/Users/2pha/AppData/Local/Temp/kev_stag_20170123_095407.sql
.gz and replace with data from twopha@XXX.XXX.XX.XXX:/home/twopha/drush-backups/kev_stag/20170123095407/kev_stag_2017012
3_095407.sql.gz
Do you really want to continue? (y/n): y
Calling system(rsync -e 'ssh ' -akzv --exclude=".git" --exclude=".gitignore" --exclude=".hg" --exclude=".hgignore" --exc
lude=".hgrags" --exclude=".bzr" --exclude=".bzrignore" --exclude=".bzrtags" --exclude=".svn" --stats --progress --remove
-source-files twopha@106.185.47.186:/home/twopha/drush-backups/kev_stag/20170123095407/kev_stag_20170123_095407.sql.gz /
cygdrive/C/wamp/www/kev//cygdrive/C/Users/2pha/AppData/Local/Temp/kev_stag_20170123_095407.sql.gz);
receiving incremental file list
rsync: change_dir#3 "/cygdrive/C/wamp/www/kev//cygdrive/C/Users/2pha/AppData/Local/Temp" failed: No such file or directo
ry (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(713) [Receiver=3.1.2]

Here is the relevant part of my aliases:

$aliases['dev'] = array(
  'root' => 'C:/wamp/www/kev',
  'uri'  => 'localsite.dev',
  'path-aliases' => array(
    '%dump-dir' => 'c:/wamp/tmp',
    '%files' => 'sites/default/files',
  ),
    'source-command-specific' => array (
    'sql-sync' => array (
      'no-cache' => TRUE,
        'create-db' => TRUE,
        'mode' => 'rultvz',
    ),
  ),
);

$aliases['stag'] = array (
  'uri' => 'xxx.xxx.com',
  'root' => '/var/www/xxx.xxx.com/public_html',
  'remote-user' => 'serveruser',
  'remote-host' => 'xxx.xxx.xxx.xxx',
  'path-aliases' => array(
    '%dump-dir' => '/tmp',
    '%files' => 'sites/default/files',
  ),
  'source-command-specific' => array (
    'sql-sync' => array (
      'no-cache' => TRUE,
    ),
  ),
  // No need to modify the following settings
  'command-specific' => array (
    'sql-sync' => array (
      'sanitize' => TRUE,
      'no-ordered-dump' => TRUE,
      'structure-tables' => array(
       // You can add more tables which contain data to be ignored by the database dump
        'common' => array('cache', 'cache_filter', 'cache_menu', 'cache_page', 'history', 'sessions', 'watchdog'),
      ),
    ),
  ),
);

EDIT
Also, while running rsync to sync the files, the paths seems all messed up:
I ran:
drush rsync @kev.stage:%files/ @kev.dev:%files
And this is what I got (notice the paths):

You will delete files in /cygdrive/C/wamp/www/kev//cygdrive/C/wamp/www/kev/sites/default/files and replace with data fro
m @kev.stage:/cygdrive/C/wamp/www/kev//cygdrive/C/wamp/www/kev/sites/default/files/

So, as far as using drush (specifically sql-sync and rsync with cygwin)
Is there some setting I am missing in relation to the paths?
Has someone encountered this before?
Is this a Drush bug? (I did search the issue queue but found nothing)

Drush issues that seem relevant:
Drush is converting Cygwin paths unnecessarily. If Cygwin PHP is being used, paths should not be converted.
fix for use under cygwin's php


texts: [fixed]Trigger an ajax Submit Form button by clicking on a div

texts:
I've a form inside a custom template and I would like to trigger the submit button clicking on one div. Then the function submitForm sends the form-data to a webservices using Drupal httpClient.

The twig template is like:

<div class="Rectangle" id="rectangle-div" >
 This is the div containing some stuff that I want to click to submit the form.
</div>

<form id="form-id">
{{ form.elem }}
{{ form.actions.submit }}
</form>

I tried with a simple jQuery function like:

jQuery(function($) {
    $(document).ready(function () {
        $('#rectangle-div').on('click', function () {
            var wrapper = $('#form-id');
            $('.form-submit', wrapper).trigger( "click" );
        });
    });
});

I tried also to write a selector like:

$('button[id^="edit-mod-submit"]', wrapper).trigger( "click");

if I try with a simple submit like

$('form-id').submit();

the js code submits the form but refresh the page avoiding ajax and furthermore doesn't send data to the WS:

(if I use the submit button the data goes to the WS).

Any other ideas?

UPDATE #1: FIXED

I added inside the ajax option of my submit button the event 'click' and now, using jQuery, I am able to send the post request to the WS. The form is like:

 $form['actions']['submit'] = array(
            '#type' => 'submit',
            '#value' => $this->t('Save'),
            '#button_type' => 'primary',
            '#ajax' => [
                'callback' => '::setMessage',
                'event' => 'click',
            ],

        );

The jQuery function is:

jQuery(function($) {
        var wrapper = $('#form-id');
        $('.form-submit', wrapper).trigger( "click" );
    });

Now I should intercept the response coming from the webserver and then execute a JS script, but these are other questions :)


texts:
In Drupal 7 I used some JavaScript that required jQuery in the page.tpl.php file using the following code.

<script type="text/javascript">
    (function($) {
    $( ".mobile-menu-button" ).click(function() {
    $(".navigation").toggleClass( "visible" );
    $(this).toggleClass( "active" );
});
    })(jQuery);
</script>

Hod do I do this in Drupal 8? I have tried many ways of adding this code (with and without the jQuery argument above) in page.html.twig without success. I can see the code in the page source, but it fails to work.


texts: How can i add a span element within the search form using hook_form_alter?

texts:
I’m trying to customize a search box that appears in the global header, using hook_form_alter. I’ve succeeded in changing the submit button to an image but still need to do the following 2 things:

add placeholder text that reads ‘Enter search terms here….’
and then add a

within the form itself. This is for future use, i’ll be coding the field to hide/show when mousing over a search icon.

my hook_form_alter code is as follows:

function mytheme_form_alter(&$form, &$form_state, $form_id){
  if($form_id == 'search_block_form'){
  //dsm($form);
  $form[actions][submit]['#type'] = 'image_button';
  $form[actions][submit]['#src'] = drupal_get_path('theme', ‘mytheme’). '/images/search_trans.png';
  }
}


texts: I have used custom_module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id); I get the form ID of other forms, but I don't get the login form $form_id inside the hook.


texts: How to use Output as a link and replacement patterns to get friendly URLs

texts:
In a View, with a list of fields, I have the Rewrite results --> Output this field as a link, and a replacement pattern [title]. However, the URL is not completely friendly, although I can substitute white space for dashes "-", it still can have accents or other symbols which simply do not appear when using the module PathAuto and the function ´pathauto_cleanstring´ in which they are substituted. As the links are completely dynamical, I cannot find any option in the Config of the module to have the patterns substituted.

Summarizing, I have a field "title", and I get the output rewrite as

my-page/[title]

if I have a node titled "Atención: no beber", I would like to have the URL:

my-page/atencion-no-beber

and I am getting, instead,

my-page/Atención:-no-beber

The only way I have found is programmaticaly rewriting the output again, but I am confident that it can be done without a single line of code somehow.

How can output this URL without programmatically rewriting it?


texts:
I am using the following code.

public function buildForm(array $form, FormStateInterface $form_state) {
 $appDir = take_control_app_dir();
 $extpath = take_control_fb_ext_client_path();

 $validationString = take_control_random_string(20);
 $fbpath = take_control_client_path(drupal_get_path('module', 'fb') . '/fb.html?extpath=' . $extpath);
 $form = [
   'example one' => [
     '#markup' => ''
   ],
   'take_control' => [
     '#markup' => '
iframe
',
   ],
 ];

 return $form;
}

The  tag is not rendered.

Is there any way to make it render?


texts: Adding a button to a form that links to an external URL

texts:
I am trying to add another button to a user login form.  I am able to get the button to show up, but not to link to an external URL (example.org in the code below).  Code I am using is below:

<?php

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'user_login' || $form_id == 'user_login_block') {
    $form['change_pass'] = array(
      '#type' => 'button',
      '#prefix' => '
',
      '#suffix' => '
',
      '#value' => t('Change Password'),
      '#weight' => 1000,
      '#submit' => array('MYMODULE_change_pass_submit'),
      '#limit_validation_errors' => array(),
    );
  }
}

function MYMODULE_change_pass_submit($form, &$form_state) {
  drupal_goto('https://example.org', array('external' => TRUE));
}

Any thoughts?


texts: Sub-menu does not showing up despite "expandend" option is on

texts:
I have an menu that has some sub-menu:

For the top option of sub-menu I've selected "expanded" option:

My .twig for menu looks like this:

{{ menus.menu_links(items, attributes, 0) }}

{% macro menu_links(items, attributes, menu_level) %}
  {% import _self as menus %}
  {% if items %}
    {% if menu_level == 0 %}

    {% else %}

    {% endif %}
    {% for item in items %}

            {{ item.title }}
            {% if item.below %}
                {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
            {% endif %}

    {% endfor %}

  {% endif %}
{% endmacro %}

But I don't get sub-menu in output (item.below always returns false).
I've clear the cache via admin panel. I don't see sub-menu output with default menu--main.html.twig either.


texts: How to create a rule to combine the terms of 2 fields to create a new term and store it in a 3rd field?

texts:
I have a content type that has 3 term reference fields:

Field A (required), which contains a single tag.
Field B (required), which contains a single tag.
Field C (not required), which contains a single tag.

The tags from those 3 fields all related to the same taxonomy.

When creating or updating a node, values are entered for field A and B. I want to have a rule ((using the Rules module) with some Rules Action to set a  data value for field C, equal to the concatenation of the value entered for field A and B. But "set a data value" only sets one value.

What can I do to set multiple values?

Some more screenprints to explain all this:

And here is my current Rule I'm trying to get to work:

{ "rules_juhe_xieru" : {
    "LABEL" : "\u805a\u5408\u5206\u7c7b\u81ea\u52a8\u5199\u5165",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_insert--mfpf" : { "bundle" : "mfpf" } },
    "DO" : [
      { "data_set" : { "data" : [ "node:field-juhe-fenlei" ], "value" : [ "node:field-diqu" ] } }
    ]
  }
}


texts: How to force a selection in one field if another webform field is a certain value

texts:
I know it is quite simple with Conditionals to show and hide fields based on another fields value in a Webform -- is it possible to change values of fields based on another field's value?

For example, if someone selected a certain membership type in a field at the top, could a field lower down automatically have certain selections disabled automatically (or a single selection selected, and the entire second field disabled)?

This is a bit of an oversimplified example, but:

  Membership type (select) > Single person

  How many t-shirts would you like (select)? [Preselect "One" and disable the field from edits]

and

  Membership type (select) > Two people

  How many t-shirts would you like (select)? [Option to select "One" or "Two"]


texts: Merge content (e.g. a forum, with nodes, terms and users) from one Drupal site into another

texts:
How would I merge content (e.g. a forum, with nodes, terms and users) from one Drupal site into another?

Here's my specific use case:

I have a local site which just contains nodes, terms and users for a forum (these were imported with http://drupal.org/project/phpbb2drupal - and before you suggest just using it on my live site, I can't get it to work there, running into the issues described at http://drupal.org/node/1033316 )
I have a live site which has no forum, but has its own nodes, terms and users.
I'd like to merge the local site forum into the live site, adding the forum to the live site.


texts: Search form block not showing in IE7 and IE8

texts:
Search shows fine in chrome but not in IE8- looking at the code the DIV block-search-form simply isn't there. This occurs in different themes and also if I change where search should be displayed.

I'm on a fresh install of 7.12 with commerce kickstart, internationalization and other pretty standard modules.

Any ideas?


texts: Required Modules by Translation Management Tool (tmgmt)

texts:
I read the description for the translation management tool (tmgmt) and I found it requires many other modules. I'm wondering what the modules do specifically to make the tmgmt work? I read their respective project page descriptions, but that doesn't really help me understand how exactly it integrates with the module. Those modules are:

Entity API
Views
Chaos Tools
Views Bulk Operations
Content Translation
Locale
Internationalization
Entity translation
Rules

Is there quick explanations or examples regarding how they support tmgmt?


texts: Displaying linked information based on a users profile fields

texts:
I am trying to figure out the best way to show certain information based on a users profile field.

What I am trying to achieve is having a directory of peoples contact information (name, email, phone number) - note these will not be users in the drupal system.

Then for example when creating a drupal user, one of the required fields will be contact - in this field I would like to have it select a contact name from the directory I mentioned above.

If the person was not in the contact information then, the administrator would have the option to create the new contact before finishing the drupal user signup.

Finally once the contact field is linked to a persons name in the contact information, I would like to have a node that looks at the drupal users profile, shows their information and shows the contact information that is linked.

I hope the above makes sense :)

The way I think I would approach it is by creating a custom content type for the contact information directory with a name, email and phone number field.

Then adding a contact field to the users profiles (not sure how to link to the contact content type though - maybe through taxonomy?) - I am not sure how I would go about creating a new contact during a user signup?

Lastly displaying the information, assuming I could link the contact field to the relevant information I am guessing that using views and it's filters would be the best way to display it.

Any thoughts or guidance on this would be appreciated :)


texts:
I have a big problem. I don't know why, but every day are created users in my site. It's not a normal registration because I have disabled the block for login/registration in my site. The users' status is locked and they are many.

What can I do?


texts: An AJAX HTTP request abnormally terminated in autocomplete textbox

texts:
I have autocomplete textbox which populate the suggestion based on search text.
Steps

User type in search text box
User press enter instead of waiting for AJAX autocomplete to respond

It comes up with the following error.

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: path/allcontent/autocomplete
StatusText: error
ResponseText:  ReadyState: 4

I read Drupal alerts "An AJAX HTTP request terminated abnormally" during normal site operation, confusing site visitors/editors, but it didn't help.
This is the callback code.
Autocomplete Textbox
function search_user($form) {
        $form['text_usersearch'] = array(
            '#type' => 'textfield',
            '#title' => t(''),
            '#autocomplete_path' => 'searchuser/autocomplete',
            '#size' => 30,
            '#attributes' => array('class'=> array('auto_submit'),'style'=> array('float:left')),
        );

$form['submit_user'] = array(
            '#type' => 'submit',
            '#value' => t('Find'),
            '#attributes' => array('class'=> array('submit_user linkbuttonAction'),'style'=> array('float:left;margin-left:10px')),

        );

Autocomplete menu register
$items['searchuser/autocomplete'] = array(
     'title' => 'Autocomplete for User',
     'page callback' => 'user_autocomplete_search',
     'access arguments' => array('access content'),  //or whatever permission makes sense
     'type' => MENU_CALLBACK
      );

Menu callback
function user_autocomplete_search($string) {
        global $user;
        $arrUserMatch = array();

        $matchCode = '%'.db_like($string).'%';
        $arrUserTitle = SelectMatchingUserTitle($matchCode,10);

        foreach ($arrUserTitle as $userId=>$userName)
        {
            $autotext .= check_plain($userName);
            $arrUserMatch[$userName] = $autotext;
        }

        drupal_json_output($arrUserMatch);
    }

Form submission handler
function search_user_submit($form, &$form_state) {

        $searchval= $form['text_usersearch']['#value'];

        if($searchval=='')
            return;
        else
           drupal_goto('user/'.$searchval);
}

JavaScript autocomplete
$(window).load(function(){
                Drupal.jsAC.prototype.select = function (node) {
                        this.input.value = $(node).data('autocompleteValue');

                        if(jQuery(this.input).hasClass('auto_submit')){
                              this.input.form.submit();
                        }};

        });


texts: Advice on CSV import with taxonomy for data sanitaztion

texts:
i have a situation where users will be uploading csv files of the same format/columns but
the data is not consistent...for example in the "state" field, one office might use "NC" and another might use "North Carolina". another might have "N. Carolina". misspellings are common too in some fields.

how do i let them upload this data but sanitize it at the same time so that i know that "NC" == "North Carolina" == "N. Carolina"...etc?

my thought is to use a vocabulary for each column and force the user to map any data that doesn't match up before the csv is processed and nodes are created.

so i'm thinking the process would be as follows:

user uploads csv
user gets a form/table showing the data they uploaded along with a vocab drop down for each cell that needs to match up to a term. (each cell in the state column would have a drop down)
user manually maps any data that did not match up to a term.
user hits "process csv" and nodes are created.

so if i uploaded a csv that had "Nrth Car." in the state column...i would have to select "North Carolina" from the drop down before the csv can be processed.

*would also be cool if i could store these variations as synonyms so that next time they upload a csv they won't have to map the same variations again. ("Nrth Car." would automatically be mapped to "North Carolina" the second time around.)

thoughts?


texts:
I would like to add some custom fields to the taxonomy_term_data table.

How do I programmatically extend the Term entity?


texts:
drush config-export dumps my entire site config into files.

What I want is to only export config which is non-default.

ie. if I haven't changed my "automated cron settings" since installing my Drupal site, leave it out of my config.

Is this possible with drush? Some other tool?


texts: Is there a function to clear the watchdog log inside a module?

texts:
I don't want to clear the watchdog log from the UI each time while debugging. It becomes time consuming and tedious.

Is there a Drupal function to clear the watchdog log inside a module?


texts: drupal /?q=user is working but /user not working

texts:
I have recently moved my files from dev server to test server. same setting and db of dev server were copied to test server. In dev server all is working fine but when I have am checking in test sever /user not working but /?q=user is working

I have checked with mod_rewrite in test server apache setting and it is enabled.
I also checked my clean url drupal setting it is also enabled

/user throws 404 error for me

Not Found

The requested URL /user was not found on this server.

Can someone help me find the issue


texts: How/where do I add $('#fullpage').fullpage() code?

texts:
I want use the fullpage library. In my theme.libraries.yml file, I added theses lines.

fullPage:
  header: true
  js:
    js/fullPage.js/jquery.fullPage.js: {}
  dependencies:
    - core/jquery

jquery.js and jquery.fullPage.js are now present in the <head> tag,
but to run fullpage.js, I must execute [this additional script2.

$(document).ready(function() {
    $('#fullpage').fullpage();
});

How and where do I add this little script?


texts: impllement bootstrap checkbox in drupal 8

texts:
I need to add the checkbox-inline class (as mentioned in bootstrap checkbox tutorial) to show checkboxes inline one after another instead of one checkbox per line.

How can I add the class to a checkbox being an form (content type) element?


texts:
I am trying to create a copy of a Drupal installation in a different folder.

I want to copy the site that is located on https://my-url/drupal to http://my-url/copy. I copied all the files in the Drupal root to the copy folder and I exported and imported the database in a new database and also changed the database configuration of the copy site using settings.php (copy/sites/default/settings.php).

When I put the main site on maintenance mode though the copy site is also put on maintenance mode.

Am I missing something here?


texts: Numbering the content list in drupal (as simple as it sound) - possible via the UI?

texts:
Went through the conf and the Drupalsite > Content page but couldn't find any where to number the list (or at least to get a nubmer of all contents of all entities and types - including Views, Panels, Webforms, ETC).

Would thank you for showing a simple way for numbering this list \ get a content-total number.

Here is the picture of my natural display of the content page... Thanks, Ben.


texts: How can I render single Simplenews fields in Twig?

texts:
I had a Drupal 7 site and I have build my newsletter with print render. Example:
 print render($build['field_title']);
 print render($build['field_image']);
 print render($build['field_description]);

With that, I could render every field, one per one. Now, how can I do that with Drupal 8 and twig?
What I want is to build a newsletter with layout and existing content but without the generic {{ build }}.
I successfully print every field of the node with tokens like [node:body], but I can't print the rest of the node and only {{ build }} can do it.
I know this is not correct, but can I do something like that {{ build | description }}?
I use the Simplenews template.


texts: Why is my rules created shipping profile not being used?

texts:
I've created a rule with the intention of pulling an address from the users account and creating a shipping customer profile type instead of showing the user an address field to enter shipping (The site is designed for customers to sell to their customers so someone might be looking over their shoulder and we don't want them to have to type their address in multiple times a day (even if it's saved)) while the rule creates a shipping profile type just fine if I don't have the shipping information pane in the process I don't get rates however I can look at the backend and have a properly (as far as I can tell) filled in shipping profile

A copy of my rule so far:

{ "rules_shipping_address_test" : {
    "LABEL" : "shipping Address Test",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "-10",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "commerce_shipping" ],
    "ON" : { "commerce_shipping_collect_rates" : [] },
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "commerce_customer_profile",
            "param_type" : "shipping",
            "param_user" : [ "commerce-order:owner" ]
          },
          "PROVIDE" : { "entity_created" : { "shipping_info_unsaved" : "Customer Profile Shipping information Unsaved" } }
        }
      },
      { "data_set" : {
          "data" : [ "shipping-info-unsaved:commerce-customer-address" ],
          "value" : [ "site:current-user:field-primary-shipping-address" ]
        }
      },
      { "entity_save" : { "data" : [ "shipping-info-unsaved" ], "immediate" : "1" } }
    ]
  }
}

(it's not important now but in the future I'm planning on allowing the user to choose between 2 profiles on their account)

Update 1: After looking at a dsm of the order on a backend administration view that I was attempting to add shipping to I find that commerce_customer_shipping is an empty array which I assume is my problem that even though I'm creating and saving a profile it's not being set to the order?


texts: How to create a module as a wrapper for js

texts:
I do a lot of theming but I don't have much in the way of php skills. So when I use or create a cool piece of javascript, I put it into my theme layer. The problem is, 90% of the time it doesn't belong there, and I really can't share what I've done with others.

So, how can I create a module, basically as a wrapper, for js code? I need to know more about that basic custom module structure and also the php used to insert js and css. Bonus would be basic info about creating blocks, content types and views with the module rather than creating them on the site UI.


texts:
Drupal CCK taxonomy field value lost when doing feed importing

In Drupal 6, CCK lost taxonomy when doing feeds import.

Have a content type "Thesis".
It has a field taxonomy "Category".

For example, have this thesis, in Physics category
Thesis: Investigations on Inductively Coupled Plasma Interaction
Category: Physics

Have this thesis, in Chemistry category
Thesis: Layer-by-Layer Self-Assembled Thin Films
Category: Chemistry

Create feed import to import and parse xml to load this content type.
Select update existing content.

When doing feed import, somehow the taxonomy field value is lost.

For example, have this thesis, in Physics category
Thesis: Investigations on Inductively Coupled Plasma Interaction
Category: VALUE LOST HERE <<<<<<<<<<==========================================

Have this thesis, in Chemistry category
Thesis: Layer-by-Layer Self-Assembled Thin Films
Category: VALUE LOST HERE <<<<<<<<<<==========================================


texts:
Problem

I have a series of file fields on a user account where users can upload files. These files need to be attached to emails (by the system with drupal_mail) and removable by the user.

But they don't actually need to be downloadable. And it would be a nice extra level of security if they can't download the files, only upload, remove and upload again.

Has anyone ever tried this (admittedly fairly niche) idea before?


texts: Download Update's fail (Unix File Permissions on /tmp directory)

texts:
When I goto admin/reports/updates/update select all and then hit the "Download these updates" I get the following  error message

  The specified file temporary://filewq3Nao could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.
  http://ftp.drupal.org/files/projects/ctools-7.x-1.0-alpha4.tar.gz could not be saved to temporary://update-cache/ctools-7.x-1.0-alpha4.tar.gz.

File System Settings can be found here: admin/config/media/file-system

/tmp is setup with 777 and I get NO errors on this page.  I attempted to create a /tmp2 with 777 and that directory would fail the security checks.  I am on shared hosting.  There are directories in /tmp called analog, awstats, cpbandwidth, webalizer, webalizerftp which I assume are CPannel utilities:)


texts: Add a calculated column programmatically using views data export

texts:
I am using the views data export module with Drupal 8. I have a view that shows a list of users and the desired columns to be exported to the csv are:

Name
Trained
Status

Unfortunately, both of the Trained and Status columns are calculated through a semi-complex method from my module. Using the calculated field module isn't really an option.
Ideally my csv should look something like the below. The "Trained" and "Status" columns would be calculated by running the user_id through their respected methods:
Name | Trained | Status
user_name_1 | is_trained(user_id_1) | get_status(user_id_1)
user_name_2 | is_trained(user_id_2) | get_status(user_id_2)
...

I have tried what I feel is every combination of views pre_render, post_render, post_execute, etc...; however, I just can't seem to find a way to add a calculated value to the row. It is possible I am approaching this wrong but any suggestions on how to accomplish this would be appreciated.


texts: How to use fields of a flag instead of only toggling the flag?

texts:
I have created a flag (using the Flag module) called status and a field to it and named it remarks. Now, how do I let users to flag other users and fill in the remarks field for that particular flag.

All I am able to do is toggle the flag.

I couldn't find any documentation on it and the complimentary module of flag called flagging form is obsolete.

When a user flags another user, I want a pop-up to appear asking them for remarks before flagging the user.


texts: Role to edit user profiels but not administer accounts

texts:
As far as i can tell drupal allows me to make a user role able to edit other user profiles(edit the profile fields) only if the role they have includes "Administer users."

When this is set a role can see the edit tab on all profile pages and make edits to other user profiles. Good we want that. But this also allows the user to administer accounts as well(add/remove accounts). Bad, we want that restricted so that only account admins can add/remove accounts. We want a role for a "lower tier" user to be able to edit profile fields as needed, but not administer accounts.

I use the Fields Permissions module to control access to fields. Works great, allows that different user roles can or can not see and/or edit different fields for other users.
This lets us to have internal use only fields on our user profiles that only appropriate staff can access.
But this is not controlling if a user has the ability to edit user profiles or not.
Just what specific fields in user profiles can be seen or edited IF the user already has the rights to edit other user profiles first. That is still controlled with the "Administer users" setting, which seems to only give the rights for account administration as well as profile editing all in one.

Can we separate the rights to edit user profiles from administering user accounts,
allowing for a role that can edit user profiles but not administer accounts?

Thanks for any help on this one.


texts: How to select a custom block and region according to a view

texts:
I have a view / display page that needs to be displayed in a specific html - page format.
I did a html--viewname.tpl.php and page--viewname.tpl.php to display my view.

Within page--viewname.tpl.php I call print render($page['content']); to render my view.
All is working except that block.tpl.php and region.tpl.php are called by drupal system to wrap the view content adding several html tags (div)  that I don't want.

I expected to use function MYTHEME_preprocess_block(&$variables) to ask drupal to use a custom block.tpl.php file, but within this function I didn't find the way to know if the function is called to render my viewn or anything else.


texts: How can I programmatically render a node's field respecting the view mode settings?

texts:
I want to render a node's field inside a block. It works like this:

<?php

if ($node) {
  if (isset($node->field_body_secondary) && $field = $node->field_body_secondary->value) {
    $markup = render($field);
    $build = array(
      '#type' => 'markup',
      '#markup' => $markup,
    );
  }
}

return $build;

But this is not 100% as if I would just render the field normally, making it visible in the view mode settings.


texts: How to redirect to www without editing .htaccess file?

texts:
What alternative methods are there for redirecting all page requests to the www version of a domain?

I know how to eidt the root .htaccess file but find that this method does not survive core updates.

Is there another way? Perhaps with a module?


texts: Drupal 7 contexual filter display block based on node reference

texts:
I have been going around in circles with this for a few hours now... Time to ask for help!!

I have two Content Types:

1: Book

2: Reader

The Book Content Type has a node reference field which is a select list of readers create with the Reader Content Type.

This is all set up and working fine.

Now the issue with my views:

I have a view with is a block containing the Reader fields. What I want to do is have it when the Book node is loaded my block shows underneath with the referenced reader details. Also if no reader is referenced then no block shows up.

I have spent some time in Relationship and Contextual Filters but can't get it to work.

The book URL is formatted like this:

books/[book-title]

I tired using 'raw value from url' in Contextual Filters as setting it to the 2nd argument but that didn't work either.

If anyone can help me out here I would be very much appreciative.

Thanks
C