[pmwiki-users] The Template Shuffle
dspitzle at wash.k12.mi.us
Fri Apr 15 09:47:07 CDT 2005
<grovel>I am not worthy!</grovel>
Seriously, that is really cool. I'll see what I can do about
developing Cookbookery on this subject once I've tested that it all
>>> "Patrick R. Michaud" <pmichaud at pobox.com> 04/14/05 10:29 PM >>>
On Thu, Apr 14, 2005 at 09:16:04PM -0400, David Spitzley wrote:
> Ok, I'm looking to do something with templates that may not be
> but I thought I'd ask. My wiki has a page called MichiganCounties,
> which has one link off of it to each county in the state; the
> of them do not currently have pages, and through PM's kind advice, I
> able to set up MichiganCounties.php so that all of the links off of
> page use CountyTemplate as the source template. That's spiffy.
> The trick now is that each County page is going to have two sets of
> links: one set points to pages for municipalities in the county,
> the other set points to pages for school districts in the county.
> the question is, can I somehow set up the CountyTemplate page so
> the links in the municipalities section use MunicipalityTemplate and
> school districts use DistrictTemplate? I'm inclined to think not
> how the trick in MichiganCounties.php is set up, but I figured I
> as well ask.
...some people are *never* satisfied! :-) :-) :-)
But, since you asked, and since I like a challenge, here goes an
idea. I haven't tested any of this code -- I just want to see if
it's along the lines of what you're looking for...
# change the link format for creating new pages
$LinkPageCreateFmt = "<a class='createlinktext'
# default is no template
$LinkTemplate = '';
# the (:template Group.PageName:) markup causes any create page
# links that follow to use Group.PageName as the template
"PZZ(\$GLOBALS['LinkTemplate'] = '&template=$1')");
Okay, in the MichiganCounties page you can add the directive
(:template Content.CountyTemplate:). This will cause all new page
links that come after the directive to use Content.CountyTemplate
as the default.
In the CountyTemplate page you'll add
(:template Content.MunicipalityTemplate:) before the section
with the municipality links and (:template Content.DistrictTemplate:)
before the section with the school district links. This changes
the new page links in each section to the corresponding templates.
Of course, I've used (:template ...:) here to show generally how
this works. But you might not want people to see (and be confused
by) the (:template ...:) directives in the middle of the markup.
So, you could key the setting of the template off of something else.
For example, if you know that the sections will always begin with
"!!!Municipalities" and "!!!School Districts" in the markup, you
can key the changes from those:
# "!!!School Districts" switches template to
# "!!!Municipalities" switches template to
Note that the "!!!School Districts" markup still gets processed to
produce an <h3> heading (it's left there via the '$0' in the
replacement string) -- but now that specific heading also has the
side effect of changing the edit template for any new page links
that follow it.
Anyway, hope this helps, or at least points in the general direction
of how this could be solved.
More information about the pmwiki-users