Recent Topics

1 Sep 12, 2008 21:38    

My b2evolution Version: Not Entered

I know the $MainList->date_if_changed() function prints a date which contains at least one post. I use this in my skin and I understand it. But, how can a grab that date as a php variable?

For example something like...

$post_date = $MainList->date_if_changed();

would be perfect if the date_if_changed function actually returned the date rather than just printing it to the screen. I'm sure this functionality is somewhere, I'm just not seeing it in the documentation/forums.

Thanks in advance for any/all help!

2 Sep 12, 2008 22:51

You could try:

ob_start();
$MainList->date_if_changed();
$post_date = ob_get_contents();
ob_end_clean();


$post_date will contain an empty string if $MainList->date_if_changed(); outputted nothing.

3 Sep 12, 2008 23:08

or try

$post_date = $Item->get_issue_date();


a few lines down the code once you're within the mainloop (that starts with 'while').
I'm not completely sure and my current desktop setup is not as such that I can easily try it out for you.

Good luck

4 Sep 12, 2008 23:12

date_if_changed() shows a date only when the date of the next post is different than the date of the current post. So I guess are you trying to get the date of the current item or the "date if changed from previous item" is worth asking. By the by I think $post_date above will contain a lot more than the date of the current post assuming it isn't different from the previous post. The date_if_changed function ends like this:

			// Display the new current date:
			echo date_sprintf( $params['before'], $this->last_displayed_date )
					.date_i18n( $params['date_format'], $current_item_date )
					.date_sprintf( $params['after'], $this->last_displayed_date );


AFAIUI that means $post_date would contain enough info to properly echo the info in a format defined by other parameters.

I'd be looking for something like $Item->get(date) but that might not be the right bit inside the () part.

5 Sep 15, 2008 22:55

Thanks all,

I don't necessarily need the issue date of every post. But I think the $Item->get_issue_date() will work for what I'm trying to do.

The skin I'm making groups posts under a single if_changed() date header. I'm just trying to format that header based on the actual date of the posts in that group.

Thanks again!


Form is loading...