Jump to content

Output a WYSIWYG Custom Field added to a Custom Collection

Go to solution Solved by SquatchCreative,

Recommended Posts

Posted

I have a custom collection:

{
    "title" : "SHOWS",
    "ordering" : "user-orderable",
    "addText" : "Add Show Date",
    "acceptTypes": ["showsCustom"]
}

And I gave it the custom fields:

{
		"title" : "Show Info",
		"name" : "showsCustom",
		"base" : "text",
		"fields" : [
		  {
			"name" : "tourdateMonth",
			"title" : "Month of Event",
			"type" : "text"
		  },
		  {
			"name" : "tourdateDay",
			"title" : "Day of Event",
			"type" : "text"
		  },
		  {
			"name" : "time1",
			"title" : "Time of Event",
			"type" : "text"
		  },
		  {
			"name" : "time2",
			"title" : "Second Time (optional)",
			"type" : "text"
		  },
		  {
			"name" : "ticketLink1",
			"title" : "Ticket Link",
			"type" : "text"
		  },
		  {
			"name" : "ticketLink2",
			"title" : "Ticket Link 2 (optional)",
			"type" : "text"
		  },
		  {
			"name" : "additional",
			"title" : "Additional Info (optional)",
			"type" : "wysiwyg"
		  }
		]
	  }

And when I output it on a custom template, everything works except for my `wysiwyg` field called "additional".  Below is the code I am using:

<squarespace:query collection="upcoming-shows">
    <div class="row tour-show-row">
      {.repeated section items}
      <div id="post-{id}" class="tour-show {@|item-classes}" data-item-id="{id}">
        <date>
          <month>{customContent.tourdateMonth}</month>
          <day>{customContent.tourdateDay}</day>
        </date>
        <place>
          <location data-content-field="title">{title}</location>
          <venue>
            <a href="{customContent.ticketLink1}" target="_blank">@{location.addressTitle}</a>
            {.if customContent.additional} <span class="presale">{customContent.additional}</span> {.end}
          </venue>
        </place>
        <times>
          <a href="{customContent.ticketLink1}" target="_blank">{customContent.time1}</a>
          {.if customContent.time2}
          <a href="{customContent.ticketLink2}" target="_blank">{customContent.time2}</a>
          {.end}
        </times>
      </div>
      {.end}
    </div>
</squarespace:query>

The conditional statement fires, as I see empty

<span class="presale"></span>

so it is returning true... but nothing is output.  Can anyone guess as to why? 

Using the docs for reference -- https://developers.squarespace.com/custom-post-types -- and all seems correct.

Thanks!

  • Replies 2
  • Views 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution
Posted

Aaaaaand I figured it out.  The 'wysiwyg' field returns an object, so to call it, it requires:

{customContent.additional.html}

Which I discovered because the docs mention that you can append

?format=json-pretty

to your URL and it will output all of the page's JSON for debugging, which was incredibly helpful.  So your URL would be:

http://www.mysite.com/my-list/?format=json-pretty

Hope this helps someone!

👋

  • 2 months later...

Create an account or sign in to comment

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


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.