Page 1 of 1
[SOLVED] How to use page images (as defined on Page:Options)
Posted: Thu Jan 27, 2011 5:46 am
by minneapolisite
I want to make these images:
Show up in the templates:
I know this should be simple, but I can't figure out how to do it.

Re: How to use page images (as defined on Page: Options tab)
Posted: Thu Jan 27, 2011 8:11 am
by Dr.CSS
Re: How to use page images (as defined on Page: Options tab)
Posted: Thu Jan 27, 2011 12:54 pm
by minneapolisite
Yes, {$content_obj->GetPropertyValue('image')} was exactly what I needed! One follow-up question: how would I wrap an "if" statement around it so the code only shows up if there is an image defined?
{if _____________}
<img src="/uploads/images/{$content_obj->GetPropertyValue('image')}" alt="" />
{/if}
Re: How to use page images (as defined on Page: Options tab)
Posted: Thu Jan 27, 2011 4:40 pm
by Dr.CSS
{capture assign="junk"}<img src="/uploads/images/{$content_obj->GetPropertyValue('image')}" alt="" />{/capture} {if !empty($junk)}
{$junk}
{/if}
You capture it and assign a var to it, {$junk}, then if it is not empty, if !empty, show it, {$junk}...
Re: How to use page images (as defined on Page: Options tab)
Posted: Thu Jan 27, 2011 6:03 pm
by minneapolisite
Success! You are a peach!

Re: How to use page images (as defined on Page:Options)
Posted: Fri Feb 25, 2011 4:45 pm
by minneapolisite
Follow-up question:
I currently am using this code:
Code: Select all
{capture assign="page_illustration"}
<img src="/uploads/images/{$content_obj->GetPropertyValue('image')}" alt="" class="illustration" />
{/capture}
{if !empty($page_illustration)}
{$page_illustration}
{/if}
But when there is not an assigned image, it's outputting this:
Code: Select all
<img src="/uploads/images/-1" alt="" class="illustration" />
How can I make it output NOTHING?
Re: How to use page images (as defined on Page:Options)
Posted: Fri Feb 25, 2011 6:02 pm
by uniqu3
As it looks like there is a value of -1 if no image selected you could try:
Code: Select all
{capture assign="page_illustration"}
<img src="/uploads/images/{$content_obj->GetPropertyValue('image')}" alt="" class="illustration" />
{/capture}
{if $page_illustration == '-1'}
{else}
{$page_illustration}
{/if}
But there is for sure more elegant way.
Re: How to use page images (as defined on Page:Options)
Posted: Tue Mar 01, 2011 3:05 pm
by minneapolisite
Hm, that suggestion didn't work.

Re: How to use page images (as defined on Page:Options)
Posted: Tue Mar 01, 2011 3:34 pm
by uniqu3
Try this, i tried it on 1.9.3 version and works as expected.
Code: Select all
{assign var=page_illustration value=$content_obj->GetPropertyValue('image')}
{if $page_illustration == '-1'}
{else}
<img src="{root_url}/uploads/images/{$content_obj->GetPropertyValue('image')}" alt="" class="illustration" />
{/if}
Re: How to use page images (as defined on Page:Options)
Posted: Tue Mar 01, 2011 4:07 pm
by minneapolisite
uniqu3, you are my hero! That works great.

Thank you!
Re: [SOLVED] How to use page images (as defined on Page:Opti
Posted: Sun Mar 13, 2011 10:05 am
by pixelita
Uniqu3 is my hero too! That code worked on a client site that I am working on where I want them to be able to associate an image with a page that they create.
And I was Googline for "page_image" because I had been trying to use the {page_image} tag without success.
Am I misunderstanding the purpose of {page_image} perhaps?