Topic: mobile version
I'm not a programmer and I don't know how to create a plugin... but I played a little bit with this script that generates a mobile version for small websites.
All you have to do is to download jquerymobile from http://jquerymobile.com/ and create a page with the following script:
<?php
$omit_pages = array('gallery', 'other-page');
?>
<?php
$www = array('www.');
$no_www = array('');
$output = str_replace($www, $no_www, $_SERVER['HTTP_HOST']);
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $output; ?> - mobile version</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="<?php echo URL_PUBLIC; ?>public/jquery.mobile/jquery.mobile-1.0a1.min.css" />
<script src="<?php echo URL_PUBLIC; ?>public/jquery.mobile/jquery-1.4.3.min.js"></script>
<script src="<?php echo URL_PUBLIC; ?>public/jquery.mobile/jquery.mobile-1.0a1.min.js"></script>
<?php echo "<link rel=\"canonical\" href=\"" . URL_PUBLIC . "\" />"; ?>
</head>
<body>
<div data-role="page" data-theme="a" id="home">
<br /><center><?php echo $output; ?> - mobile version</center>
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="a">
<li><a href="#<?php echo $this->find('/')->title(); ?>" rel="external" data-transition="slide"><?php echo $this->find('/')->title(); ?></a></li>
<?php
foreach($this->find('/')->children() as $page)
{
$page_children = $page->children();
if (in_array($page->slug, $omit_pages)) {
continue;
}
if( count($page_children) > 0 )
{
echo '<li data-theme="c" data-icon="arrow-d"><a href="#">'.$page->title().'</a></li>';
}
else
{
echo '<li data-theme="c"><a href="#'.$page->slug.'" rel="external" data-transition="slide">'.$page->title().'</a></li>';
}
if( count($page_children) > 0 )
{
foreach( $page_children as $subpage )
{
echo '<li class="ui-li ui-btn ui-btn-icon-right ui-btn-up-c" data-role="button"> <a href="#'.$subpage->slug.'" rel="external" data-transition="slide">'.$subpage->title.'</a></li>';
}
}
}
?>
</ul>
</div>
<center>
View in <b>Mobile</b> | <a href="/">Classic</a><br />
</center>
<div data-role="footer">
<p><center>© <?php echo date('Y'); ?> <?php echo $output; ?></center></p>
</div><!-- footer -->
</div><!-- page home -->
<div data-role="page" id="<?php echo $this->find('/')->title(); ?>">
<div data-role="header">
<h1><?php echo $this->find('/')->title(); ?></h1>
</div><!-- header inside -->
<div data-role="content">
<p><?php echo $this->find('/')->content(); ?></p>
</div><!-- content inside -->
<center>
View in <b>Mobile</b> | <?php echo $this->find('/')->link('Classic', 'rel="external" target="_blank"') ?><br />
</center>
<div data-role="footer">
<p><center>© <?php echo date('Y'); ?> <?php echo $output; ?></center></p>
</div><!-- footer inside -->
</div><!-- page inside -->
<?php foreach ($this->find('/')->children() as $pagechild): ?>
<?php if (in_array($pagechild->slug, $omit_pages)) {continue;}?>
<div data-role="page" id="<?php echo $pagechild->slug(); ?>">
<div data-role="header">
<h1><?php echo $pagechild->title(); ?></h1>
</div><!-- header inside -->
<div data-role="content">
<p><?php echo $pagechild->content(); ?></p>
</div><!-- content inside -->
<center>
View in <b>Mobile</b> | <?php echo $pagechild->link('Classic', 'rel="external" target="_blank"') ?><br />
</center>
<div data-role="footer">
<p><center>© <?php echo date('Y'); ?> <?php echo $output; ?></center></p>
</div><!-- footer inside -->
</div><!-- page inside -->
<?php foreach ($this->find($pagechild->slug())->children() as $pagegrandchild) : ?>
<div data-role="page" id="<?php echo $pagegrandchild->slug(); ?>">
<div data-role="header">
<h1><?php echo $pagegrandchild->title(); ?></h1>
</div><!-- header inside -->
<div data-role="content">
<p><?php echo $pagegrandchild->content(); ?></p>
</div><!-- content inside -->
<center>
View in <b>Mobile</b> | <?php echo $pagegrandchild->link('Classic', 'rel="external" target="_blank"') ?><br />
</center>
<div data-role="footer">
<p><center>© <?php echo date('Y'); ?> <?php echo $output; ?></center></p>
</div><!-- footer inside -->
</div><!-- page inside -->
<?php endforeach; ?>
<?php endforeach; ?>
</body>
<?php $this->includeSnippet('snippet-traffic'); ?>
</html>Any suggestions or improvements are more then welcome.
Thanks!
N
Last edited by negru (2010-12-09 21:46)



