Prefilter in Widget setting

Aisling Chaud asked on April 13, 2022 05:54

Hi, I would like to explain first what I am trying to do. I have a widget named Article Widget which has a setting to select the article from content tree. But then as a user I should be able to differentiate which category they belongs to while selecting them right? Is there a way to do that from inside the widget itself?

Or is there a way that I can add one more properties for selecting a category and populating the article selector with the sorted data? I do not see any standard thing on doing this scenario. simply any way to select the article by Page selector depending on category? in widget itself? Any expert on this?

Recent Answers


Eugene Paden answered on April 18, 2022 16:31 (last edited on April 18, 2022 16:31)

your widget's model should be able to help you with that. you can add a Category property to the model and then use that Category as the filter to articles you want to display in the selection.

0 votesVote for this answer Mark as a Correct answer

Aisling Chaud answered on April 19, 2022 03:33

Hi Eugene Paden not sure how we can do it by widget model or property? Can you share me with exact Property component? or any helper code snippit? Would be a great help Thankyou!

0 votesVote for this answer Mark as a Correct answer

Eugene Paden answered on April 19, 2022 03:49 (last edited on April 19, 2022 03:50)

Can you share the code on how you are doing it now?

0 votesVote for this answer Mark as a Correct answer

Aisling Chaud answered on April 19, 2022 04:29 (last edited on April 19, 2022 06:41)

Hi, https://ibb.co/PhcpWtL
The screenshot will show my widget properties which allows to select the article but as an user i should be able to filter the article to which category they belongs to right? I am using the default category and tags for those articles.

0 votesVote for this answer Mark as a Correct answer

Aisling Chaud answered on April 19, 2022 04:34 (last edited on April 19, 2022 05:23)

This will be my Properties Model

   [EditingComponent(PageSelector.IDENTIFIER, Order = 0, Label = "Article Items", ExplanationText = "")]
    [EditingComponentProperty(nameof(PageSelectorProperties.RootPath), "/Articles")]
    [EditingComponentProperty(nameof(PageSelectorProperties.MaxPagesLimit), 3)]       
    public IList<PageSelectorItem> Articles { get; set; }
0 votesVote for this answer Mark as a Correct answer

Aisling Chaud answered on April 19, 2022 09:16 (last edited on April 19, 2022 09:31)

Hi @Kenya not sure if that is possible in Kentico13 specially as Widget Properties, I can do my custom js inject to make it work, but i do not want to do that approach. But to follow only natives provided my kentico itself.

If you have some example related my query can you show me?

0 votesVote for this answer Mark as a Correct answer

Eugene Paden answered on April 19, 2022 17:29

alternatively, you can also try extending the page selector widget and add the category property.

https://docs.xperience.io/developing-websites/page-builder-development/developing-widgets/extending-widgets

1 votesVote for this answer Mark as a Correct answer

Aisling Chaud answered on April 20, 2022 03:46

Hi @Eugene i do not think that will help, i do not want any thing inherited or extended. i just want either filterting the category inside the widget for my page selector or by creating another field for category dropdown which selected value will sort the page selector datasource.

Thanks!

0 votesVote for this answer Mark as a Correct answer

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