Categories > TinyButStrong general >

Website structure advice

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: howman
Date: 2005-11-10
Time: 04:31

Website structure advice

This is maybe more of a general website structure question rather than TBS specific, but here goes.

When building a site, is it better to have you site structure like this...

One index page which changes based on the GET var:
http://www.yoursite.com/index.php?page=home
http://www.yoursite.com/index.php?page=about
http://www.yoursite.com/index.php?page=contact
http://www.yoursite.com/index.php?page=page2

or like this...

Multiple php pages:
http://www.yoursite.com/index.php
http://www.yoursite.com/about.php
http://www.yoursite.com/contact.php
http://www.yoursite.com/page2.php

Thanks.
By: Skrol29
Date: 2005-11-10
Time: 11:43

Re: Website structure advice

I'm always divided on this point.

The first (with parameters) is more logical. But it becomes heavy when the page needs more parameters. And also too much parameters makes your page not saved into Google.

The second (that I've choosen from tinybutstrong.com) is more simple and quickly manually written. But it needs a php file for each page or an URL Rewriting.
By: howman
Date: 2005-11-10
Time: 14:24

Re: Website structure advice

Glad to see I am not the only one who is divided on this point.

I like the idea of having a clean URL without all of the parameters added on.  When I did it this way using TBS, I realized that all of my php pages used a lot of the same code.  The only thing that was different was the choice of content.  I started to think that if I ever needed to make a change to the site, I might need to edit every PHP script.

When I tried doing it with one PHP script and GET vars, it worked fine until I need to create a page that had more than just basic contect, it had logic.  Then the script started to get messy.

Thanks for your input Skrol.
By: Skrol29
Date: 2005-11-10
Time: 14:37

Re: Website structure advice

If it can help you, most of php pages if the tinybutstrong.com site are coded like this :
<?php
$page = 'manual';
include('index.php');
?>

Only few pages are realy doing someting.
I don't know yet if this is smart, but this enables me to have a global simple site.
By: howman
Date: 2005-11-10
Time: 15:27

Re: Website structure advice

That does help.  Thanks.

Do you use a fixed path for templates and images?  For example, if you create a new page such as www.mysite.com/subfolder/coolpage.php, you would need to do:
<?php
$page = 'coolpage';
include('../index.php');
?>
Any relative paths in the index page would now break.
By: Maz
Date: 2005-11-11
Time: 15:20

Re: Website structure advice

For what it's worth, I've done it this way:

In my init.php file I have:

        //-----------------------------------------
        // Set Member template and image path
        //-----------------------------------------
        $TBS->GlobalPath = "/templates/".$mbr_config['theme']."/";
        $tpl_imgpath = $TBS->GlobalPath."images/";

Then I modded the TBS class slightly to:

var $GlobalPath         = "/templates/default/";
var $GlobalExtension    = ".tpl.php";

function LoadTemplate($File,$HtmlCharSet='') {
    // Load the file
    $x = '';
    $File = $this->GlobalPath.$File.$this->GlobalExtension;
    if (!tbs_Misc_GetFile($x,$File)) return $this->meth_Misc_Alert('LoadTemplate Method','Unable to read the file \''.$File.'\'.');
    $x = '[onload;file=templates/default/layout/start.tpl.php]'.$x.'[onload;file=templates/default/layout/end.tpl.php]';

Then, because I wanted to use a global language file in my templates, so I could just add [lang.welcome_text] for example, I added the following:

function Show($Render='') {
    $this->RenderLang();
    $this->render_timer();
    $this->render_queries();
    $this->render_load();
    if ($Render==='') $Render = $this->Render;
    if ($this->_CacheFile!==true) $this->meth_Merge_Special('onshow,var');
    if (is_string($this->_CacheFile)) $this->meth_Cache_Save($this->_CacheFile,$this->Source);
    if (($Render & TBS_OUTPUT)==TBS_OUTPUT) echo $this->Source;
    if (($this->_Mode==0) and (($Render & TBS_EXIT)==TBS_EXIT)) exit;
}

function RenderLang() {
    global $lang;
    $src = $this->Source;
    if(!empty($lang))
    {
    foreach($lang as $key => $value) {
        $src = str_replace('[lang.'.$key.']', $value, $src);
    }
    }
    $this->Source = $src;
}

As you can see, I've also added quite a few more functions for my needs but you get the idea.
By: Maz
Date: 2005-11-11
Time: 15:23

Re: Website structure advice

Ooops. Forgot the useage:

It means I get to use:

<img class="thumbbutton alignright" src="[var.tpl_imgpath]buttons/btn-dlskin.png" alt="Download This Skin" />

and

                    <div id="anylinkmenu1" class="anylinkcss">
                        <a href="[var.abs_root]source/skins/upload.php">[lang.menu_skins_upload]</a>
                        <a href="[var.abs_root]source/skins/track.php">[lang.menu_skins_track]</a>
                    </div>

By: howman
Date: 2005-11-11
Time: 15:51

Re: Website structure advice

Thanks Maz.  I appreciate you sharing your approach.