I got this working in Drupal but could not get these separate calls to be combined. Can anyone help with teh syntax?
$currentpage = $_SERVER['REQUEST_URI'];
if ( strstr( $currentpage, "term1") )
{
$match = FALSE;
}
if ( strstr( $currentpage, "term2") )
{
$match = FALSE;
}
even better if you can combine this as well:
if (drupal_is_front_page())
{
$match = FALSE;
}
Combine these
Moderator: General Moderators
Re: Combine these
is there something that couldn't be solved with a Logical Operator ?
Re: Combine these
I think yes but I just cannot get the syntax right. Any help would be appreciated. Want to streamline this to decrease server load.
Re: Combine these
Consolidating this will not likely have a noticeable effect on server performance - it's just a few lines. However, you can do something like this:
This means that if the value of $currentpage is in that array, set $match to FALSE, and if not, set to TRUE.
Code: Select all
$match = (!in_array($currentpage, array('term1', 'term2')))Re: Combine these
I could not get your suggestion to work. Do you have the full syntax?
I was however able to get this to work but would still like to learn your array method. Seems it would be more efficient?
$currentpage = $_SERVER['REQUEST_URI'];
if (strstr( $currentpage, "term1") || strstr( $currentpage, "term2"))
{
$match = FALSE;
}
I was however able to get this to work but would still like to learn your array method. Seems it would be more efficient?
$currentpage = $_SERVER['REQUEST_URI'];
if (strstr( $currentpage, "term1") || strstr( $currentpage, "term2"))
{
$match = FALSE;
}