Dotclear

Vous n'êtes pas identifié(e).

Annonce

13 février 2024 Sortie de Dotclear 2.29

#1 2014-12-23 09:39:45

jarekb
Membre
Inscription : 2014-09-06

Different sorting for different categories

Hello Friends,

I'm building new website using Dotclear (yes, i like it!).

There are different types of posts. Some of them are landing in "News" category and they should be sorted by date, the newest ones first. Another ones should go to "Products" category and they should be sorted alphabetically in ascending order.

Category.html template part i've prepared, now looks like that:

 <tpl:Entries no_content="1">
    <tpl:EntriesHeader>
      <tpl:Pagination>
        <tpl:PaginationIf end="0">
        <link rel="prev" title="{{tpl:lang previous entries}}" href="{{tpl:PaginationURL offset="1"}}" />
        </tpl:PaginationIf>

        <tpl:PaginationIf start="0">
        <link rel="next" title="{{tpl:lang next entries}}" href="{{tpl:PaginationURL offset="-1"}}" />
        </tpl:PaginationIf>
      </tpl:Pagination>
    </tpl:EntriesHeader>
    <link rel="chapter" href="{{tpl:EntryURL}}" title="{{tpl:EntryTitle encode_html="1"}}" />
  </tpl:Entries>
    
   <tpl:Entries category="News" sortby="date" order="desc">
      <tpl:EntriesHeader>
      <tpl:Pagination>
        <tpl:PaginationIf end="0">
        <link rel="prev" title="{{tpl:lang previous entries}}" href="{{tpl:PaginationURL offset="1"}}" />
        </tpl:PaginationIf>
        <tpl:PaginationIf start="0">
        <link rel="next" title="{{tpl:lang next entries}}" href="{{tpl:PaginationURL offset="-1"}}" />
        </tpl:PaginationIf>
      </tpl:Pagination>
    </tpl:EntriesHeader>
    <link rel="chapter" href="{{tpl:EntryURL}}" title="{{tpl:EntryTitle encode_html="1"}}" />
    </tpl:Entries>
  
    <tpl:Entries category="Products" sortby="title" order="asc">
    <tpl:EntriesHeader>
      <tpl:Pagination>
        <tpl:PaginationIf end="0">
        <link rel="prev" title="{{tpl:lang previous entries}}" href="{{tpl:PaginationURL offset="1"}}" />
        </tpl:PaginationIf>

        <tpl:PaginationIf start="0">
        <link rel="next" title="{{tpl:lang next entries}}" href="{{tpl:PaginationURL offset="-1"}}" />
        </tpl:PaginationIf>
      </tpl:Pagination>
    </tpl:EntriesHeader>
    <link rel="chapter" href="{{tpl:EntryURL}}" title="{{tpl:EntryTitle encode_html="1"}}" />
</tpl:Entries>

Unfortunately it doesn't  work... The posts in categories are still sorted by date.
What did i wrong?

I would be glad for any suggestions.

Hors ligne

#2 2014-12-23 10:55:37

Philippe
Stagiaire
Lieu : Toulon
Inscription : 2004-06-13
Site Web

Re : Different sorting for different categories

You should use CategoryIf behavior

<tpl:CategoryIf url="News">
   <tpl:Entries sortby="date" order="desc">
   --- here goes the entries loop ---
   </tpl:Entries>
</tpl:CategoryIf>

<tpl:CategoryIf url="Products">
   <tpl:Entries sortby="title" order="asc">
   --- here goes the entries loop ---
   </tpl:Entries>
</tpl:CategoryIf>

etc.

Hors ligne

Vous n'êtes pas identifié(e).

Pied de page des forums

Sites map