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

Posted by "Jeroen de Jong" on 10/18/05 23:02

In your Apache config or .htaccess file you could do something like:

RewriteEngine On
RewriteRule ^/static([a-z]+)\.php$ /staticpage.php?template=$1 [L]


see: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

Jeroen


----- Original Message -----
From: "Josh Santangelo" <joshs@endquote.com>
To: <smarty-general@lists.php.net>
Sent: Tuesday, October 18, 2005 9:31 PM
Subject: [SMARTY] default templates?


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. :)

-josh

--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

 

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

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