Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

How to Create a Template


  • Please log in to reply
16 replies to this topic

#1 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 16 May 2008 - 09:25 AM

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)?
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#2 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 25 May 2008 - 12:29 AM

When you say template, you mean the layout for example where the sidebar should be, where the header should be etc.. or the images?
  • 0

#3 Guest_Jordan_*

Guest_Jordan_*
  • Guest

Posted 25 May 2008 - 05:29 AM

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.
  • 0

#4 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 25 May 2008 - 09:56 AM

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?
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#5 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 25 May 2008 - 10:51 AM

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.
  • 0

#6 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 25 May 2008 - 10:58 AM

And with the SEO mod?
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#7 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 25 May 2008 - 11:31 AM

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?
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#8 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 25 May 2008 - 11:52 AM

And with the SEO mod?


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

#9 Guest_Kaabi_*

Guest_Kaabi_*
  • Guest

Posted 25 May 2008 - 12:26 PM

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

#10 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 25 May 2008 - 12:29 PM

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.
  • 0

#11 Guest_Jordan_*

Guest_Jordan_*
  • Guest

Posted 25 May 2008 - 06:12 PM

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.

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.
  • 0

#12 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 26 May 2008 - 09:04 AM

I see. Which is better - a single index.php with a GET variable, or a header/footer file embedded into every page?
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download