We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9496
    • 113 Posts
    Thats funny. I was thinking about exactly that after I got my eyeballs uncrossed last night. A way to tie the customFields parameters into the snippet call itself, without a direct query statement in the snippet, and using them as a way to alter the display output. I’ll give it a go and report back.

    Again, many thanks-

    [UPDATE]
    That worked like a charm. The only thing was a missing quote so the final Select statement went like this:
    <?php
    $rs=$modx->db->select(
            "*", 
            $modx->db->config['table_prefix'].$mg->mgconfig['gtable'],
            "(gal_id='" . $mg->pageinfo['id'] . "' AND NOT hide='1') ".$conditions."",
            $orderby.' '.$mg->mgconfig['order_direction'], 
            $mg->mgconfig['offset'].','.$mg->mgconfig['limit']);
    ?>
    


    It looks like there are three statements total total (depending on whether or not gal_id, pic_ids, or is default) are set. So I put the condition statement at the top and then modified the dafault to what you had provided. I could easily make the modification to the other two SELECT statements as well right?

    Now all I need to do is figure out how to only choose a date range. (Like last week) Is it possible to compare the date set in the maxigallery picture date field to some other date?

    Like in the outer template

    [+maxigallery.picture.date:isgt`[[winnerWeek]]`:then=` rest of outer template goes here

    and the snippet winnerWeek looks something like this:
    <?php
    echo date("Y-m-d", strtotime('last Monday -1 week'));
    ?>


    Ill probably have to think about that. Maybe convert the MG date into a timestamp and then compare from there to get there.
      • 7923
      • 4,213 Posts
      Quote from: Fatknuckle at Sep 25, 2009, 07:50 AM

      It looks like there are three statements total total (depending on whether or not gal_id, pic_ids, or is default) are set. So I put the condition statement at the top and then modified the dafault to what you had provided. I could easily make the modification to the other two SELECT statements as well right?
      Yeah, three statements for the thumbnail view.. but if you want that the conditions also affect to the picture management part, you’d need to put it to other queries too... and to the picture view part so that prev / next links are built correctly etc.. So basically if you would want to do it right, you would create the conditions at the top of maxigallery.php and add them to each SELECT query (where necessary).

      Quote from: Fatknuckle at Sep 25, 2009, 07:50 AM

      Now all I need to do is figure out how to only choose a date range. (Like last week) Is it possible to compare the date set in the maxigallery picture date field to some other date?
      Well.. you could expand on that custom where condtions thing we achieved above and do another parameter where you can say what operator is used to compare the field, eg.

      &custom_where_fields=`date` &custom_where_values=`[[datetime? &time=`last Monday -1 week`]]` &custom_where_operators=`>`

      Then make the conditions read that operator parameter for each field. And the contents of "datetime" snippet would be something like:

      <?php
      return strftime('%Y-%m-%d %H:%M:%S', strtotime($time));
      ?>
      


      Or you could do it in the templates with PHx like you said (need to convert datetimes to timestamps).. but then you would always need to query all rows from db and go through them one by one, so it can cause some overhead.


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 9496
        • 113 Posts
        makes sense. In this case though, performing custom selects at the picture level doesnt seem necessary, I guess I cant think of how I would use it other than in a gallery view situation. Taking the long view however its good to plan for any circumstances.
        -P