My try at explaining:
- placeholder
- Template Variable (which is a placeholder)
- chunk
- snippet
- and how they work together?
Placeholder
Placeholders are like dynamic pieces of a website. In Joomla, you may have a module that says "Hello username" where username is the logged in persons username. But in Joomla, you have no control of the output without hacking the actual php. In MODx, you can create your html output however you want and use a placeholder as the ’puzzle-piece’. 2 Examples:
//Example 1
<h1>Hello [+username+]</h1>
//Example 2
<div class="welcome-user">Hello <span>[+username+]</div>
The power of the above code is you did not have to ’hack’ or modify the php that creates the placeholder. Most website clients want a unique and customized look to their site. Placeholders allow developers to create dynamic output (username) but allow you the designer to control the html and how it looks. Placeholders are usually put in ’chunks’ (explained later). Most snippets document the placeholders available. When you first use a snippet, you may want to use all of the available placeholders to see what is available to you.
Template Variable (ie TV)
TV’s are two things. (1) They are placeholders. (2) They are extra input options. The problems with CMS’ like Joomla is sometimes your user needs more than 1 content field. What if the site owner needs 3 fields- Author, Web Link to Amazon, and email. In Joomla, the user could put that information in the 1 content box and format it the way they want. Or you could teach the user how to format the information the way they want (it’s a hassle to show most people how to create a table or nested div with TinyMCE). But the power of MODx is you can create additional TV’s (or input boxes). How to style the output (examples below):
//Example 1
<h1>[*author*]</h1>
<p>Web Site: [*website*]</p>
<p>Email: [*email*]</p>
//Example 2
<table class="books">
<tr>
<th>Author</th>
<th>Website</th>
<th>Email</th>
</tr>
<tr>
<td class="author">[*author*]</td>
<td class="website">[*website*]</td>
<td class="email">[*email*]</td>
</tr>
</table>
The power in the above code is the user does not have to know any of the html code. They just fill in their separate input text boxes, and the TVs are placed in their placeholders. TV’s offer a lot of extra options, but this is the basics.
Chunk
A chunk is html that will be shown in a document. There are many reasons to place the html output somewhere other than the main content box. 1 reason would be html that will be used in multiple pages (like a menu, header, or footer). Another reason would be to use placeholders. If we use the above example, you could put that html in a chunk so the user could not edit it and mess up the table. Let’s create a new chunk called ’Books’ and call it to be shown in the main content.
<!-- New chunk called Books -->
<table class="books">
<tr>
<th>Author</th>
<th>Website</th>
<th>Email</th>
</tr>
<tr>
<td class="author">[*author*]</td>
<td class="website">[*website*]</td>
<td class="email">[*email*]</td>
</tr>
</table>
<!-- in the main content of MODx, show the above chunk 'Books' -->
{{Books}}
Now the user only sees the chunk {{Books}}, but the html output is the table we created that is populated with the TV placeholders. And if the user wants to add an image or more description above or below the ’Books’ chunk, they can.
Snippet
A snippet is a piece of php code that creates the dynamic part of a placeholder. If we use the first example above, the snippet would be responsible for getting the username of the user and sending that to the placeholder [+username+]. In MODx, snippets are php functions and classes. They are what make MODx dynamic.
I dont know what else to put here, because snippets can be anything you can think of. They are like modules or components in Joomla.
How it all works together
(1) Snippets do the php magic- calculations, query the database, massage data. They send the final output to placeholders.
(2) Chunks hold html output. You can call your placeholders here.
(3) Placeholders are where the output will be shown
(4) TV’s are simple placeholders. They also provide simple input forms (in the manager) when you just need more input boxes.
Rough draft one - chunk
PS - will anyone actually read this if it’s posted to the wiki, etc?