Developer forum

Forum » Rapido » Displaying groups on page

Displaying groups on page

Ivan Marijanović
Ivan Marijanović
Reply

We have following request:

1. Prodcts are grouped in groups and each group can have subgroups. 

2. When one group is selected we need to display subgroups and only in last group in tree we need to display products

Is this possible using Rapido?

Thank you in advance!

Ivan


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

It is not possible out of the box - you need to add code to the product list template (/Files/Templates/Designs/Rapido/eCom/Productlist/ProductsRender.cshtml) to render the subgroups loop if subgroups are present instead of fetching the producst using ajax.

It is on the roadmap for the next Rapido release though.

BR Nicolai

Votes for this answer: 1
 
Ivan Marijanović
Ivan Marijanović
Reply

Thank you Nicolai

Ivan

 
Ivan Marijanović
Ivan Marijanović
Reply

Nicolai

When I try to get Groups from this page I dont get anything.

I used this code from productsGroup file:

<div class="grid grid--external-bleed-x">
 
    @foreach (LoopItem item in GetLoop("Groups"))
    {
 
        <div class="grid__col-lg-3 grid__col-md-3 grid__col-sm-6 grid__col-xs-12">
            @if (!String.IsNullOrEmpty(item.GetString("Ecom:Group.Link.Clean")))
            {
                <a href="@item.GetString("Ecom:Group.Link.Clean")">
                    <h3 class="u-no-margin">@item.GetString("Ecom:Group.Name")</h3>
                    @if (!String.IsNullOrEmpty(item.GetString("Ecom:Group.SmallImage")))
                    {
                        <img class="grid__cell-img grid__cell-img--centered b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=300&amp;height=180&amp;crop=5&amp;FillCanvas=True&amp;Compression=75&amp;DoNotUpscale=true&amp;FillCanvas=true&amp;image=@item.GetString("Ecom:Group.SmallImage")" alt="@item.GetString("Ecom:Group.Name")" />
                    }
                </a>
            }
            else
            {
                <h3 class="u-no-margin">@item.GetString("Ecom:Group.Name")</h3>
                if (!String.IsNullOrEmpty(item.GetString("Ecom:Group.SmallImage")))
                {
                    <img class="grid__cell-img grid__cell-img--centered b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=300&amp;height=180&amp;crop=5&amp;FillCanvas=True&amp;Compression=75&amp;DoNotUpscale=true&amp;FillCanvas=true&amp;image=@item.GetString("Ecom:Group.SmallImage")" alt="@item.GetString("Ecom:Group.Name")" />
                }
            }
        </div>
    }
</div>

What I am doing wrong?

Ivan

 
Nicolai Pedersen
Reply

I think you need another loop.

Try to do a TemplateTags() in the template to see what loops are there.

I think Groups loop is list of groups selected on the paragraph. SubGroups loop is list of subgroups of current group in navigation (&GroupID=G1).

BR Nicolai

 
Ivan Marijanović
Ivan Marijanović
Reply

When I put TemplateTags inside RenderPageĆontainer or RenderProductList I got only this:

Template:BaseUrl System.String /Files/Templates/Designs/Rapido/eCom/Productlist/
Template:DesignBaseUrl System.String /Files/Templates/Designs/Rapido/
Loops  

Ivan

 
Nicolai Pedersen
Reply

Ah - yes.

When a feed template is selected on the catalog app, and/or if the tag @GetValue("DoNotRenderProductListTemplate") is in the list template, the rendering of the product list in the list template is skipped - to load data from the feed instead. So that is why it will not work.

So you have to remove the @GetValue("DoNotRenderProductListTemplate") from the ProductsRender.cshtml template AND remove the feed template before the ChildGroup loop will work. But then your product list does not work...

So you need another approach. 2 options:

  1. Add the subgroups to the feed template instead and ensure that the json response contains the subgroups/childgroups information. Then in your List template you have to add a x-template in handlebars for rendering the subgroups and ensure that the data is binding to that template.
  2. Add another paragraph before the current paragraph with the product catalog app. Let that paragraph only render the childgroups (if any)

You might need some other minor changes in order to only show subgroups if present and only show products if no subgroups are present.

BR Nicolai

 
Ivan Marijanović
Ivan Marijanović
Reply

Thanx, I'll try to modify feed!

Ivan

 
Ivan Marijanović
Ivan Marijanović
Reply

Hi!

I solved the display of groups/products on page but have following issue:

On left menu where we have groups and subgroups displayed I get also listed groups that have some subgroups inside but they are all empty.

So for example I have group1 which have subgroup1 and subgroup2. In subgroup1 we have two subgroups sobgroup1_1 and subgroup1_2 and there are no products in either of them. So when user selects group1 in main window I correctly display only subgroup2 but in left menu there are both subgroup1 and subgroup2. 

How can I change this or better to say where to change how LeftNavigation_leftnav.xml is generated so I can include additional fields which can help me to decide in LeftNavigation.xslt which group to display and which one not?

Ivan 

 
Nicolai Pedersen
Reply

Not fully sure I understand your request... Have screen dump maybe?

You can deactivate groups you do not want in the navigation. Or mark them as not "Show in menu"...

There are also some settings for the navigation that might help you - check screendump. I.e. include product count so you can skip groups that has no products. comes with a small performance hit though.

Capture.PNG
 
Ivan Marijanović
Ivan Marijanović
Reply

Hi

We cannot delete or deactivate groups since they are managed in Dynamics Nav and different users can have different products displayed in groups. Also issue is that some groups dont have  products inside but have subgroups that can have products inside. Ill take a look in this options you shoved to check if I can use.

Ivan

 
Ivan Marijanović
Ivan Marijanović
Reply

Hi

We cannot delete or deactivate groups since they are managed in Dynamics Nav and different users can have different products displayed in groups. Also issue is that some groups dont have  products inside but have subgroups that can have products inside. Ill take a look in this options you shoved to check if I can use.

Ivan

 
Ivan Marijanović
Ivan Marijanović
Reply

Hi Nicolai

I looked at settings and it does not help me.

Here is image with situation:

I have group named Vario otiraci and it has two subgroups - Vario indoor and Vario Outdoor. Group Vario indoor does not have any products inside and it has two subgroups whcih do not have any products inside. So Vario indoor should not be rendered in menu. I adjusted the display on page and you can see on right side there is only group named Vario Outdoor rendered and it should be the sam in menu.

In fact I adjusted ProductListFeed and added SubGroupsCount with counts of subgroups that have products inside or which have subgroups that have products inside. But i dont have this info in LeftNavigation_leftnav.xml where the ProductCount = 0

So for group Vario indoor  I have in xml ChildCount = 2 and ProductCount = 0 and for group Vario Outdoor I have sam info ChildCount = 2 and ProductCount = 0 but for group Vario indoor total count of products in group and all of its subgroups is 0 and it should not be displayed in menu.

Like I said we have different products visible to different customers so we cannot just delete it!

Ivan

 
Nicolai Pedersen
Reply

Hi Ivan

If you use assortments and DW9.6.7+, Dynamicweb will remove groups from navigation that has no products - also taking the entire tree depth into consideration. Apart from that you only have 2 choices - change navigation and group/product structure to not be this complicated or find a custom approach to achieve the logic you require...

Sorry about the inconvenience.

BR Nicolai

 
Ivan Marijanović
Ivan Marijanović
Reply

Hi

After activation of asortments I get in sync groups displayed on main page and groups displayed in menu and it was working fine until we started using the asortments. Now I have following situation:

When user selects top level (all products) I get and display all top level groups but if we have a top level group which is in Asortments and it should not be displayed to current user on my page it is displayed since I load all top level groups so it is displayed on main page and not in menu. How can I get json feed of top level groups that are displayed to current user (included in menu). I dont have problem on second level or further where I get subgroups and can decide what to do.

 

Ivan

 
Ivan Marijanović
Ivan Marijanović
Reply

Hi 

again on this topic and I was not able to sort it out by myself.

Issue is following. I implemented view of products (product catalog app) in a way that the instead of products we display groups for each group that have subgroups and only when the last group which do not have any subgroups is selectd products will be rendered. 

It works great whenever one of groups is select because then we have loop named Subgroups and in ProductsListFeed I iterate through subgroups and generate custom collection called SubGroups which is then used to render view. When there is no selected group (user clicked on all products) I fetch all top level groups and render them.

It all worked fine untily we started to use asortments. Now everything works fine when some group is selected but when the top level (all products) page is opened all top level groups are rendered and I cannot determine which of top levele groups should not be renedered since it is part of asortments not available to current user. 

Left menu is rendered ok (without top level groups not available to current user).

Do you have any idea how to solve this?

Thank you in advance!

Sincerely

Ivan

 

You must be logged in to post in the forum