- Impact
- 2,382
I'm trying to help out a friend that has been stuck with a site built with a proprietary CMS.
In an effort to help her site's SEO, I've created a few hacks that should improve things, but my overall PHP-fu is weak.
I'm trying to hack the Description meta tag so that it will use a truncated portion of a variable (please excuse me if my nomenclature is incorrect) if that variable exists. If the variable does not exist, an alternate "standard" piece of information should be used.
What I think I'm looking for is an an "if else" sort of thing.
I came up with the following chunks of code that work individually, but I've been unsuccessful in getting them to work together as an "if else" statement.
Display the Variable Description
Display the "Standard" Description
So in a nutshell...
If the variable exists/is not empty then use/display the truncated Variable, otherwise (else) display the Standard description.
Thank you in advance!
In an effort to help her site's SEO, I've created a few hacks that should improve things, but my overall PHP-fu is weak.
I'm trying to hack the Description meta tag so that it will use a truncated portion of a variable (please excuse me if my nomenclature is incorrect) if that variable exists. If the variable does not exist, an alternate "standard" piece of information should be used.
What I think I'm looking for is an an "if else" sort of thing.
I came up with the following chunks of code that work individually, but I've been unsuccessful in getting them to work together as an "if else" statement.
Display the Variable Description
Code:
<?php
{
echo '<meta property="og:description" content="'.substr(strip_tags($getVARIABLE1['description']),0,110).'" />';
}
?>
Display the "Standard" Description
Code:
<?php
{
echo '<meta property="og:description" content="blah, blah, blah... Boilerplate text..." />';
}
?>
So in a nutshell...
If the variable exists/is not empty then use/display the truncated Variable, otherwise (else) display the Standard description.
Thank you in advance!
Last edited: