Publishing news with automatic features (autosummary, img au

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
User avatar
blast2007
Power Poster
Power Poster
Posts: 508
Joined: Wed Aug 01, 2007 5:36 pm

Re: Publishing news with automatic features (autosummary, im

Post 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
Loopy
Forum Members
Forum Members
Posts: 38
Joined: Sat Jun 10, 2006 5:34 pm

Re: Publishing news with automatic features (autosummary, im

Post 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!
EricG
Forum Members
Forum Members
Posts: 29
Joined: Tue May 02, 2006 1:46 pm
Location: Apeldoorn

Re: Publishing news with automatic features (autosummary, im

Post 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
EricG
Forum Members
Forum Members
Posts: 29
Joined: Tue May 02, 2006 1:46 pm
Location: Apeldoorn

Re: Publishing news with automatic features (autosummary, im

Post 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
EricG
Forum Members
Forum Members
Posts: 29
Joined: Tue May 02, 2006 1:46 pm
Location: Apeldoorn

Re: Publishing news with automatic features (autosummary, im

Post 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 :)
Locked

Return to “Tips and Tricks”