-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi.
I'm making a site with the aproach of Paged based Navigation as is mentioned in this chapter: www.zkoss.org/wiki/ZKEssentials/Chapter7:Navigationand_Templating.
I would like to share css between pages, but the only way to do this is adding at the begining of the *.zul the line and others like js, favicon, etc.
The thing is that I don't want to repeat all of this lines in all files. I try to make an <include src=""> with this lines inside but it's not possible.
Could anyone inspire me?
Thanks a lot.
Hi there,
Assuming you want to declare the same JS / CSS / etc resources on every page of your project, I'd recommend making them into a lang-addon: https://www.zkoss.org/wiki/ZKClient-sideReference/Language_Definition
you can create a lang-addon xml file, declare it in zk.xml with the langage-config element https://www.zkoss.org/wiki/ZKConfigurationReference/zk.xml/Thelanguage-configElement and the content of the lang-addon will modify all zul pages loaded in this website.
You can globally declare JS with the javascript element, styles using stylesheet, etc. I recommend making all of these resources into separate files under a /resources folder, for easy management, then your lang-addon will look like:
<language>
<addon-name>myAwesomeAddon</addon-name>
<depends>zk</depends>
<language-name>xul/html</language-name>
<!--VERSION IS OPTIONAL, JUST HERE IF YOU NEED TO KEEP YOUR OWN LANG-DEF TIDY BETWEEN VERSIONS-->
<version>
<version-class>org.zkoss.zul.Version</version-class>
<version-uid>5.0.6</version-uid>
</version>
<javascript src="ressources/js/myScript.js"/>
<javascript src="ressources/js/myOtherScript.js"/>
<stylesheet href="/ressources/css/mySheet.css" type="text/css"/>
<stylesheet href="/ressources/css/myOtherSheet.css" type="text/css"/>
</language?
Can I ask why you don't want to create a separate CSS file and put something like :
<?link rel="stylesheet" type="text/css" href="css/mystyles.css"?>
at the start of each ZUL?
You (as you said) do it for JS and FAVICON.
Just interested in your reason.
can't answer for OP specifically, but I can think of a number of good reasons: Not wanting to update all of the pages when you need to change your global resources imports, having a lot of pages, using lang-addon as a packaged module (to still include the resources when added into a project, etc)
MDuchemin ( 2021-11-24 18:12:16 +0800 )editNot want to update all of the pages and not repeat in all pages the same making the code cleaner.
jballesteralejo ( 2021-11-30 23:53:51 +0800 )editAsked: 2021-11-18 20:09:12 +0800
Seen: 13 times
Last updated: Nov 30 '21