Do the widgets belong to a page type, not a page?

Luis Youn asked on August 26, 2019 03:59

Hi there,

I am trying to develop pages and widgets with MVC in Kentco 12SP.

Once I define a page type and add a page of the page type and put some widgets into the page, it works fine.

Once I am done above, when I try to add another page of the page type, I expect that there is no widget in the page because I don't put any widget in the new page. But, the new page has all widgets that I defined in the first page, and the new page doesn't allow to add any widgets - it looks like "Preview" mode even though it's the edit mode.

My question is Is there something I missed to make the second page of the page type blank? If not, do I need to define the other page type for this?

Thanks in advance,

Luis

Correct Answer

Zoltán Jalsovszky answered on August 26, 2019 09:53

Hi Luis! Most probably you did not configure the URL Pattern of the page type correctly, so you are seeing the content of the first page even when you are trying to view the second page. How the URL pattern looks like? It should contain some macros too:

Specifying the URL pattern for content-only pages

2 votesVote for this answer Unmark Correct answer

Recent Answers


Sean Wright answered on August 27, 2019 01:06

Luis,

Widgets are associated with the DocumentID of the 'current page'.

Looking at the docs for setting up the PageBuilder functionality we can see that in order for the widgets and sections to correctly be associated with a specific Document in the tree, we need to:

  1. Retrieve that document from the database
  2. Pass the DocumentID to HttpContext.Kentico().PageBuilder().Initialize()
  3. Ensure the @Html.Kentico().PageBuilderStyles() and @Html.Kentico().PageBuilderScripts() HtmlHelper calls have been made on the page in the correct locations.

My guess is you are specifying the same DocumentID for both documents in the tree.

Something about the URL (on the MVC side) needs to uniquely identify one page from another so that you can query the correct page from the database.

0 votesVote for this answer Mark as a Correct answer

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