We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1261
    • 27 Posts
    I’d like the ability to add a custom stylesheet to certain pages in my site that have content requiring extra formatting -- a blog display page, for instance -- to avoid code bloat in the CSS files that are permanently linked to my template. I know I could use inline styles, but I’d prefer not to.

    Now, a TV seems like the obvious answer, but I’d like to keep the editing process as simple as possible for the sake of my non-technical content editing users. I’ve already tested, and while setting the TV to "locked" prevents non-admin users from editing it, it still shows up in the document editing view and I don’t particularly relish the thought of explaining to my users "oh, just ignore that." If there’s a switch I’m missing to hide TVs from users that aren’t authorized/don’t need to touch them, that would be beyond excellent.

    Option #2 seems to be using a page-unique identifier (probably [*alias*]) as the CSS filename -- ie, my template would include
    <link rel="stylesheet" src="/assets/templates/templatename/[*alias*].css" />
    but that’s a bit more granular than I’d ideally like. Is there a hidden ModX variable for "highest non-zero parent’s alias" or something? I’d prefer something a bit more flexible than that, but so long as it keeps the code out of non-admin users’ view, its fine, I suppose.

    [edit: So, I just found out about [!UltimateParent!]. I suppose that makes option #2 somewhat more palatable, although it’ll result in some ugly CSS filenames. Is there anything else I’m missing here? ]
      • 33337
      • 3,975 Posts
      When you setup TV, you can set access permissions for this also, based on Roles, if an editor is not allowed to edit it, it will not render while editing the document.
        Zaigham R - MODX Professional | Skype | Email | Twitter

        Digging the interwebs for #MODX gems and bringing it to you. modx.link
        • 1261
        • 27 Posts
        Thanks, Zi. Your response inspired me to take a closer look at "access controls" for TVs, which seems to have done the trick.

        I find the way that feature is described in the manager to be a bit counter-intuitive, however. When I first read "document groups," I interpreted it to mean that the checkbox would select which documents would be permitted to change the TV from its’ default value. After thinking about it, the current behavior makes sense, but it’s a bit opaque at first

        Is this one of the things likely to change in the near future as per the discussions re: new documentation on the docs forum? If it is, I won’t worry about it, but if not, I wouldn’t mind writing up a wiki page with what I’ve learned, for others who go this way after me.
          • 33337
          • 3,975 Posts
          Well, go ahead and put up a wiki page! smiley .. it will for sure help others.

          Thanks and regards.

          zi
            Zaigham R - MODX Professional | Skype | Email | Twitter

            Digging the interwebs for #MODX gems and bringing it to you. modx.link
            • 1261
            • 27 Posts
            Unfortunately, it looks like I’m still not understanding access permissions correctly.

            Here’s the setup:

            I have a template called "SiteMain" used as the template for a variety of documents which belong to a Document Group, "Site Contents," and a template value called "rc.css" that’s set up to be used in SiteMain and has access permissions set to "Admin Pages Only."

            I -thought- the last part of that -- setting the Access Permissions to Admin Pages Only, was what you meant, since I couldn’t find any way to assign a TV to a Role. And it works, insofar as non-Admin users can’t see the TV when they edit pages using the SiteMain template, but my admin user can. Unfortunately, my Admin user can’t seem to get any changes made to the TV to save -- it always returns to the default after a Save. Am I terribly mucking this up somehow?
              • 33337
              • 3,975 Posts
              What is the type of TV you are using?
                Zaigham R - MODX Professional | Skype | Email | Twitter

                Digging the interwebs for #MODX gems and bringing it to you. modx.link
                • 1261
                • 27 Posts
                It has a textarea for input and no widget for output.

                As an aside, thank you for your responses, Zi. I really appreciate the help getting up to speed here. smiley
                  • 33337
                  • 3,975 Posts
                  You are most welcome smiley

                  Please check this topic: http://modxcms.com/forums/index.php/topic,3284.0.html , if u are using 095 release from download page, then its line# 173 or 169.

                  It should not be there, if you can please log a bug report at http://modxcms.com/bugs/

                  Hope this helps.

                  regards.
                    Zaigham R - MODX Professional | Skype | Email | Twitter

                    Digging the interwebs for #MODX gems and bringing it to you. modx.link
                    • 1261
                    • 27 Posts
                    I made the change suggested in that thread to line 169, but I’m still not having any luck. I wish I knew more about debugging PHP -- I’m really hesitant to start throwing debug print statements into code I don’t know. Maybe in the morning.

                    Huh. I just tried changing the TV through quickedit, and the change stuck that time. I’m mystified, but I suspect that other thread is relavent.
                      • 8069
                      • 1 Posts
                      There is a topic in the MODx Wiki that might help you out. Dynamic CSS with TVs, http://wiki.modxcms.com/index.php/Dynamic_CSS_with_TVs.
                      I used it on my test site to give each section a unique branding.