Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-03-17 00:12:06

hcgtv
Plugin Author
From: Miami, Florida
Registered: 2005-11-29
Posts: 2,634
Website

Theme mechanism for TxP 4.0.X

After spending a few days, I think I have a working mechanism.

Using mcw_templates, I created a new plugin that uses a root level directory called /templates, this keeps user data away from the /textpattern directory, similar to /files and /images.

Sample Kubrick template layout:

  • /templates
    • ../kubrick
      • ../files
        • nicetitle.js
      • ../forms
        • kubrick_default.article.html
        • kubrick_search_results.article.html
        • kubrick_comments.comment.html
        • kubrick_comment_form.comment.html
        • kubrick_popupcomments.comment.html
        • kubrick_files.file.html
        • kubrick_plainlinks.link.html
      • ../images
        • kubrickheader.jpg
        • kubrickfooter.jpg
      • ../pages
        • kubrick_default.html
      • ../plugins
        • hcg_templates-0.3.txt
      • ../style
        • kubrick_default.css

The /templates directory should contain an .htaccess file to keep prying eyes out of your templates but still allow access to the files and images subdirectories.

This mechanism is working for me locally, just looking for comments in case I missed something.

Last edited by hcgtv (2007-03-17 00:17:05)

Offline

#2 2007-03-17 01:27:04

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,202
Website

Re: Theme mechanism for TxP 4.0.X

This is really well thought out and needed work. Thank you.

Offline

#3 2007-03-17 08:01:25

hcgtv
Plugin Author
From: Miami, Florida
Registered: 2005-11-29
Posts: 2,634
Website

Re: Theme mechanism for TxP 4.0.X

Sample Kubrick template layout, part deux:

  • /templates
    • ../kubrick
      • kubrick_default.page.html
      • kubrick_default.article.html
      • kubrick_search_results.article.html
      • kubrick_comments.comment.html
      • kubrick_comment_form.comment.html
      • kubrick_popupcomments.comment.html
      • kubrick_files.file.html
      • kubrick_plainlinks.link.html
      • kubrick_default.style.css
      • ../files
        • nicetitle.js
      • ../images
        • kubrickheader.jpg
        • kubrickfooter.jpg
      • ../plugins
        • hcg_templates-0.3.txt

Offline

#4 2007-03-17 09:07:52

mapu
Member
From: Munich, Germany
Registered: 2004-03-16
Posts: 141

Re: Theme mechanism for TxP 4.0.X

I like the first example better. Very good idea, indeed. Especially to implement needed plugins. That way, template packages could be made even more feature filled ;)

But why an extra .htaccess file? Putting an empty index.html into that folder could do the same job.

Offline

#5 2007-03-17 16:52:28

hcgtv
Plugin Author
From: Miami, Florida
Registered: 2005-11-29
Posts: 2,634
Website

Re: Theme mechanism for TxP 4.0.X

mapu wrote:

I like the first example better. Very good idea, indeed. Especially to implement needed plugins. That way, template packages could be made even more feature filled ;)

In the second example everything resides in one top level folder, I just found it easier while working on templates with an editor, less clicking around. Plugins should be included, this way the user doesn’t have to go hunting them down or running the risk of the plugin version they need getting lost in cyberspace.

But why an extra .htaccess file? Putting an empty index.html into that folder could do the same job.

Template authors would need to remember to add an empty index.html to their folders and the plugin would have to be modified to output index.html when it does it’s export routine. Either or works fine, it depends on how you’d like to approach it.

Offline

#6 2007-03-17 17:55:22

hakjoon
Moderator
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: Theme mechanism for TxP 4.0.X

Questions,

Why not put it in /textpattern/ and avoid the whole index.html .htaccess mumbo jumbo?

Why preceed the files with kubrick_ if they are in a Kubrick folder? If we are going to use a prefix shouldn’t all files have them (ie. nicetitles.js)?

Really good work here.


Shoving is the answer – pusher robot

Offline

#7 2007-03-17 22:33:51

hcgtv
Plugin Author
From: Miami, Florida
Registered: 2005-11-29
Posts: 2,634
Website

Re: Theme mechanism for TxP 4.0.X

hakjoon wrote:

Why not put it in /textpattern/ and avoid the whole index.html .htaccess mumbo jumbo?

The good:

  1. I think of Textpattern as the core, sort of like /bin, templates are user generated additions, either /usr or /opt material. This also makes it easier to do folder comparisons on system upgrades.
  2. background:url(../textpattern/_templates/mistylook/img/icon_feed.gif) no-repeat left center; background:url(/templates/mistylook/images/icon_feed.gif) no-repeat left center; less typing
  3. Hard coding ../textpattern is not future proof, the textpattern directory may be able to move around one day. unless we can have CSS conditionals

The bad:

  1. Needs protection.
  2. mcw_templates forks, where we could instead further one code base. But the code should be opened, like you’re doing with zem event code.

Why preceed the files with kubrick_ if they are in a Kubrick folder?

  1. In the admin section, you will have the opportunity to work on Kubrick while your site still runs fine on the old template. When you’re ready, set the section defaults and away you go.
  2. You may also install different templates to learn from, it’s a great way to get up to speed.

If we are going to use a prefix shouldn’t all files have them (ie. nicetitles.js)?

Cause they’re in the Kubrick folder :)

Really good work here.

Open Source is a scratch your own itch type of thing. I came from Nucleus CMS that has the ability to pick looks from a list, Textpattern on the other hand is more of a CMS, but I miss the templating capabilities.

Over the last three months, I’ve been creating templates locally for my live sites. Thanks to changes in the upcoming 4.0.5, I can pick what Page and Style is the default when I enter that tab. EditArea allows me to work more in the Admin section and less in an external editor. Textpattern, the template machine, who woulda thought ;)

Thanks to everyone for the feedback, cause it either solidifies my thoughts or makes me rethink them, and words of encouragement always give you a second wind.

Offline

#8 2007-03-18 05:07:20

NeilA
Member
From: Blue Mountains, Australia
Registered: 2004-08-15
Posts: 316
Website

Re: Theme mechanism for TxP 4.0.X

Like I said in the other thread Bert – more power to you! ;-)


Neil – Blue Mountains, Australia

http://westserve.org
http://ministrygrounds.net.au

Offline

#9 2007-03-18 06:06:32

hakjoon
Moderator
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: Theme mechanism for TxP 4.0.X

Thanks for the answers Bert. They make a lot of sense to me.


Shoving is the answer – pusher robot

Offline

#10 2007-03-18 08:10:22

hcgtv
Plugin Author
From: Miami, Florida
Registered: 2005-11-29
Posts: 2,634
Website

Re: Theme mechanism for TxP 4.0.X

Ladies and gents, children of all ages…

The TxP Templates are performing in the center ring.

Last edited by hcgtv (2009-08-29 04:46:45)

Offline

Board footer

Powered by FluxBB