We launched new forums in March 2019โ€”join us there. In a hurry for help with your website? Get Help Now!
    • 9995
    • 1,613 Posts
    fourroses666 Reply #1, 13 years ago
    I need to show something when an user is logged into the front-end (webuser)
    I have tryed this phx: snippet but I always see Logged In..

    [+phx:loggedinweb:then=`Logged In`:else=`Not Logged In`+]


    I don't want to use Personalize because I need to make too much chunks or there is a easy other way.

    This gives a error:
    [+phx:mo=`myWebgroup`:then=`xxx`:else=`yyy`+]
    [ed. note: fourroses666 last edited this post 13 years ago.]
      Evolution user, I like the back-end speed and simplicity smiley
      • 9995
      • 1,613 Posts
      fourroses666 Reply #2, 13 years ago
      I tried a different way:

      In Ditto:
      &tplFirst=`@CODE: <h2>[+pagetitle+]</h2>`


      Somehow Evo 1.0.10 and @CODE doesn't work?!

      Does anyone has a good solution to show something only when loggen in with only one simple call like:

      when logged in : then x : else y ?
        Evolution user, I like the back-end speed and simplicity smiley
        • 20413
        • 2,877 Posts
        Are those calls in the template? Weird! Did you spell the usergroup right? What's the gist of the error?

        I've only dealt with manager users in evo1012 but try this (untested):
        snippet: displayMsg
        <?php
        $output = '';
        $private  = isset( $private )  ? $private  : $output;
        $public  = isset( $public )  ? $public  : $output;
        if (!isset($_SESSION['webValidated']))
        {
        	$output = $public;
        }
        else
        {
                $output = $private;
        }
        return $output;
        ?>


        ยป The call: [[displayMsg?private=`This is private` &public=`This is public`]]

        Notice: EVO snippet variables strip = , ? and &

        In order to use those ones, one has to do:
        <?php
        $output = '';
        $params = array(); 
        if (isset($private)) $params['private'] = str_replace(array('|xq|','|xe|','|xa|'), array('?','=','&'), $private);
        else return $output;
        if (isset($public)) $params['public'] = str_replace(array('|xq|','|xe|','|xa|'), array('?','=','&'), $public);
        else return $output;
            // This is how FeedX does it
            //  ?  =>  |xq|
            //  =  =>  |xe|
            //  &  =>  |xa|
        if (!isset($_SESSION['webValidated']))
        {
        	$output = $params['public'];
        }
        else
        {
                $output = $params['private'];
        }
        return $output;
        ?>
          @hawproductions | http://mrhaw.com/

          Infograph: MODX Advanced Install in 7 steps:
          http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

          Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
          http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
          • 9995
          • 1,613 Posts
          fourroses666 Reply #4, 13 years ago
          Thanks!

          This works: chunk displayMsg

          <?php
          $output = '';
          $private  = isset( $private )  ? $private  : $output;
          $public  = isset( $public )  ? $public  : $output;
          if (!isset($_SESSION['webValidated']))
          {
              $output = $public;
          }
          else
          {
                  $output = $private;
          }
          return $output;
          ?>


          The call:
          [!displayMsg?private=`This is private` &public=`This is public`!]


          ##################

          When I add [+phx:mo= in my template I get the following error. (correct name)
          Prolly phx is conflicting or smt.

          PHP error debug
          Error : strlen() expects parameter 1 to be string, array given
          ErrorType[num] : 	WARNING[2]
          File : 	/usr/home/xxx/domains/xxx.com/public_html/modx/assets/plugins/phx/phx.parser.class.inc.php
          Line : 	209
          Source : 	$grps = (strlen($modifier_value) > 0 ) ? explode(",",$modifier_value[$i]) :array(); 


          ##################

          This seems to work only when the page is uncached I just noticed.
          [+phx:loggedinweb:then=`Logged In`:else=`Not Logged In`+]
            Evolution user, I like the back-end speed and simplicity smiley
            • 28042 โ˜† A M B โ˜†
            • 24,524 Posts
            Probably because when a page is cached there are no more phx tags, since they get removed. An uncached page of course will be straight from the database, and the tags are there. Revo allows all elements to be uncached wink
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 9995
              • 1,613 Posts
              fourroses666 Reply #6, 13 years ago
              didn't know that :-o
                Evolution user, I like the back-end speed and simplicity smiley