This is anything but a short article, so be ready for a long haul. We're going to cover a lot of ground on how to make WebGUI behave the way you want it to. This article is aimed at the same sort of person I was at the beginning of Jan, 2007: I've installed WebGUI. Now what the heck do I do with it? How do I make it look like I want it to look, and not how Plain Black wants it to look? As a result, the first few sections cover some terminology that more experienced people probably don't need. Instead, they want to head straight to Bringing It All Together, to show the actual process of creation and installation from beginning to end.
First, though, we have to cover one very important thing: Making WebGUI look like your site really means creating a stylesheet, along with HTML, which defines how your site will look. As a result, I'm going to recommend starting your work in a very non-technological way: Get out a pen and paper, and draw on it, until you have an idea how you want your site to look.
After you've got your drawings, make the graphics that you need to. Personally, I use the GIMP, though many people prefer Photoshop, or other tools. After you have the graphics, you will need to make the HTML and CSS for your site. Personally, I find ViM(for making the original .html and .css files) helpful, along with Mozilla Firefox and Firebug. Using the latter two items will let you view your site and edit the CSS right in the browser, live, and view the results, without the usual "edit/save/reload" process you would normally have to go through. Naturally, we can't ignore Internet Explorer, so for debugging the CSS/HTML/etc. on that browser, you will need IE Web Developer (alas, not a free plug-in).
Only after you've completed all of the above are you ready to begin the process of making the style templates in WebGUI.
This process is quite important, and you will use it a great deal, so take some time to get comfortable with it now.
First up, you need to know about version tags. Simply put, you are able to go back in time to how a website looked at a specific date and time. Because of this, WebGUI must keep track of the work you do while you are doing it. It does this by creating something called a version tag.
As you work on your site, editing and saving your work, your work is, basically, put in a "pending" state. One way of looking at this is to say that webgui internalizes the development/qa servers, allowing you to work on the production site without worry of how you will affect the users of your site. All of your changes are given a label. If you do not specify the label yourself, then WebGUI will create one for you when you first save something. It will usually be named something like "username date time".
As you can imagine, an article as long as this one could be written about version tags. However, you're not really here for them, so I'm giving the you bare minimum to deal with them while customizing your site. When you have a version tag, you will be able to see it under your "Admin Console", under the heading "Version Tags". You will need to know that you have one before you can commit it.
In order to make your changes apparent to other users of your site, you must commit your work. Fortunately, this process is much easier than understanding version tags, and takes only a few steps.
Your work is now visible to other users of your site. This is the "Commit" part of the process being documented: "Commit/Clear/Reload".
After committing your work, your changes might not be visible to all users of your site immediately. This is due to the object cache, which WebGUI uses to dramatically speed up page load times for your users. Normally, this is a good thing. When making changes like these, though, this can be distracting for you.
To clear your cache, take the following steps:
That's it, your cache is now emptied, and WebGUI will force all pages it serves to be rebuilt. This is the "Clear" step of "Commit/Clear/Reload".
This part probably goes without saying, but it will be said anyway for completeness: Browse to the page you've modified, and click "Reload". You should now see your updates.
This is the "Reload" part of "Commit/Clear/Reload".
From now on, anytime you need to do this process, I will simply tell you to "CCR", which is short for "Commit/Clear/Reload".
A common enough question regarding WebGUI is something like "What programming language do I have to learn to make my own templates?". You don't have to learn any programming language. Instead, you learn the WebGUI templating language.
Well, it is the templating language for WebGUI, but that's kind of overstating things. It's a normal templating language, and very easy to deal with, and is used outside of WebGUI as well. It's called HTML::Template. Go and read some of the articles about it (linked to from the HTML::Template site), and you'll see. It's easy to deal with, but you do need to know it in order to make sense of what's coming up soon.
Assets are what WebGUI is all about. Specifically, WebGUI is about managing the pieces that make up your website, and providing an easy way to build some very complex pieces. In this discussion and tutorial, we won't cover even 1% of the possibilities. Instead, we will focus on some very core items, so that you can understand the pieces you need to to make your site.
Basically, everything on your site is an asset. Every file, every image, every snippet of CSS, or HTML, or Javascript, every calendar, every article, absolutely everything that you would present to the user (or to you) is an asset. WebGUI is what makes managing those assets feasible.
Now, broadly speaking, there are two types of assets: Container Assets and Displayable Assets. We will not cover all of the Displayable Assets. I recommend purchasing the official training guides and books from PlainBlack. In addition, the WebGUI Wiki (which is what you're using right now), is extremely useful and almost always has the information you require. Just search for it!
So, what is the difference between the two? Container Assets hold all of your Displayable Assets. Container Assets include "Page Layout", "Folder", and "Dashboard" (an advanced topic, and one we won't pursue for this discussion). Displayable Assets include "Page Template", "Snippet", "Image", and others.
"Page Layouts" are what many other sites would consider to be a page. For instance, you might be looking at http://www.webgui.org/support/ at some point. That would be a "Page Layout" in WebGUI terms. While browsing through there, you would find a section named Contibutions, then Packages, then Burned. After clicking on the Burned package, you would finally find yourself looking at an "Article", along with other Assets (to hold the package, a forum, and the like).
This point cannot be overstated: Page Layouts contain Assets, and are generally what are given out as URLs to your site. Remember this above all else. Your Assets go on Page Layouts.
"Folders" contain just about everything, including Page Layouts, Snippets, Articles, Images, and everything in between. They are a handy way to organize your site. We will be showing how to use these assets by example, later in this article.
Macros are not Assets, not by the definitions we used above. Macros are a part of WebGUI. You can make your own Macros, but that is definitely a topic for another time. For now, we are going to cover a set of Macros that we will use heavily in making our own style, and making WebGUI use that style. Note that this is just a listing of the macros, not a full "how to use" guide. We will use every one of them in the final section, "Bringing It All Together". Here, though, you have links to the online help files, along with basic information on what each one is, and why you might need/want it.
AssetProxy : One of the two most used macros you can/will have in your template. This will put the appropriate code for the Asset right into your page. This is useful for putting in images, calendars, wiki's, etc.
FileUrl : The other of the most used macros you can/will have in your template. This will only put the uURL of the asset into your page, and will not add in any necessary HTML code to make it work. For instance, this is a great way to do your own link to an image, but using it to place a Navigation will only do you harm.
There is one other important difference between AssetProxy and FileUrl, though: FileUrl gives exactly the URL of a file. When the web browser receives this information, it will request the file url itself from WebGUI. This has the benefit of bypassing an access to the database, thereby helping the page load slightly faster for the user, and reducing load on the server. If you are putting an image onto a page, then FileUrl might save your web server some small effort. On the other hand, if you're putting in a Collaboration system, you probably need to use AssetProxy anyway.
L : This is how to place a login box on the page, so the user can login. Pretty important to allow them to modify the site more easily later.
AdminBar : This code is what handles displaying the Admin Bar, which is the set of controls that allow you to place new content, modify existing, etc. This macro should be placed right after your opening <body> tag. This macro is not enough to ensure the user can display the Admin Bar! Make sure to insert the AdminToggle macro (covered next).
AdminToggle : This macro is what is responsible for showing the link to allow the user to turn the Admin Bar on and off. Generally speaking, you will place this near to the ^L; macro.
c : This macro displays the company name, as defined in the Site Settings. Most often, this will be useful in a footer, as part of a copyright statement. At least, that's how I've used it most often, so far.
PageTitle : Using this macro, you can insert the title of the page. Very handy when writing your <title> tags, and quite possibly as a page element.
/ : This will insert the URL of the root of your site. For instance, if your site is actually under your home directory on the server homes.webgui.org, it will paste the URL http://homes.webgui.org/~yourhome/ into the output. Very handy in menus, or as a way to specify where to find a stylesheet (i.e.: <link rel="stylesheet" href="^/;style.css" type="text/css">)
When making your site, there are two critical pieces that you simply must add. Failure to add them will, in fact, prevent your site from working in any way, shape, or form. Namely, two magic lines of code. Well, not so magical if you remember that WebGUI is a very specialized use of HTML::Template. You need to insert two template variables into your style template, and that will make your page display the way you expect.
In your <head> section, add the following line, right after your <title> tags:
<tmpl_var head.tags>
In your body section, find the location for where WebGUI should put its output from the page, and insert this line:
<tmpl_var body.content>
After doing that, you will see the site behaving the way you would expect.
Everybody has their own opinion on where their themes should go. My standard is for any of my themes to be installed in a folder named "Themes", under the Root Folder. So, here's how to do make that folder.
We are now going to make the place where your new theme will reside.
You will almost always be uploading multiple images. As a result, this article will only explain how to use the "File Pile" to upload a pile of files. It really does make it easier to upload the 4 to 10 images common for many themes.
The images for your theme are now ready for use.
Adding in a Navigation to your theme is one of the most critical pieces of your theme. Without it, people will not be able to navigate your site (well, unless you use only static menus hardcoded into your theme, but that makes it impossible to distribute very well).
The first thing you must do is navigate to your theme's root folder. Take these steps.
After doing the above, you will be presented with a moderately complex screen. Let's cover the options, one at a time:
Make sure that "Who can view" under "Security" is set to "Everyone", and then click "Save". You are now ready to attach this Asset to your Page Layout.
This step will be done outside of WebGUI. Open up your HTML page in your HTML editor, and find the place where your menu will go. Insert the following there:
^AssetProxy(themes/themename/menu);
That will put your menu on your page when it is displayed. Make sure to save your HTML file now!
This section might seem out of place, but it has a direct bearing on the following sections, so we're going to interrupt this article to discuss a snippet. So, what is a snippet? A snippet is a segment of HTML, or CSS, or JavaScript, or even just plain text. It is referred to as a URL, but the contents of it are stored in the database. The difference between a Snippet and a File is that a File is stored on disk, with references in the database. A Snippet is stored right in the database.
That's the backend differences. The frontend differences, though, are more readily visible. If you need to update a file, you have to browse to the file, upload a new copy, and overwrite the old. A snippet gives you an editor right in the browser, and lets you edit there. For ease of use, I prefer the snippet, though others prefer a file. I will be recommending a Snippet for the following pieces.
In all cases, the way to make a snippet will be fairly familiar to you by now. Here's the process.
Give it a Title, give it a URL, and insert the contents of the Snippet in the editor window. Turn off "Process as template", and set the appropriate mimetype. Update the "Who can view" in "Security" to "Everyone", and hit Save.
As an added benefit of the Snippet, once you update the Snippet in one place, all places which refer to that Snippet are updated, without your needing to do any work.
Templates are the meat of making your own themes. Without them, you will not get a theme to work correctly. If you make them incorrectly, your theme will not work. They are extremely important. Fortunately, they are also extremely easy to make, and to make correctly.
You will now do some very common steps: Give it a title, give it a URL, make sure "Who can view" in "Security" is "Everyone".
There is a major "gotcha" which happens right here: If you do not set "Namespace" to "style", then you will be unable to use this template as a template. Make certain you set "Namespace" to "style"! Furthermore, you only get one chance to do this right! Failure to do this will result in your having to remake your template!
Also under "Properties", you will have a text editor window. Copy and paste the HTML which comprises your template into here, and hit Save. You'll now be able to specify this as your style for your site, or for anything which can use a style.
You might not need to do this. You might be happy with the default Navigation Template chosen when you added the Navigation Control. If, however, you are not happy with it, you will need to choose another.
Now, choose a different "Display Style". If none of the other "Display Styles" suits you, you will need to make your own. Making your own Navigation template is beyond the scope of this article, and definitely fodder for another one. While not overly complex, you will need to be able to handle some very minor coding in HTML::Template.
First, make sure you have updated your CSS file that you've created back in the Pre-Requisites. You must change all URL's to use the appropriate FileUrl macro's. For instance, this line of CSS code:
background: #000000 url('images/a1.jpg') top left no-repeat;
becomes this line of WebGUI template code:
background: #000000 url('^FileUrl(images/a1.jpg);') top left no-repeat;
Double-check to make sure you are not using any other Assets in your CSS code, and then create a snippet in your Theme folder, and paste the contents of your CSS file as your snippet. Make sure you pay attention to your URL, as you will need it in the next section.
Finally, the part you've been waiting for: Actually installing your newly converted theme!
Create a new Template in your Theme folder, and paste the HTML into the template window. Make sure you've inserted all your macro's properly, as this is where all your work comes to fruition. For a better example of what I mean, check out Bringing It All Together, and you will see a complete list of the edits that were made to the source HTML file to make it work.
Now, don't forget to Commit/Clear/Reload!
At this point, you've got your theme installed, and want to see how it will look.
Your theme is now applied, and your site will look the way your theme allows it to. However, you are not yet done! Follow the next section.
When an error occurs (for instance, the user attempts to login, and gives the wrong password), a User Function page is brought up. By default, WebGUI uses its own style for that page. We want it to use the new style that you've just applied.
Now you're done. Your style is made, installed, and in use throughout your site. As long as you work under the Root/Home folder, your style will automatically be used. If you make another folder under Root, and expect it to be used, you should apply your style (using the "Edit Branch" technique) to it, as well, to keep the overall look and feel uniform.
Next, we'll work together to build a complete style, working by example.
Right about now, your reaction should be something like "Great. So what in heck do I do with all of this information?" We're now going to work our way through a conversion together. We need a common starting point, so let's use an existing open source theme. In this case, I've chosen Sundark. We'll take the zip file, analyze it, make some artistic changes (which we need to make for WebGUI), and create a theme. We'll apply it to our site, make sure it gets used everywhere on our site, and then export it as a package, for upload to the WebGUI Contributions Packages Section.
Now, before I continue, I'd like to point out why I chose Sundark. It's simple. The entire uncompressed archive takes up 28K of disk space. Of that, 20K goes to the graphics. For the CSS and the HTML files, there's a total of 137 lines. The display is minimalist. We can focus on the conversion process, rather than on debating the artistic merit of the style of navigation, etc. So, even though Sundark might not be the most beautiful theme, for these purposes, it is perfect.
As with any conversion, we first have to identify what we are going to do, and then perform the steps to do it. So, first, let's examine a screenshot of the theme, before we have done anything:
Now, in order to make this work for WebGUI, we need to have five elements. More are fine, but these five are pretty much mandatory:
I've already modified that screenshot to show the first 4 elements (highlighted), and the last one, the body, should be fairly self-evident (if not, it's all the Latin text).
You'll notice that I had to make a place for somebody to login. I chose what seems to be a fairly empty place in the banner of the page. What can I say? It seemed good to me.
I'm also changing the "Pagename" section to reflect the site name. I wanted to put the Page Title in place of the word "Content", and that made things fairly redundant unless I changed "Pagename". Having the site name display is a good thing, and I didn't have any other location jump out at me as being a good one, so there you have it.
The Navigation was already placed, so I just used the original placement location.
First, we need to set up the section for the login box/display. Add the following CSS code to the end of the file:
#login {
color:#000000;
font-family:verdana,tahoma,arial,helvetica,"sans serif";
font-size:8pt;
margin:0cm 0cm 0cm 11cm;
padding:0px 0px 4px;
}
#login a {
color:#000000;
font-weight:normal;
letter-spacing:0px;
margin-right:18px;
font-size: 8pt;
}
.loginBox {
display:inline;
font-size:8pt;
}
.loginBox input {
margin-top: 0.75cm;
font-size:8pt;
}
Now, we have to adjust the URL's in the file. Since we're going to be putting them into the "images" folder, we're going to be making noticeable changes. Find the two URL's listed below (they are at very different sections of the file):
background-image:url(header.jpg);
background-image:url(footer.png);
And now we will change them to the following:
background-image:url(^FileUrl(sundarkimages/header.jpg););
background-image:url(^FileUrl(sundarkimages/footer.png););
There is one other change, but this one does not make sense for now, mainly because it is something that is found after trying things out. Find the section for ".title" and change the "padding-top: 160px;" to "margin-bottom: 15px;" This is due to the addition of the login box that we need to make this adjustment.
And, finally, save the changed CSS file. We're done working with this file for now. We'll need it again in a few more minutes, though.
Find this line:
<title>www.rotw.de.ki | Template</title>
Replace with this line:
<title>^c; | ^Page("title");</title><tmpl_var head.tags>
Find this line:
<link rel="stylesheet" href="style.css" type="text/css" />
Replace with this line:
<link rel="stylesheet" href="^/;themes/sundark/style.css" type="text/css" />
Find this line:
<div id="all">
Insert immediately before it:
^AdminBar;
Find this line (it ends with an "a href" tag, but the wiki tries to convert it, so I can't place the tag here):
<span style="float:right;margin-right:5px;display:inline;">
Get rid of all <a> tags between it and the closing </span> tag.
Insert this line between the opening and closing <span>:
^AssetProxy(themes/sundark/menu);
Immediately after the closing <span> tag, place the following code:
<div id="login">
^L("","","PBtmpl0000000000000092"); · ^AdminToggle;
</div>
Find this line:
<div class="title">Pagename</div>
Replace with this line:
<div class="title"><a href="^/;">^c;</a></div>
Find this line:
<h1>Content</h1>
Replace with this line:
<tmpl_var body.content>
Find this line:
<div id="footer">© 2007 Pagename | Design by <a href="http://www.rotw.de.ki/" target="_blank">RotW</a></div>
Replace with this line:
<div id="footer">© 2007 ^c; | Design by <a href="http://www.rotw.de.ki/" target="_blank">RotW</a></div>
Now, save the HTML file. We're done working outside of WebGUI, it's time to get into it and make all our pieces.
This is fairly straightforward: We want to place the newly created theme in one place, with all of the pieces of the theme, so that we can easily manage the theme later.
Now, we need to define the Navigation for this theme. I strongly recommend re-reading the info in this article about the Navigation control now.
Now, we upload the images. First, though, we need a place to store the images.
Now, to upload the files.
You're done, your images are now uploaded.
Now, we need to supply the CSS file for this theme.
Your stylesheet is now ready to be used by your theme.
Okay, your template is installed, and ready to be used. Now to apply it.
Your site will now have the Sundark look applied to it throughout the site.
So, now that you have your theme built and in use for you, what if you wish to distribute your theme? For instance, maybe you've converted a design from Open Source Web Designs, and want to let other people use it as well. Here's how.
Now, you can distribute this file to other users of WebGUI, including posting it at the Plain Black Package Contributions page.
Now, the last thing you need to do is to test your .wgpkg file. You need to have a way to make sure that when somebody else installs it on their site, they can see the entire theme, and have it work correctly. Fortunately, this is easy to do, thanks to Plain Black. Visit the Online Demo page, and set up a new demo. After doing so, take the following steps.
You can now see the result with your own eyes as to whether or not others can use your theme.
As promised at the beginning, we covered a lot of ground. I hope this has been helpful to you in learning how to make your own templates, and make your site look the way you want it to look.
The files for Sundark can be found in the contributions section of the Plain Black web site.
I'd like to thank the participants of the IRC channel, as they gave me lots of information when I was trying to work out how to do my own templates, and basically taught me what I needed to know in order to make them work. Thanks to them, this page became possible.
If you wish to email me directly, you may do so at m.pedersenNO@SPAMicelus.org.
Keywords: howto layout style theme