Questions tagged [modx-templates]

Questions about creating, managing and using templates and their variables in the ModX CMP. Templates in ModX are a way to manage look at functionality between types of ModX Resources.

Templates in ModX (Evolution and Revolution) are ModX Elements allowing management of style and functionality by type of ModX Resources. A simple example is: Assume you have a Resource that is an article. The content of the document is the Resource itself. The template would be article.

This structure allows the developer to logically design groups of resources at once. Modx Markup can then be utilized just as simply in the template rather than the resource. With ModX Chunks and Snippets, the structure is pretty free form. This allows for many different levels of abstraction, depending on need.

Template Variables

Templates have the ability to apply variables to Resources that use them. These variables may be a variety of different types, displayed in a variety of different ways. Each may also have validation included by the system or even custom validation. Every resource that uses the template may then have its own value for that variable. Validation occurs at the time the resources is edited.


Creating a Template

While there are many plugins for managing resources and their content through the front-end of your website, Templates should be created and edited through the manager. For more detail, see the ModX Documentation for Templates

  1. Log into the Manager.

  2. In the sidebar, click on the "Elements" tab.

  3. Either: a) Right click on Templates and choose "Create Template"; or b) Click on the button that looks similar to a form or window (a tooltip will appear showing "New Template").

  4. Add a name.

  5. Add some content that you want to see in all documents of that type. Don't forget to place [[*content]] where you would like it to be rendered.

  6. Click "Save".

Creating a Template Variable

These instructions explain how to make the most basic template variable. Template Variables have so many options, it is impossible to completely cover them here. A more detailed resource can be found in the ModX Documentation for Template Variables

  1. Log into the Manager.

  2. In the sidebar, click on the "Elements" tab.

  3. Either: a) Click on the button that looks like a TV; or b) Right click on Template Variables and choose "Create Template Variable".

  4. Add a name: this can be referenced in markup using [[*name]].

  5. Add a caption: this is the display name on the resource editing form.

  6. Click on the "Input Options" tab. Choose the type of variable.

  7. Click on the "Template Access" tab. Click the check box next to each template that you want add the variable to.

  8. Click "Save".

48 questions
0
votes
1 answer

Is it possible to configure TableSorter to display dynamic data in 1 table?

First off, what a great plug in; Now, question: Is it possible to configure TableSorter to display dynamic data in 1 table? I have a form on the front end & once submitted is saved to mysql. This data is displayed in a table on the front end. This…
Michael Joseph
  • 115
  • 1
  • 3
  • 13
0
votes
1 answer

How to get src path from TV image in ModX?

The situtation is the following: I have a TV of image type called [image-news]. When I call it in a chunk it represents Is there a way to get src-url of the template variable or to change its…
Alex
  • 31
  • 5
0
votes
1 answer

modx - issue with capital case letters in alias

I have a page in modx for which I have created a symlink to make available the same page in bit lengthy URL also. My problem is I need to have symlink alias URL with some capital case letters. I tried to save it with proper capital case letters modx…
Arun
  • 11
  • 2
0
votes
3 answers

Modx rich text input field for template variable

I'm new to modx Rev and I am trying to set the input field for a template variable so that it uses my chosen richtext editor. If I set the input field as rich text I just get a 1 line text field. If I set the editor as Textarea then thats all I get…
user2317093
  • 746
  • 4
  • 8
  • 25
0
votes
1 answer

Modx formit + fromz duplicate email

I use the last modx revo with formZ and it duplicates emails. Each time I submit the form I receive the email twice. I can't figure it out. Here is my form tpl: [[!FormIt? &hooks=`[[+action]][[+hooks:notempty=`,[[+hooks]]`]]` …
0
votes
2 answers

How to organize templates in multilingual modx

I'm building a multilingual website with ModX, so I installed the Babel extra and the things seem to be working fine. I am now wondering how to handle my templates and I can't come up with a solution for using the same template for pages with…
fkoessler
  • 6,932
  • 11
  • 60
  • 92
0
votes
2 answers

Output placeholders of modx TV list-box

I am new to modx and have limited knowledge of PHP. I'm writing a snippet and struggling with the syntax. I want to output placeholders of template variable list-box. What I have tried to do is to get the TV list-box IDs and loop through each one…
0
votes
1 answer

MODX getPage caches non cacheable snippets in 1st resource, how to fix the bug

I have a strange problem. I use getPage to view some similar resources. They have one template and same resource options. The problem is that getPage trying to cache my non-cacheable snippets in the 1st element. If u see next code, u can notice the…
0
votes
2 answers

Modx php & Template variable

Is there a way to do something like that in a snippet :
Sylvain Le Bihan
  • 163
  • 1
  • 2
  • 13
0
votes
2 answers

modx Decrement a TV to obtain 0

I need my [[+idx]] tv to start at 0 instead of 1 so I tried this: [[+idx:decr]] or [[+idx:substract=1]] but it gives me -1 (minus one). Does anyone know another way to obtain 0? Thank you
Sylvain Le Bihan
  • 163
  • 1
  • 2
  • 13
0
votes
3 answers

modx template-ing in files not in the db

So I've got the template files working correctly. Sort of. The static resource does render. But when I make changes to the file, I MUST hit save in the Modx ui before the changes show up in the output. Is there any way I can turn the cache off all…
Fresheyeball
  • 29,567
  • 20
  • 102
  • 164
0
votes
2 answers

Loading template variables from another document

I have a document with ID = 1, which relies on a series of template variables in the format [+template-variable-NUMBER+]. I have filled fields using these values, and it's good for document ID = 1. What I want to do, however, is paste the values of…
Tomasz Szulc
  • 4,217
  • 4
  • 43
  • 79
0
votes
2 answers

How can I extract the core of a Wordpress Theme and transfer / recode it to be used in Modx?

I have bought WP Themes to look at their code so that I can transfer them to Modx, are there specific folders I should look out for? If it helps one of the Wordpress Themes (Roots), uses the HTML5 Boiler Point and Twitter's Bootstrap.
0
votes
2 answers

Pagination [+next+] not working on MODx CMS template

I'm having difficulty getting the pagination functionality working with [[Ditto? ... ]] in MODx CMS. I have the documents displaying in the page, limit is set to 5. The output from my other pagination template placeholders seem to be working but the…
Chris
  • 882
  • 1
  • 10
  • 22
0
votes
1 answer

ModX Revolution TV Access Permissions not working as expected

I'm having difficulty getting the access permissions set on a Template Variable in ModX Revolution. I'm a member of the Administrators group, which has full access to the Admin resource group. However, whenever I set my template variable to allow…
Matthew Simpson
  • 153
  • 1
  • 16