Search This Blog

Friday, February 15, 2008

Add a forum to ur site

When you’re setting up a site using CSS, it’s a good idea to do a little planning ahead and think how you’ll be using your styles, otherwise you could end up spending much more time later.

As a case in point – for a site I’ve recently built, a basic style sheet was put together, with entries for matters like headlines, section headings, item headings and so on. When it came to forms on the site that needed headings next to the data entry boxes, the logical choice was the item headings style. It helped maintain a consistent look across the site, but it came back to bite me later. The reason? After some feedback from the beta testers, a left margin was added, so that text didn’t butt up against the left-side of a browser window. You might think that is fairly straightforward. And it would be, but for the fact that simply adding a margin to all the CSS styles would do the same wherever a style was used, making the headings on some of the forms look a little odd.

So, the solution was to duplicate the appropriate style – before adding the margin to it – and call the new duplicate something useful like ‘formItemHeading’. Then, amend the original item heading style to add the margin and, finally, go through the entire site changing headings in forms to the new style. It’s tedious work and something that could have been avoided had I done the thing that I’m always urging other people to do – plan, plan and plan. Even if you first imagine that two types of element on your page – in my case item headings, and form box headings – will look the same, remember that they are separate items and, though it might feel tedious at the time, create a separate CSS style for each type of item. It will save you a lot of time if you need Building a community Add a forum to your site and planning ahead with CSS to make changes to the style sheet later . You’ll just need to alter the style sheet – which is best saved as a separate file, rather than included in each document, for large sites – instead of having to manually edit every page and reassign styles later. It’s far better to end up with a few extra styles in your style sheet than to have too few. The amount of data in a style sheet is trivial, so it’s really not going to make any difference to the download time of your site.

Attracting visitors One of the things that most web designers would like is for their site to be visited by lots of people. You can promote it – but not by using junk mail – and mention it elsewhere on the Internet, put it in your email signature and arrange reciprocal links with similar sites. But none of that is much use unless there’s a compelling reason for people to keep coming back. So, how do you tackle that sort of thing? It was one of the issues facing the site on which I had my style sheet tribulations. It’s a site that’s intended to be a resource for users of a digital video recorder, which can be enhanced via software downloads.

But a site that simply lists things you can download isn’t terribly exciting, so we needed something to try and draw people back. The obvious answer to that is forums.

Discussion forums can help provide a community and draw people back to your site to see the answers to questions they’ve posed. Obviously, they’re not relevant to every site, but for the site in question, it seemed a logical idea. And one that immediately raises the question – how do I add a forum? There are several packages that you can use to provide forums. In some cases, the type of forum that you can install will depend on your web host. Two of the most popular and well known are phpBB and YaBB. The former is actually a component of the PHP Nuke (www.phpnuke.org) open source portal system, though you can install it separately, if you don’t want all the other portal functions.

As you can guess from the name, you need PHP on your web server to run phpBB. You’ll also need the MySQL database, which is used as the back-end of the system – don’t worry if you don’t have the two on the main part of your site. If you have a site like www.nigelwhitfield.com, it won’t look odd if you use a separate site like forum.nigelwhitfield.com to host your discussions, but obviously you’ll also need to be able to manage the DNS entries to set that up. YaBB is written in Perl, which is also a very popular scripting language and available on many web servers. Rather than use a database, it stores its information in text files, so all you need is the ability to run Perl scripts on your web host, rather than PHP scripting, MySQL and full access to a database. On the downside, the file structure might store up problems for the future if you’re running a very busy site.

In the end, though, we went with YaBB (www.yabbforum.com), which is very easy to set up. It’s a simple matter of downloading a zip file, unpacking it and then uploading the files to your web server. You need to edit the Settings.pl file to tell the scripts where your files are stored, both in terms of the URL and of the directory on the server, and then make sure the script is set so that it can be executed. Then log in to the web page with the default admin user name and password, and fill in a few simple web forms to set up your forums. It really is extremely easy to do. If you want to tweak the design a little, for instance, to match the colour scheme of your website, it’s easy – just click on the Admin link, and you can alter the template file, with its CSS definitions from within your browser. That really is just about all it took – certainly less than half an hour. Even if you’re not familiar with Perl, it’s not exactly difficult to edit the settings file and get up and running. If you want a forum on your site, it’s well worth taking a look at. A forum isn’t necessarily the only thing that you’ll need.

On the site I was setting up, we decided that it would be a good idea to have a function that allowed users to build up a personal page with information and quick links to the things they want to download. It’s a handy tool that might help bring people back – especially since you can then email people when a new version of a product in their list appears, providing you seek their consent. And to help tie it in with the forums, and give an incentive to register, the functions restricted only to those who have signed up for the forums. That might sound complicated, but it’s a lot simpler to do than you might imagine. All you do is check for the cookie that’s set when a user logs in to the forums, and only allow the personalisation scripts to run when that’s set. In the case of YaBB, the default cookie is called YaBBusername, though you can change it if you like. You can check for the presence of the cookie with some PHP code like this, which, if before the HTML section of a document, will redirect to the forum home page if the cookie is not there.


{ header(‘Location: d www.mysite.com/cgi-d bin/yabb/YaBB.cgi’) ; exit ; }

(Key: d code string continues)



You may want to redirect to a different page, explaining why people need to sign into the forums. Linking functions of the site like this can help to encourage people to sign up, since there’s a tangible benefit to doing so. But don’t do it just for the sake of it – think of how people might want to use your site and work around that. Pointlessly restricting functions or sections of your site is likely to turn people away, rather than encourage them. Reader queries David Boswell asks: ‘is it possible to reduce the size of an Excel spreadsheet saved as a web page, other than by printing out, scanning and reducing it as an object? Printing out in Excel does not reproduce the macro buttons and I also need the very best definition I can get. Using the zoom factor on the spreadsheet before saving it as a web page does not seem to work.’ The answer is, sort of. When you save a web page as Excel, either on a Mac or PC, what’s created – unless you use embedded objects inWindows – is simply an HTML table, with formulas changed to the results they use. (Actually, strictly speaking, the formulas are still there, in XML, so the spreadsheet could be recreated from the HTML file). At the top of the file, you’ll find an embedded stylesheet. You can edit that – you could set up a global search and replace if you do this often – to alter the options, including font sizes, so that you end up with the desired effect. If you have the last twoWeb Development columns, you can now marvel at the forethought of including a crash course on CSS in them. Alternatively, depending on the browser you’re using, you have a few different options. In Internet Explorer, the View/Text Size menu options won’t work because there are sizes specified in the document. But if you choose Accessibility from the Internet Options, you can override text sizes and styles in the document, which will then allow the menu options to increase or decrease text size to work. You could even create your own style sheet to apply, though that would only be worth the effort if you used an almost identical spreadsheet template a lot. If you’re using Opera, you can zoom in and out of a page, regardless of the style sheet that’s been applied, so you can easily fit more of a spreadsheet into theWindows. And you can also click the drop-down view mode menu at the right to switch to User mode, which will use your own default styles, instead of the ones specified in the file.

No comments: