• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: CGBlog images not showing in detail template on default page
PostPosted: Tue Jun 12, 2018 10:48 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Fri Sep 14, 2007 1:05 pm
Posts: 138
Location: South Derbyshire – UK
Hi

A conundrum? I have CGBlog installed and have a page that has a main tag in the content block

Code:
{CGBlog detailtemplate="00_newsdetail" detailpage="latest-news" number="1" category="General" action="detail"}


Which should show the latest post.

I then have a tag in a content block forming the right hand column which gives a list of posts.

Code:
{CGBlog summarytemplate="00_newspagesummary" detailpage="latest-news" number="5" category="General" detailtemplate="00_newsdetail"}


Both use the same detail template. However when you navigate to the page the post in the main content shows up with the text, but the images don't show. If I then click on the link in the right hand column the images do show?

I am using the following code to select the appropriate image.

Code:
{if isset($entry->fields)}
  {foreach $entry->fields as $field}
    {if $field->type == 'image' && $field->name == 'Standard Image' && $field->value != ''}
{capture name=newsdetailimg assign=standardnews}{CGSmartImage src1=$entry->file_location src2=$field->value  max_width="1000" max_height="800" class="img-responsive" noembed=1 alt=$entry->title}{/capture}
    {/if}
  {/foreach}
{/if}

{if isset($entry->fields)}
  {foreach $entry->fields as $field}
    {if $field->type == 'image' && $field->name == 'Revolving image' && $field->value != ''}
{capture name=newsdetailimg2 assign=revolvingnews}{CGSmartImage src1=$entry->file_location src2=$field->value  max_width="1000" max_height="800" class="img-responsive" noembed=1 alt=$entry->title}{/capture}
    {/if}
  {/foreach}
{/if}

{if $standardnews != ''}
    {$standardnews}
    {elseif $revolvingnews != ''}
    {else}---
{/if}


I think it is probably something to do with the way the page is processed. I seem to think that this might be a resent change. Although I can't remember the administrator says the images used to show?

I have tried just calling the image directly without the capture, but the result is the same.

I am running 2.2.7 with all the latest associated modules. PHP version 5.5.38. The only resent changes are upgrade to 2.2.7 and installation of CG content utilities.

Any help would be gratefully received.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBlog images not showing in detail template on default
PostPosted: Tue Jun 12, 2018 2:46 pm 
Online
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Feb 25, 2009 4:25 am
Posts: 313
Location: Victoria, BC
If the output of the captured variables isn't in the same template, you need to give them a global scope.

So after the captures, you could add:
Code:
{$standardnews=$standardnews scope=global}
{$revolvingnews=$revolvingnews scope=global}


Note: I think there are better and more efficient ways to do what you're doing, but that should at least determine if it's a scope issue.

_________________
Not getting the answer you need? CMSMS support options


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBlog images not showing in detail template on default
PostPosted: Tue Jun 12, 2018 2:48 pm 
Offline
Dev Team Member
Dev Team Member

Joined: Mon Nov 28, 2011 9:29 am
Posts: 2970
Location: The Netherlands
My first step would be to just print the contents of the fields to the page. To check if that works.

Put this code somewhere in the top of the detail template you use and then check on the frontend if it has the values as you expect.
Code:
<pre>{$entry->fields|print_r}</pre>



Further, it's not very efficient to iterate to 'all' fields twice only to find one value, which you already know where to search for it.
You already know the name, you know the field is of type image, so you only want to check if it's not empty

Code:
{if $entry->fields['<FIELD_NAME>']->value != ''}
...
{/if}


(note: I don't know if CGBlog uses field ALIASES in stead of NAMES. You can check this in the output of the earlier mentioned {$entry->fields|print_r})

Then, {capture} is said to be expensive. So you might consider to use assign.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBlog images not showing in detail template on default
PostPosted: Tue Jun 12, 2018 6:50 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Apr 23, 2008 7:53 am
Posts: 7496
Location: The Netherlands
Smarty scope code examples at http://cms.ms/Hupy

_________________
Image
Latest CMSMS article: Search Form Autocomplete

Did my post help you solving a problem at your (customers) website and it saved you many hours of work? Great!! Consider buying me a cup of coffee in return! [ Click here ]



Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting