Want to change the order for content selector

Før mig ær ønskligt att det går att bestæmma rekkefølgen på relaterat innehåll.
Tænker mig på samma måte som når man publicerar innehåll på en site i enonix 4.x.x. Dær kan man kontrollera rekkefølgen med pilar.

2 Likes

Hi! It is possible to control the order for a single input type already - what did you have in mind, could you give a use case?

At this moment I am creating a menu. I have food dishes and ingredients as contenttypes. So the dish, lets say Entrecote, have related content meat, fries, vegtables and sauce. When listing the menu I would like to controll the order of whats included. This looks strange to me:

Entrecote

  • vegtables, sauce, fries, meat

I would prefer to have:

Entrecote

  • meat, fries, saus, vegatables.
1 Like

In theory you could fix it using either a field in the content-type or a mixin with a “sequence”-number that you specify, then order by that when getting content… but not as easy as the Enonic 4 ordered/arrows approach…

Thanks but not in my case I am afraid

  • Some Pizza
    tomato sauce, cheese, ham, shrimps

  • Shrimp sallad
    cheese, shrimps …

The point is that you need cheese to appear in different orders. Maybe it fixed but that’s more complicated then it should be.

There are two solutions that works in the current version, below is an example that uses a combination of these:

Keep all ingredients in its own folder and:

  1. Use a form-item-set with with a ContentSelector that support Ingredient content inside. This has the advantage that you can add multiple form-item-sets with one ingredient in each set, and then ‘sort’ the ingredients by using drag-and-drop.
  2. Use relatedcontent ContentSelector with f.x. occurrences maximum=“99” and select ingredients in the correct order, they will be fetched in the order they are added as related content (as they appear in the list). If you want to change the order here, you will have to remove all ingredients and add them again in the correct order. A bit awkward, but pretty quick, and ok if you don’t change the order often.

I agree that it would be nice to sort relatedcontent the same way as it is possible to sort child-content in admin today, that would be a good feature to have. When having many form items in a form-item-set that take much space vertically, it is a bit hard to do sorting by drag-and-drop today.

<content-type>
<display-name>Recipe</display-name>
<form>
   <form-item-set name="Ingredients">
        <label>Ingredients</label>
        <items>
            <input type="ContentSelector" name="Ingredient">
                <label>Ingredient</label>
                <occurrences minimum="0" maximum="99"/>
                <config>
                    <relationship-type>system:reference</relationship-type>
                    <allow-content-type>ingredient</allow-content-type>
                </config>
            </input>
        </items>
        <immutable>false</immutable>
        <occurrences minimum="0" maximum="99"/>
    </form-item-set>
</form>

Also when using the solution with form-item-set, you could add amount of each ingredient like this:

<items>
    <input name="amount" type="TextLine">
        <label>Amount</label>
        <occurrences minimum="0" maximum="1"/>
    </input>
    <input type="ContentSelector" name="Ingredient">
        <label>Ingredient</label>
        <occurrences minimum="0" maximum="99"/>
        <config>
            <relationship-type>system:reference</relationship-type>
            <allow-content-type>ingredient</allow-content-type>
        </config>
    </input>
</items>

Here is an example for gluten-free ‘Runekake’, where I re-use the amount for two ingredients:

Amount: 2dl (ca 100g)
Ingredient: Solsikkefrø
Ingredient: Gresskarfrø

Amount: 3-4 ss
Ingredient: Kokosolje

Amount: litt, smak til
Ingredient: Salt

2 Likes

Hi Peter

I misunderstood your question to be related to 4.7 :slight_smile:

The short answer is that sorting for contentSelector is in the backlog - and will hopefully be included in 6.0 release this summer. For now, don’t create a workaround, just insert items in an order to make it work - and the it will be sortable with an upgrade.

3 Likes

This was included in the 6.0 release just after summer.

1 Like