I'm using views to build podcast feeds. The feeds and views are working great. Here is my situation, Each of my users has their own RSS feed, over time, my app needs to give them new episodes. In my Audio content, I have added a field called publish_day to my audio content type. I have these set to integers like x. So if an audio has publish day of 12, then my user would have that added to his feed on day 12 of his subscription.
I've been trying to use views_view_add_filter to add a filter in the argument code, but could not get this to work. Here's what I really need to happen, can someone tell me how to approach it.
I want a view that's www.vlfit.com/podcasts/5. podcasts is the itunes feed and 5 is the $user->uid.
When this URL is loaded, I want my view to check and see what day in the cycle my user is on. Let's say I have a function Userday($user->uid) that returns 12. Since my user is now on day 12 of the cycle, I want to show all audios that have 12 or less in their publish_day field.
HELP!
How can I call my UserDay function from views
How can I match its return value against the publish_day.
Thanks for your guidance.
JimF
Comments
Comment #1
merlinofchaos commentedIn the argument code, you need to use $query->add_where() to add a filter.
By the time argument code is running, it is too late to try to actually add new 'filters' to the view; you're in the middle of processing. You have to do your filter manually, like almost every argument actually does.
I'm guessing you're going to just have to load your data through normal means, and use $query->add_where() to add a proper WHERE clause to the query to do the filtering.
I'm sorry I can't be more specific, but I don't know where your data resides or how it's loaded; if it's CCK, I cannot help you as I am not familiar enough with the CCK storage structure to tell you what to do.
Comment #2
phazer commentedThe pointer to $query->add where() is a good tip, I'll start with that. Thanks
Comment #3
phazer commentedI finally got this to work, so I thought I'd post the solution so others might find this thread and it help them. The real secret was that I had to create an Exposed Filter in the View, then I could override it at runtime.