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

    I'm developing a site for a company with multiple office locations. Something like this (simplified site-map)

    Locations
    ....London
    ........page 1
    ........page 2
    ....Liverpool
    ........liverpool sub page 1
    ........liverpool sub page 2
    ....Manchester
    ........manc sub page

    There will be users for each location, with permission to make changes for their own location only.

    I want each location to have it's own folder of images. File structure looks like this:
    /locations
    /locations/london
    /locations/liverpool
    /locations/manchester

    All the location pages will use the same template. So how can I specify an image template variable to use the correct media source when the same template is used across all pages?

    Hope I've made sense, as you may tell, I am a complete novice with modx. I'm picking it up quite well, but this has stumped me.

    Jay.
    @letsallplaygolf
      • 4172
      • 5,888 Posts
      you can add a snippet-call to mediasource-pathes like that example:

      assets/images/[[getUserID]]/


      the example-snippet getUserID:

      if (is_object($modx->resource)){
      $createdby = $modx->resource->get('createdby');
      //at frontend or if created resource is active, return createdby
      if (!empty($createdby)){
      return $createdby;
      }
      }
      // else (backend) return userid
      return $modx->user->get('id');


      this example works with the createdby-field if it exists on a resource or the userid.
      This needs to be modified for your needs.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!