Theming Composr CMS

Post

Posted
Rating:
#8557 (In Topic #2142)
It has been a while since I dug in to Composr CMS, but as I recall, the templates, such as BLOCK_MAIN_NEWS_SLIDER_SLIDE.tpl *probably* won't change going forward, and any edits I do to it using Show template edit links (at the bottom of the pages in Composr CMS) will travel from upgrade to upgrade, kinda automatically because the templates folks edit are stored in a custom folder, and edits do not overwrite the original code. This is mostly correct?

Post

Posted
Rating:
#8559

Hello,

Some small edits are still being made here and there to templates. It's possible there might be a release, maybe the first RC release, where a lot of template changes are made, to conform them to WCAG standards better. All these edits are made in templates/css/js folders.

When you use the template editor, if you have a *_custom file, that is loaded in. Else, the original file is loaded in (but changes are saved as a *_custom file). *_custom files are maintained between versions / do not change unless you change them.

Be aware when using the template editor, it generally loads in the full original file and saves it with your edits into the custom file. When this happens, the custom file is used, but *not* the original. So any updates to the original file will need to be merged into your custom one. The "file integrity scan" tool in the upgrader usually warns you of this; it will tell you that you have overrides which have originals that are newer, therefore you likely need to update the overrides. And it will list the applicable files.

If you want more flexible (but power-user) functionality, instead of saving the entire contents of the original file into the custom one, start with a blank file (e.g. erase everything in the editor). Then, add this to the top:

 (for CSS files)

Code

/*{+START,INCLUDE,global,.css,css}{+END}*/

(For JS files) 

Code

/*{+START,INCLUDE,global,.js,js}{+END}*/

(For template files)

Code

{+START,INCLUDE,EXAMPLE,.tpl,templates}{+END}

The parameters to the directive are (all may be blank or left out):

  1. the codename of the template to include (e.g. EXAMPLE)
  2. the file extension of the template to include, including the dot (defaults to .tpl)
  3. the subdirectory type of the template to include (defaults to templates) (e.g. templates, css, js)
  4. the theme to include from (usually leave blank and Composr will work it out / use the default theme)
  5. whether to force the non-overridden file (defaults to 0 unless the template being included has the same name as the template the INCLUDE is in; this is the case in what you are doing)

Then, after adding that line at the top, add your customisations / overrides below it. Note you will still need to check these files regularly between updates (file integrity scan will let you know... if no changes need to be made, simply re-save the file without any changes so modification time is updated).

Doing this will ensure everything, except your overridden code, is still automatically updated between version updates. This is unlike if you were to copy the entire original over to the custom / not use the INCLUDE at the top, where you will have to manually merge the changes in every time.

 See https://composr.app/docs/tut-tempcode.htm for more information (Scroll down to INCLUDE directive).

0 guests and 0 members have recently viewed this.