Is there a way to make a tv control the title of a resource?

I have a tv called Reviewer Name. I would like the resource title to match the value of the tv. Is this possible?

Why use a TV at all? If the pagetitle should have the same value as the TV, why not getting rid of the TV?


If you really need the TV, then you could (maybe) achieve this, by writing a plugin that runs on the event OnBeforeDocFormSave (or maybe OnDocFormSave) and sets the pagetitle value.

The main reason is for when we turn the webpage over to the client we think it will be easier for them to use if Reviewer Name is explicitly defined in TVs.

Thank you for providing these links.

One problem with this approach is, that the pagetitle is also used to automatically generate the alias (if the system setting automatic_alias is set to “Yes”).

So the value of the pagetitle has to be set, before the resource is saved.


Also, if you are using MODX 3 and the template-picker window is used when creating a new resource (system setting enable_template_picker_in_tree), you have to fill out the pagetitle of the resource, before you can enter any TV values.

Would using OnBeforDocFormSave allow me to set the resource name before the automatic_alias is evaluated?

Would it be possible to set the tv’s value on initial save or if the tv = null then it should be populated with the resource title?

I believe so, but I haven’t tested it.
The request parameter name for a TV is “tv” plus the TV-ID (e.g. “tv1”).


Sure, you can do that in the OnDocFormSave event.

It’s just getting overly complicated now, that’s why I personally would avoid the extra TV.

Is there any other content in this resource other than the Review Body text? If this is just a list of reviews (one per resource), I’d not use TVs at all. Assuming the reviews use their own template, use Form Customization to change the label on the Page Title field to “Reviewer Name” and change the label for Content to “Review”. Put the Location field on top of that. You can also remove any fields you don’t need for reviews (like IntroText, Description, LongTitle, MenuTitle, etc.). In 3.0, there is a bug preventing renaming of the Content field label, but at some point that bug will be fixed. I manually applied the fix from the Github pull request to make it work:

If there IS other content already in the Content field, just use Form Customization to put the Review Body field underneath the Content field:

Either of these will make it easier for your client, since they wouldn’t have to click the Template Variables tab to enter content.

2 Likes