I need to include custom .tpl files on product pages. The .tpl files have a naming scheme of brand1.tpl, brand2.tpl where the number represents the brand ID.
I'd like to be able to use a smarty function to check what the current products brand ID is, place it into a variable, then dynamically add that ID/variable into the .tpl file such as {include file='brand$bid.tpl'} so it renders to brand2.tpl etc.
Any help is appreciated, thanks
When you refer to Brand I assume you are referring to a product feature you created and titled Brand.
The best way I am aware to retrieve a products feature_id is to first loop through all features of the product
and place the feature_id into a temporary variable. The code below should get you started:
// Loop through all Features and variants of the selected product
{foreach from=$product_features item="feature"}
{foreach from=$feature.variants item="var"}
{if $feature.description == 'Brand'}
{assign var="v_featured_id" value=$var.variant_id}
{include file='brand`$v_featured_id
{/if}
{/foreach}
{/foreach}
Thanks yes I meant feature, i'm jumping between projects and forgetting cs-cart uses features and doesn't have brands
I placed the code into the default_template.tpl and it wasn't getting the feature ID. When I put the code into the product_features.tpl file it worked. How can I get it to grab the feature ID when the code is in another template other than the product_features.tpl?
try changing your from in your first foreach to $product.product_features
Awesome thanks that did the trick