You are here: Re: [SMARTY] default templates? « Smarty Templates Posts « IT news, forums, messages
Re: [SMARTY] default templates?

Posted by boots on 10/18/05 23:12

--- Josh Santangelo <joshs@endquote.com> wrote:
> I'm working on a site that has a lot of dynamic content for which
> there
> are PHP scripts and Smarty templates for each. Additionally, there is
>
> lots of static content that does not need a separate PHP script for
> each.
>
> Explaining the layout might help understand the problem:
>
> /private/
> /private/templates/
> /private/templates/dynamicpage.tpl
> /private/templates/staticpage.tpl
> /public/ (the public web root)
> /public/dynamicpage.php
>
> So when a browser goes to http://host/dynamicpage.php, that script
> runs
> and pulls in dynamicpage.tpl. What I'd like to do is be able to go to
>
> http://host/staticpage.php and pull up staticpage.tpl without
> staticpage.php actually existing.
>
> This is because I don't want to create a ton of staticpage.php files
> for
> each page of static content -- there would be hundreds of them in
> this
> case, and would make for a maintenance nightmare.
>
> I don't want to do something like
> /staticpage.php?template=staticpage.tpl, because that's ugly and not
> search-friendly.
>
> I can't do /staticpage.php/staticpage.tpl, because PHP is running as
> CGI
> and not as a module, and apparently that doesn't work.
> I don't want to do some kind of trick with a custom 404 page, because
> then the log will fill up with 404 errors.
>
> I figure the answer must be some sort of mod_rewrite trick, which I
> could sit around and figure out, or I could ask here because I'm sure
> it's been done already. :)

Hi.

If it is static, then maybe name the files .html or make the web server
deliver .tpl as html? Seems like the simplest thing to do.

If you mean they are static but still contain smarty code but all use a
common controller, then a mod-rewrite should work and be relatively
simple to implement. Of course, you would need some way of determining
if a request_uri pointed to "static" content or not -- and that's where
the effort in your mod_rewrite regex comes in.

eg (untested!):

from //foo/static/bar.tpl
to //foo/staticpage.php?template=bar.tpl
----
RewriteEngine on
RewriteRule ^/static/([a-z0-9_]+).tpl$ /staticpage.php?template=$1.tpl
[NC]

....but do take the time to learn enough to write these on your own.

Another idea is to root all standard content from a common path and to
set use a ForceType for that path. The forced script could determine
the actual request_uri and do the template loading transparently.

At anyrate, these questions aren't particularly related to smarty and
you might get better answers at an apache list or php-general.



__________________________________
Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация