[SOLVED] Auto expiration after custom time limit (SAEF)
Posted: 29 May 2008 12:54 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  189
Joined  05-25-2002

I’m using SAEF to allow users add an entry. I want to set expire time to the value: current time + 2 months by default. It means all entries added through SAEF will be expired after two months. So I’ve changed expire field to hidden type.

<input type="hidden" name="expiration_date" value="{expiration_date}" />

Now I need to know, how to generate wished time stamp (current time + 2 months) for the value=”“

Could you help me anybody?

 Signature 

+ CM faviconizEE
+ CM Nice URL
+ CM Strange URL Interpreter
+ CM Textarea Resizer
+ CM Template Editor

Profile
 
 
Posted: 29 May 2008 01:59 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  189
Joined  05-25-2002

[SOLUTION]

OK, there is a little solution with PHP hardcoding. I’m turned template with SAEF to allow input PHP.

<?php
global $LOC;
$future_time={current_time}+5184000;
$expiration_2months = $LOC->decode_date('%Y-%m-%d %g:%i', $future_time);
?>

5184000 - is 2 months in seconds

Your entry expire <strong><?php echo $expiration_2months; ?></strong>
<
input type="hidden" name="expiration_date" value="<?php echo $expiration_2months; ?>" />

If there is any elegant solution using EE tags, post it here. Maybe will be useful for other.

 Signature 

+ CM faviconizEE
+ CM Nice URL
+ CM Strange URL Interpreter
+ CM Textarea Resizer
+ CM Template Editor

Profile
 
 
Posted: 29 May 2008 02:25 AM   [ Ignore ]   [ # 2 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  29214
Joined  05-15-2004

I was going to suggest something along these lines. Glad it’s working for you.

 Signature 

ExpressionEngine 2.0 Downloads | Docs | Bugtracker

“If the English language made any sense, lackadaisical would have something to do with a shortage of flowers.” (Doug Larson)

Profile
MSG
 
 
Posted: 29 May 2008 02:49 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  483
Joined  07-17-2006

this is great, Gabriel!

i was looking for something like that for some weeks now (for a classifieds-site)!

thx!

 Signature 

Greetings from the swiss alps
macprime.ch | stefanrechsteiner.comswissmacmeeting.ch | studisurf.ch | isurf.ch | studimedia.ch

Profile
 
 
Posted: 29 May 2008 03:03 AM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  189
Joined  05-25-2002

macsteve: right! I’m building classifieds site too smile I’ve extended SAEF following - maybe will be interesting for you too:

PHP variables

<?php
global $LOC;
$future_time_7={current_time}+604800;
$future_time_14={current_time}+1209600;
$future_time_30={current_time}+2419200;
$future_time_60={current_time}+5184000;

$expiration_7 = $LOC->decode_date('%Y-%m-%d %g:%i', $future_time_7);
$expiration_14 = $LOC->decode_date('%Y-%m-%d %g:%i', $future_time_14);
$expiration_30 = $LOC->decode_date('%Y-%m-%d %g:%i', $future_time_30);
$expiration_60 = $LOC->decode_date('%Y-%m-%d %g:%i', $future_time_60);

$label_7 = $LOC->decode_date('%d.%m.%Y', $future_time_7);
$label_14 = $LOC->decode_date('%d.%m.%Y', $future_time_14);
$label_30 = $LOC->decode_date('%d.%m.%Y', $future_time_30);
$label_60 = $LOC->decode_date('%d.%m.%Y', $future_time_60);
?>

SAEF select field - user can choose lenght of displaying your insertion

Expiration time<br />
<
select name="expiration_date">
<
option value="<?php echo $expiration_7; ?>">1 week (to <?php echo $label_7; ?>)</option>
<
option value="<?php echo $expiration_14; ?>">2 weeks (to <?php echo $label_14; ?>)</option>
<
option value="<?php echo $expiration_30; ?>">1 month (to <?php echo $label_30; ?>)</option>
<
option value="<?php echo $expiration_60; ?>" selected="selected">2 months (to <?php echo $label_60; ?>)</option>
</
select>

If you want, we can share own solutions. I’ve solved almost all problems how to turn EE to classifieds site.

 Signature 

+ CM faviconizEE
+ CM Nice URL
+ CM Strange URL Interpreter
+ CM Textarea Resizer
+ CM Template Editor

Profile
 
 
Posted: 29 May 2008 03:07 AM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  483
Joined  07-17-2006

awesome!!! thank you very much!

 Signature 

Greetings from the swiss alps
macprime.ch | stefanrechsteiner.comswissmacmeeting.ch | studisurf.ch | isurf.ch | studimedia.ch

Profile
 
 
Posted: 03 September 2008 06:35 AM   [ Ignore ]   [ # 6 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  21029
Joined  04-29-2002

Gabriel, this would make a great wiki entry. smile Hint, hint.

 Signature 

EE 2.01PB - 2.x Bug Tracker | Docs | Upgrade from 1.x to 2.x | Build Update Instructions | 1.6.x Update Info

Most recent 2.x version: Build 20100215
Don’t forget to upgrade MSM and Forum as needed!

Profile
MSG
 
 
Posted: 11 March 2009 06:53 PM   [ Ignore ]   [ # 7 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  292
Joined  11-11-2006

Just had to say thank you for this Gabriel.

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1743, on December 02, 2009 03:47 PM
Total Registered Members: 120384 Total Logged-in Users: 36
Total Topics: 126501 Total Anonymous Users: 26
Total Replies: 665233 Total Guests: 319
Total Posts: 791734    
Members ( View Memberlist )