Jump to content
SamC

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

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'

Share this post


Link to post
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. 

 

Share this post


Link to post
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

Share this post


Link to post
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

 

Share this post


Link to post
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...

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...