ilikephp Posted April 24, 2008 Share Posted April 24, 2008 hi guys!! is there a way to put my website name in the title bar of I.E without putting it in each page? for example: "Wecome to my website" I want it to be displayed in all the webpages, so if I need to modify it, I modify in the css file. Can we do it? Thanks... Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/ Share on other sites More sharing options...
jonsjava Posted April 24, 2008 Share Posted April 24, 2008 config.inc.php (example) <?php $title = "hello world!"; ?> in your header: <?php include("config.inc.php"); <html> <title><?php print $title; ?></title> Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-525987 Share on other sites More sharing options...
The Little Guy Posted April 24, 2008 Share Posted April 24, 2008 put it in a file (include.php) like this: <?php $siteTitle = 'Welcome to my website'; ?> then have all your pages formatted like this: <?php include 'include.php'; ?><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title><?=$siteTitle;?></title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <!-- HTML HERE --> </body> </html> Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-525991 Share on other sites More sharing options...
ProblemHelpPlease Posted April 24, 2008 Share Posted April 24, 2008 As long as your files are php files then you can simply add require("title.php"); to each page where you would normally put the title. The file title.php would consist of <title>The title of your website</title> You can then alter the title on every page by altering the title.php file Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-525992 Share on other sites More sharing options...
jonsjava Posted April 24, 2008 Share Posted April 24, 2008 This topic is beginning to show why PHP is so great. 1 billion ways to do the exact same thing, and it's all dependent on how you like to code. Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-525995 Share on other sites More sharing options...
ilikephp Posted April 24, 2008 Author Share Posted April 24, 2008 Thanks !! it works.. but I have a very small problem: when I put: <?php include "/www/arabic/include.php"; ?> everything is OK coz www is the folder of the server in my windowx XP What can I put if I need to upload it on the server(online) coz there is no www Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-526121 Share on other sites More sharing options...
Daniel0 Posted April 24, 2008 Share Posted April 24, 2008 Whatever other directory your script is in. Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-526145 Share on other sites More sharing options...
The Little Guy Posted April 24, 2008 Share Posted April 24, 2008 instead I would use relative linking instead. so use ../ to move up one directory. if your tree looks like so: /root /folder1 /file1.php /file2.php /folder2 /file1.php /folder3 and your in folder2/file1.php, and you want to go to folder1/file2.php, you would do this: <?php include('../folder1/file2.php');?> doing it this way, will allow the site to work on any server at any depth. Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-526148 Share on other sites More sharing options...
ilikephp Posted April 24, 2008 Author Share Posted April 24, 2008 <?php include ('../arabic/include.php'); ?> .. is the root I receive: Warning: include(../arabic/include.php) [function.include]: failed to open stream: No such file or directory in C:\www\arabic\SubPage\Fathers\index.php on line 2 Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-526167 Share on other sites More sharing options...
The Little Guy Posted April 24, 2008 Share Posted April 24, 2008 try this: <?php include ('../../arabic/include.php'); ?> Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-526171 Share on other sites More sharing options...
ilikephp Posted April 24, 2008 Author Share Posted April 24, 2008 Warning: include(../../arabic/include.php) [function.include]: failed to open stream: No such file or directory in C:\www\arabic\SubPage\Fathers\index.php on line 2 Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-526172 Share on other sites More sharing options...
jonsjava Posted April 24, 2008 Share Posted April 24, 2008 try <?php /* Place it in the same folder as the file calling it */ include("include.php"); Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-526175 Share on other sites More sharing options...
ilikephp Posted April 24, 2008 Author Share Posted April 24, 2008 in this way, it works, but the problem is when I put it inside folders ??? Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-526177 Share on other sites More sharing options...
ilikephp Posted April 24, 2008 Author Share Posted April 24, 2008 /root /arabic /include.php /SubPage /Fathers /index.php inside include: I have the script for the title inside index: I am puting this: <?php include ('../arabic/include.php'); ?> Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-526200 Share on other sites More sharing options...
The Little Guy Posted April 24, 2008 Share Posted April 24, 2008 I wouldn't place it in the same folder, because what will happen if you try to access it from another file outside that folder? You may run into the problem again. I would make in "incl" folder in the root folder. This will hold all the included files (functions.php, db.php, globalVariables.php) so it would look like this: /root /incl /functions.php /db.php /globalVariabls.php /arabic /SubPage /Fathers /index.php Then you will want to add a file in the /incl folder called "includes.php", so now your directory structure would look like this: /root /incl /functions.php /db.php /globalVariabls.php /includes.php /arabic /SubPage /Fathers /index.php In the file "includes.php" you would place this: <?php include 'functions.php'; include 'db.php'; include 'globalVariabls.php'; ?> In the file index.php (your current file), you would have this: <?php include '../../../incl/includes.php'; ?><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title><?=$siteTitle;?></title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <!-- HTML HERE --> </body> </html> Now, this file contains everything that is in the incl folder. Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-526203 Share on other sites More sharing options...
ilikephp Posted April 24, 2008 Author Share Posted April 24, 2008 in the file include.php I have this: <?php $siteTitle = 'Welcome to my website'; ?> should I remove it and put: <?php include 'functions.php'; include 'db.php'; include 'globalVariabls.php'; ?> and in this function:include '../../../incl/includes.php'; why I have .. (3 times)? before the folder incl I have the root only? Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-526238 Share on other sites More sharing options...
ilikephp Posted April 24, 2008 Author Share Posted April 24, 2008 now it works and I put it inside the folder arabic but why I put: include ('../../../arabic/include.php'); ../../../ (3 time?) Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-526256 Share on other sites More sharing options...
The Little Guy Posted April 24, 2008 Share Posted April 24, 2008 for every "../" it moves up a directory. This is so you don't have to list all your include files in every file, just a link to this file, which will add all the files you need to the running file, it makes for less typing (the files must exist though). <?php include 'functions.php'; include 'db.php'; include 'globalVariabls.php'; ?> Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-526264 Share on other sites More sharing options...
ilikephp Posted April 24, 2008 Author Share Posted April 24, 2008 thx Link to comment https://forums.phpfreaks.com/topic/102721-solved-welcome-message-in-title-bar/#findComment-526266 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.