473,473 Members | 2,357 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

discussion: script structuring and mod_rewrite?


hi group.

i'm tackling a bigger project that will use mod_rewrite to patch
a series of urls into a master php-script. this script builds the
page framework that contains a series of elements that remain on
every page. only a center part (a <div>) is filled with different
contents, depending on how the page is called (= mode of the page).
the point is, there are quite a few (approx 20) different 'modes'
for the center part to be filled with.

so now i wonder, what kind of approaches you guys use to keep the
project and all the subpages/includes/static elements as flexible
and clear as possible. there's really many ways to do this but i
can't yet decide on 'the right way' to do it...

let me examplify this:

/program index.php?mode=program
/movie index.php?mode=movie
/reservation index.php?mode=reservation
etc...
+-------------------+
|menu |
|calendar |
|etc.. |
| +--------------+ |
| | content 1 | |
| | ... | |
| | content 20 | |
| | | |
| +--------------+ |
| footer, banner... |
+-------------------+
- one way would be to have a master php script and include ALL
subitems such as menu, calendar etc. as well as the contents
that go in the main content section, thus keep everything in
.inc files besides tha main logic. (= whole project becomes a
huge puzzle). as such:

index.php [the logic switch]
menu.inc [decoration elements]
calendar.inc
footer.inc
banner.inc
content1.inc [content elements]
content2.inc
content3.inc

- another way would be to make many master pages for evey mode and
only include the framework-items (= every page-type can be
edited as one, only the framework-items are detached). of
course mod_rewrite would properly map the calls to those pages...

content1.php [content pages]
content2.php
content3.php

menu.inc [framework elements]
calendar.inc
footer.inc
banner.inc

- then the version with the exact opposite:

index.php (with menu, calendar, footer elements fix)
content1.inc
content2.inc
content3.inc

- make one HUGE page with all the subelements in the same script
and tons of switches and if's to turn them on and off.

index.php (menu, cal, footer, content 1-20 as switches)
what would you suggest? is there a way that i'm missing?
speedwise, all the versions should be more or less that same...

are there any tutorials or links that deal with these kinds of
structuring issues? i know i'm starting bible studies here, but
i think the discussion is pretty relevant also for newbies.
thanks already for all the input!
Feb 12 '07 #1
2 1993
Rik
On Tue, 13 Feb 2007 00:11:29 +0100, Susanne West <sw***@gmx.dewrote:
i'm tackling a bigger project that will use mod_rewrite to patch
a series of urls into a master php-script. this script builds the
page framework that contains a series of elements that remain on
every page. only a center part (a <div>) is filled with different
contents, depending on how the page is called (= mode of the page).
the point is, there are quite a few (approx 20) different 'modes'
for the center part to be filled with.

so now i wonder, what kind of approaches you guys use to keep the
project and all the subpages/includes/static elements as flexible
and clear as possible. there's really many ways to do this but i
can't yet decide on 'the right way' to do it...

let me examplify this:

/program index.php?mode=program
/movie index.php?mode=movie
/reservation index.php?mode=reservation
etc...
+-------------------+
|menu |
|calendar |
|etc.. |
| +--------------+ |
| | content 1 | |
| | ... | |
| | content 20 | |
| | | |
| +--------------+ |
| footer, banner... |
+-------------------+
- one way would be to have a master php script and include ALL
subitems
- another way would be to make many master pages for evey mode and
only include the framework-items (= every page-type can be
edited as one, only the framework-items are detached).
- then the version with the exact opposite:
index.php (with menu, calendar, footer elements fix)
content1.inc
content2.inc
content3.inc

- make one HUGE page with all the subelements in the same script
and tons of switches and if's to turn them on and off.
what would you suggest? is there a way that i'm missing?
speedwise, all the versions should be more or less that same...
Bigger project -go for a database.

Specify in the database what modes require what scripts, what pages have
what content (possibly storing flat HTML directly in the database for easy
maintainability). Make an interface for it, and presto, with u few
buttonclicks most of the pages adapt directly to how you want them,
without fiddling about in tons of files.

I usually define one or several layouts, store a page-tree in the database
and link layout-id's to the pages as desired. Create content (where
'content' can be flat HTML, the name of a (php-)file to include, some
custom wrapper around a certain database-queries, etc.), and again link
that to the pages. Voilą, the beginnings of your own custom build CMS.

--
Rik Wasmus
Feb 12 '07 #2
Rik wrote:
>
Bigger project -go for a database.

Specify in the database what modes require what scripts, what pages
have what content (possibly storing flat HTML directly in the database
for easy maintainability). Make an interface for it, and presto, with u
few buttonclicks most of the pages adapt directly to how you want
them, without fiddling about in tons of files.

I usually define one or several layouts, store a page-tree in the
database and link layout-id's to the pages as desired. Create content
(where 'content' can be flat HTML, the name of a (php-)file to include,
some custom wrapper around a certain database-queries, etc.), and again
link that to the pages. Voilą, the beginnings of your own custom build
CMS.
hi.

i know what you're heading after. the point is, that a raw db with data
exists, and i don't want to build a page-based db besides. all i need is
already in a relational structure and i only have to pull it out in
different ways. that can easily be done with identifyable modules and
routines which is much faster than to build a whole page-system on top.

what you describe makes maily sense if you have tons of manually-
maintained pages. then i'd opt for a page-db also. also, i don't have
'different' layouts with modules that are turned on/off depending of the
page. it's really just a framework with the same components around
all the time...

greets.
Feb 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Geoff Soper | last post by:
I'm not quite sure if the answer to my question lies in the Apache or PHP realm. If I have a php script running on Apache which outputs a JPEG image such as...
4
by: Phil Powell | last post by:
http://www.sitepoint.com/article/910/2] How can it be possible to use Apache's mod_rewrite module in such a way as to dynamically feed it variable information into the "RewriteRule" option? I...
3
by: Peter Gaunt | last post by:
My site is based on XML templates and uses a PHP script to turn them into XHTML. The script use the expat parser functions and works just fine. The XSLT extensions are not enabled on the server. ...
1
by: Andrew Chalk | last post by:
I am developing a CGI app, When the user loads my page I want to populate an HTML 'select' box (drop down menu) with items from a database. What is the best way to get my Python procedure that does...
3
by: Jedediah Smith | last post by:
In order to facilitate search engine indexing, I'd like to be able to access a script using something like this: http://server/script.asp/param where this would execute script.asp which could...
0
by: reggie wasson via .NET 247 | last post by:
If I write an ASP.NET application, and want to have client sideediting, validation, and the like, I believe I can only do itwith java script. If so, does there exist a framework or bestpractices for...
11
by: joelbyrd | last post by:
I have a people-networking type site in which each user has their own profile page, with their user id encoded. So, for example, the web address of their page might look like...
7
by: Wladimir Borsov | last post by:
I want to call a perl script myscript.pl in my cgi-bin from a HTML web page. This call should NOT use SSI (because in this case HTTPS://.... protocol is necessary). Furthermore NO button click...
2
by: King Ron | last post by:
Ola all. In responding to a recent post requesting help with a search issue, I recommended using a combo box lookup in the table design. "paii, Ron" (no relation) posted this reply: " There are...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.