Website Development
Miscellaneous Forums/General Discussion/Website Development
Recently I've been getting more into web development, namely HTML, CSS, and JavaScript. I decided to develop my own site, but before I begin I have a few questions.
First off, is it a good decision to make it dynamic (php, asp, databases, etc..) in any way, or should I just use static html/css, with a bit of javascript if needed? As of now, it'll only consist of a few pages -- Bio, Games, Links, Homepage -- stuff like that.
While this certainly isn't hard to do, it seems odd that I just copy the html for each page (except for the header/footer and other stuff that's the same everywhere), and then change the content. For instance, I'm using a list for my navigation links. On each page I have to change it so that the class of the selected link is different, in order to differentiate between the current page being visited and the other pages. Is there a more efficient way to do this?
I'm sure I'll have more questions later, which I'll just post to this thread, but that's all for now.
Thanks!
Hey Torrente, welcome to the fun!
I've been getting into web development after a long break from it - before it was all static html with tables and frames. Now it includes all sorts of fun dynamic stuff(JS, php, SQL, flash, ect) they bring a whole new level to website development. My advice is to make your site dynamic, right now I use php/sql/html/sql for my site, I've yet to dive into javascript.
As for your second question:
It really depends on what you're using, with php, there are ways to identify your page.
Currently what I have of my website is using PHP, but I stopped and thought about it, and came to the conclusion that I didn't really need it -- hence my post on here to make sure.
Are there any specific reasons I should make it dynamic? The one thing all dynamic websites seem to have in common is input, whether it's a forum post, a blog entry, or an uploaded image. My website won't have any input, however, so I don't see any need for anything other than static code. Correct me if I'm wrong, though!
As for the second part, that's very good to know, although still not quite enough of a reason for me to use php.
If the site will only ever be a small site with a few pages, and you really don't need any dynamic stuff, then I'd suggest making it a static html site. You can easily create a program in Blitz to generate the site from template files, etc, which will make it simpler to manage. I've used this approach with a few sites.
If the site will potentially require a large number of pages at some point (hundreds or thousands) and/or requires dynamic stuff, then you're probably better off going for a dynamic approach. You can then use include files, etc, to build the site theme, menus, and other stuff you may find you might wish to change at some point.
Bear in mind that you can always start with a static site and change it to a dynamic site later on, if you find you need to do so.
Save yourself from a lot of unnecessary work and install one of the many Open Source Content Management Systems (Typo3, WordPress, whatever else).
But in case you really, really want to do it all yourself -- forget HTML and use Flash.
But in case you really, really want to do it all yourself -- forget HTML and use Flash.
Forget Flash and use html+css/whatever...
Flash is slow, big, inaccessible to blind people, poorly indexed by search engines, proprietary, and not supported out of the box on many computers.
It definitely has its place (flash games and youtube-style streaming video), but making an entire site in flash is a bad idea.
Thanks for the information everyone. It seems a dynamic site might be overkill for what I'm trying to achieve.
I'll be sticking with html/css, simply because I'm fairly comfortable with it, and I personally don't like entirely-flash based sites.
I'll take a look into creating a blitz program like you said, Bill -- thanks for the tip!
My site is all html, and I did the copy paste method you said.
Worked fine for me, and it seems like your website is about the same size as mine.
Its in my sig if you want a look.
I'd do php/html/css - they all work together, and php really opens up alot of stuff like file reading/writing, cookies, ect.. plus you can use just html on a php file.
Making your site completely in Flash is sure-fire way to make sure that the first thing I click is the 'close' button.
I use HTML/PHP/CSS/MySQL for my site. I do it that way because then all I need to change is the content in the database, without worrying about site layout.
Why don't you write it all in PHP and create your own templates. Here is an example of how I write PHP pages with temlplates:
Content page looks like
<?php
include "../settings.inc.php";
$TEMPLATE = array();
$TEMPLATE['head'] = "Some head HTML";
$TEMPLATE['content'] = "Some content";
include "../template.inc.php";
?>
The template looks like:
<html>
<head>
<?=$TEMPLATE['head'];?>
</head>
<body>
<?=$TEMPLATE['content'];?>
</body>
</head>
I use the same technique on my website:
http://www.nextpoint.co.ukObviously you can make your template more advanced and have multiple templates and multiple content areas - but you see how I'm using an array to inject the content into the tempplate. No need to write a program to create static HTML pages that you need to upload the whole site for every change you want to make the the template, etc.
Certainly don't do your website in Flash - it will restrict you in terms of maintainability, ability to have specific landing pages, people not being able to bookmark pages, not being accessible to blind people and search engines not being able to see your content - plus long downloading times will turn people away from your website.
I know it's kinda repeating what other people have said, but as a web developer (working for a web design company, not just from my bedroom).
I would suggest using PHP even if you don't use a database, that way you can have a header and footer include.
In the header you have everything that would be at the top of the page including your navigation, that way if something changes, you only need to change one file instead of 10 or 20 depending on the size of your site.
In the footer I'd put things I want on every page, like javascript (google analytics for instance), and also any footer navigation.
For PHP I recommend Zend_View and Zend_Layout. These are 'templating engines' that are much faster than template engines like Smarty. Smarty for example has it's own syntax so unless you use a compiled cache it has to interpret the template. Any template functionality you want to add has to come from own written content filters or template functions.
Zend_View and Zend_Layout just use native PHP, like Game Boy's example. So any PHP command will just work.
Using a natural template method, you can also define your own settings, like as follows:
<?php
include "../settings.inc.php";
$TEMPLATE = array();
$TEMPLATE['head'] = "Some head HTML";
$TEMPLATE['content'] = "Some content";
$TEMPLATE['title'] = "Title example";
$SETTINGS = array();
$SETTINGS['show_contactInfo'] = true;
$SETTINGS['title_bigger'] = true;
include "../template.inc.php";
?>
... template:
<html>
<head>
<?=$TEMPLATE['head'];?>
</head>
<body>
<?php
if($SETTINGS['title_bigger'] == true)print"<h1>".$TEMPLATE['title']."</h1>";
else print $TEMPLATE['title'];
print $TEMPLATE['content'];
if($SETTINGS['show_contact'] == true)print $TEMPLATE['show_contact'];
?>
</body>
</head>
Your templates can then also include whatever standard headers and footers they need to also.
I would suggest using PHP even if you don't use a database, that way you can have a header and footer include.
If that's all you want to do you can also use plain html with ssi (service-side includes, .shtml)
ive been working with smartyphp template engine, its very cool and takes away the template coding while you develop your site.
very cool indeed.
http://www.smarty.net/kev
@Gameboy,
Quite frankly that is a terrible way of doing things. You should be seperating the logic from the view - don't have any HTML in your PHP code!
I suggest you try a templating library like SMARTY :
http://www.smarty.net/whyuse.phpEDIT: Seems Kev read my mind.
@Indiepath
Quite frankly that is a terrible way of doing things. You should be seperating the logic from the view - don't have any HTML in your PHP code!
Maybe my second example was a bit misleading because it's a basic example. In my real code, all HTML layout is supported by CSS and so has the advantage of keeping both code maintenance and layout maintenance separate. Design elements can also be chosen to be presented by the programmer within their main code file, which is then injected into the template. This is essentially the same as what the Smarty template engine is doing, but without using external code. A better example of what I mean is as follows:
Content file:
<?php
include "../settings.inc.php";
$TEMPLATE = array();
$TEMPLATE['head'] = "Some head HTML";
$TEMPLATE['content'] = "Some content";
$TEMPLATE['title'] = "Title example";
$SETTINGS = array();
$SETTINGS['show_contactInfo'] = true;
$SETTINGS['title_bigger'] = true;
if($SETTINGS['title_bigger'] == true)$TEMPLATE['content'] .= "<h1>".$TEMPLATE['title']."</h1>";
else print $TEMPLATE['title'];
$TEMPLATE['content'] .= $TEMPLATE['content'];
if($SETTINGS['show_contact'] == true)$TEMPLATE['content'] .= $TEMPLATE['show_contact'];
include "../template.inc.php";
?>
Template:
<html>
<head>
<?=$TEMPLATE['head'];?>
</head>
<body>
<?=$TEMPLATE['content']?>
</body>
</html>
Taking the example further, you could separate the rules defined using the $SETTINGS array into another file so that all your pages share one common set of rules that automatically populate and modify the $TEMPLATE array, but lets keep things simple for the example ;-).
For what you need, I'd just do an XSLT-based site. No need for PHP to create template based websites. Even if you did need PHP, you'd be much better off choosing a proper web application framework (like Django) over using straight PHP. The PHP syntax is horrible (compared to Python), and debugging even remotely complex sites, is practically impossible.
You can learn more about XSLT
here.
Surprisingly, FlameDuck, I do know XSL quite well -- I just never considered it for this project. I'll take a look into that, though.
Thanks for the suggestions, everyone -- there seem to be plenty of options for me to choose from.
The PHP syntax is horrible (compared to Python), and debugging even remotely complex sites, is practically impossible.
I've found it has a nice syntax and is very flexible - especially the array features it has. Everyone has their own opinion though - and the main thing is that whatever method you use work.
The more I think about it, the more FlameDuck's suggestion of XSL is appealing. However, I've never used it in this context before. Wouldn't I still need PHP or something similar to carry out the transformation on the server side?
No. All mayor browsers, from IE 6 / Firefox 1.02 (IIRC) have a built in XSLT processor (on the client side). If you want to have it running on Lynx, then okay you might run into issues, but for IE/FireFox/Opera/Safari, you should be fine.