Tyssen

Strange output when setting Name format for children

Recommended Posts

I'm using a single page template with Name format for children filled in with date(U) so the children have their name field automatically filled with the UNIX timestamp, but when I save entries it's coming out in the format 11am28australia-brisbane-1549849103.

How do I only get the time stamp at the end?

Share this post


Link to post
Share on other sites

date(U) is working fine for me. It only adds the timestamp although I have installed ProcessSetupPageName module which expands "Name format for children". If you want try it but before that double check that you're using ONLY date(U) on "Name format for children". Maybe you have a custom hook forgotten on init.php or ready.php that manipulates the name on that template?

Share this post


Link to post
Share on other sites

I'd actually installed the SetupPageName module before I realised there was a native name format for children field but with it installed, I got errors when trying to add new pages, so I installed it. But I wonder if it's done something which is causing this behaviour?

Oh, and I don't have anything in init or ready which would be causing it.

Share this post


Link to post
Share on other sites

If the output of the name is 11am28australia-brisbane-1549849103 you obviously using more options in "Name format for children" than just "date(U)". For example how "Australia" or "Brisbane" injected?

Share this post


Link to post
Share on other sites

That's what I can't work out, because date(U) is all that's there.

Screen Shot 2019-02-12 at 11.02.39 am.jpg

Share this post


Link to post
Share on other sites

I also tested "string".date(U) and got tue-12-feb-2019-15-30-03-1000australia-brisbane2019-02-12t15-30-03-10-0003pmtue-12-feb-2019-15-30-03-10003australia-brisban 😕

Share this post


Link to post
Share on other sites
On 2/11/2019 at 2:50 PM, Tyssen said:

I'm using a single page template with Name format for children filled in with date(U)

From the documentation for "Name format for children":

Quote

If you want your page names to reflect the created date/time: Enter a PHP date format for the value of your name format. Your date format must include at least one non-alphanumeric character (like a slash "/" or colon ":" for example) in order to be recognized as a date format. Example: "Y/m/d H:i:s" would result in page names like: "2014-10-30-12-39-01". As you can see, non-alphanumeric characters still present in a formatted date are converted to hyphens.

So if you want date format "U" you would enter that along with at least one non-alphanumeric character - e.g. "/U" or "U/". Do not enter "date()" anywhere in the format.

ProcessSetupPageName is not the same as the core "Name format for children" feature and it has different format requirements.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Yep, that did it.

In all the Googling I've done on how to do this, that page in the docs never came up. The ProcessSetupPageName module did though which is why I attempted to use that first.

Share this post


Link to post
Share on other sites
4 minutes ago, Tyssen said:

In all the Googling I've done on how to do this, that page in the docs never came up.

If I remember correctly, on the notes of "Name format for children" should have a "More" link that leads to documentation. At least this is how it's done with the ProcessSetupPageName module.

  • Like 1

Share this post


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

  • Recently Browsing   0 members

    No registered users viewing this page.