First, it seems to be great work. The backend design and usability seems to be alright. The only thing i would change is the template engine. Why does it use these cryptic symbols for placeholders? Even more problematic: these symbols are familiar to php developers, but in a complete different meaning. If I got it right, you could find such code within a template:
<?php ++$index ?>
This is very confusing.
I would rather use something like [[system:placeholder]], [[snippet:mysnippet]] and so on. This would be much more readable.
Mark Hamstra - 2011-09-23 15:13:54 - In reply to message 1 from Klaus Potzesny
The tag syntax for within templates are: http://rtfm.modx.com/display/revolution20/Tag+Syntax
In PHP you would use $modx->getChunk() and $modx->runSnippet() as well as other methods depending on what you're trying to achieve.
The symbols don't seem cryptic to me - every symbol represents a certain type of element you're referencing. But it's for sure shorter and I would say easier to maintain when you have [[*pagetitle]] instead of [[resourcefield:pagetitle]].
Jennifer Simonds - 2011-09-23 19:06:03 - In reply to message 1 from Klaus Potzesny
I agree that using symbols to namespace the tags looks confusing. I'd prefer something like "res:xxx" or "snip:xxx". When they inevitably decide to add a new type of tag variable, they'll have to choose yet another symbol to add to the menagerie.
Anyway I assume it's a small learning curve to get used to that notation. (I think now I know how other coders must feel when they see my code, which is filled with Hungarian Notation! :) )
Mark Hamstra - 2011-09-23 19:28:37 - In reply to message 3 from Jennifer Simonds
Yeah, but even if it would be "snip" or "snippet" that's arbitrary language you need to learn... I guess that's just part of the learning curve.
Another issue with using "snippet:name" with the current code is that the : symbol is a separator used in output modifiers. While that may be a bit going in too deep for an introduction article, you can use that to parse the result of a snippet/placeholder further and you can chain that all you want.
For example, this is a common use of selecting the pagetitle if there is no longtitle set using output modifiers:
"default" (or "empty) is being parsed when the value of [[*longtitle]] is empty. If it is, it takes the value passed to the output modifier (between ``), so in this case [[*pagetitle]].
That parsing is fully recursive too (inside-out), so you could go beyond this simple example. You can tell it to not cache items with an exclamation mark: [[!*longtitle]]
But yeah. It uses symbols and in that it's part of the learning curve ^^
Klaus Potzesny - 2011-09-24 00:33:05 - In reply to message 1 from Klaus Potzesny
IMHO, readability is more important then shortness. There are similar shortcut symbols in asp.net. Although I worked with them for years, I forget their meaning after a single week of holiday. Please believe me, it's what most mediocre developer brains work like;) You could also use the suggested long (or mid size) symbols as an alternative syntax.
Bob Ray - 2011-09-24 00:34:26 - In reply to message 1 from Klaus Potzesny
It's really pretty simple once you get used to it. In Revolution, *all* tags start with [[ and end with ]].
What you're suggesting ([[snippet:mysnippet]]) is essentially already there except that instead of "snippet:" it's a token, i.e., [[token objectname]].
(no token) -- snippet tag [[snippetname]]
$ chunk tag -- [[$chunkname]]
+ placeholder tag -- [[+placeholdername]]
++ setting tag -- [[++settingName]] (system, user, or context setting)
* content/TV tag -- [[*contentfield/TVname]]
~ link tag -- [[~resourceID]]
language tag % -- [[%languagestringkey]]
The objects are cached by default and putting a ! ahead of the token makes any of them them uncached:
<?php ++$index ?> could never appear in a template because no PHP code is allowed in templates.