On Tue, Dec 16, 2008 at 11:07 AM, jacmgr <[email protected]> wrote:
>
> Dan,
>
> I can't do this:
>
>> return "Hello $name, I like your $animal.<br>Please keep the
>> $animal away from my $myarray[one] and $myarray[hat].";
>
> because I am wanting
>> to make the template flexible, so you could adjust it within the wiki?
>> If so, I have some easy suggestions for that....
>>
>
> Your second choice is what I am after. The function handles getting a
> variety of type of data from some external source and does some
> serious processing of that data to set some desired values that could
> be an array, or a few individual values. I would like to be able to
> get that data in the function and then in the page that calls the
> function I would like to be able to fully customize and change how the
> data is output by anyone with edit privledge for that page.
>
> thankyou
Ok a great question. Here's the trick. Not tested, just off the cuff...
In your function set all your variables however you want into an array
something like this:
$myarray['name'] = 'Bob';
$myarray['animal'] = 'Dog';
$myarray['one'] = 'Tree';
$myarray['hat'] = 'Flower';
If you wish to make function parameters also available you could do:
$myarray = array_merge($myarray, $args); // or $args, $myarray
depending on which should override which
In this way you could add additional parameters from the wiki, and
have them available... Like [(myfunc time={now})]
Set a template parameter in the function (perhaps with a default if not set).
Make sure $pageLink to global. This will make your template work as if
it is on the current page. I suppose it could be anything however. You
just need a label for the template. Theoretically you could do
page1,page2,page3 etc and get multiple returns, but your custom data
would all be the same for each return.
Finally for your output, just do
return BOLTdisplay($pageLink, $args['template'], $zone, $myarray);
Now in the page you will have
[(myfunc parameters template=mytemp)]
/*
[[#mytemp]]
Hello {+name}, I like your {+animal}
Please keep the {+animal} away from my {+one} and {+hat}.";
[[#end]]
*/
You could of course define the template also in page template.mytemp
as well, rather than in the page. And note also you have access to all
your normal markup in the template, meaning you can do any formatting
or whatever you want based on the data.
This is a pretty cool function. Maybe we should create a plugin page
with the basic idea, for others to build on. I can see interesting
uses.
Cheers,
Dan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"BoltWire" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/boltwire?hl=en
-~----------~----~----~----~------~----~------~--~---