Jump to content

Strange output when setting Name format for children


Tyssen
 Share

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?

Link to comment
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?

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

Link to comment
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 2
  • Thanks 1
Link to comment
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
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...