Archive

Author Archive

Google Unveils Virtual Panoramas of Ski Runs At The 2010 Winter Olympic Games

February 11th, 2010

Google has added the Winter Olympics slopes to its Street View , allowing people to see the same view down a mountain as a skier about to push off in their quest for gold.

Engineer Dan Ratner explained: “In typical scrappy Google fashion, we were able to put this together over a few weekends. We used extra pieces from our Street View cars, some 2×4s, some duct tape, and a lot of extra hard drives.

Author: Zero7Web Categories: General, News Tags: , ,

How to: Allow hyphens in URL’s using ASP.NET MVC 2

February 6th, 2010

If you wan’t to allow hyphens in your URL’s you will need to change the way the routing works in your Global.asax file.

First create a new class which extends the MvcRouteHandler and place this in the Global.asax file after the main MvcApplication class.

C#:

public class HyphenatedRouteHandler : MvcRouteHandler{
	protected override IHttpHandler  GetHttpHandler(RequestContext requestContext)
	{
		requestContext.RouteData.Values["controller"] = requestContext.RouteData.Values["controller"].ToString().Replace("-", "_");
		requestContext.RouteData.Values["action"] = requestContext.RouteData.Values["action"].ToString().Replace("-", "_");
		return base.GetHttpHandler(requestContext);
	}
}

VB:

Public Class HyphenatedRouteHandler
    Inherits MvcRouteHandler
 
    Protected Overrides Function GetHttpHandler(ByVal requestContext As System.Web.Routing.RequestContext) As System.Web.IHttpHandler
        requestContext.RouteData.Values("controller") = requestContext.RouteData.Values("controller").ToString.Replace("-", "_")
        requestContext.RouteData.Values("action") = requestContext.RouteData.Values("action").ToString.Replace("-", "_")
        Return MyBase.GetHttpHandler(requestContext)
    End Function
 
End Class

Then you need to replace the routes.MapRoute with an equivalent routes.Add specifying the new handler as the MapRoute does not allow you to specify a custom route handler.

C#:

routes.Add(
	new Route("{controller}/{action}/{id}", 
		new RouteValueDictionary(
			new { controller = "Default", action = "Index", id = "" }),
			new HyphenatedRouteHandler())
);

VB:

routes.Add(New Route("{controller}/{action}/{id}", 
	New RouteValueDictionary(New With {.controller = "Home", .action = "Index", .id = ""}), 
		New HyphenatedRouteHandler()))

I hope this is useful, any questions feel free to get in touch.

Would like to say thanks to John from here for answering the original question on Stackoverflow

Author: Zero7Web Categories: .NET Tags: , , , , ,

ASP.NET MVC 2 RC 2 Released

February 5th, 2010

Today ASP.NET MVC 2 RC2 has been released.

To download it click here

It seems there are only a few changes to this release which you can find here: Release Notes

A few words from Phil Haack’s blog:

The biggest change in this release was described by Brad Wilson in his blog post on Input Validation vs. Model Validation in ASP.NET MVC. Also included in this release are an assortment of bug fixes and performance improvements.

The window to provide feedback on this release is going to be very short as we are closing in on the RTM. If you want to provide input into this release, please do take the bits for a spin as soon as possible. I’m pretty excited about this release as I can see the end of the tunnel fast approaching. :)

At this point, we’ll only be taking recall class bugs for ASP.NET MVC 2. All other bug reports will be filed against ASP.NET MVC 3. Sometime in the near future, I’ll start sharing some of our planning around that. How exciting!

Author: Zero7Web Categories: Development, General Tags: , ,

Facebook launch HipHop, a sourcecode-converter from php to c++

February 3rd, 2010

Yesterday Facebook launched HipHop, a converter from php to c++ so your apps can run twice as fast due to them being compiled not interpreted.

Today I’m excited to share the project a small team of amazing people and I have been working on for the past two years; HipHop for PHP. With HipHop we’ve reduced the CPU usage on our Web servers on average by about fifty percent, depending on the page. Less CPU means fewer servers, which means less overhead. This project has had a tremendous impact on Facebook. We feel the Web at large can benefit from HipHop, so we are releasing it as open source this evening in hope that it brings a new focus toward scaling large complex websites with PHP. While HipHop has shown us incredible results, it’s certainly not complete and you should be comfortable with beta software before trying it out. – Haiping Zhao (Facebook)

HipHop is for scaling large multiserver high traffic sites like Facebook. In your regular application, you will get no great advantage from it. It is definately something to be aware of but it does make you think if your trying to compile PHP using a tool like this why not develop in C# (ASP.NET MVC 2 maybe?) that is compiled anyway?

Author: Zero7Web Categories: Development Tags: , , , ,

How to: Use JQuery – The Basics

January 29th, 2010

JQuery Basics
This post will show you some of the basics of JQuery. It is not an in depth tutorial but will give you some pointers to get you started with JQuery.
OK, the first piece of code you need to use JQuery is a link to the JQuery JS library. First, download the latest JQuery Library from the following link….
http://docs.jquery.com/Downloading_jQuery
Then link to it like any other javascript file (like so)…

<script src="./js/jquery-1.4.1.js"></script>

Obviously choosing the correct path for your version web server file system setup.
The next step after linking the JQuery library is to use it! Look at the following piece of code.

<script src="./js/jquery-1.4.1.js"></script>
	<script>
		$(document).ready(function() {
			// here is some code
		});
	</script>

This is essentially the same as calling a standard Javascript Window.OnLoad event handler, except it’s the JQuery way.
We are saying… when the document is ready (loaded) run some code.
This is your basic first step to using JQuery. You can also use other event handlers to launch your code, or even call the functions directly, but often when using JQuery, especially for styling/design features, you will want to run the code and so this is the easiest way.
At the moment this code is not very useful, as it doesn’t do anything, so let’s add a little more.
Let’s create a very basic html page.

<html>
	<head>
		<title>JQuery Basics</title>
	</head>
	<body>
		<a id="link1" class="myLink" href="#">Link 1</a>
		<a id="link2" class="myLink" href="#">Link 2</a>
		<a id="link3" class="myLink" href="#">Link 3</a>
	</body>
</html>

Ok now let’s add some JQuery….

<html>
	<head>
		<title>JQuery Basics</title>
		<script src="./js/jquery-1.4.1.js"></script>
		<script>
			$(document).ready(function() {
				$('a').click(function() {
					alert("This is JQuery in action!");
				});
			});
		</script>
	</head>
	<body>
		<a id="link1" class="myLink" href="#">Link 1</a>
		<a id="link2" class="myLink" href="#">Link 2</a>
		<a id="link3" class="myLink" href="#">Link 3</a>
	</body>
</html>

Now save the file and open it in a web browser. When you click a link you should find you get a popup.
Let’s examine this code a little further.

$('a').click(function() {
		alert("This is JQuery in action!");
	});

The first part

$('a')

is a selector, the same as in CSS. Here we are saying apply to all of the A (anchor) tags in the document.
Next we’re saying

.click(function() {

This means for all of those A tags use the click event handler.
Finally we’re saying when that click event is found on an A tag

alert("This is JQuery in action!");

This generates the popup.
In this example we chose to use

$('a')

as our selector, but there are many other ways we can select elements.

$('#link1').click(function() {

This is the same as the getElementByID function that is commonly used in JavaScript. Here we are selecting the element with the ID “link1”.
We could also use

$('.myLink').click(function() {

to select all elements with the class name “myLink”.

In our examples we have used the click event handler to launch the code when the link is clicked. We don’t have to add an event handler here if we don’t want to.
Let’s look at another example.

<html>
	<head>
		<title>JQuery Basics</title>
		<script src="./js/jquery-1.4.1.js"></script>
		<script>
			$(document).ready(function() {
				$('a').addClass("red");
			});
		</script>
	</head>
	<body>
		<a id="link1" class="myLink" href="#">Link 1</a>
		<a id="link2" class="myLink" href="#">Link 2</a>
		<a id="link3" class="myLink" href="#">Link 3</a>
	</body>
</html>

This sets all A tags in documents to have the class “red”.
This is a basic class which is built into the JQuery library, but you could just as easily add your own class.

<html>
	<head>
		<title>JQuery Basics</title>
		<script src="./js/jquery-1.4.1.js"></script>
		<script>
			$(document).ready(function() {
				$('a').addClass("myClass");
			});
		</script>
		<style>
			.myClass {
				color:blue;
				text-decoration:underline;
			}
		</style>
	</head>
	<body>
		<a id="link1" href="#">Link 1</a>
		<a id="link2" href="#">Link 2</a>
		<a id="link3" href="#">Link 3</a>
	</body>
</html>

You could also use first, last, parent and child selectors just like in CSS. For example

$('a:first').addClass("myClass");

to select the first of the link tags and apply the class “myClass” just to that first link.

These are just a few very basic examples of how you can start using JQuery, look out for more posts in the future where we will show you some of the many other exciting features of JQuery.

Author: Zero7Web Categories: General Tags: , , , ,

30,000 Niche Market Articles at Your Fingertips to use as you please (plus e-book creation tool)

January 23rd, 2010

I found this on another blog and thought it would be very useful for a lot of the readers:
Original Blog Link

I thought this would be of interest to you all. It’s a piece of software you can get your hands on that gives you access to 30,000 Niche articles that you can use as you please. Place them on your blog to generate traffic or give them away as freebies to attract people towards your chargeable products.

You can use these articles to help create backlinks to your sites and you can even create One-of-a-Kind eBooks with the Built in eBook Creation Wizard. Bonus!

There’s a free video you can watch that shows how it works and just how easy it is to get going. The time you will save by having a massive library of articles is going to be insane!

This is highly recommended by us and we would like to hear your success stories, because there will be a lot of them! I have bought into this package myself and I can honest say I am very glad as I not how content to post on all of my other website to bring in the visitors.

Visit the site now to watch your free video explaining more…

Andi Gibson Photography Website Online

January 15th, 2010

Andi Gibson’s Photography site is now online. The simple design was requested to create a nice sleek look. The site is sat on top of a wordpress blog and will be updated regularly with portfolio and company information.

Visit website

Author: Zero7Web Categories: General Tags:

210 Dental Clinic Website Complete

January 15th, 2010

The 210 Dental Clinic is now online. The site has been developed over the past few months and the client is very happy with the end result.

210 Dental Clinic Website

Author: Zero7Web Categories: General Tags: , ,

What are RSS and Atom Feeds and how do I create them?

November 25th, 2009

What are feeds?

Really Simple Syndication (RSS) and Atom feeds are different formats used to publish updates or changes such as new blog entries, news entries or user activity in a standard format. The feed is basically an XML document containing certain information about the updated content.

What information do they contain?

The “feed”, “web feed” or “channel” includes full or summarised text, plus metadata such as published date, category and authorship.

Should I use RSS or Atom?

RSS is more widely used as it was around first although the Atom feed standards seen to have a better structure I personally would stick with RSS 2.0 as it will work on all readers and software, and people are familiar with the term RSS.

Why should I use a feed on my website?

Web feeds make it easy to inform people of changes to your website. Anyone interested in your feed can subscribe to it via an RSS reader which can then keep track of updates for you. You can use fees in outlook, through the browser or through many desktop applications available.

How can I create a feed?

I will talk you through a very basic example of a feed to get you started but if your interested in taking it further you should read the RSS 2.0 specs and also those for Atom feeds.

You can either generate the feed manually or dynamically, but either way the end result will be structured the same.

Below is an example of a RSS document (XML).

<rss version="2.0">
 <channel>
  <title>Social Addict Feed</title>
  <description>This shows the latest updates on socialaddict.co.uk</description>
  <link>http://www.socialaddict.co.uk</link>
   <item>
    <title>HOUSJUNKI :: BOXING DAY :: 26.12.09 :: CLUB.V</title>
    <link>http://www.socialaddict.co.uk/events/single-event?eID=91</link>
    <description>Event added: HOUSJUNKI :: BOXING DAY :: 26.12.09 :: CLUB.V @ Club Venus by andoi - Sat 21st Nov 2009 8:19pm</description>
    <category>EVENT</category>
    <pubDate>Sat, 21 Nov 2009 20:19:40 +0000</pubDate>
    <copyright>(c) Social Addict 2009</copyright>
   </item>
 </channel>
</rss>

Creating a static feed

Simply take the code you have produced like above and save it as an XML document, rss.xml will be fine and then upload to your website. You take give out a direct link to the feed or if you would like users of the website to pick up that it exists automatically then simply add the following code into the head area of the HTML code.

<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="rss.xml" />

Dynamically creating a feed using PHP

If you have a dynamic (database driven) website then it would make more sense to dynamically generate the feed.

We have recently made a feed for a client site ( www.socialaddict.co.uk/rss ) and we had to bring together the data from several different tables and merge them so the feed could take all updates into account.

We used the RSS2Writer class to generate the XML document which simplies the use of the PHP XMLWriter object. Grab yourself a copy of the class and you can use the example below to help get you started.

This is assuming you have a mySQL database with a table called “updates” and it contains:

`title` VARCHAR
`category` VARCHAR
`info` VARCHAR
`url` VARCHAR
`created` DATETIME

<?php
try {
 
   // Create RSS writer
  include('includes/RSS2Writer.php');
   $rss = new rss2writer('Social Addict Feed', 'This shows the latest updates on    socialaddict.co.uk', 'http://www.socialaddict.co.uk');
 
    // Create Database connection
    $dbh = new PDO('mysql:host=localhost;dbname=test', 'username, 'password'); // put your database details in here
    // Get data and iterate through it
    foreach($dbh->query('SELECT `title`,`category`,`info`,`url`,`created` from updates') as $feed) {
 
        // Get each feed item information
	$rss->addItem($feed['title'], $feed['info'], $feed['url'], true);
	$rss->addElement('category', $feed['category']);
	$rss->addElement('pubDate', date("r",strtotime($feed['created'])));
	$rss->addElement('copyright', '(c) Social Addict 2009');
	$rss->closeItem();
 
    }
    $dbh = null;
 
    // Set header type to XML
    header('Content-type: text/xml');
 
   //$rss->writeToFile('rss.xml'); //write the xml output to file (optional)
   echo $rss->getXML(); // Output XML to browser / screen
 
// Catch any errors
} catch (PDOException $e) {
    print "An error occured: " . $e->getMessage() . "<br/>";
    die();
}
?>

Any questions are welcome, and we also help people out where we can.

Author: Zero7Web Categories: Development Tags: , , , , ,

How To: Create a re-usable form with the Zend Framework with validation and filters

November 2nd, 2009

It is quite easy to start using a framework as an easy way to manage your url rewriting, and forget about all the added functionality provided by the framework. An ideal example of this is when making forms. You can create a form manually and that is perfectly valid, but if you use the framework it will help you filter and validate the form with very little effort!

Zend_Form
The framework provides a Zend_Form class that you can extend to easily create forms and assign validation and filters too with a few simple lines of code. Name the elements the same as the db then the populate will work with one line of code also.

In your Application folder create a Forms folder

This is an example form:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
class Form_CreateEmail extends Zend_Form
{
public function __construct($options = null)
{
        parent::__construct($options);
 
        $this->setName('createemail');
        $title = new Zend_Form_Element_Text('title');
        $title->setLabel('Subject')
        ->setRequired(true)
        ->addFilter('StripTags')
        ->addFilter('StringTrim')
        ->addValidator('NotEmpty');
        $info = new Zend_Form_Element_Textarea('info');
        $info->setLabel('Email Content')
        ->setAttribs(array('rows' => 12, 'cols' => 79)); 
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id', 'submitbutton');
        $this->addElements(array($title, $info, $submit));
}
 
}
?>

You can then call it from your controller like this:

1
2
3
$form = new Form_CreateEmail();
$form->submit->setLabel('Add');
$this->view->form = $form;

And display it from you view using

1
echo $this->form;

If you want this to be included on everypage you could create a new helper file

in your views folder create a helpers folder and create a myHelper.php file

1
2
3
4
5
6
7
8
9
10
11
class Zend_View_Helper_MyHelper
{
    function myHelper()
    {
 
$form = new Form_CreateEmail();
        $form->submit->setLabel('Add');
        return = $form;
 
    }
}

This could be output from your layout using:

1
<?php echo $this->MyHelper(); ?>

Hope this helps someone

Author: Zero7Web Categories: General Tags: