We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30765
    • 66 Posts
    Quote from: dev_cw at Feb 16, 2008, 10:47 AM

    Now that IS nifty.

    It is. But

    [+content:notags:limit=`100`+]


    would be better.

    Cheers
    Matt

      • 12027
      • 63 Posts
      Thanks for replying guys smiley

      But I still see no way of making an interesting blog page, i.e., either

      1) Include first <p> with any images, or
      2) Make n "subject" image TVs, selectable by the webuser (article writer) from where he writes the article (i.e., checkbox or something)

      Help! smiley
        • 30765
        • 66 Posts
        Ah, I stepped into this thread a bit late. Hope this will help.

        Quote from: Henrik at Feb 17, 2008, 08:51 AM

        1) Include first <p> with any images, or

        Obviously, if you’re comfortable using HTML, you can put styled text in the introtext field. I think also I have seen a note on the forums somewhere about a small tweak that can be made to turn the introtext field into a rich text field. Finally, to do as you want, you could easily use PHx and make a custom modifier. If you haven’t installed PHx yet you should definitely do so (Ditto includes its own internal version of PHx; not sure if it supports custom modifiers).

        More here: http://wiki.modxcms.com/index.php/PHx

        Create a custom modifier as a snippet called something like phx:firstpar. Here’s an untested bit of code that should get you most of the way:

        <?php
        // Returns text up to and including a specific closing tag
        // Pass tag without angle brackets. Tag defaults to 'p'
        
        if (!$options) $options = 'p';
        $options = '</' . $options . '>';
        
        return substr($output, 0, strpos($output, $options) + strlen($options));
        ?>


        Then your chunk could print the content up to the end of the first par with the tag
        [+content:firstpar+]


        Quote from: Henrik at Feb 17, 2008, 08:51 AM

        2) Make n "subject" image TVs, selectable by the webuser (article writer) from where he writes the article (i.e., checkbox or something)

        There are several ways to do this. Check out the instructions on creating a DropDown List Menu or Listbox template variable about halfway down this page:

        http://modxcms.com/creating-a-template-variable.html

        Because you’re talking about having a set number of categories, you could just hard-code the image name in the TV input options:

        Default==generic.gif||Cats==lolcats.jpg||Fads==facebook.jpg||Computers==happymac.gif


        Hope this doesn’t look too daunting, but once you’ve done it a few times it’ll be second nature.
          • 12027
          • 63 Posts
          PHx looks powerful, will give it a go. The main thing is that article writers can use the normal editor to select/insert a picture, whether it be by ticking a Category checkbox or clicking the image icon in TinyMCE. Thanks a bunch grin
            • 12027
            • 63 Posts
            Installed PHx and the snippet, called it in my blog template-chunk. No output. Even <?php return ’hello’;?> gives no output. I’m not familiar enough with how the elements work together to figure out what to check.
              • 30765
              • 66 Posts
              Quote from: Henrik at Feb 17, 2008, 06:44 PM

              Installed PHx and the snippet, called it in my blog template-chunk. No output. Even <?php return ’hello’;?> gives no output. I’m not familiar enough with how the elements work together to figure out what to check.

              Happy to help, but we’ll need some info. Please post the contents of your chunk and the name you used when saving the snippet.
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                For one thing, <?php...?> won’t work in MODx. That’s what snippets are for.
                  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
                  • 12027
                  • 63 Posts
                  I meant replacing the snippet content with that code.

                  More info? Well, I got the latest PHx, followed install.txt, added the snippet. It was uploaded to the /assets/plugins/phx folder, the plugin was named "PHx" -- I followed tuatara’s instructions, i.e. snippet is called ’firstpar’.

                  Here are the contents of the nl_blog chunk relevant to the problem:

                  <p>[+introtext+]</p>
                  [+content:firstpar+]


                  Replacing that second line with [+content+] outputs the main article texts nicely.

                  URL to non-working blog (content div made 200px high to test scrollbars at the moment): http://scoopex1988.org/photon.html
                    • 7231
                    • 4,205 Posts
                    I think that you need to prefix the snippet name with "phx:"

                    From the docs:
                    1. Login to the MODx manager
                    2. Go to Resources -> Manage Resources -> Snippets
                    3. Click "new snippet"
                    4. Prefix the snippet name with "phx:"

                    http://wiki.modxcms.com/index.php/PHx/CustomModifiers
                      [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]
                      • 12027
                      • 63 Posts
                      That’s it, ofc. I just didn’t "get" how the chunk code would automatically find the phx:snippetname just by inserting :snippetname.

                      Cake for everyone! smiley