We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30939
    • 27 Posts
    Hello everyone,

    I have a folder "News" with lots of news:

    /NewsSummary.html
    /News/news1.html
    /News/news2.html
    /News/news3.html
    ...

    I display the news with the NewsSummary.html. In this file is a call to Ditto. It works fine - ok.

    Now, I want to display only the news from the last 365 days. OK, this I can make with the
    parameter &where of Ditto - I thought wink

    But here I have a problem:
    My idea is:
    &where=`1=1 AND ((TO_DAYS(NOW()) - TO_DAYS(sc.editedon)) < 365)`

    The part "1=1" I have to set, because in front of the where-clause Ditto write
    automatically the words "sc.".

    The complete SQL-Statement is:

    SQL: SELECT DISTINCT sc.id,sc.published FROM `modx`.modx_site_content sc LEFT JOIN `modx`.modx_document_groups dg on dg.document = sc.id WHERE (sc.id IN (22,23,24,25,26,32,33) AND sc.published=1 AND sc.deleted=0 AND sc.1=1 AND sc.((TO_DAYS(NOW()) - TO_DAYS(sc.editedon)) < 2)) AND (sc.privateweb=0) GROUP BY sc.id ORDER BY sc.createdon DESC

    Hmm, Ditto doesn’t consider this statement and shows all news.

    Ok, I make the following to test the general function of the &where-Parameter:
    &where=`alias=’News1’
    But here I get the error:

    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « Execution of a query to the database failed - Unknown column ’sc.alia’ in ’where clause’ »
    SQL: SELECT DISTINCT sc.id,sc.published FROM `modx`.modx_site_content sc LEFT JOIN `modx`.modx_document_groups dg on dg.document = sc.id WHERE (sc.id IN (22,23,24,25,26,32,33) AND sc.published=1 AND sc.deleted=0 AND sc.alia) AND (sc.privateweb=0) GROUP BY sc.id ORDER BY sc.createdon DESC

    The &where-Parameter will cut to "AND sc.alia".
    Does anyone know, why I’m wrong?
      • 11975
      • 2,542 Posts
      Hi,

      this a known issue.
      The snippet parameters cannot contain some characters.
      Unfortunately, the equal sign is one of them.

      :-)
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 30939
        • 27 Posts
        OK, I solved my problem with the following clause:
        &where=`editedon > (UNIX_TIMESTAMP() - 60*60*24*365)`

        and for the issue "no equal sign" I propose the following:
        &where=`pagetitle LIKE ’News1’`

        wink