Sep 07, 2008, 01:28 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Filtering by publish year  (Read 2189 times)
0 Members and 1 Guest are viewing this topic.
neilcreek
Full Member
***
Posts: 130


« on: Apr 26, 2007, 10:46 PM »

Hi, I hope this hasn't been answered elsewhere, but I've scoured the documentation, wikis, forums etc and haven't been able to find an answer which I am able to apply to my problem.

I am building a site which will have an archive of articles which have a specific date (I've entered the date into the pub_date field). I am using ditto to present the articles and I need to be able to display a selected number of results by year. I have a box on my page with ALL of 2007 articles, and two other boxes which show the first 5 articles each of 2006 and 2005. I've looked at the $filter parameter, but can't figure out how to get it to filter out all years by one in the pub_date field. What am I missing?

Thanks so much for your help!
Logged
Mark
Moderator
*
Posts: 3,247


Ditto Developer


WWW
« Reply #1 on: Apr 27, 2007, 12:28 AM »

Take a look at the dateFilter extender (and its example use in 0.9.6 in conjunction with Reflect)
Logged

neilcreek
Full Member
***
Posts: 130


« Reply #2 on: Apr 27, 2007, 02:12 AM »

Thanks for your reply, but I'm afraid I need a bit more hand-holding than that. I've searched and my frustration is growing, so I'm going to have to swallow my pride and ask for more help. The biggest problem I'm having is finding a "top level" explanation of how it all works and what I need to do, perhaps with examples. In my searching I found:

This thread, which seems close to explaining, but confuses me because I'm not using wordpress, and I don't understand how this links with the ditto snippet use, because from my reading it seems that both need to be used?
http://modxcms.com/forums/index.php/topic,14003.0.html

The official documentation has no examples and doesn't explain how to correctly code the snippet, only listing the parameters, and I'm afraid describing them in computer programmer terms, which I find hard to figure out, not being very familiar with programming:
http://ditto.modxcms.com/files/snippet-reflect-php.html

The TRAC doesn't seem to make any mention of reflect at all:
http://modxcms.com/ditto_trac.html

The compiled documentation for Ditto has been a fantastic resource, but only makes mention of reflect in passing:
http://modxcms.com/forums/index.php/topic,13533.0.html

I tried the MODx wiki, but that doesn't seem to have anything about reflect:
http://wiki.modxcms.com/index.php/Ditto

I really have tried to do the research but having as little knowledge of php as I do, I feel like I'm lost in the woods. A simple tutorial would be a huge help, and I'm ahppy to figure it out myself, but I feel like I've jumped in the deep end before I can swim!!

Sorry for being so helpless, I really appreciate the time you take to help me out.
Logged
Mark
Moderator
*
Posts: 3,247


Ditto Developer


WWW
« Reply #3 on: Apr 27, 2007, 02:25 AM »

Your are not helpless at all. You've perfectly followed the policy on how to get help. Smiley The documentation deficiencies are being addressed with a MODx based support site to be unveiled in the near future. If you'd like a sneak peek PM me.

This should get your started:
1. Add &extenders=`dateFilter` &dateSource=`pub_date` to your uncached ( [! syntax ) Ditto 2 call
2. Append &year=YEAR to your URL or send via POST

Ditto will do the rest Wink
Logged

neilcreek
Full Member
***
Posts: 130


« Reply #4 on: Apr 28, 2007, 10:57 PM »

Thanks for your ongoing help!

I've added &extenders=`dateFilter` to the ditto call. I already was using the correct &dateSource. I don't follow what you mean by "uncached ( [! syntax )". I'm also not sure what you meant in point 2. My ditto call is embedded within a page, and that page will have three different ditto calls, showing documents from 3 different years, so the filter will need to be different on the same page. That, I assume, would mean that putting the &year parameter in the url wouldn't work. I'm not sure how I can put a "POST" into the ditto call?

This is the (first) ditto call on my page as it is now:

Code:
[[Ditto? &tpl=`dittospeeches` &parents=`17` &dateSource=`pub_date` &dateFormat=`%d %b %g` &sortBy=`pub_date` &display=`999` &extenders=`dateFilter`]]

This is the page as it looks now: http://www.orionvisuals.com/wip/harryjenkins/index.php?id=4

This is a screencap from the designer I'm working with showing how he wants this page to look (some aspects of the design have changed since this stage but the layout is the same):

Logged
Mark
Moderator
*
Posts: 3,247


Ditto Developer


WWW
« Reply #5 on: Apr 29, 2007, 01:20 PM »

For uncached syntax I mean calling Ditto like so: [!Ditto!] instead of [[Ditto]].
To handle the multiple Ditto calls on the same page add &id=`UNIQUE STRING` to each Ditto call where UNIQUE STRING is unique for each call.
Lastly, add &UNIQUE STRING_year=`2006` where UNIQUE STRING is the same as above for the corresponding Ditto call you want to affect and 2006 is the year you want to show.
If you want to be able to do this without adding things to the URL file a feature request using TRAC (link in my signerature).
Logged

neilcreek
Full Member
***
Posts: 130


« Reply #6 on: Apr 29, 2007, 10:00 PM »

Okay, I've given that a try, here's what my Ditto call looks like now:

Code:
[!Ditto? &tpl=`dittospeeches` &parents=`17` &dateSource=`pub_date` &dateFormat=`%d %b %g` &sortBy=`pub_date` &display=`999` &extenders=`dateFilter` &id=`speeches2007` &speeches2007_year=`2007` !]

Unfortunately, it hasn't filtered out items older than 2007: http://www.orionvisuals.com/wip/harryjenkins/index.php?id=4

My first guess is that &speeches2007_year=`2007` is looking to the creation date for the year, when i want it to look to the pub_date. All of the items will be created in 2007, so fot items that were originally created in past years, i've set their date in the pub_date field. Is there any way to get &speeches2007_year=`2007` to look in pub_date?
Logged
Mark
Moderator
*
Posts: 3,247


Ditto Developer


WWW
« Reply #7 on: Apr 29, 2007, 11:30 PM »

You need to add &speeches2007_year=2007 to the URL, not the Ditto call. If you do, it works on that page.

If you want to be able to do this without adding things to the URL file a feature request using TRAC (link in my signerature).
Logged

roki13
Member
**
Posts: 74



« Reply #8 on: May 06, 2007, 03:29 AM »

Hi,

I have the same problem. My call is the following:

Code:
[!Ditto? &tpl=`ListNews` &parents=`58` &dateSource=`NewsDate` &dateFormat=`%d/%m/%Y` &sortBy=`NewsDate` &display=`999` &extenders=`dateFilter` &id=`allnews` !]

my tv is called NewsDate

I tried to put &NewsDate=2006 in the url, didn't filter. I tried &NewDate_year=2006, not working neither. Any idea ?

thanks,

Seb
Logged
Mark
Moderator
*
Posts: 3,247


Ditto Developer


WWW
« Reply #9 on: May 06, 2007, 03:11 PM »

@roki13: The URL format is id_year=2006 where ID is what you have set &id to.

@all: The development version should now allow you to do this via parameters. For example:
Code:
[!Ditto? &parents=`2` &extenders=`dateFilter` &dateSource=`createdon` &year=`2006`!]

You can get the development version here
Logged

roki13
Member
**
Posts: 74



« Reply #10 on: May 08, 2007, 04:29 AM »

ok got it Smiley

On the same subject, I want to create a drop down list that will contain the years of my news. And be able to switch from one year to another (my news are not filtered by month). Is there a way of doing that ? I tried using tplContainer and tplYear. I put the following in tplContainer :
Code:
<select name="allnews_year" onchange="changeNewsYear();">
    [+archive_items+]
</select>

and in tplYear:

Code:
<option value="[+year+]">[+year+]</option>


which gives the following output:
Code:
<select name="allnews_year" onchange="changeNewsYear();">
    <ul class="reflect_archive"><li class="reflect_year"><option value="2007">2007</option>

<ul><li class="reflect_month"><a href="/fkm/index.php?id=67&amp;reflect_10_month=4&amp;reflect_10_year=2007&amp;reflect_10_day=false&amp;reflect_10_start=0" title="April 2007" class="reflect_month_link">April</a>
<ul class="reflect_items">
<li class="reflect_item"><a href="index.php?id=66" title="news 1" class="reflect_item_link">news 1</a> (<span class="reflect_date">24-Apr-07 13:19</span>)</li><li class="reflect_item"><a href="index.php?id=65" title="news 2" class="reflect_item_link">news 2</a> (<span class="reflect_date">24-Apr-07 13:17</span>)</li><li class="reflect_item"><a href="index.php?id=64" title="Back home" class="reflect_item_link">Back home</a> (<span class="reflect_date">24-Apr-07 12:07</span>)</li></ul></li></ul><ul><li class="reflect_month"><a href="/fkm/index.php?id=67&amp;reflect_10_month=5&amp;reflect_10_year=2007&amp;reflect_10_day=false&amp;reflect_10_start=0" title="May 2007" class="reflect_month_link">May</a>

<ul class="reflect_items">
<li class="reflect_item"><a href="index.php?id=74" title="another news in may" class="reflect_item_link">another news in may</a> (<span class="reflect_date">05-May-07 19:55</span>)</li></ul></li></ul></li></ul>
</select>



The output of tplContainer is correct, but obviously the tplYear is not. Is there any way to get rid of the <ul> and <li> tags, and to avoid months getting displayed as well ? I guess I'm gonna need to hack the snippet but want to make sure first.

thanks a million

seb
Logged
Mark
Moderator
*
Posts: 3,247


Ditto Developer


WWW
« Reply #11 on: May 08, 2007, 09:39 AM »

Yes there is in the current dev version. Its output is 100% templateable. You can get a copy from the link in my signerature.
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF 1.1.4 | SMF © 2005, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!