Bob, I want the pagetitle to be altered based on the values that the user entered in the TV's.
I was thinking that it must be done before saving the resource, like you suggest.
But I've never written any plugin because I'm fairly new to modx revolution, so this is a difficulty for me.
Can you please show me an example of such a plugin ?
I'm guessing somewhat, but it should look pretty much like this (connected to OnDocFormSave). This assumes that the IDs of your two TVs are 12 and 22, so change those numbers to the actual TV IDs. This would be the entire plugin code:
$value1 = $resource->getTVValue(12);
$value2 = $resource->getTVValue(22);
$resource->set('pagetitle', $value1 . $value2);
There are some ways to speed this up, but since it won't affect page-load speeds, they're probably not worth the trouble.
Quote from: bendy4 at Jul 10, 2015, 07:07 AM
I want the pagetitle to be altered based on the values that the user entered in the TV's.
@BobRay, in his case, do the TVs have values already in the MODx DB, or are they going to have their value for the first time when he submits the form?
Or upon saving, are the TVs registered before the pagetitle? - I am not even sure I am making sense to myself.
I am in wonder how MODx works here.
: Complete back/frontend content solution.
Harden your MODX
site by passwording
your three main folders: core, manager, connectors
and renaming your assets
(thank me later!)
5 ways to sniff / hack
your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
It's a good question. That's why I used OnDocFormSave rather then OnBeforeDocFormSave. They should be there by the time that event fires (hopefully). OnBeforeDocFormSave might work, but I think probably not.
NewsPublisher sends the TV values to the resource/create processor, but unfortunately, AFAIK, they're not in the array sent to the System Events, so you have to get them from the DB.
Thanks guys, got it working !
Great to get this help as a novice here.