Page 1 of 2
Summary Template for News
Posted: Thu Aug 07, 2014 12:07 pm
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!
Re: Summary Template for News
Posted: Thu Aug 07, 2014 12:13 pm
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
Re: Summary Template for News
Posted: Thu Aug 07, 2014 12:24 pm
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>
Re: Summary Template for News
Posted: Thu Aug 07, 2014 12:32 pm
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.
Re: Summary Template for News
Posted: Thu Aug 07, 2014 12:35 pm
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" , "@"
Re: Summary Template for News
Posted: Thu Aug 07, 2014 12:40 pm
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>
Re: Summary Template for News
Posted: Thu Aug 07, 2014 12:42 pm
by kerryshamblin
No problem! Here's what displays now:
Array ( ) 1
Re: Summary Template for News
Posted: Thu Aug 07, 2014 12:54 pm
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.
Re: Summary Template for News
Posted: Thu Aug 07, 2014 1:11 pm
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.
Re: Summary Template for News
Posted: Thu Aug 07, 2014 1:14 pm
by kerryshamblin
FYI.
CMS Version 1.11.10
News 2.14.2
Re: Summary Template for News
Posted: Thu Aug 07, 2014 1:43 pm
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.
Re: Summary Template for News
Posted: Thu Aug 07, 2014 9:57 pm
by Rolf
Try to remove sortby="start_time" from the module tag
Re: Summary Template for News
Posted: Fri Aug 08, 2014 1:36 am
by kerryshamblin
Rolf, thank you. When I removed that part of the call tag, the page completely broke! Nothing displayed at all.
Re: Summary Template for News
Posted: Fri Aug 08, 2014 2:37 am
by applejack
Have you tried {$entry->fieldsbyname.story}
Re: Summary Template for News
Posted: Fri Aug 08, 2014 11:08 pm
by psy
Try {News....} instead of {news...}