We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51020
    • 670 Posts
    Hi,

    I am working on a live site and want to add some media queries to it without the end user seeing until it's finished. I was thinking of initially creating a seperate style sheet for the media queries, and then only showing that to managers who are logged in.
    I tried the below;
    [[!+modx.user.id:isloggedin:eq=`1`:then=`
    <!-- logged in -->
    `:else=`
    <!-- NOT logged in -->
    `]]

    But even though I'm logged in as a manager, it's still show me the 'else' comment instead of the 'then' comment.

    What am I doing wrong?

    Thanks
    Andy

    This question has been answered by multiple community members. See the first response.

    • discuss.answer
      • 3749
      • 24,544 Posts
      I would try a snippet in the Template:

      if ($modx->user->isMember('Administrator')) {
          $modx->regClientCSS('path/to/css/file');
      }
      return '';


      That will inject the CSS at the end of the head section where it will override any previous CSS file.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 51020
        • 670 Posts
        Quote from: BobRay at Jun 13, 2016, 05:58 PM
        I would try a snippet in the Template:

        if ($modx->user->isMember('Administrator')) {
            $modx->regClientCSS('path/to/css/file');
        }
        return '';


        That will inject the CSS at the end of the head section where it will override any previous CSS file.

        Ah Ok thanks - I actually found this online in the meantime - using an isAdmin snippet - this was designed to hide google analytics to managers, but does the same job I guess!

        https://www.markhamstra.com/modx/2012/01/hiding-google-analytics-code-from-manager-users/

        Thanks
        Andy
          • 3749
          • 24,544 Posts
          They do almost the same job. Mark's snippet uses hasSessionContext('mgr'), so it will detect anyone who is logged into the mgr context (Administrator group member or not), but not someone who is testing the front-end without logging in to the Manager. Which one would be better depends on the specific use case.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
          • discuss.answer
            • 51020
            • 670 Posts
            Quote from: BobRay at Jun 14, 2016, 03:01 PM
            They do almost the same job. Mark's snippet uses hasSessionContext('mgr'), so it will detect anyone who is logged into the mgr context (Administrator group member or not), but not someone who is testing the front-end without logging in to the Manager. Which one would be better depends on the specific use case.

            Gotcha - thanks for clarifying.