Pages Created on Backend CMS should reflect to live Frontend Site through API

Abid M. Rafiq asked on April 12, 2019 09:58

Hello, I am using Kentico MVC Development model. The issue is the pages I created a page the page alias and the page itself should reflect on my live site.

Suppose.

Back-end CMS Kentico (Page Type Tabbed Page Content)


I have a page created in back-end as About Us. with alias /about (should be editable, like I could change it to about-us)

Front-end MVC Website


I have a controller named as TabbedPageController now on my Front-end site I would like to use same page alias as kept in Backend. The URL created was domainName/{culture}/{controller}/{action}. I have availability to create a routeName but how will I know that the page created in Backend belongs to which page type.

Also another page with same page type will be created naming faq page that should also reflect with domainName/{culture}/faq but faq will not be hardcoded. Content editor will have ability to change it to frequently-asked-question.

Correct Answer

David te Kloese answered on April 12, 2019 12:46

Routing is one of the core parts of MVC. You'll have to think carefully about the strategy.

Full flexibility (all URLs on all page types) will be hard to maintain.

You could look into something like: https://stackoverflow.com/questions/16026441/dynamic-routes-from-database-for-asp-net-mvc-cms

Which let's you create a catchall kinda route that you verify against some logic.

In case you give the editor the option to create/adjust the "URL pattern" property, keep in mind it isn't verified to be unique for all page types in Kentico for MVC.

2 votesVote for this answer Unmark Correct answer

Recent Answers


Abid M. Rafiq answered on April 17, 2019 13:37

I appreciate your answer/idea. Thank you for quick response.

In case you give the editor the option to create/adjust the "URL pattern" property, keep in mind it isn't verified to be unique for all page types in Kentico for MVC.

So is it something like against the standard of Kentico MVC?

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on April 18, 2019 10:41

By default Kentico doesn't check over page types...

It assumes logic like :

  • page type person, url /people/violet
  • page type flower, url /garden/violet

if you leave the url patern free and just use node name its in possible to have 2 pages that both have a url of /violet


what you could do is add a global event handler: docs.kentico.com/k12/.../handling-global-events

In the document Insert and update events (docs.kentico.com/...#Reference-Globalsystemevents-DocumentEvents)

you can have some custom logic to check if the url is taken or not and refuse the page saving if it's taken.

0 votesVote for this answer Mark as a Correct answer

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