hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : PHP and Dynamic <head><title>
Reply

Forum Jump

PHP and Dynamic <head><title>

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 03-11-2008, 05:59 PM
chrismfz chrismfz is online now
Junior Guru
 
Join Date: Feb 2006
Location: Greece
Posts: 183

PHP and Dynamic <head><title>


Hello people.

I designed a website using isset for exploring it.

Example of index.php:
Code:
<?php
include_once("menu.php");
include_once("functions.php");
?>
I got a static menu file something like this:
menu.php:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7" />
...
...
<title> static title here </title>
...
...
link1, link2, link3, linkX
...
and the functions.php which loading all the rest:
functions.php:
Code:
<?php

if(isset($_GET['something'])){
 include("afile.php");
}

elseif(isset($_GET['about'])){
 include("about.php");
}
...
...
etc
So if someone type a www.domain.com/?about after the already
included menu, the file about.php will be included.

I tried to make this work:
eg after the isset to set a $title=something related

and in the menu.php which have the <title> to add:
Code:
<title><?php echo $title ?> </title>
but it didnt worked.
A friend told me that this should be BEFORE the menu.php
but I cant include functions before menu for logical reasons..
(I need the menu in the top of course)

I dont know if I can do this including a second functions like
php but in the if commands to set a title var only not include.

And generally I got confused with this.
Any ideas?

Regards,
Chris



Sponsored Links
  #2  
Old 03-11-2008, 06:10 PM
ZeroPing ZeroPing is offline
Junior Guru Wannabe
 
Join Date: Oct 2006
Posts: 76
Don't use a static menu.php with the title tag. In the menu.php, check if the query string (about or whatever) is present - if so, display it within the title tag. If not, display a default title.

  #3  
Old 03-11-2008, 09:29 PM
AmyWilliams AmyWilliams is offline
Aspiring Evangelist
 
Join Date: Mar 2008
Location: Sheffield, UK
Posts: 447
I think this has something to do with the scope of the variables you are using. You might have to make some of them global.

__________________
If we do not plant knowledge when young, it will give us no shade when we are old.
Lord Chesterfield


Sponsored Links
  #4  
Old 03-11-2008, 09:38 PM
chrismfz chrismfz is online now
Junior Guru
 
Join Date: Feb 2006
Location: Greece
Posts: 183
I dont want to make them global and still I didnt find
a solution searching all evening...

  #5  
Old 03-12-2008, 04:28 AM
ZeroPing ZeroPing is offline
Junior Guru Wannabe
 
Join Date: Oct 2006
Posts: 76
Sorry, didn't read your post carefully enough. Obviously, your menu.php file tries to echo the title.

The problem is the order in which files are loaded - as far as I know, you can't reference from an earlier loaded file a variable whose value is set later.

I have a simpler solution. In about.php / other similar pages, insert a javascript function executing on load of the body, that sets document.title = Title of Page

Let the default title be 'Loading Page...'

This is a bit messy, but should work.

  #6  
Old 03-12-2008, 07:34 AM
Fox-Rice Fox-Rice is offline
Newbie
 
Join Date: Mar 2008
Posts: 7
Or, my suggestion would be for you to make a default page(as in if no get variable is set change the title, ect. to something) and then make the function page run like thing:
Code:
<?php
if (isset($_GET["something"]))
{$title=*whatever*;
include("menu.php");
include("afile.php");}

else if (isset($_GET["about"])){
$title="The About Page";
include("menu.php");
include("about.php");
}

else 
{$title="Home Page";
include("menu.php");
include("index.php");}
The reason its not changing the title ect. is because you can't dynamically change the title of a page through php last time i checked.

Reply

Related posts from TheWhir.com
Title Type Date Posted
ICANN Bulk Transfers Domains from Dynamic Dolphin to BigRock Web Hosting News 2013-12-27 12:04:23
The 451 Group Acquires Research Firm Applied Velocity Labs Web Hosting News 2013-02-26 15:30:32
CloudFlare Railgun Offers Hosting Customers One-Click Dynamic Caching Web Hosting News 2013-02-27 10:44:29
Cloud Expo Europe 2013 Web Hosting Events 2012-12-05 14:26:07
Sign Up for Wednesday's Webinar on Evaluating Lead Generation Opportunities Blog 2012-09-11 11:29:35


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?