Forum

Thread tagged as: Question, Problem, Configuration

Unique URL for list and detail page

There's a risk the editor will forget the items he's previously added to a list and details product photo gallery and cause duplicated URL because of name repetition in using one field for the slug.

What would you suggest to use to prevent this? Can you tap in to the ID yet like this post? https://forum.grabaperch.com/forum/10-08-2014-list-and-detail-creating-a-unique-slug

Any bright ideas?

David Owen

David Owen 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What type of content is it?

It's for a series of images to form a gallery page that ideally wants a unique URL to view/share a single image on (it's not a pop up gallery)

Something like this gallery_details.html...

<h1><perch:content id="title" type="text" label="Picture Name" required="true" title="true" size="xl" /></h1>
<perch:content id="image" type="image" label="Image" width="640" output="tag" />
<perch:content id="desc" type="text" label="Short Description" required="true" size="xl" />
<perch:content id="slug" for="title" type="slug" suppress="true" />
<perch:content id="image" type="image" label="Image" width="100" height="100" crop="true" suppress="true" />

Then there's a feed of the recently added image thumbnails on the home page. Clicking on one will take you to the unique URL. All doable except for the editor making duplicates.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Hmm, nothing too obvious to use to make it unique. I'm not sure I've got a good answer.

Could I add a date/time to the end of the slug?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you could do that if it makes sense in the context, sure.

If I could add the date/time to the end of the id="title" type="text" label="Picture Name" slug or perhaps add id="desc" to the end of the slug either could reduce/stop duplicates

But how do I join two id's / fields to make the combined slug URL?

<perch:before>
<ul>
</perch:before>
<li>
     <a href="?s=<perch:content id="slug" type="slug" />">
          <perch:content id="image" type="image" width="100" height="100" crop="true" output="tag" />
          <perch:content id="title" type="text" />
     </a>
</li>
<perch:after>
</ul>
</perch:after>
Drew McLellan

Drew McLellan 2638 points
Perch Support

"You can also use a space-separated list of IDs in the for attribute. This will draw content from multiple fields."

https://docs.grabaperch.com/docs/templates/attributes/type/slug/

do you mean...

for="title desc"

or

for="title date"
Drew McLellan

Drew McLellan 2638 points
Perch Support

If date is a date field, you'll need to address the components of the date individually -

date-year
date-month
date-day

Ok thanks. Could you get a timestamp?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Not without creating a custom field type for a timestamp.