We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11449
    • 28 Posts
    I would like pagetitle to be generated from two TV's on a document. I have bike-model-name and bike-model-year TVs already in use in the document, I want the pagetitle to be
    "[[*bike-model-name]] [[*bike-model-year]]"
    so that in the manager the document will follow the naming convention in use. I can't figure out how to do this, and having the client type in a name for the page (only used in the manager) as well as the name and year in TVs which is used on the page feels dirty.

    I have read this topic but have had no luck with it:
    https://forums.modx.com/thread/?thread=31326&page=2

    A last resort could be to be able to move [[*pagetitle]] to a different tab using "form customization" but that doesn't seem to be possible now ether.
      • 3186 ☆ A M B ☆
      • 279 Posts
      Can't you create a plugin OnBeforeDocFormSave and then grab the both TV values and then set this combined as pagetitle?

      Don't know if the validation accepts it, but it's worth trying?
      Something like this; (not tested)

      <?php
      if ($modx->context->get('key') != 'mgr') { return ''; }
      
      $eventName = $modx->event->name;
      switch($eventName) {
          case 'OnBeforeDocFormSave':
              $bikeModelName = $resource->getTVValue('bike-model-name');
              $bikeModelYear = $resource->getTVValue('bike-model-year');
              $resource->set('pagetitle', $bikeModelName . ' ' . $bikeModelYear);
              break;
      }
      


      This will keep your pagetitle in sync.
      Maybe even to hide pagetitle field in FC
        MODX Ambassador (NL) & Professional MODX developer
        Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
        MODX e-commerce solution SimpleCart