• 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  [ 7 posts ] 
Author Message
 Post subject: How to check if a page has a thumbnail or image?
PostPosted: Fri Apr 13, 2012 9:17 am 
Offline
New Member

Joined: Fri Apr 13, 2012 8:16 am
Posts: 3
Hey everyone,

I'm new to CMSms. However, I'm very pleased with it and managed to convert my template to CMSms very easily (I do know XHTML/CSS/PHP). I guess the most difficult thing so far has been to sign up for this forum (seriously, who came up with that Monty Python question ??? ).

Anyway, what I haven't got working so far is this:
I want to use the {page_image thumbnail=true} template tag to display an image, if the page has one set. But how can I check if the page has a thumbnail assigned within my template? I tried $node->thumbnail but it didn't return anything (I read it may work only in the menu manager).

So, I'm trying to do sth. like this:
Code:
{if !empty($whatever_the_name_of_the_page_thumbnail_variable_is)}
<img src="uploads/images/Hintergruende_und_Logos/{page_image thumbnail=true}">
{/if}


Anyone knows which variable I have to call to check whether there is a thumbnail set for the page?

Thanks a lot,

Timo


Top
 Profile  
 
 Post subject: Re: How to check if a page has a thumbnail or image?
PostPosted: Fri Apr 13, 2012 9:49 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Tue Mar 31, 2009 8:45 pm
Posts: 377
Location: Delft, Netherlands
try this:
Code:
<pre>{$node|print_r}</pre>


to see all the page variables


Top
 Profile  
 
 Post subject: Re: How to check if a page has a thumbnail or image?
PostPosted: Fri Apr 13, 2012 1:54 pm 
Offline
New Member

Joined: Fri Apr 13, 2012 8:16 am
Posts: 3
Thanks mcDavid,

I tried what you suggested and found out that 1) there is a variable $node->thumbnail but only after the menu manager has been called withing the template. If you try to call the variable before. It won't work at all. 2) Even if you call it after calling the menu manager from within your template, it will only give you the result of the last item that the menu manager processed which often will not be your current page. So, that's pretty useless.

For now, I built myself a workaround by making a small template in the menu manager with this code:
Code:
{foreach from=$nodelist item=node}
{if $node->current==true && !empty($node->thumbnail)}
<img src="uploads/images/{page_image thumbnail=true}" class="pagethumbnail">
{/if}
{/foreach}


This works. But of course it would be nicer if there is a way to check whether there is a thumbnail for the page in the template code.

Cheers,

Timo


Top
 Profile  
 
 Post subject: Re: How to check if a page has a thumbnail or image?
PostPosted: Fri Apr 13, 2012 7:03 pm 
Offline
Administrator
Administrator
User avatar

Joined: Thu Mar 09, 2006 5:32 am
Posts: 11812
Location: Arizona
I use this in the menu calls where the normal menu text call is...

{if !empty($node->image)}<img src="{$node->image}" alt="{$node->menutext}" />{else}<span class='{$node->alias}'>{$node->menutext}</span>{/if}

This is used to replace menu text with an image is an image has been chosen in page Options tab, may need to change it for thumbnail...

Used here...

http://dequenesh.org/

And here...

http://dezertdesign.com/pill-dock.html

_________________
Extensions » Modules/Tags click the name of the module/tag or Help to the right to get its parameters.
Right click and view source is a great way to see what you have to work with.
Check ver. CMSMS, PHP, server OS, in System Information page.
Default content http://multiintech.com/defaultcontent/
People are Wonderful
Business is Great
Life is Terrific
Ever wonder what happened to the Album module? Well it is alive and well.
http://album.multiintech.com/
Image


Top
 Profile  
 
 Post subject: Re: How to check if a page has a thumbnail or image?
PostPosted: Mon Apr 16, 2012 2:33 pm 
Offline
New Member

Joined: Fri Apr 13, 2012 8:16 am
Posts: 3
Thanks Dr.CSS.

But if I understand your reply correctly, you use this code in your menu manager template and not directly in your theme, right? My workaround works similar but I was asking for a way to call the thumbnail variable without having to use the menu manager. In my opinion that is far more logical than doing that in the menu manager considering that the thumnail I like to display has nothing to do with any menu.

Cheers,

Timo


Top
 Profile  
 
 Post subject: Re: How to check if a page has a thumbnail or image?
PostPosted: Tue Apr 17, 2012 5:37 pm 
Offline
Administrator
Administrator
User avatar

Joined: Thu Mar 09, 2006 5:32 am
Posts: 11812
Location: Arizona
The $node-> call is only used in menu manager...

Quote:
For now, I built myself a workaround by making a small template in the menu manager with this code:


This is why I posted menu code...

_________________
Extensions » Modules/Tags click the name of the module/tag or Help to the right to get its parameters.
Right click and view source is a great way to see what you have to work with.
Check ver. CMSMS, PHP, server OS, in System Information page.
Default content http://multiintech.com/defaultcontent/
People are Wonderful
Business is Great
Life is Terrific
Ever wonder what happened to the Album module? Well it is alive and well.
http://album.multiintech.com/
Image


Top
 Profile  
 
 Post subject: Re: How to check if a page has a thumbnail or image?
PostPosted: Tue Apr 17, 2012 6:01 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Aug 12, 2008 9:30 pm
Posts: 1979
Location: Feldkirchen in Kärnten, Austria
Code:
{page_image thumbnail='1' assign='my_thumb'}
    {if !empty($my_thumb)}<img src='uploads/images/{$my_thumb}' />{/if}

_________________
CMSMS Blog - I do this!
Forge profile
Github profile
Twitter
=============================================
Support CMSMS


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 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