We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6726
    • 7,075 Posts
    I’ve been trying to get my head around this great snippet, not for blogging purpose : for those who have come upon my other post, I have been wondering how to use TVs or add custom variables to this snippet.

    Not successful yet, so I got my head in it and found out the &tpl parameter. The documentation says : &tpl - name of the chunk to use for the summary view template. Well, great, let’s do that then I thought I could at last use TVs along with the NewsListing variables in the summary view.

    I have a chunk containing the following :

    <div class="summaryPost">
            <h3>[+title+]</h3>
            <div class="float_right">[*picture*]</div>
            <div>[+summary+]</div>
            <div>[*location*] - [*price*]</div>
            <span class="lien">[+link+]</span>        
    </div>  
    


    And my document contains
    [[NewsListing? &tpl=`fiche` &summarize=`15` &truncText=`Voir le détail de la fiche` &emptytext=`Désolé, nous n’avons aucune fiche correpondant à votre demande pour le moment`]]

    But I get a parsing error :

    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « PHP Parse Error »
     
    PHP error debug
      Error: 	strtotime() [function.strtotime]: Called with an empty time parameter.	 
      Error type/ Nr.: 	Warning - 2	 
      File: 	C:\Program Files\xampp\htdocs\fuchslock\manager\includes\tmplvars.format.inc.php	 
      Line: 	67	 
      Line 67 source: 	$timestamp = strtotime($value); 	 
     
    Parser timing
      MySQL: 	0.0376 s s	(5 Requests)
      PHP: 	0.4337 s s	 
      Total: 	0.4713 s s


    I think I didn’t quite understand something there...
      .: COO - Commerce Guys - Community Driven Innovation :.


      MODx est l&#39;outil id
      • 25663 MODX Staff
      • 12,272 Posts
      It might be that there are fewer docs than you’re trying to summarize... I recall something faintly about that...

      Try:
      [[NewsListing? &tpl=`fiche` &summarize=`1` &truncText=`Voir le détail de la fiche` &emptytext=`Désolé, nous n’avons aucune fiche correpondant à votre demande pour le moment`]]
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 18397
        • 3,250 Posts
        David,

        As I said in the other post, there is no current option in NewsListing to let you use TV’s, or filter by TV’s.

        The TPL is used for formatting only.
          • 6726
          • 7,075 Posts
          Thanks Ryan, Thanks Mark !

          I did not mean to cross-post but I was trying to understand how I could use a chunk as a template for displaying summary information. I thought doing it that way would maybe allow for TV use...

          If I get it correctly using a chunk as tpl makes it unnecessary to edit the snippet code to format the summary.

          The Snippet tests if there is any chunk set up as tpl

          ($tpl = isset($tpl) ? $modx->getChunk($tpl):')


          then just after that in the code you have the default template for summary, used if there is no chunk defined as tpl :

             <div class="summaryPost">
                  <h3>[+title+]</h3>
                  <div>[+summary+]</div>
                  <p>    [+link+]</p>
                  <div style="text-align:right;">by <strong>[+author+]</strong> on [+date+]</div>
              </div>
          


          Do I get it now ?
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l&#39;outil id
            • 25663 MODX Staff
            • 12,272 Posts
            That’s it. The demo content does this for one of the news-related snippets btw. I think the publisher, in fact.
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 6726
              • 7,075 Posts
              I like to understand smiley

              Didn’t use NewsPublisher yet, will do laugh
                .: COO - Commerce Guys - Community Driven Innovation :.


                MODx est l&#39;outil id
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                That’s next in the Blog Tutorial.
                  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
                  • 6726
                  • 7,075 Posts
                  Cool Susan, I can’t wait to read it smiley

                  In the meantime, I have started studying php, at last ! Already ingested 100 pages from the PHP5 book I bought a few months ago... starting to get the basics...
                    .: COO - Commerce Guys - Community Driven Innovation :.


                    MODx est l&#39;outil id
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    It’s up now, thanks to Zi for fixing the images for it!
                      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
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Quote from: davidm at Nov 24, 2005, 11:21 AM

                      In the meantime, I have started studying php, at last ! Already ingested 100 pages from the PHP5 book I bought a few months ago... starting to get the basics...

                      I haven’t bought a book for years, there are so many excellent articles available on the Internet, and I bought a neat little Xerox b/w laser printer. Four years and thousands of pages of documentation and tutorials later, I’m still printing on the same toner! But the code put out by Raymond and Ryan is excellent! I’ve learned as much in the last few months from their stuff as I have in the last couple of years!
                        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