Skip to main content
Known Participant
August 10, 2022
Answered

Show/Hide certain elements on page, when certain text is visible in specified area

  • August 10, 2022
  • 3 replies
  • 1703 views

I have another query, if anyone can help me? 🙂

 

Is there any way in inDesign to show/hide certain specified elements on the page, if a certain word in another element is present?

This topic has been closed for replies.
Correct answer Laubender

@KuriousKatie asked: "Will this work if I add more things to that group, as in the grey box and the description below?"

 

Hi @KuriousKatie ,

you did another thread where you asked a similar question:

 

Show/Hide a group of items based on whether a word from a data merge is present in that group.
KuriousKatie, Aug 16, 2022

https://community.adobe.com/t5/indesign-discussions/show-hide-a-group-of-items-based-on-whether-a-word-from-a-data-merge-is-present-in-that-group/td-p/13138760

 

From your posted csv file there I can see that the first entry of e.g. Oestradiol is simply none.

So Brian's first[*] script will not work on a merged document with that data. The problem is to find a sufficient algorithm that could react on e.g. a group with that entry set and turn the whole group to invisible.

 

Also related is this thread you started in Aug 01, 2022:

 

Conditional Formatting to shapes from CSV text
KuriousKatie, Aug 01, 2022
https://community.adobe.com/t5/indesign-discussions/conditional-formatting-to-shapes-from-csv-text/td-p/13108461

 

Here the link to my post where I am presenting a solution based on the "Conditional Formatting" thread:

 

https://community.adobe.com/t5/indesign-discussions/show-hide-a-group-of-items-based-on-whether-a-word-from-a-data-merge-is-present-in-that-group/m-p/13140217#M488700

 

Regards,
Uwe Laubender
( Adobe Community Professional )

 

[*] Edited. Did not see all the answers that were posted the last two hours.

Forum notification via mail failed.

3 replies

LaubenderCommunity ExpertCorrect answer
Community Expert
August 17, 2022

@KuriousKatie asked: "Will this work if I add more things to that group, as in the grey box and the description below?"

 

Hi @KuriousKatie ,

you did another thread where you asked a similar question:

 

Show/Hide a group of items based on whether a word from a data merge is present in that group.
KuriousKatie, Aug 16, 2022

https://community.adobe.com/t5/indesign-discussions/show-hide-a-group-of-items-based-on-whether-a-word-from-a-data-merge-is-present-in-that-group/td-p/13138760

 

From your posted csv file there I can see that the first entry of e.g. Oestradiol is simply none.

So Brian's first[*] script will not work on a merged document with that data. The problem is to find a sufficient algorithm that could react on e.g. a group with that entry set and turn the whole group to invisible.

 

Also related is this thread you started in Aug 01, 2022:

 

Conditional Formatting to shapes from CSV text
KuriousKatie, Aug 01, 2022
https://community.adobe.com/t5/indesign-discussions/conditional-formatting-to-shapes-from-csv-text/td-p/13108461

 

Here the link to my post where I am presenting a solution based on the "Conditional Formatting" thread:

 

https://community.adobe.com/t5/indesign-discussions/show-hide-a-group-of-items-based-on-whether-a-word-from-a-data-merge-is-present-in-that-group/m-p/13140217#M488700

 

Regards,
Uwe Laubender
( Adobe Community Professional )

 

[*] Edited. Did not see all the answers that were posted the last two hours.

Forum notification via mail failed.

brian_p_dts
Community Expert
Community Expert
August 10, 2022

Need some more specifics, but this rudimentary function would find a phrase in all top-level text frames on the doc's first page, and, if found, toggle off a specific top-level page item on the page. Note if you have grouped/anchored objects to toggle, this doesn't work. 

 

var page = app.activeDocument.pages[0];
var tfs = page.textFrames.everyItem().contents.join(" ");
if (/lorem ipsum/g.test(tfs)) {
    page.pageItems.itemByName("someframe").visible = false;
}

 

Known Participant
August 16, 2022

Basically, I have a file pulling data from a CSV, and I want to know if there is a way to show/hide the 'oestradiol' title circle and description text, if the text within the coloured circle is "noprostate". The text within the coloured circle used a grep style that displays red/green based on whether the field says 'safe' or 'unsafe'.

 

I've attached a mock file of what I mean, if someone can look over it to help me out?

 

Hopefully what I'm explaining I need makes sense?

 

brian_p_dts
Community Expert
Community Expert
August 16, 2022

Assuming the title and text circle are grouped, then you could do something like this, adapting my code from above:

 

var pis = app.activeDocument.allPageItems;
var n = pis.length;
while(n--) {
try {
if (/noprostate/g.test(tfs)) {
    pis[n].parent.visible = false;
} catch(e) {//not a text frame probably}
}
}
John Mensinger
Community Expert
Community Expert
August 10, 2022

You can make bodies of text "conditional," but what you describe doesn't seem to fit that. Even if you could make (the) InDesign (editing space) actively hide/display certain elements based on the presence or absence of a particular word, it would only be of workflow benefit, and not necessarily active in the deliverable end product. For that, in PDF, you could use Acrobat Javascript to show/hide "fields" based on the value of another given field.