Hook in jojo_cart_transaction_report.tpl

Hook in jojo_cart_transaction_report.tpl, a forum discussion on Jojo CMS. Join us for more discussions on Hook in jojo_cart_transaction_report.tpl on our Plugin Support forum.

Back to Forum Index : Back to Plugin Support   RSS
Rick Rick

11 Aug 2012
Posts: 336

I'm trying to use the "jojo_cart_transaction_report_td" hook in jojo_cart/templates/jojo_cart_transaction_report.tpl and it's not working as hoped.

I can't access $transaction in there, and I realise that Dwoo handles the assignment of vars different to Smarty (Smarty did it better) but does anyone have this working under Dwoo?
antony

14 Aug 2012
Posts: 17

Hi Rick,

I did some work with hooks when I was working on a calendar plugin. I hooked into the from process in my calendar class file.

Are you hooking into it in a template? If so it may be a mater of scope as the hook declaration is just like a function declaration. Check what is being passed to the hook.

cheers,
Antony
Rick Rick

15 Aug 2012
Posts: 336

Hi Antony,

I'm trying to use a hook (jojo_cart_transaction_report_td) from within a template in jojo_cart_transaction_report.tpl to pull in another template from my theme to show more information.

I've done this successfuly using the new hooks I added to jojo_cart_transaction_list.tpl and it works. I can access the $order variable and display what I need to.

But when I try to do the same with jojo_cart_transaction_report_td I can't get access to the $transaction variable. It is within a loop while the other one isn't, but I'm not sure if that's the difference.

I'll keep testing and see what I come up with.
Rick Rick

15 Aug 2012
Posts: 336

Even trying to output {$transaction.id} shows nothing as the error "Undefined index: transaction" gets added to the event log. My current bet is on it being in a loop, but I'm not sure.
antony

15 Aug 2012
Posts: 17

Hi Rick,

Accessing a hook in a template thats awesome!

I would check the scope and confirm that $transation is actually available - you check the declaration of the hook function - you could go print_r($transaction) and wrap it in pre tags that would give you a clear idea of the data structure for it (outside the loop and in a dev environment).

cheers,
Antony
Rick Rick

15 Aug 2012
Posts: 336

Thanks Antony... hooks within templates are awesome... back with Smarty you could have hook within a template that would call your class which could then ->assign() stuff... which made it great for only loading/assigning sidebar stuff when the template was going to use it. So you could have the "is this displayed or not?" logic in the template and only load the data if needed. Sadly this doesn't work with Dwoo.

I'm also experimenting with lazyloading after Jai mentioned it at the meetup. Though I started off writing a lazy loader and that progressed into a custom query builder that would automatically lazyload data from dblist and many2many fields only when it was needed. I'd like to scale it back to a simple lazyloader to attach to applicable fields before assigning a dataset to Dwoo.

I'll try the debug dump you mentioned, I hadn't thought that the class function called by the hook would have access to the template vars, so I just never tried it.
Rick Rick

21 Dec 2012
Posts: 336

I thought I'd already posted this but it looks like I didn't. Smarty and Dwoo handle their scopes differently. The jojo_cart_transaction_report_td worked perfectly with Smarty, but using Dwoo doesn't give you the scope you need and you can't access the required data.

I looked into Smarty3 ages ago and it looked very promising (especially being able to assign objects for use in templates) but it still used way more memory than Dwoo.
Back to Forum Index : Back to Plugin Support   RSS
You must be logged in to post a reply



You need to Register or Log In before posting on these forums.