We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Are any {exp:channel:entries} variables available to plugins inside the loop?

Development and Programming

Michael C. (ProImage)'s avatar
Michael C. (ProImage)
102 posts
13 years ago
Michael C. (ProImage)'s avatar Michael C. (ProImage)

I’m finding myself needing a {gmt_expiration_date} field in a {exp:channel:entires} loop, but no such variable exists yet for some reason. So I figured I’d just write up a quick plugin to do the job.

Now obviously I could pass the {entry_id} as a parameter, like so: {exp:gmt_expiration_date id="{entry_id}”}, but I’m wondering if there’s a simpler way for the plugin to know what the current entry is through existing PHP variables, and if so, which variables would those be?

EDIT: I should clarify, in case I’m over-complicating this: all I need is a way to display the expiration_date in a fixed (non-localized) way. 😊

       
Michael C. (ProImage)'s avatar
Michael C. (ProImage)
102 posts
13 years ago
Michael C. (ProImage)'s avatar Michael C. (ProImage)

Any takers?

       
Michael C. (ProImage)'s avatar
Michael C. (ProImage)
102 posts
13 years ago
Michael C. (ProImage)'s avatar Michael C. (ProImage)

Never mind, I managed to resolve the problem.

tl;dr: Don’t overcomplicate things. :p

For the curious:

I had 2 “event” weblogs - one with generic fields for general events, and one with very customized fields for an annual conference. Entries from both weblogs were displayed intermingled together, sorted by date. I would only display the date of each event (not the time, since that was irrelevant for these events). However, when localization kicked it, sometimes it “helpfully” adjusted the entry time so much that the date changed, leading to much confusion.

Initially I solved this by using TBZ Date field (which only does dates, not times, thus sidestepping the issue entirely). However, this broke the ability to sort entries from both weblogs by date, since each weblog had a differently-named TBZ Date field (eg. event-date-from vs conf-date-from).

I tried wrestling with the native EE entry date fields to somehow get them to display a non-localized date, without much success. A “gmt_entry_date” variable existed, which helped, but it was missing a “gmt_expiration_date” counterpart, which didn’t help. So I tried coding a custom plugin to show the “gmt_expiration_date” but was unable to get the Localization class to cooperate. I then tried hacking in the “gmt_expiration_date” variable into the core files (searching for “gmt_entry_date” in *.php and duplicating code portions as needed), only to belatedly realize that the entry/expiration dates were being localized on initial submission as well as when being displayed… my member account’s localization settings (GMT+2) were affecting things, which was problematic when I posted entries between midnight and 2am (resulting in a different GMT date).

Finally, I realized that since the only obstacle to using TBZ Date was the inability to sort entries from multiple weblogs by their custom and differently-named TBZ DAte fields, I could simply use P&T’s Gypsy extension to share one set of TBZ Date fields (named shared-event-from and shared-event-to) across both event and conference weblogs, and sort by that one field.

       
OrganizedFellow's avatar
OrganizedFellow
435 posts
13 years ago
OrganizedFellow's avatar OrganizedFellow

I truly miss when these forums were active with participating members and developers. :(

       
Michael C. (ProImage)'s avatar
Michael C. (ProImage)
102 posts
13 years ago
Michael C. (ProImage)'s avatar Michael C. (ProImage)

I know what you mean. :(

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.