RE: [SMARTY] RE: Assigning to variables
| From: | Lambert, Patrick | Date: | Thu, 19 Aug 2004 15:46:26 +0000 |
| Subject: | RE: [SMARTY] RE: Assigning to variables | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-11708@lists.php.net to get a copy of this message | ||
Sorry, I though you wanted to capture each iteration individually.
But your catCap example looks like it does what you want, no? Alternately,
if you just want to capture everything at once, you can move the capture
outside the section.
After the capture you are free to concatenate $catCap or $smarty.capture.cap
onto whatever else you want
(http://smarty.php.net/manual/en/language.modifier.cat.php).
p.
> ----------
> From: Jake Stride
> Sent: Thursday, August 19, 2004 3:10 AM
> To: Lambert, Patrick; smarty-general@lists.php.net; 'Jake Stride'
> Subject: Re: [SMARTY] RE: Assigning to variables
>
> Thanks this should work, but how would I go about concatinating the output
> to another value? Ie I want to build up a string:
>
> $var = $var1.$var2;
>
> {section name=dataloop loop=$data}
> {capture name="cap"}
>
> {$data[dataloop].FOO}
>
> {/capture}
> {$catCap|cat:$smarty.capture.cap}
> {/section}
>
> {$catCap}
>
> On 18/8/04 10:44 pm, "Lambert, Patrick" <Patrick.Lambert@noggin.com>
> wrote:
>
> > Capture should work...
> >
> ˜£ß^ÍØ
> )·6&²…http://smarty.php.net/manual/en/language.builtin.functions.php#LANGUAGE.FU
> NC
> > TION.CAPTURE
> >
> > You can dynamically name your capture by concatenating the section index
> > value into it....
> >
> > {section name=dataloop loop=$data}
> > {capture name="cap"|cat:$smarty.section.dataloop.index}
> >
> > {$data[dataloop].FOO}
> >
> > {/capture}
> > {/section}
> >
> > {$smarty.capture.cap0}
> > {$smarty.capture.cap1}
> >
> > p.
> >
> >> ----------
> >> From: Jake Stride
> >> Sent: Wednesday, August 18, 2004 5:18 PM
> >> To: smarty-general@lists.php.net
> >> Subject: Assigning to variables
> >>
> >> I have had a look at the faqs and done a search on google, but can't
> seem
> >> to
> >> solve this question.
> >>
> >> I have a template that iterates over an array using a section, the
> problem
> >> is that I would like to parse some of the variables so that I can use
> them
> >> later on in the template. Below is a cut down version of the template:
> >>
> >> {section name="view" loop=$view_data}
> >>
> >> {if isset($view_data[view].newmodule)}<a
> >>
> href="{$serverRoot}/?{$sessionName}={$sessionValue}&module={$view_data
> >> [v
> >>
> iew].newmodule}&function={$view_data[view].newfunction}&sub={$view
> >> _d
> >>
> ata[view].newsub}&type={$view_data[view].newtype}&view={$view_data
> >> [v
> >> iew].newview}&id={$view_data[view].newid}"><img
> >> class="new"
> >> src="{$serverRoot}/themes/{$theme}/graphics/news.gif"
> >> alt="{$view_data[view].newname}" /></a>{/if}
> >>
> >> {/section}
> >>
> >> What I want to do is something like:
> >>
> >> {section name="view" loop=$view_data}
> >>
> >> {assign var="uselater" value="}<a
> >>
> href="{$serverRoot}/?{$sessionName}={$sessionValue}&module={$view_data
> >> [v
> >>
> iew].newmodule}&function={$view_data[view].newfunction}&sub={$view
> >> _d
> >>
> ata[view].newsub}&type={$view_data[view].newtype}&view={$view_data
> >> [v
> >> iew].newview}&id={$view_data[view].newid}"><img
> >> class="new"
> >> src="{$serverRoot}/themes/{$theme}/graphics/news.gif"
> >> alt="{$view_data[view].newname}" /></a>"}
> >>
> >> {/section}
> >>
> >> ...
> >>
> >> {$uselater}
> >>
> >> Obviously this doesn't work so is there some way around this or do I
> need
> >> to
> >> use another template?
> >>
> >> Thanks
> >>
> >> Jake
> >>
> >>
> >
>
>