Post by florina » Wed Nov 01, 2017 11:15 pm

Hello
Is there a reference list of available twig variables? Both front-end and back-end.

Newbie

Posts

Joined
Wed Apr 09, 2014 2:32 am

Post by yodapt » Thu Nov 02, 2017 2:29 am

No there isn't, but it's fairly easy to know what you can use if you have minimal understanding of PHP.

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by straightlight » Thu Nov 02, 2017 2:58 am

One way to start would be by using this free extension: https://www.opencart.com/index.php?rout ... n_id=31419 . Another way to start would be by looking into your install/opencart.sql file where all field names may correspond to each variable names on the platform.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by IP_CAM » Fri Aug 07, 2020 6:33 am

See all variables available in twig templates in Opencart
https://webocreation.com/blog/how-to-see-all-variables/

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by letxobnav » Fri Aug 07, 2020 1:35 pm

It is much simpler to list out the $data array before it is passed to the view as that will also visualize structures so you know if a variable is a string, boolean, array,etc. and give you the contents as well.

Simply add just before any call to the view like:

Code: Select all

$this->response->setOutput($this->load->view('product/product', $data));

Code: Select all

If (TWIG_PRINT_DATA_STRUCTURE) {
	$this->log->write('data structure to view: product/product'.print_r($data,true));
}
then add a constant in your config.php so you can switch it on and off relatively quickly

Code: Select all

// print data passed to view to the oc error log
define('TWIG_PRINT_DATA_STRUCTURE',	true);

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan
Who is online

Users browsing this forum: Majestic-12 [Bot] and 60 guests