Images with CGFeedMaker

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
fprm67
New Member
New Member
Posts: 6
Joined: Thu Apr 03, 2014 10:22 pm

Images with CGFeedMaker

Post by fprm67 »

Hi all,
I'm using CGFeedMaker to display the RSS of the News on my website.

RSS Feed template:

Code: Select all

{* original rss feed template *}
<?xml version="1.0"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
  {* note: if you have not configured pretty urls or mod rewrite, the next line may fail when trying to validate the feed *}
  <atom:link href="{$feed_url}" rel="self" type="application/rss+xml" />
    <title>{$feed.title|cms_escape}</title>
    {if isset($feed.link) && !empty($feed.link)}<link>{$feed.link}</link>{/if}
    {if isset($feed.description) && !empty($feed.description)}<description>{$feed.description}</description>{/if}
    {if isset($feed.copyright) && !empty($feed.copyright)}<copyright>{$feed.copyright}</copyright>{/if}
    {if isset($generator)}<generator>{$generator}</generator>{/if}
    {if isset($feed.managing_editor) && !empty($feed.managing_editor)}<managingEditor>{$feed.managing_editor}</managingEditor>{/if}
    {if isset($admin_email)}<webMaster>{$admin_email} ({$admin_user->firstname} {$admin_user->lastname})</webMaster>{/if}
    {if isset($feed.image) && !empty($feed.image)}
      <image>
	{if isset($feed.description) && !empty($feed.description)}<description>{$feed.description}</description>{/if}
        {if isset($feed.link) && !empty($feed.link)}<link>{$feed.link}</link>{/if}
        <title>{$feed.title}</title>
        <url>{$file_location}/{$feed.image}</url>
      </image>
    {/if}

    {News assign='junk'  category='news-it' detailpage=$feed.pageid lang=$lang_locale}

    {if isset($items)}
    {foreach from=$items item='entry'}
    <item>
      <title>{$entry->title|cms_html_entity_decode}</title>
      <link>{$entry->moreurl}</link>
      {capture assign='description'}{if isset($entry->summary)}{$entry->summary} {$entry->content}{/if}{/capture}
      <description>{$description|trim|strip_tags|summarize:500}</description>
      <pubDate>{$entry->postdate|rfc_date}</pubDate>
      <guid>{$entry->moreurl}</guid>
    </item>
    {/foreach}
    {/if}
  </channel>
</rss>
Everything works fine but I would display also the Images of the news on RSS page.

This is my Detail Template in News:

Code: Select all

{strip}
<!-- Start news detail template-->
{if isset($entry->canonical)}
  {assign var='canonical' value=$entry->canonical}
{/if}
<h2>{assign var='newstitle'  value=$entry->title}</h2>
{* <h2>{$entry->title|cms_escape:htmlall}</h2> *}
{if isset($entry->fields)}
  {foreach from=$entry->fields item='field'}
        {if $field->type == 'file'}
	  {* this template assumes that every file uploaded is an image of some sort, because News doesn't distinguish *}
          <img class="th left" src="{CGSmartImage src1=$entry->file_location src2=$field->value alias1='large_thumbnail' notag=1}"/>
        {/if}
  {/foreach}
{/if}

<div class="meta">
<p class="noMarginBottom">{if $entry->postdate}<span class="general foundicon-calendar"> {$entry->postdate|cms_date_format}</span>{/if}{if $entry->category} | <span class="general foundicon-paper-clip"> {$entry->category}</span>{/if}{if $entry->author} | <span class="accessibility foundicon-adult"> {$entry->author}</span>{/if}</p>
</div>
{if $entry->summary}
<h4 class="subheader">{eval var=$entry->summary}</h4>
<hr />
{/if}
{eval var=$entry->content}
{if $entry->extra}
	<div id="NewsPostDetailExtra">
		{$extra_label} {$entry->extra}
	</div>
{/if}

{if $return_url != ""}
<p><span class="button radius secondary right small">{$return_url}{if $category_name != ''} - {$category_link}{/if}</span></p>
{/if}
{Disqus disqus_identifier=$entry->id}
{/strip}
CMS version 1.12
CGFeedMaker 1.0.20
MleCMS 1.11.5
News 2.15.1

Somebody might give me an idea to solve this problem?

Thanks
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Images with CGFeedMaker

Post by velden »

If you read the sample template you could understand how to directly get a field's value instead of using a foreach loop.

Code: Select all

$entry->fields.IMAGE_FIELD_NAME->value
So try something like (untested):

Code: Select all

{CGSmartImage src1=$entry->file_location src2=$entry->fields.IMAGE_FIELD_NAME->value alias1='large_thumbnail' notag=1}
Obivously IMAGE_FIELD_NAME needs to be replaced by the proper field definition name.
fprm67
New Member
New Member
Posts: 6
Joined: Thu Apr 03, 2014 10:22 pm

Re: Images with CGFeedMaker

Post by fprm67 »

thank you for your reply.

In News module under "Field Definitions" I have "news_image".
I have replaced IMAGE_FIELD_NAME with "news_image":

Code: Select all

{CGSmartImage src1=$entry->file_location src2=$entry->fields.news_image->value alias1='large_thumbnail' notag=1}
In the website all is fine, but on my ;http://www.domain.com/feeds/news-it.rss are not yet displayed images. Some other ideas?

thanks
Last edited by Dr.CSS on Fri May 15, 2015 5:30 pm, edited 2 times in total.
Reason: Use 'Do not automatically parse URLs' checkbox for fake urls
fprm67
New Member
New Member
Posts: 6
Joined: Thu Apr 03, 2014 10:22 pm

Re: Images with CGFeedMaker

Post by fprm67 »

Hello,
Is there anyone who might help me please with this issue?

Thank you so much
Post Reply

Return to “Modules/Add-Ons”