How can I change link displayed dynamically without putting logic in view?

thread: 4 messages  |  last: a year ago  |  started: tuesday, march 23, 2010, 11:37 am pdt


#1  |  kingwithin (San Francisco, CA) United States of America
Tuesday, March 23, 2010, 11:37 AM PDT

I want to change the link displayed depending on whether the user has completed his User Profile or Not:


    public function IsProfileComplete() {

    $this->objUserDetails = UserDetails::LoadById($this->objUserUser->UserDetailId);
        if(
            !$this->objUserDetails->LName ||
            !$this->objUserDetails->Title ||
            !$this->objUserDetails->City
        ) {
            echo <a href='incomplete linklink'/>;
            
        } 

        echo <a href='completed link'/>;
    }

Not sure if I'm doing this right, but then wanted to do $this->IsProfileComplete() in the View?

Better way?  Thanks.

#2  |  Zbyszek Czarnecki (Warsaw, PL) Poland
Tuesday, March 23, 2010, 12:18 PM PDT

I would use a QLinkButton in this case, with a action function that calls your function and QApplication::Redirect accordingly.

Your function should reside in your data classes and return true and false IMHO.

#3  |  kentpachi (France, EU) France
Sunday, March 28, 2010, 4:10 AM PDT

Which will give somthing like this :

   public function IsProfileComplete() {

    $this->objUserDetails = UserDetails::LoadById($this->objUserUser->UserDetailId);
        if(
            !$this->objUserDetails->LName ||
            !$this->objUserDetails->Title ||
            !$this->objUserDetails->City
        ) {
            $this->btnLink->Url = "complete profile";
            
        } 

         $this->btnLink->Url = "next profile step";
    }

and then render the btnLink in the page

#4  |  kingwithin (San Francisco, CA) United States of America
Sunday, March 28, 2010, 8:41 AM PDT

Okay, I think I see, if the first popup changes teh condition of the profile, will it then refresh the link button via an Ajax call?

If not, how do I do that?

In other words, LinkA will show up and say that the profile is incomplete and upon a QForm which allows the profile to be completed.

Upon completion and successful save(), will the QLinkButton now be LinkB?



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.