Catalog Module & formatting template with Smarty
Posted: Sun Oct 21, 2007 1:13 pm
Hi there,
I'm using the catalog module (v.0.5.5, http://dev.cmsmadesimple.org/) to for a client's online product catalog.
I have added an item attribute named "price" - this adds the field "price" to the "add content" page, allowing the client/admin to input a price amount when adding/modifying a product, or "catalog item".
What I would like to do is format that attribute, "price", so when the client/admin inputs a price (such as, "1000") via the CMS, it comes out on the front-end formatted in strike-through, dollar sign ($) added in front and with the following words after the given price, "(contact us for the best price)", like this:
Right now, I can manually format the price on the front-end by putting the above code in the "price" attribute field via the back-end, but this will be problematic for the client to do.
What I want to do is make every "price" field in a category-item page type to be formated like above, but the problem is that the "price" attribute is loaded to the front-end via a loop in the catalog-item template, so it's hard to edit a specific attribute.
This is a snippet from the category-item template, which loads the attributes automatically:
Using the above code, is it possible to keep the loop to load the attributes but use PHP or Smartytags (I'm unfamiliar with both of these 'languages') to say something like;
[pseudo-code] if the attribute, "price", is not blank (ie, a price is given), then add "$" before value and "(contact us for the best price)" after value, else, display the text, "(contact us for the best price)" [/pseudo-code]
There are also the following variables to use:
Category Template Variables
{$title}, {$notes}, {$prev}, {$prevurl}, {$navstr}, {$next}, {$nexturl}, {$items}, {$image_1_url}, {$image_thumb_1_url}, {$src_image_1_url}, {$image_url_array}, {$src_image_url_array}, {$image_thumb_url_array}
$items array contents:
$items[].title, $items[].link, $items[].image, $items[].attrname
Is this method possible via the template alone? Or will I need to go in and modify the catalog module files?
Could someone please give me an example of what code would make it work via the template, if possible?
Thank you in advance.
I'm using the catalog module (v.0.5.5, http://dev.cmsmadesimple.org/) to for a client's online product catalog.
I have added an item attribute named "price" - this adds the field "price" to the "add content" page, allowing the client/admin to input a price amount when adding/modifying a product, or "catalog item".
What I would like to do is format that attribute, "price", so when the client/admin inputs a price (such as, "1000") via the CMS, it comes out on the front-end formatted in strike-through, dollar sign ($) added in front and with the following words after the given price, "(contact us for the best price)", like this:
Code: Select all
<s>$1000</s><span>(contact us for the best price)</span>What I want to do is make every "price" field in a category-item page type to be formated like above, but the problem is that the "price" attribute is loaded to the front-end via a loop in the catalog-item template, so it's hard to edit a specific attribute.
This is a snippet from the category-item template, which loads the attributes automatically:
Code: Select all
<div class="catalog_item">
{section name=at loop=$attrlist}
<div class="item_attribute_name">{$attrlist[at].name}</div>
<div class="item_attribute_val">{eval var=$attrlist[at].key}</div>
<br />
{/section}[pseudo-code] if the attribute, "price", is not blank (ie, a price is given), then add "$" before value and "(contact us for the best price)" after value, else, display the text, "(contact us for the best price)" [/pseudo-code]
There are also the following variables to use:
Category Template Variables
{$title}, {$notes}, {$prev}, {$prevurl}, {$navstr}, {$next}, {$nexturl}, {$items}, {$image_1_url}, {$image_thumb_1_url}, {$src_image_1_url}, {$image_url_array}, {$src_image_url_array}, {$image_thumb_url_array}
$items array contents:
$items[].title, $items[].link, $items[].image, $items[].attrname
Is this method possible via the template alone? Or will I need to go in and modify the catalog module files?
Could someone please give me an example of what code would make it work via the template, if possible?
Thank you in advance.