We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20682
    • 31 Posts
    This code is used in the default installation of 0.9.6 with regard to creating new entries through Newspublisher:

    @EVAL if ($modx->getLoginUserID()) return 'Logout'; else return 'Login';


    I would like to create a different template to use for the page that the user is redirected to when not logged in. But, I am not sure how this small piece of script works. Is "Login" the document’s alias name? Is it a chunk name or a snippet name?

    Thanks for any help.
    Sheri
      • 26435
      • 1,193 Posts
      Hey muskokee.
      @EVAL is a Template Variable binding. As it’s name implies, it evaluates a PHP conditional.

      what this particular script evaluates is whether or not a user is logged in.
      If a user is logged in, $modx->getLoginUserID() will return the user id, if a user (specifically a webuser) is not logged in, it will return 0 or false.

      So, this script is saying is if a user is logged in, output the word "Logout" in this space, otherwise, output the word "Login".  When using this TV as the pages menu title, the menu title becomes dynamic and changes between "Login" and "Logout" depending on whether or not a user is logged in.

      I hope this clarifies what is happening with this @EVAL example.

      -sD-
      Dr. Scotty Delicious, Scientist.
        Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
        All of the above... in no specific order.


        I send pointless little messages
        • 7455
        • 2,204 Posts
        LOL Scotty just beat me on the answer but here are by 2 cents:

        Login is nothing more than a word in this case

        this piece of code is used to make the title from the login/logout page change if you are logged in or not.

        in English this code says:

        if the user is logged in then return Logout if not then return login just the word Login and Logout

        you could return it like this:

        @EVAL if ($modx->getLoginUserID()) return ’{{Logout}}’; else return ’{{Login}}’;

        then you could make a chunk calles Logout or Login and get this chunk called.

          follow me on twitter: @dimmy01
          • 20682
          • 31 Posts
          Thanks guys! That was simple laugh

          The behavior I am seeing must be written into Newspublisher then. If I attempt to access the blog entry page, I am booted over to another page showing me a login request.

          I’ll delve into newspublisher to figure out how to boot the user to a different page.

          Thanks again

          Sheri

          ***** UPDATE *******
          I found what I was looking for in the configuration. This is the parameter that redirects a user who is not authorized to view the page:

          Unauthorized page:Enter the ID of the document you want to send users to if they have requested a secured or unauthorized document. NOTE: make sure the ID you enter belongs to an existing document, and that it has been published and is publicly accessible!

          It’s a shame I can’t specify different unauthorized pages for different page accesses attempted by users
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: muskokee at Jul 13, 2007, 08:53 PM

            It’s a shame I can’t specify different unauthorized pages for different page accesses attempted by users
            You can, but you would need to control that programmatically in your code for those particular pages.
              • 20682
              • 31 Posts
              Is there a specific code that is used to represent the various config values? A snippet would do the trick if this were so.

              Thanks!

              ****found the code to reference the config values: $modx->config[’base_path’]

              how to set the value though?

                • 20682
                • 31 Posts
                How about this function for redirection?

                $modx->sendForward(1);
                  • 22303 MODX Staff
                  • 10,725 Posts
                  See sendRedirect().

                  e.g.
                  <?php
                  ...
                  $modx->sendRedirect($modx->makeUrl($pageid));
                  ?>
                    • 20682
                    • 31 Posts
                    Thank you open geek!