Forum

Thread tagged as: Question, Problem

Categories entered are automatically sorting.

I'm sure it's something simple.

I have content template for a collection that has a category area. When I enter in the categories, they don't stay in the order in which I entered them, but rather sort by the base category structure (hope that makes sense). My Category is structured like:

Products

Products>SeriesA

Products>SeriesB

Services

Services>ServiceA

Services>ServiceB

If I input the categories in the template in an order like [Services>ServiceB][Products>SeriesA]

upon saving, it reorders them to: [Products>SeriesA][Services>ServiceB]

The order in which I enter a category matters to this site.

(using perch3)

Raymond Wiggins

Raymond Wiggins 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you mean on your site, or in the control panel?

Both actually.

Order Entered Order Entered

After Save After Save

Result in HTML Result in HTML

This is my category template

<perch:before><ul></perch:before>
<li style="margin-left: <perch:category id="catDepth" type="hidden" />0px;">
    <h4><perch:category id="catTitle" type="smarttext" label="Title" required="true" /></h4>
    <perch:category id="catSlug" type="slug" for="catTitle" suppress="true" />
    <perch:category id="desc" type="textarea" label="Description" editor="markitup" markdown="true" size="s" />
</li>
<perch:after></ul></perch:after>

And here is my content template

    <perch:categories id="wheelCategories" label="Wheel Pain Point Reference" set="wheel-categories" required="false">
      <perch:before>
      <h3>Wheel Pain Point Reference</h3>
      <ul>
      </perch:before>
      <li><a href="/category/<perch:category id="catPath" />"><perch:category id="catTitle" /><br>||<perch:category id="desc" /></a></li>
      <perch:after>
      </ul>
      </perch:after>
    </perch:categories>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Categories have their own order as configured in the category set. Reordering them when you select them doesn't do anything.

OK. I'll have to think of another way of customizing their order. If nested repeaters was an option, that would work - I guess I'll have to think of another way of structuring my content.

It appears Perch stores the correct order on save. But when it refreshes the control panel page - that's when the sorting happens in the UI. - then when a subsequent save occurs, it uses the sorted arrangement.

It seems that it would be useful to be able to sort the categories and have that sorting stay. Otherwise, the ability to drag the categories into different positions serves no purpose.

I did a workaround using blocks, and then use a repeat region for the category entry.

Drew McLellan

Drew McLellan 2638 points
Perch Support

You can sort the categories within the set. Then that order is applied.

Sometimes I feel like a complete idiot. Somehow the concept of <perch:related> missed my radar. I guess that's how I learn, by doing things wrong 5 times.