texts: How to set the permission for particular role user to access the user profiles of users with a particular role?

texts:
I have two user roles:

business_users
company_users

I want to set the permission for all users to see the user profile of users in "business_users" role only.

User with the "company_user" role should not to see user profile of user in their role but they can see user profile of user in "business_users" role.
User with the "business_users" role can see user profile of users with their role but they should not see the user profile of users with the "company_user" role.
Anonymous users should see user profile of user in "business_users" role only.

Can you tell how can I implement it?


texts: Where is source code of advanced search form?

texts:
I can't find where in Drupal 7 search module is the source code of advanced search form that appears on search result site.

Below is code of search_form. You can see there is basic key in renderable array. In output of dpm is even advanced key, but i can't find from where it comes.

It should be probably somewhere in search module, but it is not big module and i checked it last 4 hours and can't find it.

function search_form($form, &$form_state, $action = '', $keys = '', $module = NULL, $prompt = NULL) {
  $module_info = FALSE;
  if (!$module) {
    $module_info = search_get_default_module_info();
  }
  else {
    $info = search_get_info();
    $module_info = isset($info[$module]) ? $info[$module] : FALSE;
  }

  // Sanity check.
  if (!$module_info) {
    form_set_error(NULL, t('Search is currently disabled.'), 'error');
    return $form;
  }

  if (!$action) {
    $action = 'search/' . $module_info['path'];
  }
  if (!isset($prompt)) {
    $prompt = t('Enter your keywords');
  }

  $form['#action'] = url($action);
  // Record the $action for later use in redirecting.
  $form_state['action'] = $action;
  $form['#attributes']['class'][] = 'search-form';
  $form['module'] = array('#type' => 'value', '#value' => $module);
  $form['basic'] = array('#type' => 'container', '#attributes' => array('class' => array('container-inline')));
  $form['basic']['keys'] = array(
    '#type' => 'textfield',
    '#title' => $prompt,
    '#default_value' => $keys,
    '#size' => $prompt ? 40 : 20,
    '#maxlength' => 255,
  );
  // processed_keys is used to coordinate keyword passing between other forms
  // that hook into the basic search form.
  $form['basic']['processed_keys'] = array('#type' => 'value', '#value' => '');
  $form['basic']['submit'] = array('#type' => 'submit', '#value' => t('Search'));

  return $form;
}


texts: Help with a db_select() not returning results when it *should*

texts:
I'm having trouble figuring out why the db_select() is not returning any results.  Long story short, if I pass the results of $results->execute() through a foreach ($results as $result), I don't get any results.  If I take the generated SQL and go directly to command line or phpMyAdmin (substituting manually for the placeholders) I get the expected result.  I feel like I have to just be overlooking something - I'm hoping fresh eyes can point it out for me.

Here is the select:

$results = db_select('product_charges_override', 'pc');
$results->join('products', 'p', 'p.product_id = pc.product_id');
$results->fields('pc', array('uid', 'product_id', 'override_count', 'redemption_count', 'coupon_code'))
  ->fields('p', array('human_name'))
  ->condition('pc.coupon_code', $coupon_code);
$results->execute();

Here is the result of dpq($results):

SELECT pc.uid AS uid, pc.product_id AS product_id, pc.override_count AS override_count, pc.redemption_count AS redemption_count, pc.coupon_code AS coupon_code, p.human_name AS human_name FROM {product_charges_override} pc INNER JOIN {products} p ON p.product_id = pc.product_id WHERE (pc.coupon_code = :db_condition_placeholder_0)

Here is the relevant Where statement from just var_dump($results):

protected 'where' =>
  object(DatabaseCondition)[136]
    protected 'conditions' =>
      array
        '#conjunction' => string 'AND' (length=3)
        0 =>
          array
            'field' => string 'pc.coupon_code' (length=14)
            'value' => string 'ugd2pl8z92j9' (length=12)
            'operator' => string '=' (length=1)
    protected 'arguments' =>
      array
        ':db_condition_placeholder_0' => string 'ugd2pl8z92j9' (length=12)
    protected 'changed' => boolean false
    protected 'queryPlaceholderIdentifier' => string '52e7fdf78bbd25.63959182' (length=23)
    public 'stringVersion' => string ' (pc.coupon_code = :db_condition_placeholder_0) ' (length=48)

And, finally, the query as I run it from the command line (notice the '{' and '}' have been removed, as well as the placeholder replaced with the value from the 'where' object). Those are the only things I replaced from the results of dpq().

SELECT pc.uid AS uid, pc.product_id AS product_id, pc.override_count AS override_count, pc.redemption_count AS redemption_count, p.human_name AS human_name FROM product_charges_override pc INNER JOIN products p ON p.product_id = pc.product_id WHERE (pc.coupon_code = 'ugd2pl8z92j9')

And an export from phpMyAdmin of the query results:

/**
 * Export to PHP Array plugin for PHPMyAdmin
 * @author Geoffray Warnants
 * @version 0.2b
 */

 //
 // Database "mats_theme"
 //

 // mats_theme.product_charges_override
 $product_charges_override = array(
       array('uid'=>null,'product_id'=>7,'override_count'=>5,'redemption_count'=>0,'human_name'=>'Fleet Forum Registration')
);


texts: Simple way to change messages after node creation

texts:
Before I would use Custom Submit Messages to customize each message but, seems to not work as we like with Drupal 7.

Is there any other simple way that will allow to alter the message text after creating content?


texts: How to add multiple panel nodes to a panel page

texts:
What I need to achieve is essentially a panel page of panel nodes.

I have contact information for various divisions of a company. Then I used panel node to override the layout of these nodes. Now I need to maintain that layout and add them to a panel page or view.

Any help is much appreciated. Thank you in advance.


texts: D7 - Can't set selected value of a webform select element

texts:
I'm trying to set the selected value of a webform select form element before it is rendered. I'm using the below code and the textfields are working just fine but no luck with the select options.

function mytheme_preprocess_webform_form(&$vars) {
    $vars['form']['submitted']['emailAddress']['#value'] = 'some@email.com'; //This is working
    $vars['form']['submitted']['country']['#selected'] = 'BARBADOS'; // This is not working even though #default value is used instead
}

I can't figure it out why this is not working for select field. I would be glad if someone could help me.

Thanks in advance.


texts: Error while set a paragraph field to NULL during cron run

texts:
I am using Drupal 8 and I have implemented a hook_cron to set a node field to NULL. Here is my code:

if ($lesson->field_lesson_ended_at->value < $current_time && $session_id && count($paragraphs) > 0) {
  $pids = [];
  foreach ($paragraphs as $paragraph) {
    $pids[] = $paragraph['target_id'];
  }
  $storage_handler = \Drupal::entityTypeManager()->getStorage('paragraph');
  $entities = $storage_handler->loadByProperties(['id' => $pids]);

  foreach ($entities as $entity) {
    try {
      $apiObj->forceDisconnect($session_id, $entity->get('field_session_connection_id')->value);
    } catch (Exception $e) {

    }
  }
  $storage_handler->delete($entities);
  $lesson->set("field_session_id", NULL);
  $lesson->save();
}

When cron task reaches these lines:

$lesson->set("field_session_id", NULL);
$lesson->save();

Throws the following error (capture from cron logs):

Error: Call to a member function getTranslation() on null in Drupal\Core\Entity\ContentEntityBase->hasTranslationChanges() (line 1430 of core\lib\DRupal\Core\Entity\ContentEntityBase.php)

Any ideas on how to solve this issue?


texts:
In a view using Articles and Blog posts sorted by recent post date, I'm using [Content: Post date] and I would like to display (as a column on the display) as only the date and not the time, i.e. 2016/04/08.

I merely wish to alter what data Drupal is displaying, not the data it is collecting.

How can I apply this date format to the field in the view?

In Home>Administration>Date and Time, I can add new date type but all 19 of the options include displays of time.


texts: How to print a field content link in the views-view-field template in Drupal 7?

texts:
I am trying to figure out if it is possible to print the content link of a field in the Views' template.

I would like to link an article title to its node, something like the following code:

print '' . $article['und']['0']['value'] . ''

This is a dumbed down version of my code in the view-view-field--field-article-title.tpl.php

$article = $row->_field_data['nid']['entity']->field_article_title;
$subtitle = $row->_field_data['nid']['entity']->field_article_subtitle;

if (isset($subtitle['und']['0']['value'])) {
  print $article['und']['0']['value'] . ': ' . $subtitle['und']['0']['value'] . '
';
}
else {
  print $article['und']['0']['value'];
}

Can anyone point me in the right direction? I've tried printing out the available fields, but for some reason I cannot print the fields in the view.


texts: How to delete a taxonomy term with a broken URL

texts:
I was trying to change the URL pointed to by a taxonomy term so that clicking on it would take the user to a map. However, after changing the URL I am no longer able to go into the term to edit the value.
How can I switch the URL back, or delete the term altogether when I can't access it's edit screen?


texts: Is there way for create custom "add userpoints transaction" form

texts:
Good day to everyone!

I have view which show user list, current userpoints, and email. I want set some link, which will lead to add transaction form where name will already fill. Is there way to add userpoints transaction for specific user except standard form?


texts: QuickTabs with ajax and information from url

texts:
I am using Drupal 7 and QuickTabs to display some tabs. There is no problem without ajax. But I want to use ajax to have a clean url.
In one tab I am displaying a block which uses the current nid. The current nid is needed to display some fields which I configured in the block.
In another tab I am displaying a view which has the contextual filter 'Content: Nid' with an entity reference. I configured to get content id from url when the filter value is not available in the contextual filter options. The view displays a node with the entity reference. I need to pass the nid for this.
Without ajax the url looks like this:

test.com/category/subcategory?qt-quicktab=0 (for the block)
test.com/category/subcategory?qt-quicktab=1 (for the view)

It works just fine without ajax. With ajax: I always get two empty tabs and the url looks like this

test.com/category/subcategory (which it should be and is good).

Because of this difference, I think that the problem could be that the information form the url is needed in some kind to display the block and view in tabs. I have other tabs which just display a view/block without any special requirements and they are displayed correctly in both cases.
I already cleared the cache / tried other contextual filter options in the view / tried the same configurations in a clean install of drupal.
Edit1: I created the tabs with QuickTabs programmatically in hope that it could solve this, but still the same problem occurs. I changed the filter options (and tried almost any logical alternative) for the view, but then I get no results with/-out ajax.
Edit2: Additionally, I am displaying the block in the normal way in a region and within quicktab. The block gets the nid from the subpage to display the fields. Only quicktab has the problem to show it, although it is the same block...I am still trying to solve all this.


texts:
Drupal 8.2.7:
Similar to this question: Why does my Site have a broken theme/style?

In my case only certain admin pages css are broken and this seems to only affect admin, not unauthenticated users. For example /node/add/article. In the head tag, I see the correct aggregated css listed a few times:
/sites/default/files/css/css_Va4zLdYXDM0x79wYfYIi_RSorpNS_xtrTcNUqq0psQA.css?onn5ym

But some stylesheets are not aggregated:
/?onn5ym

The common consensus is that the files where css are stored are not writable by Drupal, but I'm not sure this is the case because some stylesheets get aggregated. Or they are coming from another directory I do not know about? I've also tried clearing cache, no luck. Any other suggestions?


texts: Dificulties in modifying or duplicating a view

texts:
I'm using drupal 8 (it seems to me exact version is 8.1.8) as CMS.
I created many views, and I would like to modify them o to duplicate those views.
But, mainly after I set a contextual filter, is not possible to modify the view.

And I 'm experiencing troubles too in duplicate a view and then modify the parameters.

Is there any know issue about those difficulties?


texts:
I'm trying to debug a segmentation fault (11) from drush.
I have xdebug installed. The command it's giving the error is the pm-disable.

$ drush dis "module" --debug --verbose:
...

Calling hook drush_pm_disable [11.17 sec, 84.08 MB]                                                                                [debug]
Segmentation fault: 11

I think the issue is when it is calculating the dependencies, as I was also getting this on features/create, but disabling the dependencies checkbox in the features settings makes the features/create work well.


texts: Can NOT Disable/Enable/Add/Edit any component of the site

texts:
My drupal site is acting strange. I can NOT add/disable/enable/edit any components of the site. I can't add new content types, content fields, disable/Enable modules.

I just removed a module from the drupal server and updated the server cache and drupal cache but the module is listed being listed as 'Enabled' in the Modules List.

How do i fix the issue of my drupal site not accepting any changes?

(P.S. I was able to do a Drupal core update yesterday but that's about it for the changes I can make.)


texts: Passing variables from modulefunction to theme

texts:
I have a custom theme and a custom module. The module shows users. Every user has its specific image (that can be uploaded, changed). The location/name of this file is in the database.

I have an template with specific layout for that page: page--uspage.tpl.php
In this page, I need the location from the database when I access uspage.

$items['uspages'] = array(
    'title' => 'User pages', //page title
    'description' => 'User pages',
    'page callback' => 'show_uspages'
);

$items['uspage/%'] = array(
    'title' => 'User page',
    'description' => 'User page detail',
    'page callback' => 'show_uspage',
    'page arguments' => array(1),
    'access callback' => TRUE,
     'type' => MENU_CALLBACK,
);

I have a lot of other pages that doesn't need that. So I can't use preprocess_page.

What's the easiest and best way to pass an array with the backgroundinformation from the function show_uspage to page--uspage.tpl.php ?


texts: how to make relations link when editing taxonomy not show

texts: When a user edits a taxonomy term, there is a link for "Relations" at the bottom.  how can I make that link not show up for certain roles?


texts: Where does Drupal render the content of the  tag?

texts:
I'm calling drupal_add_html_head() a few times to add meta data for facebook integration. To my surprise, this data is not rendered in the order I add it.

Where is this data actually rendered? I would like to examine the code so I can understand the logic behind it.

I'm aware there's hook_html_head_alter too, but without understand the render order, messing with the order of input data is not likely helpful.


texts: Remove code from content type news article

texts:
Is there anyway to remove the code snippets from the content news article. facebook is pulling in the teaser text for the content which is correct but it is displaying unwanted code (as you can see in the screenshot).

thanks for your help!


texts:
I'm considering alternatives to pathauto module for automatic URL alias generation.

The reasons I want to stop using it are the following:

Most of the aliases are [node-type]/[node-title] so I do not need all other functionality.
Token goes wild and takes too much resources on pages where it needs to display the available tokens. I have 16 content types and quite a lot of fields and certain pages take considerably more time to load due to the large list of tokens.
I do not need token module for anything else
I would have 2 big modules less - pathauto and tokens, which would have impact on performance

I checked some similar discussions on drupal.org, but none of them offered really an alternative.

I'm now looking into optimizing the fields as each content type has its own set of fields (meaning they are not shared); this was done because of the performance but ironically I ended up with performance issues on the other end.

Setup: D7 with all latest modules.

Did you have similar problems? How did you solve them? Any words of wisdom?

Thanks!

[UPDATE]

For anyone looking for something similar, here is an article which explains how to handle that through a custom module.


texts:
I would like to associate users with a node (and make it possible for users to do this themselves) and have the result easily retrievable programmatically in a nice array( preferably with $node) and also have this in Views..

I found the following options so far

User Reference
Flag
Custom text field where I store userids as comma separated values
Entity Reference
Relation

Flag has the advantage of having actions that show on node view as well, which is quite convenient.


texts: How can I make my ubercart catalog content available to users?

texts:
I can't make my ubercart catalog content available to logged in users.

They can see the catalog page title but not the products.

This is what a logged in User can see:

This is my catalog views settings:

What I tried: I changed the rights for users already as shown below. Nothing happens.

What else am I missing?


texts:
I'm using drupal 7.

Normally, during the creation of a contents, the preview is added above the form.

I would wish that the preview opens in a new window, and that it is separated from the form of creation of contents.

Do you know a solution?


texts: How do I list all nodes created by the same author on a (custom) profile page?

texts:
In my setup each user has a profile page. The profile page is a custom content type (each user can only have one and they have to add it them selfs).

On this profile page I would like to list all nodes of a certain type created by the same user as the profile page.

How do I do this (in a views block preferably)?


texts: Trying to enter an argument with multiple words into a Views argument

texts:
I'm using Organic Groups with Views in Drupal 7  with OG Tokens to create a view which returns all content with a type associated with it, so groups/foo/article would return all articles where the content type is article and the group is foo. This works fine for a group audience where the audience is one word, such as foo, or two run together without spaces, such as FooBar. However when I create a group like foo-bar, the view returns the no content page even when there is content attached the group. The contextual filter that I am using is OG Group: Label.

I've tried putting PHP to explode the results in the 'WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED', following the posts that I've seen but although I can see it printing out the "foo bar", it is not calling the types attached to the group. Is there somewhere else that I can explode this data and remove the spaces so that the group details can be presented in the view, or even look at the query to see what is being passed into it by the argument?

Thanks for your help and time.

UPDATE:
Having run a slightly orthogonal search, i came across the following code:

    $handler->argument = str_replace('_', ' ', $argument);
    return TRUE;

Having replaced the underscore with a dash, the multi-worded OG audience type can be used as I outlined above. Put the code into the "PHP Validate" code on the specify validation code and apply. The original came from PixelClever . I'll mark as answered when the site allows me to do so as I don't have enough user points to do so immediately.


texts: Override Image Formatter template based on parent view

texts:
I have multiple views for the same content type (article), and want to override the Image Formatter template based on the view that is rendering it.

I have been able to add a suggestion to theme_suggestions_image_formatter_alter and select a template based on the content type and field name, based on the answer here, but if I apply that to the image field inside the article type, that applies to all views of this type. Is there any way to extract the view information inside the alter function so I can select the template based on the view as well as the content type?


texts: Apply condition between two fields in drupal 7 by using JQuery

texts:
This is updated JQuery code I have created condition between two fields in drupal 7 i.e. If we select item from first field then as per there selected item, some items of second field is going to hidden. But problem is that : If first I select item from second select field & after that I have select same item in first field then in this condition my created condition is wrong. Please Help to solve this. Thanks

Please check this DEMO

Below is my my updated JQuery code

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(function(){
abc();
$("#edit-main-field-i-am-field-und").change(function() {
    var value = $(this).val();
    var optionText = $(this).find('option[value='+value+']').val();

    $('#edit-main-field-look-for-field-und').find('option').show();

       if(optionText=="sbf" || optionText=="smf" )
       {

           $('#edit-main-field-look-for-field-und').find('option').filter(function(){
               if($(this).val()=="sbf" || $(this).val()=="smf")

                 return true;
              else
                 return false;
           }).hide();
       }
      else
       {

           $('#edit-main-field-look-for-field-und').find('option').filter(function(){
               if($(this).val()=="sdm" || $(this).val()=="sbm")
                 return true;
              else
                 return false;
           }).hide();
       }

    });
});

function abc()
{

   var value = $('#edit-main-field-i-am-field-und').val();

if(value=="sbf" || value=="smf" )
       {

           $('#edit-main-field-look-for-field-und').find('option').filter(function(){
               if($(this).val()=="sbf" || $(this).val()=="smf")
                 return true;
              else
                 return false;
           }).hide();
       }
      else
       {

           $('#edit-main-field-look-for-field-und').find('option').filter(function(){
               if($(this).val()=="sdm" || $(this).val()=="sbm")
                 return true;
              else
                 return false;
           }).hide();
       }

}
</script>


texts: Create a view from one result of another view and link to it

texts:
I need to set up a contextual filter that will pass the information from a single row of a view into a new view that only shows that one row, using maybe a link that opens it into a new page or a PDF.

When a user clicks "Print" I would like the resulting page to just show the information from that one line...

Background

I have a view that lists a row of things in a table. It's data imported into MySQL that's not associated with a node. I need to build a view page certificate to use instead of Certificate.

The data is quiz scores and the fields are QID, Date, Course, Score and Print Certificate. The "Print Certificate" column is a Global: Math Expression field that basically compares the score (score) with the global passing score variable (pass_rate) and prints a link if the expression is not zero, otherwise the field is left blank. The expression I am using to accomplish this is: abs(([score]+1)-[pass_rate])+(([score]+1)-[pass_rate]).

Course is a custom content type that is connected to the quiz that was taken. The quiz also links to the course so that it comes up in this view and Quiz is using the Quiz module.

What I've Tried

I created another view as a page that is similar to the view that shows all the scores, except I limited it to one item, excluding all fields from showing and I arranged it as an unordered list instead of a table. Using Global Text field which is not excluded, add back all the other fields using replacement patterns in order to control how the data is rendered so that it reads more like a certificate about one specific quiz score or QID. What needs to be done in order that the information displayed on this view page is the same as the row that linked to it, or just one QID?

Notes

So why not just use certificate? Biggest issues are that there is no token for when the certificate was earned or when the quiz was passed. See my SE post. The other reason is because the quiz scores were imported as values from another site. See my other SE post on this.

Ideas
Can I use a contextual filter in the parent view with some php using the fetchfield() function such as something like:

db_query_range('SELECT 1 FROM {quiz_node_results} WHERE qid = :qid', 0, 1, array(':qid' => $[something]->qid))->fetchField();


texts: Is it possible to link images to different URLs?

texts:
Using View's module it is possible to create a page to display some content horizontally. I have done this using carousel feature.
The content type that these contents belong to have an image_field and a body_field.
What I want from Drupal 8 is that when these images are clicked they should redirect visitors to a specific page (not to the node's / content's page).
Is it possible to do so or using html on body_field to place the images with a and img tags is the only way?
UPDATE:
At first I understood nothing from the answer below but a day later it just made sense like in the movie "Phenomenon"; I was struck by a mysterious light in the sky. Here is what I did:

Created a new link_field inside the content type that I am using on this View.

Went back to the content / node (under Content) where I wanted to add the link to the image and filled the link_field

Added this newly created link_field to the View and made it hidden by checking the box titled "Exclude from display".

Clicked on the image_field on View settings (under the FEILDS) and REWRITE RESULTS > check the box "Output this field as a custom link" (An empty area shows up to be filled here).

Went down and expanded the drop down list titled "REPLACEMENT PATTERNS" and found the link_field's name (The name you gave to your link field you have created it) and copied the string (something like {{ the_name_of_my_link_field }}).

Pasted this string into the empty area above then Saved, Saved, Saved to exit.

That's all!


texts: How to control field visibility in Views based on permission?

texts:
I am displaying Flag links via Views. By default the Flag module provides settings to control whether the Flag link appears eg. only appear on own content, only appear on others content etc.

The dilemma is that when displaying the Flag links via Views this no longer has any effect, and the Flag link will always display in the View. I have two Flags; one for owners of content and another for non-owners of the content. Depending on whether the user viewing the content owns the content or not I would like to display one Flag link or the other. This will allow owners for example to "delete" their own content, while non-owners to only hide content which is not theirs. If Views fields respected permissions this would be straight forward, but they don't seam to at least in my experience. How can this be done?


texts: How do I make the page created from my module visible only to anonymous users?

texts:
I programatically created a page using the following code.

/**
* Implements hook_menu().
*/
 function page_prog_menu() {
   $items['page_prog/custom'] = array(
     'title' => 'My Custom page',
     'page callback' => 'page_prog_custom',
     'access arguments' => array('access content'),
   );
   return $items;
 }

 /**
 * Custom callback function.
 */
 function page_prog_custom() {
   $content['raw_markup'] = array(
     '#type' => 'markup',
     '#markup' => '
Hello world
',
   );

 return $content;
 }

I need to make this page visible only to anonymous users. How can I achieve this?

I have tried with hook_permission(), but it doesn't help.

/**
* Implements hook_permission().
*/
function page_prog_permission() {
  return array(
    'access page_prog content' => array(
    'title' => t('Access content for the pages created programatically'),
    )
  );
}


texts: How do you add a nodequeue to an existing view on the front page?

texts:
I'm confused on how to get a nodequeue to appear on the front page?

I took over an existing Drupal website with Views and Nodequeue installed.

I created the nodequeue I want to add to the front page view as well as the nodes to include in the queue.
I duplicated the "relationship" and "sort"/ "filter" settings from the views that are already on the homepage.
This nodequeue I created looks fine when I preview it..

How do I actually assign the nodequeue to display on the front page like the others? I can't figure it out for the life of me.


texts:
I am having trouble with the Cache API in Drupal 8.
I embedded a views block with pagination through a field preprocess function into a node. When caching is off, I can normally use the pager and will always get the right results, but once caching is one, every block page (e.g. /node/1?page=2) shows the same block content rendering the pager useless.

I assume my hacky method is preventing the node cache to let the view in the field handle it's own caching, hence I always get the content from the page I visited first after clearing cache.

This is how the view is embedded:

function foo_preprocess_field(&$variables) {
  $field_name = $variables['field_name'];

  if($field_name === 'bar'){
      foreach ($variables['items'] as &$item) {
        $item['content'] = views_embed_view($item['content']['#markup']);
      }
   }
}


texts:
I have a default install of Drupal 7 with the Tokens module. I'm using [current-page:title] in a node body, but the content isn't being replaced.

I've looked for settings and at the Token module page, and nothing. What am I missing?


texts: How do I use "IGNORE" in a database query?

texts:
I would like to run a query similar to INSERT IGNORE INTO the_table (nid, language) VALUES (8, 'Chinese'), but I cannot find any documentation on how the "IGNORE" statement works with the Drupal DB API.

Does anyone know how to achieve that?

db_merge('the_table')
  ->key(array('nid' => 8, language' => Chinese))
  ->fields(array(
      'nid' => 8,
      'language' => Chinese,
  ))
  ->updateExcept('nid','language')
  ->execute();

Would the code above be the equivalent of my initial query ?

EDIT: updateExcept method doesn't exist, no idea why it s still in the documentation


texts: How to create a custom content type that accepts zip files and puts them in a new directory?

texts:
I want to simplify the workflow for putting an e-magazine on my  D7 site.

I currently have to manually upload a zip file, move it to a custom directory with in sites/default/files/emagazines/NEWCONTENT and then manually add a link to a node or content type to provide a link to the emagazine.

I imagine a custom content type that accepted zip files and then unpacked and placed the files in a directory based on the content types' name field would be a more user friendly solution, and ultimately give me a little bit more versatility. I've never really approached something like in  Drupal before, so I'm not sure where to start, but I imagine it can be done.

So,

Can the Drupal file field accept zip files?
If so, how do customize the field to extract the zip files into a custom directory?

I'm sure there's more to process, but that's where I figured I'd need to start.


texts: Using panels and\or contexts to build simple blog w/ static menu

texts:
My goal is to build a simple blog that has a vertical list containing a library of blog titles and then the "meat" of a selected bog entry on the left.  I want the library list to be static such that it is always there whenever the user selects different blog articles.

This seems to me to be somewhat simple but for the life of me, it's got me stumped.

Any help is appreciated - Thanks.


texts:
I sent an email in a function.

My email body is like "Hello [user:name], blablablala --  Team [site:name]".

But the token aren't replace by their values in the email.

What's wrong ?

Cordially


texts:
I have 2 goals on my website: 'Published 1 article' and 'Published 2 articles'. I have according rules that record the tasks for these goals when new content is published by a user.

Now, assume that a user published exactly 2 articles. That means he/she completed 'Published 2 articles'. How can I undo this goal (programmatically) when one of his/her articles are removed?

PS: I've already found this post, but as there aren't any answers, it wasn't that helpful... :)


texts: indexing first letter of items to make an A-Z type glossary, using solr backed and search api

texts: I am using the search_api and the solr backend. It is possible to index first letter of content so I can use solr to create an A-Z style filter?


texts: Save Inline entity form-Multiple values for product reference field programmatically

texts:
I have product reference field with inline entity form(multiple values) widget in one of my node type.

I need to save commerce product via inline entity form to the node programmatically.

I tried to figure out the code used in inline entity form module. I can't understand those codes. Searched in google, no solution found.

Please tell me if anybody knows the solution.

Thanks in advance.


texts: Display list of users with a specific role to guest users

texts:
Some users on my Drupal 8 site have the role of 'Champion'. I have created a views block that lists out all the users with this role. It shows the list correctly when I am logged in as an admin, but does not display any results to guest users. It appears that the 'View user information' permission, which I have assigned to guest users does not allow viewing of user's roles ( I can see why from a security point of view).

Can anyone suggest how I can get this list of users to display for guest (unauthenticated) users? Either how I could override the permissions, or another approach?


texts: 404 page not found error even though the page exists

texts:
On my Drupal 7 website, I'm getting a 404 page not found error on the front page: http://mydomain.com even though I can view the page just fine. Google Webmaster tools wouldn't validate my site; w3 website validator stops with 404 error.

I looked at my error logs in the database, and noticed that this is coming from node/1 which doesn't exist anymore. I set my home page to a different node, node/133.

This doesn't make sense to me. Either a page exists or it doesn't!


texts:
I have a project to QA all of our open webforms. We have about two screens (using the default pager) of open webforms.

The simple-but-hard way is to copy each link, but I wonder if there is an easier way. Can I programmatically pull up the path for all open webforms? Or is there a module?

I looked at building a view of webforms, but there was only an option to create a view of webform submissions, not of webforms themselves.


texts:
I am using Search API and search views to add facet blocks into my views page. It works perfect on my test site with only search/facet/views related modules.

But on my working site, when I add Search Index, the ItemType is missing "Node" selection, instead, it is showing "Content". I have updated all modules, but can't figure out why "Node" option is missing.

Anyone has ideas on this?


texts:
I am using putObjectFile to move images form local to s3 bucket.
Source image is moving fine. After moving, I am updating its uri, filename in file_managed table.
But I am unable to see its image styles on s3 bucket.
When I opne the node, checkin in firbug, it shows me the path from local server say local.site.com/s3/files/styles/thumbnail/s3/legacy/2015/1429522593_1974262741.jpg while 1429522593_1974262741.jpg is new name on s3.

I am using putObjectFile as

$s3->putObjectFile($tmp, $bucket, $actual_image_name_directory, S3::ACL_PUBLIC_READ)

which is working fine.

I have tried using image_style_create_derivative to create on s3. But it changes nothing.

When I view the node, then look in dblog it shows for example.

Unable to generate an image derivative at s3://styles/thumbnail/s3/legacy/2015/1429522593_1974262741.jpg.


texts: How to create slideshow with views using images from node's field

texts:
I have a field in Page content type. Field's type is Image. It can contain unlimited number of images. I want to use this field for Slideshow (module views_slideshow). I need to create view for showing content of this field sorted by field's delta and showed like Slideshow. I have a problem with sorting, and showing field items as images (I also need to apply images style to my images).

Is it possible?


texts:
In my user entity, I have a term reference. In that vocabulary, I have a regular field. How can I fetch that field's value? I tried the below in  devel/php to no avail.

$user = Drupal\user\Entity\User::load(17);
$dept = $user->field_department->entity;
\dpm($dept->field_administrator_e_mail->value);

My end goal is to send the email to the department's administrator when a user is created.

UPDATE: I also tried the below:

$user = Drupal\user\Entity\User::load(17);
$dept = $user->field_department;
\dpm($dept->name);


texts: How to publish referenced nodes at the same time node is published?

texts:
I have a product content type and a review content type. A user can create a product node and then several users can review it. There is a node reference field in the review content type that links the product type using the node reference url widget.

The user can create and edit the product node but it is not published. However, there are links from the node reference url widget that allows for reviews to be attached that get published immediately. Now I have views on other pages with reviews that link to an unpublished node. This doesn't work.

How do I allow for reviews to be made but are not published if the product is unpublished and published if the product is published? Are there techniques using Rules?


texts: How can I change a rendered user display to a combination of fields linking to the user?

texts:
I have a set of users on the site I'm building that have First and Last name fields in their profile.  How can I create a display that will show the user link as "Last name value, First name value" all inline?

There are a number of places where this is how I want user references to show up.  In some other places, it would be ideal to show those fields, and a couple of others along with the user's image.  Then of course there is the full profile view.  I had though this must be done with different display types, but can not see anyway to bring fields inline with each other, or adjust what text makes up the link.


texts:
I am using Drupal 7 and my search functionality is not working properly.

When I click on search button without enter any keyword it redirects to home page with showing the message Please enter some keywords. and same thing happens when there is no result found for the respective search keyword.

So can anyone please guide me how can I redirect the empty search to search page?

Thanks in advance...


texts:
We're hoping there's already a module that will do this...

We are creating a page that will contain three view blocks. Each view will have a different exposed filter (all based on taxonomies.) The views are completely independent of one another; they're just going to display on the same page.

What we're looking to do is allow a user to set the filters on each view, and then have Drupal remember those filters. This will be available to authenticated users only, and we're hoping that the filter values can be remembered from session to session.

Example: View 1 will have a Retailer filter, so the user can choose to view all content about Target. View 2 will have a Manufacturer filter, so the user can choose content about General Mills. And so on for as many views as we choose to display on the page.

I know we could do this to a certain extent with javascript and cookies, but as I said, we're hoping it's already been done, as we're under a deadline. Does anyone know of a module that does this? I've tried searching drupal.org for user customization and exposed filters, but the results are overwhelming, and not entirely relevant.


texts: Implementation of the Google Identity Toolkit (openid like)

texts:
I´m trying to weite a module that implements the folliwing google api
http://code.google.com/apis/identitytoolkit/index.html

it´s kind of like the openid, uses external accounts from the api to allow users to login without having to register the anoying long register form and pass through all verification

I´m new to D7 and openid conpcepts, what i´ve tested was the openid module that comes with D7 and got very disapointed...

first of all I had to have an openid url then I had to create the user and aprove my validation link from my email in order to get logged in to my drupal

that´s useless... because I went through basicaly the same process

What I want is something similar as this StackExchange experience, I used my gmail account and got logged in, I only had to login to google and that was it...

Any ideeas from where to begin with the implementation ?
I want to be able to sync automaticaly the users that will use the Google Id kit with Drupal, without asking too many questions.. because after all what I´m interested is them be able to leave a trail on my site but do encourage them to register easily...

update:

found on google documentation this page
http://code.google.com/apis/identitytoolkit/v1/drupalsample.html


texts: Strange PDOException Error With Computed Field

texts:
I have a computed field which is calculating values based on an entity reference field. It works fine when calculating an AVG, but I realized today that what I actually would like is for it to find the most popular result in a column. So I altered the code as suggested here. However, now it's throwing me a PDOException error that (I think, I'm not exactly an expert) is related to the WHERE portion of the query. I'm not sure why it would be doing this. The code and error are included below. Any suggestions?

Old, working code:

$entity_field[0]['value'] = "";

$nids = db_query('
    SELECT entity_id
    FROM {field_data_field_review_venue_reference}
    WHERE field_review_venue_reference_target_id = :nid',
    array(':nid' => $entity->nid)
   )->fetchCol();

if (empty($nids)) {
    $entity_field[0]['value'] = "-10";
}

else {
    $entity_field[0]['value'] = db_query('
    SELECT AVG(field_review_payment_value)
    FROM {field_data_field_review_payment}
    WHERE entity_id IN (:nids)',
    array(':nids' => $nids)
   )->fetchField();
}

New, error-throwing code:

$entity_field[0]['value'] = "";

$nids = db_query('
    SELECT entity_id
    FROM {field_data_field_review_venue_reference}
    WHERE field_review_venue_reference_target_id = :nid',
    array(':nid' => $entity->nid)
   )->fetchCol();

if (empty($nids)) {
    $entity_field[0]['value'] = "-10";
}

else {
    $entity_field[0]['value'] = db_query('
    SELECT COUNT(field_review_payment_value) AS `Rows`
    FROM (field_data_field_review_payment)
    GROUP BY (field_review_payment_value)
    ORDER BY `Rows` DESC
    LIMIT 1
    WHERE entity_id IN (:nids)',
    array(':nids' => $nids)
   )->fetchField();
}

Error:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE entity_id IN ('16', '17', '21', '22', '30', '31', '32', '33', '34', '35', ' at line 6: SELECT COUNT(field_review_payment_value) ASRowsFROM (field_data_field_review_payment) GROUP BY (field_review_payment_value) ORDER BYRowsDESC LIMIT 1 WHERE entity_id IN (:nids_0, :nids_1, :nids_2, :nids_3, :nids_4, :nids_5, :nids_6, :nids_7, :nids_8, :nids_9, :nids_10, :nids_11, :nids_12, :nids_13, :nids_14, :nids_15, :nids_16, :nids_17, :nids_18, :nids_19, :nids_20, :nids_21, :nids_22); Array ( [:nids_0] => 16 [:nids_1] => 17 [:nids_2] => 21 [:nids_3] => 22 [:nids_4] => 30 [:nids_5] => 31 [:nids_6] => 32 [:nids_7] => 33 [:nids_8] => 34 [:nids_9] => 35 [:nids_10] => 36 [:nids_11] => 38 [:nids_12] => 40 [:nids_13] => 45 [:nids_14] => 46 [:nids_15] => 47 [:nids_16] => 50 [:nids_17] => 51 [:nids_18] => 52 [:nids_19] => 57 [:nids_20] => 75 [:nids_21] => 79 [:nids_22] => 85 ) in eval() (line 26 of /Applications/MAMP/htdocs/sites/all/modules/computed_field/computed_field.module(466) : eval()'d code).


texts:
I use commerce, search api and facets. I have a "shop" view with indexed products. It works good and I can filter and sort the view using "search api" facets and "search api" sorts fields.
I can sort the view by an indexed field, like product base price which is a field of a product object. The problem is this base price could change due to rules (discounts, offers, etc), and then, the final price for the customer could be different.
I need to sort the "shop" view by the final customer prices, but I don't know how to do it with this indexed view. Any sugestion? TIA


texts: Add a Drupal site wide contact form to the maintenance page

texts:
How do I add the Drupal site wide contact form to the maintenance page?

I'm currently using a custom maintenance-page.tpl.php template page in my theme.


texts: Increase Product Quantity based on attendees added Drupal Commerce

texts:
I am developing a training website using Drupal Commerce. The person can book a single slot every time and can add attendees(used field collection for dynamic rows) to the training slot. How Can I increase the Order total based on the people added in the form in checkout?

For Example, If the slot is 33 dollars per person then if I add two attendees in the checkout, automatically the quantity should increase and should change the order total.

I thought to try with rules, but I didn't get how to get the count of field collection items in the rule and increase the price.

Could anyone please suggest on this?

Thanks in Advance!!!


texts: Insert node title in the message sent by contact form

texts:
I'am looking for a way to insert a node title to mail message sent by contact form in Drupal 8.

A contact form is inserted into my node as a field. It is used on each node to receive mail from users. But I need to specify what node the email was sent with.

I use MYMODULE_mail_alter to format mail message. How can i insert node title to mail subject and body?

Or is it possible to get node title in MYTHEME_form_alter ?


texts:
I am getting lost with the multilanguage Taxonomy management in drupal 7.

The english version of the site is build so that a product is taged with a unique term, that may belong to a parent term. So Product Type > Parent type > Sub type.
The product can be reach at a URL that is build according to their catergory so :
Product Type/Parent type/Sub type/Product-name

All of this is working fine but i now need to add more languages to that site. So here is what i have done so far:

1- Enabled Taxonomy translation Module with all it s dependencies.

2- Activating  "Translate. Different terms will be allowed for each language and they can be translated" for my vocabulary (Product Type)

3- Added translation to each Product type terms

Now i have 2 problems.

First all the translated terms are shown in the Term reference drop down in node creation and translation (as i plan on having 5 languages it s going to be very confusing), and this happens even when i am translating a node (I was expecting the field to be prfield with the corresponding translation from the term of the main node, otherwise what s the point of translating terms ?)

Second the Menu path doesn't display the translated terms, when i switch language i always get : node/nid even though i defined the following pattern for the url

[node:field-product-category:i18n-vocabulary:name]/[node:field-product-category:root:i18n-name]/[node:title]

EDIT:
I tried using "Localize. Terms are common for all languages, but their name and description may be localized." for my vocabulary, which would make more sense as i don't want all translated terms to show in the term reference drop down in node creation and translation. Though now it seems even worst as i after switching to french, the term attached to that node doesn't seem to translate at all even though i have already translated it.

EDIT2 So far i think my best option is to create one vocabulary per language and one content type for each language. Any better idea ?
PS i am not using Views at all

Is there anyway to make all of this work as it was intended ?


texts: Twig templates for nodes in different views

texts:
I have a content type, blog_post, that is displayed by a number of different views.

I'm having a problem that the node template that gets used first after clearing the cache will then be used for all other views.

For example one page displays a view called "Blog Posts". If I load this page after clearing the cache, it correctly uses the template node--view--blog-posts.html.twig.

Another page uses the view "Latest Blog Posts", and this should use the template, node--view--latest-blog-posts.html.twig. However if I load this page without clearing the cache first, it uses the node--view--blog-posts.html.twig template.

If I clear the cache and reload the second page, it will then use the correct template, but if I go back to the first page, it will be using the template for the second!

I have twig debugging enabled, and it shows the wrong view name under "FILE NAME SUGGESTIONS" as follows:

<!-- FILE NAME SUGGESTIONS:
   * node--view--blog-posts--page.html.twig
   x node--view--blog-posts.html.twig
   * node--20--teaser.html.twig
   * node--20.html.twig
   * node--blog-post--teaser.html.twig
   * node--blog-post.html.twig
   * node--teaser.html.twig
   * node.html.twig
-->

I expect that lots of other sites theme nodes in multiple views, so I expect I'm done something wrong. Any suggestions how I can debug this?


texts: How can I defined regions like default admin theme (Seven)?

texts:
For example, visit admin/structure/block/manage/search/form/configure
config search block, in "Region settings", can see Seven (administration theme) "Dashboard(sidebar)" selected, but I find Seven Theme's file, there is no region defined as "Dashboard(sidebar)".

So how can I do the same thing as Seven Theme?


texts: Why is the apostrophe converted to ' in account activation e-mail?

texts:
In admin/config/people/accounts, the body of Welcome e-mail is (my site in in French):

user:display-name],

Un administrateur sur [site:name] a créé un compte pour vous. Vous pouvez maintenant vous connecter en utilisant le lien ci-dessous ou en le copiant dans votre navigateur :

[user:one-time-login-url]

Ce lien ne peut être utilisé qu'une seule fois pour vous connecter et vous redirigera vers la page où vous pourrez choisir votre mot de passe.

Après avoir choisi votre mot de passe, vous pourrez vous connecter sur [site:login-url] en utilisant :

nom d'utilisateur : [user:name]
mot de passe : Votre mot de passe

--  L'équipe de [site:name]

And in the e-mail received by the recipent, every apostrophe is changed to &#039;  like in the signature:

--  L&#039;équipe de Le Jardin de Poissy

My version of Drupal is 8.7.8 and I use these modules: Mail System and Swift Mailer.

How can I let Drupal send properly formatted mails including apostrophes?


texts: CSS is not loading when create a new template node from newly created content type

texts:
The issue me having is that i cant able to successfully create a new page from newly create Content Type (if i use existing content types for create node template its working properly).
i have tried to build simple content types that missing CSS styles/ formatting. (reference image attached)


texts: Contextual filter that checks front page URL for taxonomy term

texts:
My site is laid out in the following way using the Sites Module:

mysite.com/one
mysite.com/two
mysite.com/three

(And so on)

Additionally, there are subpages created with Context for each of these "Sites" such as:

mysite.com/one/content
mysite.com/two/content
mysite.com/three/content

etc.

I share a single view (generated as a block) on these pages that displays content from a content type based on the taxonomy term found in the URL using Contextual Filters in the view. The taxonomy terms assigned to the content, in this case, are "one" "two" "three" etc.

The view block works as intended on the page with a contextual filter of "filter not avail default -> raw url -> path component 1 -> use path alias and filter is avail -> specify criteria -> validator taxonomy term -> term name converted to id -> transform dashes" IF the taxonomy term appears in the URL after the main "sites" page in the path (in this case /one).

This means the view block at mysite.com/one does not work, but mysite.com/one/one does.

Also, mysite.com/one/one/content filters correctly, as does mysite.com/one/one/one/content etc.

I need the contextual filter to consider the "site" name (as determined by Sites or just by the URL that the user enters) in the URL when determining the taxonomy term to filter by.


texts:
I am using Views PDF to export some of my pages as PDF files. So far I can get it to export the files .
I am however getting challenges in trying to adjust the styling. I have looked at the module for any tpl files and they are not there. Anybody with a headstart on this?


texts:
I am running a Zen subtheme for another drupal instance and it all worked fine. However, when I copied the folders across to my new Drupal instance, all I see is

The name of the site and

User menu :

My account
Log out

There is no Add content link... or the administration menu along the top... also no styles are applied... I am pretty sure I changed all the site specific instances in the code (.info file etc)... What am I doing wrong?

Ok, so I can navigate through the admin menu by changing the url path... admin/appearance

I have cleared the cache, but the styles for the zen sub theme are still not being picked up and I cannot see the Add Content link on the front page.

I've tried changing the theme to Bartik, and it looks fine. The styles are being picked up and everything.

So why is it not working for the Zen subtheme?

In the logs, I am seeing this message:

  Notice: Undefined property: stdClass::$prefix in system_theme_settings() (line 547 of /home/mysite/public_html/modules/system/system.admin.inc).

Does this explain the wsod problem?


texts: RSS feed not updating using feeds module

texts:
I have an RSS feed that has not been updated after the initial import. I actually managed to get it to update once using cron, but even that has since stopped working. Looking at the original feed, I see it is being updated, but I'm not getting the updates on my site.

My feed importer settings are as follows:

It is attached to a specific content type
The minimum refresh period is 15 minutes
The option "Import on submission" is checked
The fetcher is "HTTP"
The parser is set to "common syndication parser"
The processor is "node processor"
I respecify the content type in node processor settings
The input format is the default one
"Expire nodes" is set to "never"
"Update existing nodes" is set to "Update existing nodes (slower than replacing them)"

Is there anything else I need to do, maybe configure something in Job Scheduler? I couldn't find a UI for it.

EDIT: Upon checking admin/reports/dblog as per Jeremy's suggestion I found the following error:

  Download of failed with code -1003.

Does anyone know what this means or how I can fix it?


texts: What arguments can I use when defining a service?

texts:
Looking at system.services.yaml, I noticed that some of the services arguments are strings starting with @. They seem to contain a reference to another defined service.

system.manager:
class: Drupal\system\SystemManager
arguments: ['@module_handler', '@database', '@entity.manager']

Are those @-arguments only references to other services? Are there any other type of arguments I can use when defining a new service?


texts:
I am setting up a personal site in Drupal, and at the Login page it will have "Enter your Josh Mustillo username." Is it possible to change the "Josh Mustillo" to something else like "Enter your Username"?

(Domain is www.joshmustillo.com),


texts: Is there any way to add the social medial buttons in a field?

texts:
I have made the field using field collection which is collection of 7 fields and the 8th field I would like to add as strip of social media buttons (like easy social module).

So when the entire content is displayed, below each set of field collections the social media button appears.

I searched and found that all social modules can be attached to content type which adds at the top of content or bottom. But is there a way where it can be added in-between the text or using CKeditor, the above issue can be solved?


texts: Perform bulk operations on a custom database table

texts:
I have a custom database table. I implemented hook_views_data() to make it available with views.
/**
 * Implements hook_views_data().
 */
function uploader_views_data() {
  $data = array(
  'texts' => array(
        'table' => array(),
      ),
  );

  $data['texts']['table'] = array(
    'group' => t('Uploaded Texts'),
    'handler' => 'views_join',
  );

  $data['texts']['table']['base'] = array(
    'field' => 'txt_id',
    'title' => t('Texts'),
    'help' => t("Text ცხრილში ინახება ინფორმაცია ტექსტების შესახებ. მაგ: ავტორი, სათაური და ა.შ"),
    'weight' => -10,
  );

  $data['texts']['txt_id'] = array(
    'title' => t('txt id'),
    'help' => t('ცხრილის უნიკალური ID-ი.'), // The help that appears on the UI,
    // Information for displaying the nid
    'field' => array(
      'handler' => 'views_handler_field_node',
      'click sortable' => TRUE,
    ),
    // Information for accepting a nid as an argument
    'argument' => array(
      'handler' => 'views_handler_argument_node_nid',
      'name field' => 'title', // the field to display in the summary.
      'numeric' => TRUE,
      'validate type' => 'nid',
    ),
    // Information for accepting a nid as a filter
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    // Information for sorting on a nid.
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  $data['texts']['teqstis_saxelcodeba'] = array(
    'title' => t('ტექსტის სახელწოდება'),
    'help' => t('ნაბეჭდი ტექსტის სახელწოდება.'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE, // This is use by the table display plugin.
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );

  $data['texts']['xelnaceris_saxelcodeba'] = array(
    'title' => t('ხელნაწერის სახელწოდება'),
    'help' => t('ხელნაწერის სახელწოდება.'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE, // This is use by the table display plugin.
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );

  $data['texts']['type'] = array(
    'title' => t('Type'),
    'help' => t('ტექსტის ტიპი.'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE, // This is use by the table display plugin.
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );

  return $data;
}

I want to create a custom bulk operation on this table.
function uploader_action_info() {
  return array(
    'uploader_myaction' => array(
      'type' => 'entity',
      'label' => t('Do my action'),
      'configurable' => FALSE,
      'pass rows' => TRUE, //this will ensure that the entire views row is passed as part of the context in your action callback.
    ),
  );
}

The action callback is the following one.
function uploader_myaction($cmt, $context = array()) {
   drupal_set_message(t('uploader_myaction was called'));
}

When I try to add a field in the view fields, there is no Bulk operations: Content option.


texts: Prevent certain user roles from showing up in results

texts:
I have a special role (role A) that I have to have set with view user profiles permission. I then have another role (role B) as well as the administrator role that I don't want for that roles users to show up in a views exposed filter and/or for the users with role A to be able to view their profiles. Is there:

a. a way to stop users from certain roles showing up in the exposed filters.

b. a generic way (or module) that stops certain roles being able to view other certain roles.

UPDATE:

I solved b with this module which works well:

http://drupal.org/project/view_profiles_perms

So just need to come up with a way of preventing certain roles from showing in a views exposed filter


texts: drupal 7 xml sitemap showing nodes that are unpublished

texts: we have xml_sitemap 7.x-2.0-rc1 and drupal 7.23 core and it is putting unpublished nodes in the xml site map. What can we do?


texts:
I'm trying to set a value before the form is submitted. The field is calculated by two other fields. One of them is a property of an entity reference. This is what I do:

function nodeoverlay_node_submit($node, $form, &$form_state) {
    if($node->type == 'zoekertje')
    {
        $korting = $form['field_field_korting']['und'][0]['value']['#value'];
        $node = field_get_items('node', $node, 'field_product_zoekertje');
        $node = node_load($node[0]['target_id']);
        $aankooprijs = $node->field_aankoopprijs['und'][0]['safe_value'];
        $price = floatval($aankooprijs - (($aankooprijs/100)*$korting));

        $form['field_verkoopprijs']['und'][0]['value']['#value'] = $price;
        $form['field_verkoopprijs']['und'][0]['value']['#default_value'] = $price;

        $form_state['field']['field_verkoopprijs']['und']['instance']['default_value'] = $price;
        $form_state['values']['field_verkoopprijs']['und'][0]['value'] = $price;
    }
}

I've tried different things to set my value of the field field_verkoopprijs but the result is always empty (and yes, my $price variable contains a float variable).

What can I do?


texts:
I understand using Views you can use a different view mode, e.g. teaser or full content.

Is it possible to view a node using a view mode other than the full content view mode?
What I want to achieve is being able to display different fields depending on the user's role.


texts: \Drupal::database() ->insert - Error: Call to undefined method Using ->condition()?

texts:
I am trying to insert a new row based on conditions. The ->condition() in $database->update() works fine, in $database->insert() they do not.

$database = \Drupal::database();

// Query our DB.
$queryDB = $database
  ->select('table_name', 'value3')
  ->fields('value3')
  ->condition('value1', $value1, "=")
  ->condition('value2', $value2, "=")
  ->execute()->fetchAll();

if (isset($queryDB[0])) {
  // Check if table row exists and overwrite.
  if ($queryDB[0]->value1 == $value1 && $queryDB[0]->value2 == $value2) {
    $database
      ->update('table_name')
      ->fields([
        'value3' => $value3,
      ])
      ->condition('value1', $value1, '=')
      ->condition('value2', $value2, '=')
      ->execute();
  }
}
// Create table row.
else {
  $database
    ->insert('table_name')
    ->fields([
      'value1' => $value1,
      'value2' => $value2,
      'value3' => $value3,
    ])
    // Without these conditions, I get a duplicate entry integrity restraint as value1 and/or value2 may already exist.
    // With them I get Error: Call to undefined method Drupal\Core\Database\Driver\mysql\Insert::condition().
    ->condition('value1', $value1, '!=')
    ->condition('value2', $value2, '!=')
    ->execute();
}

Very similar questions:
1. EntityQuery condition "is not equal to..."
2. How do I add a condition to a query?

But I am having no luck. Is it different with an insert?

What I want is that if value1 AND value2 don't both match, create an entirely new table row with all three values.


texts: How can I print a views exposed form into a custom block?

texts:
I have a page view with exposed filters and would like to print said filters into a custom block in order to add extra html markup above the actual form.  This block will be used on other pages using Context.

I know I can create a block by setting 'exposed filters in block' to yes, however that's not the solution I am looking for.


texts:
I'm transferring SQL statements from a Drupal 5 installation to Drupal 8, and struggling with And/Or condtions. eg given the original SQL:

    SELECT .....
    WHERE .....
          AND classes.description = "Photographer"
          AND (classoptions.description = "Name of photographer here"
           OR classoptions.description = "Not assigned").

I've translated it to:

$query = $this->dbConnection->select('classes');
....etc....
$query->condition('classes.description', 'Photographer');

So far, so good. Then I need an OR condition for

$query->condition('classoptions.description', 'Name of photographer here');
$query->condition('classoptions.description', 'Not assigned');

Looking at documentation on-line, using db_or() is suggested, as in :

$query->condition(db_or()
 ->condition('classoptions.description', 'Name of photographer here');
 ->condition('classoptions.description', 'Not assigned'));

..but this is a) deprecated, b) gives error 'db_or function not found'
The replacement for db_or() is to obtain a new Condition object, but what am I supposed to do with it?  The function

 $query->orConditionGroup();

Will return a new Condition object, and the code

$query->condition(orConditionGroup()
 ->condition('classoptions.description', 'Name of photographer here');
 ->condition('classoptions.description', 'Not assigned'));

Formats a Condition object with the conditions to be ORed just fine.But again, how do I incorporate this into the query?


texts:
when using Views Format:Unformatted List and Show:Fields I get lots of Style Classes referenced by default (e.g. "views-row-odd") within the resulting html-code.

1) Until now I couldn't find a corresponding css-file that defines formats for all the classes in the generated code. Am I missing something ?

2) As test, I tried to include a self-written css-file to the folder "modules\contrib\views\css" and referenced it in the views.info file (stylesheets[all][]=...). Unfortunately this doesn't seem to work, since the generated html code is missing <<@import url("hxx://adr/drupal/modules/contrib/views/css/my_style.css..:>>. What am I doing wrong ?

Thanks for your support,

Martin
PS: Using Bartik as theme ...


texts:
I have few pages and need to add custom color and background image to every page and need to edit it from admin.

The best solution for me is adding custom variables in view or menu item. And then use it in page.tpl.php.

Is there any way to do it without a module?


texts: Why is file_create_url() returning inconsistent values?

texts:
I'm experiencing an inconsistent behaviour in Drupal 7 on the function file_create_url(). I have one field collection with 4 fields in it. On the first field the function provides the correct file url. For the other 3 fields it displays only first part of url. How can I get rid of this?

Here is my code:

<video controls="controls"  autoplay="autoplay" poster="<?php print file_create_url($content["field_poster"][0]["#item"]["uri"]); ?>" style="width:100%"   >
  <source src="<?php print file_create_url($content["field_mp4"][0]["#item"]["uri"]); ?>" type="video/mp4" />
  <source src="<?php print file_create_url($content["field_webm"][0]["#item"]["uri"]); ?>" type="video/webm" />
  <source src="<?php print file_create_url($content["field_ogg_theora"][0]["#item"]["uri"]); ?>" type="video/ogg" />
</video>

And here is the result: field_poster is fine but the others fail;

<?php print_r($content["field_poster"][0]); print_r($content["field_mp4"][0]); ?>

leads to...

            Array
(
[#theme] => image_formatter
[#item] => Array
    (
        [fid] => 288
        [uid] => 1
        [filename] => Transgourmet_Waldputen_MASTER.jpg
        [uri] => public://Transgourmet_Waldputen_MASTER.jpg
        [filemime] => image/jpeg
        [filesize] => 65241
        [status] => 1
        [timestamp] => 1440456242
        [type] => image
        [rdf_mapping] => Array
            (
            )

        [image_dimensions] => Array
            (
                [width] => 1008
                [height] => 573
            )

        [alt] =>
        [title] =>
        [width] => 1008
        [height] => 573
    )

[#image_style] =>
[#path] =>
)
Array
(
[#theme] => file_link
[#file] => stdClass Object
    (
        [fid] => 289
        [uid] => 1
        [filename] => Transgourmet_Waldputen_MASTER.m4v
        [uri] => public://Transgourmet_Waldputen_MASTER.m4v
        [filemime] => video/x-m4v
        [filesize] => 34256348
        [status] => 1
        [timestamp] => 1440457177
        [type] => video
        [rdf_mapping] => Array
            (
            )

        [display] => 1
        [description] =>
    )

)

Is it possible that is has to do with the mime-types?

Thanks in advance.


texts: How to get rid of Re geocode and delete radio boxes on Location module?

texts:
How can I remove the ReGeocode and Delete checkboxes from the Location module? I don't need these functions and there is no settings to delete them.

Where is the PHP or html file located so I can manually delete the lines of code? I searched for it but can't find it anywhere.

<label for="edit-locations-0-re-geocode-location">Re geocode </label>

<label for="edit-locations-0-delete-location">Delete </label>

I think these are the lines I need to delete?


texts: How to fire multiple Rules Actions in a single rule?

texts:
I have a real estate website using the drealty module. In the real estate RETS feed, there is a numeric field called "Area". That numeric value refers to a specific area... for example, "22" might be "Miami Beach", and "32" might be "Miami Beach" and "South Beach".

When new real estate listings are created (via a command line in drush), I need for the corresponding "verbose" name of the area(s) to be selected from a specific taxonomy. For example, if the RETS feed returns "22" for the area value, then "Miami Beach" should be checked in that taxonomy field on the listings entities. Likewise, if the RETS feed returns "48", then both "Miami Beach" and "South Beach" should be checked.

I created a Rules Component for each area numerical value. The Miami Beach Rules Component is below:

 { "rules_set_area_miami_miami_beach" : {
 "LABEL" : "Set Area - Miami - Miami Beach",
 "PLUGIN" : "rule",
 "OWNER" : "rules",
 "REQUIRES" : [ "rules" ],
 "USES VARIABLES" : { "drealtylisting" : { "label" : "drealtylisting", "type" : "drealty_listing" } },
 "IF" : [
   { "entity_has_field" : { "entity" : [ "drealtylisting" ], "field" : "field_area" } },
   { "entity_has_field" : { "entity" : [ "drealtylisting" ], "field" : "field_area_taxonomy_" } },
   { "data_is" : {
       "data" : [ "drealtylisting:field-area" ],
       "op" : "IN",
       "value" : { "value" : [ "22", "32" ] }
     }
   }
 ],
 "DO" : [
   { "data_set" : {
       "data" : [ "drealtylisting:field-area-taxonomy-" ],
       "value" : { "value" : { "35" : "35" } }
     }
   }
  ]
 }
}

The same type of Rules Component exists for South Beach:

  { "rules_set_area_miami_south_beach" : {
  "LABEL" : "Set Area - Miami - South Beach",
  "PLUGIN" : "rule",
  "OWNER" : "rules",
  "REQUIRES" : [ "rules" ],
  "USES VARIABLES" : { "drealtylisting" : { "label" : "drealtylisting", "type" : "drealty_listing" } },
  "IF" : [
    { "entity_has_field" : { "entity" : [ "drealtylisting" ], "field" : "field_area" } },
    { "entity_has_field" : { "entity" : [ "drealtylisting" ], "field" : "field_area_taxonomy_" } },
    { "data_is" : {
        "data" : [ "drealtylisting:field-area" ],
        "op" : "IN",
        "value" : { "value" : [ "32" ] }
      }
    }
  ],
  "DO" : [
    { "data_set" : {
        "data" : [ "drealtylisting:field-area-taxonomy-" ],
        "value" : { "value" : { "23" : "23" } }
      }
    }
  ]
 }
}

I then created a Rule with Event "After saving a new drealty listing" and Actions: "rule: Set Area - Miami - Miami Beach" and "rule: Set Area - Miami - South Beach".

    { "rules_set_area_on_drealty_listing_cloned_" : {
    "LABEL" : "Set Area on Drealty Listing (cloned)",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "drealty" ],
    "ON" : { "drealty_listing_insert" : [] },
    "DO" : [
      { "component_rules_set_area_miami_miami_beach" : { "drealtylisting" : [ "drealty-listing" ] } },
      { "component_rules_set_area_miami_south_beach" : { "drealtylisting" : [ "drealty-listing" ] } }
    ]
  }
}

When I run a RETS import and the website creates the new listings, I expected it to evaluate each of those Rule actions in succession and check the taxonomy boxes when necessary, but instead it appears that only the South Beach Rule Action is taking effect, and thus only South Beach is checked in that field. Is this because it is listed last in the Rule action list? Is there a better way for me to set this up so that I can get the desired end result?


texts:
Here's the deal. I want to create a modal popup when an add to cart event is triggered.

I've got the event working just fine but can't seem to get the ajax to work properly. What I'm working off of was using the magnific popup library and was creating the popup using \Drupal::messenger()->addMessage($content, NULL); where content was a render array and the theme has

{{ attach_library('commerce_add_to_cart_confirmation/confirmation_overlay_css') }}
{{ attach_library('commerce_add_to_cart_confirmation/magnific_modal') }}

right at the top.

I thought this was very weird and funky. After some searching I found that you could create an ajax response like :

  $content = "Something to show in the modal";
  $title = "Hi, I'm a Modal";
  $response = new AjaxResponse();
  $response->addCommand(new OpenModalDialogCommand($title, $content, ['width' => '700']));
  return $response;

So I started doing this instead but it wouldn't work. I was told that nothing was handling that return since this function was just called because of an event. That made sense.

I then found this which seemed to be doing nearly the same as me.
I modified my code to use the same method.
No dialog box. :( I used xdebug and saw that there was no ajax response coming from the kernel::response and thus my function kept returning no response.

I then thought that it could be that ajax isn't loaded. I used the chrome network dev tool and found no ajax.dialog there. I tried adding this to my .module file :

function commerce_add_to_cart_confirmation_page_attachments(array &$attachments) {
  $attachments['#attached']['library'][] = 'core/drupal.dialog.ajax';
}

Then I saw ajax.dialog in the network but still no popup on my site.
The module linked above uses a hook to some commerce form (I can't tell which because the name is so cluttered) and wonder if that makes a difference.

How can I create a modal popup from a CartEvents::CART_ENTITY_ADD event subscriber? Am I missing something to do with the libraries or something wrong with my php?


texts: How to set page variable from custom module

texts:
In Drupal 8:

I have custom module code that declares its own theme can twig template.  How do I make module variables available to my Drupal theme's page.html.twig?

I have tried various preprocess_page* functions; however, those functions don't see the variables the module is passing to it's own themed twig templates.

Can the module's controller inject something into the page variables?

Can a Drupal theme's preprocess functions access some variables flowing from a custom module to the module's twig templates?

The controller file:

class PromtController extends ControllerBase
{
    public function program($id)
    {
        $program = PromtService::program((int)$id);

        return [
            '#theme'   => 'promt_program',
            '#program' => $program,
            '#title'   => $program['title']
        ];
    }
}

The module code:

function promt_theme()
{
    return [
        'promt_program' => [
            'template' => 'promt_program',
            'variables' => [
                'program' => null
            ]
        ]
    ];
}


texts: How to hide my hook_menu items from the navigation menu?

texts:
I've got a custom module which I use to define some urls that are used for a json api. I don't want them to show up in the Navigation menu. How do I change my hook_menu configuration so these urls are excluded from the menu?

Here is an example of two of my menu items that I want to hide, and a third one I would like to be visible:

$items['mymodule/1/login'] = array(
    'page callback' => 'mymodule_login',
    'access callback' => TRUE,
);
$items['mymodule/1/signup'] = array(
    'page callback' => 'mymodule_signup',
    'access callback' => TRUE,
);
$items['mymodule_bulkupload'] = array(
    'title' => 'Bulk Upload',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('mymoduleapi_form_bulkupload'),
    'access callback' => 'mymoduleapi_user_is_mymodule_owner',
);

I end up getting a bunch of empty items in my Nav menu. I would like to be able to hide those api menu items.

How do I control that from within hook_menu?


texts: Drupal Remove jQuery, and jQuery UI and add migrate plugin with Updated jQuery and UI

texts:
I am trying to use drupal_add_html_head to add script elements to the head tag, however, this is important that these script tags are not self-closing because that is not the correct way to add them.

How do I do this:

$html5jquerymigrate = array(
    '#tag' => 'script',
    '#attributes' => array(
        'src' => libraries_get_path('jquery.migrate', true) . '/jquery-migrate-1.2.1.min.js',
    ),
    '#prefix' => '',
    '#suffix' => '',
);

drupal_add_html_head($html5jquerymigrate, 'html5jquerymigrate');

But instead of getting it printed out like this:  <script src="/sites/all/libraries/jquery.migrate/jquery-migrate-1.2.1.min.js" />

How do I have it print out in the head like the following instead?

<script src="/sites/all/libraries/jquery.migrate/jquery-migrate-1.2.1.min.js"></script>


texts: How to get the parameters in hook_menu function correct?

texts:
I'm developing my first custom module and I need some help with it.

When a user is clicking on the following

Export to Word

then the user should recieve a word document from his node.

I used the hooks_menu. I do not know why. So based on examples it is like this:

function foo_menu() {
  $items = array();
  $items['exportoword/%'] = array(
    'title' => 'Export to Word',
    'type' => MENU_CALLBACK,
    'page callback' => 'convert_to_word',
    'access arguments' => array('access content'),
  );
  return $items;
}

And the of course the function itself.

function convert_to_word ($args = 'all') {

// HOW TO GET THESE argument here?
// NodeId           567
// Pathtoxml        /xmlcv
// Pathtotemplate   internal.xsl
// FileToSave       filename.docx

// Get the NodeID XML from /xmlcv/576
$xml = new DOMDocument;
$xml-> file_get_contents( $pathtoxml & '/' &$nodeid );

// Load XSL file from the template location
$xsl = new DOMDocument;
$xsl->load($pathtotemplate);

// Configure the transformer
$proc = new XSLTProcessor;

// Attach the xsl rules
$proc->importStyleSheet($xsl);

// Process it
$proc->transformToXML($xml);

// Document is now in XHTMl. Somehow convert to .docx

// No clue yet...
// shell converting or just rename the file and push back to customer?
//  $output = shell_exec('pandoc -s -S README -o example29.docx');
// Save it to a file on the server or do I return the file?

 file_put_contents($FileToSave, $proc);

return 'success

How to get the arguments as parameters in the convert_to_word function?


texts: How to create a megamenu where not all the text is links, and where layout is more varied than just N columns throughout

texts:
I want to create a mega-menu with the same kind of layout as the table below, where the plant names are links but the classificatory headings are not:

   Ferns
Bracken

   Conifers
Fir Yew Pine
Cypress Cedar

   Dicotelydons  -  (edible)
Turnip  Beetroot  Grape  Okra

   Dicotelydons  -  (not edible)
Duckweed    Yarrow    Sundew
Oxlip            Elm

Although there are mega-menu modules that display multi-column tables, the output I want differs from what I think they can produce. First, my menu may need different numbers of columns in different sections. As far as I can see, existing mega-menu modules can't do that, because they just take a list of links (either from a Drupal menu, or from a sequence of HTML <LI> elements) and divide it into a fixed number of columns.

Second, my menu may need classificatory headings which are not links and which are not aligned with the links under them. As far as I can see, existing mega-menu modules can't do that either, because they take the non-links from the same list as the links.

I was therefore wondering whether there are any modules that allow the user to input an arbitrary chunk of HTML, and then mark certain pieces of text as menu links, for example by surrounding them by brackets analogous to HTML <A>...</A> tags, or by using a WYSIWYG link-insertion tool. In my example, I'd want to do that to all the plant names.

Before asking this question, I examined Giga Menu, Maximenu, Mega Dropdown, Mega Menu, Menu Minipanels, Menu Views, Mucho Menu, OM Maximenu, Superfish, and TB Mega Menu. I don't think any of these do what I want.

From the above, I discarded Gigamenu because it doesn't have a documentation page, and its Drupal-7 download is dev only. Maximenu and OM Maximenu also have no documentation; and one is an update of the other, but it's not clear which the author now intends us to use. Mega Dropdown is an experimental "sandbox" project.

Menu Views doesn't have documentation, apart from some blog postings about it, but it seems to be intended to replace links by views, which isn't what I need.

Mega Menu, TB Mega Menu, Menu Minpanels, and Superfish turn Drupal menus into mega-menus. That doesn't give me the control over layout that I want — at least I don't think it does.

Mucho Menu might do what I want, but has no documentation apart from a video, which I can't hear where I am. Also, I'm not sure that it's maintained any more.


texts: How to call a function of one module in another module

texts:
How can I call a function of one module in another module? I want to call uc_stock_adjust() function of uc_stock.module in my own custom module. Is it possible?

Here is my code so far:

function my_module_node_presave($node){
  if($node->type == 'add_stock') {
    $stock_value = $node->field_stock_value['und'][0]['value'];
    $sku = $node->field_sku['und'][0]['value'];
    if (module_exists('uc_stock') && function_exists('uc_stock_adjust')) {
      uc_stock_adjust($sku, $stock_value);
    }
  }
}

I want to add and delete stock of products by using reference uc_stock_adjust(), which is defined in uc_stock.module, in my custom module. But when I try the above code, it doesn't work.

It giving an error, and the error is:

  Notice: Undefined variable: sku in my_module_node_presave() (line 29 of \sites\all\modules\my_module\my_module.module)


texts:
According to the current documentation I don't think this is possible, or is it?
(drush sql-dump --routines doesn't work or anything like that)

Aaaannndd... let's say it's not possible, and I want to add this feature to drush sql-dump command, how can I do that? Where should I start?


texts:
I am trying to change the output in my view; the problem is that I cannot access the [URL] token to rewrite to this is my link.

It seems I can only access the [title] token. Do you have any idea?


texts: How do I programatically change default values in a contact form?

texts:
I have a Drupal 8 contact form where the form's placeholder values are the default values of the fields. Unfortunately, this site is multilingual and I don't think it's possible to translate default field values.

Is there a way I can set the fields' default values equal to the (translatable) field labels in either a module or preprocess function?


texts: How to change stylesheet ordering of base and child theme?

texts:
I have downloaded Drupal Commerce and started playing around with it. I have a new theme created using Commerce Kickstart as base. My theme is in sites/all/themes. Any styles that I put in the stylesheets of my new theme are being overridden by the base drupal commerce stylesheet.

How can I make sure my styles get applied on top of the default?


texts: Design help for serialized classes that need database access

texts:
I want to convert from \Drupal::database() to dependency injection.

I'm not 100% certain how to move forward with a refactor I know I have to complete.  Currently I have a series of custom classes that implements a Callback interface of mine. They do whatever the respective callback requires.  These callbacks are stored serialized in some QueueManager (database, rabbitmq, etc).

At some point in the future the QueueManager will grab a callback from the queue, inflate it and issue the interface contract for the Callback to do its work.  The catch is the callback needs access to the database.

Now I currently have them built in such a way that they use the \Drupal::database() method to access the database (because they get serialized), but I want to use the more acceptable and better approach of dependency injection.  I'm not 100% certain how to go about doing this; because I cannot serialize a database connection.

I know that the QueueManager class will most likely become a Drupal service, but I don't know how to handle the database dependency on the serialized callbacks.


texts: Synchronize commerce stock for product variations

texts:
I am selling tickets to a class at multiple price points (think student, adult, senior), and each class has limited seats. I have the product display working great using product reference with inline entity form - Multiple values. I can successfully checkout with each product variant.

I have run into a snag using Commerce Stock as the stock is per product, which in my case is each variant of the class. So say I have 30 seats, I need to be able to sell 30 of any product variant, but no more than 30 of all product variants total (per class, which is a single product display).

Is there a way for the stock to be per product display, not per product? If not, is there something I can invoke using Rules to subtract from all product variants stock when one is purchased?

Ultimately, I am looking for a way to synchronize all product variant's stock in a single product display.


texts:
I know a lot has been written on this issue already but I found no clear answer.

Here it is:

With the Voting API and another module such as Fivestars or Rate, how do you rank the results within results?

Let me give an example: With views, I can have a proper display of all the nodes that have received, say, 5 stars followed by all those that received 4 stars and so on. So the nodes are grouped properly.

But to rank the nodes within each group (i.e.: The 5 star node that have received the most number of votes being displayed first followed by the 5 star node that come in second position, etc. How does one set that in views?

At the present, I have no sorting within each star group so a node that has received one 5 star vote comes before one that has received three 5 stars, followed by one with that received two (1-3-2.)

My setting are:

Relationships: Content: Vote results -- Value type: No filtering -- Aggregation function: Average vote.
Sort criteria: Vote results: Value (desc.)

It looks like I need an additional sorting mechanism but i can't find it.

Any one has an answer for this? I am not a programmer but a site builder. :)

Thank you. :)


texts: Facet API and Entity Reference Autocomplete

texts:
I have two content types, with Drupal 7 :

City
Job Offer, with an Entity Reference CCK field named "City" that accept Node Entities of Type City.

I am also using the apachesolr module, with Facet API, and I would like my users to be able to filter the offers by city. However, as I have thousands of cities in the database, the "Links" widget is unusable.

How could I easily integrate the Entity Reference module's autocomplete widget (or  https://drupal.org/project/entityreference_autocomplete, or any other one...) with the Facet API ?


texts:
I need to create an custom event for an action to be triggered in the Rules module.

Custom event is after completing the checkout process the page will be redirected to confirmation page. I need to trigger an action if the page is redirected to the confirmation page.

I need to check if the user has on the confirmation page like /payment-confirmation then i need to trigger an action.


texts: Can I stop D6's email sending to blocked users?

texts:
I have a few actions. They send email to authors.
The problem is, I don't want emails to be sent if the user is blocked.

Any suggestion is appreciated.

ps: I couldn't create a tag on drupal.stackexchange.com . So tagging this custom-module for posting sake.


texts: How do I import products using commerce_feeds and commerce_autosku?

texts:
how do I import a CSV of products into a Kickstart site using commerce_feeds, with commerce_autosku enabled to generate the SKUs on import?

This sounds like it should be possible because an obvious use case is the one where you don't care about SKU and you have a CSV with Title, Price and Description of each product.  But I keep getting an error similar to:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'commerce_product-52' for key 'PRIMARY'


texts: placing a menu block inside a views template

texts:
I need to place a menu block (the main-menu) inside a views template file - the template for the rows design.

I tried

$block = module_invoke('system','main_menu');
print render($block['content']);

and

$block = module_invoke('menu','main_menu');
print render($block['content']);

but nothing works.

Can anyone please give me a little help?


texts: Get all available permission after NodeType delete - Drupal 8

texts:
I know that to get all available permissions you can do

var_dump(array_keys(\Drupal::service('user.permissions')->getPermissions()));

which give you a list of all permissions' name.

I also know that when you create a NodeType, it refresh this list.

So what I want to do here, is to fill a table of my database with a list of all available permissions, that update when permission is add or removed.

When I create a NodeType :

function inside_entity_insert(\Drupal\Core\Entity\EntityInterface $entity) : void
{
    if (get_class($entity) === 'Drupal\node\Entity\NodeType') {
        $permissions = array_keys(\Drupal::service('user.permissions')->getPermissions());

        foreach ($permissions as $permission) {
        // somestuff -> updating database permission table
        }
     }
}

So that means when NodeType is created the Drupal permissions list is updated and I must update my database too.

What I want to do here is the same thing but when a NodeType is deleted.

I tried :

hook_entity_delete
hook_entity_predelete

But in both hook the user.permission list didn't change, I still get the same permissions, and what I though is that the permissions of my actual nodetype dissapeared, because of the deletion.

I do not know where to look..

Is getting the name of the nodeType and delete matchings rules' name of the database, a good alternative ?

I also wanted where can I initialize these database, because actually it's created & updated only when someone create a NodeType. But that's not urgent at the moment.

Thanks to all


texts: How can I access the node ID when writing PHP into a block?

texts:
I see that when I am creating a block through the drupal admin I can use PHP, in addition to plain text & html.  Is there a variable in scope that I can use to access the node id?

<?php echo my_custom_function( $node_id, $my_desired_class); ?>


texts: Drupal Commons update is having troubles using drush

texts:
I have Drupal Commons distribution's based website,everything was good untill I updated the site with drush.

The problem is drush downloaded the file to sites/all/modules instead of profile folder. Now I am getting bunch of redeclare function error.

When I remove everything from sites/all/modules I get can't find function xxx. How will I get back the site to normal.


texts: How can I print article author profile picture?

texts:
I have a blog where basic author information needs to be printed out.

Basically, I want to print author name and profile picture in my article teaser template.

I tried googling but none of the answers seemed to help.

Can I somehow access Author object?


texts:
I have a requirement to return a list of content types accessible to a user in JSON format using services module.

I have followed this approach:

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

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

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

EDIT:

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

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

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


texts: Renaming the label of the Title textfield

texts: Adding new fields allows you to specify the label of the field but the Title field does not. In fact, it just sits there on top acting all high and mighty. I just want to change the label of Title to something like Your name but retain the machine name. Does anyone have an idea how to do it?


texts: How should I name  the node template files for my theme?

texts:
I'm a bit confused about how to name my template files. It's the first time I started to mess with templates in drupal 7 and somehow I don't get it.

I want a template file that changes the behavior of my blog posts which are on my front page. In Drupal 6 a file named node-blog.tpl.php was all I needed to mess with my blog posts.

I tried the same with Drupal 7, but it didn't work. I searched for an answer and read that the following function should be relevant for choosing the template files.

function template_preprocess_node(&$variables) {
  ...
// Clean up name so there are no underscores.
  $variables['theme_hook_suggestions'][] = 'node__' . $node->type;
  $variables['theme_hook_suggestions'][] = 'node__' . $node->nid;
}

I also read about some conversion between '-' and '_' because '-' could not be used in function names. So I tried a few variants.

node__blog.tpl.php
node--blog.tpl.php
node-blog.tpl.php
node_blog.tpl.php

None of them is recognised by Drupal. What am I doing wrong?


texts: How can I replace a value already present in the database?

texts: Is there a way for db_insert() to overwrite existing entries?


texts:
I'm trying to alter the email and change the default "From" address to a different email address.

function mymodule_mail_alter(&$message){
   $message['from'] = 'myemail@gmail.com';
}

When I test send a test email through my site Contact Form.  The email "From" address is still using the default site email not the one I altered in my module.

Is there another way to make this work?
Thanks for your help.


texts:
I'm trying to move the breadcrumb from one part of my theme to another, and they have different template files (using an Omega subtheme). $breadcrumb seems to be an array. I've tried l($breadcrumb) and theme($breadcrumb) to no avail. How do you print out a properly themed and string-ified breadcrumb in a template?

Here's my code btw.

<?php
function rescue_breadcrumb($variables) {
    $breadcrumb = $variables['breadcrumb'];
    if (!empty($breadcrumb)) {
    $crumbs = '
';
    foreach($breadcrumb as $value) {
       $crumbs .= '
'.$value.'
';
       }
       $crumbs .= '
';
    }
      return $crumbs;
  }
$breadcrumb = drupal_get_breadcrumb();
if ($breadcrumb): ?>
  <div id="breadcrumb" class="grid-<?php print $columns; ?>"><?php print $breadcrumb; ?>

<?php endif; ?>


texts: how to separate taxonomy hierarchy in pathauto with slashes

texts:
Pathauto seems to have a different way of aliasing taxonomy hierarchy.

From Taxonomy Menu:

Classifieds > Cars > Aston Martin > DB9 Coupe
Classifieds > Jobs > Accounting

What I want is something like this for the url:

classifieds/jobs/accounting (not accounting-jobs-classifieds)

(Note that Pathautho generates this with dashes in reverse order as well.)

In Pathauto, I'm using this pattern: Default path pattern (applies to all vocabularies with blank patterns below)

[term:parents-all]

Confused.