Looks like you solved it, works great! Thanks Raluca :-)

Regards,

Lockie


Raluca Stavro-2 wrote:
> 
> Hello Ricardo and Lockie,
> 
> If you want the initial value to be collapsed, but then you want cookies
> to
> work, what you have to do is to add a JavaScript function that will handle
> the initial cookie.
> The rationale is:
> 1. Check if a cookie exists for the current panel, on the client side
> 2. If there is no such cookie, toggle panel visibility
> 
> This is the code of a panel:
> 
> ##
> ## Get cookie
> ## ----------------------------------
> #set($id = $util.generateRandomString(30))
> 
> #set($cookieName = "${xcontext.user}_${panel}")
> #set($panelCookie = $xwiki.getUserPreferenceFromCookie($cookieName))
> 
> ##
> ## Display panel
> ## ----------------------------------
> #panelheader("Test")
> 
> #panelfooter
> ##
> ## If there is no cookie set for the current panel,
> ## toggle panel visibility (since by default the panel is expanded)
> ##
> -----------------------------------------------------------------------------------------
> #if("$!panelCookie" == '')
>   
> #end
> 
> This way, you don't need #set($expanded = 'collapsed') anymore.
> 
> I hope this helps you both,
> 
> Raluca.
> 
> 
> On Sat, Mar 12, 2011 at 5:57 PM, Ricardo Rodriguez [eBioTIC.] <
> [email protected]> wrote:
> 
>> Hi Lockie!
>>
>> On 3/8/11 1:31 AM, Lockie wrote:
>> > Ricardo Rodríguez wrote:
>> >> #if(!$expanded)
>> >>     #set($expanded = 'collapsed')
>> >> #end
>> >>
>> > Thanks I found this helpful. It means I don't have to have javascript
>> > extensions collapsing the panels, slowing down load times.
>>
>> But as Raluca stated in her previous message, this causes the panels to
>> keep collapsed because this value prevents the cookie to be created. I'm
>> afraid I'm still lost with this issue: I don't understand yet why
>> setting $expanded = 'collapsed' instead of reading its value from a
>> cookie prevents cookies function.
>>
>> Please, Lockie, how to you get a collapsed panel at page loading time
>> being later on controlled by a cookie? I mean, panel A appears collapsed
>> when you access the site for the first time. From this moment onwards, a
>> cookie will remember the preferences of each visitor.
>>
>> Here it is the example that is making me nuts:
>>
>> http://pescaderias.org
>>
>> It is a simple portal still in progress. I want that all four menus on
>> the right will appear collapsed the first time a visitor/users access
>> the site. And that the stated of each panel will be stored in a cookie
>> for subsequent visits.
>>
>> #set($expanded = 'collapsed') allows me to show them collapsed, but
>> prevents cookies function. In fact cookies are never created. I think I
>> understood Raluca's explanation in the her previous message in this same
>> thread, but I'm still not able to find a solution for this issue.
>>
>> Thanks!
>>
>> Ricardo
>>
>>
>> > -----
>> > ----
>> > Lockie
>> > --
>> > View this message in context:
>> http://xwiki.475771.n2.nabble.com/struggling-to-understand-panels-expanding-initial-state-tp6095465p6099685.html
>> > Sent from the XWiki- Users mailing list archive at Nabble.com.
>> > _______________________________________________
>> > users mailing list
>> > [email protected]
>> > http://lists.xwiki.org/mailman/listinfo/users
>>
>> --
>> Ricardo Rodríguez
>> CTO
>> eBioTIC.
>> Life Sciences, Data Modeling and Information Management Systems
>>
>> _______________________________________________
>> users mailing list
>> [email protected]
>> http://lists.xwiki.org/mailman/listinfo/users
>>
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users
> 


-----
----
Lockie
--
View this message in context: 
http://xwiki.475771.n2.nabble.com/struggling-to-understand-panels-expanding-initial-state-tp6095465p6229138.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to