Forum

Thread tagged as: Question, Runway

perch:related and slugs

Hi

I'm working with perch:related for the first time and I've run into a problem - hoping it's just something I've done wrong...

This is my perch:related template

    <perch:related id="relateddevelopmentName" collection="property developments" label="Development name">
    <perch:content id="developmentName" title="true" label="Development name" />
    </perch:related>

This works in the Admin CMS, it lists all the perch:content with a id="developmentName" I can also output this to the page.

BUT, the slug isn't being generated?

Here's the template for the id="developmentName" used in another part of the website:

          <perch:content id="developmentName" divider-before="Development information" type="text" label="Name of development" html="false" title="true"  />
          <perch:content id="slug" for="developmentName" type="slug" suppress="true" />

I've tried adding the id="slug" to the perch:related template - but it doesn't have any effect.

 <perch:related id="relateddevelopmentName" collection="property developments" label="Development name">
   <perch:content id="developmentName" title="true" label="Development name" />
<perch:content id="slug" for="developmentName" type="slug" suppress="true" />
</perch:related>

I've used <perch:showall /> to list all the available IDs but slug isn't listed. But it is listed where I'm using the id="developmentName" elsewhere on the website...

Hope you can help.

  • Perch Runway 2.8.13
  • PHP 5.6.10 is up to date
  • MySQL 5.5.42 is up to date
  • Image processing available
Stephen Meehan

Stephen Meehan 4 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I've very confused about that you're trying to do.

When you add an item to the property developments collection, does the slug get generated?

I'm not sure how slug generation factors into the relationship.

Hi Drew

Yes. The slug is being generated from id="developmentName" in the property developments collection.

I'm using perch:related in a different collection, pulling in id="developmentName".

This bit works, a list of id="developmentName" is displayed in the CMS and I can output the selection to the page.

The problem is with the slug. I need it as I'm using slug as part of my navigation.

I'll create a simplified demo (might help me get to the bottom of it) or at lease make it easier to explain :)

Drew McLellan

Drew McLellan 2638 points
Perch Support

You have suppress="true" set.

Hi Drew

Thanks, yes suppress="true" was set, that was stopping the slug from displaying, I also realised that everything related needs to be within the perch:related tag pair.

I have noticed something though:

When I use a regular perch:content with title="true" the item name in the CMS updates.

<perch:content id="developmentNameDEMO" title="true" label="Development name DEMO" />
<perch:content id="slug" for="developmentNameDEMO" type="slug" />

Perch CMS screenshot

But when I used perch:related the item name in the CMS isn't updated. Even though title="true" is used. It's worth mentioning perch:related is pulling in content from collection="property developments" and a slug is being generated.

 <perch:related id="relateddevelopmentName" collection="property developments" label="Development name">
  <perch:content id="developmentName" title="true" label="Development name" />
  <perch:content id="slug" for="developmentName" type="slug" />
  </perch:related>

Perch CMS screenshot

The main issue here is with the item in the CMS not updating to display title="true". This means all my items in the collection that uses perch:related look like this:

Perch CMS screenshot

Is there something I'm missing (again)? :)

Drew McLellan

Drew McLellan 2638 points
Perch Support

It's a different scope. You can't use fields from a related item to name the current item. The title needs to come from the item itself.

No worries, thanks for the reply! :)

Hello Drew,

Is a slug based on fields from a related item something that you are planning to add? It would be very convenient.

I've tried using a composite input, but it doesn't seem to work with related content either.

<perch:content id="title" type="text" label="Title" title="true" />

<perch:related id="author" collection="Authors" scope-parent="true" label="Authors">
  <perch:content id="name" type="text" />
</perch:related>

<perch:content id="fullname" type="composite" for="author.name title" />

Am I missing something?