0

We want a div on an ExactTarget landing page to reflect a background color defined in a Data Extension. My thought process includes setting a text field with the color code and then using an AMPscript variable in the style sheet such as:

{... background-color: %%=v(@clientColorPref)=%%; ...}

This doesn't appear to be working so while we can simply create the style inline I am curious to know if it simply doesn't work to post AMPscript variables in a .css file (which is also built as a an ExactTarget landing page) or if something special needs to be done to see or review it.

I was certain to post the variable on the html page PRIOR to the link to the style sheet knowing that the order of calls would be critical. As stated I am obtaining a similar result using an inline style on that element to keep all of the code within the HTML file but would prefer to maintain styling of DOM elements on the remote page.

1

What you are trying to do is certainly possible as I have done something similar.

IF that is your exact code, then the problem is you are missing an "@" on your variable, should read:

{... background-color: %%=v(@clientColorPref)=%%; ...}

The way to do it would be:

  1. Create an ampscript block at the top of the page.

  2. Do your DE lookup.

  3. Set your AMPscript variable to the desired field.

  4. Use the "v()" operation in your actual script.

Hope this helps.

|improve this answer|||||
  • Tim - I updated the code/script above. I'll see if that was the issue I was facing. Are you suggesting that the DE lookup (ampscript block) takes place within the .css file or just to be sure it's above the css link on the landing page? – Jonny Shaw May 27 '14 at 20:20
  • Are you linking to an external CSS? I'm not sure that would work, but it might. I was assuming inline CSS on the same LP. You would have an AMPscript block on the top of that page to populate @clientColorPref, and use that in your inline CSS. – Timothy May 28 '14 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.