ADX STUDIO - setting the default home page for a specific portal user.

I have two kinds of users in my portal, customer user and agent user. I want it every time he logs in or clicks the home button on the website, instead of the default client home page. Ru (Agent Home Page) Currently I was able to achieve this with the code below:

var userId = AuthenticationManager.AuthenticationResponseGrant.Identity.GetUserId();
var user = await UserManager.FindByIdAsync(userId);

var portal = PortalCrmConfigurationManager.CreatePortalContext();
var usercontext = portal.User;
var context = portal.ServiceContext;
var contact = (from c in context.CreateQuery("contact")
               where c["contactid"].Equals(userId)
               select c).First();
var isAgentUser = contact.GetAttributeValue<bool>("bh_isagentuser");

if (isAgentUser == true)
{
    return Redirect("/agent-home");
}
else
{
    return RedirectToLocal(returnUrl);
}

      

I want to know if there is another workaround for ADX studio to achieve this?

+3


source to share


1 answer


Instead of being redirected to another web page, you can change the information displayed on the home page based on the type of user detected. A simple example of using Liquid would be to include a different web template depending on the type of user:

{% if user.bh_isAgentUser %}
  {% include "Agent Home" %}
{% else %}
  {% include "Default Home" %}
{% endif %}

      

You would add different home page rendering logic to each of the " Agent Home

and" web templates Default Home

Agent Home

.



The above liquid can be pasted into the box to copy the home page, or the home page can be modified to use a web template with this liquid inside. This choice will depend on the structural elements of the displayed web page that need to be changed.

See the documentation on user object , include tag and web templates for more details.

0


source







All Articles