We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40088
    • 708 Posts
    I need to change the Description field from text to textarea but I don't see a tpl for it. Where should I be looking?

    This question has been answered by sottwell. See the first response.

      Todd
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      On examining the code, it looks like there's no way to do that. The only text fields that are handled differently are the introtext and content fields. The rest just get text input fields.
        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
        • 40088
        • 708 Posts
        Well ...

        BobRay? Can you add a tpl for this or somehow make it possible to customize?
          Todd
        • discuss.answer
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          See line 844 of core/components/newspublisher/model/newspublisher/newspublisher.class.php. That's where the fields displays are set up. There are special cases for "content" and "introtext" fields. The rest of the text fields get displayed using the npTextTpl chunk.

          You would need to modify that function to add a switch block for the "description" field.

          Around line 912, add this block of code - of course you would need to also modify the CSS to style it like the other textarea fields:

                      case 'description':
                          $rows =  ! empty($this->props['descriptionrows'])
                              ? $this->props['descriptionrows']
                              : '10';
                          $cols =  ! empty($this->props['descriptioncols'])
                              ? $this->props['descriptioncols']
                              : '60';
                          $inner .= $this->_displayTextarea($field,
                              $this->props['rtdescription'],
                              'np-description', $rows, $cols);
                          break; 
          
            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
            • 3749
            • 24,544 Posts
            The description field is varchar(255), so be careful what you put in it -- anything longer than 255 characters will be truncated.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 40088
              • 708 Posts
              I saw that, which is why I was hoping there was a specific Description tpl that I could duplicate and customize.
                Todd
                • 3749
                • 24,544 Posts
                Susan's suggestion should work, but it won't change the limit of 255 characters, which is set in the MODX database. Using a different Tpl chunk won't change it either.
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 40088
                  • 708 Posts
                  Gotcha. Thank you both.

                  If I do try Susan's suggestion won't it be overwritten if/when NP gets updated?

                  Also, are the label names editable? I would like to remove the colon (:). [ed. note: todd.b last edited this post 11 years, 9 months ago.]
                    Todd
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    Yes, of course any changes to the code would be lost in an update. That's why changing core code of anything is never a good idea. That code was primarily an exercise, a bit of idle fiddling just to see if it would work.
                      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
                      • 3749
                      • 24,544 Posts
                      I think the colons are in the Tpl chunks, so you can duplicate them (the Tpl chunks), specify your duplicate's names in the properties, and edit out the colons. That way they won't be overwritten on upgrade.

                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting