Jump to main content Jump to doc navigation
Note: This document does not describe a full workflow for using static resources and elements, and could do with a rewrite.

The Problem

When working in collaboration, teams of developers and designers often collaborate via Subversion (SVN) to make development easier between multiple people. MODX, however, stores its data in the database. This has many benefits generally, but DB-stored code cannot be version-controlled via SVN.

However, the solution in MODX Revolution is quite simple.

The Solution

For Resources, it's simple. Just use Static Resources, and point the content to a file in your SVN checkout.

The following is relevant to older versions of MODX. For MODX 2.2.x, as with static resources, simply use Static Elements. Static Elements have the further advantage of being able to use Media Sources.

For Elements, all you need is a simple "include" snippet. The code:

if (!file_exists($file)) return '';
$o = include $file;
return $o;

You can then call it like so in your Static Resources:

[[include? &file=`/path/to/my/svn/checkout/snippet.php`]]

And you're done. You can also use tags within the 'file' parameter, such as this:

[[include? &file=`[[++assets_path]]/js/myscript.js`]]

Conclusion

This allows you to easily manage content via SVN. It can be achieved with Templates and TVs as well; just plop the include snippet wherever you need filesystem-based files.

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.

Backers

  • modmore
  • STERC
  • Jens Wittmann – Gestaltung & Entwicklung
  • Fabian Christen
  • Digital Penguin
  • Dannevang Digital
  • Sepia River Studios
  • CrewMark
  • Chris Fickling
  • deJaya
  • Following Sea
  • Anton Tarasov
  • eydolan
  • Raffy
  • Lefthandmedia
  • Murray Wood
  • Snow Creative
  • Nick Clark
  • Helen
  • JT Skaggs
  • krisznet
  • YJ
  • Yanni
  • Richard

Budget

$366 per month—let's make that $500!

Learn more