We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27330
    • 884 Posts
    Hi all,
    does anyone knows of a way I can set the page [+introtext+] to be the first <p></p> of same page content?

      • 27708 MODX Staff
      • 2,502 Posts
      It seems possible using regex and the documentObject[’content’] but it would likely take all day for me a PHP grasshopper to wade through.

      Sorry.
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
        • 7231
        • 4,205 Posts
        Something similar was discussed in a recent post. You want this in intro text to be able to display the summary in Ditto or some other snippet? If so look at this post and see how to do it on the fly with PHx:
        http://modxcms.com/forums/index.php/topic,22854.15.html

        Also you could turn that phx modifier into a snippet and just drop that into the intro text field, or maybe even turn it into a plugin and have it run onDocumentSave. That sould like a good idea. Wonder if this already exists? Seems that I have seen something like this in the Repository.
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don&#39;t know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 27330
          • 884 Posts
          thx for the replies.

          are you talking about this from the repo?
          http://modxcms.com/DynamicDescription-1544.html

          edit:
          just read the post you linked up there. just what I needed. phx defiently the easiest way to go. still would be nice to have it set on all new docs like that instaed of adding the introtext manually.

            • 7231
            • 4,205 Posts
            are you talking about this from the repo?
            No, this is the same as the PHx described. It would work as well for dynamic on the fly descriptions (as the name says). The plugin would actually record the data, not sure if that would really an advantage of any sorts (load wise) but it sounds good grin
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Hm. That does indeed sound good. Would obviate the necessity of training end users to copy the first x amount of text into the Summary field for Ditto’s use.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 27330
                • 884 Posts
                make sense too isn’t it?
                I mean 99% of the time your introtext *should* be your first paragraph if you write properly (I think), I do needed it for Ditto call where I show some products description polled from the introtext. using the [+content+] with phx:word_limit from the wiki can save me the chopped words but still I won’t have all the first paragraph. tuatara posted here something to avoide this and to kepp the whole first <p>. I’ll play with all these and see if I can make it work somehow.

                how I wish I knew some php smiley
                  • 27708 MODX Staff
                  • 2,502 Posts
                  The trick here would be to get all the text up to the first </p> occurance. I am not sure how to do that with PHx but it is not hard to do with a snippet.
                    Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
                    • 27330
                    • 884 Posts
                    Another issue I can think of if using this is a plugin with OnDocomentSave is with pages like ’login’ and ’search’ where the first <p> can be a snippet and I’ll end up with the snippet call in my introtext.
                    so maybe not such a great idea after all smiley
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      The plugin could specifically exclude a list of page IDs, or perhaps even better, since this really would only be useful for blog or news pages, have it work with pages whose parent is in a list of ids.
                      $parents = array(56, 74);
                      if(in_array($_POST['parent'], $parents) {
                          // do stuff ...
                      }
                      
                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org