Quote from: Bruno17 at Apr 18, 2011, 10:58 AM
you can try to use $modx->setPlaceholder('mypagetitle',$mypagetitle); in your snippet and place this placeholder with on place of
Many thanks, that’s exactly what I was after! It has worked perfectly. I wasn’t sure whether you could use a placeholder that you weren’t actually defining until within a snippet call later in the page, but it looks as though MODx must parse through the page more than once in order to Do What I Mean..?
if this will not work in evo, and you don’t want to get your data-object twice, you can get your data-object in an extra snippet in the head and store your data-object for later use or store them also in placeholders to put them out where you need them.
Ah, I think I’m starting to get a twinkling of enlightenment.. Up until now, I’ve been writing snippets essentially as ’thinking teletypes’: just appending all output to a string variable and then printing the eventual result (to create the main ’content’ part of a page), varying according to the data processing within the snippet; but I’m starting to get the idea that if I were to make more sensible use of placeholders this might help me write more flexible code.. (Right now my data output is rather intertwined with the layout/presentation code, which I gather is somewhat non-recommended.)
What do you mean by "stor[ing] the data-object for later use", by the way? Using placeholders I think I’m now starting to comprehend, but I’m afraid I’ve not yet really delved into those aspects of how MODx works technically.
I think its also possible to use snippet-tags in the pagetitle-input-field if this helps
I didn’t realise that, that’s very useful to know. However, in this case, I was hoping to avoid having to have more than one snippet call as this would mean having to query the database more than once for my data, which seemed unnecessary (and possibly also would introduce a risk of inconsistency if the data were changed in the short interval between the two snippets being called).