Best way to dynamically update the content on my website

Soldato
Joined
1 Dec 2004
Posts
23,085
Location
S.Wales
Hi,

I have been developing myself a website lately using XHTML/CSS/PHP, however I want an easy way to update the content on my website, at the moment what im doing at the moment is editing each xhtml file individually with the content, ideally I would like to not have to edit the content on each page.

Please see below page for an example.

www.dmoranda.co.uk/newsite3

as you can see, the two main area's of concern are the left hand body sidebar div (this will be used as a newsfeed) I will be creating an admin page with a form that I can use to add content to this newsfeed div using PHP/CSS, storing the news in an SQL Database table - Does this seem the best way to accomplish this?

The main body div just to the right, I want to obviously add content to, but when a user selects a particular page to visit, I want the mainbody div to update? would this be the best way? otherwise I would have to go into each individual page and change the content. Also the newsfeed would be different on each page unless I kept them consistant?
 
Absolutely. It would give you an RSS feed for your news as well :). Use Wordpress and use 'posts' for your news and 'pages' for everything else.

tonyyeb - it'll take no time at all to install, will be really easy to use and will give him a load of extra advantages - so why not?
 
Here is what I do. You take all content and put them into .php files. You can then include them into your content when a link is clicked. This means you only have 1 page to edit to make changes to the layout.

So in your index.php you place this:
PHP:
	<?php
	$base = './include';

	if (!isset($_GET['page']) || empty($_GET['page']))   
	{
		$file = "$base/home.php";
	}
	else
	{
		$page = preg_replace('/[\W\.-]/si', '', $_GET['page']);
		$file = "$base/$page.php";
	}

	$file = file_exists($file) ? $file : "$base/404.php";
	require $file; 

	?>

Then links will look like this:

PHP:
<a href="index.php?page=home" title="Home">Home</a>

All of the content for the homepage will be in ./include/home.php
 
Here is what I do. You take all content and put them into .php files. You can then include them into your content when a link is clicked. This means you only have 1 page to edit to make changes to the layout.

So in your index.php you place this:
PHP:
	<?php
	$base = './include';

	if (!isset($_GET['page']) || empty($_GET['page']))   
	{
		$file = "$base/home.php";
	}
	else
	{
		$page = preg_replace('/[\W\.-]/si', '', $_GET['page']);
		$file = "$base/$page.php";
	}

	$file = file_exists($file) ? $file : "$base/404.php";
	require $file; 

	?>

Then links will look like this:

PHP:
<a href="index.php?page=home" title="Home">Home</a>

All of the content for the homepage will be in ./include/home.php



Thanks for this, so let me get this straight, you have one main .php page (index.php) which has the above code, and the menu links, when you click on each menu link it will use the "GET Page" feature to get the content from another php page?

how is this other php page set-up?

A working example of this would be perfect (How the index.php page will look) and how the php page holding the content will look.

Thanks very much for that. :)
 
How easy would it be to integrate Wordpress with an existing site design?

Ideally would like to do what fini suggested and use 'posts' for news and 'pages' for everything else.

Downloading now to have a look but wondered on exisiting users thoughts?

Sorry to hijack thread btw :)
 
It should be relatively easy - just chop your design in to a header, main content and footer and replace where the text should be with 'the loop'.

Whilst I'm sure MSM's solution will work, it's horrible from an SEO perspective.
 
How so fini? I'm curious as the website I have this on is ranked very well for it's target searches.
 
What are the pro's/con's of using PHP's get function to dynamically load page content?

I would like to know to choose which route I am going to go down.

Any help greatly appriciated.
 
How so fini? I'm curious as the website I have this on is ranked very well for it's target searches.

One of the things that Google takes in to account when ordering the SERPS is having the term in the URL. Whilst theoretically these two URLs both have the same term in them:
www.xyz.com/bluewidget/
www.xyz.com/index.php?page=bluewidget

All the tests I've seen pull towards Google treating the latter as if it was just index.php (it'll still be able to link to it, but wont give it any extra cudos for having the term in the url). Additionally if you saw those two URLs you're far more likely to click on the first and thus click-through rates are greatly increased on the first.

Additionally, you can do some nice sorting like:
www.xyz.com/widgets/blue/
which just looks messy if you're trying to stuff that in to a php query.
 
My basic website wasn't built around a framework so structuring things as you mention wasn't considered. Are there any easy ways to accomplish the URL structure you recommend?
 
One of the things that Google takes in to account when ordering the SERPS is having the term in the URL. Whilst theoretically these two URLs both have the same term in them:
www.xyz.com/bluewidget/
www.xyz.com/index.php?page=bluewidget

All the tests I've seen pull towards Google treating the latter as if it was just index.php (it'll still be able to link to it, but wont give it any extra cudos for having the term in the url). Additionally if you saw those two URLs you're far more likely to click on the first and thus click-through rates are greatly increased on the first.

Additionally, you can do some nice sorting like:
www.xyz.com/widgets/blue/
which just looks messy if you're trying to stuff that in to a php query.

Have you got any source dis/proving the /bluewidnet vs ?page=bluewidget argument, other than your own tests? I'd be really interested! :)

Thanks
 
One of the things that Google takes in to account when ordering the SERPS is having the term in the URL. Whilst theoretically these two URLs both have the same term in them:
www.xyz.com/bluewidget/
www.xyz.com/index.php?page=bluewidget

All the tests I've seen pull towards Google treating the latter as if it was just index.php (it'll still be able to link to it, but wont give it any extra cudos for having the term in the url). Additionally if you saw those two URLs you're far more likely to click on the first and thus click-through rates are greatly increased on the first.

Additionally, you can do some nice sorting like:
www.xyz.com/widgets/blue/
which just looks messy if you're trying to stuff that in to a php query.

You shouldn't try to take this URI scheme further than is appropriate though; it only works for hierarchical URI elements.
 
Back
Top Bottom