Curiosity - moving meta data to external file

From the server you should see the PHP codes. In a browser window (doesn't have to be Firefox) it should be the HTML. Does that solve the "problem" ?

Make sure both your pages are php files...
 
Hmm, there are some flaws with the code anyway. There's loads of CSS in the page itself instead of in the CSS file.

Basically all you need to do is take pageName.html, rename it pageName.php and then move chunks into includes, it should always work… I can't really guess anything without seeing it.
 
Onartis said:
From the server you should see the PHP codes. In a browser window (doesn't have to be Firefox) it should be the HTML. Does that solve the "problem" ?

Make sure both your pages are php files...
tried with both as php files

Harry said:
Hmm, there are some flaws with the code anyway. There's loads of CSS in the page itself instead of in the CSS file.
- blame golive

Basically all you need to do is take pageName.html, rename it pageName.php and then move chunks into includes, it should always work… I can't really guess anything without seeing it.
I forgot the link :eek: - linky (just had a thought though, it could be server side), I'll upload it to my home server and check there (I'll add link shortly)
 
Use Notepad++, or at least a code editor rather than WYSIWYG. Post the exact code for you index.php page each of your .php includes.
 
ok its my host side (they're crap - I've told them about the php before)

this should work but it may not be on all the time

I've attached the files as txt as the post was too big.

I forgot to say too, Harry I've tried shifting the css from the page into the main css file (as its the same on all pages) but it keeps making the page disappear (annoying as this is a common thing for me :)) so being that I'm no coder I said sod it and left it be.

thanks for all the help by the way, if its a lot of work to get right don't worry over it, I'll just stick with the every page approach
 

Attachments

  • header.txt
    891 bytes · Views: 2
  • index2.txt
    8.4 KB · Views: 2
Okay, big 'my bad'. You need a ; after each variable in your PHP:

PHP:
<?php
$pageName = 'My Site homepage';
$pageID = 'home';
include("/includes/header.php");
?>

EDIT: You also have closing body and html tags in the header.php file. These are effectively closing the page before any content even hits it. Put all that in-page CSS into the css file.


header.php at its most basic:
PHP:
<html>
<head>
<title><?php echo pageName; ?></title>
</head>
<body id="<?php echo pageID; ?>">

index2.php at its most basic:
PHP:
<?php
$pageName = 'page name here';
$pageID = 'home';
include("/includes/header.php");
?>
[content]
<?php
include("/includes/footer.php");
?>

footer.php at its most basic:
HTML:
</body>
</html>
 
Damn you, Harry! Teaching us wrong stuff :<

Lol, I hadn't noticed it either. But I only know the basics of PHP (I guess that includes the colon at the end, but let's ignore that fact for now :p) :D
 
I'll do some more changes later, my heads started to spin a little on it :)

Harry as I said I've already tried shifting all the page css into the css file, it just does not like it and everything disappears, its actually quite annoying too.
 
That's what WYSIWYG will do to your hard work—wipe its arse on it ;)

You'll probably just need to update file paths etc.
 
Yeah I totally back Harry's way of doing it up.
The other benefit which I didn't read is preformance, that being that the server actual caches include files so all the code in an include is already cached and thus loads quicker on a primed cache page.

Expanding on Harry's solution a little I always find it better to define a constant then test for the constant in the include then you can do far more things.

For example ~

<?php define("PAGE","home");
include"inc/header.php"?>


Then in header.php you can right.
<?php if(PAGE=="home"){?>
<title>Welcome to our home page</title>
<meta description.....
<meta keywords....

<?php }elseif(PAGE=="portfolio"){?>
<title>Welcome to our portfolio page</title>
<meta description.....
<meta keywords....

<?php }if(PAGE=="home"){?>
<link href="css/home.css" rel="stylesheet" type="text/css" media="screen" />

<?php }else{?>
<link href="css/2.00.css" rel="stylesheet" type="text/css" media="screen" />
<?php }?>
</head>
<ul>
<li>
<?php if(PAGE=="home"){?><b>Home</b><?php }else{?><a href="">Home</a><?php }?></li>
<li>
<?php if(PAGE=="portfolio"){?><b>Portfolio</b><?php }else{?><a href="">portfolio</a><?php }?></li>
....
<li><?php if(PAGE=="contact"){?><b>Contact us</b><?php }else{?><a href="">Contact us</a><?php }?></li>


Which just gives you more possibilities based on the page you are on and what you are trying to do especially from an SEO possibility, so rather than creating 15 odd variables on each page you create 1 and then change within the page again making maintenance slightly easier.

You can then also use includes within includes which helps with smaller files and again improving caching. So we could change the header.php include to

<?php include"meta.php";
include"css.php";
include"nav.php"?>


But also remember this can be used to include the footer as well, didn't read that, but it does make site changes a lot easier to manage form just 1 file rather than opening up 6 or 7 different files to make small changes.

Jaz :)

Key:
Red ~ PHP
Blue ~ XHTML
 
Decided to not bother with this in the end, I'm going to have slightly different keywords on each page so that its more focused to that page plus google (which lets be honest is probably the search engine of 90% of the population) doesn't take too much notice of meta keywords it would seem although I'm going to have them as some others do use them.
 
Yahoo! is still the only 1 that may use then, but as Yahoo! will more then likely be selling out to Bing, well for it's search results as Bings search results are amazing, then the only ones that will use it will be meta search engines which get no traffic TBH.

But you can do that approach using this as well.
Just check for the page and test via an if statement and it writes the correct keyword tag to the page.

Jaz
 
Back
Top