[pmwiki-users] How to start to write a recipe

sti at pooq.com sti at pooq.com
Wed Sep 26 11:40:05 CDT 2007


ThomasP wrote:
> On Wed, September 26, 2007 09:52, Matthias Günther wrote:

>> I want to start to create a recipe. I looked over the pmwiki
>> documentation but there I found nothing. It would be nice if someone can
>> post a simple example which has the following function:
>> 
>> - include the recipe on my wiki like (:test:) - when I include this
>> markup then a phrase like "Jeah it worked!!!" should be displayed in my
>> wiki
>> 
> Hello Matthias,
> 
> On Wed, September 26, 2007 09:52, Matthias Günther wrote:
>> Hello,
>> 
>> I want to start to create a recipe. I looked over the pmwiki
>> documentation but there I found nothing. It would be nice if someone can
>> post a simple example which has the following function:
>> 
>> - include the recipe on my wiki like (:test:) - when I include this
>> markup then a phrase like "Jeah it worked!!!" should be displayed in my
>> wiki
>> 

> Create a file yeah.php in the cookbook directory with the lines
> 
> <?php if (!defined('PmWiki')) exit(); 
> Markup('myYeah','inline','/\\(:test\\s+(\\S.*?):\\)/ei', 
> "MyYeahFunction('$1')"); function MyYeahFunction($arg) { return "Yeah, $arg
> works.<br>"; }
> 
> and include this file into your configuration by adding
> 
> include_once("cookbook/yeah.php");
> 
> in your local/config.php.
> 
> This will register a markup of the form (:test my_argument:) that allows 
> passing a parameter to the given function. The exact choice of the 
> parameters to the function Markup() might take some time to be fully 
> appreciated, but just the following explanation:

Yeah, we should probably create a NewRecipe page or something that gives some
examples. I would recommend extending the above example to include recipe info
 so its more like:

<?php if (!defined('PmWiki')) exit();

  define(YEAH_VERSION, '2007-09-26');

  $RecipeInfo['Yeah'] = array
    ( 'Version' => YEAH_VERSION
    , 'Author'  => 'John Q. Public'
    , 'Email'   => 'someone at sample.com'
    );

  Markup
    ( 'myYeah'
    , 'inline'
    , '/\\(:test\\s+(\\S.*?):\\)/ei'
    , "MyYeahFunction('$1')"
    );

  function MyYeahFunction($arg)
    { return "Yeah, $arg works.<br>"; }




More information about the pmwiki-users mailing list