Hi everybody!
Here how I have resolved my problem with changing page's layout on-the-fly:)
I have created my own extension folder with my namespace-tags for unusual
tasks.
desc %{
Works like design switcher.
}
tag 'gsession:design' do |tag|
design_type = request.session["gsession_design"]
if design_type == nil
design_type = GenieSessionExtension.defaults[:design]
request.session["gsession_design"] = design_type
end
design_type.strip!
if layout = Layout.find_by_name(tag.attr["#{design_type}"])
tag.globals.page.layout = layout
tag.globals.page.render
end
end
Usage:
I have created layout named "master-index" with only one line in it:
<r:gsession:design full="full-index" light="light-index" />
With 2 arguments, which describes layout names for 'full' and 'light'
version of my site. You can define 'gsession_*design*' session variable at
any time by hitting, for example:* /genie/set/design/light*
All my pages have selected 'master-index' layout.
That is all, while page is rendered my tag switches current layout to
'full-index' or 'light-index' named layouts.
Waiting for comments ... Thank you:)
________________
Regards,
Mamed Mamedov
On Thu, Jul 16, 2009 at 6:16 PM, Sean Cribbs <[email protected]> wrote:
> If all of your pages have the same layout at any time, make sure all
> descendant pages have their layout set to <inherit> and then your extension
> could change the layout on the root page.
> However, it would not be trivial to do this on a per-user basis. Have you
> considered something like a combination of Javascript and CSS that lets your
> users switch layouts?
>
> Sean
>
> Mamed Mamedov wrote:
>
>> Hi everybody!
>>
>> I have a little question: how can I change page's layout from within my
>> extension?
>> Problem is, that I have 2 different page layouts for my site: [
>> full-version
>> and light-version ].
>> I want to write a mini-extension to switch between designs of my site
>> throw
>> hitting: /design/set/full and /design/set/light or /design/reset
>> And I'am saving current design variable in current user's session.
>>
>> And now, just need to change current page's layout on the fly accordingly
>> to
>> session value.
>> ________________
>> Regards,
>> Mamed Mamedov
>> _______________________________________________
>> Radiant mailing list
>> Post: [email protected]
>> Search: http://radiantcms.org/mailing-list/search/
>> Site: http://lists.radiantcms.org/mailman/listinfo/radiant
>>
>>
>>
>
> _______________________________________________
> Radiant mailing list
> Post: [email protected]
> Search: http://radiantcms.org/mailing-list/search/
> Site: http://lists.radiantcms.org/mailman/listinfo/radiant
>
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant