Guest Posted March 15, 2006 Share Posted March 15, 2006 Hello all, I'm wanting to put a bit of code in the viewProd.inc.php file so when the user is in a certain catagory they cannot see a bit of text written in the viewProd.tpl file. Using say: <!-- BEGIN: product_colour --> text here <!-- END: product_colour --> How would i go about doing this, with the $view_prod->assign() assign, and a 'if' catagory equals 2 statement. Can anyone help, i just don't seem to be able to quite do it. Cheers Tim Quote Link to comment Share on other sites More sharing options...
Guest PMinteractive Posted March 15, 2006 Share Posted March 15, 2006 Hi Can you post the sections of code you're trying to change here? Might help to see if there's an easy mistake someone can point out :D Quote Link to comment Share on other sites More sharing options...
Guest Posted March 15, 2006 Share Posted March 15, 2006 Hi Can you post the sections of code you're trying to change here? Might help to see if there's an easy mistake someone can point out Unfortunately i don't really know what im doing, so could do with some help in the coding. I just assume it can be done in a similar way to all the other bits of code in the .tpl.inc files, using something like (but i REALLY don't know what im doing): $view_prod->assign("COLOUR",$prodArray[0]['product_colour']); if ($prodArray[0]['productId'] == 83){ $view_prod->assign("COLOUR",$lang['front']['viewProd']['product_colour']); $view_prod->parse("view_prod.prod_true.product_colour"); } else { $view_prod->assign("COLOUR",""); } EDIT I've somehow managed to get it to work for the product id of the two items using the code: $view_prod->assign("COLOUR",$prodArray[0]['product_colour']); if ($prodArray[0]['productId'] != 83 && $prodArray[0]['productId'] != 84 ){ $view_prod->assign("COLOUR",$lang['front']['viewProd']['product_colour']); $view_prod->parse("view_prod.prod_true.product_colour"); } else { $view_prod->assign("COLOUR",""); } However it would be better if i could hide the text based upon a catagory level rather than a specific product ID. Any ideas ? The main thing i suppose though is it seems to be working for me now. Cheers Tim EDIT AGAIN: infact im not even sure why this works, can anyone explain it to me. Quote Link to comment Share on other sites More sharing options...
Guest PMinteractive Posted March 16, 2006 Share Posted March 16, 2006 Morning, Your code is almost there, you just need to change this line: if ($prodArray[0]['productId'] != 83 && $prodArray[0]['productId'] != 84 ) { to this if ($prodArray[0]['cat_id'] != 4) { where '4' is the category ID of products you don't want to assign the COLOUR variable for. However you seem to be assigning the variable COLOUR twice, your first line sets it to the product's colour, and the second time inside the IF statement sets it to the current language text for 'Product Colour'. Did you want the text or the colour displayed? Quote Link to comment Share on other sites More sharing options...
Guest Posted March 16, 2006 Share Posted March 16, 2006 Morning, Your code is almost there, you just need to change this line: if ($prodArray[0]['productId'] != 83 && $prodArray[0]['productId'] != 84 ) { to this if ($prodArray[0]['cat_id'] != 4) { where '4' is the category ID of products you don't want to assign the COLOUR variable for. However you seem to be assigning the variable COLOUR twice, your first line sets it to the product's colour, and the second time inside the IF statement sets it to the current language text for 'Product Colour'. Did you want the text or the colour displayed? Thanks, i just want to show and hide text based on that IF statement. What can i remove so im not assigning it twice. Cheers Tim Quote Link to comment Share on other sites More sharing options...
Guest PMinteractive Posted March 16, 2006 Share Posted March 16, 2006 Ok, I think you need to remove the line above the IF statement but if that breaks it put it back, and then play with the assignment inside the IF statement A large chunk of the modifications I've made to my store are based on this highly scientific progamming method. $view_prod->assign("COLOUR",$prodArray[0]['product_colour']); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.