Thanks for looking into this. I suppose we should have a docs page for
developers tips or something. Anyway, as you discovered, I seem to
have told you the wrong thing...
1) It is true you can define the data as normal page vars, like
$BOLTvars[$page]['field'] = $value, and the template will evaluate
them properly. So kudo's to you for figuring this out.
2) There is a simpler way in your specific situation. I remembered
there being a way to insert function parameters into the template, but
in reviewing the code it wasn't what I expected. It is $field.
So for example you could just do this:
function BOLTFtest($args, $zone) {
global $pageLink; //BW variable
$pages[]=$pageLink;
return BOLTdisplay($pages, $args['template'], $zone, $args);
}
And then in your page, put:
[(test name=joe animal=dog one=tree hat=flower template=test)]
/*
[[#test]]
It is [(time {now} "%c")]
Hello $name, I like your $animal
Please keep the $animal away from my $one and $hat.
[[#end]]
*/
If one of the variables is not defined in the function however you get
$field in the output. Probably not desired. So in your case, you
probably want to set some default values like this
function BOLTFtest($args, $zone) {
global $pageLink;
$pages[]=$pageLink; // actually you could just do $pages[] = '';
since you are not using any info from the actual page...
$myarray['name'] = 'Bob';
$myarray['animal'] = 'Dog';
$myarray['one'] = 'Tree';
$myarray['hat'] = 'Flower';
$myarray = array_merge($myarray, $args);
return BOLTdisplay($pages, $args['template'], $zone, $myarray);
}
So either option could work, but this might be a bit easier. Kind of a
cool function actually.
BTW, the reason for this functionality is so you can easily pass
labels and things from a search function say directly into the output.
Or display things like the search query or groups, or whatever. Very
handy. More hidden treasures in BoltWire.
Cheers,
Dan
P.S. Sorry again about sending you "barking" up the wrong "tree".
On Mon, Jan 5, 2009 at 10:22 PM, jacmgr <[email protected]> wrote:
>
> Ran some tests. This is what I got.
>
> Function 1 below does not work.
> Function 2 below DOES work as intended, but it is probably not the way
> it should be done?
>
> I also tried every variation of the variables in template with
> Function 1. Still no go.
> {+name}, {:name}, {name}
>
> So I am meeting my current purpose with Function 2, and using it, but
> if you have better idea how to do....
> =========================
> Page looks like this:
> ----
>
> The test 01 function output is below:
> It does NOT WORK
> [(test01 time={now} template=mytemp)]
>
> ----
>
> The test 02 function output is below
> IT DOES WORK
> [(test02 time={now} template=mytemp)]
>
> ----
>
> /*
> [[#mytemp]]
> It is [(time {time} "%c")]
> Hello {name}, I like your {animal}
> Please keep the {animal} away from my {one} and {hat}.
> [[#end]]
> */
>
> =========================
> My FUNCTIONS LOOK LIKE THIS:
> function BOLTFtest01($args, $zone)
> {
> global $pageLink; //BW variable
> $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
>
> $outarray[]=$pageLink;
> return BOLTdisplay($outarray, $args['template'], $zone, $myarray);
> }
>
> // ----------------------------------------------------
> function BOLTFtest02($args, $zone)
> {
> global $pageLink; //BW variable
> global $BOLTvar;
>
> $BOLTvar[$pageLink]['name'] = 'Bob';
> $BOLTvar[$pageLink]['animal'] = 'Dog';
> $BOLTvar[$pageLink]['one'] = 'Tree';
> $BOLTvar[$pageLink]['hat'] = 'Flower';
>
> //If you wish to make function parameters also available you could
> do:
> foreach ($args as $key=>$value)
> {
> $BOLTvar[$pageLink]["$key"] = $value;
> }
>
> //myarray really is doing nothing in this version
> //everything is going in the global var BOLTvar
> $myarray = null;
>
> $outarray[]=$pageLink;
> return BOLTdisplay($outarray, $args['template'], $zone, $myarray);
> }
>
> ====================
> The displayed page looks like:
> --------------------------------------------------------------------------------
>
> The test 01 function output is below:
> It does NOT WORK
>
> It is
> Hello , I like your
> Please keep the away from my and .
>
> --------------------------------------------------------------------------------
>
> The test 02 function output is below
> IT DOES WORK
>
> It is 01/05/09 22:11:08
> Hello Bob, I like your Dog
> Please keep the Dog away from my Tree and Flower.
>
> --------------------------------------------------------------------------------
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---