We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38537
    • 34 Posts
    hey there,

    i use the longtitle for my headlines.
    but my headline have two different colors. the html-code looks so:
    <h2>this is my awesome<br>
    <span>headline</span></h2>


    so i need a new field in my document-overview (where the longtitle, description,... is.)

    i don't wanna do this with a new tv in the template variable section. cause that is'n easy for a cutsomer to understand.

    hope for some answers.
    xoxo
      • 33968
      • 863 Posts
      You mean you want another field for the coloured section of your headline?

      Is there any rule for which word will be coloured? For example if it is always the last word (or 2 or 3...), you could write an output filter that wraps the last word in <span> tags automatically...
        • 28042 ☆ A M B ☆
        • 24,524 Posts
          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
          • 38537
          • 34 Posts
          @Lucas
          That is exactly, what I need.
          I cant use the output-filter, 'cause there is no rule for which word or words will be coloured.
            • 38537
            • 34 Posts
            @sottwell
            Is there no other way to do that? A little bit simple perhaps?!
            I can't programming a own plugin for that... :s
              • 33968
              • 863 Posts
              I think a nice way to do it would be to just use the longtitle field, but have the user wrap the coloured part in asterisks (*). Then an output modifier would replace them with <span> tags when inserting into your page.

              Create a snippet called spanwrap or something that makes more sense with the following (not tested):
              <?php
              return preg_replace('/*(.*?)*/', '<span>\\1</span>', $input, 1);
              

              Then in your template add the modifier to the longtitle tag:
              <h2>[[*longtitle:spanwrap]]</h2>
              

              And get your users to enter the longtitle text like this:
              Longtitle:    This is my awesome *headline*