Jonathan Davis
Jul 2 2005, 11:12 AM
Hello,
I am looking at converting my webpage to use php includes to save time in
updating the site. I would like to setup a template for the design and use a
php include to add the content into the page.
I was looking at something like:
www.domain.com/index.php?page.php
or
www.domain.com/index.php?news/newspage.php
So the first url would include the content from page.php within say a table
in index.php
And the second would include the content from newspage.php.
The content would always be in the same place on the index page so is there
is a php include i could use that would achieve this?
thanks, Jonathan
Stefan Rybacki
Jul 2 2005, 12:47 PM
Jonathan Davis wrote:
QUOTE |
Hello,
I am looking at converting my webpage to use php includes to save time in updating the site. I would like to setup a template for the design and use a php include to add the content into the page.
I was looking at something like:
www.domain.com/index.php?page.php or www.domain.com/index.php?news/newspage.php
|
First of all you shouldn't do it that way, because of security.
Better use something like www.domain.com/index.php?page=11111
where you can determine what page with 11111 is meant.
in index.php
$page_array=array('11111'=>'page.php');
include($page_array[$_REQUEST['page']]);
But note that isn't the right way anyway, at least you have to check
whether the requested page is available.
You also could use a real template system like smarty or try to
implement one for your own.
QUOTE |
So the first url would include the content from page.php within say a table in index.php And the second would include the content from newspage.php.
The content would always be in the same place on the index page so is there is a php include i could use that would achieve this?
thanks, Jonathan
|
Regards
Stefan
>
Jonathan Davis
Jul 2 2005, 01:30 PM
"Stefan Rybacki" <[Email Removed]> wrote in message
news:[Email Removed]...
QUOTE |
Jonathan Davis wrote: First of all you shouldn't do it that way, because of security. Better use something like www.domain.com/index.php?page=11111
where you can determine what page with 11111 is meant.
in index.php
$page_array=array('11111'=>'page.php');
include($page_array[$_REQUEST['page']]);
But note that isn't the right way anyway, at least you have to check whether the requested page is available. You also could use a real template system like smarty or try to implement one for your own.
|
Thanks for that Stefan, I was thinking there would be a big security risk
doing it that way.
I have setup a test of this and it seems to work fine.
Unfortunately with the way my site is setup, in order to get the whole site
done this would involve setting up a folder with every file in it (around
2000 files), and also having to rename most of them and rewrite a lot of
code....
I think an easier solution might be to include a index.php and a content.php
file in each subfolder (instead of just a index.php - which at the moment i
am having to manually redesign) so when i wanted to redesign the site i
could just create a single new index.php and paste it into all 30 folders so
i would not have to redesign all the content pages every time as the content
does not change.
www.classickidstv.co.uk is the site if anyone wants to check it out and see
if there is a better solution.
thanks for your response, Jonathan
Ian Hobson
Jul 2 2005, 08:37 PM
Take a look at phpCMS
This is a templating system that
a) Leaves existing files alone so you can install and convert file by
file.
b) Maps urls to hide the fact that it is a php script, so search engines
to index the pages.
c) Works easily on sites with php. It needs no database.
d) It is GPL. (Free download).
e) It is easy to set up.
In message <Byxxe.13194$[Email Removed]>, Jonathan Davis
<[Email Removed]> writes
QUOTE |
You also could use a real template system like smarty or try to implement one for your own.
Unfortunately with the way my site is setup, in order to get the whole site done this would involve setting up a folder with every file in it (around 2000 files), and also having to rename most of them and rewrite a lot of code....
I think an easier solution might be to include a index.php and a content.php file in each subfolder (instead of just a index.php - which at the moment i am having to manually redesign) so when i wanted to redesign the site i could just create a single new index.php and paste it into all 30 folders so i would not have to redesign all the content pages every time as the content does not change.
In phpCSM you point each data file (index.htm, or whatever.htm) to a |
format file. So updating the format is one file change (per layout -
you can have several).
By using sub-templates, you can update sub-areas on many layouts
(adverts?) by uploading one file.
Regards
Ian
--
Ian - posting to a Newsgroup. Please remove everything to reply.
Exyle
Jul 3 2005, 01:47 AM
Jonathan Davis wrote:
QUOTE |
"Stefan Rybacki" <[Email Removed]> wrote in message news:[Email Removed]...
Jonathan Davis wrote: First of all you shouldn't do it that way, because of security. Better use something like www.domain.com/index.php?page=11111
where you can determine what page with 11111 is meant.
in index.php
$page_array=array('11111'=>'page.php');
include($page_array[$_REQUEST['page']]);
But note that isn't the right way anyway, at least you have to check whether the requested page is available. You also could use a real template system like smarty or try to implement one for your own.
Thanks for that Stefan, I was thinking there would be a big security risk doing it that way. I have setup a test of this and it seems to work fine.
Unfortunately with the way my site is setup, in order to get the whole site done this would involve setting up a folder with every file in it (around 2000 files), and also having to rename most of them and rewrite a lot of code....
I think an easier solution might be to include a index.php and a content.php file in each subfolder (instead of just a index.php - which at the moment i am having to manually redesign) so when i wanted to redesign the site i could just create a single new index.php and paste it into all 30 folders so i would not have to redesign all the content pages every time as the content does not change.
www.classickidstv.co.uk is the site if anyone wants to check it out and see if there is a better solution.
thanks for your response, Jonathan
There isn't really a security risk unless somone visiting the url |
directly is an enourmously bad thing, in that case there's an easy way
to fix it: put all the included php files in another directory, unless
the intruder knows that directory name they wont be able to access the
files directly.
I looked at your site, and I have a few ideas for you.
But have you already done all of your file naming conventions? In
other words,, some of my ideas would take your url
http://www.classickidstv.co.uk/ripleyandscuff/and change it to
http://www.classickidstv.co.uk/ripley_and_scuff/That's ripley_and_scuff with underscores.
Interested?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.