Skip navigation
Currently Being Moderated

Change text colour based on text in another text box

Jul 25, 2012 1:09 AM

Tags: #grep #cs6 #data_merge

I am playing around with data merge in CS6 to layour customised artwork and I'm stuck.

 

I have the data merge working no probs, bringing in the correct artwork and the names to go on the artwork. What I cannot seem to acheive is how to get the names to change colour based on the club field i have in my data set.

 

I have the following fields:

 

@design - brings in the artwork

name - bringing in the customers name to be printed on the artwork

club - brings in the club name

 

I presume I have to apply a paragraph style to the <<name>> field to get it to change colour, I cant work out how to use a GREP style to get it to change based on the <<club>> field though.

 

Any help would be much appricated or alternative ways to do this.

 

I have around 500 records to propcess on a weekly basis so being able to automate it would be a big help.

 
Replies
  • Currently Being Moderated
    Jul 25, 2012 4:21 AM   in reply to spartansupport

    Nothing I can think of in Indesign , however you can use the Micrsosoft Excel to filter the content based on the Club name and then create sepeate CSV or Tab -delimited file and then use that for Data merge in Indesign.

     

    You can create and apply the Character style on the <<Name>> tag before merging to have the Name's in the specific color based on Club name.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 25, 2012 6:39 AM   in reply to spartansupport

    I'm not sure I understand this either, but if you add a field with a color code character to the beginning of the paragraph (this should be a character not otherwise in use), afte the merge you can do a series of find/chnage operations to find the code, apply a paragraph style with the correct color, and delete the code.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 25, 2012 8:27 AM   in reply to spartansupport

    Create a colored-text character style for each club name.

     

    Create a nested style paragraph style that applies character style None up to a club's name, then applies the club's character style through one club's name, then another None, then another club, etc. This works for club names in their own paragraphs, and also for multiple club names in one paragraph. In the example below, the paragraph style has nested-style commands for only john and paul. All the paragraphs use the same nested-style paragraph style.

     

    NOTES:

    • Nested styles are case-sensitive, so you'll need one command pair for George and george, etc.
    • The nested style commands in the example only find the first occurrence of a name. Didn't test if it's possible to find multiple occurrences of the same name in a paragraph.

     

    color data field nested style.png

     

    HTH

     

    Regards,

     

    Peter

    _______________________

    Peter Gold

    KnowHow ProServices

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2012 2:02 AM   in reply to spartansupport

    I think the OP wants to change the colour of the <<customer name>> depending on the corresponding <<team>>. For instance “Joe Bloggs” will appear in red if the team is Rovers, but “John Doe” will appear in blue if the team is Rangers.

     

    The only way I can think to fully automate that without using scripting would be if InDesign’s GREP styles are capable of selecting a paragraph based on a match in the next paragraph. In other words, select paragraph one if paragraph two contains a text string (the team). Can InDesign’s GREP styles do that?

     

    Other than pre-filtering or pre-marking the data, you could use a GREP Find/Change for each team after the data merge is done (see screenshot). This would require that both fields are in the same story, so if two separate text boxes are used in the template they must be linked and the fields separated by a return.

     

    Find_Change.jpg

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2012 5:50 AM   in reply to ja3754

    Continuing from my last post, it would be better to use a frame break (shift - enter) rather than a return to separate the fields. That way you could use oversized text frames to accommodate longer names whilst forcing the next field into the next text frame.

     

    The GREP find/change would then be:

    ~R(?=Club Name)

     

    I would create a master paragraph style for the name field, then create duplicates for each colour, making sure the duplicates are all “Based On” the master name style. Change only the Character Color in the duplicate name styles. Use the master name style to make any other changes to the paragraph’s appearance if necessary, and these will cascade down into the coloured name styles.

     

    template.jpg

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 27, 2012 10:02 AM   in reply to spartansupport

    I think it can be done with GREP styles, though I'm very weak in GREP skills.

     

    This this example has the club name before the player's name:

     

    GREP style team player2 color data field.jpg

    I burned out trying to recreate the successful example with the player name preceding the team name. I think it used a different lookaround method. Any suggestions are welcome.

     

    One problem I'm stuck on is how to make the expression that captures the player's name work with one, two, three, or more names, like first, middle, last, esq., etc. Currently there needs to be the same number of word placeholders in the GREP expression as there are words in the player's name.

     

    In this example, the bteam search fails. I moved it to another position in the GREP style dialog box, but no success. I created dteam to see if perhaps there was a limit to the number of searches. It succeeded when I deleted, then recreated, the bteam search.

     

     

    HTH

     

     

    Regards,

     

     

    Peter

    _______________________

    Peter Gold

    KnowHow ProServices

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 27, 2012 10:10 AM   in reply to peter at knowhowpro

    I haven't followed this entire thread, but

     

    >In this example, the bteam search fails.

     

    ... that's because you cannot use the ^ "Start of paragraph" marker this way. A GREP style cannot span multiple paragraphs; any attempt to do so will make it silently fail.

     

    (You are also using the ^ marker wrong. It's just a position *placeholder*. In your case it would seem it needs a '\r' return before it to make it work, which (a) would NOT work because of the single line constraint a a GREP style, but also (b) if you insert that return anyway, you don't need the placeholder.)

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 27, 2012 10:25 AM   in reply to [Jongware]

    The bteam search succeeds at the beginning of a paragraph or anywhere else, since I deleted it and recreated it in the GREP styles dialog box.

     

    I'm not using ^ start of paragraph in my searches.

     

    I'm trying to search across paragraphs, just within the current paragraph that uses the paragraph with the GREP style. Thanks for making the explicit point, though, that the team and player data items need to be in the same paragraph.

    [Jongware] wrote:

     

    I haven't followed this entire thread, but

     

    >In this example, the bteam search fails.

     

    ... that's because you cannot use the ^ "Start of paragraph" marker this way. A GREP style cannot span multiple paragraphs; any attempt to do so will make it silently fail.

     

    (You are also using the ^ marker wrong. It's just a position *placeholder*. In your case it would seem it needs a '\r' return before it to make it work, which (a) would NOT work because of the single line constraint a a GREP style, but also (b) if you insert that return anyway, you don't need the placeholder.)

     

     

    Regards,

     

     

    Peter

    _______________________

    Peter Gold

    KnowHow ProServices    

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points