Simpel
January 19, 2022, 6:34pm
1
I made a style sheet extension with following code:
#if($doc.getExternalURL().contains('rubbish.example.org'))
#companylogo::after {
content: "Spielwiki";
}
#elseif($doc.getExternalURL().contains('test.example.org'))
#companylogo::after {
content: "Testwiki";
}
#else
#companylogo::after {
content: "";
}
#end
I set:
use: in this wiki
parse: yes
cache: standard
type: css
It’s not working. And if I look at the css “file” beautified I see:
#if($doc.getExternalURL().contains('rubbish.example.org')) #companylogo::after {
content: "Spielwiki"
}
#elseif($doc.getExternalURL().contains('test.example.org')) #companylogo::after {
content: "Testwiki"
}
#else #companylogo::after {
content: ""
}
#end
There is no difference in this css “file” whether I switch parse on or off.
This happens at:
XWiki Jetty HSQLDB 13.1
XWiki Debian 13.10.1
Any ideas?
Regards, Simpel
mleduc
January 20, 2022, 9:14am
2
Hello @Simpel ,
I did a try a got the expected result with the same configuration as you.
One small improvement you can do is to escape the #
used in the css id selectors, since otherwise if a macro with the same name exists, it will be called instead (see the example below).
Calling http://localhost:8082/xwiki/bin/ssx/TestCSS/WebHome returns #companylogo::after{content:""}
(given that the StyleSheetExtension
is located at TestCSS.WebHome
).
One thing you can do to find what’s going wrong in you instance is check you logs, if something goes wrong with velocity interpretation, a warning will be logged.
#set( $H = '#' )
#if($doc.getExternalURL().contains('rubbish.example.org'))
${H}companylogo::after {
content: "Spielwiki";
}
#elseif($doc.getExternalURL().contains('test.example.org'))
${H}companylogo::after {
content: "Testwiki";
}
#else
${H}companylogo::after {
content: "";
}
#end
Hope that helps.
Simpel
January 20, 2022, 9:45am
3
Hi.
I tried your trick, but this wouldn’t be parsed too.
Our wiki language is set to german. Maybe there is a difference? But not very likely.
If I put this code into a pure article (with {{velocity}} around it) then it will be parsed. I then only see that part of css that should be used.
Simpel
January 20, 2022, 11:30am
4
Found a warning in the log:
WARN c.x.x.w.s.SxDocumentSource - Velocity errors while parsing skin extension [xwiki:Macros und Plugins.NDR-Theme-Style.WebHome] with content [
Not very helpful?
Simpel
January 23, 2022, 8:39pm
5
To be precise, there were nearly 900 lines of css before. And I found that one line with the error.
The following comment line made velocity not parse correctly:
/* NOPRINT für #hierarchy (Breadcrumbs); .menu-horizontal-toggle (Mainmenu); #xdocFooter, #xwikidata (Likes, Kommentare etc.) */
As I removed parentheses and wrote it this way it worked:
/* NOPRINT für #hierarchy <Breadcrumbs>, .menu-horizontal-toggle <Mainmenu>, #xdocFooter, #xwikidata <Likes, Kommentare etc.> */