Widget visibility with macro expression

Ozgur Ozguven asked on November 9, 2016 17:15

Hello

My users want to be able place widgets on a page and make it visible from a certain date in the future. Similar to Publish From field available for pages.

I was hoping this would be easy to set up by exposing the the Visible property in the Widget UI but it turns out that macro statements are not allowed on widgets.

I think this is a fair request but I don't want code changes. Is there an easy way that I am not aware of? Any suggestions and recommendations are welcome.

Many thanks Oz

We have Kentico v8.2.48

Recent Answers


Zachary Perry answered on November 9, 2016 17:40

You are correct that widget's do not allow macros from the front end, but you can still set them in the properties on the backend. This probably wouldn't help to much since it seems you want the macro to change.

I am not 100% sure it would work, but you could try creating a new field on the widget that takes a date that the users can set, then in the backend for the visibility set a default macro that will check this new field and determine if the visibility should be on or off.

0 votesVote for this answer Mark as a Correct answer

Anton Grekhovodov answered on November 9, 2016 17:47

Hi,

You can add macro expression into default value for 'Visible' property: Image Text

Enter your macro in popup window: Image Text

Disadvantages:

  • it will work only with new widgets on a page.

  • all widgets will have the same visibility condition, so they will be visible at the same time.

I think it will be better to change the code and create another visibility field as Zachary said, but maybe this solution help you.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on November 10, 2016 14:42

Hi,
You can also take a look at this article. It was made for Kentico 7 but the idea should be very similar - so you can use it as an inspiration.

0 votesVote for this answer Mark as a Correct answer

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