We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17301
    • 932 Posts
    Another approach I've seen quite a few people do is set your templates to static files and then you can commit them on git without having to worry about the database too much.
      ■ email: [email protected] | ■ website: https://alienbuild.uk

      The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
      • 17301
      • 932 Posts
      Hopefully someone will find this useful...

      When you create or edit a template paste this code:

      {set $properties['tpl'] = $_modx->getPlaceholder('template.tpl')}
      {if empty($properties['tpl'])}
      {set $properties['tpl'] = "default"}
      {/if}
      {include "file:templates/tpl/{$properties['tpl']}.tpl"}


      Check 'Is Static' and set the media source to 'templates', usually you'd create one for snippets, chunks, templates etc. In this case our code above is looking in a folder called templates/tpl so our templates media source is pointing to a folder that has these folders within it.

      Then in the properties tab click 'default properties locked' and add a new property set with the name of tpl and the value of 'base', for example. Then create your template 'base.tpl' in the '/templates/tpl/' folder.

      Helpful Tips

      Create an abstract template for your header/footer and inside your container div where you want content to sit within stick
      {block "content"}{/block}
      


      Then when you create a new template, for example a news template, you can extend the abstract template with

      {extends "file:templates/abstract.tpl"}
      {block "content"}
      ***your code goes here***
      {/block}

      Sometimes if you're creating a news template you'll have a different overview/containing page to that of the post page. Instead of creating two seperate tempaltes you can isolate the two markups with

      {if $_modx->resource['isfolder']}
      ***Markup for your news container/overview***
      {else}
      ***Markup for your news post***
      {/if}
        ■ email: [email protected] | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.