Using object methods in smarty tags

bernie.schelberg
bernie.schelberg's picture

Joined: 2009-12-04
Posts: 3
Posted: Tue, 2009-12-22 19:37

Hi,
I'm developing a new module to link YouTube videos in Gallery, and have a problem accessing object methods from within my template. I've copied code from the ItemAddFromWeb and ItemAddLinkItem modules. In the template, I've changed this line (from ItemAddFromWeb):
<input type="checkbox" id="cb_{$idCount}"
name="{g->formVar var="form[webPageUrls][`$url.url`]"}"/>
to:
<input type="checkbox" id="cb_{$idCount}"
name="{g->formVar var="form[videoIds][`$videoEntry->getVideoId()`]"}"/>
I'd like to call the object method on the $videoEntry object, but this is what I'm getting in my html:
<input type="checkbox" id="cb_1"
name="g2_form[videoIds][`->getVideoId()`]"/>
I've tried with and without the backquotes, with a full stop and the method accessor. I'm relatively new to Gallery development, and smarty tags as well, so I'm not sure which system my question relates to.
Can anyone explain how to access the method?
Thanks,
[b]Bernie

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2009-12-22 22:22
 
bernie.schelberg
bernie.schelberg's picture

Joined: 2009-12-04
Posts: 3
Posted: Tue, 2009-12-22 23:01

Ok, [i]I figured it out... just needed to use the cat modifier:
<input type="checkbox" id="cb_{$idCount}"
name="{g->formVar var="form[videoIds]["|cat:$videoEntry->getVideoId()|cat:"]"}"/>
Cheers,
Bernie

 
bernie.schelberg
bernie.schelberg's picture

Joined: 2009-12-04
Posts: 3
Posted: Tue, 2009-12-22 23:11

@suprsidr: Almost, but I'd like something that works cleaner than jamming HTML into the description field, but thanks for the suggestion.
Cheers,
Bernie