Hiding date for entries not shown on front page?

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
Mangek
Regular
Posts: 85
Joined: Tue Jun 24, 2008 1:08 am
Location: Sweden
Contact:

Hiding date for entries not shown on front page?

Post by Mangek »

Good evening!

I have a couple of entries that I've hidden from the front page, containing links and a gallery and such (I don't want to use static pages, I still want the comments).

My question is whether it'd be possible to hide the date for these entries? Perhaps in the same way the 'sticky'-text is not shown when the entry isn't stickied?

I don't know much of the smarty syntax, so I won't solve this one myself. ;)

Thanks much! :)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Hiding date for entries not shown on front page?

Post by garvinhicking »

Hi!

It depends a bit on your template. If you use a template that shows the date for each entry again and again, and not only once for all entries of the same day, you can easily create a custom field called something like "hide_date" and then set that to "1" or "true" for every entry that should get no date. Then inside your entries.tpl you would just make an "{if $entry.properties.ep_hide_date != ''}" smarty check around the output of your date.

If the date is emitted not for entries themselves, but rather for dategroups, this won't work. You must then change the template and shuffle the foreach-loops where the date is printed within the main loop, resulting in slightly more work.

HTH,
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/
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

Hey Garvin - how about {if $entry.properties.ep_no_frontpage ='true'}?? Then the date hiding would correspond exactly to the flag already set for hiding the entry from the frontpage, and an additional custom extended property field would not be necessary....
=Don=
Mangek
Regular
Posts: 85
Joined: Tue Jun 24, 2008 1:08 am
Location: Sweden
Contact:

Post by Mangek »

Awesome, that works like a charm, Garvin! Thank you so much! :)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi Don!

Well, if the no-frontpage option is set, the entry doesn't even show up on the frontpage...I was reading the question like it was about the frontpage, not the entry detail page?

Of course if it's all only about the entry detail page, then one should use this variable, you are right! :-)

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/
Mangek
Regular
Posts: 85
Joined: Tue Jun 24, 2008 1:08 am
Location: Sweden
Contact:

Post by Mangek »

Don Chambers wrote:Hey Garvin - how about {if $entry.properties.ep_no_frontpage ='true'}?? Then the date hiding would correspond exactly to the flag already set for hiding the entry from the frontpage, and an additional custom extended property field would not be necessary....
Yeah, actually I added 'true' to the code and wrote true in the field to make it happen. :)

Edit: I read your answer too fast, I'm a little tired. If what you say means I don't have to type anything extra (they won't be on the front page, ever) that'd be great! :)
Mangek
Regular
Posts: 85
Joined: Tue Jun 24, 2008 1:08 am
Location: Sweden
Contact:

Post by Mangek »

Actually, I changed it to

Code: Select all

{if $entry.properties.ep_no_frontpage ='true'}
and now I get a fatal error. :?
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

Sorry, that should be 2 equal signs....

Code: Select all

{if $entry.properties.ep_no_frontpage =='true'}
=Don=
Mangek
Regular
Posts: 85
Joined: Tue Jun 24, 2008 1:08 am
Location: Sweden
Contact:

Post by Mangek »

== hid the date from all instances, both frontpage and entry detail page. != however, did the trick! Thanks! :)
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

I didn't look at more than a single entry... looks like $entry.properties.ep_no_frontpage does not exist at all for entries that are not hidden, so the first instance of it occuring sets it to true, and it never gets set to anything else.

This MIGHT work:

Code: Select all

{if $entry.properties.ep_no_frontpage}
Then again, if you already have a solution, there is probably no reason to change it except for curiosity. My point was simply to use the same ep field that already exists rather than creating a new one... that way, your single check of "hide from frontpage" solves both of your objectives.
=Don=
Mangek
Regular
Posts: 85
Joined: Tue Jun 24, 2008 1:08 am
Location: Sweden
Contact:

Post by Mangek »

Heh actually, {if $entry.properties.ep_no_frontpage} did just the oposite of what I wanted.. :D (Yeah, I was curious enough to try it -- less code means more fun).

I'll go with the !=, it worked fine. Many thanks Don! :)
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

Well, it probably did the exact opposite because I never saw the balance of your code - you could either be printing, or supressing, the date. Regardless of HOW you got it to work, at least it does!! :wink:
=Don=
Post Reply