[pmwiki-users] Using variable in skin template
DaveG
pmwiki at solidgone.com
Fri Oct 23 13:46:21 CDT 2009
Sven Hartenstein wrote:
> Dear pmwiki-users,
>
> I have a lot of fun discovering pmwiki and I already like it very
> much.
>
> One thing I can't figure out, even after reading many pages on
> pmwiki.org:
>
> I would like to use a variable in my skin template. Ideally, this
> would be similar to the
>
> (:title Title of Page:)
>
> markup, but I'd be ok with using a PageTextVariable. So, is it
> possible to use such a variable in the skin template? {*$:MyVariable}
> does not seem to work. (It does work in the SideBar or in a
> GroupHeader, but not within the skin template.)
To use a PHP variable within a skin template you need to store it as a
FmtPV variable, which needs to be a executable PHP statement (thus the
odd quotes). Refer to PmWiki/PageVariables:
$FmtPV['$MyVar'] = '"abc"';
And then to use it in the .tmpl file:
My quote of the day is {$MyVar}
> In case it helps to know what I want this for: I'd like to print some
> quote on each page in the very top of the page. I could use a
> WikiStyle with absolute positioning CSS, but I imagine using a
> variable within the templage (just like {$Title}) would be more
> elegant.
>
> (Or is the standard way to use a GroupHeader? I tried this but the
> content of the GroupHeader is shown at the top of the page content,
> not within the skin's HTML.)
You might be better off doing this in the GroupHeader -- that will
provide a little more flexibility if you decide that some pages don't
need a quote.
So, just edit the group header from within PmWiki and add the FmtPV you
declared:
Here's my variable {$MyVar}
~ ~ Dave
More information about the pmwiki-users
mailing list