We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47432
    • 48 Posts
    Hi,
    i'm trying to have tv inside css, i have backgrounds images in sliders and things like that and i would like to offer my clients the ability to easily change the image (for the moment i'm just testing things, as i'm learning modx!)

    I succeed in having my css has document, and then i tried to have my tv, but don't work, then i tried to have my tv inside a chunk and the chunk in the css, don't work (i have read about that in the forum, but it was a 7 years old post, so maybe there are solutions now!)

    finally i found the solution having inline css with the tv inside: <div class="bg img" style=" background-image: url('[[*bgImg?]]');"> , that works perfectly

    So i wanted to know if this practice is good, and if there's now a solution to have directly tv to css (when css is a document)

    Thanks in advance!

    i'm on modx since 1 week only, coming from wordpress, and i found it fantastic when it comes to integrates an html template, that i build with webflow (very much complicated with wp for a front en designer!), and learning how to best feet my needs smiley
    • A TV is only good for the resource that it's edited on. So if you have a resource "style", then a TV edited on the "home" resource will have no effect on the "style" resource (as you have noticed).

      Unless you want the values different for different pages, then the solution to this is to use the ClientConfig extra. This allows you (the Admin user) to create system settings in a CMP that your editors can access, to change the values in the settings you created. Then you would use regular System Settings tags like [[++bgImg]] in your "style" resource.

      If the CSS values are to be different for different pages, I prefer to have a small style block in the head of my template (usually actually in a chunk), and put the directives that use TVs there. It's much better than using inline styles.
        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
        • 47432
        • 48 Posts
        Thank you,
        i'm going to study that!
        for the moment i don't need to have different css value on different pages, but if it comes, i have the solution smiley