[pmwiki-users] Displaying a markup variable via a skin template

Dominique Faure dominique.faure at gmail.com
Fri Oct 3 00:02:30 CDT 2008


On Mon, Sep 29, 2008 at 23:28, marc <gmane at auxbuss.com> wrote:
> Hi,
>
> I want to display a variable from the markup on each displayed page via
> the skin template.
>
> I thought I would be able to use a PTV directly. Thus, in markup:
>
>  (:something: marctest:)
>
> and in the template file, something like this:
>
>  {$:something}
>
> But this just displays {$:something} on the page.
>
> I get close with
>
>  <!--markup:{$:something}-->
>
> but this puts a <p></p> around the result and breaks the <div> it's in.
>
> I don't have to use a PTV, I just want to use something in markup so
> that users can change it.
>
> (I currently have:
>
>  <!--function:header_text-->
>
> in the template and:
>
>  function header_text($pagename) {echo 'something';}
>
> in the page's .php file, but the users can edit the text in this
> method.)
>
> Any ideas? Thanks.
>

Hi,

You may perhaps have a look at the Monobook/grease Skins where I
implemented such kind of workarounds in order to handle markup
definition rendering within specific template areas.

Excerpt from grease/grease.tmpl:
  ...
  <h1 class='titlepage'><!--function:RenderPart title--></h1>
  ...

Excerpt from grease/grease.php:
  ...
  function RenderPart($pagename, $part, $strip = '') {
    global $SkinPartFmt, $PCache;
    $n = "skin_$part";
    if(!isset($PCache[$pagename][$n])) {
      $t = MarkupToHTML($pagename, "<:block>{$SkinPartFmt[$part]}",
array('escape' => 0));
      $PCache[$pagename][$n] = $strip ? preg_replace($strip, '', $t) : $t;
    }
    print $PCache[$pagename][$n];
  }
  ...

Roughly, the function takes a markup source fragment from the
$SkinPartFmt definition array, renders it as an unenclosed block of
text (no <p> markers), then does some optional housekeeping on the
resulting html and stores it in the page cache for future reuse to
prevent extraneous generations before outputing the result.

-- 
Dominique



More information about the pmwiki-users mailing list