Page 1 of 1

[SOLVED] ListIt2: Smarty in fields? 2 instances on one page?

Posted: Fri May 02, 2014 10:22 am
by reinhardmohr
Hi,

thanks for the module ListIt2 that I have learned to like a lot. It's really helpful and flexible.
I use ListIt2 1.4.1 on a website with CMSms 1.11.10. Now I have run into two problems that I cannot solve myself. I have searched the forum but couldn't find a solution here, too.

I‘d be glad if someone could help me:

1) A smarty tag in a ListIt field is not processed. E.g.: When I make my clients enter their mail address as

Code: Select all

{mailto address='a@b.com' encode='javascript'}
this is not processed but the complete string is displayed on the web page.
The same is true when I use a wysiwyg editor in a text area field and apply the cms selflinker: I produces a link but the smarty tag within this link is not processed at all.

2) I have two instances of ListIt2 on my website. Both work fine. But when I insert both tags into one page template only one instance is displayed properly. The second instance has obviously been processed by the appropriate ListIt2 template. But all the content (the text in the fields) has gone.

Could someone kindly give me a hint?
Thanks a lot

Reinhard

Re: ListIt2: Smarty in fields? Two instances on one page?

Posted: Fri May 02, 2014 10:28 am
by velden
1: use smarty eval for that

Btw, I think it's not good practice to ask users to enter those code/tags.

Why don't you just ask them to enter their email address and let the template take care of the rest?

2: I leave that to someone else.

Re: ListIt2: Smarty in fields? Two instances on one page?

Posted: Fri May 02, 2014 10:30 am
by uniqu3
To process smarty use {eval} (http://www.smarty.net/docs/en/language. ... n.eval.tpl)

For your second problem i guess Smarty variables in LI2 templates collapse, depends how you are using this, how your calls look like or LI2 templates, so it's mor of a wild guessing.

You could try replacing variables in second instance templates so instead of {foreach $items as $item} something like {foreach $items as $whatever} and replace {$item->something} in foreach with {$whatever->something}

Re: ListIt2: Smarty in fields? Two instances on one page?

Posted: Fri May 02, 2014 1:00 pm
by reinhardmohr
Thanks for helping.

for problem 1) So smarty eval seems to be the solution. I tried around a little bit but couldn't get it to work for now – but I am not a smarty guru and I will surely work it out with some trial and error.

for problem 2) As soon as possible I will modify the template as uniqu3 has proposed it. Thanks. This may take a while but I will let you know.

Velden: I tried hard to make my customers type their mail addresses in content pages as this mailto-smarty-tag. So I thought they should do this again in the ListIt fields. How else could I provide them with a safe mail address on a regular content page?
Thanks for your idea to have the template do the work for changing the client submitted mail address to a safe smarty tag: I split the text area that included the mail address into text-field-one, mail-field and text-field-two. And then combined the three fields in the template while inserting the necessary smarty code to make the mail address safe.

Thanks you all

Reinhard

Re: [SOLVED] ListIt2: Smarty in fields? 2 instances on one p

Posted: Fri May 02, 2014 1:48 pm
by velden
{eval var=$item->email} (or whatever the alias of that field is)

2: for normal page content it would involve Event Manager and an UDT with some 'fancy' search/replace code. Beyond scope probably.