maandag, 05 juli, 2010

HTML as PHP

With a proper configuration on the server you can use webpages with a html extention as php files.

The question was raised in the iWeb forum at Apple Discussions.

Here's an explanation :

Execute PHP from a .html File

I used this :

AddType application/x-httpd-php .html

Here's a widget_markup file. You won't see anything php in the source :

http://dailynews.webege.com/phpdemo/widget1_markup.html

This is what I pasted in the HTML Snippet :

<?php
echo("hello world\n");
?>

How to create a .htaccess file on the server, read this :

http://iweb.dailynews.webege.com/PHP_parse_error.html
Geplaatst door wyodor at 21:34.21
Categories: Web

zaterdag, 22 mei, 2010

iWeb : Adding Google Analytics without editing the webpage

Google Analytics is a service that tracks the visitors of your webpage and provides information about where they come from, what pages they visit, what they use as Operating System and Browser and how long they stayed on your website. And a lot more.

Google uses JavaScript code which you have to paste in the webpage.

iWeb has no way of adding this to the webpage. After publishing you must open the html file in a plaintext editor and paste the code before the </body> HTML element. Then save the page.

Everytime you edit the page in iWeb, you have to edit the published page again to add the code.

Rather cumbersome.

Here's how you can add the code with the HTML Snippet.

Go to Google Analytics and sign-up for an account if you haven't already done that.

Create a new profile for your website.

It will provide you with a Webuser ID and the JavaScript code :

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

Open een plaintext document and paste the code without these lines :

<script type="text/javascript">
</script>

Save the file as plaintext and give it a meaningful name : I use analytics.js

Connect to your webserver and create a folder in the root of the server and put the file in it. I call this folder js.

Open iWeb and select the Site and page you want to track.

Add the HTML Snippet and paste this code :

<script type="text/javascript">

var bodyID = parent.document.getElementsByTagName("body")[0];

var newScript = parent.document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = '/js/analytics.js';
bodyID.appendChild(newScript);

</script>

Publish the page and open it in the browser. In Safari open the Activity window (Command-Option-A).

Check to see that the /js/analytics.js file is loaded correctly and a very long URL to Google is present.

The newScript.src = '/js/analytics.js'; only works when you have your own domain.

If you use both web.me.com/username and Personal domain, use newScript.src = '../js/analytics.js'; for non-blog pages and newScript.src = '../../js/analytics.js'; with the main blog page.

And again, verify it.

Geplaatst door wyodor at 12:45.59
Categories: Design, Web

dinsdag, 04 mei, 2010

iWeb : HTML5 Audio and Video

Based on some topics in the iWeb forum at Apple Discussions about HTML5 I decided to give it a go too.

I already made the BlowUp and 3D pages described earlier.

Now I added some sample pages with audio and video.

HTML5 AudioHTML5 Video

Both pages determine if a browser supports html5 and what audio or video formats.

Usually mp4/mpeg (h.264/AAC) or ogg. On the audiopage it falls back to a Flash Audioplayer if html5 is not supported.

I wrote the JavaScript in the past few days with some help from code at Apple Developers :

Safari HTML5 Audio and video Guide

I think it all looks rather well. See if you can apply it to your own pages.

Geplaatst door wyodor at 11:12.32
Categories: Design, Web