codefog/contao-news_categories

Make selected categories sortable

zonky2 opened this issue · 10 comments

Would it be feasible for the selected categories to be sortable - similar to the Contao gallery?

I have a picture for each category and for the first category the picture is displayed as an icon - it would be nice to be able to change the order here.

FireShot Pro Webpage Screenshot #288 - 'Nachrichten › GUTcert-News › Beiträge › Beitrag ID 2587 bearbeiten I www_gut-cert_de' - www_gut-cert_de

Doesn't it already depend on sorting of the categories?

I don't think so - the selected categories are sorted alphabetically after selection. As seen in the screenshot.

Oh, you want to change the order of the selected categories in the back end? I thought you were talking about the front end, since the image feature of a category is just for the front end.

Oh, you want to change the order of the selected categories in the back end? I thought you were talking about the front end, since the image feature of a category is just for the front end.

In the FE, I take the picture of the first assigned category and display that in the news. Currently, when multiple categories are assigned, they appear in alphabetical order. I would like to have that more individually.

Yes, I can confirm that the sort order is in fact ignored in the front end. I would also assume that the categories in $this->categories and $this->categoriesList are sorted according to that.

Your screenshot is misleading though: the sort order of the selected categories in the back end is according to the defined sorting, as far as I can tell. You should instead post a screenshot of the sort order of your categories and and a screenshot of the selected categories in the front end.

The sorting order should be individually adjustable for each news item - analogue to the picture selection in the gallery... they can also be re-sorted.

I add own file tl_news.php with

$GLOBALS['TL_DCA']['tl_news']['fields']['categories']['eval']['eval']['sorting'] = true;

And I can sort the selected items

FireShot Pro Webpage Screenshot #733 - 'Nachrichten GUTcert-News Beiträge Beitrag ID 2700 bearbeiten I www gut-cert de' - www gut-cert de

But its not possible to save the changed list... hmm??

with sorting, I can reorder the list of ids in value

  <h3><label>Kategorien</label></h3>
  <div><input type="hidden" name="categories" id="ctrl_categories" value="1,4">
  <input type="hidden" name="" id="ctrl_" value="">
  <div class="selector_container">
    <p class="sort_hint">Elemente können durch Ziehen umsortiert werden</p>
    <ul id="sort_categories" class="sortable"><li data-id="1">
...

I'm afraid there's a mistake here:

<input type="hidden" name="'.$this->strOrderName.'" id="ctrl_'.$this->strOrderId.'" value="'.$this->{$this->orderField}.'">' : '').'

I add own file tl_news.php with

$GLOBALS['TL_DCA']['tl_news']['fields']['categories']['eval']['eval']['sorting'] = true;
-$GLOBALS['TL_DCA']['tl_news']['fields']['categories']['eval']['eval']['sorting'] = true;
+$GLOBALS['TL_DCA']['tl_news']['fields']['categories']['eval']['sorting'] = true;

Not sure if that will actually have any effect though.

typo mistake... but that is not the problem but the given line in the source code

ahh... o.k. - I check the picker widget: if set orderField sortable is true