73 posts
  • 6 Years of Membership
  • Collector Level 4
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?

243 posts
  • Featured Author
  • 4 Years of Membership
  • Trendsetter
  • Weekly Top Seller
+6 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 ;)

73 posts
  • 6 Years of Membership
  • Collector Level 4
topbuzza
says

contact is the name of the breadcrumb?

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

141 posts
  • Weekly Top Seller
  • Exclusive Author
  • Author Level 3
  • 7 Years of Membership
+7 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;
}
73 posts
  • 6 Years of Membership
  • Collector Level 4
topbuzza
says

thanks mate, really appreciate the info!

73 posts
  • 6 Years of Membership
  • Collector Level 4
topbuzza
says
<?php if ($breadcrumb['text'] == 'ABOUT US' && $breadcrumb['text'] == 'CONTACT') { ?> this appears to return null on the contact page?
141 posts
  • Weekly Top Seller
  • Exclusive Author
  • Author Level 3
  • 7 Years of Membership
+7 more
ram64
says
Sorry, it should be
<?php if ($breadcrumb['text'] == 'ABOUT US' || $breadcrumb['text'] == 'CONTACT') { ?>
Notice the || instead of &&.
1565 posts
  • Affiliate Level 1
  • Author Level 5
  • Collector Level 2
  • Featured Author
+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 .

1406 posts
  • 3 Years of Membership
  • Affiliate Level 5
  • Author Level 8
  • Beta Tester
+9 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