ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

date_heading not showing...

September 21, 2007 3:43pm

Subscribe [1]
  • #61 / Oct 02, 2007 1:19pm

    ignite

    149 posts

    OK. That makes sense. Is it safe to assume that it will be added to next version of EE as a standard conditional variable?

    Why would you assume that? You’re welcome to put it as a feature request; but it works perfectly well now within the {}.

    Yes it works but at the beginning of our discussion you weren't even sure whether or not to include the {} in the conditional. To me that says that if the staff doesn’t know that it’s supposed to have {} around the variable then how is a general user. I didn't see anywhere in the docs where it outlines this special usage of {current_time} in conditional statements. All it says is:

    NOTE: Unlike the rest of the Standard Global Variables, {current_time} is parsed very early on in the Template parser, which allows you to make dynamic use of it in your tags, for instance as a tag parameter, or in a conditional.

    To me, that says “you can use it in a conditional just like your other variables”. If that’s the case then either having to use {} is either a bug, in which case it should be fixed in a new build or next release, or it's simply undocumented.

    As far as date_heading: you’re asking ExpressionEngine to read your mind instead of reading the code.  I don’t mean to argue with you but this is really, really important.  ExpressionEngine can do only what you tell it.  We don’t make assumptions, and you’ve encased it within a conditional that is telling everything inside that conditional not to display in this instance. It doesn’t matter if it’s the date_heading code or the text “pink elephants rock”. 

    If you want it to work *differently* then you should limit, not by conditionals, but by parameters; or consider writing a plugin specific to your project.

    Actually the opposite is true. I’m asking EE not to read my mind but to act only when requested and not before then. By using a conditional I’m asking the {date_heading} tag pair to react to the first record that meets that criteria and there after. The test we preformed tells me that it’s reacting to the first record returned by the weblog:entries tag which doesn’t meet the criteria so therefore it doesn’t execute.

    Either way you I look at it, your telling me that’s the way that EE is meant to work so I have to deal with it or come up with a plugin that works the way I’d expect it to.

    Lisa, I sincerely thank you for sticking with me in this thread. I have a better understanding of how the {date_heading} tag pair and the {current_time} global variable work. All your comments are greatly appreciated.

  • #62 / Oct 02, 2007 1:22pm

    Lisa Wess

    20502 posts

    I just want to clarify one further thing, ignite - not so much for you, but for the benefit of others.  In your case, the problem was not at all with date_header, and only mildly with current_time (btw: I am not a programmer, being staff does not make one a developer =) ), but the problem was actually with conditionals, and how conditionals work and when they are executed.  I keep saying this because it really is important and I don’t want confusion from anyone else viewing this thread in, say, a year from now. =)

  • #63 / Oct 02, 2007 1:30pm

    Lisa Wess

    20502 posts

    It bothers me that I’ve failed to communicate why your code isn’t working. I’m going to give it one last shot.

    You have a weblog entries tag; everything returned by the tag is filtered, ordered, and sorted by the parameters. 

    So you have 10 entries being returned.

    Now you’re using a conditional inside the weblog entries tag.  The conditional is run *for every entry*; in this case, it is run 10 times.

    Now, you have your date_heading tag.  It is inside the conditional.

    The date_heading tag is, in itself, a bit of a conditional, right?  After all, it compares what you want to a list of entries and figures out when to show up.

    Only, in this case, you’ve put it inside of another conditional.  Your first X entries (including the first entry) does not match and so it squelches everything inside the conditional - including the date_heading.  So the date_heading does not appear until it meets the next heading interval based on your parameters for that tag.

    Several posts later your conditionals do match, and by whacky coincidence, the date_heading should also appear with that set of entries, and so it does, indeed, show up.  However, if your fist post for *that* interval didn’t meet your conditional’s requirements, then that date_heading (and anything in the conditional) would also not show. 

    I hope that makes a bit more sense.  In order to avoid this, since you actually do not want the first X entries showing up at all (they do not meet your requirements, after all, and it’s extra processing to do what you’re doing, it is not optimal) you should use parameter to limit what is actually processed by the weblog entries tag pair.

  • #64 / Oct 02, 2007 1:54pm

    ignite

    149 posts

    Lisa that explanation was much more clear to me! I understand the way I was trying to do it wasn’t the most efficient way but the parameters for the weblog:entries tag pair doesn’t allow for the result I was after. That’s why I was trying to use a conditional to get what I wanted. I guess the one question I have remaining is what exactly is the condition that is required by the date_heading tag pair that must be met to display the contents within the date_heading tag pair?

  • #65 / Oct 02, 2007 2:07pm

    Lisa Wess

    20502 posts

    Well, let us take this example:

    {exp;weblog:entries weblog="default_site" limit="10" disable="trackbacks"}
    {date_heading}
    
    <h1> It's a brand new day, in a brand new month, in a brand new year!</h1>
    
    {/date_heading}
    {/exp:weblog:entries}

    The default for date_heading is daily. So in this case, the date_heading looks at each entry shown, in the order that the weblog entries tag outputs it.  For the first post, it has to show the date_heading, that’s pretty obvious.  Now it looks at the subsequent (lets say we posted 3 entries that day) posts and sees that they were all posted on the same day, so does not display the information inside the date_heading tag pair for those days.

    But the fourth post was yesterday, so the date_heading tag now sees that a new post meets its requirements and shows the information inside the date_heading tag pair.

    The 5th, 6th, 7th, and 8th post were also yesterday.  Since they were all the same day, the date_heading tag pairs sees that and nothing inside of it is displayed - remember, date_heading is used to show a heading for all entries within a particular time period.

    But the 9th and 10th posts were a week ago!  Oh, that’s a totally different day, now the date_heading tag pair must display its contents - for the 9th post, but not the tenth; since the tenth post was created on the same day as the ninth post.

    I guess the one question I have remaining is what exactly is the condition that is required by the date_heading tag pair that must be met to display the contents within the date_heading tag pair?

    So the answer to your question is that it depends. You set the condition (daily, weekly, monthly, yearly), and the date_heading will only show with the first post (in the order/set/limit (based on the parameters of the containing weblog entries tag) that meets that interval, then will not show until a post hits the next interval.  That is explained in the docs for the date_heading as well.

  • #66 / Oct 02, 2007 2:36pm

    ignite

    149 posts

    So the answer to your question is that it depends. You set the condition (daily, weekly, monthly, yearly), and the date_heading will only show with the first post (in the order/set/limit (based on the parameters of the containing weblog entries tag) that meets that interval, then will not show until a post hits the next interval.  That is explained in the docs for the date_heading as well.

    Ok, thanks for the explanation. What your saying is exactly how it’s acting in all my continued testing. Do you think asking for a parameter like start_condition=”” would be a reasonable feature request?

    {exp:weblog:entries weblog="default_site" limit="10" disable="trackbacks" start_condition="entry_date > {current} OR expiration_date > {current_time}"}
  • #67 / Oct 02, 2007 2:41pm

    Lisa Wess

    20502 posts

    You could certainly put in a feature request for that.  You might also consider using the query module or a custom plugin to figure out the appropriate date and pass *that* information to the start_on parameter.

  • #68 / Oct 02, 2007 2:52pm

    ignite

    149 posts

    Good thoughts Lisa. Thanks so much for your assistance with this and your patience! 😊

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases