Master / Detail View

Hi!
I need to implement some sort of Master/Detail functionality.
What I have so far:

  • A Nodetype “Product” which is used in the Backend to create/update/delete Products.
  • A Nodetype “Category”.
    The “Products” get mapped to one or more “Categories” via ContentReferences.
    On the Category-Pages I want to show a list of all the Products in this category (this is already working so far).

Now I want to be able to show the Detailview of a “Product”. The intendend outcome in terms of URL-structure is as follows:

domain.org/cat-1” -> shows a list of product.
Clicking on one of the products should open “domain.org/cat-1/product-name” where I want to show the details.

I am not sure how to code this up.
Could someone please point me in the right directions?
Please.

Hey @fgrell,

basically you will need to supertype your category and your product of TYPO3.Neos:Document. So both NodeTypes are pages in your tree.
On your category you can easily fetch all products with an category set and list those. I did something similar with News/Categories here: https://github.com/johannessteu/JohannesSteu.Neos.News

In your category typoscript do something like
products = ${q(node).find('[instanceof Your.Vendor:Product]').get()}
and then render the product list in your template.

If you want the url’s to match, you must put the product nodes inside the category structure.

  • Cat (cat)
    • Product (cat/product)
  • Cat 2 (cat-2)
    • Other product (cat-2/other-product)
    • Other other product (cat-2/other-other-product)

If you want to add multiple categories to one product, permalinks will be more difficult.

Thank you both for your replies @stolle and @hphoeksma.
I have understood the basic idea of relating products to categories and listing them.
But I can’t find any information about the permalink problem. As @hphoeksma wrote

But this is my question. How would I tackle something like that. So that I am able to assign mutliple categories to one product AND have it displayed under the correct URLs.

Example:
/cat-1/product-1.html
/cat-2/product-1.html

I would have no clue :frowning:

Well basically this does not work right now. But for me it is good that it doesn’t. Because what you are going to do is generating duplicate content. The same content on different url’s is something google don’t like.
To achieve something like that you would have to adjust some RoutePartHandler or so. But i highl suggest not to do so.
What you should do is something like:

/cat-1.html
/cat-2.html
/products/product-1.html
/products/product-2.html

If you look at shop systems like magento or so they also do it like this. Another point is search: If you search for a product and the product is listed in different categories: in wich category should it point to?

So i’d suggest you to save your products node not below your categories. If you really wanna do so you have to adjust the route handling by yourself.

1 Like