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

    first of all this is my first project with MODx and I’d like to thank all for the great documentation / support. So far I could solve most of my problems by reading and "trail an error", but now I could use some help smiley

    I need the NewsListing snippet to show images on the summary page. I tried to add a new placeholder for a TV with an image inside. But I think I messed it up grin


    I created a TV (type image) and tried to set up an new "placeholder" in the NewsListing snippet.
    I added/changed some lines in the snippet.

    [tt]
    /**
    * Snippet Name: NewsListing
    * Short Desc: Displays News Articles and Blog Posts
    * Created By: The MODx Project
    * Version: 6.3.1

    ...

    // ---------------------------------------------------
    // Parameters
    // ---------------------------------------------------

    // added picture placeholder before summary text

    $tpl = isset($tpl) ? $modx->getChunk($tpl):’
    <div class="nl_summaryPost">
    <h3><a href="[~[+id+]~]">[+title+]</a></h3>
    <div>[+picture+]
    [+summary+]</div>
    <p>[+link+]</p>
    <div style="text-align:right;">by <strong>[+author+]</strong> on [+date+]</div>
    </div>
    ’;

    ...

    // ---------------------------------------------------
    // Process information for display
    // ---------------------------------------------------

    ...

    // Post-processing to clean up summaries
    $summary = closeTags($summary);
    $summary = str_replace($commentschunk,’’,$summary);

    // added this line at the end
    $picture = $resource[$x][’picture’];

    ...

    // ---------------------------------------------------
    // Set Placeholders
    // ---------------------------------------------------

    // Set placeholders that can be used in the Chunk

    // Set placeholders for backwards compadibility and custom fields
    $placeholders[’[+title+]’] = $resource[$x][’pagetitle’];
    $placeholders[’[+summary+]’] = $summary;
    $placeholders[’[+link+]’] = $link;
    $placeholders[’[+author+]’] = $author;
    $placeholders[’[+date+]’] = strftime($date, $resource[$x][$datetype]);
    $placeholders[’[+picture+]’] = $picture;

    [/tt]

    But no picture!

    I have only "basic" understanding of PHP. Maybe I’m completely wrong with this huh
    Does anybody can help me with this? Maybe there is already a solution for this, but I couldn’t find one inside the forum, so far.

    Thanks for help!
    Boris
      • 18397
      • 3,250 Posts
      You just need to prefix "picture" with tv in the tpl
        • 3758
        • 17 Posts
        Oh MAN - I guess I need to read more precisely!!

        [tt]
        * Important Notes
        * When in pagination mode (&paginate = 1) always call the snippet uncached in the [!NewsListing!] format
        * Also, in pagination mode, make sure to use the placeholders for navigation!
        * To display tv’s make sure you use the tv prefix!
        * For example, if you have the template variable author you would put [+tvauthor+] in your template.
        [/tt]

        Thanks Mark anyway!
          • 33337
          • 3,975 Posts
          Quote from: bobtk at Jan 29, 2006, 10:37 AM


          Oh MAN - I guess I need to read more precisely!!


          You still guess, but I am sure laugh (j/k)

          Glad you got it working.

          regards,

          zi
            Zaigham R - MODX Professional | Skype | Email | Twitter

            Digging the interwebs for #MODX gems and bringing it to you. modx.link
            • 18397
            • 3,250 Posts
            No problem! Sorry about my brief response (I was typing on my PSP there...)
              • 27500
              • 14 Posts
              Thanks for the help bobtk and Mark! This was the solution for my post at http://modxcms.com/forums/index.php?topic=3246.new. I was originally trying to do this with DropMenu. Another gotcha was versioning of the NewsListing snippet. I just downloaded and installed MODx 0.9.1 which has version 4.4 of the snippet. I downloaded version 6.3.3 from http://modxcms.com/forums/index.php/topic,1235.0.html. Maybe I’m wrong, but it looks like 6.3.3. of the snippet was released before 0.9.1 of MODx?

              Here’s the code I modified, using a TV = thumb (for thumbnail pict).

              line 163:
              // ORIGINAL
              // $tpl = isset($tpl) ? $modx->getChunk($tpl):’
              // <div class="nl_summaryPost">
              // <h3><a href="[~[+id+]~]">[+title+]</a></h3>
              // <div>[+summary+]</div>
              // <div style="text-align:right;">by <strong>[+author+]</strong> on [+date+]</div>
              // </div>

              // CHANGES
              $tpl = isset($tpl) ? $modx->getChunk($tpl):’
              <div class="nl_summaryPost">
              <a href="[~[+id+]~]">[+title+]</a>
              <div>[+summary+]</div>
              <div><img src="[+tvthumb+]"/><div>
              </div>
              ’;

              line 557:
              // CHANGES
              $thumb = $resource[$x][’thumb’];

              line 590:
              // CHANGES
              $placeholders[’[+thumb+]’] = $thumb;



                • 18397
                • 3,250 Posts
                The 6.x series is much newer than the 4.4 series. It just looks that way because of how SMF keeps track of a topics createdon date and not editedon date.
                  • 29655
                  • 16 Posts
                  I’m going to reopen this old topic instead of starting a new one because my question is somewhat related.

                  What I’m wondering about is the step before skiphreak got to - that is setting up the template variable and making a customized input form for [+picture+].

                  I’ve looked through the documentation but couldn’t find a definite answer to how you make a TV customized for the blog form. This is what I thought would work:

                  <label>Picture: [*picture*]</label>


                  And then just creating a picture TV with a text input-type. The problem is that the form doesn’t output the input text form where you can fill in what Picture is supposed to be... Am I supposed to use widgets? I’m fairly new to ModX so please pardon the simplicity of this question and thank you very much in advance for the support.

                  Edit: Is it possible to have custom templates for the actual blog entry as well and not just the summary?
                    • 15472
                    • 14 Posts
                    Bump... Having the same problem. Getting empty image place holders.

                    What I’ve done:
                    - Created Image TV called DittoImage with input type as Image (no other changes made to the default TV settings).
                    - Created a template for summaries created by Ditto. The template calls [+tvDittoImage+].

                    Created several test posts and assigned the TV DittoImage and uploaded an appropriate thumbnail. Saved the entry and all loads except for the image information.

                    Any suggestions? This is a fresh install of ModX and Ditto so everything’s current and up-to-date.
                      • 11975
                      • 2,542 Posts
                      Hi,

                      is the DittoImage tv attached to the template of the document where the list is displayed?
                      If not, you have to set the param &hiddenTVs=`DittoImage ` in your dito call.



                      :-)
                        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l