tag:blogger.com,1999:blog-356781702024-02-08T20:34:02.718+00:00Creating a Classified Adverts websiteA discusssion on the creation of a series of internet only classified advert sites.
Disclosing many truths about owning and operating such sites.Alex Patersonhttp://www.blogger.com/profile/04777614680963312710noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-35678170.post-5120682211406002992006-10-15T17:27:00.000+01:002006-10-16T08:36:03.385+01:00A Class act - object oriented programmingProgramming with objects (OOP) is both easy and flexible. It is one of the main tools in a programmers Toolbox.<br /><br />Objects are created with PHP and most other programming languages, using Classes.<br /><br />Basically an object is Defined. For example:- an Advert.<br /><br />This object (advert) is then constructed within the computers memory.<br /><br />The object has properties, for our advert object those could be an <span style="font-weight: bold;">identity</span>, an <span style="font-weight: bold;">owner</span>, and other information about the advert. Properties are simply <span style="font-weight: bold;">variables</span> within the class.<br /><br />You can do things with the object, again using the advert object as our example. You can <span style="font-weight: bold;">view</span> it, <span style="font-weight: bold;">create</span> it, <span style="font-weight: bold;">update</span> it etc etc. The things you can do with an object are called methods, essentially the methods are <span style="font-weight: bold;">functions</span> of the class<br /><br /><br />As this blog progreses, it will become clear how powerfull OOP is, whilst retaining simplicity.<br /><br />So without further ado, lets discuss what objects we will need in our Classified advertising site. as well as what we will want to do with these objects.<br /><br /><br />The objects, starting with the obvious, but not in any particular order.<br /><table style="width: 640px; height: 440px;" border="1"><br /><tbody><tr><br /><th scope="col">Object</th><br /><th scope="col">Properties</th><br /><th scope="col">Methods</th><br /></tr><br /><tr><br /><td>Advert</td><br /><td><br /></td><br /><td><br /></td><br /></tr><br /><tr><br /><td>Image</td><br /><td><br /></td><br /><td><br /></td><br /></tr><br /><tr><br /><td>Thumbnail</td><br /><td><br /></td><br /><td><br /></td><br /></tr><br /><tr><br /><td>Banner</td><br /><td><br /></td><br /><td><br /></td><br /></tr><br /><tr><br /><td>User</td><br /><td><br /></td><br /><td><br /></td><br /></tr><br /><tr><br /><td>Session</td><br /><td><br /></td><br /><td><br /></td><br /></tr><br /><tr><br /><td height="21">Authorisation</td><br /><td><br /></td><br /><td><br /></td><br /></tr><br /><tr><br /><td height="21">Signup</td><br /><td><br /></td><br /><td><br /></td><br /></tr><br /><tr><br /><td height="21">Smarty<br /></td><br /><td><br /></td><br /><td><br /></td><br /></tr><br /><tr><br /><td height="21">Database<br /></td><br /><td><br /></td><br /><td><br /></td><br /></tr><br /></tbody></table>Alex Patersonhttp://www.blogger.com/profile/04777614680963312710noreply@blogger.com0tag:blogger.com,1999:blog-35678170.post-41715994662463902006-10-15T10:20:00.000+01:002006-10-15T17:26:39.897+01:00A Smart move - The Smarty template EngineAs was discussed in the previous blog, our classified advertising site is coded using PHP.<br /><br />If you have looked at more than a few php scripts, then you will know that<br />the combination of the php code embedded thorough the HTML code all in the one script is<br />both messy and cumbersome,<br />quite honestly it looks a mess.<br />For larger projects, such as this one, the coding would put anyone off the subect<br />for life.<br />There is a much better way.<br /><br />Using a template Class allows us to fully seperate the php code from the HTML.<br />Using such a class is almost essential for these larger projects. <br /><br />Whilst Smarty is not the only templating class available, it is one of the<br />best. It has been around for some time, so it is mature and stable. Also it is public domain.<br /><br /><br />The Smarty class<br />allows you to code all of the php in one script and place all of the<br />HTML code in a seperate file. This HTML file is not quite free of<br />programming, but it is simplified to the extent that it is merely<br />referencing of variables , looping of arrays and using simple if<br />statements.<br /><br />All of the complex stuff, like referencing of<br />databases, parsing of xml data figuring out sessions etc etc is done by<br />clean, clear, simple, pure php code.<br /><br /><br />The smarty HTML files are called templates(no surprise there) and use the extension .tpl<br />They have embedded within them the much simplified smarty programming code. <br /><br /><br />The PHP code gets the required information, puts it in variables or arrays and passes these to Smarty. via a statement like:-<br /><br />$Smarty->assign('description',$description);<br /><br />You<br />them tell Smarty which template(s) to use and the class will processes<br />these templates with the embedded code to produce the final HTML Page.<br /><br />such as:-<br /><br />$Smarty->display('header.tpl'); <br />$Smarty->display('body.tpl'); <br />$display->display('footer.tpl');<br /> <br /><br />There is a lot more to Smarty than mentioned here. Suffice to say, that we will cover the subject more thoroughly as and when we need it throughout this blog.Alex Patersonhttp://www.blogger.com/profile/04777614680963312710noreply@blogger.com0tag:blogger.com,1999:blog-35678170.post-1160282740449486822006-10-08T05:39:00.001+01:002008-03-09T08:40:01.083+00:00IntroductionThere are now many classified advert sites online.<br />Some, mostly those owned by larger companies, charge a fee to place an advert on their site.<br />When you consider how cheap they actually are to own and operate, it makes you wonder what these guys do with all the money they are making. Look at autotrader.co.uk and try to estimate how much they are making. At £25.00 per fortnight per ad, it's a lot.<br /><br /><br />Whilst the internet is essentially public domain, it should be appreciated that we should indeed be able to make money from the sites we have created, especially if that site is of value to the community. After all there is some work and costs involved.<br /><br />So I am going to discuss ways of keeping such a site free to the end user, whilst still making some money from it.<br /><br />There are many commercial classified ad scripts available, but they are not flexible enough to completely customise. In addition, if you want more than just basic functionality like adding multiple pictures, creating thumb nails etc, then you will have to pay a fee, which can be considerable. Also, there's not much satisfaction to be gained from such a thing.<br /><br />Classified Advertising sites can be as complex as you want, but they are not beyond the scope of anyone who can read, write and has a moderate amount of intelligence.<br /><br />In a series of blogs over the next several months, I intend to discuss in detail, the methods I have used to create such sites.<br />In the process, we will create another new one, to prove how easy it really is.<br /><br />The new site will be called YFORS, standing for <a href="http://www.yfors.com/">Yachts for sale.</a>.<br />The detail will have enough information to allow you to develop your own Internet classified advertising site for any purpose you wish.<br /><br />Once the site has been coded, tested and uploaded as a live site, there is still a lot of work to do to make the site popular. But when this is achieved you will be amazed, the site will become almost alive, as users upload and amend their own adverts.<br /><br /><br />Other sites I am responsible for are - <a href="http://www.afors.com/">aircraft for sale</a> and <a href="http://www.mfors.com/">motorcycles for sale</a> www.afors.com and www.mfors.com respectively. So you can see, the code could be used for any classified items, Including houses.<br /><br />The sites essentially use the same core code, which is written in PHP, and the database is MySql. The sites also take advantage of the <a href="http://smarty.php.net/">Smarty Template engine</a>, which allows complete separation of the PHP programming code, from the HTML template Code. This is a very big advantage as it simplifies things considerably, as you will discover in later posts.<br />The PHP code is written using modern programming techniques. i.e. utilising classes.<br /><br />The HTML templates are not completely without some programming skills, but these are reduced to a very basic level. If you can write HTML, you can also do Smarty.<br /><br /><br />If you are new to Internet programming, then this will be a very good learning experience. Most of the code is beginner to intermediate level, but there are some advanced bits, like parsing XML data from AMAZON, and creating static pages from dynamic data, but I will explain these comprehensively and carefully.<br /><br />It's going to take a while though, as there is a lot to cover.<br /><br /><br /><br /><br />AlexAlex Patersonhttp://www.blogger.com/profile/04777614680963312710noreply@blogger.com0