CMS Field Formatting in custom code embed

Goal
I am trying to make a custom code at the end of my CMS ‘tool’ posts to allow users to copy a citation to the page.
The format needs to be:
Last name, Initials. (Year, Month Day). Article title. Blog Name. URL

The custom code block I am using
image

The problem

  • I want to change the ‘Publication date field’ format to match the required Year, Month Day format in the custom code block.
  • I want to split the field ‘contributor name’ currently in Fname Lname format into Lat name, Initials.

The question
Are there functions I can use on the CMS fields to attain the desired results?


Here is my site Read-Only: LINK
This question refers to the tool CMS template at the bottom of the rich text under the Cite this article (APA 7th ed.) header.

@Fionn_Ferreira, you can use the Date/Time field to achieve the results you want. Welcome to the forums, by the way.

@chris_loggins, thanks for the welcome! I already use a date/time field in the CMS but am struggling to see how to get it to change the format in the custom code.

Oh okay, this one seems a little difficult to figure, I’ve been messing around with things, but nothing yet.

1 Like

You will need to leverage custom code to handle the transformation of rendered content. JavaScript can be used to parse date formats as well as manipulate text strings. If development is not your thing you can always hire help.

1 Like

@webdev This is what I was thinking. I do have some dev knowledge and would like to give this Java a shot, just don’t know where to start.

Working with date objects is documented at Date - JavaScript | MDN and working with string objects at Text formatting - JavaScript | MDN

1 Like

@Fionn_Ferreira - did you change the page? I don’t see your embed there anymore. :grinning_face_with_smiling_eyes:

Yes, I decided to give it a break until later since it was not integral to the site but rather an add-in.
I am going to refine it when I have a little more time. :slight_smile: