Making a Global Resources DB
Jake Howlett, 30 September 2001
Category: Miscellaneous; Keywords: resource
image
js
css
Chances are you have worked on at least one intranet by now. Chances are that this was as part of a team of developers. How did you find this? Personally I like it. Never is there a better chance to share knowledge and ideas. Saying that though, there are also the downsides.
The problem:
The problem comes when your team starts to use Style Sheets (CSS) to control the feel of the intranet, JavaScript to program it and images for the look. It's not long before each separate database that makes up the intranet has numerous different versions of these resources because everybody has their own version of everything. Managing these can be a nightmare as everybody has their preferred method of storing this information.
Let's look at what often happens when using CSS. The idea with using CSS is simple: keep all the style separate from the design and you only need to change it once in order to update the whole site. This doesn't work when everybody has their own version of the stylesheet in each of their databases. The person in charge of the look will have to tell them all about the change to the CSS and get them all to update each of their databases. This is when the advantages of using CSS are almost lost.
The solution:
Whenever I join a team that is not doing what I'm about to describe I try my best to convince them they should be. This normally starts with me saying:
Would it not be better if you had one central database that was just there to store the things like stylesheets that get used all over the place? This way we can manage the look of the whole intranet from one place!
This doesn't always go down well. Most often I suspect because people don't like change....
When the idea gets received with open arms I would start adding a Global Resources database to the intranet. Here's how.
Creating the Resources DB:
The first thing to do is create an empty database. No need to use a template as this DB is going to be used simply to add design elements to. Call it something like Global Resources. The file's name is irrelevant as you shall see later.
With this new database open in Domino Designer you can start adding all the things to it that are generic to all the databases that make up your intranet.
- Add all images to the Image Resources section
- Add the contents of all the CSS and JavaScript files in to Page design elements that are Treated as HTML (give them names that end in .css and .js)
- Add anything else like Java Applets as required
- Set up the ACL as you deem necessary to ensure that the look of the site is safe
We now need to alter all databases so that they point to this new Resources area when they want to load these global elements. To do this we need to know the Replica ID of the Global Resources DB. Easiest way to do this is through a Design Synopsis:
On the second tab click on "Replication" and click "OK". Toward the top of the next page you see there will be the Replica ID of the database. Copy this and put it somewhere safe for the time being.
In any DBs where you want to use these resources you now need to create a Shared Field that is Computed For Display and called ResourcesRepID. Add the above Replica ID you found as this field's Value after removing the colon (:) from the middle.
Hopefully, if you've listened to anything I've said over the past year, your database will have CommonFields Subform that exists on EVERY form. This is where you should add the new Shared Field.
Now, when you want to link to anything in the Resources DB you would create a URLs in your formulas like:
"<script type=\"text/javascript\" src=\"/" + ResourcesRepID + "/CommonScripts.js\"></script>"
"<link rel=\"stylesheet\" href=\"/" + ResourcesRepID + "/global.css\">"
"<img src=\"/" + ResourcesRepID + "/companyLogo?OpenImageResource\" />"
The idea of using the Replica ID rather than the DB's file path is simple. The Replica ID is less likely to change that the path. You can also replicate this database to other servers where it may have different file paths.
Copyright © 2000 - 2024 Jake Howlett of Rockall Design ltd. This article was printed from codestore.net