Show two webparts in the same real estate

Sherry Collins asked on May 12, 2015 16:49

I have a user satisfaction poll on my home page that have a start and end date on the form. When the poll is over, the end users want the poll to disappear and a free from comment box to replace it. I have created an on-line form for that purpose. I can show and hide the two web parts OK, but I need the comment box to occupy the same real estate that the poll is occupying.

Is there anyway I can do that?

Correct Answer

Rui Wang answered on May 12, 2015 22:34

In the following screenshots, you can see where the black triangle is in the properties of a web part. Then you can click on it to enter the macro and SAVE it.

Ex: if you want to swap the web part on May 15. Then you can add this to first web part {% DateTime.CurrentDateTime.Date < 15 && DateTime.CurrentDateTime.Month = 5 |(identity)GlobalAdministrator%}

I haven't test the macro but it should work.

Image Text

0 votesVote for this answer Unmark Correct answer

Recent Answers


Rui Wang answered on May 12, 2015 21:51

One out of box idea would be use the "Visibility > visible" property. Click on the black triangle and add some macro to check the date and time in order to show/hide a web part.

This way, both web parts will be stack in design view. But on the live site view, 1st one (poll) will be visible as to 2nd one (form) will be hidden. Then when the time comes, the 2nd web part will take 1st one's place when it become not visible.

0 votesVote for this answer Mark as a Correct answer

Sherry Collins answered on May 12, 2015 22:00

I am very new to Kentico, would you be able to tell me a bit more in detail what you are talking about. For example, where is the black triangle you speak of and where would I enter the macro

0 votesVote for this answer Mark as a Correct answer

Sherry Collins answered on May 13, 2015 01:00 (last edited on December 10, 2019 02:30)

Thank you for the details. I have followed your instructions and both controls are still showing from the live site.

It must be the macro. Can you take a look

{% DateTime.CurrentDateTime.Day >= 15&&DateTime.CurrentDateTime.Month = 5|(identity)GlobalAdministrator%}

For some reason it puts in a # at the end.

I am desperate for an answer.

Thanks.

0 votesVote for this answer Mark as a Correct answer

Sherry Collins answered on May 13, 2015 01:15

Nevermind, I think I got it working. I truly appreciate this. One last question, is there any chance that the date could be dynamic inside a macro?

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on May 13, 2015 14:20

Sherry, the # at the end is added automatically as it's represents a security signature generated by the CMS. So don't worry about that.

Now, for the dynamic date part. What is you idea of "dynamic"?

0 votesVote for this answer Mark as a Correct answer

Sherry Collins answered on May 13, 2015 14:39

By dynamic, I mean can I put a variable in the macro. My poll webpart has two dates the content admin can enter to say how long the poll lasts. When the poll is over they want the comments box to show. This will all be done according to the poll end date. So I need to put a variable in the macro which would represent whatever date was in the poll end date text box.

We are modifying the Intranet Portal website that comes with kentico and if you have that handy, you can look at the poll web part under Advanced Settings to see the two dates I am referring to.

Can I some how pass the value of the poll end date into the macros.

Thanks

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on May 13, 2015 17:41 (last edited on December 10, 2019 02:30)

For the Poll web part, there is a property "hide if closed", when that's checked, at least the poll will be hidden when it reaches the OpenTo time.

But there is nothing to trigger the Form webpart to be visible dynamically from the Poll. I tried to use {% WebPart.GetValue("Poll", "PollOpenTo") |(identity)GlobalAdministrator%} to see if I can get the date, but later find out the Poll webpart was created before Macro was introduced, so it won't work. You will have to customize the Poll webpart in order to expose some of those value to macro.

0 votesVote for this answer Mark as a Correct answer

Sherry Collins answered on May 13, 2015 17:43

OK. Thanks.

0 votesVote for this answer Mark as a Correct answer

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