What's new

making a web site mobil???

  • Thread starter mohawk-man
  • Start date
  • Views 354
M

mohawk-man

Newbie
Messages
29
Reaction score
0
Points
35
Sin$
0
making a web site mobile???

Some of my users go on my site with there sidekicks and they wanted it too be easier to log on.
How can I make my site so that ppl with cell phones can get on it with no hasle?
 
H

HeadTax

Banned
Messages
10
Reaction score
1
Points
45
Sin$
7
Step 1: Set up a domain mirror

If your site lives at Anything and Everything I Want to Blog About — My Awesome Blog, you’re going to want to set up a subdomain at mobile.myawesomeblog.com. How you accomplish this is usually pretty straightforward but differs depending on your host. I use Dreamhost and from their control panel, I can add subdomains effortlessly until I pass out from excitement. You want to set up your subdomain as a “mirror” of your main site, meaning the subdomain is really just pointing to your existing site.
Step 2: Create global_prepend file

The next thing we’re going to do is a create a PHP file which will be automatically prepended to every page of our site. Call this file something like "global_prepend.php" and throw it at the root of your server:

<?php
function callback($buffer) {
if ($_SERVER['SERVER_NAME'] == ‘mobile.myawesomeblog.com’) {
$buffer = str_replace(’http://www.myawesomeblog.com’, ‘http://mobile.myawesomeblog.com’, $buffer);
$buffer = preg_replace(’/[\n\r\t]+/’, ”, $buffer);
$buffer = preg_replace(’/\s{2,}/’, ‘ ‘, $buffer);
$buffer = preg_replace(’/(<a[^>]*>)(<img[^>]+alt=”)([^"]*)(”[^>]*>)(<\/a>)/i’, ‘$1$3$5
’, $buffer);
$buffer = preg_replace(’/(<link[^>]+rel=”[^"]*stylesheet”[^>]*>|<img[^>]*>|style=”[^"]*”)|<script[^>]*>.*?<\/script>|<style[^>]*>.*?<\/style>|<!–.*?–>/i’, ”, $buffer);
$buffer = preg_replace(’/<\/head>/i’, ‘<meta name=”robots” content=”noindex, nofollow”></head>’, $buffer);
}
return $buffer;
}
ob_start(”callback”);
?>
This code uses a PHP function called ob_start() to read in your entire HTML source, run some rules on it, and then send the output to users’ web browsers… all in real time. The first "if" statement simply checks to see if the user is coming from our special “mobile” URL, and if so, runs seven replace statements on the code. Here’s what each line does:

  1. Changes all URLs to “mobile”-ized URLs.
  2. Strips all linefeeds, carriage returns, and tabs.
  3. Trims multiple spaces down to one (HTML doesn’t recognize more than one space in a row).
  4. Changes any anchored images with alt text to plain text anchors.
  5. Strips all stylesheets, images, inline styles, scripts, and comments (including RDF).
  6. Tells search engine robots not to index or crawl the mobile version of the site so as to not create duplicate listings.
Step 3: Create global_append file

Next, we need to create a tiny PHP file which will automatically get added to the end of every file on our site. This is the code that actually outputs the page to the browser. So the flow is like so: Suck code into buffer, siphon fat away, spit contents of buffer into browser.
The code for the global_append file is below. Call it something like "global_append.php" and throw it at the root of your server:

<?php
ob_end_flush();
?>
Step 4: Enable prepends and appends using .htaccess

If you don’t already have an .htaccess file at the root of your server, open up a new text file and add these lines to it:
php_value auto_prepend_file /localfilepath/global_prepend.php
php_value auto_append_file /localfilepath/global_append.php
Then save it to the root of your server with the filename ".htaccess". If you already have an .htaccess file, just add the above lines to it.
* Important Note: If you copy these two lines from your web browser, you might need to delete the carriage return and make your own. Sometimes a browser’s carriage return will cause your .htaccess file to fail (you’ll know immediately if it has failed because your site won’t come up).
Assuming your subdomain is live, you should now be able to hit your site in a web browser using the special mobile URL and see a nice, compact, imageless, styleless, scriptless version of your site. Voila!
 
M

mohawk-man

Newbie
Messages
29
Reaction score
0
Points
35
Sin$
0
Great thank you this helped. :biggrin:D
But how can I get it to apply to my vb too?
 
punkskater2448

punkskater2448

Taking Over The World
Retired
Messages
4,307
Reaction score
863
Points
475
Sin$
0
there should be a mod for vb to allow memebrs to use their phones n have it in mobile format.
 
M

mohawk-man

Newbie
Messages
29
Reaction score
0
Points
35
Sin$
0
punkskater2448 said:
there should be a mod for vb to allow memebrs to use their phones n have it in mobile format.
Oh cool thanks Ill search for it on vborg. =D
 
Top Bottom
Login
Register