I need help on php if else based on url to print certain information for meta tag info and title.
example if url contain only "sitename.com/?do=index" or "?do=index", it should print for <title> "default title", meta tag description will be "default meta tag description".
if the url contain "domain.com/?do=detailpage&" or "?do=detailpage", it should print "<title> not default title</tile>", meta tag description will be "not default meta tag description".
can anyone please help me?
thanks,
lioney
if else based on url to print certain info
Moderator: General Moderators
Re: if else based on url to print certain info
If I understand your question, it is: how do I specify a different value for the HTML Title tag, depending on the value of a variable in the URL?
Just use the value of that variable in an if(..) { ... } else { ... } or switch (..) { case ..: } block, like:
Just use the value of that variable in an if(..) { ... } else { ... } or switch (..) { case ..: } block, like:
Code: Select all
&do=$_GET['do'];
if($do=='.....') {
echo "<title>something</title>";
} else {
echo "<title>something else</title>";
}Re: if else based on url to print certain info
@ califdon
thank you so much for the reply.
I will try on your code.
I have a little problem with my script.
it's a classified script which I bought from website.
the title tag is coded on this file "site.com/templates/includes.html"
<AJDF:output>$site_settings.meta_tag</AJDF:output>
<title><AJDF:output>$site_settings.site_title</AJDF:output></title>
there is a controller file(Cpostings.php), model file (Mpostings.php) and also displaying file(Dpostings.php) .
all the displaying file will load the file the header.php and the header.php will load the includes.html(which the title tag is there).
Can anyone tell me how to code so I will get the different title on every different page?
I can try to code it on includes.html but I don't know how to begin.
Any tips will be a great help for this newbie php.......
thank you so much for the reply.
I will try on your code.
I have a little problem with my script.
it's a classified script which I bought from website.
the title tag is coded on this file "site.com/templates/includes.html"
<AJDF:output>$site_settings.meta_tag</AJDF:output>
<title><AJDF:output>$site_settings.site_title</AJDF:output></title>
there is a controller file(Cpostings.php), model file (Mpostings.php) and also displaying file(Dpostings.php) .
all the displaying file will load the file the header.php and the header.php will load the includes.html(which the title tag is there).
Can anyone tell me how to code so I will get the different title on every different page?
I can try to code it on includes.html but I don't know how to begin.
Any tips will be a great help for this newbie php.......