[pmwiki-users] The Template Shuffle
Patrick R. Michaud
pmichaud at pobox.com
Fri Apr 15 10:56:28 CDT 2005
On Fri, Apr 15, 2005 at 11:31:44AM -0400, David Spitzley wrote:
> Hmm, it >almost< works, but not quite. If you check
Oops, it's the $...Fmt variable cache at work. Okay, change the code
to the following:
# change the link format for creating new pages
$LinkPageCreateFmt = "<a class='createlinktext' href='\$PageUrl?action=edit\$LinkTemplate'>\$LinkText</a><a class='createlink' href='\$PageUrl?action=edit\$LinkTemplate'>\$LinkText</a>";
# default is no template
$FmtV['$LinkTemplate'] = '';
# the (:template Group.PageName:) markup causes any create page
# links that follow to use Group.PageName as the template
"PZZ(\$GLOBALS['FmtV']['$LinkTemplate'] = '&template=$1')");
That should fix it. (If you're doing the other markups, you'll need
to switch them to use 'FmtV' also.)
> >>> "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...
> In config.php:
> # 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
> Markup('template', 'directives',
> "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
> Markup("schooldistricts", "directives",
> "/^!!!School Districts/e",
> "'$0'.PZZ(\$GLOBALS['LinkTemplate'] =
> # "!!!Municipalities" switches template to
> Markup("municipalities", "directives",
> "'$0'.PZZ(\$GLOBALS['LinkTemplate'] =
> 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.
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
More information about the pmwiki-users