I have a handful of extended properties configured. I'd like to include them, along with some pre-defined text, in my posts only when the ep's are actually specified.
For example, say I have a property named ProductName. I'd like to have:
Name of this product: <product name>
Appear in my posts, but only when a product name is actually defined in the extended properties. (Product name is a completely arbitrary example... I'm not actually dealing with products.)
Is there an easy way to do this directly in the template or will I need to write a plugin to do this? If I do need to write a plugin can anyone suggest a good one to copy as a starting point?
Thanks
-Tom
Easy way to optionally include extended properties
Hi Tom,
yes there is an easy way, given that you know how to "address" the variables within the template.
Just wrap your line into an if-statement, so that you end up with something like this:
To find out more about what can be done in smarty-templates, have a look at their documentation 
Hope this helps,
Manfred.
yes there is an easy way, given that you know how to "address" the variables within the template.
Just wrap your line into an if-statement, so that you end up with something like this:
Code: Select all
{if $name_of_product != ""}Name of this product: {$name_of_product}{/if}Hope this helps,
Manfred.
Try not. Do or do not. There is no try. (YODA)
-
Don Chambers
- Regular
- Posts: 3657
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
Code: Select all
{if $entry.properties.ep_ProductName}
<span class="product_name">Product Name: {$entry.properties.ep_ProductName}</span>
{/if}If it does not, you need to first copy that file from /templates/default to templates/yourtemplatefolder. The only remaining issue is where you want the text to appear relative to the rest of the entry.
EDIT: an equal (=) sign was missing between "class" and "product_name" when this message was originally posted. Corrected 2/29/2008.
Last edited by Don Chambers on Fri Feb 29, 2008 3:44 pm, edited 1 time in total.
=Don=
-
lordcoffee
- Regular
- Posts: 308
- Joined: Tue Nov 29, 2005 10:22 pm
- Location: Munich - Germany
- Contact:
Hi!
I'm trying to add a download field to my entries. I've put this code inside the entries.tpl and the text: Download file: "bla blubb" apears if I enter "bla blubb" in the custom field. Now I've tried to style this span and nothing happens. When I use the "css-viewer" it does not recognise the class. Any Ideas?

Thanks , Lordcoffee
I'm trying to add a download field to my entries. I've put this code inside the entries.tpl and the text: Download file: "bla blubb" apears if I enter "bla blubb" in the custom field. Now I've tried to style this span and nothing happens. When I use the "css-viewer" it does not recognise the class. Any Ideas?
Code: Select all
{if $entry.properties.ep_downloads}
<span class"mydownloads">Download file: {$entry.properties.ep_downloads}</span>
{/if}Code: Select all
.mydownloads {
color:red;
background-color:#FFCCCC;
border-top:3px solid #FFCC99;
border-bottom:3px solid #FFCC99;
}
Thanks , Lordcoffee
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi!
Did you check the rest of your HTML for validity? Try adding "!important" to your styles? The span should be there.
Regards,
Garvin
Did you check the rest of your HTML for validity? Try adding "!important" to your styles? The span should be there.
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
-
Don Chambers
- Regular
- Posts: 3657
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
Error in my original code... needs to be class="whatever".... note the missing equal sign. I've corrected the original post, but the equal sign was missing in both my original post as well as your quote.lordcoffee wrote:Hi!
I'm trying to add a download field to my entries. I've put this code inside the entries.tpl and the text: Download file: "bla blubb" apears if I enter "bla blubb" in the custom field. Now I've tried to style this span and nothing happens. When I use the "css-viewer" it does not recognise the class. Any Ideas?
Code: Select all
{if $entry.properties.ep_downloads} <span class"mydownloads">Download file: {$entry.properties.ep_downloads}</span> {/if}Code: Select all
.mydownloads { color:red; background-color:#FFCCCC; border-top:3px solid #FFCC99; border-bottom:3px solid #FFCC99; }
Thanks , Lordcoffee
=Don=
-
lordcoffee
- Regular
- Posts: 308
- Joined: Tue Nov 29, 2005 10:22 pm
- Location: Munich - Germany
- Contact: