Jump to content

Create page with auto title "jS F Y - Day n"


SamC
 Share

Recommended Posts

Hi everyone,

I'm creating a journal style site. I have the templates journal-index and journal-entry (child), I wanted to see if there was a way that when I create a new blog entry, the title field will automatically be populated with [DATE] - [DAY n], for example:

9th April 2019 - Day 1
10th April 2019 - Day 2
11th April 2019 - Day 3

This is a local 'countdown from' site and I may publish it, haven't decided yet.

Now, let's say this is possible. What would then be the way to change the format at a later date, say I wanted to change to '09/04/19 - Day 1 since...'.

Would this be awkward? Is there a way to batch change all the titles like this after a bunch of pages have been created?

Thanks.

*NOTE* I'm open to other suggestion because this may suck a fair bit for SEO should this go live. Thing is, I don't have an actual title in mind for each page, there could be a lot of these. I was thinking in this case, a date actually makes more sense. Although, another problem could be the URL, it would be awesome to get something like 'site.com/09/04/2019/day-1'

Link to comment
Share on other sites

Just a quick thought...

  • Create a date field add it to journal-entry
    • field settings: Input > Default to today's date
    • Output format: whatever you want
  • Change journal-entry template settings to
    • Advanced > List of fields to display in the admin Page List > {date}

Create a hook that alters the page name based on the page's date field value right after saving or publishing that page. Add additional conditions to enable custom URLs/page names.

Downside would be... you have to count the days somewhere else. 

 

Link to comment
Share on other sites

32 minutes ago, SamC said:

Although, another problem could be the URL, it would be awesome to get something like 'site.com/09/04/2019/day-1'

Unless you consider creating the page tree like this, URL segments would be the solution. I'd probably sort the date fields in descending order, though ('site.com/2019/04/09/day-1' or simply 'site.com/2019/04/09').

  • Like 1
Link to comment
Share on other sites

2 hours ago, SamC said:

Now, let's say this is possible. What would then be the way to change the format at a later date, say I wanted to change to '09/04/19 - Day 1 since...'.

Are you talking about the frontend or the backend? I don't understand your whole setup, I guess ?  Where do you store your initial date (the one that is the reference to count the days to the date of the entry)? Is it like this?

2019/04/01 Foo Bar
  2019/04/02 - Day 1
  2019/04/05 - Day 4
  2019/04/09 - Day 8
2019/04/02 Bar Foo
  2019/04/05 - Day 3
  2019/04/09 - Day 7

 

Link to comment
Share on other sites

Ah yeah, I see your point. These dates are actually backdated. Hmmmm, I'll look at the other replies on here tomorrow and see if I can come up with something.

 

@bernhard like:

Journal (journal-index)
 - 2019/04/02 - Day 1 (journal-entry)
 - 2019/04/05 - Day 4 (journal-entry)
 - 2019/04/09 - Day 8 (journal-entry)
 - 2019/05/09 - Day 9 (journal-entry)
 - 2019/06/09 - Day 10 (journal-entry)
 - 2019/07/09 - Day 11 (journal-entry)
etc...

 

Link to comment
Share on other sites

For now, I added a $post_date (datetime) field on journal-entry and created pages normally with a title. It actually works ok, I sort the index page children by $post_date and happy enough for the moment.

Thanks everyone.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...