News Module Summary template

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Idan023
New Member
New Member
Posts: 1
Joined: Mon Apr 27, 2015 1:32 pm

News Module Summary template

Post by Idan023 »

I have a question about the news module..and i cant seem to find the answer by googling or here.. my apologies if it is on here and i searched wrong..

Anyway:

I made a summary template that shows all the news articles (all categories) as links under eachother... like in the added image...
newsblok.jpg
newsblok.jpg (20.45 KiB) Viewed 932 times
Now i want to add a different image icon to each category...
So that if the news article is for example "music" it shows a different icon than if the article is "general" or "art"..

how would i do that?

at the moment the summary template looks like this
{foreach from=$items item=entry}
<div class="News">

<div id="morenews">
<img src="/images/arrow.png"><a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}">{$entry->title|cms_escape}</a>
</div>

{/foreach}
Here i just put the same image in front of all the links (the image doesnt show because its not uploaded), which also works fine, but i would prefer a category related image..

im using CMS Made Simple™ 1.9.4.1 "Faanui" (its an website i havent worked on in a while, just picked it up today)
staartmees
Power Poster
Power Poster
Posts: 1049
Joined: Wed Mar 19, 2008 4:54 pm

Re: News Module Summary template

Post by staartmees »

update your core and modules asap for security and stability as your version normally isn't supported anymore, http://forum.cmsmadesimple.org/viewtopi ... 40&t=30336
HarmO
Power Poster
Power Poster
Posts: 251
Joined: Thu Jan 26, 2012 3:22 pm
Location: Belgium

Re: News Module Summary template

Post by HarmO »

I haven't tried it, but here are my thoughts.

You could create an image for every category and name them after your category's alias (assuming is has an alias). These images you than place on your hosting, for example under "uploads/images/newsicons"

next you can change your code to

Code: Select all

{foreach from=$items item=entry}
<div class="News">
<div id="morenews">
  <img src="{uploads_url}/images/newsicons/{$entry->alias}.jpg">
  <a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}">
    {$entry->title|cms_escape}
  </a>
</div>
<div> {* <-- You forgot to close this one !! *}
{/foreach}
If you cant find the category alias, you could try {$entry->title|escape:'url'}

Hope you can work with it.
Kind regards,
HarmO
Post Reply

Return to “Modules/Add-Ons”