use wire query args in actions

52 views
Skip to first unread message

Behrad Zari

unread,
Mar 17, 2013, 9:06:50 AM3/17/13
to zotoni...@googlegroups.com
Considering I have 

{% wire name="user_did_that" action={update target="id" template="my.tpl"} %}
z_event("user_did_that", { foo: bar });

then, how can I access {{ foo }} in my.tpl? (if it will be possible, since we had talked about a topic on actions being early bound in previous topics)

Behrad Zari

unread,
Mar 26, 2013, 7:13:41 AM3/26/13
to zotoni...@googlegroups.com
Anybody?

Andreas Stenius

unread,
Mar 26, 2013, 12:37:11 PM3/26/13
to Zotonic users
Ah, sorry. At first I thought someone else would chime in on this. I
think it is a interesting question, that I'd like answered too...

I'll poke around a bit see what I can find out.. :)

2013/3/26 Behrad Zari <beh...@gmail.com>:
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Zotonic users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to zotonic-user...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Andreas Stenius

unread,
Mar 26, 2013, 1:34:54 PM3/26/13
to Zotonic users
Aha, first, I see your example is pretty similar to that in the docs:
http://zotonic.com/docs/0.9/manuals/templates/calling-zotonic.html#wired-events

And there, it hints at the info is in the query args: " ‘foo’ and
other arguments will become query args ". No proper example use is
given, though, especially for use within a template :/

However, you can access the query args from a template with the `q` variable.

So this ought to work (not tested), my.tpl:

Value of foo is: {{ q.foo }}.


Now, I spent a few minutes searching the docs for any reference at all
to this "magic" q variable in the templates, but came out short.
Well, now that I did find some reference to this use, I also found it
mentioned in the docs, but that was so in passing so it's impossible
to find when searching for it.
http://zotonic.com/docs/0.9/ref/scomps/scomp_pager.html

Try it, see if it works! :)

2013/3/26 Andreas Stenius <andreas...@astekk.se>:

JRad

unread,
Mar 26, 2013, 2:58:15 PM3/26/13
to zotoni...@googlegroups.com
I hope "q" will work Andreas, I'd noticed missing information about "query args" in zotonic docs when I was reading http://zotonic.com/docs/0.9/manuals/templates/calling-zotonic.html#wired-events. I hope I gets updated.

I'll check it...

You received this message because you are subscribed to a topic in the Google Groups "Zotonic users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/zotonic-users/_I_qiL01NS8/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to zotonic-user...@googlegroups.com.

Arjan Scherpenisse

unread,
Mar 26, 2013, 5:59:47 PM3/26/13
to zotoni...@googlegroups.com
On 03/26/2013 07:58 PM, JRad wrote:
> I hope "q" will work Andreas, I'd noticed missing information about
> "query args" in zotonic docs when I was reading
> http://zotonic.com/docs/0.9/manuals/templates/calling-zotonic.html#wired-events.
> I hope I gets updated.
>
> I'll check it...

Yep. I stumbled over this as well. It is not clear what variables are
available to you in the template. We should have a list of default
variables documented somewhere in the templates manual.

Arjan

>
> On Tue, Mar 26, 2013 at 10:04 PM, Andreas Stenius
> <andreas...@astekk.se <mailto:andreas...@astekk.se>> wrote:
>
> Aha, first, I see your example is pretty similar to that in the docs:
> http://zotonic.com/docs/0.9/manuals/templates/calling-zotonic.html#wired-events
>
> And there, it hints at the info is in the query args: " �foo� and
> other arguments will become query args ". No proper example use is
> given, though, especially for use within a template :/
>
> However, you can access the query args from a template with the `q`
> variable.
>
> So this ought to work (not tested), my.tpl:
>
> Value of foo is: {{ q.foo }}.
>
>
> Now, I spent a few minutes searching the docs for any reference at all
> to this "magic" q variable in the templates, but came out short.
> Well, now that I did find some reference to this use, I also found it
> mentioned in the docs, but that was so in passing so it's impossible
> to find when searching for it.
> http://zotonic.com/docs/0.9/ref/scomps/scomp_pager.html
>
> Try it, see if it works! :)
>
> 2013/3/26 Andreas Stenius <andreas...@astekk.se
> <mailto:andreas...@astekk.se>>:
> > Ah, sorry. At first I thought someone else would chime in on this. I
> > think it is a interesting question, that I'd like answered too...
> >
> > I'll poke around a bit see what I can find out.. :)
> >
> > 2013/3/26 Behrad Zari <beh...@gmail.com <mailto:beh...@gmail.com>>:
> >> Anybody?
> >>
> >>
> >> On Sunday, March 17, 2013 4:36:50 PM UTC+3:30, Behrad Zari wrote:
> >>>
> >>> Considering I have
> >>>
> >>> {% wire name="user_did_that" action={update target="id"
> template="my.tpl"}
> >>> %}
> >>>
> >>> z_event("user_did_that", { foo: bar });
> >>>
> >>>
> >>> then, how can I access {{ foo }} in my.tpl? (if it will be
> possible, since
> >>> we had talked about a topic on actions being early bound in
> previous topics)
> >>>
> >> --
> >>
> >> ---
> >> You received this message because you are subscribed to the
> Google Groups
> >> "Zotonic users" group.
> >> To unsubscribe from this group and stop receiving emails from
> it, send an
> >> email to zotonic-user...@googlegroups.com
> <mailto:zotonic-users%2Bunsu...@googlegroups.com>.
> >> For more options, visit https://groups.google.com/groups/opt_out.
> >>
> >>
>
> --
>
> ---
> You received this message because you are subscribed to a topic in
> the Google Groups "Zotonic users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/zotonic-users/_I_qiL01NS8/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to
> zotonic-user...@googlegroups.com
> <mailto:zotonic-users%2Bunsu...@googlegroups.com>.

Behrad Zari

unread,
May 19, 2013, 9:03:44 AM5/19/13
to zotoni...@googlegroups.com
I can't access query args in actions with z_context:get_q, I searched the source and found that they are accessible after making postbacks !!!
Why !?


On Sunday, March 17, 2013 4:36:50 PM UTC+3:30, Behrad Zari wrote:
Reply all
Reply to author
Forward
0 new messages