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
2
votes
1 answer

How to create Dynamic Menu in Modx

I want to create a e-commerce in Modx CMS. I have create dynamically everything in Modx, but i am not able to create dynamic menu. How can i do this?
2
votes
5 answers

Output modifier on modx placeholder is not working

I have this code in a template [[+isShowMore:is=`1`:then=`show more`:else=`no`]] It is printing no. But it should show show more as placeholder isShowMore is set to 1 by this line of code in a snippet. $modx->setPlaceHolder('isShowMore', 1); Also…
chanchal118
  • 3,551
  • 2
  • 26
  • 52
1
vote
4 answers

modx create layout with chunk and call with template

I'm using modx revolution. I'd like to create a chunk called layout that calls other chucks example Head header nav body footer then in my template do something like //open layout tag[[$layout]] [[$layout]]//close layout tag. then inside of the the…
Code Junkie
  • 7,602
  • 26
  • 79
  • 141
1
vote
1 answer

MODX Evolution. It is possible to get Template Variable ID in template?

I need to know which ID the Template Variable (TV) has, to put it into a form in the template. Something like this: Does MODX Evo have some special tag for it, which can be used in templates?
user4545171
1
vote
1 answer

Create article preview in ModX?

How can I create preview of my articles(which are in the resource "articles") using their [[*description]] and [[*introtext]] in the right sidebar on another resources page, called "services"(this page's (template) code:…
1
vote
3 answers

All MODX *publishedon dates showing same date despite different inputs

I am using: [[*publishedon:strtotime:date=`%e %B %Y`]] This shows a date (18 August 2015 for some reason) but it won't change. No matter what date I put into the Published On field this will not change. I have tried reinstalling MODX to no…
MeltingDog
  • 14,310
  • 43
  • 165
  • 295
1
vote
2 answers

get document by id in modx

Very simply I want to have multiple content regions on a single page. Note this is my first Modx site. So far I have the home page and created child documents for the sub regions on the home page. All I want is to call them in the template. For…
Fresheyeball
  • 29,567
  • 20
  • 102
  • 164
1
vote
1 answer

Modx: display all pages in one template

i'd like to find a way to call [[*content]] of every page in one template. I mean something still dynamic so that I could add or remove pages and it would appear in the menu without modifying anything.…
Sylvain Le Bihan
  • 163
  • 1
  • 2
  • 13
1
vote
1 answer

Some of my Templates (and other Elements) have disappeared. Where are they?

I recently cleaned up my ModX Elements so that I categorized them. I added several categories and then started moving my Templates and other Elements into them. They aren't showing up in the list anymore and I can't get to them. How can I get them…
Fuzzical Logic
  • 12,947
  • 2
  • 30
  • 58
0
votes
2 answers

How to configure Wayfinder (MODx) for Bootstrap 5 Dropdown-Menu

how do I have to configure the "Wayfinder" in MODx to get a Bootstrap 5 output. specifically for the "Dropdown Submenue".
0
votes
3 answers

Modx *id isnot =`` and isnot=`` not working

Hi can someone help me with the correct code for this statement because it is not working for me. [[*id:isnot=`250` and isnot=`252`:then=`[[$qc-wrap]]`]]
0
votes
1 answer

Problem to input custom HTML with schema and JavaScript to individual page modx

I'm new on ModX. I've created a template variable to input custom HTML into my page. I choose Rich Text as input type for this template variable. On the other hand, my HTML contains some meta tag like tag…
itshimelkazi
  • 71
  • 2
  • 4
0
votes
1 answer

How to fetch articles on custom page in MODX CMS

I am new to the MODX CMS so I don't know more about this CMS. I tried to fetch articles in the custom template please see screenshot 01:- Screenshot 01 This is the shortcode of articles which I am using to fetch the articles on the custom pages…
Bhanu
  • 21
  • 5
0
votes
2 answers

MODX: Is there a way to disable caching for templates completely?

I'm developing a site locally with XAMPP. I am using static files for templates, snippets and chunks. Currently, whenever I update a template file I need to manually clear MODX's cache in the Manager before I see any changes on the front end. This…
MeltingDog
  • 14,310
  • 43
  • 165
  • 295
0
votes
0 answers

HTML in MODX Manager GUI is not reflecting that on static file

I'm messing around with static files for the first time. I want to make all my templates and chunks static .html and .php files. However, there is one issue: the changes I make to my files do not seem to appear within the MODX GUI, and vice…
MeltingDog
  • 14,310
  • 43
  • 165
  • 295
1
2 3 4