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

    We're getting some strange behaviour that is proving really difficult to track down - I thought I'd pop this here while we keep looking for a solution.

    We have a series of custom system settings that define the environment (eg: 'development', 'staging', 'production') - these are updated by Grunt depending on the environment in use. All is well there.

    However we are trying to use one of these system settings as a property value (basePath) in media sources:

    An example would be the basePath for a media source on 'development' would be app/src/assets/ but for 'production' would be app/dist/assets.

    So we're either using the straight system setting or a custom snippet call IN the basePath value field. The corresponding media source table updates and all works well...

    ...weirdly though the basePath value 'randomly' (I know there is no such thing!) just updates itself and essentially 'hardcodes' the system setting value in the place of the call to the system setting or snippet (which get's the system setting).

    We've played with the caches (both manager and front-end) and can't seem to recreate consistently - it just 'does it'.

    What are peoples thoughts?

    For some reason - most likely at any point in the system the Media Source basePath value is no longer accepting a variable as a value and overriding that variable as a hard coded string which is the value of that variable.

    Also - I don't even know if we can / meant to use varibles/snippets in property settings??

    I look forward to all ideas, this one is driving my guy nuts (and it's a Friday!)

    Thank you in advance!










      • 3749
      • 24,544 Posts
      I don't think Media Source properties can be dynamic at all. I could be wrong.

      Maybe you can move that logic higher up and use different Media Sources for the different environments.
        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
        • 50264
        • 15 Posts
        Thank you for your swift response. I wasn't sure either, there is no reference to the ability within the docs but it seemed to work...sometimes.

        Creating media sources for each environment may just work, I don't have access to the dev box at the moment but my only concern (without confirming it) would be seeing how the instance knows which media source to use - we still need to 'tie' it together.

        Again, thanks for your help. It's a possible solution out of this!
          • 3749
          • 24,544 Posts
          You might be able to use a plugin that fires only on the Admin login that checks the environment somehow (server name, a config file, etc.) and modifies the Media Source if necessary.
            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