0

I'm trying to create a template for a block that I created at Views. So this View (block) has some filters in it, and if I use the default template layout lists my products as it should. My problem is that when I use a custom template, I don't know how to access to those products variables inside that block. I tried to find that variable using get_defined_vars() but was impossible because it display a huge list of vars, and yes, products are there, in an array called 'rendered_content', but I can't figure out the path to that variable in the huge list that is printed.

Please, help this desperate soul.

  • 1
    I am little confused do you have problems in overriding the views block template or debugging of the available options on template making you problem. – arpitr Oct 9 '13 at 20:11
0

use devel module for better debugging option.Devel module provides dpm() which will make the array structure easy to see.When you know the exact array key where your content lies, its better to check the output with that key instead of dumping the complete vars.

so better you first do dpm(get_defined_vars());after installing devel module it will return the same what you are seeing now but in a well structure way, when you figure out the next better key of output holding the data,use dpm() on the returned array with useful key

  • I'm looking a better solution, I don't know if I can use a funciont or API (from Commerce) to access directly to that var. Like $producst = commerce_get_products_queried(); instead of have $products = $view['a']['b']['c']['d']['e']->content['rendered_content']. – nikoskip Oct 10 '13 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.