$entry.has_extended, $is_single_entry, $entry.is_extended

Discussion corner for Developers of Serendipity.
Post Reply
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

$entry.has_extended, $is_single_entry, $entry.is_extended

Post by Don Chambers »

Had some template logic that was not working as expected and decided to take a closer look at these smarty vars. I viewed these variables with extended body existing, and not existing, as well as overview and detailed page views.

Everything worked as expected except one thing - $entry.is_extended is never true if extended body does not exist. Why?

It seems $is_single_entry is true when viewing the extended entry (ie, entry body, extended body, comment form)..

Code: Select all

No Xbody overview, No Xbody detailed, Yes Xbody overview, Yes Xbody detailed:
$entry.has_extended: null, nulll, 1, 1
$is_single_entry: null, 1, null, 1
$entry.is_extended: null, null, null, 1
This came up in the following context, found in many entries.tpl:

Code: Select all

{if $entry.has_extended and not $is_single_entry and not $entry.is_extended}
Truth is only one or the other of thse last two "and not" is necessary. The way this works, one cannot be true and the other false. They are both always false or always true if extended body exists.

Based on wording alone, I would like to see $entry.is_extended=true (1) for any detailed page view regardless of whether or not extended body exists... but at that point, it probably becomes redundant with $is_single_entry.

Either way, seems there may be one too many smarty vars in there, or there is some use for these I have yet to encounter. :wink:

Hope the above makes sense - cannot draw much of a chart here! :wink:
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: $entry.has_extended, $is_single_entry, $entry.is_extended

Post by garvinhicking »

Hi!

$entry.is_extended is only set when an entry has an extended body. If you want to check on the detail view, you should rely on $is_single_entry.

The extra checks there actually shows output when an entry has an extended body on the overview page, so the "if" clause is NOT meant to tell "this is an detail page", but "this is an entry with extended body on the overview page".

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply