Search

It's been a long time since I've used Symphony but a client recently came back with a request re:product ordering. I can't figure out the best way to do this:

We have Products that are in one or more Categories. The site lists these products per category: /products/<category>/ The products are ordered DESC by ID: so the newest Product appears on top.

Now they wish to have more control over the ordering (across Categories)...

Say Product Milk is in Category Drinks and Healthy. In Drinks, Milk should be on top of the list, but in Healthy somewhere in the middle…

Assuming Milk is our newest Product it will currently appear on top of both Categories.

Since, in our case, the categories are limited (3) – and will not quickly change – I could add a new field to the Product: order-cat-healthy and order-cat-drinks, etc but this seems nastly.

Any tips?

Update I realize the ordering could probably be done in the XSL (with the Muenchian Method?) - The bigger challenge, I believe, is how to handle this in the UI…

well, you could use sort

<xsl:for-each select="products/entry">

 <xsl:if test="category = 'drinks'"> 
       <xsl:sort select="drinks"/>
</if:xsl>

 <xsl:if test="category = 'healthy'"> 
       <xsl:sort select="healthy"/>
</if:xsl>

  item markup
</xsl:for-each>

and to give more control to the client, you should install http://symphonyextensions.com/extensions/order_entries/

to order categories and in your data sources use ORDER BY category

Thanks cotiunix, but I don't see how xsl:sort allows me to order Products within categories (I don't need to order Products by categories since they're on a category page)

On the category page /products/drinks I need to list all Products in the category drinks and order them according to some ordering. On a different page (say /products/healthy) I need to be able to list the same products (when in both cats) but order them differently.

Say Product Milk is in Category Drinks and Healthy. In Drinks, Milk should be on top of the list, but in Healthy somewhere in the middle…

Since, in our case, the categories are limited (3) – and will not quickly change – I could add a new field to the Product: order-cat-healthy and order-cat-drinks, etc but this seems nastly.

Sadly, for highly custom ordering like that, you will need a custom field per category to explain where it should lie in each datasource, and then have each datasource sort by that field.

Somewhat like I explained in the text you quoted you mean? How do I need an extra field per category then? I assumed I need to add multiple category-order fields per Product?

Yeah, a field in the Products section, one per Category, like you said:

order-cat-healthy
order-cat-drinks

Same way, different explanation ;)

bummer ;)

Or you could abstract it out into another section, choosing the product, category, and then define the order. But then you would need to chain datasources.

It's always a tossup between ease of authoring versus normalisation. I'm the kind of arse that would do the abstracted way :D

Just to clarify my above post...

Having an intermediary section is actually a good idea. It will need an SBL for both Product and Category, and a text input for the Order.

You can have a datasource as a primary for the filtering, using that section and filtered by the $category url-parameter. Make sure it outputs the Product as a ds-parameter. Order it by the Order field.

Now you can filter your product list by the ds-param output by the other datasource, and use the previous ds for ordering your products!

even easyer .. make category field type tag. then you can assing custom order of given tags; so the order of them give the weight.

par example:

we have these tags/category: food, drink

product1 category: drink, food product2 category: food, drink

then you can order by this in the frontend. it should work

@cotiunix thanks for your suggestion. I don't think this will work though since I need exact control over the order. So, e.g., I need to define Product1 as nr 4 under Food and nr 2 under Drinks.

I think I'll need to go with @designermonkey's suggestion and build an intermediary Section. I'm not exactly sure how my datasources need to be set up but I'll figure it out I guess ;)

Thanks both!

David, if you need extra help on that, I can spare some time, just give me a shout on Twitter :)

Thanks John, I'll let you know when I get stuck

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details