55 posts
  • Has been part of the Envato Community for over 5 years
  • Has collected 100+ items on Envato Market
topbuzza says
<?php if ($breadcrumb['text'] == 'ABOUT US' && 'CONTACT') { ?>

Trying to show some specific content on pages but when i use a second constant (Contact) it does not work… where am i going wrong?

224 posts
  • Made it to the Authors' Hall of Fame
  • Has been part of the Envato Community for over 3 years
  • Has sold $40,000+ on Envato Market
  • Helped several times protecting Envato Market against copyright violations
+4 more
SurStudio says

If you write ‘CONTACT’, that’s not a constant, that’s just a string. Write CONTACT , make sure you have it defined ;)

55 posts
  • Has been part of the Envato Community for over 5 years
  • Has collected 100+ items on Envato Market
topbuzza says

contact is the name of the breadcrumb?

In terms of the order of statement / format is this correct?

139 posts
  • Sells items exclusively on Envato Market
  • Has sold $1,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
  • Has been a beta tester for an Envato feature
+6 more
ram64 says

<?php if ($breadcrumb['text'] == 'ABOUT US' && 'CONTACT') { ?> Trying to show some specific content on pages but when i use a second constant (Contact) it does not work… where am i going wrong?
It should be
<?php 
    if ($breadcrumb['text'] == 'ABOUT US' && $breadcrumb['text'] ==  'CONTACT') {
?>

If you have more page names you want to check against just do a switch statement:

switch ($breadcrumb['text']) {
    case 'ABOUT US':
           // do something for this page
           break;
    case 'PORTFOLIO':
           // do something for this page
           break;
    case 'CONTACT':
           // do something for this page
           break;
}

Or if you want the same functionaliti for more pages do:

switch ($breadcrumb['text']) {
    case 'ABOUT US':
    case 'PORTFOLIO':
    case 'CONTACT':
           // do something for this page
           break;
}
55 posts
  • Has been part of the Envato Community for over 5 years
  • Has collected 100+ items on Envato Market
topbuzza says

thanks mate, really appreciate the info!

55 posts
  • Has been part of the Envato Community for over 5 years
  • Has collected 100+ items on Envato Market
topbuzza says
<?php if ($breadcrumb['text'] == 'ABOUT US' && $breadcrumb['text'] == 'CONTACT') { ?> this appears to return null on the contact page?
139 posts
  • Sells items exclusively on Envato Market
  • Has sold $1,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
  • Has been a beta tester for an Envato feature
+6 more
ram64 says
Sorry, it should be
<?php if ($breadcrumb['text'] == 'ABOUT US' || $breadcrumb['text'] == 'CONTACT') { ?>
Notice the || instead of &&.
1497 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+2 more
OriginalEXE says

Also, if you are not trying to compare actual string but the constant, you should not use ‘CONTACT’ but only CONTACT .

The same goes for ABOUT US .

1329 posts
  • Has been part of the Envato Community for over 2 years
  • Has referred 200+ members
  • Has sold $125,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+8 more
Pricop says

<?php if ($breadcrumb['text'] == 'ABOUT US' && $breadcrumb['text'] == 'CONTACT') { ?> this appears to return null on the contact page?

ram64 is right, you should use the OR statement, instead of &&, here is a useful links with PHP operators: http://www.w3schools.com/php/php_operators.asp

&& is not used correctly in your if statement, currently you are checking if $breadcrumb[‘text’] == is equal first with about us and then with contact, and if that is true, only then execute the if statement.

by
by
by
by
by
by