Table of Contents
Collection Specific Macros
Collection specific macro files go into collect/<collection_name>/macros
, and are used instead of the system ones.
The Collection Specific Macros section of the Format view allows you to add/modify macros specifically for the current collection. By default, the text on this page looks like this:
# extra.dm file # You can add collection specific macros in here # Lines starting with a '#' are comments. # Remember to include the package declaration package Style # will be applied to all pages # add css style lines inside the style tags _collectionspecificstyle_ { <style type="text/css"> </style> } # add any javascript functions here _collectionspecificscript_ { }
Because they are listed under package Style, _collectionspecificstyle_
and _collectionspecificscript_
will apply to all pages in the collections.
Page Specific Macros
If you would like to have style or script that applies to a specific page in the collection, you can add it under the applicable package:
Page | Package name |
---|---|
About page | package about |
Search page | package query |
Preferences page | package preferences |
Help page | package help |
All pages | package Style |
All classifier and document pages | package document |
(Notice all of the package names are lowercase except for Style
.)
For example, if you add the following to the bottom of the Collection Specific Macros page:
# will be applied only to the 'about' page package about _collectionspecificstyle_ { _Style:collectionspecificstyle_ <style type="text/css"> body.bgimage \{ background: url("_httpimages_/background_about.jpg") scroll repeat-y left top; \} </style> } # script that will be applied to only the 'about' page _collectionspecificscript_ { _Style:collectionspecificscript_ <!-- alert ("This alert will only appear on the About page!") //--> }
the about page of your collection will have a different background than the rest of the pages in the collection, and an alert box will appear when the about page loads (but not for any other pages).
Some important things to notice in the above code:
_Style:collectionspecificstyle_
on lines 5 refers to the_collectionspecificstyle_
macro in package Style above. Adding it here ensures any style you have set for the collection as a whole is also included on the about page. Similarly,_Style:collectionspecificscript_
on line 13 includes the scripts specified for the whole collection.- The
_httpimages_
macro on line 7 resolves to theGreenstone/web/images
folder, which is wherebackground_about.jpg
is located.
The packages for the query, preferences, and help pages work exactly the same way.
Unique style/script for classifier and document pages
Before reading this section, be certain you know how Browsing classifier numbering works. package document works the same as the example above, but effects all pages for all of the browsing classifiers and documents in the collection.
If you do want unique style/scripts for specific pages, there are a few different ways to accomplish this, depending on exactly what you want to do. The most straightforward and comprehensive solution is the use of "if" statements to distinguish between pages. For example:
# for browsing classifier and document pages package document _collectionspecificstyle_ { _Style:collectionspecificstyle_ <style type="text/css"> _If_("_cgiargcl_" eq "CL1", body.bgimage \{ color: pink; \}) _If_("_cgiargcl_" eq "CL3.2", body.bgimage \{color: grey;\}) _If_(_cgiargd_, body \{ color: purple; \} _If_("_cgiargd_" ne "HASH96b70944cdfe840c1462d4", body \{ color: cyan; \} body \{font-family: cursive ;\} div.documenttext \{color: green;\}) body.bgimage \{font-size: 200%; background: url("_httpimages_/browse_cltop_.jpg") scroll repeat-y left top; \} </style> } _collectionspecificscript_ { _Style:collectionspecificscript_ }
First, it's important to understand what the macros represent:
macro | name | explanation | example values |
---|---|---|---|
_cltop_ | Classifier Top | The top level of the browsing classifier | CL1, CL2, CL3… |
_cgiargcl_ | CGI classifier (cl) argument | The granular level in the browsing classifier (for hierarchical/partitioned classifiers) | CL1, CL3.2, CL2.3.1 |
_cgiargd_ | CGI document (d) argument | ex.Identifier for the document | HASH01465d851b65a4bfa0055606, HASH018a60934c30bd1353381c8e |
The example looks very complex, because it is demonstrating several things. Let's take a look at what each section of code is doing.
_If_("_cgiargcl_" eq "CL1", body.bgimage \{ color: pink; \})
This sets the font color of the first browsing classifier (CL1) to pink.
_If_("_cgiargcl_" eq "CL3.2", body.bgimage \{color: grey;\})
This sets the font color of the second hierarchical level/partition of the third browsing classifier to grey.
_If_(_cgiargd_, body \{ color: purple; \}
This tests for the existence of the CGI argument d, which only appears in document page URLs. So,
this changes the font color to purple for only document pages. Notice that the body
tag does not
include .bgimage
here. the body
element for all of the browsing classifier pages (as well as
the query, about, etc.) pages has a class
attribute value of bgimage
. However, the document
body
element does not.
_If_("_cgiargd_" ne "HASH96b70944cdfe840c1462d4", body \{ color: cyan; \}
For the document page of the document with an ex.Identifier
of HASH96b70944cdfe840c1462d4
, the font color is cyan.
div.documenttext \{color: green;\}) body \{font-family: cursive ;\} body.bgimage \{font-family: serif;\} body.bgimage \{font-size: 200%; background: url("_httpimages_/browse_cltop_.jpg") scroll repeat-y left top; \}
The document text on document pages is green (div
of class documenttext
only appear on document pages).
The font on document pages is cursive, and is serif on browsing classifier pages (because the more specific
body.bgimage
overrides body
).
The final line here presents a possible alternative to the use of 'if' statements specifically if you
want different background images for each classifier. Because _cltop_
resolves to the top level
of the current classifier, the image name here will be different depending on the page you are on. So, you can
have documents names browseCL1.jpg
, browseCL2.jpg
, etc. to correspond to each classifier.