Pcfr43k
01-27-2010, 04:31 PM
I have a website that uses a foreach to display all items in a row.
Now I want to inject some code trough these rows.
Here is the foreach code of the website:
{foreach item=job from=$jobs}
<div class="{cycle values='row,row-alt'}">
<span class="row-info">
<img src="{$BASE_URL}_templates/{$THEME}/img/icon-{$job.type_var_name}.png" alt="{$job.type_name}" />
<a href="{$BASE_URL}{$URL_JOB}/{$job.id}/{$job.url_title}/" title="{$job.title}">{$job.title}</a> <span class="la">{$translations.homepage.at}</span> {$job.company}{if $job.is_location_anywhere}, {$translations.jobs.location_anywhere}{else} <span class="la">{$translations.homepage.in}</span> {$job.location}{/if}
</span>
<span class="time-posted"><img src="{$BASE_URL}_templates/{$THEME}/img/clock.gif" alt="" /> {$job.created_on}</span>
</div>
{/foreach}
(This realy works on the website :p)
This looks like this in the output:
(Fulltime)(Title with URL)(Location)---(space)---(Clock)(posttime)
How can I inject some code after every 5 entries?
So instead of a long list you get this:
(Fulltime)(Title with URL)(Location)---(space)---(Clock)(posttime)
(Fulltime)(Title with URL)(Location)---(space)---(Clock)(posttime)
(Fulltime)(Title with URL)(Location)---(space)---(Clock)(posttime)
(Fulltime)(Title with URL)(Location)---(space)---(Clock)(posttime)
(Fulltime)(Title with URL)(Location)---(space)---(Clock)(posttime)
---(code to be implemented)---
(Fulltime)(Title with URL)(Location)---(space)---(Clock)(posttime)
(Fulltime)(Title with URL)(Location)---(space)---(Clock)(posttime)
...
Can this be done by another foreach that goes before this foreach?
Or an array that goes +1 for every "each" and when reaching 5 it gets reset and injects some code?
I have a hard time on this because I can't find any scripts of this nature.
Now I want to inject some code trough these rows.
Here is the foreach code of the website:
{foreach item=job from=$jobs}
<div class="{cycle values='row,row-alt'}">
<span class="row-info">
<img src="{$BASE_URL}_templates/{$THEME}/img/icon-{$job.type_var_name}.png" alt="{$job.type_name}" />
<a href="{$BASE_URL}{$URL_JOB}/{$job.id}/{$job.url_title}/" title="{$job.title}">{$job.title}</a> <span class="la">{$translations.homepage.at}</span> {$job.company}{if $job.is_location_anywhere}, {$translations.jobs.location_anywhere}{else} <span class="la">{$translations.homepage.in}</span> {$job.location}{/if}
</span>
<span class="time-posted"><img src="{$BASE_URL}_templates/{$THEME}/img/clock.gif" alt="" /> {$job.created_on}</span>
</div>
{/foreach}
(This realy works on the website :p)
This looks like this in the output:
(Fulltime)(Title with URL)(Location)---(space)---(Clock)(posttime)
How can I inject some code after every 5 entries?
So instead of a long list you get this:
(Fulltime)(Title with URL)(Location)---(space)---(Clock)(posttime)
(Fulltime)(Title with URL)(Location)---(space)---(Clock)(posttime)
(Fulltime)(Title with URL)(Location)---(space)---(Clock)(posttime)
(Fulltime)(Title with URL)(Location)---(space)---(Clock)(posttime)
(Fulltime)(Title with URL)(Location)---(space)---(Clock)(posttime)
---(code to be implemented)---
(Fulltime)(Title with URL)(Location)---(space)---(Clock)(posttime)
(Fulltime)(Title with URL)(Location)---(space)---(Clock)(posttime)
...
Can this be done by another foreach that goes before this foreach?
Or an array that goes +1 for every "each" and when reaching 5 it gets reset and injects some code?
I have a hard time on this because I can't find any scripts of this nature.