Hiding a portion of text on one category
It's been a mighty long time since I have had to post a question, but a PHP coder I am definitely not so here we go...
I have a portion of text (sizing information) on a site which I have "coded" into the tpl_product_info_display.php which is working perfect because we want this info to show on all products... until now.
Now we have added a new category of product which doesn't need that extra text and I would like to hide it on that specific category only.
I know this can be achieved with an "if" statement, my problem is that I am apparently not writing the "if" statement correctly. Can someone please tell me the correct way to write the code.:unsure:
Thanks!
Re: Hiding a portion of text on one category
Something like
PHP Code:
if($_GET['cPath'] != '##') {//replace ## with your cPath
//output the text
}
Re: Hiding a portion of text on one category
:frusty::frusty::frusty:
That didn't work either... I had tried using the code for hiding columns from tpl_main_page and that didn't do it either.
I am thinking that it might have something to do with either the length of the text that I am putting there or maybe I need to escape some characters, because I get a blank page completely when I put the "if" in...
I will look closer at it and see if I can get it to work through some miracle.
Thanks Glen!
Re: Hiding a portion of text on one category
Try the if test with a simple text output inside the switched area, to see if it is the test or the output causing the problem.
Post the text you are trying to use (exactly as it is in the code) so we can see if there are any problem characters.
Re: Hiding a portion of text on one category
Good Idea Glenn - unfortunately the test shows that it is the code itself. When I add this :
Code:
<?php
if($_GET['cPath'] != '19') {
TESTING THIS TO SEE WHERE ERROR IS
}
?>
I get a blank page for the product description. It loads as far as breadcrumbs and then goes blank :frusty:
Re: Hiding a portion of text on one category
You need to either go back to HTML or use a PHP echo statement for the text:
PHP Code:
<?php
if($_GET['cPath'] != '19') {
echo 'TESTING THIS TO SEE WHERE ERROR IS';
}
?>
or
PHP Code:
<?php
if($_GET['cPath'] != '19') {
?>
TESTING THIS TO SEE WHERE ERROR IS
<?php
}
?>
Re: Hiding a portion of text on one category
OK - we got the page back while it is wrapped in the if statement.
Only problem now is that it still shows on all products pages.
In this case I need it to either show only on cpath=19 or I need it to not show on cpath=23 - either way doesn't matter to me :)
Re: Hiding a portion of text on one category
The test as written should hide the content on category 19. Add this just above the if line to see what the actual cPath is in each case:
PHP Code:
echo 'cPath ' . $_GET['cPath'];
Re: Hiding a portion of text on one category
:clap::clap::clap:
Thank you very very much Glen!
Works like a champ :)