I've been messing with php for a few weeks now and haven't been able to find this answer.
Basically what I'm trying to do is make a news template for my site and add an article to it so I don't have to make a page for each article. I was thinking news.php?filename then whatever the file name do the include command on the page. Any help would be appreciated.
Get a file and add it example: news.php?filename
Moderator: General Moderators
Re: Get a file and add it example: news.php?filename
Why not use a database?
Re: Get a file and add it example: news.php?filename
Databases are out of my league at the moment. I'm just trying to save myself a ton of page edits if I need to add something to a template and my articles start reaching the 10-20 range.
Re: Get a file and add it example: news.php?filename
Well...you're probably setting yourself up for more work in the long run by not using a database....
But what are you having trouble with?
You could do this:
But what are you having trouble with?
You could do this:
Code: Select all
//all your formatting
$tpl = basename($_GET['filename']);
$tpl = ((in_array($tpl, array('valid', 'template', 'files')) ? $tpl : 'default_template').'template_extension';
include $tpl;
//more formatting