Page 1 of 1

draft watermark until approved?

Posted: Fri Jun 29, 2018 1:38 am
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;
}

Re: draft watermark until approved?

Posted: Fri Jun 29, 2018 2:06 am
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.

Re: draft watermark until approved?

Posted: Fri Jun 29, 2018 10:51 am
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

Re: draft watermark until approved?

Posted: Fri Jun 29, 2018 4:27 pm
by shudson310
Worked like a charm. As always, you oXygen folks are the best!

Many thanks! :D

Re: draft watermark until approved?

Posted: Fri Jun 29, 2018 5:16 pm
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?

Re: draft watermark until approved?

Posted: Fri Jun 29, 2018 5:18 pm
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.

Re: draft watermark until approved?

Posted: Fri Jun 29, 2018 5:37 pm
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" ');