473,748 Members | 4,697 Online
Bytes | Software Development & Data Engineering Community
+ 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 2004
Rik
On Tue, 13 Feb 2007 00:11:29 +0100, Susanne West <sw***@gmx.dewr ote:
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
6141
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 http://domain/get_image.php?id=15&size=thumb can I somehow disguise it as http://domain/image15_thumb.jpg to allow browser caching? I'm assuming the majority of people's browsers don't cache images generated from scripts such as PHP? For this reason I would imagine the solution...
4
2583
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 am having to get info from a db call and then feed it into RewriteRule since the rule will be, to a degree, dynamic. Is this what I would be doing; if so, can I use a PHP script to call this, set the vars and make this happen? What must I do? ...
3
2005
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. At the moment I am passing requests for the XML files to the script by setting up .xml as a PHP file using AddType and then using a mod_rewrite rule to ensure that the request gets handled by the script (don't laugh!). This is all set up in...
1
1745
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 this called when the page is loaded? Many thanks
3
2439
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 then retrieve the extra data "param" using the PATH_INFO server variable. PHP has a feature similar to this and I've heard that IIS can do the same thing but I'm not quite sure how. I've already enabled PATH_INFO as detailed here:
0
851
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 structuring my java script in VB.NET classes,rather than having just stray script throughout theapplication? -------------------------------- From: reggie wasson ----------------------- Posted by a user from .NET 247...
11
2074
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 "www.example.com/my_profile.php?user_id=fdjkhfh2489298hf298h3s0dhfxj". I want the users to be able to choose their own web address that would look like "www.example.com/Joel", and then when they type in that address, they are automatically redirected to their profile...
7
9923
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 should be required (so I am not talking about a perl script in a form). I only want to call this script automatically when someone load the web page. How can I do this ? If necessary the perl script could return a value (e.g. a picture resp....
2
2901
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 many posts in this group explaining the pitfalls of using the lookup feature in tables. Best practice appears to be, keep the lookup in the forms using combo box or list box."
0
8984
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9530
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8237
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.