Re: [pmwiki-users] how to access configuration variables from skin scripts

1 view
Skip to first unread message

a.sond...@gassi-tv.de

unread,
Mar 11, 2012, 5:41:01 AM3/11/12
to 5...@5ko.fr, pmwiki...@pmichaud.com
Dear Petko

Apologies for my delayed reply and many thanks for your answers. Your hint with the globals declaration works great (I did try to access the globals with the globals array only and not by declaring them global in my script, which was my error).

> $HandleBrowseFmt = array(&$PageStartFmt, &$PageRedirectFmt, &$PageEndFmt);
This works as well, though not exactly like I was hoping to use it. I was hoping to use a directive like this in the skin template’s php file (where I have all the skin related conditional stuff).

My template basically has a primary content div which shows an image and some text extracted from PTVs and a sidebar content div into which the sidebar (basically a pagelist with pagination) is AJAXed:
› The sidebar has its own tmpl file which will either use <!--PageText--> or <!--wiki:$Group.SideBar Site.SideBar--> directive to render the contents
› The primary content’s tmpl does not use the <!--PageText--> directive at all
› all actions other than browse obviously use a tmpl which needs <!--PageText-->

So I can either
A) conditionally implement ‘$HandleBrowseFmt = array(&$PageStartFmt, &$PageRedirectFmt, &$PageEndFmt);’ in the config.php to show up only on action == browse and use <!--wiki:$Group.SideBar Site.SideBar--> directive to circumvent the <!--PageText--> directive being neutralized in the config.php or
B) find some way to do place the conditional logic in the template’s .php

B sounds like the cleaner solution to me, but I am lacking knowledge of PmWiki’s processing chain. In which order are config.php and skin.php(1) evaluated? E. g. can I define a global variable in skin.php to conditionally use the var in config.php? Or are there other ways to achieve this?

Thanks a lot
Josh

(1) skin.php in this context is a placeholder for the skin templates primary php file

--
GASSI TV® brand & marketing

office +49 2238 4629519
mobile +49 1511 5794189
fax +49 2238 963023
email <a.sond...@gassi-tv.de>
web <http://gassi-tv.de>

moving pixies GmbH
Aurikelweg 22
DE-50259 Pulheim
Geschäftsführer: Daniel Sonderhoff
Amtsgericht Köln, HRB 74273


Save the world — Don't print this e-mail!


On Feb/26, 2012, at 1900 , pmwiki-use...@pmichaud.com wrote:

> Date: Sun, 26 Feb 2012 12:18:28 +0100
> From: 5...@5ko.fr
> To: pmwiki...@pmichaud.com
> Subject: Re: [pmwiki-users] how to access configuration variables from
> skin scripts
> Message-ID: <cone.1330255108.147913.13221.1000@pc4>
> Content-Type: text/plain; format=flowed; delsp=yes; charset="UTF-8"
>
> a.sond...@gassi-tv.de writes:
>> 1) Basically I have a lot of <!--file:somephp.php--> in my tmpl to fire the
>> scripts that merge the page variables and PTVs with the html/css. The
>> functions described in the link given above work just fine, configuration
>> variables (such as $FarmD, $SkinDirUrl, etc.) however are not accessible.
>
> Add at the beginning of your scripts
>
> global $FarmD, $SkinDirUrl;
>
>> a limitation as I do not need the output produced by <!--PageText--> in all
>> of the tmpl files ... Omitting the
>> PageText special directive results in PmWiki outsmarting me and inserting
>> the PageText content just before the </body> tag. Is there any way to force
>> PmWiki to not output the PageText in certain tmpl?s?
>
> You can add this in config.php - possibly conditionnally :
>
> $HandleBrowseFmt = array(&$PageStartFmt, &$PageRedirectFmt, &$PageEndFmt);
>
> Petko


_______________________________________________
pmwiki-users mailing list
pmwiki...@pmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-users

Petko Yotov

unread,
Mar 18, 2012, 8:50:02 AM3/18/12
to pmwiki...@pmichaud.com
Sorry for my late reply. You are using PmWiki in unusual ways so I had to find
some time to test the thing.

a.sond...@gassi-tv.de writes:
> > $HandleBrowseFmt = array(&$PageStartFmt, &$PageRedirectFmt, &$PageEndFmt);
> This works as well, though not exactly like I was hoping to use it. I was
> hoping to use a directive like this in the skin template’s php file (where I
> have all the skin related conditional stuff).

You can set this line in pub/skins/yourskin/yourskin.php if you declare the 4
variables global.

> In which order are config.php and skin.php(1) evaluated?

config.php is used very early, long before a skin-template.php file.

> E. g. can I define a global variable in skin.php to conditionally
> use the var in config.php?

No.

> Or are there other ways to achieve this?

I hope that I have correctly understood your need and I hope that the above
line in a template-skin.php file with a global declaration will work for you.

Reply all
Reply to author
Forward
0 new messages