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

    Have made some of my CSS dynamic by creating a document set to type css, the template set to empty and the content has a tag that points to a chunk with the actual css in.

    I wanted to be able to create some TV's so that I can have a user change elements of the CSS file.

    What I have tried tried:


    1. Created a template, say 'Css_Template' , that has my TV's and setting my css document, say 'styles', to template 'Css_Template' - this failed, causing an error in the css file when loading the webpage
    2. Created a new document say 'css' and set the template to 'Css_Template'. Then in 'styles' with the template left at 'empty' I set it to be a child of 'css' in the hope that any TV's would get inherited - this unfortunately do not work

    The only way I could get it to work but it is of no real practical use is to temporarily set 'styles' to have a template of 'Css_Template', set all the TV's, then set the template back to 'empty' and I could then access my TV's via MODX tags in the Css Chunk, and my webpage would not error.

    Probably doing this all wrong but would be interested to know otherwise.

    Revo 2.2-4pl

    Many thanks.
    • Usually I'll have a small style block in the template head using the TVs. The TVs would be radio buttons, which could refer to chunks or be the actual CSS values, such as colors or sizes, with the default being @INHERIT if I want the styles to be inherited.
        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
        • 40541
        • 85 Posts
        Hi,

        Thanks for answering.

        Thats a great idea and one I will definitely remember for the future.

        In my particular case and if I am understanding you correctly, I would just need to put @INHERT as my default value in the TV when using my option 2? Which I have tried and does not work, probably because the sinario is different in my case.

        In my CSS I have some background images that I wanted the user to be able to change using Gallary. The way I would do is is by taking the css

        background-image:url(/assets/gallery/4/9.png)


        and replacing the url with

        [[!getPicSrc? &imageTV=`[[*divButton1Bw]]`]]


        getPicSrc is a snippet as per below

        <?php
        $obj=json_decode($imageTV);
        return $obj->gal_src;


        this works fine for dynamically changing the url but only in the way explained above.

        My TV input is set to GalleryItem and my output is set to text, the default value is set to @INHERIT.

        Many thanks.
        • Gallery may be overkill in this case; it would be much easier to just use an image type TV with a media source to a directory where images can be uploaded and selected. Unless, of course, you're also using that same Gallery for a gallery besides supplying background images.
            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
            • 40541
            • 85 Posts
            Which I am unfortunately and why I have been persistent with it. Could probably live without the feature, or combine the two worse comes to worse but was just wondering if I had missed anything.

            Thanks
            • Well, maybe then a simple image TV with a media source limited to the Gallery folder to use? But then if the Gallery folders are likely to be dynamic that wouldn't work either.

              I'm sure there must be a way to make use of the images in the Gallery folder; I've never used Gallery though.
                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