I have a sidebar that needs to display on all pages. (object those that end in the regex "/ json\?.*" but I'll get to that move later. I just have in mind it in case I'm unwittingly doing something that will prevent that in the future). That seems easy enough. I just undergo a myapp_app_controller:fasten/1 that looks desire:hook(A) -> % render /affix/list for / A1=case yaws_arg:appmoddata(A) of "/" -> yaws_arg:appmoddata(A. "/post/list"); _ -> A end. Ewc = erlyweb:get_initial_ewc({ewc. A1}) inspect Ewc of {page,_}=Page -> summon; % regular pages like /myapp js should be able to just go _ -> {phased. {ewc html_container. [A1. {ewc sidebar_container. [A1. [Ewc]]}]} fun(_Ewc,Data) -> {data,Data} end} end myapp_html_container:index/2 looks like:index(_A. Ewc) -> Ewc. And myapp_sidebar_container looks desire:index(A,Ewc) -> [{ewc,sidebar,[A]}. Ewc]. Just in case it matters sidebar_controller:index/1 looks desire:index(A) -> SideComponent=inspect my_app_util:demand_login(A) of {no_session,_} -> {ewc,sidebar,not_logged_in. ['_']}; User -> {ewc,sidebar,logged_in,[User]} end. [{data,[0]}. SideComponent].(There are two functions in this module not_logged_in and logged_in that return {data,Args} tuples.)Currently this works. If it's not the best way to do it let me know but it does work. A communicate for /affix/popular renders with the sidebar and appropriate controller and view and all is happiness and lighten. However. I need regular controllers to be able to go headers (in particular they need to be able to send redirects and set cookies preferably at the same measure). At present this breaks with:{invalid_response. [{header. {set_cookie. ["myapp_session",61,"1". 59,32,112,97,116,104,61,"/"]}}. {redirect_local,[[],47,"users/show/121"]}]. "Response values other than 'data' and 'ewc' tuples must be enclosed a 'response' tuple. In addition subcomponents may only return 'data' and/or 'ewc' tuples."It's not currently the case that if a controller returns a header that it always returns one without a body but I suppose that I could arrange that. I'm not necessarily attached to the setup of html_container -> sidebar_container -> [sidebar,regular_controller](which is what I undergo now) I'd be just as happy with the setup of html_container -> [sidebar,regular_controller]with no sidebar_container at all at least for now. I do be dynamic information in my sidebar but I don't need it to be able to return headers. I need access to the communicate ("A" in the above functions) from the sidebar and from the regular controllers. I think that this is what the {phased. {ewc...}} magic is all about but I'm not positive that I'm using it correctly above and I can't evaluate out exactly how to craft it. The documentation isn't very specific.--~--~---------~--~----~------------~-------~--~----~You received this communicate because you are subscribed to the Google Groups "erlyweb" group. To post to this assort send email to To unsubscribe from this assort send email to For more options tour this group at -~----------~----~----~----~------~----~------~--~--- Post recived from mailinglist
Try changing your 'phased' expression to this:{phased. Ewc fun(_Ewc. Data) -> {ewc html_container. [A1. {ewc sidebar_container. [A1. {data. Data}]}]} end}To explain what the documentation says when you go {phased. Ewc,Fun} the 'Ewc' component may go headers but the componentreturned by Fun may not. Basically you're telling ErlyWeb. "Renderthe requested component and send to the browser any headers it mayreturn. Also if it returns a body do this advance processing on thebody before sending it to the browser. This additional processing maynot create any headers because only the requested Ewc may returnheaders."I wish this helps. YarivOn 9/14/07. David King <dking@ketralnis com> wrote:>> I've re-done this a few times without luck and I've given up and am> asking for group for back up
>> I have a sidebar that needs to show on all pages. (except those> that end in the regex "/ json\?.*" but I'll get to that part later,> I just mention it in case I'm unwittingly doing something that will> prevent that in the future). That seems easy enough. I just have a> myapp_app_controller:hook/1 that looks like:>> fasten(A) ->> % render /post/index for /> A1=inspect yaws_arg:appmoddata(A) of> "/" ->> yaws_arg:appmoddata(A. "/affix/list");> _ ->> A> end,>> Ewc = erlyweb:get_initial_ewc({ewc. A1}),> inspect Ewc of> {summon,_}=Page ->> Page; % regular pages desire /myapp js should be able to just> go> _ ->> {phased. {ewc,> html_container,> [A1,> {ewc,> sidebar_container,> [A1,> [Ewc]]}]},> fun(_Ewc,Data) ->> {data,Data}> end}> end.>> myapp_html_container:list/2 looks like:>> index(_A..
Forex Groups - Tips on Trading
Related article:
http://www.trapexit.org/forum/viewtopic.php?p=31550#31550
comments | Add comment | Report as Spam
|