Osclass forums
Support forums => General help => 3.6.x => Topic started by: shaan1988 on October 18, 2016, 11:14:17 pm
-
<?php if(( (osc_item_category() != 'Motorcycles'))||((osc_item_category() != 'Brides Wanted'))) { ?>
<input type="image" src="/oc-content/themes/bender/buy2.png" alt="Submit" width="50%"><?php }else{ ?> <br><br><?php } ?>
The above is not working but the code below works please help me.
<?php if(osc_item_category() != 'Motorcycles') { ?>
<input type="image" src="/oc-content/themes/bender/buy2.png" alt="Submit" width="50%"><?php }else{ ?> <br><br><?php } ?>
-
Do you mean:
<?php if( osc_item_category() != 'Motorcycles' or osc_item_category() != 'Brides Wanted') { ?>
<!-- your code -->
<?php } ?>
Regards
-
Yes but it is not working
-
Hi, will working if the name of categories are on same language. Otherwise will not working on different languages, unless you use proper condition for current language by user.
Maybe is not the best solution with "if and else" with a lot of languages, but with few languages you can do something like:
<?php
if(osc_current_user_locale() == en_US) {
if(osc_item_category() == 'Art - Collectibles' or osc_item_category() == 'Animals' ) {
/* your code */
}
} elseif(osc_current_user_locale() == pt_PT) {
if(osc_item_category() == 'Arte - Colecionáveis' or osc_item_category() == 'Animais' ) {
/* your code */
}
}
?>
My suggestion is you use category Id and forget category by name, this a way you avoid condition to current language by user.
You just need change the number ID for your category numbers you really need.
<?php if(osc_item_category_id() == '9' or osc_item_category_id() == '10' ) {?>
you can see this text on your items on these categories ID
<?php } ?>
But both codes will working.
Regards
-
@shaan1988
It is more comfortable to compare on category id instead of name.
osc_item_category_id()
-
FOG and MB Themes, thanks for your immense support.
It is now working with the codes written below
<?php
if(osc_item_category()!='Motorcycles'){
......My Code......}
else if(osc_item_category()!='Brides Wanted'){
....... My Code.....}
else{
...... My Code......
}
?>