Jump to content

using variables in other tpl files


Guest shickson

Recommended Posts

Guest shickson

Hi can someone help me out please?

I have the variable {TXT_PRODCODE} which is used in the product page to display the actual code of the product. (this is in viewprod.tpl)

However i wish to show this in the category list (viewcat.tpl) but it seems that the variables for each document are defined seperately and are not avaiable across the whole platform.

So my question is, how do i use the product code variable to display in my category view page?

I'm sure this is easy but just confused why the variables are not avaiable site wide as this would make life so much easier

thanks

Link to comment
Share on other sites

Guest dtmswebmaster

Hi can someone help me out please?

I have the variable {TXT_PRODCODE} which is used in the product page to display the actual code of the product. (this is in viewprod.tpl)

However i wish to show this in the category list (viewcat.tpl) but it seems that the variables for each document are defined seperately and are not avaiable across the whole platform.

So my question is, how do i use the product code variable to display in my category view page?

I'm sure this is easy but just confused why the variables are not avaiable site wide as this would make life so much easier

thanks

Ok.. I've figured it out...

Open %store%/includes/content/viewCat.inc.php... on/at line 434, look for:

$view_cat->assign("BTN_BUY", $lang['viewCat']['buy']);




and add this after it:




$view_cat->assign("TXT_PRODCODE", $productResults[$i]['productCode']);




Repeat for the other else statements within that if statement.



Your final code for this should look like this:


			if ($config['outofstockPurchase'] == true) {

				$view_cat->assign("BTN_BUY", $lang['viewCat']['buy']);

				$view_cat->assign("PRODUCT_ID", $productResults[$i]['productId']);

 				$view_cat->assign("TXT_PRODCODE", $productResults[$i]['productCode']);

				$view_cat->parse("view_cat.productTable.products.buy_btn");

			

			} else if ($productResults[$i]['useStockLevel'] == true && $productResults[$i]['stock_level']>0) {

				$view_cat->assign("BTN_BUY", $lang['viewCat']['buy']);

				$view_cat->assign("PRODUCT_ID", $productResults[$i]['productId']);

 				$view_cat->assign("TXT_PRODCODE", $productResults[$i]['productCode']);

				$view_cat->parse("view_cat.productTable.products.buy_btn");

			

			} else if ($productResults[$i]['useStockLevel'] == false) {

				$view_cat->assign("BTN_BUY", $lang['viewCat']['buy']);

				$view_cat->assign("PRODUCT_ID", $productResults[$i]['productId']);

				$view_cat->assign("TXT_PRODCODE", $productResults[$i]['productCode']);

				$view_cat->parse("view_cat.productTable.products.buy_btn");

			}




Save and close file.



---------------------------------



Open %store%/skins/%YOURSTYLE%/styleTemplates/content/viewCat.tpl, on line 35, look for:


<td class="tdListTitle"><a href="{SORT_NAME}" class="sortLink"><strong>{LANG_NAME}</strong></a> {SORT_ICON}</td>




add after


<td align="center" class="tdListTitle">Code</td>




Then find


<div class="txtOutOfStock">{TXT_OUTOFSTOCK}</div></td>




and add after


<td align="center" class="txtDefault">{TXT_PRODCODE}</td>

Save and close file.

----------------------------------

This should provide the desired effect that you are looking for. Hope this helps you! :)

Link to comment
Share on other sites

  • 4 months later...
  • 10 months later...

Thanks for taking the time to post this. It works great :)

Really this should have been possible in beginning as it means these changes could potentially be overwrote when patching Cubecart.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...