Problem: redirect on mobile version of detail multi-listing page

3 posts by 2 authors in: Forums > CMS Builder
Last Post: May 27, 2014   (RSS)

By meg - May 27, 2014

I have a multi-listing section (blog) that I have set up for a client. I'm developing a mobile version of the website, but I'm having trouble connecting the links on the mobile pages to the mobile detail pages of the multi-listing. 

In the view URL section of the section editor, I have the list pages as index.php and the detail pages as article.php.

The mobile version has the same naming scheme to the list and detail pages. 

I'm using a redirect on the index.php and article.php pages:

On the index: 

<script language=javascript>if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
location.replace("http://name.com/mobile/index.php");}</script>

On the article, I tried both of these scenarios without success:

<script language=javascript>if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
location.replace("http://name.com/mobile/article.php");}</script>

It takes me to the correct page initially, then redirects to the first article.

<script language=javascript>if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
location.replace("http://name.com/mobile/article.php?<?php echo htmlencode($detailRecord['title']) ?>");}</script>

It takes me to the "named page" but none of the content appears. 

I'm using this to link the mobile pages to the articles.

<?php foreach ($articlesRecords as $listRecord): ?>
<?php $isSelected = ($listRecord['num'] == $detailRecord['num']); ?>
<?php if ($isSelected) { print "<b>"; } ?>

<?php echo htmlencode($listRecord['_link']) ?>

<?php if ($isSelected) { print "</b>"; } ?>
<?php endforeach ?>

How do I properly handle this mobile redirect?

Thank you!

By Damon - May 27, 2014

Hi Meg,

The _link variable is already set and used on the main part of the site so you need to recreate the detail page link for the mobile version.

So if a URL like this works for the mobile version, the title with the record number on the end:
http://name.com/mobile/article.php?Example-Article-18

this can be recreated with this code:

<?php echo $record['_filename'] ?>-<?php echo $record['num'] ?>

And to add this into a link:

<a href="/mobile/article.php?<?php echo $record['_filename'] ?>-<?php echo $record['num'] ?>"><?php echo $record['title'] ?></a>

Give this a try and let me know if this works for you.

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/