Use template loader object within template

#41 · closed · 2 comments

View on GitHub ↗

wetory

Hello is it possible to use template loader inside template that is called within get_template_part function? For example, template for table which iterates data and load row template for every item. Thank you in advance.

Comments

GaryJones

It's fairly simple code, and ultimately, just a basic class. I've not tried it, but I think that each template lookup is done independently of any other, so the effort to nest these lookups _should_ work - but please try and let me know!

alanef

@wetory yes - I do this all the time ```php $template_loader = new Template_Loader(); $template_loader->set_template_data( array( 'template_loader' => $template_loader, // and what ever ) ); ``` then in the template you can use ```php $data->template_loader->get_template_part( 'whatever'); ``` Works fine