custom web part properties set at page level

Larry Wildey asked on November 8, 2017 17:35

I have a custom web part that uses a property to determine data displayed on the page. Currently, I am creating new page templates for each possible value of the property. The the content editors create pages with the appropriate page template.

I would like to have a more generalized page template, page type, or whatever to hold the web part and html for the page. Then the content editors can create new pages and select the type of data displayed on the page in the page creation step rather than by selecting 1 of 15 similar page templates. I have not figured out how to get a form value in a page to set the web part property but it seems like this should be something that is pretty straight forward.

Thanks for the help.

Correct Answer

Rui Wang answered on November 8, 2017 17:49

In the web part properties, try use macro like this {% CurrentDocument.GetValue("FieldName") |(identity)GlobalAdministrator%} to get value from a field in the page type (assigned to that page).

1 votesVote for this answer Unmark Correct answer

Recent Answers


Larry Wildey answered on November 8, 2017 22:54

Can a page type field be setup to query a SQL table outside of the Kentico tables? My web part currently is set up to have a dropdown with the list of possible values based on a sql query so that it isn't setup with an invalid value. If I change my webpart to get the value from the page using the field name I would need to have the field values limited to valid entries from my database table.

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on November 8, 2017 23:00

Yes, if you use the Drop Down List form control, there is an option to use SQL query to generate the list of options. Certainly, there connection to the other database would have to be available for the site.

Is the web part you are talking about a custom web part?

0 votesVote for this answer Mark as a Correct answer

Larry Wildey answered on November 8, 2017 23:05

I just went through and changed some settings on a existing page type and found that I can setup the field to be a dropdown with a SQL query so this should all work together as you described. Thanks Rui.

0 votesVote for this answer Mark as a Correct answer

Larry Wildey answered on November 8, 2017 23:07

Yes, it is a custom web part.

0 votesVote for this answer Mark as a Correct answer

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