Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to add a class based on the field value I used in commerce order view. I have tried a solution from here I have installed "devel" module and already enabled it. However, I cannot find the dpm() result from my admin order page. I don't know if it is because of my code or dpm() function.

Here is my code and put them in my theme's template.php file::

function MYTHEME_preprocess_views_view_list(&$vars) {
    if ($vars['view']->name == 'commerce_backoffice_orders' && $vars['view']->current_display == "Admin Page") {
        dpm($vars); //uncomment to see variables
        foreach($vars['view']->result as $key => $value){
             $timestamp = $value->node_created;
             if ($timestamp) { // add whatever conditional logic you need here
             $vars['classes_array'][$key] .= ' hello'; // note the space in front of class
             }
         }
     }
}

Here is a screenshot: enter image description here

Does anyone have any idea about my issue? Thank you for anyone's help~~~~

share|improve this question
    
If you are not using the site administrator account check the permissions page and see if the "Access developer information" permission is grated to your role. Just to make sure that your hook is being called add a die() call and see if your page is still being loaded or not. Also, can you add a screenshot of the whole view configuration? – OPTASY Canada 17 mins ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.