Changing textcolor driven by database

Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Changing textcolor driven by database

Viewing 10 reply threads
  • Author
    Posts
    • #91966
      Steven Himpe
      Member

      Maybe a simple question, but I can’t find it.
      Imagine I would like to make business cards with first and last name. Depending on Male of Female I would like to change the color of the variable firstname from blue to red. The gender is also in the database.
      Can someone explain me how to do this ?

    • #91967
      David Blatner
      Keymaster

      Are you creating the cards with Data Merge? One idea would be to put the variable or the color on the same paragraph as the name. So it would come in as something like “Male:Steven Himpe”. And set up the template so that it comes in with a paragraph style that has a GREP style in it… and the GREP style could make the word “Male:” disappear (apply a character style that makes that text 0.01 pt large and a color of None) and then make the first word after “Male:” the color you want (again, with a character style).

    • #91968
      Steven Himpe
      Member

      Sounds complex, but I’ll try to read some more about GREP styles. This seems to me a simple question but not so simpel te do. :)

      Thanks anyway.

    • #91969

      I imagine this could be scripted…not be me, but by someone who actually knows how to script in ID…

      If I were doing this as a merge, I would just use Em Software’s InData as it can do this without needing to hide anything. One would write the merge script to allow for the two conditions and use the appropriate character style and at the merge it just happens. InData also has far greater utility for merging than just for something like this and if you do merging much, take a look at it.

      Mike

    • #91970
      Loic Aigon
      Member

      No need for scripting specifically. This can be achieved with a grep style.

      All you have to do is use a character as a “fill” character. Its fill color will be related to the gender.





      HTH

      [EDIT] Well I thought the [img] tag would make the images to be loaded but it doesn’t seem to be the case.

      Loic

    • #91975
      David Blatner
      Keymaster

      Loic: I think it was because the image service URL you used looked like a png, but it was actually an html/php file that pointed to a png. Tricky! I fixed the urls for you. :-)

      For readers: Loic’s idea is that you just insert a HUGE black rectangle character (a glyph that looks like a black rectangle) in a text frame and then change the color of that whole paragraph (including the based on the first character. The rectangle is so big that it fills the whole page, I guess. Interesting!

    • #91976
      Loic Aigon
      Member

      Hi David,

      Thanks for the fix and precisions. I should have given more details indeed. I don’t claim it’s how I would do it. As an EasyCatalog pro, I would advice differently but I thought it was interesting to share the trick anyway.

      Loic

    • #91977
      Steven Himpe
      Member

      Thanks a lot Loic & David !!!
      I know what to do next weekend :)

    • #91996
      Loic Aigon
      Member

      In the meanwhile no one saw the musical reference :(

    • #92000
      David Blatner
      Keymaster

      Um… James Brown?

    • #92003
      Loic Aigon
      Member
Viewing 10 reply threads
  • You must be logged in to reply to this topic.
>