Developer forum

Forum » Rapido » Accessing Loops in Model View mode

Accessing Loops in Model View mode

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I want to access a generic loop in the master page of the Rapido solution.

In the old days, I was accessing it like this: GetLoop("DWExtranetExternalLoginProviders")

Nowadays, this approach is not valid anymore.

How do I adjust it to work?

Thank you,
Adrian

 


Replies

 
Nicolai Pedersen
Reply

Hi Adrian

If you are using a viewmodel there are not tags or loops from the 'old' template world. It is either one or the other. The viewmodels are instead of template tags.

When in a master template, you are using the pageviewmodel which can be found here: https://doc.dynamicweb.com/api/html/8175ac67-de8b-696a-7436-6505c1a61e47.htm

The list of external providers is not exposed on the viewmodel, but can be accessed directly in the API:

using Dynamicweb.Security.UserManagement.ExternalAuthentication;
ProviderCollection providers = Provider.GetActiveProviders();

Be aware that GetActiveProviders will result in a database call and has no caching whatsoever. Same as with the DWExtranetExternalLoginProviders loop.

BR Nicolai

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Thank you. Any chance this loop will benefit from caching in the nearest future? For B2C this is a pretty common request and making database calls everytime we load the list of providers in the login preview, would affect the performance.

Thank you,

Adrian

 
Nicolai Pedersen
Reply

Maybe it should have. But, the loop and the feature was originally made to be on a dedicated login page and not on all pages. If you want the login feature on all pages, it is easy to cache it your self. I am not a fan though...

It might be helpful to look at how some of the champions of ecommerce does it - most of them have dedicated login pages i.e. https://www.asos.com (also with external auth), amazon and a few others.

BR Nicolai

 

You must be logged in to post in the forum