texts: Drupal 8 custom type content, getting values for a field of type Taxonomy (hence, Entity Reference), which can have multiple values in the field

texts:
I have a custom content type (we'll call it 'book')... and it has a field  (We'll call the field 'category') which is of type Taxonomy Term and which can hold say ten items.

I can load the content programmatically:

$nids = \Drupal::entityQuery('node')->condition('type','custom content type machine name')->execute();

        $nodes =  \Drupal\node\Entity\Node::loadMultiple($nids);

I can then scroll through the items of node using something like

  foreach ($node as $node_item){
      echo $node_item->title
   }

However, how would I output the content of the reference entity 'category' ... say if category has 3 items assigned to it, it would be something like this:

  foreach ($node as $node_item){
      echo $node_item->title,
      echo $node_item->category[0]->target_id,
      echo $node_item->category[1]->target_id,
      echo $node_item->category[2]->target_id,
   }

But, this does not work...

There is the suggestion that $node_item->category has to be loaded as an entity reference but using $node->cateogry->referenceEntities () does not load anything.

Any ideas?  Thanks in advance.


texts:
I couldn't find the answer at How to change a field value with a Rules Action?, so instead of necroing that I figured it would be better to ask here.

I have a Rule that, when a Taxonomy Term of a certain type is created, it creates a node of a specific type. I need the Rule to also have actions that edit a few fields of the node - there's a term reference field I need set to the Taxonomy term that triggered the event, and I would also like to set the body to some generic text (either the term name or "Lorem ipsum...").

I see no "Populate a Field" in the Populating a node reference field using PHP in Rules. I don't need the PHP filter, thankfully.

Is this possible?


texts:
I just discovered the revisions function of Drupal. I tried it and the new revisions are stored in the database. I expected to get a list of revisions on the edit node page. But i don't see anything like this.

Is it possible to list and switch between revisions from within the UI?


texts: Database error when upgrading from Drupal 6.37 to Drupal 7.41

texts:
I have updated my site from Drupal 6.21 to 6.37 and it worked fine. Now I am trying to upgrade it to Drupal 7.41. I have changed the core as per the instructions that we follow for upgrading, but there is a database error I am seeing and don't know how can we fix it. I have googled and there were few threads asking to manually increasing the field size https://www.drupal.org/node/1133024 but it doesn't helped much and shows the same error again.

How can I fix this error?


texts: entity_metadata_wrapper - how to remove one item from entity reference field

texts:
I have a entity reference field that holds relations to multiple nodes. I have to remove one item programmatically based on nid. Normally to remove item I've just set it to null like this:

$wrapper->field_foobar = NULL;

But entity reference is a list, so I have to know delta for element to do something like this:

$wrapper->field_foobar[$delta] = NULL;

So I have content_id and target_id what should I do to find delta? I know it's possible to do it with simple SQL query, but I gues there should be some way to do that with entity metadata .

Any sugestions?

I'm on Drupal 7 of course.


texts: Can Drush 9 be used with this core version?

texts:
I have a Drupal 7 site that was not built with Composer. I have been using Drush 7 with it, but about a week ago, drush wd-show --tail stopped working, I'm not getting any output. I installed Drush 9, but I'm having difficulty configuring it.

I created an XML file, per the example., Instructions say to put aliases in $PROJECT/drush/sites/self.site.yml but I don't have a project root with a composer.json – can I get this to work without using Composer to build my site? Or is Drush 9 depending on the Drupal site using Composer?

I'm running the local version of the site in MAMP on my Mac. I created sites/drush/sites/self.site.yml – it contains:

local:
  root: /Users/pglatz/dev/wdocs/wdocs-code/www
  uri: 'https://www.whiskerdocs-local-qa.pglatz.com/'

The command I'm using is:

$ drush9 @local --alias-path=/Users/pglatz/dev/wdocs/wdocs-code/www/sites/drush/sites --root=/Users/pglatz/dev/wdocs/wdocs-code/www

When I run it, I get the error:

  Command wd-show was not found. Pass --root or a @siteAlias in order to run Drupal-specific commands.

But I am passing --root and a site alias. Likely a dumb syntax error on my part, but I can't figure it out. What am I doing wrong? And how can I get Drush to be working properly again?


texts: Clone nodes and change fields with Rules and VBO

texts:
I' trying to create a rule component that clones selected nodes and then changes some fields, using Rules, VBO and Node Clone.

VBO and Node clone work fine, but I can't change values of every field in the clones afterwards.
After the action "Clone node", I can add a "set data to value" action to change just core node fields (like status, sticky...), but the selector doesn't show me my other fields defined in the content type (like cloned-node:field_xyz).

I also tried to use Rules Bonus Pack  instead of Node clone to duplicate nodes, but with no luck: same issue.

After some researches, I tried to force a save entity action on the cloned node and then tried to load entity from cloned-nid, but I cannot choose my content type's fields to change them.

I also added a condition on top like "Content is type | entity has a field | entity is bundle", but nothing happens.

Probably I miss something.
Any idea?

Thanx in advance


texts: Drush does not work after I sudo su to another user

texts:
I have a CentOS 6 server with WHM/cPanel. I installed a global Drush as root using the instructions here (http://docs.drush.org/en/master/install/). Drush works fine for any user I ssh in as. However I typically ssh in as my user and then sudo su to the user I'm working on. When I do that I get these errors. If I ssh in as that user directly drush works fine. How can I make drush work when I su to a different user?

PHP Warning:  proc_open(): Descriptor item must be either an array or a File-Handle in phar:///usr/local/bin/drush/includes/startup.inc on line 366
Content-type: text/html; charset=UTF-8

Warning:  proc_open(): Descriptor item must be either an array or a File-Handle in phar:///usr/local/bin/drush/includes/startup.inc on line 366

PHP Warning:  proc_get_status() expects parameter 1 to be resource, boolean given in phar:///usr/local/bin/drush/includes/startup.inc on line 367

Warning:  proc_get_status() expects parameter 1 to be resource, boolean given in phar:///usr/local/bin/drush/includes/startup.inc on line 367

PHP Warning:  proc_close() expects parameter 1 to be resource, boolean given in phar:///usr/local/bin/drush/includes/startup.inc on line 368

Warning:  proc_close() expects parameter 1 to be resource, boolean given in phar:///usr/local/bin/drush/includes/startup.inc on line 368

EDIT

So I got it to work. If I do
sudo su - newuser
instead of
sudo su newuser it works.

I think it's related to CLI/CGI. PHP runs as CLI when I su with the - and CGI when I su without the -. Can anyone explain the difference the - makes?


texts: field_get_items('user', $user, 'field_name') empty?

texts:
I have a added data to the user using:

taxonomy_term_reference

when creating the

field_create_instance($instance)

and everything is working fine, I can add and store values and these are added to the specified vocabulary.

The problem is, I cannot extract the value added as a term to the $user object using field_get_items and field_view_value since field_get_items('user', $user, 'field_name') is empty.

Is field_get_items and field_view_value not applicable to $user?


texts: Strange entry in "flood" table / possible hack attempt

texts:
yesterday, when I tried to log into my Drupal 7 site with my admin account, I was informed that there had been to many incorrect login attempts with this account and that therefor I have to wait some time before I'm able to log in again. I checked with all other persons who have the credentials and all told me, that they didn't log in recently or had had any issue with providing the correct credentials.

I then checked the "flood" table and found several entries regarding failed user login attempts from the IP 127.0.0.54. Now that gives me pause. That address should be part of the local network. Does anyone have an idea what could be the cause of this?


texts: Show the pager on the top and in the bottom of the page (generated by Views)

texts:
I created a view and set a pager for it.
I is shown in the bottom of the page. Is there any way to show it both in the bottom and in the top of the page?


texts: Drupal 7 large files from private file system not fully downloading

texts:
Files from private system are not fully downloading. When I download the file of 20MB or less it is downloaded perfectly.

Files more than 20MB are not fully downloaded. For example after downloading 60MB file it shows only 35MB  and cannot open then file. But browser shows download is success and there error in dblog.

NOTE:
1. Small files are downloaded perfectly
2. No error or warning occurs in dblog
3. Browser showing download is success


texts: Is it good to declare API details as constants

texts:
I am writing a custom module for payments and using stripe payment method to accept payments on site.

i have a payment form on site and functions are written in above mentioned module.

right now my stripe api details are placed in a function and this function is called wherever i need to use them ( stripe publishable and private keys ) but i am not sure if i am doing it right because it might be not a safe approach to use api details directly in code

so i am thinking about re-writing the code to save the details in database ( using set_variable ) and then fetch them wherever they are needed.

can you help to figure out the most safe approach to save my details and use them.

another options is to declare them as constant at top of module but then they will be available globally that is also not secure.


texts:
I was wondering if there was a method to show anonymous users in a view. I have looked at various alternative such as the link below for showing anonymous users.
http://scito.ch/content/count-access-statistics-anonymous-users-only-drupal-7.
I did construct a view for the number of registered users but am having a problems showing just anonymous users in a view


texts:
I'd like to attach a javascript library to every page call. I created a directory for my module called flot_d8
I created an info file, lot_d8.info.yml. My understanding is, the libraries section should insert the javascript on every page load:

name: FLOT-D8
type: module
description: 'This module provides a wrapper to the javascript FLOT library.'
package: Misc
version: 8.x-1.0
core: 8.x
hidden: false
libraries:
  - flot_d8/flot

The library file which describes the flot asset is flot_d8.libraries.yml. I placed the flot library in drupal/modules/flot_db/flot:

flot:
  version: 1.x
  js:
    flot/jquery.flot.js: {}
  dependencies:
    - core/jquery

I enabled my module and fail to see the inclusion of jquery or foot in the header. My next attempt was to make a flot_d8.module file with a call to hook_page_attachment_alter:

<?php
function flot_d8_page_attachments_alter(array &$page) {
  // Attach the flot asset on every page.
  $page['#attached']['library'][] = 'flot_d8/flot';
}

Still no dice. Any advice? I'm wanting to begin playing around with getting the flot library working in D8. I'll eventually move the javascript attachment to occur during themeing, but I don't want to attempt that until I can even get the simplest case working.

As background. I've installed the PHP module so I can enter PHP directly into a page. If I insert the scripts and add javascript directly in the page. it works fine. This tells me the files are in the webspace and readable by the outside world:

EDIT:
I surrounded the jQuery, and still no go. I tried simplifying the problem to just try to force the inclusion of jQuery on every page load and that does not work either. I changed the module file to be

function flot_d8_page_attachments(array &$page) {
  // Attach the flot asset on every page.
  $page['#attached']['library'][] = 'core/jquery';
}

and changed the basic page to be

<?php
$jquery_already_included = TRUE;
if (!$jquery_already_included) {
  echo '';
}
?>

?>

and even that does not work.


texts: Views filterable by current logged in user that equals Entity Reference field?

texts:
I have nodes that have a user assigned to them as a responsible party via Entity Reference.  I would like to have a View display all the nodes that the current logged in user has they that they are the responsible party of.

Would a filter that looks something like this Content: Responsible Party (Current User) be do able?

I have gotten this far using the Entity Reference Filter for Views, but it doesn't give me a "Current User" option.


texts: Content type structure (nested content: Gallery / Photo)

texts:
I've been digging for some days how to organize my Drupal 7 site.
I want to build a site with multiple galleries, each one of them with multiple photos:
 - The galleries will show a cover photo, a description and thumbnails of the pictures;
 - Each photo will have a title, a description, date, will allow for comments, have tags, etc.
I want both the gallery and the photos as nodes (so I can have a page for a gallery and a page for each single photo with different layout).
So, I thought this would be the structure of the content types, where 1 gallery has multiple photos:

content type: GALLERY

description (text)
cover (image)
photo_entries (unlimited | content type: PHOTO)
...

content type: PHOTO

file (image)
title (text)
date_taken (text)
...

I tried a solution (like the one explained here:http://megadrupal.com/blog/creating-an-image-gallery-in-drupal-7) where I have an unlimited image field in my gallery, but I really want the photos to be nodes and this is the thing I don't know how to do.
I've been unsuccessfully trying using some modules like Views and entity reference, or even taxonomy, but I'm not sure what should be the approach to get this.
This can be a very simple question and I'm sorry if it is, but I'm stuck...
I really appreciate if someone could give me advice and put me on the way.


texts: How to add default text that clears on focus with jQuery to a search form text field in Drupal

texts: I would like to have a default text in an Exposed Views Search form that says something like 'type in a keyword to search' which will disappear if the user clicks on the text field and reappear if the user removes the cursor and didn't type anything. I would like the title of the field which is added through Views to become the text in the text field box. Should I use pure jQuery to add the text to the box? Or should I use hook_form_FORM_ID_alter() to add the jQuery and change the location of the title?


texts: How to edit Menu primary nav tab in Drupal 8

texts:
Page contains two nav bars with primary having View, Edit, Notes, Resend, Devel tabs and a secondary nav bar with Definition, Render, Load, Tokens. I am using css to not display particular tabs in primary and totally hiding the secondary nav bar. But, one of the requirement is to edit the name of a tab. I tried using theme_preprocess_menu_local_task hook but I am not able to edit the protected object values. What is the approach I need to take to edit the name of the tab. In this case 'resend' to 'forward'.

    function theme_preprocess_menu_local_task(&$variables) {
     if($variables['item']->text =='Resend'){
        $variables['item']->text = 'Forward';
     }
    }

the above code bombs with error saying protected values cannot be accessed.


texts: What was the motivation for developing the plugin API?

texts: I am trying to wrap around my head as to what was the need for the Plugin API when the module system extends the Drupal core.


texts: Reset password after creating user account programmatically

texts:
I'm creating a user account programmatically using the code below (Drupal 8). Everything works well except when the user suppose to change their password via the Drupal generated 'one-time login link'. The password reset doesn't work and it seems the 'pass-reset-token' is not generated properly. What am I doing wrong?

public function submitForm(array &$form, FormStateInterface $form_state)
    {
        $the_user_email = $form_state->getValue('user_email');
        $the_user_name = $form_state->getValue('user_name');
        $language = \Drupal::languageManager()->getCurrentLanguage()->getId();

        $user = \Drupal\user\Entity\User::create();
        $user->setPassword(user_password());
        $user->enforceIsNew();
        $user->setEmail($the_user_email);
        $user->setUsername($the_user_name);
        $user->set("init", $the_user_email);
        $user->set("langcode", $language);
        $user->set("preferred_langcode", $language);
        $user->set("preferred_admin_langcode", $language);
        $user->addRole('price_list_users');
        $user->activate();

        //Create the account
        $user->save();

        _user_mail_notify('register_no_approval_required', $user);

        drupal_set_message($this->t('A welcome message with further instructions has been sent to your email address.'));
        $form_state->setRedirect('/price-list');
    }


texts: Drupal 6: Move the 'Add new comment' link to the bottom

texts: Like the subject says. I'd like to move the 'Add new comment' link to the bottom of the comment list. The only thing we're using them for a is a forum, and this is how we want them set up. I can't seem to find out to move this section in the template.


texts: Trying to access modules page callback while authenticated

texts:
I have a module below that will only show "hello world" when I am an administrator. I would also like "hello world" to display when I an authenticate user but right now all I am getting is you are not authorised. I have set  mymenuitem as the home page and I am using Drupal 7.

 function mymenuitem_menu() {
  $items = array();
  $items['mymenuitem'] = array(
    'title' => 'mymodule',
    'description' => 'my menu access issue',
    'page callback' => 'mymodule_homepage',
    'access arguments' => array('access mymodule homepage'),
    'type' => MENU_LOCAL_TASK,
  );

  return $items;
}

function mymodule_homepage(){
  drupal_set_title(t('menu system'));
  return "hello world";
}

How can I achieve this?


texts: Can I simply delete the File Entity folder from Modules if I am using Media 7.x-1.3

texts:
When I try to create new content with a linked YouTube video I am getting the following error:

  Fatal error: Call to undefined function file_info_file_types() in /home/setstart/public_html/sites/all/modules/media/media.module on line 1084

I have inherited a site that use Media 7.x-1.3

I see that the following Module is also installed - File Entity 7.x-2.0-unstable7

I see from the following threads that the file entity submodule within Media should be used not the standalone one.

http://drupal.org/node/1516804

http://drupal.org/node/1850324

So it looks like File Entity 7.x-2.0-unstable7 should never have been installed.

Can I simply remove the independent File entity module? I see a lot of other modules state they depend on it (so I can't disable it from admin screen)

If not what is my best option? Upgrade to Media 2.x?


texts: Views exposed date filter using "Is between" doesn't include end date

texts:
SITUATION:

Create a view of transactions (a custom entity in my case, but I don't think this is relevant)
Filter against Authored on (which includes both the date and time of creation)
Expose the filter
Choose Operator: Is between
Display the view with 10/01/2020 and 10/31/2020 as start and end dates for October
Note: I'm using the Date Popup module for date entry, which accepts mm/dd/yyyy

PROBLEM:
Transactions on 10/31/2020 are omitted. How can I include end-date transactions, short of telling users to put 11/01/2020 instead of 10/31/2020 (which is what seems natural to them)?
SOLUTION:
Thanks to @prkos in his answer below that a time of 23:59:59 must be included with the end date to compare up to the last second of the day. After learning this, I added a custom submit function to the exposed filter that appends the end time, like so:
use \Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_form_FORM_ID_alter().
 */
function mymodule_form_views_exposed_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  // Use array_unshift() so custom submit runs before default submit
  array_unshift($form['#submit'], '_my_submit_function');
}

function _my_submit_function($form, FormStateInterface $form_state) {
  $created = $form_state->getValue('created');
  if ($created['max']) {
    $created['max'] = $created['max'] . ' 23:59:59';
    $form_state->setValue('created', $created);
  }
}

Thanks to @No Sssweat for pointing out in his accepted answer below that array_unshift must be used to make the submit function run before the default. Initially, I simply used
$form['#submit'][] = '_my_submit_function'; // Don't do this. It doesn't work

See the accepted answer below from @No Sssweat for an alternative method of solving the problem using views_query_alter. I tried this and it worked as well, although in the end I chose the simpler of the two solutions.
UPDATE:
Turns out that, although the "simpler" hook_form_alter solution appeared to work, changing the value of the filter by adding a time breaks the filter if you move to another page in the list because the filter is passed via the query string to the page and it includes the time, which won't display in the date field. Given this, I reverted back to the views_query_alter approach, which doesn't have the same problem. My simple code is
function mymodule_views_query_alter($view, $query)
{
  if (!empty($query->where[1]['conditions'])) {
    foreach ($query->where[1]['conditions'] as $key => &$value) {
      if (strpos($value['field'], '.created <=')) {
        $e = explode(' ', $value['field']);
        $e[2] += (24 * 60 * 60) - 1;
        $value['field'] = implode(' ', $e);
      }
    }
  }
}

Note that I have switched from using IS BETWEEN to using two, separate tests against the Author On variable, on with >= and one with <=. You can see in the code that I'm modifying only the <= instance.


texts: Can't change my custom logo for Bartik-theme. How to fix this?

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

Any suggestions/help? Thank you in advance.


texts:
I've been trying to figure out how to create a content type "a course" that has title, description, duration, instrucor details and contains video lessons.
I made three different content types - courses, videos and instructors but couldn't figure it out how to relate it. I've been trying with View but if someone could suggest module/tips how-to would be much appreciated.

BR, Ivan Ivanov


texts: What does it mean to "Use rendered output to group rows?"

texts:
Is the alternative to use raw output?
To what grouping is it referring?
Does this affect the sort order of rows?


texts:
I have a view that shows a list of nodes and has a contextual filter.
If the number of nodes shown is only 1 then I want to redirect to that node page instead of showing the view.
Can I do that in views or do I have to code it?


texts: Linking to content from Image not working when using Views Slideshow

texts:
When using Views Slideshow the ability to "Link Image To: Content" doesn't seem to create an anchor tag in the HTML. It only seems to be happening on a single slideshow on my site but I can't find anything that would stop it from working.

This is the code that's generated from Views. If I change it to link to the original file then it works - have I just stumbled on to an odd bug?


texts: Is there a drupal hook that I can use to redirect a user to an interstitial page for the first page view? If not then how can I accomplish this?

texts:
I am currently in the process of developing a custom module that will redirect a user on entry to an interstitial landing page.  This page will closely replicate how forbes.com functions.  The landing page itself is a page template within the custom module that displays a view, an ad, and links back to the originally requested page. All of the pieces are in place and function as intended except for the hook when caching is enabled. After researching hook_boot, hook_init, and hook_page_alter, I have found that none of these are working when caching is turned on or in the case of hook_boot because drupal functions were not loaded when the hook was called.  I feel hook_boot is the closest solution at this point but after reading the comments in the api it was said that you shouldn't invoke any drupal modules inside of that hook. Is there a way I can detect if the user is anon without user_is_anonymous()? Should I write this hook without any drupal functions? Should I bootstrap drupal in hook_boot similar to how its done in the core module file statistics/staticstics.php?

Here is my code for hook_boot:

function my_module_boot() {
  // If anon proceed
  if(user_is_anonymous()){
    if(isset($_COOKIE['welcome_page'])){
      // do nothing
    } else {
      $cookie = filter_xss($_COOKIE['welcome_page']);
      // If user saw welcome page and has cookie- skip redirect
      if($cookie != 1) {
        setcookie('welcome_page', 1, time()+86400);
        $destination = drupal_get_destination();
        drupal_goto('welcome', array('query'=>$destination), $http_response_header = 301);
      }
    }
  }
}

My goal is to keep all of the code contained inside of the module. I'd rather not use any other contrib module at this point because my module is close to completion. This redirect should only get triggered if the user does not have the cookie and is anon.  Finally I do not want the site to appear before the landing page.

Thanks for any help.

Solution:

function my_module_boot() {

  if(isset($_COOKIE['welcome_page']) || isset($_COOKIE['welcome_page_admin'])) {
    // do nothing
  } else {
    $cookie = filter_var($_COOKIE['welcome_page'], FILTER_SANITIZE_STRING);
    // If user saw welcome page and has cookie- skip redirect
    if($cookie != 1) {
      $destination = '/';
      if($_GET['q']) {
        // Microtime for IE9 to properly redirect
        $destination = $_GET['q'] . '?a=' . microtime(true);
      }
      // Redirect and set cookie
      setcookie('welcome_page', 1, time()+86400);
      header("HTTP/1.1 301 Moved Permanently");
      header("Location: /welcome?destination=" . $destination);
      exit();
    }
  }

}

function my_module_user_login(&$edit, $account) {

  // Expires in one year for authenticated
  setcookie('welcome_page_admin', 1, time()+31556926);

}


texts: How to add Permalink for custom content type(nodes)

texts:
I need to add Permalink for my section/div where the ID will keep on changing whenever i update the page(custom content type).

I have achieved it through client side(Jquery) by find & get ID seems like tedious?

I have checked for module support like permalink & permalink block, Deeplink nothing seems to be helpful?

Is there is any better way to achieve it?


texts: Trying to set a twig global variable for a function

texts:
I have a Twig function in my theme that sets a random ID. The function works well if I include the entire function within any given template and then render the variable for that {{ randomID }} in the same template.

However, I'd like to be able to call this variable globally. I made an include file with the function and then call it in another Twig template like so:

  {% include directory ~ '/templates/slices/random_id.html.twig' with { randomID : 'randomID' } %}

... but now when I print {{ randomID }} in a given template where the include file is called, I do not see the random id print. I think I am on the right track here but not quite there yet.

I used these pages for reference:

http://twig.sensiolabs.org/doc/tags/include.html
http://twig.sensiolabs.org/doc/functions/include.html


texts: Can't get preprocess_node function to override items

texts:
I've been stuck on getting a custom preprocess_node function to work in a Drupal 6 install. I can get it to echo out things based on values but I just can't seem to get overrides working. The latest thing I've tried is the answer described in the answer on this page. If I do:

$node->title = "Test";

and do a print_r on the $node I can see that it is overridden in the array with the new value but the title that's being output is still the old one. I've also tried setting $variables[title] but no luck. I'm actually trying to target something deeper than the title but thought I'd start with this. Here's an example I've tried putting in the template.php file. I've replaced my actual theme name with mythemename.

function mythemename_preprocess_node(&$variables) {

//Profiles
if($variables['type'] == "child_profile"){

    $node = $variables['node'];

        $node->title = "Test";
        //This echo correctly shows the new title but it's not actually overriding anything
        echo $node->title;

    $variables['node']=$node;
}}


texts:
I am using Drupal-6. I Created CCK Field with Select Box with content type name as list_porducts.

i am  fetching products from external url . Here is my code

$key=array();
$flowervalue=array();
for($i=2;$i<=150; $i++) {
        $url="http://testurl.com/test/node/".$i.".jsonp";
        $timeout=0;
        $ch = curl_init();
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
        $data = curl_exec($ch);
        $jdata=json_decode($data);

            if($jdata->type=='product') {
                $key[]=$jdata->nid;
                $flowervalue[]=$jdata->title." ".$jdata->field_petals_code[0]->value;

            }

}
$res=array_combine($key, $flowervalue);
return $res;

which is running properly. Now Problem is this is Quite slow. and i guess it is running for all page load.

Any Idea how to do this.

Thanks


texts: Add custom field to search_api_solr index

texts:
I've used search_api, search_api_solr, search_api_sorts, search_api_sorts_widget, nodeviewcount modules.

I have tried to add custom field into search_api_solr index which contains number of views for a node and also sort using this custom field.

How to do this?


texts: How to display the output of my module without clearing cache and refresh page?

texts:
I created a very simple module which generates a tag cloud based on user input; you can see the code here.

// wow.module
function wow_menu() {
    $items = array();
    $items['wall/of/words'] = array(
        'title' => 'Wall of Words',
        'page callback' => 'wow_page',
        'access arguments' => array('access content'),
        'file' => 'wow.inc',
        'weight' => 1,
    );
    $items['admin/settings/wall/of/words'] = array(
        'title' => 'On this date module settings',
        'description' => 'Description of your On this date settings page',
        'page callback' => 'wow_admin_page',
        'page arguments' => array('wow_admin'),
        'access arguments' => array('administer wow settings'),
        'type' => MENU_NORMAL_ITEM,
    );
    return $items;
}

function wow_admin_page() {
    return 'hey';
}

// wow.inc
function wow_page() {
    $output = array(
        'form' => drupal_get_form('wow_cake'),
        'words' => _getWords(),
        'min_count' => 0,
        'max_count' => 999
    );
    drupal_add_js(drupal_get_path('module', 'wow') . '/js/jquery.tagcloud.js');
    drupal_add_js('jQuery(function(){jQuery("#wow-container .cloud a").tagcloud({size:{start:20,end:40,unit:"pt"},color:{start:"#46A7E3",end:"#0969A3"}})})', 'inline');
    return theme('wow_template', array('output' => $output));
}

function wow_theme($existing, $type, $theme, $path) {
    return array(
        'wow_template' => array(
            'template' => 'wow_template'
        ),
    );
}

function wow_cake($form, &$form_state) {
    $form = array();

    $form['title'] = array(
        '#type' => 'textfield',
        '#title' => t('Thank you for...'),
        '#size' => 60,
        '#maxlength' => 128,
        '#required' => TRUE,
    );

    $form['buttons']['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Submit'),
    );
    return $form;
}

function wow_cake_validate(&$form, &$form_state) {

    if (empty($form_state['values']['title'])) {
        form_set_error('title', t('Please leave a thank you message in highlighted field below.'));
    }
}

function wow_cake_submit(&$form, &$form_state) {

    if (_create_node($form_state['values']['title'], $form_state['values']['title'])) {
        drupal_set_message(t('Thank you for your kind words!'), 'status');
    }
}

function _getWords() {
    $query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'node', '=')
            ->propertyCondition('status', 1, '=')
            ->propertyCondition('type', 'wall_of_words', '=');
    $result = $query->execute();
    $nodes = $result['node'];
    $fields = field_info_instances('node', 'wall_of_words');
    $field_id = $fields['body']['field_id'];
    field_attach_load('node', $nodes, FIELD_LOAD_CURRENT, array('field_id' => $field_id));
    $wall = '';

    foreach ($nodes as $node) {

        if (!empty($node->body['und']['0']['value'])) {

            $wall .= trim($node->body['und']['0']['value']);
            $wall .= " ";
        }
    }
    if (!empty($wall)) {
        $cloud = explode(" ", $wall);
    }

    return array_count_values($cloud);
}

function _create_node($title = "", $body = "", $language = "und") {

    $node = (object) array();
    $node->type = 'wall_of_words';
    $node->status = 1;
    $node->promote = 0;
    $node->sticky = 0;
    $node->revision = 0;
    $node->language = $language;
    $node->title = $title;
    $node->body[$language][0] = array(
        'value' => $body,
        'format' => 'full_html',
    );
    if ($node = node_submit($node)) {
        node_save($node);
    }

    return $node;
}

My issue: when I visit another page and come back to the page that I generated with my module the output of the content does not get displayed unless I clear the cache and visit the page again.


texts: Number Slider for exposed filter using Drupal 6

texts:
I need to expose the number fields in views with the range slider, for example : Min- 421 and Max 780.

I found this slider Field module, but it support only for Drupal 7. any idea for Drupal 6 ?

I don't want to use Better Exposed Filter module, because the plugins mentioned in the documentation are not there and hard to configure the options. Looking for any other alternate way.


texts:
I am trying to customize the authored by information for all of my nodes that prints the User First and Last Name, which are custom fields on the User Profile.

I copied the node.html.twig template into my theme
I added the following code to load the user information in my preprocess function

function blend_preprocess_node(&$variables) {

// Load the current user.
$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());

// get field data from that user
$firstname = $user->get('field_first_name')->value;
$lastname = $user->get('field_last_name')->value;

// some default getters include
$email = $user->get('mail')->value;
$name = $user->get('name')->value;
$uid= $user->get('uid')->value;

}

I added this code to node.html.twig

{{ title_prefix }}   {% if not page %}

  {{ label }}

   {% endif %}   {{ title_suffix }}

{% if display_submitted %}

      {{ content.field_services }}

  {{ author_picture }}

    {% trans %}Submitted by {{ firstname }} {{ lastname }} on {{ date|date("m/d/Y") }}{% endtrans %}
    {{ metadata }}

   {% endif %}
{# We hide the comments and links now so that we can render them later. #}

{{ content|without('comment', 'links', 'field_tags', 'field_services') }}

{% if content.field_tags|length and not is_front %}
{{ content.field_tags }}   {% endif %}
{{ content.links }}   {{ content.comment }}

How do I make variables (mostly fields) from different entities available to print in different template files?


texts: Menu Block Appears When Page NOT in Any Menus

texts:
Let me describe the site/block issue:

The site has multiple menus.
We use a menu block to generate a left-column menu that follows active trail. Attached is a screencap of the settings we're using for our block. Menu block settings page has a few of the menus we use on the site checked off (why we're using "the menu selected by the page" for menu).

The issue right now is that the menu block will appear on all nodes, even ones not defined in ANY menu at all, as opposed to hide when not in menu.

We can hide it using the block visibility settings, but preferably it would be nice to fix this issue so that it just auto-hides when it does not detect a menu associated with the node.

Is there a fix or something I'm setting wrong to cause this issue to happen? Or am I doomed to just use block visibility to control it?


texts: How to display the values after submit in drupal 7

texts:
I have a three form fields like Name,phone,email now after inserting the values in my db i want to display the values into same page or another page like
 Name:XXXXXXXXXXX
 Phone:5545445454
 email:yyy@some.com

how can do this in drupal7


texts: Why can't I delete both account and content when cancelling a user account, in Drupal 8?

texts:
Before, drupal 7 core, and in drupal 6, a contrib module called user_delete,  had this 4th option in deleting user accounts settings:

"Delete the account and its content." (drupal 7) and

"delete a user and delete all submitted content including nodes and comments" (drupal 6)

But this option seems unavailable in drupal 8 core. Why?

I really want both account and content deleted. The option they offer would force me to periodically delete the unpublished content of the removed account via cron.

Or am I missing something here?


texts: Feature with Content Types is not reverted

texts:
I am stuck watching the Feature state as Overriden. I tried different solutions as:

Disable and re-enable the feature
Restart apache to ensure the APC cache is cleared
Clear All caches from Drupal administration

But I get stcuk with the overriden state.

Doing a Diff within the Diff module, I see the following differences:

But if I check the current feature code the Line 732 doesn't seems to be the same as the Diff module is detecting.

So I don't understand where is the difference.

I do the revert of the feature, clear cache, ... several times, and the Feature is always on Overriden state.

Please, any idea to discover the reason why I can't do the revert and a solution to perform the revert?


texts: How can I schedule change of the default front page?

texts:
I have a node being displayed on the front page, set at admin/config/system/site-information > Frontpage.

I need to change it to another node on specific date.

It would be ideal if I could do that using views display of /frontpage + Promote node to frontpage. But i have a referenced by nid view inserted into the nodes of this content type (using Views Field) which does not show anymore if I use this method.

Thanks


texts:
I've installed Drupal 7, Drush 7.0 and the Omega 4 theme. I'm using MAMP. I'm attempting to create an Omega subtheme with the command line:

drush omega-wizard

I then receive the following error.

When I run drush --debug, this is the result. Can anyone decipher this?


texts: How to display all values of List (text) instead of just the selected ones?

texts:
When viewing a node, how can I display all values of a List (text) instead of just the selected ones.

So, instead of displaying:

B (good)

I want to display all values, with some markup telling selected and unselected apart:

[_] A (superior)
[_] A-
[_] B+
[X] B (good)
[_] B-
[_] C+
[_] C (average)
[_] C-
[_] D+
[_] D (poor)
[_] F (failure)
[_] I (incomplete)
[_] PR (course in progress)
[_] W (withdrew from course)
[_] FF (failing in a pass/fail course)
[_] PP (passing in a pass/fail course)
[_] N/C (not for credit)

Now, I have actually solved this already for myself and for some others (who had desperately been searching for this functionality) in my sandbox module https://drupal.org/sandbox/kari.kaariainen/1349570, but I just wanted to ask if anyone else has a) needed this, b) solved it and how?

Edit: my solution is to rebuild the $items at hook_field_formatter_prepare_view so that it doesn't have just the selected items, but all items, including data about whether an item has been selected or not. $items will then be handled by hook_field_formatter_view actually outputting items with added markup and translated.

It's kind of frustrating to bring back data at prepare_view, so I'm wondering if data for all items could be retrieved from database initially.

Another thing is i18n support, which I'm now copying from i18n module. Code for each field type (there will be more than just text lists) will need to be duplicated and modified separately. I'm wondering if field translation could be left for i18n and not duplicating code.


texts: scale up small uploaded images in drupal 7 imce

texts:
I have many image size Thumbnails defined in imce module.

whenever a very small image (smaller than any of my thumbnail) is uploaded, imce does not scale up it to make a bigger thumbnail than the actual size and it make trouble for me.

how can I make all thumbnails for big or small images?
hope explaining clearly.


texts: Drupal Twig custom alias for templates in components

texts:
i want to combine a living styleguide generator with drupal 8. The living styleguide generator uses a unique symtax for reusing templates like this "@button"

for the component library itself i use https://www.drupal.org/project/components

The component libary lives in THEME/components
The example layout lives in THEME/components/box/box.twig

I can include this in a Drupal template using it like this:

{% include "@components/box/box.twig" with {
  'classes' : classes,
  'attributes' : attributes|without(classes),
  'button' : {
    'modifier' : 'default',
    'label' : 'Read More'
  },
 'paragraph.text' : content.field_body|field_value

}%}

The box.twig template itself reuses other components like this:

{% include '@button' with {
  'value' : button.label,
  'modifier' : button.modifier }
%}

Now Drupal tells me it can't find @button, sure thats true because it does not know the alias structure.

What would be the best way to tell Drupal to look for @components/box/box.twig if it is called with @box ?

Thanks in advance,

yobottehg


texts:
I'm just trying to clone a d7 site in 8.  My first step was to use drupal console to generate a custom entity.  Everything is working fine but I want to change the title of the form to "Create project" instead of the default "Add project".

I don't see "Add " anywhere except for module.links.action.yml, but that is just the local action - it doesn't change the name of the form.

The root of the directory looks like:

config
  schema
    project_entity_type.schema.yml
src
  Entity
    ...several classes
  Form
    ...several classes
  templates
    ...couple template files
  Tests
    LoadTest.php
module.page.inc
module.links.action.yml
module.links.menu.yml
module.links.tasks.yml
module.module
module.permissions.yml


texts: Pre populate a text field when creating node

texts: Say I'm creating content into a text field. Instead of inserting text by typing into text field, how could select text from a drop down list to pre populate the text field?


texts: How do I get the order_id and order_number on the checkout completed page?

texts:
I'm trying to get the order information inside the mymodule_preprocess_page hook.
On the normal page I can get it via the $cart. But the $cart is not available on the checkout page anymore. How do I get the order information specifically the order_id and order_number.
This is what I do on other pages:
  $order_type = 'physical';
  $cart_provider = \Drupal::service('commerce_cart.cart_provider');
  $store = \Drupal::service('commerce_store.current_store')->getStore();
  $cart = $cart_provider->getCart($order_type, $store);
  if ($cart) {
    foreach ($cart->getItems() as $order_item) {
      $orderId = $order_item->get('purchased_entity')[0]->get('target_id')->getValue();
  }


texts:
We have a weird bug with the Linked module.

We installed Linkit on a Drupal 7 website on the WISYWIG with TinyMCE. On environments local and staging, it works perfectly but in the production environment on a different server, the modal of linkit is empty and we have the error javascript:

TypeError: $(...).once is not a function
Drupal.behaviors.panopolyImagesModule.attach()
 jquery.js:5
Drupal.attachBehaviors/<()
 drupal.js:76
.each()
 jquery.js:654
Drupal.attachBehaviors()
 drupal.js:74
Drupal.ajax.prototype.commands.insert()
 ajax.js:570
Drupal.ajax.prototype.success()
 ajax.js:428
Drupal.linkit.getDashboard/Drupal.ajax["linkit-modal"].options.success()
 linkit.js:117
jQuery.Callbacks/fire()
 jquery.js:1075
jQuery.Callbacks/self.fireWith()
 jquery.js:1193
done()
 jquery.js:7538
.send/callback()
 jquery.js:8324

The version on JQuery in 1.7.2 on all environments.

I tried to reproduce the bug in local, same code, same database, no problem. I try to execute the javascript step by step, I found the last line on linkit js before the exception is:

Drupal.ajax['linkit-modal'].success(response, status);

in the file linkit.js line 117.

Too many things happen in library js in Drupal core, I missed the line which launch the exception.

The markup of the modal is limited to:

Additionnally, I have this html behind the modal:

If I understand well, drupal.js add this block during the generation of element to prevent upwards scrolling. The function is call by ajax.js line 424, in the function Drupal.ajax.prototype.success but the execute bug before (or during) the UnfreezeHeight, line 441 of ajax.js, so the block isn't remove.

So, if I understand well, I could search in this part of code, but I don't understand very well the javascript drupal engine so I don't know if I'm on a good track.

I verify the configuration server, I see nothing which could influence the behavior but maybe I missed something.

The linkit module is installed with the profile of OpenAtrium, I look issue on the Linkit Project, OpenAtrium and Panopoly, but I find nothing which could help me :-/


texts: User uid incrementing in non sequential manner

texts:
I have a drupal site that has been running for about 1 year. there are about 1000 members in the users table

recently I have noticed something very strange the Users uid field is no longer inrementing sequentially.

It now jumps up in the 10s, for example, my last 8 users, the uids went from 7999 to 8068, 8094, 8350, 8416, 8458, 8534, 8566.

So sometimes it is jumping 100s at a time.

How can I work out what might be causing this, and should I be worried?


texts: How should I patch drupal core to Calendar Systems module work thoroughly?

texts:
After installation Calendar Systems module, I get a message in status report section that Its
require to patch drupal core to work fully.
Please see below image:


texts:
A service I have takes a username, and should find and log in a local Drupal user account with that username. After logging in, I need the session ID (from the sessions table) for that users new session.

I have some basic procedural code that I'd like to refactor for Drupal 8 practices:

$user = user_load_by_name($username);
if ($user) {
  user_login_finalize($user);
}

1) What's the OO way of loading a user entity? A service I found that may help loading a user is entity.manager, but is that the right way to do it?

2) Logging a user in? Should I just take the code from user_login_finalize and try and inject the services used and essentially "copy" what's done in that function?

3) After the user is logged in, how can I get their session information? Injecting the current_user service doesn't work, because the user data in there is stale after I log the user in.

EDIT: Looks like a user's session is not saved until AuthenticationSubscriber runs (listens for kernel response event), which is when the session data would be saved. Maybe I can manually save the session before then, and then obtain session? Not sure what that would impact.


texts: How to pass an array or an object from a module to a theme

texts:
I have used hook_menu() with a page callback as follows:

function profilecb_menu() {
  $items['profilecb'] = array(
    'title' => 'Profile CB',
    'page callback' => 'pcb_exe',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );

  return $items;
}

The callback code is the following:

function pcb_exe($id) {
  $ar = array('arg1'=> 'value1', 'arg2'=> $id);

  return $ar;
}

I have been able to make the callback function return a single string; when I try to return an array, I get an error.

All I need to do is to make the callback function do some tasks, like connecting to the database, and return to a template a complex array of useful information.

How can I do that?


texts: Rendering a module's template contents in the page body

texts:
I've been digging through the Drupal docs and haven't found a solution for this:

What I'm trying to do is to create a module with a URL using menu hooks. I've got that far. When this URL is viewed, I'd like to insert some HTML and JS code in the body but I haven't managed that. I've been trying to use templates.

This is what my module looks like:

<?php
  function hello_menu(){
    $items = array();

    $items['nodes'] = array(
      'title'            => t('My Nodes'),
      'page callback'    => 'helloworld_output',
      'access arguments' => array('access content'),
    );

    return $items;
  }

  function hello_theme($existing, $type, $theme, $path){
    return array(
      'timeline' => array(
        'variables' => array('content' => NULL),
        'file' => 'timeline.tpl.php',
        'path' => drupal_get_path('module', 'hello')
      )
    );
  }

  function helloworld_output() {
    header('Content-type: text/plain; charset=UTF-8');
    header('Content-Disposition: inline');
    return theme('timeline', array());
  }
?>

..and this is what I want rendered in the body.

If I place this code into my timeline.tpl.php, it doesn't get rendered in the page but before the whole content. Do I need to wrap this in PHP tags?

How can I get the onLoad() function to fire once my Drupal page is loaded. I a normal HTML page, I could use the body onload= callback.

(It looks really simple when you've worked with Drupal but for a first-timer, it's been a nightmare.)


texts: Can I show email Id entered by user to the visitors?

texts: Suppose When a user doing the registration, site will ask that "Do you like to show your email ID?" If the user selects YES then the site will show his email ID and if it selecet no the site will not, I am new to the drupal, so please help me.


texts: How do I remove the inserted a span tag in an href parameter when using Full Calendar and Devel Themer

texts:
When devel_themer is active inside of a Fullcalendar formated View, links contain the span tag. See below in the href parameter. This however does go away when I disable devel_themer and clear cache.

11:15

You can see in the status (bottom left) that the span tag (with devel_themer generated classes) is in the link.

This is what the Views Format Settings look like

And the general Views Admin

How might I fix this?


texts:
I am using shared host and after some problems they restarted the server and my Drupal website shows the following error:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1286 Unknown table engine 'InnoDB': SELECT

This is the full log

Error message

  PDOException: SQLSTATE[42000]: Syntax error or access violation: 1286
  Unknown table engine 'InnoDB': SELECT
  field_data_media_gallery_expose_block0.entity_type AS entity_type,
  field_data_media_gallery_expose_block0.entity_id AS entity_id,
  field_data_media_gallery_expose_block0.revision_id AS revision_id,
  field_data_media_gallery_expose_block0.bundle AS bundle FROM
  {field_data_media_gallery_expose_block}
  field_data_media_gallery_expose_block0 WHERE
  (field_data_media_gallery_expose_block0.media_gallery_expose_block_value
  = :db_condition_placeholder_0) AND (field_data_media_gallery_expose_block0.deleted =
  :db_condition_placeholder_1) AND
  (field_data_media_gallery_expose_block0.entity_type =
  :db_condition_placeholder_2) AND
  (field_data_media_gallery_expose_block0.bundle =
  :db_condition_placeholder_3) ; Array ( [:db_condition_placeholder_0]
  => 1 [:db_condition_placeholder_1] => 0 [:db_condition_placeholder_2] => node [:db_condition_placeholder_3] => media_gallery ) in field_sql_storage_field_storage_query() (line 577 of
  /home/fossisor/public_html/techiestuffs/modules/field/modules/field_sql_storage/field_sql_storage.module).

What is wrong with the database ?


texts: I have created content on 30/8/15 and the same created content is edited by other user on 1/9/15, when I go check in the dashboard or if i create view and see the edited only i could see, but in my case i want to see overall like when the content is created and by whom its created and also by whom edited?on what date for that particular content I want to see it in a view. how to achieve this please can any one suggest me?


texts: Quick tabs: Passing current nid to a view

texts:
I have a content type called products. The url is products/[node:title], i.e. /products/pear, products/banana, etc.

On the node page itself many of the fields of that node are hidden, because I want them displayed in tabs, along with content from associated nodes (via Entity References). So I am using Quicktabs and views to display this content. However, I can't work out how to pass the NID to a view if it doesn't appear in the URL. Since I just want to pass the NID of the page I am on, this seems like it should be a simple issue, but I can't work it out.


texts: Apache Solr / Facet API: filter by negative facets (e.g. items NOT red)

texts:
I'm using Apache Solr with Facet API, and want to allow users to filter negatively by items that do NOT have a term.

For example, I have a Facet API block connected to my taxonomy for color:

red
blue
yellow
orange

And I want to be able to filter by items that are NOT red, or NOT blue (in addition to being able to filter by items that ARE red, or ARE blue).

Can someone point me in the direction of how to most easily achieve this kind of functionality? Is a custom widget needed? Does Lucene syntax support negative filters out of the box? Surely people have attempted this kind of negative filtering?


texts: Change class on the div wrapper of a form element

texts:
Is there a way to add or change a class to a form wrapper (the div's) using the form api?

Or is that just done with the theme function ?

If so which theme function is used to change that?


texts: How to send an email using Rules when a node's boolean field is changed?

texts:
I managed to setup email notification via the Rules module when the content is updated.

But I want to limit this only when the value changes in a specific field that is boolean "Yes", "No".

Update:
This is the part where i am stuck. I am not sure what to pick at Data selector, while at bottom (Field: Value) i found the field i need.
I tried to save with "node" to try 2nd condition but also did not find an option: "Rules Condition (2nd): Compare the value of the specific field, for both the original value (before editing the field) and the (new) updated value, to verify if they are different."


texts: Exposed filter checkbox for "has comments"

texts:
I would like to add a checkbox as an exposed filter to my view. When checked it will show all ndoes with 0 comments.

I looked at BEF but it didn't seem to be able to handle this.
I also have another exposed filter for that view, otherwise I could just hide the filter and use jquery to toggle the url when checking the checkbox.


texts: Any easy way to create Login page in Drupal 7

texts:
Most of the tuts I found want me to edit the code in template but I am not sure about editing the code, so, thought of asking is there any easy way to create Login Form in Drupal 7.

I don't want to show login block to everyone, and want to put it in some Page and visit it via uri like http://localhost/login then only the login page should show.

So, far I have made a Page called login gave it a title with empty body, Configured user-login block to be shown in content area and be displayed only in login page. So far so good, it looks cool, but the thing is: after logging in I can see the same login page as Blank Page. I did something like the login page would only be accessible by anonymous users but no luck.

My quest is either I should be able to redirect the users to main page after logging in, or have a separate login page instead of using the block which came by default with D7 installation. Any ideas ???


texts: Simple button to send users info to an email address

texts:
What would be the best route to create a button on a page that once it's clicked, it sends an email to the administrator. Basically we are using the profile percentage completion module, and when a user is at 100% I want to display a button to opt into a program (the program meaning, it sends us all of their info in their drupal account)

It seems very simple, but I can't wrap my head around this. I could definitely add the logic to where if the profile is 100%, it will display a button. It's just the button functionality that I don't know how to do. Would I write a ajax hook? create a custom module?

Any help would be appreciated!

Thanks!


texts: Shutdown functions not working on php-fpm setup?

texts:
I have a problem with drupal_register_shutdown_function(): my callback is not being called =| Here's example code:

<?php
/**
 * Implements hook_node_update().
 */
function example_node_update($node) {
  if ($node->type == 'test') {

    drupal_register_shutdown_function('_example_shutdown');
    dpm(drupal_register_shutdown_function()); // This outputs callbacks array showing that '_example_shutdown' really gets registered.
  }
}

function _example_shutdown() {
  dpm('Shutdown callback executed'); // This is not shown
}

I use php-fpm, and php.net register_shutdown_function discussion suggests to use fastcgi_finish_request() instead of register_shutdown_function() with php-fpm. Also, see this D8 issue: "Ensure register_shutdown_function() works with php-fpm". Is there any D7 workaround?

I think there could be two different approaches:

Global: Fix drupal_register_shutdown_function() to check for php-fpm environment and use fastcgi_finish_request() in that case.
Local: Use some hook to force _drupal_shutdown_function(). Maybe hook_exit() would be ok for some cases, but in my case it is too late (as my callback updates nodes, and by the time hook_exit() runs the response is already sent to the browser, so user would get an "old" node, I'm afraid).

Maybe there is something simpler that I'm missing?


texts:
I am using Drupal 6 with Ubercart 6.x-2.9. In checkout, I dont need my customers to fill out their address - I just need name and email. So I have removed the address fields within the 'Billing information' part of the form.

When the customer gets to the 'Review Order' page, it lists the name and address with the label 'Address:'. As I only have the first and last name fields, I wish to change 'Address:' to 'Name:'.

Strangely, I cant seem to find anywhere where this 'Address' label is set (I did a text search in all files and searched through the database). Can anyone help please.


texts: How to use hook_form_alter with commerce checkout

texts:
The module "commerce_checkout_buttons" alters the buttons in the commerce checkout process as seen below in using HOOK_form_alter. In this code, only the review form is being altered, but the changes seem to be global in the checkout process?

For example, the site I'm working with has a one-page checkout, and the Review pane doesn't include anything. Yet, the buttons are altered.

Can anyone explain how this works?

function commerce_checkout_buttons_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'commerce_checkout_form_checkout':
    case 'commerce_checkout_form_shipping':
    case 'commerce_checkout_form_review':
      if (isset($form['buttons']['back']['#value'])) {
        $form['buttons']['back']['#value'] = t('Back');
      }
      if (isset($form['buttons']['continue']['#value'])) {
        $form['buttons']['continue']['#value'] = t('Continue');
      }
      if (isset($form['buttons']['back']['#prefix'])) {
        unset($form['buttons']['back']['#prefix']);
      }
      if (isset($form['buttons']['cancel']['#prefix'])) {
        unset($form['buttons']['cancel']['#prefix']);
      }
      break;
  }
}


texts: Is it possible to add a CiviCRM API to the Webform CiviCRM integration module and how would I do that?

texts: If I have created a specific CiviCRM API entity/action for a project, can I then add that API to the Webform CiviCRM integration module so that I can use the API in the Webform? And how would I do that?


texts:
I am trying to write a Batch import to create nodes based on a uploaded file. The form works and I receive the file, and can read it in my submit callback which should initiate the Batch import. Here is the code:

function mymodule_import_submit(&$form, $form_state) {
  $xml = file_get_contents($form_state['values']['xml']->uri);

  $ads = xml2ary($xml);

  $batch = array(
    'title' => t('Importing Content ...'),
    'operations' => array(),
    'init_message' => t('Commencing'),
    'progress_message' => t('Processed @current out of @total.'),
    'error_message' => t('An error occurred during processing'),
    'finished' => 'mymodule_import_finished',
  );

  foreach ($nodes['nodes']['_c']['node'] as $new_node) {
    $batch['operations'][] = array('mymodule_import_create_node', array($new_node['_c']));
  }

  batch_set($batch);
}

While it seems to know the amount of operations needed (how many need to be created) my callback doesn't seem to get called. Here is its code:

function mymodule_import_create_node($new_node) {
  $clean_body = make_safe($new_node['CONTENT_BODY']['_v']);

  $node = new stdClass();
  $node->type = 'article';
  node_object_prepare($node);

  $node->title = substr(strip_tags($clean_body, 0, 20)) . '...';
  $node->body['und'][0]['value'] = $clean_body;
  $node->status = 1;
  $node->field_article_category = array();
  $node->field_article_location = '';
  $node->field_email_address = '';
  $node->uid = 1;

  node_save($node);

  $context['results']['articles_imported']++;
}

I put a few dumps at the start of the batch callback and it never exits. Watchdog indicates nothing, and no new nodes appear.


texts: How to move files, images or docs into live site on as needed basis

texts:
For several reasons we can't upload files such as images, pdfs, xls, etc., to our production server.  It has to do with another application that is wrapped around Drupal7 and the revisioning process that application/framework has.

I need a method of moving the above file types into production that is outside the normal weekly migration process.  Currently, the content editor creates content in production, recreates it in staging and attaches the images or files as needed, then when the migration from staging to prod takes place the files are moved, we link.  So, as you can image this is not optimal.

What options are available out there - I am thinking to create a folder outside of deployment and have images and files sit there.  I have tried a feeds/xparser option, but see that it is tied to the content, so seems I would need to create a feed for each type and then for new content types as they are added.

What is a good method for moving image files or syncing image/file folder from staging to production?


texts: Textfield values not being stored on form submit

texts:
Ok, so I'm working in Drupal 7 and am making a form that either inserts values in the database or updates existing information in the database.  Each row of my table has two entries, 'counter_name' and 'expected'.  Expected is the number of applicants each counter is expected to process per half hour.

What I have is:

//Get a list of counters with 'expected' set already.
  $expected = get_expected_numbers();
  //Get's a list of all counters stored in the db
  $counters = get_counter_info('not_set');
  $counter_names = array();
  $expected_names = array();
  // Here, I format both arrays so they can be diffed
  foreach ($counters as $key => $value) {
    array_push($counter_names, $counters[$key]['counter_name']);
  }
  foreach ($expected as $key => $value) {
    array_push($expected_names, $expected[$key]['counter']);
  }
  //Diff the two arrays to see what counters are there but do not have expectations set.
  $expectations_to_be_set = array_diff($counter_names, $expected_names);
  $expectations_to_be_set = array_values($expectations_to_be_set);
  //If there are any that aren't set, display them.
  if (!empty($expectations_to_be_set)){
    foreach ($expectations_to_be_set as $key => $value) {

      $form[$expectations_to_be_set[$key]] = array(
        '#type' => 'textfield',
        '#prefix' => '
',
        '#suffix' => '

',
        '#title' => $expectations_to_be_set[$key],
      );
    }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
    );

  }
  //If they are all set, display them for editing.
  else {
    foreach ($expected as $key => $value) {
      $form[$expected[$key]['counter']] = array(
        '#type' => 'textfield',
        '#prefix' => '
',
        '#suffix' => '

',
        '#title' => $expected[$key]['counter'],
        '#default_value' => $expected[$key]['apps_per_half_hour'],
      );
    }
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => 'Update',
      );
  }

function set_expectations_form_submit($form, &$form_state) {
  $values_array = $form_state['values'];
  unset($values_array['submit']);
  unset($values_array['form_build_id']);
  unset($values_array['form_token']);
  unset($values_array['form_id']);
  unset($values_array['op']);
  print_r($form_state['values']); echo '
'; print_r($values_array);
  if ($form_state['values']['submit'] == 'Submit') {
    foreach ($values_array as $key => $value) {
     $insert_expected = db_insert('floormap_counter_expected')
        ->fields(array(
          'counter_name'  => $key,
          'expected' => $value,
        ))
        ->execute();
    }
  }
  else {
    foreach ($values_array as $key => $value) {
      $update_expected = db_update('floormap_counter_expected')
      ->fields(array(
        'expected' => $value,
      ))
      ->condition('counter_name', $key, '=')
      ->execute();
    }
  }
}

So the problem I'm running into is that, first when showing the initial form for the user to set expectations for the first time, I do not display a #default_value because there isn't one yet.  When the user fills the text box and hits submit, the name of the input (the counter name) is stored but with no value.  The user's input is lost.  If I am on the edit form, where the database values are displayed as #default_value, the default value's are sent, not the user input.

Oh, also just to clarify...the reason that I am using $values_array to submit to the DB instead of just using $form_state['values'] is because I unset everything that isn't a 'counter_name' so that I can run it through a foreach loop.  Wasn't sure about just unsetting those from $form_state.  But the information doesn't show up when using $form_state either.


texts: Show title of referenced node in node template

texts:
I'm working on a node template for my content types and use Entity reference to reference my content with each other. THe machine name of my entity reference field is og_group_ref. In my node template I used print_r(get_defined_vars()) to show all existing varialbes to select variables I need. When I look for og_group_ref I only get the target_id of that reference:

[og_group_ref] => Array
            (
                [0] => Array
                    (
                        [target_id] => 65
                    )
            )

So, my question is how do I get the title of that referenced node?


texts: hook_menu - setting a variable to use in page.tpl.php

texts:
I know how to use hook_preprocess_page() to add/change variables for use in page.tpl.php. For nodes, you can use menu_get_object() to load the current node and process it from there.

How do I do this for a page I've created using hook_menu()? I've tried printing out all the $variables but there is nothing much I can identify this page with, apart from the 'theme_suggestions' which seems a bit flaky. Using arg(0) also seems like a hacky way to go.

Is there any way to set the page.tpl.php variable directly with hook_menu()? That would be ideal.

EDIT for clarification:

This is what I want to achieve:

function mymodule_menu() {

  $items['my-page'] = array(
    'title' => t('My Page'),
    'page callback' => 'mymodule_callback',
    'access callback' => TRUE,
    'page arguments' => array(),
    'page vars' => array('myvariable' => 'hello') // Obviously this doesn't work, but would be great
  );

}

function mymodule_preprocess_page(&$vars) {

  if($something === 'my-page'){ // What to do here???
     $vars['myvariable'] = 'hello';
  }

}

Basically I want something within hook_preprocess_page &$vars array to identify the route I have created with hook_menu. If I can define this somehow in hook_menu itself (or the callback) it would be even better.

I can use arg(0) but that doesn't account for any subpages, and I might want to change the route which means I need to change preprocess function too. Is there a better way?


texts:
I've created a Entity Reference from customer to contract and I created a user which can create a customer.

Now is the problem that I can't select any contract with the new user when I try to create a new customer.

The only solution I found is to give the new user the Bypass content access control permissions. But then he also can create a contract. And I don't want that user to do that.

Can anyone explain me what I'm doing wrong?


texts:
Possible Duplicate:
  enable viewing access to anonymous user

I can't remember how to make certain pages visible to the public, only blocks.  My site is private but I would like for 3-4 pages to visible to ALL users.  How would I go about implementing this?  Thanks!


texts: How can I set a default value for date field using hook_form_alter

texts: I am new to Drupal. I need to set a default value to a date field. Please anyone help me on this. Thanks.


texts:
I accidentally disabled the Course module. When I enabled it back, the taxonomy doesn't respond correctly for the course content type. When I add a course it does not link to taxonomy.

When I hit preview while editing a course I see this error message:

  Invalid argument supplied for foreach().

Here is the code:

foreach($content->taxonomy as $key => $term;){ echo "result"; }

I don't think I cause the code problem, because it worked before.  The error only occurred when when I disabled the course module.

How am I link this course back to taxonomy?


texts: Do I have to unistall the disabled modules?

texts:
I'd like to know if there is any difference between disable or uninstall modules regarding performance.

Will having 10 disabled modules affect my site performance? Will the performance be better if I uninstall them?


texts: Split an array returned by menu_tree_output

texts:
I want to display an expanded menu and split it in two columns after a certain amount of items:

Right now I have the following in my hook_block_view:

$menuTree = menu_build_tree('my-menu');
$menuOutput = menu_tree_output($menuTree);
$block['content'] = array('#markup' => drupal_render($menuOutput));
return $block;

So I would have to put some extra logic between menu_tree_output and drupal_render splitting the array after 5 items and wrapping the result in something like <div class="first_column">...

But dfb($menuOutput) gives me this huge array which I can't just array_chunk($menuOutput, 5).

Any idea how to handle this?


texts:
I have a website with some news. I create a view that shows them and filter  by category. When I use the filter, it reloads the page and goes at the top of the page. I want it doesn't move on the top of the page.

I added an anchor to the page, but I can't add it to the view redirect link. I tried implementing hook_view_form_alter() to add a custom submission handler, but it breaks the entire form and the news are not filtered.

I also looked at hook_views_query_alter(), but it doesn't seem it allow to do what I am trying to achieve.

Is there any way to do this?


texts:
function recipe_submit_schema() {
  $schema['recipe_submit'] = array(
    'description' => 'Recipe base table.',
    'fields' => array(
      'recipe_id' => array(
        'description' => 'Primary identifier for recipe.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not_null' => TRUE,
      ),
      'recipe_title' => array(
        'description' => 'Recipe Title.',
        'type' => 'varchar',
        'length' => 255,
        'default' => '',
      ),
      'author_name' => array(
        'description' => 'The author of the recipe.',
        'type' => 'varchar',
        'length' => 255,
        'default' => '',
      ),
      'author_email' => array(
        'description' => 'The author email.',
        'type' => 'varchar',
        'length' => 255,
        'default' => '',
      ),
      'recipe_description' => array(
        'description' => 'Recipe description.',
        'type' => 'text',
      ),
      'recipe_instructions' => array(
        'description' => 'Recipe instructions.',
        'type' => 'text',
      ),
      'recipe_ingredients' => array(
        'description' => 'Recipe ingredients.',
        'type' => 'text',
      ),
    ),
    'primary key' => array('recipe_id'),
  );

  return $schema;
}

gives me following error

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1171 All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead in /home/insasse/test_workspace/drupal7/includes/database/database.inc:2227                                                     [error]
Stack trace:
#0 /home/insasse/test_workspace/drupal7/includes/database/database.inc(2227): PDOStatement->execute(Array)
#1 /home/insasse/test_workspace/drupal7/includes/database/database.inc(697): DatabaseStatementBase->execute(Array, Array)
#2 /home/insasse/test_workspace/drupal7/includes/database/schema.inc(664): DatabaseConnection->query('CREATE TABLE {r...')
#3 /home/insasse/test_workspace/drupal7/includes/database/database.inc(2776): DatabaseSchema->createTable('recipe_submit', Array)
#4 /home/insasse/test_workspace/drupal7/includes/common.inc(7114): db_create_table('recipe_submit', Array)
#5 /home/insasse/test_workspace/drupal7/includes/module.inc(479): drupal_install_schema('recipe_submit')
#6 /home/insasse/.composer/vendor/drush/drush/commands/core/drupal/environment_7.inc(143): module_enable(Array)
#7 /home/insasse/.composer/vendor/drush/drush/commands/pm/pm.drush.inc(1167): drush_module_enable(Array)
#8 /home/insasse/.composer/vendor/drush/drush/includes/command.inc(422): drush_pm_enable('recipe_submit')
#9 /home/insasse/.composer/vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#10 /home/insasse/.composer/vendor/drush/drush/includes/command.inc(199): drush_command('recipe_submit')
#11 /home/insasse/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#12 /home/insasse/.composer/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#13 /home/insasse/.composer/vendor/drush/drush/drush.php(12): drush_main()
#14 {main}

What am I doing wrong?


texts: drupal commerce: issue with add to cart form and translated products

texts:
Hello I have some transtaled products with some attributes, those attributes are also taxonomy terms translated, I have a language switcher.

The "add to cart form" on the product display do not works correctly when I switch the language.

The original language of the products is spanish those products have translation to english

When I visit the product display in spanish (the original language of the products) the "add to cart form" works correctly, I can select between the different product attributes

But when I visit the product display in English then the "add to cart form" show the attributes select empty so I cannot select between the different attributes because they are not showed in the select list of the add to cart form.

This image works ok because I visit the product display in spanish (the original language of the products)

This image is when I visit the product display in english, please see the color attribute select, it is just empty, and Im sure that the translations are ok.

Any clue? why is happening this? I cannot find any related issue about this in the commerce issue queue


texts: Views how to group items with mutiple field collection fields

texts:
I can't figure how to group my content in my view.

Here is what I have, and what happen:
I have a content type "Slide" with the field "Body" a text (formatted) and a field collection called "Related content" that contains 2 fields ("Label", a simple text (plain) and "Related page", an entity reference).

I created 2 "Slide" with 2 "Related content" in each "Slide".

If I simply display "Body" and "Related content" I have each "Slide" displayed correctly, but the "Related Content" is a rendered list and I don't have access to the fields itself to rewrite the output (I want to create a link using the "Label" and the "Related page") like this:

Slide 1

Label1
Page 1
Label 2
Page 2

Slide 2

Label 3
Page 3
Label 4
Page 4

Now if I add a relationship to the field collection item, I do have access to the fields and I can rewrite the output, but now I have 1 slide for each item in the fields collection like this:

Slide 1
- Label1
Slide 1
- Label2
Slide 2
- Label3
Slide 2
- Label4

How do I keep the content grouped by Slide, and still display all the fields (not the rendered collection) so I can control the output.

Any help is welcome!


texts: Add a CSS class to a certain text field for node display

texts:
How can I add a CSS class to a certain text field?  I have a content type, "Board Member", displaying thusly, see my screen shot below if it comes through...  This is the node, not a view.  The text for "BIO" is typical paragraph style and size.  I want it slightly bigger.  The field in the content type is a "Long Text with summary".  The widget used is "Text Area with a summary".  I don't see any way to assign a unique CSS style to it in Drupal.  Investigating CSS here, Firebug only shows this:

Lorem.....

Why is it skipping showing that this field is the "bio".  The other lines of text above it "Name" and "Board Member Role" were presenting unique classes and thusly I was able to format with css class rules to make them green and large.

I don't want to depend on the user to type in text with WYSIWYG exactly the same style with each of the board members, although that can be done since I've enabled that for FULL and Filtered HTML for that field.  I just seems that I should be able to assign a CSS class to this field.  I'll be using this field for TEACHERS and STAFF later on as well.

Thanks for the help.

Dave N


texts: How to extends %module_x/templates/xyz.html.twig?

texts:
My module has a template which would like to extend another module's template. Is there any shortcut like we have in Symfony2?

{% extends 'path_to_module_x:templates/template-x.html.twig' %}


texts: Make custom field added to comments available in comment.tpl.php

texts: I added a integer list field called "field_rating" to the core comments. Now I want to use the new field directly in my comment.tpl.php with it's display settings, but I just don't know how to do that despite this should be a no-brainer. Help is much appreciated.


texts:
I have a file and I know there is a media that references it. How can I get this media?

In the opposite direction, knowing the media id, I can get the file:

$media = Media::load($mid);
$fid = $media->field_media_image->target_id;
$file = File::load($fid);

But now I know the file id and I want the media. How can I get it?


texts: Retrieve create node form. Why cant save send values?

texts:
I want to add a custom page for creating "blog post". Ive got a node blog. So I write something like this:

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

    $items['user/%/edit/blog/add'] = array(
            'title' => 'Add blog post',
            'page callback' => 'drupal_get_form',
            'page arguments' => array('module_add_blog',1),
            'access arguments' => array('createBlog'),
            'type' => MENU_CALLBACK,

    );
return $items;
}

And then in module_add_blog callback:

function module_add_blog(&$form_state, $arg) {
    $form = array();

    $id = intval($arg);
    if ($id == 0){
        drupal_set_message('ID must be an integer.' , '$error');
        return;
    }

    $user = user_load($id);
    module_load_include('inc', 'node', 'node.pages');
    $node = array('uid' => $user->uid, 'name' => $user->name, 'type' => 'blog');

    $form = drupal_retrieve_form('blog_node_form', $form_state, $node);
    drupal_prepare_form('blog_node_form', $form, $form_state);
    return $form;
}

Form is rendered in path user/1/edit/blog/add but when I send data it is NOT SAVED.

Any ideas how fix it? Thanks


texts:
I've been working playing with the Facet API Search lately and I liked a lot the option that Facet API provides to use the alias of the taxonomies in the URL.

I was wondering if there is a chance to do the same in the Views. eg to be able to use the taxonomy alias as a token to construct a link. What I would like to achieve is to be able to construct in the Views a URL that can take me to a Faceted Search page so I can pre-filter it.

I know that is a bit redundant to be doing it, but for the project I work on, is something that was specifically requested. In the Views, there is no way to be able to get the alias of a taxonomy as a field. The only things I've seen so far, is to mimic the re-writing of taxonomy using PHP code here and here .

I tried to find a module that would help use the alias but nothing had come up. Also, here in the forum, I had found similar issues but nothing related to my question about taxonomies.

How to filter a View with Taxonomy alias

Get a node alias as a field value


texts: How do I display a form element only if the above checkbox is checked?

texts:
I am about to create a blockForm with a display_count checkbox and two count_prefix and count_suffix textfields.

The count_prefix and count_suffix textfields shall only be shown if display_count is checked.

I have this code:

  $form['display_count'] = [
  '#type' => 'checkbox',
  '#title' => t('Display count'),
  '#description' => t('Display how many times each term is used on a node.'),
  '#default_value' => $config['display_count'],
];
$form['count_prefix'] = [
  '#type' => 'textfield',
  '#title' => t('Count prefix'),
  '#description' => t('Set a prefix to be displayed before count number e.g. (5), [5] or <5>'),
  '#required' => FALSE,
  '#default_value' => $config['count_prefix'],
];
$form['count_suffix'] = [
  '#type' => 'textfield',
  '#title' => t('Count suffix'),
  '#description' => t('Set a suffix to be displayed after count number e.g. (5), [5] or <5>'),
  '#required' => FALSE,
  '#default_value' => $config['count_suffix'],
];

I have tried to add this to count_prefix and count_suffix:

  '#states' => array(
    'visible' => array(
      ':input[name="display_count"]' => array(
        array('checked' => TRUE),
      ),
  ),
),

but it didn't worked.

I have tried to find other questions with the same but none of them worked for me.


texts:
Is there a way to show a "Last Updated" timestamp for nodes? Maybe even in views as well?

EDIT: Via a module or core configuration


texts: Does inactive modules can make my drupal site slower?

texts: I have some modules that Im not using and they are inactive, if I uninstall and delete those modules could I improve th performance of my site, my site is becoming very very slow, the ajax requests are slow everything is slow....


texts: How can I create a view of different entity types with common sorting?

texts:
Both, profiles and nodes (of one spec. nodetype) have the same taxonomy attached. (Using the profile module).
How to create a view of both together, profiles and nodes (of this type) to show as a result both sorted together (date created desc)?
Duplicate results with same nid must be filtered out (DISTINCT is not working in D8/9).
Part 2 of question:
Both, profiles and nodes (of one spec. nodetype) have a geolocation field (geolocation module) that contains coordinates (lat, long).
(In a view it is possible to do proximity sorting the result if it is a view of only nodes).
In this view profiles AND nodes (two different entity types) should be sorted together, sort order: proximity asc.
Is there a way to get this work if combining two different entity types in one view in Drupal 8/9?
How?


texts:
I would like to use Views PHP module in my Drupal Site.

But I don't have any idea on how to use this and I can't find good tutorial for this module.
Anyone who can suggest any references or videos for Views PHP Tutorial?


texts: How to use URL parameter and page callbacks for tab menus correctly?

texts:
I'm using Drupal 6 and I'm trying to display two tab (menus) on a page that has the URL /vehicle_info.
Both pages that the tabs link to should take a node's nid as parameter.
My current code looks as follows:

  $items['vehicle_info/%/basic'] = array(
    'title' => t('Basic & Bookings'),
    'page arguments' => array(1),
    'access callback' => 'user_access',
    'access arguments' => array('administer fleet'),
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => 10
   );
  $items['vehicle_info/%/history'] = array(
    'title' => t('Service history'),
    'page callback' => 'vehicle_service_history',
    'page arguments' => array(1),
    'access arguments' => array('administer fleet'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 20
   );

I'm running into 2 issues:

The tab "Service history" does not open the page "vehicle_service_history" (which is actually a view with the URL vehicle_service_history). It opens a page with the URL
"vehicle_info/123/history", which does not exist (123 stands for the current nid).
The default tab "Basic & Bookings" does not link to the URL "vehicle_info/123" but only to "vehicle_info".

What am I missing?


texts: Hooks Alter not called in Template.php for

texts:
I run into strange thing today. I have some custom hook declared in a custom module as following:

drupal_alter('strange_thing', $shared_var, $vars);

then in template file(template.php) I got the function:

function THEME_strange_thing_alter(&$shared_var, $vars){
    //do something with $shared_var
}

The THEME_strange_thing_alter() is called if i have unchecked " Use the administration theme when editing or creating content" in the admin/appearance in the "Administration Theme" section, but it is not otherwise.

To satisfy curiosity, I moved all the logic from tempalate.php into custom module/.module file and it works like expected...the hooks are called not matter if the box is checked or unchecked for " Use the administration theme when editing or creating content"

It would be great that the hooks work in template.php no matter if there is some box checked or unchecked in the UI. Is there way to make it so? Thank You


texts: Bypassing Drupal's htaccess rewrite for static page

texts:
I've created a site that is currently partly static while partly managed in Drupal.

I've managed to rewrite static HTML by specifying the /static directory in the following manner above Drupal's .htaccess code.

RewriteEngine on
RewriteRule ^about-us/(.*) static/about-us/$1 [L]

Though I now have a dilemma. I have a directory page which is static:

  website.com/products

but then the next level needs to go through the Drupal system:

  website.com/products/product-type

to add to complication the next level then should go back to the static directory:

  website.com/products/product-type/product

Is this possible? And if so how would you achieve it?

Notes

Please note that these do not need to be dynamic. Can easily declare 'product-type' as there will only be 3. It would be good if I didn't have to declare 'product' because there will be multiple under each 'product type'.

My temporary fix was to just use a different directory in the URL. I added 's' to 'product-type' (website.com/products/product-types) for that specific page, and then at product level went back to remove the s (website.com/products/product-type/product)


texts:
I need to implement my own search method in order to find nodes with some keywords in their title or body and with a specific type, but I don't know how to do this.

I tried with do_search() and node_search() methods but I don't get results.


texts: How to customize message in maestro mail notification

texts:
I am working on Maestro module. we have interactive tasks in the Maestro which are executed by the users to whom task is assigned. In Maestro, we can intimate the user by mail about the task assigned to him. Message in the mail is one paragraph. I want to customize this mail. I need to add table and send message in multiple pargagraphs.

I have tried adding br(I tried adding angular brackets but text after that is going to next line) in the message but message is being displayed along with br instead of going to new line.

I think html tags doesn't work there.

How to make html tags work in the custom mail or customise the message?
P.S: I am attaching the screenshot where I am writing the message


texts: Clearing the render cache after being programmatically logged in

texts:
This issue is on a Drupal 8 site.  I have no reason to think it would behave any different on Drupal 9.
We have a scenario where we are having trouble with caching of a custom block.
This block replicates the behaviour of the Login block in that it checks for an authentication state and presents either the user.login or user.logout route.
This looks to be working.
We also have a login state happening where a user account can be "Not Quite Logged In" (NQLI). We are extending Terms with an IP field and adding an IP Login User user reference field.  When a user hits the site and they are not logged in we check if their IP matches one mentioned on the Terms and if one matches the referenced user is programatically logged in.
When a NQLI user is logged in the Login block still presents a "Log in" link. This is the desired behaviour so the user can still access the login page to log in as an actual personal account.
This is working also.
When a user has accessed the site from a known IP and is logged in as a NQLI user, clicks the "Log in" link, logs in as their own account and is redirected back to the page they came from they are successfully logged in as that personal account.
This process works.
What doesn't work is that the "Log in" menu item is still present in that block on this page.  If you click off to any other page the "My account" and "Log out" links are there as expected.  If you click back to the page you logged in from it still holds the "Log in" link.
We've tried clearing the cache with \Drupal::service('cache.render')->invalidateAll(); in hook_user_login() and hook_preprocess_html().
This is one of my first Drupal 8+ projects. I've been working with Drupal since 4.6 and am very much feeling like a junior dev once again. I'm hoping that there is an obvious place or process to do this that I've just not been able to find. My google-fu has reached its limit on this one.


texts:
I'm new to drupal and would like to build a workflow with the below functionality.

I'm able to create extra states through workbench module.

But the above workflow needs to be applied for each department in the company. ex:- Library services, Finance, Tourism. Therefore each department has different content authors and department managers, but the Marketing team will be the same for the entire company.

I'm guessing there should be a way to specify the department from a dropdown menu or something (with the help of taxonomy) so that when a new node is created from a specific content type, the content creator can specify the department which it should be forwarded to.

Can anyone please tell me how I should create this through workbench?

Thanks in advance!


texts: How to add extra menu source and access it in a theme

texts:
The Menu module contains 2 sources to assign menus to my site.

How do I add a 3rd source?

Reading through the Zen theme code, I see the variables $main_menu, and $secondary_menu.

I would like to access this 3rd menu source through a variable called $global_menu.

How do I set this variable from a module?

EDIT

I put this at the bottom of the zen_proprocess_page hook in template.php

$global_menu = menu_navigation_links('menu-global-menu');

and was able to access it with this in page.tpl.php so thank you for that advice

<?php if ($global_menu): ?>

      <?php foreach ($global_menu as $key => $value): ?>

          <a href="<?php print($value["href"]); ?>" class="global-link" ><?php print($value["title"]); ?>

      <?php endforeach;  ?>

 <?php endif; ?>

EDIT

Moved multipart question to new question


texts:
This is a combobox showing a group of product referenced.

I have created an extra field in product list, short_title. How do I replace the Product Title with short_title? i.e. Chicken, Turkey, Pork, … Is this possible?

I’ve also tried Inline Form Entity. The YouTube tutorial: http://youtu.be/glRM_NzNVTA?t=5m3s : When the host edited the Variation Title, the Product Title remained unchanged. However, when I do it, the Product Title changed. Is this by design or the host was using an older version of Inline Entity Form?

I know that we can create attributes, but having a variety of product types complicates the form. All I wanted: one product type and just reference a group of product in product display.

The Product Title is too long in combo, but I can't shortened that because it's important as line-item title.

Any idea or workaround?


texts: How to reduce the speed of rotation in view ticker module

texts:
I created a view with views ticker for the newsfeed items. The newsfeed items are configured to vertical scroll with speed: very slow. But the rotation speed of the items are a bit fast and I'm inclined to reduce the speed of the rotation.
So, I looked into module files and tried to change the vTicker_speed values in the views_ticker_style_plugin.inc file located in the ../sites/all/modules/views_ticker/includes/

I changed the values in the line 142. Previously, it was 1000 - one second to 40000 - forty seconds. But I couldn't get it reflected in the site. It scrolls with same speed as it was before.
Can any one suggest me how to reduce the speed. Or is there any other module to work with vertical scroll??


texts: How to remove Upload picture lable from registration page?

texts: how to remove Upload picture lable from avatar image field.


texts: TypeError: $.ui and $element.dialog is undefined

texts:
I have been handed a site to work on. It's on 8.5.1. The site was working. However, I cannot make changes on certain configs. For example, the dialog boxes for the views do not open anymore. I keep getting the following js error under the console.

I do not want to revert the database back to a working condition since the client would lose their data.

Update: The dialog box does work very very random.


texts: How to show parent terms in view for restricted nodes categorised with child term?

texts:
I have a number of nodes with individually restricted permissions. Logged-in users only see a selection of nodes depending upon their permission roles.

My view lists the taxonomy terms of the nodes, but only shows the terms containing nodes the user has permission to see by a relationship between the term and node (which is a good thing).

However, I have some instances where the following is the case:

Parent term (no nodes visible to user in this category)
    Child term 1 (10 nodes visible to user in this category)
    Child term 2 (no nodes visible to user in this category)

And the taxonomy view only lists "Child term 1", but I would also like to list "Parent term". How is this possible?

Thanks.


texts: View page as default page for content type

texts:
This could be a noob question but i am really not able to understand how to achieve this. I have several content types and custom detail page i.e view page for each content type. So each time i add/edit/update/search a content type say news or something, it redirects me to default node page but i don't want that. I want it to redirect to the view page i have created.

There is a module called Rules, which helped me to redirect to that page after adding/updating content, but it has some redirection errors which results in server ended unexpectedly error. Also in search the default page shows up as node page not my custom view page.

How do i do this, so that my custom view page becomes the default page for my content type. Please help..?