SmartyTag inside style?

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
jmansa
Forum Members
Forum Members
Posts: 126
Joined: Thu Oct 19, 2006 2:46 pm

SmartyTag inside style?

Post 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...
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: SmartyTag inside style?

Post by Dr.CSS »

No...
jmansa
Forum Members
Forum Members
Posts: 126
Joined: Thu Oct 19, 2006 2:46 pm

Re: SmartyTag inside style?

Post by jmansa »

What about converting the {$entry->image} to something that could bed used?!?!
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: SmartyTag inside style?

Post by Dr.CSS »

How about assigning some kind of class to the div and moving all your styling to the style sheet...
jmansa
Forum Members
Forum Members
Posts: 126
Joined: Thu Oct 19, 2006 2:46 pm

Re: SmartyTag inside style?

Post 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}
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: SmartyTag inside style?

Post 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.
Last edited by Wishbone on Thu Jan 28, 2010 11:48 pm, edited 1 time in total.
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

Re: SmartyTag inside style?

Post 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...
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: SmartyTag inside style?

Post 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
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: SmartyTag inside style?

Post 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.
Last edited by Wishbone on Fri Jan 29, 2010 4:41 am, edited 1 time in total.
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

Re: SmartyTag inside style?

Post 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).
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: SmartyTag inside style?

Post 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
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: SmartyTag inside style?

Post 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.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: SmartyTag inside style?

Post 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...
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

Re: SmartyTag inside style?

Post 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 { }.
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: SmartyTag inside style?

Post 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!
Post Reply

Return to “Layout and Design (CSS & HTML)”