Assigning page template conditionally

sukhwinder k asked on August 7, 2018 16:10

Can we assign page template to a page conditionally. for example if a user is logged in then "PageTemplate_1" should be used and if user is logged out "PageTemplate_2" should be used.

Correct Answer

Peter Mogilnitski answered on August 7, 2018 16:42

Well... 2 choices come to my mind:

  1. redirection
  2. enable/disable zones in your template
0 votesVote for this answer Unmark Correct answer

Recent Answers


Peter Mogilnitski answered on August 7, 2018 16:32 (last edited on December 10, 2019 02:31)

Usually you do the opposite, you hide/show parts of the template (i.e. enable/disable zones/web parts etc) based on conditions using macros like {% CurrentUser.IsAuthenticated |(identity)GlobalAdministrator%}, secondly I don't think it is the right approach(read more).

0 votesVote for this answer Mark as a Correct answer

sukhwinder k answered on August 7, 2018 16:39

Thanks for the reply Peter, actually I need to change the complete layout of page, including header/footer (master page), so thats why I was asking to change the template dynamically rather than part of template.

0 votesVote for this answer Mark as a Correct answer

sukhwinder k answered on August 7, 2018 16:55

Thanks Peter. Really I also think that, redirection will be the best option.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.