Page 1 of 2

Displaying news articles in different ways - SOLVED

Posted: Sat Sep 22, 2007 2:55 pm
by aidank
Hi,

On my homepage I am looking to display the 5 latest stories from my news articles. I have a main news section aswell within the site. On my homepage I just want to display the article headline/link and not category/author etc.

I know I can edit content > news > summary template but that will also change the summary template within my main news section aswell which I don't want to do. I think I need either two news summary templates or else the code to just grab the headlines and display these on the homepage?

On my homepage template I have the following default code:
{news number='3' detailpage='news'}

It displays the three stories however it follows the main summary hence has category/author etc. If I edit the content > news > summary template it will have the knock on effect on the main news section.

I have tried just extracting the code from the summary template and using it on the homepage:

{$entry->titlelink}


I get the following error:
string(137) "Smarty error: [in template:20 line 102]: syntax error: invalid attribute name: '$entry->titlelink' (Smarty_Compiler.class.php, line 1536)"

I assume it is a fairly small thing I need to change and that other CMSMS users have done this in the past. I checked through the past forum posts and couldn't find the relevant so apologies if this has been answered previously.

Thanks

Aidan

Re: Displaying news articles in different ways

Posted: Sat Sep 22, 2007 3:16 pm
by RonnyK
Aidan,

why don't you create a new summary-template for the place where you don't want the author-stuff. In that template you can just delete the parts you don't want to show and call that template explicitly where you want it to be. So there is a default template in that case and a specific one that can be called, acting independitly.

Ronny

Re: Displaying news articles in different ways

Posted: Sat Sep 22, 2007 7:49 pm
by aidank
Hi Ronny,

Thanks for replying.

OK just so I am clear, should I just go to Layout > Templates and create a new template there called for arguments sake "news_list", copy in the code from the content > news > summary template and edit it as I wish taking out the author/category etc.

Then back in my original homepage template how would I include that template to only display the top 5 articles? 

Would it be something like:

{news number='5' template='news_list.tpl'}

Just want to double check I have the right idea

Thanks

Aidan

Re: Displaying news articles in different ways

Posted: Sun Sep 23, 2007 1:23 pm
by aidank
Hi

I have been messing around with the code but still no luck.

Here is my code at the moment:


Latest News
{news number='2' category='general' detailpage='news'}

This is correctly displays the last two news stories, it is the default code that comes with the CMSMC template however I have created a new template called "news_list", copied the code from the news summary template and stripped out the various pieces of code I don't need - author etc. I have looked through the forum and can't find an answer on how to include this "news_list" template hence display the news articles in a different manner.

Any ideas would be great appreciated

Thanks

Aidan

Re: Displaying news articles in different ways

Posted: Sun Sep 23, 2007 7:28 pm
by KO
You could make "yourTemplate.tpl" file from your template. Place that to /modules/News/templates directory

Call that template by  news call {news number='2' category='general' detailpage='news' summarytemplate="yourTemplate.tpl"}

Hope that helps.

K

Re: Displaying news articles in different ways

Posted: Sun Sep 23, 2007 7:48 pm
by RonnyK
KO,

why do it using files, as te NEWS-module already has multiple templates in DB, you can create summary and detail templates, as you wnat, give them a name and call them.

Ronny

Re: Displaying news articles in different ways

Posted: Sun Sep 23, 2007 9:10 pm
by KO
RonnyK

Sure. Why not.

K

Re: Displaying news articles in different ways

Posted: Mon Sep 24, 2007 8:16 am
by aidank
Hi Ronny/KO,

Thanks for the help.

Just confused on one part, Ronny when you say:

"NEWS-module already has multiple templates in DB, you can create summary and detail templates, as you wnat, give them a name and call them"

I know if you click content > News there are the default summary and detail templates. These templates are obviously editable but as you know I don't need to edit these, I need to create a new news summary template that doesn't have author/category etc. The normal default summary template will still be used in other areas of the site.

So I just can't see through the UI how to create/call these new summary and detail templates in the news module? How do I access these multiple templates in the DB so they can be used on my site?

Thanks
Aidan

Re: Displaying news articles in different ways

Posted: Mon Sep 24, 2007 8:40 am
by KO
I believe this is feature (news templates on database) of quite recent versions of CMS. maybe around version 1.1.1 or 1.1.2. I have not experience using them yet I cannot provide info how to use them but Ronny might have. Maybe you just leave the ending .tpl out.

They come as list under your "summary template" and "detail template" so if you do not see them you might need to upgrade to have them. Othervise you need to do them with files.

Do not get confused with page templates as those (and menu templates) are for different reason.

Hope this helps,

K

Re: Displaying news articles in different ways

Posted: Mon Sep 24, 2007 9:04 am
by RonnyK
Aidan,

what I meant is that you HAVE to edit the summary template, because you have to create a second one that doesnt show the author/category,

If you go to "Extensions -> News -> Summary template" you can "Create A New Template"

In that screen you can give it a name f.e. "aidan.tpl", and delete:

Code: Select all

<div class="NewsSummaryCategory">
	{$category_label} {$entry->category}
</div>

{if $entry->author}
	<div class="NewsSummaryAuthor">
		{$author_label} {$entry->author}
	</div>
{/if}
Call {news summarytemplate="aidan.tpl"} or the other name, but make sure that the template-name has .tpl at the end.

Ronny

Re: Displaying news articles in different ways

Posted: Mon Sep 24, 2007 9:06 am
by RonnyK
KO,

for your information, coming from the help of News:
Since version 2.3 News supports multiple database templates, and no longer supports additional file templates. Users who used the old file template system should follow these steps (for each file template):

Copy the file template into the clipboard
Create a new database template (either summary or detailed as required). Give the new template the same name (including the .tpl extension) as the old file template, and paste the contents.
Hit Submit
So I think (I didnt't test is though) that additional file-templates don't work anymore at all.

Ronny

Re: Displaying news articles in different ways

Posted: Mon Sep 24, 2007 9:22 am
by KO
Ronny,

This is definately something I need to look into soon. I saw it on some test installation I have on one of my computers but never really played with it yet. Upgrade without knowing this could cause some surprises.

Thanks for this.

k

Re: Displaying news articles in different ways

Posted: Mon Sep 24, 2007 10:29 am
by alby
KO wrote:
This is definately something I need to look into soon. I saw it on some test installation I have on one of my computers but never really played with it yet. Upgrade without knowing this could cause some surprises.
Search in forum for a small patch for News 2.3.X for use template db and file

Alby

Re: Displaying news articles in different ways

Posted: Mon Sep 24, 2007 12:01 pm
by aidank
Hey Guys,

Thanks for replying in such detail - much appreciated!

OK I am running CMSMS version 1.0.7 so when I click on Extensions tab, there is no News option to click on to add the new summary template. Do I need to upgrade my version of CMSMS or do I need to download the patch for News 2.3.X for use template db and file?

Aidan

Re: Displaying news articles in different ways

Posted: Mon Sep 24, 2007 12:09 pm
by RonnyK
Aidan,

for the versions before 1.1, you have to fill the template in a file and store it in the folder mentioned in the Help of News. You can call it than with the same code I showed earlier "summarytemplate*****".

Upgrading might be wise as well, 1.1.3.1 is the latest stable and specifically some security-issue are the reason for the newer releases.

Ronny