2009/12/18 ideamenDave <[email protected]>: > Hello! I've been using Habari for a couple months now, and I like > it. So far I've been able to get it to do nearly everything I needed > it to do right off the bat (despite my general ignorance of PHP), but > there's a couple few things I need that I'd like to learn about.
First, a big welcome to Habari (again!). > I've created a custom post type using the 'eventscontent' plugin > as a base (of course I modded it a bit to add some extra fields). > Basically it's a 'Shows' category, I'm using it as a sort of calendar > of events for my band. What I need is for these posts to be sorted > not by post entry date, but by the date of the event itself (one of > the new fields added to the new content type - post->info->eventdate), > and ultimately (details, details) would only display events in the > future (though it would also be nice to have them all displayable in > an archive). What version of Habari are you using ? The ability to display by postinfo has only been added to the Posts::get() API very recently, so it's not available in 0.6. See the thread that inspired the change here[1]. This will give you a hint of how to do it in both 0.6 and 0.7. This is the wiki page that should eventually hold your answer, http://wiki.habariproject.org/en/Dev:Retrieving_Posts. > I tried to add a sort of filter to the home.php page (I'm using Michael > Harris' Connections theme as a base), but to no avail. It appears to sort, > but only gets through 5 (the limit of posts to display per page) then > displays the rest in standard order. Here's the snippet I used (boy I hope > this displays, I've never tried to post code before): > > <?php if ( $request->display_entries_by_tag && $tag == 'shows' && ! > $request->display_home ) { ?> > <?php $theme->display ( 'showtop' ); ?> > <?php $eventposts = Posts::get( array ('content_type' => > 'ideamen_show', 'status' => Post::status('published'), 'orderby' => > $post->info->eventdate ) ); ?> > <?php foreach ( $eventposts as $post ) { > include( 'ideamen_show.php' ); } > ?> > <?php } ?> Something like this for 0.7: <?php if ( $request->display_entries_by_tag && $tag == 'shows' && !$request->display_home ) { $theme->display ( 'showtop' ); $eventposts = Posts::get(array( 'content_type' => Post::type('ideamen_show'), 'status' => Post::status('published'), 'has:info' => 'eventdate', 'orderby' => 'info_eventdate_value ASC', 'nolimit' => TRUE )); foreach ( $eventposts as $post ) { include( 'ideamen_show.php' ); } } ?> Instead of that include, you could use: $theme->content($post); That would use your ideamen_show.php template, because it's the name of the post's content type. See http://wiki.habariproject.org/en/IsContent for details. I think this is just a first step in improving what you're doing (ie, adding in the only upcoming dates stuff), so do follow up with how you go. [1] http://groups.google.com/group/habari-dev/browse_thread/thread/28d52f560f7193ef -- Michael C. Harris, School of CS&IT, RMIT University http://twofishcreative.com/michael/blog IRC: michaeltwofish #habari -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/habari-users
