Jump to content

Recommended Posts

I'd like to see how other people design a dynamic website using php which will have its content changed via url get parameters such as www.site.com/?dir=a&page=1

 

Can anyone point me to a good tutorial that takes you through the correct way to go about this

 

The way I currently do it is using a master index with

 

header.inc

php code to determine the content file/script to include

footer.inc

 

 

Link to comment
https://forums.phpfreaks.com/topic/164163-solved-dynamic-website-structure/
Share on other sites

That's similar to what I use but I don't think there's a right and wrong way to do it - down to individual taste.

 

What I do is make my template as a plain HTML file. This page has everything on it I want to display. Once completed I split it up into smaller include files and then make an index file and include them all back in.

its the including page content bit Im asking about e.g

 

<?

include("header.inc");

// content here
$dir = $_GET['dir']
$page = $_GET['page']
include("$dir/$page");

include("footer.inc");

?>

 

Thats how I do it at the moment, of course with security added in to ensure cant open what every dir/file they input. Im just wondering if thats the most logical way?

 

 

Here is a better insight on what I am probably going to design it like

 

http://www.blinding-light.com/tutorials/read/7

 

Look at the screenshot of his directory structure and then of course the code used to build the page

 

Is there any bad logic with this method?

 

I get annoyed making things then getting stick on irc for not doing it the 'correct way' or most logical way this id prefer to design it the way the books/documentation advises.

 

 

I used to use

 

<?php

$modules = array(
'news' => 'news',
'forum' => 'forum',
'members' => 'members'
'register' => 'register',
'login' => 'login',
'logout' => 'logout'
);

if (!isset($_GET['act']))
$act = 'news';
else
$act = $_GET['act'];

// Include the current module
if (in_array($act, $modules))
include('modules/' . $act . '.php');

 

until today.. I started to use templating system..

 

 

p.s> its pretty funny everyday I come to phpfreaks with a problem.. half the new topics have similar problem to mines.. is it just me or does phpfreaks forum pick out problems similar to yours..

I moved back now  ;D. I wanted to make the code look more pretty then it is ATM.. so I wanted to try a template engine.. and after the template engine failed in both looking pretty and performance I reverted back to my old backup using this. When I used a template engine the processing speed went up a tenth of a speed (like 2 pages slower) and didn't even do function calls as my old script did.. so screw it..

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.