I'm updating the documentation about phased rendering. I hope it'll be made clearer.
Yariv On Dec 24, 2007 11:42 PM, maddiin <[EMAIL PROTECTED]> wrote: > > David gave me a lesson on IRC. Visit his blog: > http://www.ketralnis.com/roller/dking/ > to read the log and you should be able to use phased_vars. :) > > > On 23 Dez., 19:08, maddiin <[EMAIL PROTECTED]> wrote: > > I would if I could...but I need an example of a > > html_container_controller.erl/html_container_view.et and a component > > making use of the phased_vars, other than that I am completely lost. I > > have tried to get a guess how this works but nothing worked. > > > > On 22 Dez., 19:08, David King <[EMAIL PROTECTED]> wrote: > > > > > > I want to have different sidebars, sorry for the confusing > > > > explanation. > > > > > You could pass up which sidebar you want (or even the full ewc for it) > > > in a phased_var > > > > > > Using your hook/1, this is the setup I have now for a sidebar that is > > > > always the same: > > > > > > html_container_controller.erl: > > > > > > index(A, Ewc) -> > > > > Ewc. > > > > > > html_container_view.et: > > > > > > <%@ index(Data) %> > > > > <html> > > > > <head> > > > > </head> > > > > <body> > > > > <div id="header"> > > > > header > > > > </div> > > > > > > <div id="content"> > > > > <% Data %> > > > > </div> > > > > > > <div id="footer"> > > > > footer > > > > </div> > > > > </body> > > > > </html> > > > > > > main_layout_controller.erl: > > > > > > index(A, Ewc) -> > > > > [Ewc, {ewc, sidebar, [A]}]. > > > > > > main_layout_view.et: > > > > > > <%@ index([Data, Sidebar]) %> > > > > <div id="main"> > > > > <% Data %> > > > > </div> > > > > <div id="sidebar"> > > > > <% Sidebar %> > > > > </div> > > > > > > For a different sidebar on each page, does it mean to get rid of the > > > > main_layout_controller/view and put the stuff in entry_controller/view > > > > and so on? > > > > > > e.g.: > > > > > > entry_controller.erl: > > > > > > index(A) -> > > > > Entries = entry:find_with({order_by, [{id, desc}]}), > > > > [[{ewc, entry, entry, [A, Entry]} || Entry <- Entries], {ewc, > > > > sidebar, entry_index, [A]}]. > > > > > > entry_view.et: > > > > > > <%@ index([Entry, Sidebar]) %> > > > > <div id="main"> > > > > <h1>Entries</h1> > > > > <% Entry %> > > > > </div> > > > > <div id="sidebar"> > > > > <% Sidebar %> > > > > </div> > > > > > > <%@ entry(...) %> > > > > ... > > > > > > This would mean to repeat the #main and #sidebar divs in every view, > > > > so it doesn´t feel right to me. > > > > > > Another thing I can´t understand is how to make use of the phasedvars, > > > > which controller should I put them in and what would my views look > > > > like then. > > > > > > Say I want to have a html_container_view.et like this: > > > > > > <html> > > > > <head> > > > > <% Title %> > > > > <% RSS-Link %> > > > > <% Whatever %> > > > > </head> > > > > <body> > > > > <div id="header"> > > > > header > > > > </div> > > > > > > <div id="content"> > > > > <% Data %> > > > > </div> > > > > > > <div id="footer"> > > > > footer > > > > </div> > > > > </body> > > > > </html> > > > > > > Thanks in advance for bringing some light in the dark. :) > > > > > > On 19 Dez., 01:16, "Yariv Sadan" <[EMAIL PROTECTED]> wrote: > > > >> On Dec 17, 2007 10:01 PM, maddiin <[EMAIL PROTECTED]> wrote: > > > > > >>> Hi, > > > > > >>> thanks for the answers, it was quite helpful. Most important: I > > > >>> found > > > >>> out how to make use of the component system and was able to put all > > > >>> logic in controllers. > > > > > >>> Following the checklist: > > > > > >>> 1. I copied David´s example and it works for now. I will ask later > > > >>> for > > > >>> more help about it. > > > > > >>> 2.+4. Now that I know how to use controllers and views correctly it > > > >>> seems odd to me to have directories for each component. :=) Most > > > >>> confusing for me was that I thought I have to use an app_view.erl, > > > >>> saw > > > >>> that in the musician example and the tutorial from > > > >>> progexpr.blogspot.com. So if you talk about views you mean .et > > > >>> files, > > > >>> I wasn´t sure about and that was confusing me. The example in the > > > >>> foreach-topic was really helpful, more examples would be great. > > > > > >> The app views used to be a part of ErlyWeb, but they were replaced by > > > >> components + 'phased' rendering. Unfortunately, those old tutorials > > > >> are still on my blog so I see where the confusion would come from :) > > > > > >>> 3. Still not understanding this, I just know how to use a sidebar > > > >>> that > > > >>> is the same on every page. I would appreciate if someone could > > > >>> give me > > > >>> an example based on the blog instead of a general explanation. > > > > > >> Do you want a different sidebar for every page, or the same sidebar > > > >> (but with dynamic contents)? If you want a different sidebar, you can > > > >> include it in your components directly, so each component could chose > > > >> which sidebar to include. If you want the same sidebar, include it in > > > >> the html_container (or the main_layout_container as in my previous > > > >> email). > > > > > >> I think you probably want the same sidebar, in which case I would > > > >> create a sidebar component and include it in main_layout_container > > > >> next to the requested component, e.g.: > > > > > >> sidebar_controller: > > > > > >> index(A) -> > > > >> {data, ...}. > > > > > >> sidebar_view: > > > > > >> <%@ index(Data) %> > > > >> <div id="sidebar"> > > > >> <h1>sidebar</h1> > > > >> <% Data %> > > > >> </div> > > > > > >> main_layout_container_controller: > > > > > >> index(A, Ewc) -> > > > >> [{ewc, sidebar, [A]}, > > > >> Ewc]. > > > > > >> main_layout_container_view.et: > > > > > >> <%@ index([Sidebar, Data]) %> > > > >> <table> > > > >> <tr> > > > >> <td><% Sidebar %></td> > > > >> <td><% Data %></td> > > > >> </tr> > > > >> </table> > > > > > >> app_controller: > > > > > >> hook(A) -> > > > >> {phased, > > > >> {ewc, A}, > > > >> fun(Ewc, Data, _PhasedVars) -> > > > >> {ewc, html_container, [A, {ewc_main_layout_container, [A, > > > >> {data, Data}]}]} > > > >> end} > > > > > >>> 5. I renamed the tables to use singular names and ran into a name > > > >>> clash (using author now instead of user). So if you are new to > > > >>> Erlang/ > > > >>> ErlyWeb, too, then have a look athttp://erlang.org/doc/ > > > >>> man_index.html > > > >>> and make sure, you don´t name your sql-tables/controllers like one > > > >>> of > > > >>> the modules listed in the Erlang manual page. > > > > > >> That one got me too. Now I use 'usr' :) > > > > > >> Yariv > > > > > >>> maddiin > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "erlyweb" 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/erlyweb?hl=en -~----------~----~----~----~------~----~------~--~---
