How to add extras to Widgets

Majed Alomary asked on February 16, 2020 19:59

Hello

How do I add poll to the Widgets? in kentico mvc 12

Recent Answers


David te Kloese answered on February 16, 2020 22:20

Hi,

unfortunately there is no out-of-the-box example for using Kentico Polls in MVC widgets.

You'd have to create your own custom widget: docs.kentico.com/.../developing-widgets-in-mvc

You can use the 'Portal Engine' Poll Widget code as an example on how to interact with the Kentico API.

You can find this code in "CMSWebParts\Polls\Poll.ascx.cs"

or look at the online API documentation docs.kentico.com/api12sp/.../polls

0 votesVote for this answer Mark as a Correct answer

Majed Alomary answered on February 17, 2020 07:42 (last edited on February 17, 2020 08:42)

Portal Engine is web form and im using MVC is there any other solution i want something like this in MVC 12

How to Create Polls in Kentico 12 The Design Tab and Zone does not show to me

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on February 17, 2020 11:15

Hi, yes the example in your link and the code in "CMSWebParts\Polls\Poll.ascx.cs" is aimed for Portal engine!

YOU need to create your OWN CUSTOM MVC widget or control.

However you could still use it's code as an example on how to interact with the API!

the Portal Engine widget actually uses the following control: "CMSModules\Polls\Controls\View\PollView.ascx.cs"

I think you are looking for the following API calls:

getting POLL info:

PollInfoProvider.GetPollInfo(PollCodeName, PollSiteID, PollGroupID);

getting answers

PollAnswerInfoProvider.GetPollAnswers()
    .Columns("AnswerID, AnswerText, AnswerCount, AnswerEnabled,
        AnswerForm, AnswerAlternativeForm, AnswerHideForm")
    .WhereEquals("AnswerPollID", pi.PollID);

setting a vote

    PollAnswerInfoProvider.Vote(answerID)
0 votesVote for this answer Mark as a Correct answer

Michal Samuhel answered on February 17, 2020 14:04

Also be careful about using polls as we will be removing whole module to next version per article here on devnet. With approach David is suggesting, you can go as well with custom page types of module classes to hold data on polls and answers.

0 votesVote for this answer Mark as a Correct answer

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