Page 3 of 3

Re: Publishing news with automatic features (autosummary, im

Posted: Sat Dec 08, 2012 3:36 pm
by blast2007
Hi folks,
after 10923 views of this thread I'm updating my first post with a new version full compatible with v.1.11.x using CGSmartImage.

Here new summary_template:

Code: Select all

{capture assign='currentdate'}{current_date format="%F" }{/capture}
<div class="NewsSummaryHP">
{assign var=num value=5}
{foreach from=$items item=entry}{* start foreach item*}
{if ( $entry->postdate|date_format:'%F' >= $currentdate) && $num>0}{assign var=num value=$num-1}
<div class="NewsSummaryHpArticle">

{if isset($entry->fields)}
{foreach from=$entry->fields item='field'}{* start foreach fields*}
    {if $field->name == 'img_news_max540' && $field->value!=''}
    <img src="{CGSmartImage src=$entry->file_location|cat:'/'|cat:$field->value filter_croptofit='90,70' noembed=1 notag=1}"  alt="{$entry->title|escape:htmlall}" title="{$entry->title|escape:htmlall}" />
{/if}
                        {if $field->name == 'img_news_max540' && $field->value==''}<img src="uploads/images/nologoimg_thumb.gif" alt="no logo" title="no logo" />
                        {/if}
{/foreach}{* end foreach fields*} 
            {/if}
            <span class="strong">
            <a href="{$entry->link}" title="{$entry->title|truncate:40|replace:'"':''}">{$entry->postdate|date_format:"%d/%m/%Y"} - {$entry->title}</a>
            </span>
            <br />
            {if $entry->summary}
                <div class="NewsSummarySummary">
                    {eval var=$entry->summary}
                     <a href="{$entry->link}" title="{$entry->title|truncate:40|replace:'"':''}">
                    {$entry->content|strip_tags|truncate:165}
                     </a>
                </div>
            {else}
                <div class="NewsSummarySummary">
                     <a href="{$entry->link}" title="{$entry->title|truncate:40|replace:'"':''}">
                    {$entry->content|strip_tags|truncate:165}
                     </a>
                </div>
            {/if}
        </div>
    {/if}
{/foreach}{* end foreach items*}
</div>
here new detail_template:

Code: Select all

{assign var="pagetitle" value=$entry->title}

<div class="NewsDetail">
<h3 id="NewsPostDetailTitle">{$entry->postdate|date_format:"%d/%m/%Y"}: 
{$entry->title}</h3>

{if isset($entry->fields)}
      {if $entry->fields|@count>0}

      {foreach from=$entry->fields item='field'}
              {if $field->name == 'img_news_max540' && $field->value!=''}
                            {assign var='loc' value=$entry->file_location}
                            {assign var='theFile' value=$field->value}
                            <img src="{CGSmartImage src=$entry->file_location|cat:'/'|cat:$field->value filter_resize='h,530' noembed=1 notag=1}"  alt="{$entry->title|escape:htmlall}" title="{$entry->title|escape:htmlall}" />
                            {assign var=title value=$entry->title|escape:htmlall}
                            {$imgName|replace:"/>":" alt=\"$title\" />"}
              {/if}
      {/foreach}
      {else}
                   <!--- <img src="uploads/images/nologoimg_thumb.gif" alt="no logo" width='300' />-->

      {/if}
{/if}

{if $entry->summary}
	<div id="NewsPostDetailSummary">
		<strong>
			{eval var=$entry->summary}
		</strong>
	</div>
{/if}


<div id="NewsPostDetailContent">
	{eval var=$entry->content}
</div>


{***** files *****}
{if isset($entry->fields)}
{if $field->type == 'file' && $field->name != 'img_news_max540' && $field->value!=''}<br />Attachment:{/if}
	{foreach from=$entry->fields item='field'}
        {if $field->type == 'file' && $field->value!="" && $field->name !='img_news_max540' }
        <div class="NewsSummaryField">
            {if 'img_' != $field->value|substr:0:4}
                <img src="modules/Uploads/images/{$field->value|substr:-3}.png" class="textmiddle" />
                <a href="{$entry->file_location}/{$field->value}">{$field->value}</a>
            {else}
				<img src="{$entry->file_location}/{$field->value}" />
            {/if}
        </div>
	{/if}
       {/foreach}
{/if}
{***** /file *****}


</div>
You can call your news template with this new code:

Code: Select all

{CGFeedMaker action='rsslink' feed='yourfeednamehere' text='Feed RSS yourfeednamehere' imageonly='true' image='/images/cms/RSS_feed.png'}
{news category="your_category_name_here" sortasc="true" summarytemplate="summary_template" detailpage="detail-page" detailtemplate="detail_template"}
I know, it's raw,ugly code but it just works fine. If a real coder want to improve it I will be happy. I'm a just a wannabe coder. ;)

Regards
blast

Re: Publishing news with automatic features (autosummary, im

Posted: Tue Feb 26, 2013 12:15 pm
by Loopy
Has anybody managed to get this to work cause it's not working for me. Copied and pasted and renamed where necessary but no joy!

Re: Publishing news with automatic features (autosummary, im

Posted: Fri Apr 26, 2013 5:58 pm
by EricG
Has anyone succeeded in getting this code to work with cmcms version 1.11.6.

I can tell the uploading of the image goes well but the template code won't show anything

Re: Publishing news with automatic features (autosummary, im

Posted: Fri May 03, 2013 10:00 am
by EricG
Commenting out this part of the code for the summary template (first line) shows a summary result but not any image

{capture assign='currentdate'}{current_date format="%F" }{/capture}

CMSMS 1.11.6
news 2.12.12
CGSmartImage 1.10.8

to be continued ;D

Re: Publishing news with automatic features (autosummary, im

Posted: Fri May 03, 2013 1:07 pm
by EricG
Stupid me... Did not see thumbnail images in the summary news, but this was because the field definition was not set to public.

Now it works :)