What is best practice for customising module block templates?

benz

Joined: 2009-01-16
Posts: 5
Posted: Sat, 2009-01-31 01:21

Hi all,

I love the way the theme template files are set out for the major pages, but I'm struggling to work out a good methodology for managing the inevitable changes that you need to make for module/block related content. How do you manage these changes?

For example, I make a new photo page for my theme, I can make a photo.tpl as follows /gallery2/themes/myThemeName/templates/photo.tpl, that all makes sense and works great.

Now I decide I need to edit the comment templates to change how the comments appear under my photo. It seems that the files I need to start changing live in /gallery2/modules/comment/templates/blocks, so I make a /local/ folder inside that to provide some insulation against future upgrades and start making my changes.

Of course what I've just done is overridden the comment template for _every_ theme, not just my own.

I then find I need a new callback in the comments module to change the sort order, so now I can't even create a /local directory but have to edit the module .inc files directly....

The more theme work I do, the more I find I need to override module templates and edit module code which as far as I can tell lives outside the theme structure. The dozens of /local/ directories and moded classes springing up around the place feels like a maintenance nightmare in the making!

Am I missing something?
How do you manage this when you make your themes?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2009-01-31 05:35

http://codex.gallery2.org/Gallery2:Editing_Templates click the show in

Quote:
Details and Example [show]

Themes can override core and module templates. The drawback is you can only do this to template files. Making changes to *.inc or .class files can't be done.
I guess you could copy the module and give it a different/similar name and use that module in your theme.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
benz

Joined: 2009-01-16
Posts: 5
Posted: Sat, 2009-01-31 06:57

Awesome - the module template override works a treat.

As someone new to Gallery, I'm finding that there's lots of documentation, but its very hard to search and sort through - so far its all there if you know where to look, but a wordpress style approach to organising documentation on theme creation and tags would be really, really appreciated :-)

Contrast the wordpress (http://codex.wordpress.org/Template_Tags) template tag documentation structure to the Gallery2 one (http://codex.gallery2.org/Gallery2:Themes:Reference:Tags) and you'll see what I mean.

Each tag has its own page with examples and parameter descriptions and a central page acts as a table of contents and highlights deprecated tags between versions - its probably hard to appreciate the difference when you're familiar with the tags, but when you're starting out its huge.

I'm very impressed with Gallery but I've probably found the Gallery2 learning curve twice as steep as Wordpress because of this (and that's already knowing a fair bit of smarty templating from other projects).

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2009-01-31 07:07
Quote:
so far its all there if you know where to look, but a wordpress style approach to organising documentation on theme creation and tags would be really, really appreciated

Are you volunteering? The docs are for users by users. Feel free to edit to your harts content.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team