We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18397
    • 3,250 Posts
    @Fellini 8.5 : I’m haven’t tested @bindings with NewsListing as of yet, so that may be a bug. Can you try changing the @INHERIT to something else for a test? Thanks!

    @davidm : Thanks for replying regarding the <?. Your correct, I do use Dreamweaver 8 or Programmer’s Notepad which requires <? to use Syntax Highlighting.

    @xeres : I already gave an example a short while ago in this thread. I hope to do more in the near future on the main MODx site...

      • 33453
      • 141 Posts
      I have spent HOURS trying to solve a rather trivial problem. Eventually I came up with a solution so simple that I wish I had thought of it at 10am this morning >:(!

      I will post it here in case it is useful to anyone else.

      The problem:
      In the sidebar of any news item page, I want to have a list linking to other news items. Obviously I do not want to show the item that is currently being viewed in that list, so I need to set up a filter to exclude it.

      How NOT to do it:
      By trying to find a ’clever’ filter condition using PHP’s ’variable variables’. They seem a bit flaky in anything but the simplest form.

      How to do it in under 5 minutes:
      In the NewsListing snippet, replace
      $filterName= $filterArray[1];
      

      with
      $filterName= ($filterArray[1]=='[+self+]') ? $modx->documentObject['id'] : $filterArray[1];
      

      and in your call to the snippet set a filter, so:
      filter=`id,[+self+],2`
      

      I really did not want to modify the snippet if possible, but it does the trick and I can now get on with some ’proper’ work. However, if anyone can think of a more elegant solution please let me know.

        • 9583
        • 25 Posts
        Ah, I think I found it.

        Some of my subfolders have Weblink objects instead of just documents.  Pointing to folders with just documents (even if it’s a multilevel tree) will work (except for the @INHERIT -- that just returns a blank).

        So I take a closer look at those Weblink documents, and...  No TVs attached!  Crap!  Well, that would explain why it wouldn’t find anything.

        So it appears TVs don’t work with Weblinks...  I must have missed that somewhere.  Or is that a bug, not a "feature"?  :)


          • 18397
          • 3,250 Posts
          @zenmaster : There is a "more elegant solution" as you put it. All you need to do is called the snippet like so:

          [!NewsListing? ... &filter=`id,[*id*],2`!]

          That will work.

          @Fellini 8.5 : I’m looking into it right now.
            • 33453
            • 141 Posts
            Quote from: Mark at Jan 11, 2006, 07:06 PM

            [!NewsListing? ... &filter=`id,[*id*],2`!]

            Thanks Mark,

            It is, indeed, more elegant and, after some initial teething problems (I forgot to change the [[...]] to [!...!] embarrassed), it works like a charm. Wish I’d asked you at 9am yesterday grin.
              • 32847
              • 171 Posts
              I unterstood filter grin, I spent some time on it!
              It’s a great feature, I made a filter for some selected news with check.
              Thanks Mark.
              I had the same problem than Fellini and I was a bit desapointed at the begining cause I didn’t understand why I had a sql error.
              I deleted all my links but I hope there will be a correction to add link with tv.
              Modx is really great
                • 6726
                • 7,075 Posts
                xeres, would you care to detail your example as a kind of tutorial when you got the time ?

                I am still struggling with this... thanks !
                  .: COO - Commerce Guys - Community Driven Innovation :.


                  MODx est l&#39;outil id
                  • 32847
                  • 171 Posts
                  Sure I can do it David

                  It’s not a wonderfull thing so don’t blame me. wink
                  I have all my news in a part of my template and I would like an area with some selected news so I create a tv named BestNews with check box as entry and "selection" as value or wathever you want and 0 as default value.
                  then I add
                  &filter=`tvBestNews,selection,1` &hiddentv=BestNews


                  to Newslisting option.
                  Now, when I edit my news, I have a check bok to add some of them in my best news area with a specific chunk
                  You can also highlight some articles from your site
                  It’s so simple and powerfull.
                  Me too, I struggled a lot but I re-read carrefully indication from Mark.
                  I hope it helps.
                    • 6726
                    • 7,075 Posts
                    Yes it does, I had not understood how useful hiddentv could be in the use of filters, now I do and can’t wait to try it !

                    Once I am done, I’ll take some time to give an example use too smiley
                    Thanks !
                      .: COO - Commerce Guys - Community Driven Innovation :.


                      MODx est l&#39;outil id
                      • 32847
                      • 171 Posts
                      Once I am done, I’ll take some time to give an example use too Smiley
                      We need to update the documentation with those exemple about filtering.
                      @Fellini 8.5 : I’m looking into it right now.
                      Mark, what about the problem with weblinks cause I had to delete them in my folder but I need them wink
                      Thanks