Jump to content

Rule with applying color to text resources


MikeVM

Recommended Posts

Hi Techsupport,

I stuck with one (looks so simple!) rule:

I have several formatted text resources - Intro_1, Intro_2, Intro_3 - which is printed depends on field "option"

Each resource could be printed in two colors - color1 or color 2, depending on value of field "color".

So I right a rule like this:

 

if (Field("Color") == "color1")
{
   if (Field("option") == "Option 1")
          return '<color name="color1">' Resource("Intro_1");
   if (Field("option") == "Option 2")
          return '<color name="color1">' + Resource("Intro_2"); 
}

if (Field("Color") == "color2")
{
   if (Field("option") == "Option 1")
         return '<color name="color2">' Resource("Intro_1");
   if (Field("option") == "Option 2")
         return '<color name="color2">' + Resource("Intro_2"); 
}

 

What is happen - instead of getting content of the Resource everything I get just line:

 

Resource("Intro_1")

 

What I did wrong?

Link to comment
Share on other sites

What is happen - instead of getting content of the Resource everything I get just line:

 

Resource("Intro_1")

 

What I did wrong?

 

You need to use the content property of the FusionProResource object, like so:

return '<color name="color1">' + Resource("Intro_1").content;

If you're simply returning a resource from a rule, then even though the return value shown when you click "Validate" in the Rule Editor dialog is something like Resource("Intro_1"), the composition engine see that it's actually an object and uses its contents. However, if you append or prepend any text (string) to the object, then the entire return value becomes a string, and the FusionProResource object simply gets converted to Resource("name"), as part of a string containing other stuff, and there's no way to "un-stringify" it. Using the content property adds the actual content (markup) of the resource to the return value.

Link to comment
Share on other sites

I have another related question... It seems like rule works correctly, but when trying to preview template locally (on local computer) I do not see any color change whatever I enter in color tag. Text's always seen as black.

 

This is does not look like correct preview... Any suggestions?

TIA

Link to comment
Share on other sites

I have another related question... It seems like rule works correctly, but when trying to preview template locally (on local computer) I do not see any color change whatever I enter in color tag. Text's always seen as black.

 

This is does not look like correct preview... Any suggestions?

 

Try doing a full composition (not just a Preview) and look in the log (.msg) file.

Link to comment
Share on other sites

  • 2 weeks later...

Hi Dan,

 

sorry, but this is not working. :(

I use the following rule:

 

 
return '<color name="' +Rule("colorname")+ '">' + Resource(Field("company")).content;

 

colorname - changing between white and black, depending on other field.

Resource (Field("company")) - formatted text, typed in Resource editor and specific for every "company". In editor it's not set "override running paragraph formatting".

 

So whatever colorname is choosen, rule always return black text in 8.5 point size, however it should change color and be at least 12.5 pt.

 

Any help??

Link to comment
Share on other sites

colorname - changing between white and black, depending on other field.

Resource (Field("company")) - formatted text, typed in Resource editor and specific for every "company". In editor it's not set "override running paragraph formatting".

 

So whatever colorname is choosen, rule always return black text in 8.5 point size, however it should change color and be at least 12.5 pt.

Try this:

return '<span color="' + Rule("colorname")+ '">' +
   '<magnify factor=100 type=pointsize min=12.5>' +
   Resource(Field("company")).content;

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...