template files in subfolders of the template folder?

template files in subfolders of the template folder?

Postby chromos on Mon Jun 23, 2008 10:30 am

I tried using template files in subfolders of a template. It did not work.
Does anyone have a clue what to change to get it working?

Example:
You are able to come up with a much more nicer URL format.
E.g. http://www.foo.bar/content/news/galleries and http://www.foo.bar/content/politicans/galleries with news and politicians as respective folders in your template's folder.
At the moment, you have to name your remplate files to something like: newsgalleries.template and politicansgalleries.template which is annoying, because of the long name and because of the resulting URL -> /content/politicansgalleries and /content/newsgalleries.

It's also a great help in huge templates ...
e.g. take a template with nav and subnav bar. it's easy to come up with A LOT of header/nav bar files that make things harder to maintain.

I was also very happy to find 2 SMARTY Plugins which implement {break} and {continue} functionality, which is a nice to have imho.
Maybe you guys should think about spreading these with the lifetype package.

regards,
fabian
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel

Re: template files in subfolders of the template folder?

Postby jondaley on Tue Jun 24, 2008 8:53 am

yes, break and continue would be nice. Can you add a feature request to bugs.lifetype.net with links to the plugins?

Here is code a user (or maybe myself? I don't remember) submitted a year ago to make subdirectories work. If I recall correctly, it wasn't perfect, and so that is why it didn't get submitted to the main code. I think it might have been a little sloppy with allowing periods or dots or something, maybe a security risk somewhere (does it allow ".." in the name?)

Code: Select all
Index: prettyrequestgenerator.class.php
===================================================================
--- prettyrequestgenerator.class.php (revision 2526)
+++ prettyrequestgenerator.class.php (working copy)
@@ -322,7 +322,7 @@
*/
function templatePage( $template )
{
- $templatePage = $this->getBaseUrl()."/static/".$this->_blogInfo->getId()."/".$template;
+ $templatePage = $this->getBaseUrl()."/static/".$this->_blogInfo->getId()."/".str_replace("/",".",urldecode($template));

return $templatePage;
}
Index: prettyrequestparser.class.php
===================================================================
--- prettyrequestparser.class.php (revision 2526)
+++ prettyrequestparser.class.php (working copy)
@@ -26,7 +26,11 @@
$params = explode( "/", $this->_path_info );

// the blog id always comes after the name of the operation
- $blogId = $params[count($params)-2];
+ $blogId = $params[1];
+// print_r($params);
+// print $this->_path_info;
+// print "bog:" . $blogId;
+// $blogId = $params[count($params)-2];

$result = Array();
$result["blogId"] = $blogId;
@@ -88,7 +92,16 @@
$result["op"] = "Default";
break;
case "static":
- $templateName = $params[count($params)-1];
+ $templateName = $params[count($params)-1];
+ if(count($params) == 4)
+ $templateName = $params[count($params)-2] . "/" . $templateName;
+
+
+// $templateName =
+/// $params[count($params)-2] . "/" .
+// $params[count($params)-1];
+// $templateName = str_replace(".","/",urldecode($templateName));
+// print $templateName;
$result["show"] = $templateName;
$result["op"] = "Template";
break;
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: template files in subfolders of the template folder?

Postby chromos on Tue Jun 24, 2008 12:35 pm

Ok I filed a featurerequest, here we go.

Thanks for the code. Going to give it a try.

I also posted a comment

Is is possible to get reminded via mantis if someone posted a new comment to a specific bug/feature request?
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel

Re: template files in subfolders of the template folder?

Postby jondaley on Wed Jun 25, 2008 1:18 am

I think you get emails by default if you open a bug report - for the other one, you can "monitor" it - I think everyone has that privilege, and not just managers - look on the bug report page for a place to "monitor" the bug report.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: template files in subfolders of the template folder?

Postby chromos on Tue Jul 08, 2008 2:35 pm

hmm unfortunately this patch does not seem to work for me.
If I am trying to open a template in a subdir, I am always getting redirected to the main.template.
e.g. clicking on a link pointing to {$url->templatePage("news/test")} -> main.template.
chromos
 
Posts: 274
Joined: Wed Mar 09, 2005 2:22 pm
LifeType Version: 1.2.9-devel


Return to Templates

cron