Developer forum

Forum » Templates » Multiple Product Lists, Navigation Tag, Breadcrumbs and URL

Multiple Product Lists, Navigation Tag, Breadcrumbs and URL

Stephen Jackson
Reply

Hello.

We are developing a site, where we wish to align the urls / breadcrumbs with the path to the product we are clicking from the product list.

e.g

http://site/webshop/toys/ (product list with groupid param set to toys group)

http://site/webshop/tools (product list with groupid param  set to tools group)

When clicking on a product in these product list, they will always want to go to the "SHOP" navigation tag, due to this being hardcoded in the swift template.

For us, this will redirect all clicks to http://site/products/toys/toy-id  etc, which we dont want

I therefore modified the productlist item_type and added a NavigationTag field, and use it in the following manner in the product-list template (see futher down page). This results in the correct links being generated e.g http://site/webshop/toys/bear-12, but clicking through just results in a blank page.

I have double checked that the Primary Details Page is set for these groups (both in the PIM and in the Ecommerce group settings), and in the product details page, I have set the Products page to the relevant products list page. So I dont understand what more I am doing wrong.

var navigationTag = "SHOP"; //Default to Shop, which is Swift default

if (Model.Item.GetString("navigationTag") != null) {
    navigationTag = Model.Item.GetString("NavigationTag").ToString();
};

foreach (ProductViewModel product in productList.Products)
{
    var defaultGroupId = product.PrimaryOrDefaultGroup.Id;
    var selectedDetailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(defaultGroupId)?.Meta.PrimaryPage ?? string.Empty;

    string link = product.GetProductLink(GetPageIdByNavigationTag(navigationTag), false); //This renders correctly, but clicking it takes us to a blank page.. no product details

 

On an side note, I think the changes I have made here should def be included in the standard Swift template. Its a bit restrictive with only one navigationtag


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Stephen,

 

We have similar needs every now and again, and have come up with multiple different solutions.

  • Do you only need multiple product lists because of the URL?
    If so, you don't need to do it like that. You can simply set the Products page 
    https://app.screencast.com/o9UyqSzKCidM5
     
  • Do you need to have a menu with a mix of content pages and groups?
    i.e. "Home  |   Toys   |   Tools   |  Contact Us"
    If so, then you can create menu similar to footer and have pages to point to the "Products" page
    https://app.screencast.com/ZiZfDkpIyeJJt
     
    • Do you need to dynamically get the subgroups of a ecom group?
      i.e. "Home  |   Toys   |   Tools   |  Contact Us"
      But then for "Toys" and "Tools" you want to list the subgroups dynamically, instead of having to select the groups
      If so, you can make an adjustment to the menu templates to "skip" 1 level
      https://app.screencast.com/Msl39zkUJR65C
       
  • Do you need to have different layouts/components for each product list?
    This is where you really need to customize (sort of how you're doing it)
    We haven't yet explored the solution; we know you still need a generic product list though, because of the search results list. That could be an argument with your customer why using a single product list should be enough. That said, I know that's not always the case

 

Let me know what your use case is. Maybe I can help a bit more.

 

Best Regards,

Nuno Aguiar

 
Stephen Jackson
Reply

Hi Nuno

Yes we only want multiple product lists because we want to place these lists in specific areas of the site, and we dont want to redirect to /products all the time. We want the URL to be consistent i.e http://site/section/productlist/productinfo

Such that the breadcrumbs will also be

Section -> ProductListName -> ProductInfo

Do you mean this is easy to implement without messing with the template?

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Stephen,

 

I am assuming that "Section" is a page (not an ecommerce group) is that accurate? In that case your URL requirement is making your life hell :) How strict is that requirement?

 

The problem is that you're also duplicating setups and adding custom code, growing how error prone this solution is for the sake of the URLs. Is that really worth it?

If it is a hard requirement, then I guess I'd have to see the site to understand why the page is turning out blank. Have you confirmed which page ID is really being pulled? And/or validated the generated URL to see if you have all of the proper parameters? And have you customized all of the templates that generate URLs already?

 

//Nuno

 
Stephen Jackson
Reply

Hei Nuno. Yes it is a page. And in that page, we link to several product lists (each filtered by group), which in turn have custom details pages for that type of product.

I am glad to hear you say "hell", cos today was exactly that. I spent way too much time trying to figure this out, and ending up with URLS like   /section/productlist/toys/details/toys/EAN-27262722 for example

For the record, the page is no longer blank. But the URL looks awful, and breadcrumbs look like a nutcase made them. When I have the URL i want... for example /section/toys/EAN-232322323  then the page is blank. I have tried every combination of URL configs and levels, with or without navigation tags etc, but none result in the correct URL and a proper details page :(

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Stephen,

 

It's hard to help more without looking into the setup in the backend. In my mind I still think this setting could help https://app.screencast.com/o9UyqSzKCidM5 on the productlist and maybe on the details pages from the URL, but I really don't know. It does look like odd URLs.

 

To me it sounds like you are trying a very unrecommended approach of a setup, trying to please the URL requirements. That will certainly make it hard on you, not just for the initial setup, but maintenance and support.

 

But then again, only after looking at the setup in more detail would I be able to help more. Maybe someone else here in the Forum could help as well.

 

//Nuno

 
Stephen Jackson
Reply

Unfortunately I cannot show you the site as its in development for a customer, but I think if I cannot get it to work in a sensible way then I will see what we can do about the need to have these URL's this way, yes

 

You must be logged in to post in the forum