Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Include .tpl on product page based on products brand ID Rate Topic   - - - - -

 
  • panag
  • Member
  • Members
  • Join Date: 14-May 10
  • 80 posts

Posted 25 January 2012 - 10:39 PM #1

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

 
  • solesurvivor
  • Senior Member
  • Members
  • Join Date: 05-Aug 11
  • 745 posts

Posted 25 January 2012 - 10:55 PM #2

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}


 
  • panag
  • Member
  • Members
  • Join Date: 14-May 10
  • 80 posts

Posted 25 January 2012 - 11:10 PM #3

Thanks yes I meant feature, i'm jumping between projects and forgetting cs-cart uses features and doesn't have brands

 
  • panag
  • Member
  • Members
  • Join Date: 14-May 10
  • 80 posts

Posted 26 January 2012 - 03:31 PM #4

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?

 
  • solesurvivor
  • Senior Member
  • Members
  • Join Date: 05-Aug 11
  • 745 posts

Posted 26 January 2012 - 10:03 PM #5

try changing your from in your first foreach to $product.product_features

 
  • panag
  • Member
  • Members
  • Join Date: 14-May 10
  • 80 posts

Posted 27 January 2012 - 06:39 AM #6

Awesome thanks that did the trick