News Module Smarty Logic

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
8bits
Forum Members
Forum Members
Posts: 11
Joined: Tue Apr 01, 2008 7:54 am

News Module Smarty Logic

Post by 8bits »

Hi there,

I'm hoping someone can help me out with a bit of Smarty logic in the News module.

What I am trying to do is create a template that has two parts to it. The first has some HTML that displays the latest news article in an unordered list with class="active" on the first . This needs to appear once, and can't be repeated on the other li's.

The next two news items can be displayed using the standard foreach loop. As I don't know Smarty that well, I just need some guidance as to what syntax I would use to achieve this. (Displaying the first article outside the loop, but having the loop continue to display the next two articles in the correct sequence.) It's almost working OK, but the first article is displaying a heading from another news section, with a summary from another news article. It's also displayinh 4 headings instead of three.

The template I am using is as follows:


{if isset($entry->fields)}
  {foreach from=$entry->fields item='field'}
   
        {if $field->type == 'file'}
{$entry->titlelink}

          file_location}/{$field->value}" alt="News Photo"/>
        {else}
          {$field->name}: {eval var=$field->value}
        {/if}
  {/foreach}
{/if}

{foreach from=$items item=entry}
{$entry->titlelink}

{if isset($entry->fields)}
  {foreach from=$entry->fields item='field'}
   
        {if $field->type == 'file'}
          file_location}/{$field->value}" alt="News Photo"/>
        {else}
          {$field->name}: {eval var=$field->value}
        {/if}
  {/foreach}
{/if}
{/foreach}






More top news stories >>


{$entry->title}
{eval var=$entry->summary}

{$entry->morelink}
 

{foreach from=$items item=entry}

More top news stories >>


{$entry->title}
{eval var=$entry->summary}

{$entry->morelink}
 

{/foreach}

Hope that all makes sense!

Thanks,

Nick.
Post Reply

Return to “Modules/Add-Ons”