Wonderful! Thanks Michael.
I took a day to wrap my head around your answer, poked around the
links (very helpful), and once I had a handle on it, I went ahead and
installed 0.7-alpha r3829 on my test site (I'm running 0.6.3 on the
official site). It works! I of course got a handful of errors for a
bit while mucking about with the code because I (cough) don't know
what I'm doing, but it behaves pretty much like I want it to.
Here's the final snippet that does the trick in the home.php file:
<?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' => 'eventtimestamp',
'orderby' => 'info_eventtimestamp_value ASC',
'nolimit' => TRUE
));
foreach ( $eventposts as $post ) {
if ( $post->info->eventtimestamp >
strtotime('yesterday') ) {
include( 'ideamen_show.php' );
}
}
}
?>
Note that there is a new field 'eventtimestamp'. I had to add another
field into the content type plugin to convert the event date string
into a timestamp for proper sorting (it got them mixed up sorting by
the string value). This was done with:
$post->info->eventtimestamp = strtotime($form->eventdate->value);
I also had to re-save all of my posts after I added the eventtimestamp
field, to fill the voids that the pages were asking for. Ack. To
progress!
I tried the "$theme->content($post);" method instead of the include,
and it filled the page with only the latest post. I likely
implemented it wrong. The include does the trick though.
Also note the "if ( $post->info->eventtimestamp > strtotime
('yesterday') )" that gets it to display only events that happened
after yesterday. I'm all giddy now.
Now I suppose I'll have to update my live version to 0.7 and go for
the gold. My next project is figuring out how to display custom
headers for each user on posts (could be as simple as loading a
different style class based on $post->author->username, but my efforts
in that direction didn't quite work).
The test site: http://www.iloveideamen.com/testCMS/habariTest/
Click the "Upcoming Shows" link in the ideaMenu :D
Happy Holidays to all, and thanks for the help!
--D.G. Solar
p.s. Are we getting a shiny new official 0.7 release for Christmas
this year?
On Dec 20, 2:57 am, "Michael C. Harris" <[email protected]>
wrote:
> 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. Seehttp://wiki.habariproject.org/en/IsContentfor
> 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/28d52f...
>
> --
> Michael C. Harris, School of CS&IT, RMIT
> Universityhttp://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