draft watermark until approved?

Having trouble installing Oxygen PDF Chemistry? Got a bug to report? Post it all here.
shudson310
Posts: 156
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

draft watermark until approved?

Post by shudson310 »

We followed the tutorial to create a draft watermark, but how can we conditionalize this so that the watermark is applied until bookmap/approved exists in the map?

Is there a way to conditionally apply an @page template?

For example, if we set a variable:

Code: Select all

draftStatus oxy_xpath("(//*[contains(@class, 'bookmap/approved')]/text())[1]");
so that when it exists, there should be some text, and when not, the value is null.

How can we conditionally apply it?

Code: Select all

@page and string(draftStatus)==not(null) {
size: 8.268in 11in !important;
margin-top: .75in !important;
margin-bottom: 1in !important;
}

@page and string(draftStatus)==null {
size: 8.268in 11in !important;
margin-top: .75in !important;
margin-bottom: 1in !important;
background-image:url("../../images/draft-watermark.png");
background-position:center;
background-repeat:no-repeat;
}
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
shudson310
Posts: 156
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Re: draft watermark until approved?

Post by shudson310 »

I tried a different approach, but still not working:

Code: Select all

body:not(*[class ~= "bookmap/approved"]) {
background-image:url("../../images/draft-watermark.png");
background-position:center;
background-repeat:no-repeat;
}

body:has(*[class ~= "bookmap/approved"]) {
}
I still get the draft watermark on every page, even when the approved element is in the bookmeta.
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Re: draft watermark until approved?

Post by Dan »

I think there is no such class on the body element.
You will need to use a more complex strategy. The approved element is located in the bookmeta/bookchangehistory element.

Code: Select all


   <bookmeta>
<author>Howe Tuduit</author>
<critdates>
<created date="1/1/2015"/>
<revised modified="3/4/2016"/>
<revised modified="3/5/2016"/>
</critdates>
<bookchangehistory>
<approved/>
</bookchangehistory>
I would use something like this:

Code: Select all


body {
background-image: url(oxy_xpath('if (//bookmeta/bookchangehistory/approved) then "" else "../../images/draft-watermark.png" '));
background-position:center;
background-repeat:no-repeat;
background-color:inherit; /* The ashes theme imposes white on the body, this will clear it.*/
}
Use oxy_xpath every time you need to probe the value form other element than the one matched by the selector, and test the expression on the merged HTML file using the XPath builder.

Let us know if you need more information.
Many regards,
Dan
shudson310
Posts: 156
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Re: draft watermark until approved?

Post by shudson310 »

Worked like a charm. As always, you oXygen folks are the best!

Many thanks! :D
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
shudson310
Posts: 156
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Re: draft watermark until approved?

Post by shudson310 »

OK, I also want to add text in the footer for the draft status. I declared the variable in the .root:

Code: Select all

draftStatus oxy_xpath('if (//*[contains(@class, 'bookmap/permissions')]) then "" else "DRAFT" ')
And in the page templates, I have:

Code: Select all

content : string(prodname) " " string(prodversion)  "."
string(prodrelease) "."
string(prodmod) " " string(category) " " string(draftStatus) "\a" counter(page) !important;
It works for the DRAFT mode, but when "approved" none of the footer content displays!

What am I missing?
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
shudson310
Posts: 156
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Re: draft watermark until approved?

Post by shudson310 »

ugh. Copy/paste error. should be:

Code: Select all

draftStatus oxy_xpath('if (//*[contains(@class, 'bookmap/approved')]) then "" else "DRAFT" ')
Still not working when "approved" though.
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
shudson310
Posts: 156
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Re: draft watermark until approved?

Post by shudson310 »

Turns out it was a quote nesting issue. This fixed it:

Code: Select all

draftStatus oxy_xpath('if (//*[contains(@class, "bookmap/approved")]) then "" else "DRAFT" ');
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
Post Reply