We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30593
    • 119 Posts
    Hello! Have an idea to make a filter on the date [* myDate *].
    What I do:
    1) my tv with the date [* myDate *]
    Type: date
    The visual component: Unixtime

    2) created the chunk filter {{filter}}

    <form class="filter">
    <ul id="date">
    <li class="c"> <a href="#" id="show_all"> All </ a> </ li>
    <li> <a href="#" name="today" id="today"> Today </ a> </ li>
    <li> <a href="#" name="tomorrow" id="tomorrow"> Tomorrow </ a> </ li>
    </ ul>
    </ form>


    3) created a snippet [ [ filter ] ]

    <?php
    $today=Date('d-m-Y'); // today
    $tomorrow=Date('dm-Y',mktime(0,0,0,date('m'),date('d')+1,date('y'))); // next day
     
    print "
    <form method='get'>
    <input type='submit' name='today' value='today' />
    <input type='submit' name='tomorrow' value='tomorrow' />
    </form>
    ";
     
    if($_GET['submit'] == 'today'){
    // today
    }elseif($_GET['submit'] == 'tomorrow'){
    // tomorrow
    }else{
      print "today or tomorrow"
    }
    ?>


    4) call Ditto:
    [[Ditto? & parents = `416` & orderBy = `myDate ASC` & dateSource = `myDate` & dateFormat = `% A |% d.% m |% H:% M` & tagData = `documentTags` & tpl = `ditto_afisha2` & extenders = `summary` & summarize = `50` & paginate = `0` & paginateAlwaysShowLinks = `a]]


    What did I do wrong?
      • 36404
      • 307 Posts
      hi Trent,

      i'll try to say it nicely smiley but sorry, to answer your question, neraly everything... smiley
      - first, you form in the chunk doesn't send anything, then why is it a form ?
      - second, the way you've written the snippet is, sorry again, but, well, so bad smiley and, once more, you will not retreive the values you're lookig for
      <form method='get'>
      <input type='submit' name='today' value='today' />
      <input type='submit' name='tomorrow' value='tomorrow' />
      </form>

      except from the fact this should not be written this way in a snippet, this form doesn't send submit like you seem to beleive (at the end of the same snippet...) but today or tomorrow as $_GET indexes and values
      this form needs an action (event if by default it will be the page itself
      you should not retreive and deal with the sent values in the same snippet as you return the form (honestly, i wonder why you put the form in the snippet)
      i can't see where the $today and $tomorrow are used
      how does ditto know what var to deal with ?
      and so on

      i think that if you just gave us a little idea of what you want to achieve, without writing it for you, we may at least help you dispatch the things to do in the right parts to use smiley

      sorry again smiley

      have swing
        réfléchir avant d'agir
        • 30593
        • 119 Posts
        virtualbear, I want to do this like this afisha.kz/club

        So that when you click on Today derived bills today
        When you press the Tomorrow are sorted and displayed posters of tomorrow

        [ed. note: Trent last edited this post 14 years, 7 months ago.]
          • 36404
          • 307 Posts
          Hi Trent,

          sorry to answer that late but things are a bit crazy those times...

          on the website you gave me as an example, the solution is quite simple, it works with ajax, each time you click on a link it send a request serverside and retreives, probably in s dedicated db table the poster matching the request
          this table probably have a timestamp column which is filles when the posters are uploaded
          the links have ids 'show_all', 'show_today', 'show_tomorrow' and 'show_calendar' for the datepicker one are targeted by js, for example, in the show_today case
          $('#show_today').click(function(){
          	ajax_post_list(this,'2012-02-16');
          });

          the js in in the page, this way, today and tomorrow dates are filled on the fly with php (they are on a nginx server)

          before telling you it the right way to proceed for you and, well then, you just need a module to store things and then an ajax request to retreive the date classified things, the first... thing smiley i would have to know is the kind of data you store and the way you do this
          are they modx ressources with a date tv or using the pubdate entry, or are they data you put online with a module ?

          have swing
            réfléchir avant d'agir
            • 36404
            • 307 Posts
            hi trent,

            had some time today to go and see the problem in your admin but too bad, i can't log in and the pm have been destroyed

            good luck

            have swing
              réfléchir avant d'agir