We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16429
    • 254 Posts
    Attention! This is deprecated: Personalize 2.0 was added to the Repository with new functions. Go to Personalize 2.0 page for further info!



    Simple hack of "Personalize" by Ryan Thrash: takes 2 chunks as params, an display one (yesChunk) to LOGGED users and the other (noChunk) to those unlogged.

    Useful to display a "Register if you want..." to unregistered users.
    I appreciate links to pages using it (just to see it in motion). If noone complains after a week, I’ll add it to the repository.

    #::::::::::::::::::::::::::::::::::::::::
    # Snippet Name: LoggedOrNot 
    # Short Desc: calls a chunk if the user is logged in, otherwise calls another
    # Version: 1.0
    # Created By: kudo ([email protected]), almost totally based on
    # 			  Personalize, by Ryan Thrash ([email protected])
    #
    # Date: July 19, 2006
    #
    # Changelog: 
    # Jul 19, 06 -- initial release
    #
    #::::::::::::::::::::::::::::::::::::::::
    # Description: 	
    #	Checks to see if webusers are logged in and displays yesChunk if the user
    #	is logged or noChunk if user is not logged. Insert only the chunk name as
    #	param, without {{}}.
    #	Only meant to be used once per page.
    #	
    #	
    # Params:
    #	&yesChunk [string] [REQUIRED]
    #		Output for LOGGED users
    #
    #	&noChunk [string] [REQUIRED] 
    #		Output for NOT logged users
    #
    #	
    #
    # Example Usage:
    #
    #	[[LoggedOrNot? &yesChunk=`Link` &noChunk=`Register`]]
    #
    #	Having Chunks named {{Link}} and another {{Register}}, the first will be
    #	published to registered user, the second to non-registered users.
    #
    #::::::::::::::::::::::::::::::::::::::::
    
    # prepare params and variables
    $o = '';
    $yesChunk = (isset($yesChunk))? $yesChunk : '';
    $noChunk = (isset($noChunk))? $noChunk : '';
    
    # do the work
    $test = $modx->getLoginUserName();
    if ($test) {
        $o = $modx->getChunk($yesChunk);
      } else {
        $o = $modx->getChunk($noChunk);
    }
    
    return $o;
    


    PS: next version will have option to use snippets as output.
      kudo
      www.kudolink.com - webdesign (surprised?)

      [img]http://www.kudolink.com/kudolinkcom.png[/img] [sup]proudly uses[/sup] [img]http://www.kudolink.com/modx.png[/img]
      • 25663 MODX Staff
      • 12,272 Posts
      This sounds like a better version of Personalize. Let’s release it as the next version, what say?
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 6726
        • 7,075 Posts
        That’s pretty cool new features, thanks for sharing kudolink !

        This will definitely come in handy smiley
          .: COO - Commerce Guys - Community Driven Innovation :.


          MODx est l'outil id
          • 16429
          • 254 Posts
          Quote from: rthrash at Aug 01, 2006, 03:25 PM

          This sounds like a better version of Personalize. Let’s release it as the next version, what say?

          I’ll be proud of it grin
            kudo
            www.kudolink.com - webdesign (surprised?)

            [img]http://www.kudolink.com/kudolinkcom.png[/img] [sup]proudly uses[/sup] [img]http://www.kudolink.com/modx.png[/img]
            • 16429
            • 254 Posts
            Personalize 2.0 was added to the Repository with new functions. Go to Personalize 2.0 page for further info.
              kudo
              www.kudolink.com - webdesign (surprised?)

              [img]http://www.kudolink.com/kudolinkcom.png[/img] [sup]proudly uses[/sup] [img]http://www.kudolink.com/modx.png[/img]
              • 6726
              • 7,075 Posts
              Great news !

              Off to downloading it grin
                .: COO - Commerce Guys - Community Driven Innovation :.


                MODx est l'outil id