Change background based on value

Hi folks,

We’re using Planet Press to produce formatted statements to send to our customers. Up until now, this has been fairly straightforward as we’ve only been using our core brand. We now need to produce a different format based upon a sub-brand, which will contain exactly the same detail but with a different logo and contact details etc.

At the moment, I’m using a print context which calls master pages depending on whether it’s a single page or multiple, and these master pages use a PDF file as a background image, which contains all the static elements such as logo, heading, address and table layout.

Does anyone know whether it’s possible to have multiple designs in this way (to cover multiple different brands) and set up Designer to select the relevant one based on values in the data (such as an identifier which denotes which brand it is)? I can create the different background images, contexts and master pages, but I don’t know how to go about setting up the logic for the ‘decision’ part when the data is processed.

All the best,
Rich

You could call, dynamically, the related PDF from a server-side script.

You setup each and every variation of your static background into separated PDF.
Save theses PDF into a folder with each a unique filename.

Then set the script to change the src attribute of your #background

Hope that helps.

Hi Hamelj,

Thanks for your reply, in the end I did something very similar which I think has done the trick. Rather than switch out the entire background, I just placed an image element on the page which will contain the company logo, then set up some script that switches which image file gets loaded depending on a field value in the data:

image

As that’s effectively all that changes (the page structure remains the same, just the logo changes), that looks to do the job. Most of our depots use the same logo, but for those that don’t I now have a means of switching out the image.

All the best,
Rich

Alternatively you could use dynamic media via scripting. This requires you to create media for the various brands and set the accompanying PDF images as the stationery background.

Subsequently create a script (similar to yours) to set the media background for the section. See the image below. You can use CSS selectors to set Media for sections and media positions. The html element of a print section has an attribute stating the section name and uses tags to drive media.

Selectors for the media positions are:

  • meta[name=“media-single”]
  • meta[name=“media-first”]
  • meta[name=“media-middle”]
  • meta[name=“media-last”]

In case you want to set the same media for all positions (target attributes prefixed with ‘media’):

  • html meta[name^=“media”]

To target media of a specific section you could add the [section] attribute selector (or put the scripts in a folder in your Scripts panel and set the execution scope to the respective section(s)).

  • html[section=“Section 1”] meta[name^=“media”]

Erik

PS. Clicking the script icon next to the media entry in the Sheet Configuration dialog creates a new dynamic media script and would give you a good starting point as it pre-populates the selector.

Hi Erik,

Thanks for that, that’s really helpful. I might have a little play with my set up and see if I can re-engineer it as you suggest. It gives me some more options at least!

All the best,
Rich