x
 
Create New Page
 View Previous Changes    ( Last updated by Lisa Wess )

Recurring entries

Answer

There is a plugin available on our forums entitled Repeet - that can handle this and other features.

Answer 2

This code illustrates how to repeat entries on a yearly basis. The first example below isn’t very flexible; you can only show entries posted ON THIS DAY on a previous year.

This entry assumes that you have a certain knowledge of SQL queries. You need to know how to add fields to a SQL query to be able to use the following examples. The queries provided below were not rigourously tested ... but they seem to work on paper ;-)

Also, please note that there is a plugin available that shows posted entries ON THIS DATE. The first query below does the same thing. However, that plugin doesn’t allow you to mix new entries with old entries. The second query below allows you to do that.
http://www.pmachine.com/plugins/on-this-day/
———

SELECT exp_weblog_titles.titleexp_weblog_titles.yearexp_weblog_titles.monthexp_weblog_titles.dayexp_weblog_titles.entry_idexp_weblog_titles.url_title 
FROM exp_weblog_titles 
WHERE exp_weblog_titles
.month=AND exp_weblog_titles.day=

The above code will display all the entries that were posted on JUNE 07, regardless of the year. Now, depending on how you want to display the results, you might need to add a clause in the query to include more fields and/or ‘regular entries’ that were posted in the past few days. The drawback is that I think that the pagination feature doesn’t work with the QUERY tag.

- To change the value for month/day, you might want to use a URL segment (see URL below), or simply use the UNIX values for the current month/day.

http://www.pmachine.com/expressionengine/docs/templates/globals/url_segments.html

———

- To include the list of ‘regular entries’ (entries posted this year on this date and in the previous few days) is a bit trickier. Also, it assumes that you also want to display ‘old’ entries that were posted before today’s date.

Entry 1 : 2005-06-15

Entry 2 : 2004-06-15

but you probably also want ;

Entry 3 : 2005-06-14

Entry 4 : 2004-06-13

Entry 5 : 2005-06-12

Entry 6 : 2004-06-11

If you just need to display the entries POSTED ON THIS DAY (entry 1&2 in the above example), you’ll be fine using the SQL Query specified above.

If you need to also display entries posted in the past few days (of the current AND previous years), you’ll need something a bit more complex !

A) First, go to the Admin Area and go to debugging preferences. Turn on the DISPLAY SQL QUERIES feature.

B) OPTIONAL : Set a maximum of days in the weblog tag that you currently use to display the entries. For example, 10 days.

C) Access the template on your website. You’ll see 10-20 queries at the bottom of the page. Find the query that is used to display the entries. That query will most likely contain the following text (NOTE: the number will vary based on your configs) ;
- exp_weblog_titles.entry_date < 1118805163
- exp_weblog_titles.expiration_date > 1118805163)
- exp_weblog_titles.weblog_id = ‘30’
- exp_weblog_titles.status = ‘open’

D) Copy that query starting with “SELECT” and create a new template. In that new template, paste the copied code in a EE Query tag. Don’t forget to close the query tag and to put {entry_id} in between the opening and closing tags. Test the template to make sure it works. The page should display the same entries that you see on the page from where you got the SQL query.

E) Edit the following query

UNION SELECT exp_weblog_titles.titleexp_weblog_titles.entry_idexp_weblog_titles.url_titleexp_weblog_titles.entry_date"2005" AS nyearexp_weblog_titles.monthexp_weblog_titles.dayexp_weblog_titles.year AS real_year 
FROM exp_weblog_titles 
WHERE 
(((exp_weblog_titles.entry_date)<((unix_timestamp(Now()))-31609362) And (exp_weblog_titles.entry_date)> ((unix_timestamp(Now()))-(31609362-(1*159762))))); 

 

You’ll need to replace the “1*159762” to reflect the number of days you want to include. If today’s date is June 16, the above query will display all the entries posted on the 26 last year. If you want to include entries posted on the 15 of last year, change it to “2*…..”. If you want to include 10 days (june 16-26 2004), change the one to 10.

F) If you need to include data from 2 years ago, you’ll need copy the above query a second time. Replace 31609362 by 63072000 in the second query. Don’t modify the first one.

G) Paste the queries below the first query we created in the new template.

H) The query won’t work. You’ll need to add the fields you need in the queries (titles, url_title, …). Make sure that the field order is the same in the 2 queries and that the column count (the number of field) is the same.

I) Add an order by clause in the query. Order the entries by YEAR, then MONTH, then DATE, then time.

Category:Queries Category:Events

Category:EE1

Categories: