Jump to content

How to Create a Template

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
16 replies to this topic

#1
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
What's the best way to create a template, where I just have the content in the individual files. The layout needs to be stored in separate file(s), so I can update the design/layout all in one place, and it affects all the pages.

So far I'm just using PHP "include" statements to add in the different parts of the page. Is there a better way (and NOT with a CMS)?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#2
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
When you say template, you mean the layout for example where the sidebar should be, where the header should be etc.. or the images?

#3
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Before my CMS days I always created a header.php and footer.php. I included these on all pages after that and it was fairly easy to update and maintain. I think a better method is to make a header.php, footer.php and index.php. The index file would have a select/case statement and receive a variable input. Depending on the variable it would automatically load the page the user is requesting. It would also include your header/footer.php file only once.

#4
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
You mean like www .website.co.uk/index.php?page=home or something? Wouldn't that mean there would only be one page for SEO, or not?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#5
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
No, if the spider crawls those links and the content is different, there will be more than one 'page'. vB without the SEO mod is just like that.

#6
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
And with the SEO mod?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#7
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts

Jordan said:

I think a better method is to make a header.php, footer.php and index.php. The index file would have a select/case statement and receive a variable input. Depending on the variable it would automatically load the page the user is requesting. It would also include your header/footer.php file only once.

Why do you need the header.php and footer.php files? Can't I just have one main file - index.php - and within that I have the entire structure of the page - topbar, sidebar, footer at bottom - and just have a script block in the content section, to load the relevant content page, which contains only the content and no formatting?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#8
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts

Xav said:

And with the SEO mod?

It's just more Search engine friendly... nothing less nothing more.

#9
Guest_Kaabi_*

Guest_Kaabi_*
  • Guests
Being search engine friendly is important though. For my personal website I've used PHP Include, I didn't think there was another way.

#10
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Well, for my websites I use TPL.. it's very easy once you get around it.

It's great to have various skins and easily switch/change between one and another.

#11
Guest_Jordan_*

Guest_Jordan_*
  • Guests

Xav said:

You mean like www .website.co.uk/index.php?page=home or something? Wouldn't that mean there would only be one page for SEO, or not?

You can use .htaccess and mod_rewrite to make your website SEO. Take a look at what we have done (thanks john!):

http://blog.codecall.net
which really is = http://www.codecall....tion=com_myblog

And google will see the virtual sub-domain and give us higher rank points because of it.

Xav said:

Why do you need the header.php and footer.php files? Can't I just have one main file - index.php - and within that I have the entire structure of the page - topbar, sidebar, footer at bottom - and just have a script block in the content section, to load the relevant content page, which contains only the content and no formatting?

That would work just fine. I like to have separate files for th e header/footer/index files because it is easier to edit IMO.

#12
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
I see. Which is better - a single index.php with a GET variable, or a header/footer file embedded into every page?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums