Pages: [1]
  Print  
Author Topic: Change the initial page dynamically?  (Read 358 times)
icd2k3
Gaia User
**
Posts: 15


« on: March 04, 2011, 11:43:57 AM »

Hey Gaia people! Loving the framework, but running into a bit of a snag with some stranger functionality...

So basically the site I'm working on has a login system and the client wants it to go to a different page first base on if you're logged in or not.

Example
Not Logged In: Start with page "intro" (current site.xml default page)
Logged In: Start with page "welcome"

I found a hackish way of doing it by checking in the first deeplink event in index, but it cancels out the intro preload and generally doesn't seem like a very efficient way of coding this functionality.

I assume when Gaia parses the site.xml it has to set some sort of default page right? is there any way to hijack or override that variable to make the initial page whatever I want? I assume it has something to do with defaultChild. Thanks for any suggestions!
« Last Edit: March 04, 2011, 12:02:03 PM by icd2k3 » Logged
icd2k3
Gaia User
**
Posts: 15


« Reply #1 on: March 04, 2011, 01:19:55 PM »

Took me a few hours to figure out because there's not much documentation in this (or maybe I just need more Gaia practice). At first I was trying to call defaultChild within index like this.defaultChild = whatever. Then I figured you probably had to do it using getPage and I was trying to pass it a route for defaultChild... Anyways, if anyone else is looking for the solution here it is:

(in constructor for index)

Code:
if(_userData.isLoggedIn) {
Gaia.api.getPage("index").defaultChild = "loggedIn";
}

Pretty easy... was just having trouble with the syntax of where I should put ".defaultChild ="
Logged
3dsign
Gaia Novice
*
Posts: 1


« Reply #2 on: September 05, 2011, 03:04:12 PM »

Hi, I had no luck with this, it doesn't work, it just sets the value of deafultChild variable, but it doesn't change the default page I need to be loaded.

Please help me!
Logged
icd2k3
Gaia User
**
Posts: 15


« Reply #3 on: September 07, 2011, 07:33:58 AM »

As far as I remember, it should work fine as long as you put that in the constructor of your index page. I would check to make sure the variable name of the page you're pointing to is correct as I ran into a few problems that way.
Logged
Ramiro
Moderator
Gaia Addict
*****
Posts: 861


interactive pragmatism


« Reply #4 on: September 07, 2011, 11:02:15 AM »

how do you know the user is logged in or not? you call for a webservice in the init code? the php/asp/jsp html container knows?
Logged
icd2k3
Gaia User
**
Posts: 15


« Reply #5 on: September 07, 2011, 11:05:52 AM »

Yep

but really, this is less about the login status as it is setting a new default page for Gaia to go to when your website starts up. As far as I remember setting default child in the first constructor worked perfectly.

I suspect 3dsign's problems with it may be related to just having the wrong page name variables ("index" or "loggedIn").
Logged
Pages: [1]
  Print  
 
Jump to:  

TinyPortal v1.0 beta 4 © Bloc