Page_Image tag dump shows null

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
SolaMia

Page_Image tag dump shows null

Post by SolaMia »

I am trying to add a conditional page image with this new {page_image} tag.  The problem is that I can't seem to get any if statements to work.  I did a {get_template_vars} dump but I see nothing that I can use in my if statement.

Example:

Code: Select all

{if $page_image==""}

<br><br><img src="uploads/images/{page_image thumbnail="yes"}" width="150px">

    {else}
    {/if}
If I do a {dump item='page_image'}  I get null even on pages that have it set and shows the image.

Any ideas?

I did get this ugly thing to work:

Code: Select all

{literal}
<__script__ type="text/javascript">
var pageimage = '{/literal}{page_image thumbnail="yes"}';
{literal}
if (pageimage > '') 
{
document.write('<br><br><img src="uploads/images/{/literal}{page_image thumbnail="yes"}{literal}" width="150px">')
}
</__script>{/literal}
Last edited by SolaMia on Mon Feb 23, 2009 8:12 pm, edited 1 time in total.
bryan

Re: Page_Image tag dump shows null

Post by bryan »

I ran into this very problem today while attempting to override my stylesheet to use {page_image} in my #header-graphic. I tried using both {if} and {capture} methods without success. After drilling down with {debug} I found that I could use this method:

Code: Select all

{if $content_obj->mProperties->mPropertyValues.image != ''}
{literal}
<style>
#header-graphic {
	background-image:url(uploads/images/{/literal}{page_image}{literal});
}
</style>
{/literal}
{/if}
You can use the same method to conditionally display your thumbnail: (UNTESTED)

Code: Select all

{if $content_obj->mProperties->mPropertyValues.thumbnail==""}

<br /><br /><img src="uploads/images/{page_image thumbnail="yes"}" width="150px" />

    {else}
    {/if}
corinteractive.com
New Member
New Member
Posts: 7
Joined: Tue Jul 14, 2009 6:34 am

Re: Page_Image tag dump shows null

Post by corinteractive.com »

I was not able to get this to work.  I wanted a solution to show a default header if the page had none set for Image for {page_image}.... Or when say a new page was created and the client did not set the image in the options tab...

Help?

It shows this when the page is rendered

Code: Select all

<style>
#header-graphic {
	background-image:url(uploads/images/);
        width: 550px;
        height: 104px;
        border-bottom-width: 5px;
	border-bottom-style: solid;
	border-bottom-color: #FFFF00;
}
</style>
Code in template:

Code: Select all

{if $content_obj->mProperties->mPropertyValues.image != ' '}
{literal}
<style>
#header-graphic {
	background-image:url(uploads/images/{/literal}{page_image}{literal});
        width: 550px;
        height: 104px;
        border-bottom-width: 5px;
	border-bottom-style: solid;
	border-bottom-color: #FFFF00;
}
</style>
{/literal}

{else}
<style>
#header-graphic {
	background-image:url(uploads/images/header-inn.jpg);
        width: 550px;
        height: 104px;
        border-bottom-width: 5px;
	border-bottom-style: solid;
	border-bottom-color: #FFFF00;
}
</style>
{/if}
Last edited by corinteractive.com on Wed Aug 05, 2009 2:38 am, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Page_Image tag dump shows null

Post by Dr.CSS »

One thing for sure once you wrap something in {literal} you don't need to do it again inside the {literal} like you have for the image call...

Maybe this helps?...

http://mit-computers.com/index.php/how- ... types.html
bryan

Re: Page_Image tag dump shows null

Post by bryan »

It looks like you have a space in your if statement:

Code: Select all

{if $content_obj->mProperties->mPropertyValues.image != ' '}
Try removing the space between the single quotes ( '' not ' ' )
corinteractive.com
New Member
New Member
Posts: 7
Joined: Tue Jul 14, 2009 6:34 am

Re: Page_Image tag dump shows null

Post by corinteractive.com »

Tried both ways still did not work.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Page_Image tag dump shows null

Post by Dr.CSS »

You can't use content image in css, that is a smarty call and css doesn't use smarty, put it in the template but not as a css call...
corinteractive.com
New Member
New Member
Posts: 7
Joined: Tue Jul 14, 2009 6:34 am

Re: Page_Image tag dump shows null

Post by corinteractive.com »

this was put in the template not in the css file.

Code: Select all

{if $content_obj->mProperties->mPropertyValues.image != ''}
{literal}
<style>
#header-graphic {
	background-image:url(uploads/images/{/literal}{page_image}{literal});
        width: 550px;
        height: 104px;
        border-bottom-width: 5px;
	border-bottom-style: solid;
	border-bottom-color: #FFFF00;
}
</style>
{/literal}

{else}
<style>
#header-graphic {
	background-image:url(uploads/images/header-inn.jpg);
        width: 550px;
        height: 104px;
        border-bottom-width: 5px;
	border-bottom-style: solid;
	border-bottom-color: #FFFF00;
}
</style>
{/if}
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Page_Image tag dump shows null

Post by Dr.CSS »

That is still using css to call it as in background: bla bla bla note the call above it...
Locked

Return to “CMSMS Core”