[pmwiki-users] php in .tmpl

Patrick R. Michaud pmichaud at pobox.com
Thu Oct 2 12:18:13 CDT 2008


On Thu, Oct 02, 2008 at 12:11:20PM -0400, Ilia Ovechkin wrote:
> I would like to be able to include <?php include "$SkinDirUrl/ 
> randomimage.php"; ?> inside of the .tmpl file which references a php  
> file inside the skin folder.
> 
> Is there documentation for how this should be done?

The .tmpl file isn't really a php script, so there's not a way
to use <?php ... ?> tags inside of the template file.

However, what you can do is create a function (in config.php or
skin.php) that looks like:

    function IncludeRandomImage() {
        global $SkinDir;
        include("$SkinDir/randomimage.php");
    }

Then in the template you can do  <!--function:IncludeRandomImage-->
to call this function (which then includes the randomimage.php script).

Also note that your original example has "$SkinDirUrl/randomimage.php"
as the argument to the include() function, which is almost certainly
_not_ what you want.  The include() function expects a filename, not
a url.

Pm



More information about the pmwiki-users mailing list