Page 1 of 1

SmartyTag inside style?

Posted: Thu Jan 28, 2010 10:29 pm
by jmansa
Is it possible to take an smarty tag and put it inside a div style?

This is what I have tryied, but with no luck...

Code: Select all

<div style="border:1px solid #CCCCCC;height:60px;background:#fff url({$entry->image}) repeat-x scroll left top;margin-bottom:5px;">
    {$entry->name}
</div>
Thanks in advance...

Re: SmartyTag inside style?

Posted: Thu Jan 28, 2010 10:30 pm
by Dr.CSS
No...

Re: SmartyTag inside style?

Posted: Thu Jan 28, 2010 10:40 pm
by jmansa
What about converting the {$entry->image} to something that could bed used?!?!

Re: SmartyTag inside style?

Posted: Thu Jan 28, 2010 10:43 pm
by Dr.CSS
How about assigning some kind of class to the div and moving all your styling to the style sheet...

Re: SmartyTag inside style?

Posted: Thu Jan 28, 2010 10:53 pm
by jmansa
I will do so, but what I need from this is to be able to assign different background image to each category depending on the category...

Code: Select all

{* Front End: List of apex categories *}
{foreach from=$items item=entry}
  {if $entry->image!='*none'}
  	<div id="catlist_fp" style="background:#fff url(The specific image assigned to the category);">
            {$entry->name}
        </div>
  {else}
        <div class="catlistline">
            {$entry->name}
        </div>
  {/if}
{/foreach}

Re: SmartyTag inside style?

Posted: Thu Jan 28, 2010 11:40 pm
by Wishbone
Dr.CSS wrote: No...
I disagree.. Smarty doesn't care if it's in a style... It just evaluates what it sees. I have the following on my test page:

Code: Select all

<div style="{title}"></div>
Of course this won't evaluate into anything meaningful, but it still evaluates.

Here's the source it generated:

Code: Select all

<div style="Smarty Test"></div>
Maybe there's something wrong with your $entry->image.... Display it by itself and see if it's evaluating to anything.

Re: SmartyTag inside style?

Posted: Thu Jan 28, 2010 11:53 pm
by Jeff
I agree smarty doesn't care where is it, as long as it isn't in {literal} tags.

You showed us the code, what output does it give, that is where your problem lies.
jmansa wrote: Is it possible to take an smarty tag and put it inside a div style?

This is what I have tryied, but with no luck...

Code: Select all

<div style="border:1px solid #CCCCCC;height:60px;background:#fff url({$entry->image}) repeat-x scroll left top;margin-bottom:5px;">
    {$entry->name}
</div>
Thanks in advance...

Re: SmartyTag inside style?

Posted: Fri Jan 29, 2010 4:19 am
by jmcgin51
ajprog wrote: I agree smarty doesn't care where is it, as long as it isn't in {literal} tags.
Hi ajprog.  Not trying to argue with you, just looking for some clarification.  I had a need to do something similar (Smarty within a stylesheet) a couple of years ago, and this is the response I ended up getting from Calguy:

http://forum.cmsmadesimple.org/index.ph ... #msg125601

So my question is: has something changed within CMSMS since then, so that Smarty gets processed anywhere?

Thanks,
jmcgin51

Re: SmartyTag inside style?

Posted: Fri Jan 29, 2010 4:39 am
by Wishbone
Your post in that thread indicated that you wanted to use smarty in a stylesheet.. That isn't supported. This thread is about using smarty tags in inline styles in a template, not in stylesheets.

Re: SmartyTag inside style?

Posted: Fri Jan 29, 2010 6:47 am
by Jeff
True this thread is about using inline style.

On the subject of smarty in stylesheets look at the plugin I just published:

http://forum.cmsmadesimple.org/index.ph ... 6.new.html

I did read your original thread and I have not tested that yet, I have just tested [[assign]] and [[get_template_vars]] which I am not importing any in so currently you are limited to what you assign at the top of the file (unless you try the GCB it may or may not work).

Re: SmartyTag inside style?

Posted: Fri Jan 29, 2010 4:53 pm
by Dr.CSS
I gave my initial reply of No... because your question lacked enuf info to really give an answer to...

You didn't and still don't say what module this is, or that it was in the modules template that you were trying to pull the info, but I'm going to assume it is one that will give you the category name...



If you can have the module show the category name then every div should be able to get a background image assigned with CSS using the class call...

So No just using {$entry->image} would not work in a page template which is the way most would read your first post...

more info=more help

Re: SmartyTag inside style?

Posted: Fri Jan 29, 2010 5:26 pm
by jmcgin51
wishbone wrote: Your post in that thread indicated that you wanted to use smarty in a stylesheet.. That isn't supported. This thread is about using smarty tags in inline styles in a template, not in stylesheets.
True, but ajprog said "I agree smarty doesn't care where is it, as long as it isn't in {literal} tags."  Which would seem to indicate that Smarty within a stylesheet would be fine.  Based on my previous experience and the post from calguy, I'm still not sure that's true, unless something has changed since that post, which admittedly was a year and a half ago.

Re: SmartyTag inside style?

Posted: Fri Jan 29, 2010 5:29 pm
by Dr.CSS
Style sheets are style sheets and no they will most likely never read a smarty tag untll/unless they get changed to run thru the smarty system before going to the front end...

Re: SmartyTag inside style?

Posted: Fri Jan 29, 2010 7:42 pm
by Jeff
To clarify, the OP has the style within a which means they are using an inline style within a template, with that as the situation, with in a template smarty doesn't care were it is in the template.

As for stylesheets if your  {stylesheet} with {smarty_stylesheet}, you can now use smarty in the stylesheet as long as you use [[ ]] instead of { }.

Re: SmartyTag inside style?

Posted: Fri Jan 29, 2010 8:34 pm
by jmcgin51
ajprog wrote: To clarify, the OP has the style within a which means they are using an inline style within a template, with that as the situation, with in a template smarty doesn't care were it is in the template.
Makes sense to me.  I guess I was reading more into your statement than you intended.
ajprog wrote: As for stylesheets if your  {stylesheet} with {smarty_stylesheet}, you can now use smarty in the stylesheet as long as you use [[ ]] instead of { }.
Very cool.  I'll have to remember this.  Thanks!