Forum for discussing general topics related to Couch.
9 posts Page 1 of 1
I've built my mobile website home page.

Now I've got all my blog posts on the normal website which link to the main blog_post. Now what i wanted to-do was have a mobile page of that said blog_post rather than having the standard post showing the normal web view i want to create a mobile page that shows that post and that page rather than the normal web view.

but only shows the mobile page version when you use the mobile/index.php page. and when you use the normal website home page you go to the normal view rather than the mobile side of things

thats the mobile web view link - http://revlimitmag.com/mobile/index.php
Hi,

If I understood you correctly, you have two types of listing pages - normal and mobile.
Both of them list your blog posts and clicking on any blog post loads up the page view of that single blog post.
You wish to serve up a different (simpler) variation of the blog post when it is accessed from the mobile page and the normal one otherwise.

One way this can be done is wrapping your original code within some PHP code checking the 'referer page' i.e. the page from which this single blog page was called and then outputting contents accordingly-
Code: Select all
<?php
   if( $_SERVER['HTTP_REFERER']=='http://revlimitmag.com/mobile/index.php' ){
      ---- output your simpler content here ----
   }
   else{
      ---- output your original (normal) content here ----
   }
?>

Please try it out and let me know if this helps.
You could also use this (*click*) article or create a specific stylesheet for media="handheld" :)
Sincerely,
Johan

Brightsites
Webdesign, webdevelopment, webapplications, hosting, advice and more.
KK wrote: Hi,

If I understood you correctly, you have two types of listing pages - normal and mobile.
Both of them list your blog posts and clicking on any blog post loads up the page view of that single blog post.
You wish to serve up a different (simpler) variation of the blog post when it is accessed from the mobile page and the normal one otherwise.

One way this can be done is wrapping your original code within some PHP code checking the 'referer page' i.e. the page from which this single blog page was called and then outputting contents accordingly-
Code: Select all
<?php
   if( $_SERVER['HTTP_REFERER']=='http://revlimitmag.com/mobile/index.php' ){
      ---- output your simpler content here ----
   }
   else{
      ---- output your original (normal) content here ----
   }
?>

Please try it out and let me know if this helps.



I've used this code no problem

Code: Select all
<?php
   if( $_SERVER['HTTP_REFERER']=='http://revlimitmag.com/mobile/index.php' ){
      ---- output your simpler content here ----
   }
   else{
      ---- output your original (normal) content here ----
   }
?>


Now where do i enter for couch?

Code: Select all
<?php require_once( '../couch/cms.php' ); ?>


<cms:else /><cms:embed 'news_list.php' />
</cms:if>
<?php COUCH::invoke(); ?>
If this was your original code -
Code: Select all
<?php require_once( '../couch/cms.php' ); ?>

<cms:if k_is_page >
         ---- output your original (normal) content here ----
<cms:else />
   <cms:embed 'news_list.php' />
</cms:if>

<?php COUCH::invoke(); ?>

It becomes this -
Code: Select all
<?php require_once( '../couch/cms.php' ); ?>

<cms:if k_is_page >
   <?php
      if( $_SERVER['HTTP_REFERER']=='http://revlimitmag.com/mobile/index.php' ){
         ---- output your simpler content here ----
      }
      else{
         ---- output your original (normal) content here ----
      }
   ?>   
<cms:else />
   <cms:embed 'news_list.php' />
</cms:if>

<?php COUCH::invoke(); ?>
@Johan,
Thanks for the link.
One can use the code to set if 'mobile' is true and then use Couch tags to output accordingly.
Okay i just get a Parse error

my code is this

Red being the simple
Blue being my normal

All my pages are coded in .php

<?php require_once( '../couch/cms.php' ); ?>

<cms:if k_is_page >
<?php
if( $_SERVER['HTTP_REFERER']=='http://revlimitmag.com/mobile/index.php' ){
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<cms:template title='News' clonable='1' commentable='1' >
<cms:editable name='news_content' type='richtext' />

<cms:editable name='news_image'
crop='1'
width='118'
height='72'
type='image'
/>

<cms:editable
name='written_by'
label='written_by'
desc='You need to enter written by e.g (admin)'
type='text'></cms:editable>


</cms:template>
<cms:if k_is_page >
<head>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title><cms:show k_page_title /> | Revlimit Magazine</title>

<link href="../css/all_pages.css" rel="stylesheet" type="text/css" />
<link href="../css/links.css" rel="stylesheet" type="text/css" />
<link href="../css/nav.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
a:link { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color:#4F4F4F; font-weight:bold; }
a:hover { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color: #999999; font-weight:bold; }
a:visted { { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color:#4F4F4F; font-weight:bold; }
-->
</style>
</head>
<body>
<div class="text-title-pages"><cms:show k_page_title /></div>
<div class="text-area-pages"><cms:show news_content /></div>
</body>
<html>

}
else{
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<cms:template title='News' clonable='1' commentable='1' >
<cms:editable name='news_content' type='richtext' />

<cms:editable name='news_image'
crop='1'
width='118'
height='72'
type='image'
/>

<cms:editable
name='written_by'
label='written_by'
desc='You need to enter written by e.g (admin)'
type='text'></cms:editable>


</cms:template>
<cms:if k_is_page >
<head>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title><cms:show k_page_title /> | Revlimit Magazine</title>

<link href="../css/all_pages.css" rel="stylesheet" type="text/css" />
<link href="../css/links.css" rel="stylesheet" type="text/css" />
<link href="../css/nav.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
a:link { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color:#4F4F4F; font-weight:bold; }
a:hover { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color: #999999; font-weight:bold; }
a:visted { { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color:#4F4F4F; font-weight:bold; }
-->
</style>
</head>

<body>

<?php include("../includes/banner-nav.html"); ?>

<div id="main">
<div class="main-area-new">
<div class="main-area-inside">
<div class="left-area">

<br /><br /><br />
<div class="text-title-pages"><cms:show k_page_title /></div>
<div class="text-area-pages1">
Date Posted | &nbsp;<strong>
<cms:date k_page_date format='%B %d, %Y' locale='English' /></strong>
</div>


<div class="text-area-pages1"> Posted by | &nbsp;<strong>
<cms:show written_by />
</strong> </div>

<div class="text-area-pages1"><br><br></div>

<div class="text-area-pages"><cms:show news_content />

</div>
<div class="text-area-pages1">
<div class="comments-area">
<strong>Comments</strong><br>
<br>

<div class="hr dotted clearfix">&nbsp;</div>

<cms:if k_comments_count >
<ol class="commentlist">
<cms:comments page_id=k_page_id order='asc' limit='20' paginate='1' >
<li class="comment">

<div class="comment_content">
<div class="clearfix">
<cite class="author_name"><strong><cms:show k_comment_author /></strong></cite>
<div class="comment-meta commentmetadata"><span class="comments-text-date"><cms:date k_comment_date format='F j, Y'/> at <cms:date k_comment_date format='h:ia'/></a></span></div>
</div>
<div class="comment_text">
<p><cms:show k_comment /></p>
</div>
</div>
</li>
<cms:paginator />
</cms:comments>
</ol>
<cms:else />
No comments.
</cms:if>

<div class="hr clearfix">&nbsp;</div>

<!-- Comment Form -->
<cms:embed 'comments_form.html' />

</div>
<br>
</div></div>

<!-- Right side bar -->
<div class="right-area">
<?php include("../includes/side.html"); ?>
</div>
<!-- End div -->
<div class="space"><br /><br /><br /><br /><br /></div>

</div>


</div>

</div></div>


<?php include("../includes/footer.html"); ?>


<!-- Main Div end -->
</div>
</body>
</html>

}
?>
<cms:else />
<cms:embed 'news_list.php' />
</cms:if>

<?php COUCH::invoke(); ?>

Sorry I should have been more explicit about the PHP syntax. The PHP curly braces need to be closed properly the following way -
Code: Select all
<cms:if k_is_page >
   <?php if( $_SERVER['HTTP_REFERER']=='http://revlimitmag.com/mobile/index.php' ){ ?>
      ---- output your simpler content here ----
   <?php } else{ ?>
      ---- output your original (normal) content here ----
   <?php } ?>
 
<cms:else />
   <cms:embed 'news_list.php' />
</cms:if>

or using the more legible syntax -
Code: Select all
<cms:if k_is_page >
   <?php if( $_SERVER['HTTP_REFERER']=='http://revlimitmag.com/mobile/index.php' ): ?>
      ---- output your simpler content here ----
   <?php else: ?>
      ---- output your original (normal) content here ----
   <?php endif; ?>
 
<cms:else />
   <cms:embed 'news_list.php' />
</cms:if>


Your code should now become -
<?php require_once( '../couch/cms.php' ); ?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<cms:template title='News' clonable='1' commentable='1' >
<cms:editable name='news_content' type='richtext' />

<cms:editable name='news_image'
crop='1'
width='118'
height='72'
type='image'
/>

<cms:editable
name='written_by'
label='written_by'
desc='You need to enter written by e.g (admin)'
type='text'></cms:editable>


</cms:template>
<cms:if k_is_page >

<?php if( $_SERVER['HTTP_REFERER']=='http://revlimitmag.com/mobile/index.php' ): ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title><cms:show k_page_title /> | Revlimit Magazine</title>

<link href="../css/all_pages.css" rel="stylesheet" type="text/css" />
<link href="../css/links.css" rel="stylesheet" type="text/css" />
<link href="../css/nav.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
a:link { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color:#4F4F4F; font-weight:bold; }
a:hover { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color: #999999; font-weight:bold; }
a:visted { { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color:#4F4F4F; font-weight:bold; }
-->
</style>
</head>
<body>
<div class="text-title-pages"><cms:show k_page_title /></div>
<div class="text-area-pages"><cms:show news_content /></div>
</body>
<html>


<?php else: ?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title><cms:show k_page_title /> | Revlimit Magazine</title>

<link href="../css/all_pages.css" rel="stylesheet" type="text/css" />
<link href="../css/links.css" rel="stylesheet" type="text/css" />
<link href="../css/nav.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
a:link { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color:#4F4F4F; font-weight:bold; }
a:hover { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color: #999999; font-weight:bold; }
a:visted { { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color:#4F4F4F; font-weight:bold; }
-->
</style>
</head>

<body>

<?php include("../includes/banner-nav.html"); ?>

<div id="main">
<div class="main-area-new">
<div class="main-area-inside">
<div class="left-area">

<br /><br /><br />
<div class="text-title-pages"><cms:show k_page_title /></div>
<div class="text-area-pages1">
Date Posted | &nbsp;<strong>
<cms:date k_page_date format='%B %d, %Y' locale='English' /></strong>
</div>


<div class="text-area-pages1"> Posted by | &nbsp;<strong>
<cms:show written_by />
</strong> </div>

<div class="text-area-pages1"><br><br></div>

<div class="text-area-pages"><cms:show news_content />

</div>
<div class="text-area-pages1">
<div class="comments-area">
<strong>Comments</strong><br>
<br>

<div class="hr dotted clearfix">&nbsp;</div>

<cms:if k_comments_count >
<ol class="commentlist">
<cms:comments page_id=k_page_id order='asc' limit='20' paginate='1' >
<li class="comment">

<div class="comment_content">
<div class="clearfix">
<cite class="author_name"><strong><cms:show k_comment_author /></strong></cite>
<div class="comment-meta commentmetadata"><span class="comments-text-date"><cms:date k_comment_date format='F j, Y'/> at <cms:date k_comment_date format='h:ia'/></a></span></div>
</div>
<div class="comment_text">
<p><cms:show k_comment /></p>
</div>
</div>
</li>
<cms:paginator />
</cms:comments>
</ol>
<cms:else />
No comments.
</cms:if>

<div class="hr clearfix">&nbsp;</div>

<!-- Comment Form -->
<cms:embed 'comments_form.html' />

</div>
<br>
</div></div>

<!-- Right side bar -->
<div class="right-area">
<?php include("../includes/side.html"); ?>
</div>
<!-- End div -->
<div class="space"><br /><br /><br /><br /><br /></div>

</div>


</div>

</div></div>


<?php include("../includes/footer.html"); ?>


<!-- Main Div end -->
</div>
</body>
</html>


<?php endif; ?>


<cms:else />
<cms:embed 'news_list.php' />
</cms:if>

<?php COUCH::invoke(); ?>
awesome stuff KK thats for your support and help :mrgreen:
9 posts Page 1 of 1