Hide repeater

Sathish Kannan asked on May 9, 2016 18:22

Hi,

I have page template ABC and this has 10 repeaters web part. I'm using this page template globally for 10 pages and I have to show one repeater for one page and hide others.

How to do this, any suggestions?

Correct Answer

Trevor Fayas answered on May 9, 2016 22:18

You can indeed put a macro in the Visibility, just click the black > arrow next to the field on almost all Kentico webpart/widget fields to allow you to enter a macro to resolve.

Another option is to use Kentico categories, you can make it visible if a page has a certain category, but still same principle as what others have posted.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Zach Perry answered on May 9, 2016 18:30 (last edited on December 10, 2019 02:30)

If you were going to go in and manually hide the web part for each page, what criteria would you use? Page name? If so, in the visibility on the web part just build a macro using that criteria {%CurrentDocument.DocumentName == "NameOfDocumentToShowOn"|(identity)GlobalAdministrator%}

0 votesVote for this answer Mark as a Correct answer

Sathish Kannan answered on May 9, 2016 18:50

Thanks for your answer.

I have tried your solution but it is not working.

Hierarchy is here,

Page ABC --> Has page template ABC and has repeater Sub1, Sub2 and Sub3 -- Sub1 --> child and has repeater Sub1, Sub2 and Sub3 -- Sub2 --> child and has repeater Sub1, Sub2 and Sub3 -- Sub3 --> child and has repeater Sub1, Sub2 and Sub3

Now when I navigate to Sub1 from ABC (through browser)I just want to show Sub1 and hide SUb2 and Sub3

Please suggest

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on May 9, 2016 19:37

I'd try to have one repeater and alter what it shows (set a dynamic path macro, etc.) instead of having 10 and hire/show some of them. This might not be possible in your case, but...

2 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 9, 2016 19:59

If you must have multiple repeaters on a template then use the hide on sub pages and show for page type filters. They will help considerably in addition to what Roman suggests. You can also set dynamic path expressions.

1 votesVote for this answer Mark as a Correct answer

Sathish Kannan answered on May 9, 2016 20:49 (last edited on May 9, 2016 22:04)

I have 10 repeaters to get 10 different set of data. I have already tried using "show for page types" and "hide for sub pages" filters but they are different way than what I need.

Any other suggestions please

Is there any way to write macro condition in visibility to check the current url and match. For example Sub1 will be displayed only if the macro condition is true

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 9, 2016 22:23

Sathish, how is the data different? Are they different page types? Different locations? Different page tags? Categories? How are they different?

0 votesVote for this answer Mark as a Correct answer

Sathish Kannan answered on May 9, 2016 22:25 (last edited on December 10, 2019 02:30)

I did it by writing macro condition in visibility.

Here it is {% Contains(CurrentDocument.AbsoluteURL, "Sub1") |(identity)GlobalAdministrator%}

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 9, 2016 22:44

So to help others, how is the data different? Are they different page types? Different locations? Different page tags? Categories? How are they different?

0 votesVote for this answer Mark as a Correct answer

Sathish Kannan answered on May 9, 2016 23:23

It is different because I have "WHERE" condition in "Content filter" specific to each repeater to retrieve documents depends on the condition and document name given.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 10, 2016 04:05

Can you give an example of a few repeaters WHERE conditions? I'm not stating they aren't different, just trying to really find out how. There could totally be a different way to go about this aside from having 10 repeaters on a template. I've worked with Kentico for over 8 years and haven't had a need to ever use 10 repeaters on one template to filter out like or similar content.

0 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on May 10, 2016 11:52

Hi Sathish,

I agree with Brenden here, I have never felt a need to use these many filters only because if the reason is where condition.

In stead of telling that you want to hide repeaters, could you please explain your entire scenario of what you are trying to achiever using queries. I am more interested in use case.

Thanks, Chetan

0 votesVote for this answer Mark as a Correct answer

Sathish Kannan answered on May 10, 2016 14:01 (last edited on December 10, 2019 02:30)

I'm just a beginner to Kentico and it would be thankful if you assist me to do this in right way. Here is my sample "WHERE" condition in repeater,

typeofdocument LIKE '%sub1documents%' AND documentsubs1 LIKE '%{%CurrentDocument.Parent["NameOfParentMenu"]|(identity)GlobalAdministrator%}%' And this is different for different Subs

Also these has different HTML wrappers ("HTML Envelope in properties") specific to repeater

Any efficient way to do this, suggestions are welcome

0 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on May 10, 2016 14:49

Hi Sathish, Apologies, It's difficult to understand through the query. Would you mind sharing the business problem you are trying to solve. What I meant is client's requirement. Thanks, Chetan

0 votesVote for this answer Mark as a Correct answer

Sathish Kannan answered on May 10, 2016 14:57 (last edited on December 10, 2019 02:30)

Sure. Assume I'm developing restaurant web site and I have a image with text like "Chinese veg food", "Chinese non-veg food", "Malaysian veg food",etc., Now when I click on "Chinese food menu" it takes me to the new page contains all the documents in PDF format related to Chinese food.

So, the query in WHERE condition is

typeofdocument LIKE '%veg food menus%' AND documentregions LIKE '%{%CurrentDocument.Parent["Chinese"]|(identity)GlobalAdministrator%}%'

And this results will be wrapped with specific region image on top of the documents.

Will this help you to understand

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 10, 2016 20:15

Where are these PDF documents stored? It might be best to store them in the content tree so you can apply taxonomy on them (tags, categories, etc.) Then you can have one repeater which is dynamic enough to get the documents based on a category or page in the content tree. For instance something like

  • /menus/chinese
  • /menus/japanese
  • /menus/korean

The values after /menus can be physical pages OR they can be dynamic querystring values (without the ugly querystring look).

0 votesVote for this answer Mark as a Correct answer

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