53 posts
  • Bought between 100 and 499 items
  • Has been a member for 5-6 years
  • United Kingdom
senshi 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?

184 posts
  • Argentina
  • Sold between 10 000 and 50 000 dollars
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Has been a member for 3-4 years
  • Referred between 10 and 49 users
  • Exclusive Author
  • Bought between 1 and 9 items
SurStudio says

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

53 posts
  • Bought between 100 and 499 items
  • Has been a member for 5-6 years
  • United Kingdom
senshi says

contact is the name of the breadcrumb?

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

127 posts
  • Author had a Free File of the Month
  • Exclusive Author
  • Sold between 1 000 and 5 000 dollars
  • Romania
  • Has been a member for 5-6 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Bought between 1 and 9 items
  • Referred between 1 and 9 users
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;
}
53 posts
  • Bought between 100 and 499 items
  • Has been a member for 5-6 years
  • United Kingdom
senshi says

thanks mate, really appreciate the info!

53 posts
  • Bought between 100 and 499 items
  • Has been a member for 5-6 years
  • United Kingdom
senshi says
<?php if ($breadcrumb['text'] == 'ABOUT US' && $breadcrumb['text'] == 'CONTACT') { ?> this appears to return null on the contact page?
127 posts
  • Author had a Free File of the Month
  • Exclusive Author
  • Sold between 1 000 and 5 000 dollars
  • Romania
  • Has been a member for 5-6 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Bought between 1 and 9 items
  • Referred between 1 and 9 users
ram64 says
Sorry, it should be
<?php if ($breadcrumb['text'] == 'ABOUT US' || $breadcrumb['text'] == 'CONTACT') { ?>
Notice the || instead of &&.
1400 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
  • Croatia
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 .

1189 posts
  • Bought between 1 and 9 items
  • Elite Author
  • Exclusive Author
  • Has been a member for 2-3 years
  • Microlancer Beta Tester
  • Most Wanted Bounty Winner
  • Referred between 200 and 499 users
+3 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