We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29332
    • 80 Posts
    I’m trying to add a little message to a page that simply says "Welcome Full Name" or "Welcome User Name". I’ve already tried every code sample on this thread: http://modxcms.com/forums/index.php/topic,3502.20.html, but none of the worked. I’ve tried using the example in the snippet itself, and still nothing. When I view my page logged in both as an admin and a web user, I only get a blank content section. No error messages, just blank. Here’s what I have on my page:
    [[LoggedOrNot? &yesChunk=`Link` &noChunk=`Register` &ph=`name`]]


    I’m running ModX Evo 1.0.4.
      Teaching myself MODx
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      1. When you pasted in the snippet code, are you sure you didn’t duplicate the <?php and ?> tags?

      2. It uses the $_SESSION[’webShortname’] as a check, so it will only display the logged-in chunk if you’re logged in as a web user. Otherwise it will display the not-logged-in chunk.

      3. Make sure the snippet name and the chunk names are exactly as they are in the snippet tags (upper case, spelling, etc).

      Works fine for me. Try it uncached as well.
        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
        • 29332
        • 80 Posts
        I didn’t do anything to the snippet, all I did was copy the example call in the snippet itself. Here’s my snippet:
        <?php
        #::::::::::::::::::::::::::::::::::::::::
        # Created By:Ryan Thrash ([email protected]), 
        #	and then powered up by kudo ([email protected])
        #
        # Date: Aug 03, 2006
        #
        # Changelog: 
        # Dec 01, 05 -- initial release
        # Jun 19, 06 -- updated description
        # Jul 19, 06 -- hacked by kudo to output chunks
        # Aug 03, 06 -- added placeholder for username
        #
        #::::::::::::::::::::::::::::::::::::::::
        # 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 {{}}. Can use a placeholder to output the username.
        #	TESTED: can be used more than once per page.
        #	TESTED: chunks can contain snippets.
        #	
        #	
        # Params:
        #	&yesChunk [string] [REQUIRED]
        #		Output for LOGGED users
        #
        #	&noChunk [string] [REQUIRED] 
        #		Output for NOT logged users
        #
        #	&ph [string] (optional) 
        #		Placeholder for placing the username
        #		ATTENTION!: place this ph only in yesChunk!
        #	
        #
        # Example Usage:
        #
        #	[[LoggedOrNot? &yesChunk=`Link` &noChunk=`Register` &ph=`name`]]
        #
        #	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);
        }
        
        if (isset($ph)) {
        	$modx->setPlaceholder($ph,$test);
        	return $o;
        } else {
        	return $o;
        }
        ?>


        It was pre-installed. Could that me where my problem starts?
        I double checked, I am logged in as a web user, and logged in using IE, while logged in as a site admin in FF.
          Teaching myself MODx
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          If you want to make me a temporary login to your Manager, email me [email protected] with the login details and I’ll take a look.
            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