Summary Template for News

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
User avatar
kerryshamblin
Forum Members
Forum Members
Posts: 87
Joined: Wed Apr 14, 2010 5:21 pm

Summary Template for News

Post by kerryshamblin »

I recently discovered that a Summary Template for News stopped working. The attempt was to call certain news articles that were defined by a field definition called "story." Here is the template code:

Code: Select all

<ul>
{foreach from=$items item=entry} 
{if isset($entry->story)}
<li>
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}">{eval var=$entry->story}</a></li>
{/if}
{/foreach}
</ul>
Something must have changed to break this, but I have no idea what. Any help would be great. Thank you!
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1973
Joined: Mon Jan 29, 2007 4:47 pm

Re: Summary Template for News

Post by Jo Morg »

If you have made a recent upgrade, it may account for it. You have a problem with the syntax of that code:

Code: Select all

<ul>
{* foreach from=$items item=entry *}{* replace this with the following *}
{foreach from=$items item='entry'}{* notice the single quotes on entry *}
{if isset($entry->story)}
<li>
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}">{eval var=$entry->story}</a></li>
{/if}
{/foreach}
</ul>
HTH
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
kerryshamblin
Forum Members
Forum Members
Posts: 87
Joined: Wed Apr 14, 2010 5:21 pm

Re: Summary Template for News

Post by kerryshamblin »

Thanks, Jo Morg!

I made that correction, cleared cache, but still not getting the list of "story" to display. Here's what I have now:

Code: Select all

<ul>
{foreach from=$items item='entry'} 
{if isset($entry->story)}
<li>
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}">{eval var=$entry->story}</a></li>
{/if}
{/foreach}
</ul>
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1973
Joined: Mon Jan 29, 2007 4:47 pm

Re: Summary Template for News

Post by Jo Morg »

Ok next suggestion is:

Code: Select all

<ul>
{print_r|$items:0}
{foreach from=$items item='entry'}
{print_r|$entry:0}
{print_r|$entry->story:0}
{if isset($entry->story)}
<li>
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}">{eval var=$entry->story}</a></li>
{/if}
{/foreach}
</ul>
This will give some clues of what might be on those variables if anything.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
kerryshamblin
Forum Members
Forum Members
Posts: 87
Joined: Wed Apr 14, 2010 5:21 pm

Re: Summary Template for News

Post by kerryshamblin »

I get a syntax error:

Syntax error in template "module_db_tpl:News;summaryStories" on line 2 "{print_r|$items:0}" - Unexpected "$", expected one of: "identifier" , "@"
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1973
Joined: Mon Jan 29, 2007 4:47 pm

Re: Summary Template for News

Post by Jo Morg »

Argh! Sorry my bad!!!

Code: Select all

<ul>
{$items|print_r:0}
{foreach from=$items item='entry'}
{$entry|print_r:0}
{$entry->story|print_r:0}
{if isset($entry->story)}
<li>
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}">{eval var=$entry->story}</a></li>
{/if}
{/foreach}
</ul> 
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
kerryshamblin
Forum Members
Forum Members
Posts: 87
Joined: Wed Apr 14, 2010 5:21 pm

Re: Summary Template for News

Post by kerryshamblin »

No problem! Here's what displays now:

Array ( ) 1
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1973
Joined: Mon Jan 29, 2007 4:47 pm

Re: Summary Template for News

Post by Jo Morg »

Apparently you have a different problem, maybe with the tag call, as that means that the results array is empty.
Check and double check the News tag call, and any parameter (filter, category, etc) that may prevent the results from coming through.
Additionally check if you have any settings on news regarding expiration dates, etc.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
kerryshamblin
Forum Members
Forum Members
Posts: 87
Joined: Wed Apr 14, 2010 5:21 pm

Re: Summary Template for News

Post by kerryshamblin »

Thank you for the tips. Here is my tag call:

{news summarytemplate="Stories" sortby="start_time" detailpage="newsletter-page" sortasc="true"}

The News items I have checked as "story" are using an expiration date, as I couldn't figure out how in a call tag to display items based on a field definition (in this case, 'story'.) So all of my "story" news items I used an expiration date, set the start date to reflect the order in which I wanted to display the stories and set the end date as far ahead as possible (2027-2028.)

As far as settings re: expired articles. I have:

The number of days (by default) before an article expires (if expiry is selected): 2000
Expired articles can appear in search results: Yes
Expired articles can be viewed in the detail view: Yes
If enabled, expired articles can be viewed in detail mode (this is reproducing older functionality). the showall parameter can be used on the URL (when not using pretty urls) to also indicate that expired articles can be viewed : Yes

Also, the field definition "story" is a text input. The title of the news article gets entered, and it was working before to display the News Article title in that "story" list.

Thank you so much for your help.
User avatar
kerryshamblin
Forum Members
Forum Members
Posts: 87
Joined: Wed Apr 14, 2010 5:21 pm

Re: Summary Template for News

Post by kerryshamblin »

FYI.
CMS Version 1.11.10
News 2.14.2
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1973
Joined: Mon Jan 29, 2007 4:47 pm

Re: Summary Template for News

Post by Jo Morg »

My problem here is the following:
{$items|print_r:0} should be filled with articles regardless of {if isset($entry->story)}...
If {$items} doesn't have nothing there is nothing to iterate through...
You may need to do some more debugging, such as start with just {news} and adding parameters, one at the time, and see the outcome at every change.
If a simple {news} tag doesn't show anything then you may need to set debug mode in config.php, but if it does, then the problem may be earlier on the template "Stories" or on the call...
Also note that Smarty is case sensitive since version 3 and an upgrade in CMSMS versions might trigger these kind of issues.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Summary Template for News

Post by Rolf »

Try to remove sortby="start_time" from the module tag
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
kerryshamblin
Forum Members
Forum Members
Posts: 87
Joined: Wed Apr 14, 2010 5:21 pm

Re: Summary Template for News

Post by kerryshamblin »

Rolf, thank you. When I removed that part of the call tag, the page completely broke! Nothing displayed at all.
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am

Re: Summary Template for News

Post by applejack »

Have you tried {$entry->fieldsbyname.story}
psy
Power Poster
Power Poster
Posts: 463
Joined: Sat Jan 22, 2005 11:19 am

Re: Summary Template for News

Post by psy »

Try {News....} instead of {news...}
Post Reply

Return to “Modules/Add-Ons”