We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43785
    • 3 Posts
    I am using MODX Evolution. I need to create custom pagetitle value which will be automatically built from unique tv values of current document i.e.:
    [*proposal-current-number*][*producer*][*product-model*]
    Each tv is a simple string.

    Could you help me to prepare any smart, simple plugin to change this system field value during editing/creation of current document (onDocFormSave event)?
    Maybe my question is trivial or was discussed here earlier, but I can't find it. Additionally, I'm not a php programmer...
    Thanks in advance
    Tad
      • 13226
      • 953 Posts
      You are not obliged to use the "pagetitle" in your template

      If you have a bespoke template for these documents, simply add the TV's to the template

      Example:
      <!DOCTYPE HTML>
      <html>
      <head>
      <title>[*proposal-current-number*][*producer*][*product-model*]</title>
      <meta charset="utf-8">
      </head>
      <body>
      [*content*]
      </body>
      </html>

      You could of course also / or use something like "IF" - using the "IF" snippet you can use one template for multiple pages but call-in the appropriate title for the individual pages.

      Example:
      <!DOCTYPE HTML>
      <html>
      <head>
      <title>[[if? &is=`[*parent*]:in:10` &then=`[*proposal-current-number*][*producer*][*product-model*]` &else=`[*pagetitle*] | [(site_name)]`]]</title>
      <meta charset="utf-8">
      </head>
      <body>
      [*content*]
      </body>
      </html>
        • 43785
        • 3 Posts
        Thank you for your advice.
        In general you're right - it's good idea, but I am going to do a step ahead - I need to build coherent system where all important data of each document will be included in the system fields. And additionally, I would like to create unique alias based on the pagetitle value for each this way created document - simply for Google indexing, and as I checked TransAlias is a good ready-to-use solution.

        There is a part of my project - section with second-hand car dealer business. In this section, each current offer (document) will be created few times daily by customer itself. It will contain a few images, table with technical data, etc. In such case back-end operations must be simplest as much as possible because will made by unexperienced user.
        That's why I need to automate document creation process - using dedicated template, a few tv's and scripts needed for describe current proposal. It's something like standard e-shop solution but limited to presentation layer only. No one shopping cart, storage or payment modules.
        But problem is that all MODX e-shop modules are too much sophisticated for my needs.
        So, I still prefer "plugin" solution as most elegant and effective.

        I found Bob Ray's article with relatively simple plugin adaptable for my needs:

        /* Do nothing if it's not a new resource */
        if ($mode !== modSystemEvent::MODE_NEW) {
        return '';
        }

        $introText = $resource->get('introtext');
        $resource->set('description', $introText);
        $resource->save();
        return '';

        but syntax of the code is from MODX Revo...


        [ed. note: tadeusz last edited this post 8 years, 5 months ago.]
          • 13226
          • 953 Posts
          sorry, am not a PHP'r
            • 43785
            • 3 Posts
            Quote from: iusemodx at Oct 17, 2015, 11:03 PM
            sorry, am not a PHP'r
            Exactly understand it smiley Thank you for support!
            Tad