Forum for discussing general topics related to Couch.
12 posts Page 1 of 2
Hi

I have just completed a website for a client and made it editable using couch cms tags but now they want a mobile version of the website, is it possible to do so that cms is still integrated so if they make changes it amends on the desktop version as well as the mobile version?

I am stuck and ran out of ideas

Thank you in advance

Kind regards

Ian
Hi,

Perhaps you'll find the following post useful
viewtopic.php?p=10628#p10628
Hi KK

Thank you for the reply

I looked at the link you provided and see the following code on that post

Code: Select all
<?php require_once 'couch/cms.php'; ?>
<cms:template clonable='1'>
    .. define all editable regions ..
</cms:template>

<cms:php>
    include 'Mobile_Detect.php';
    $detect = new Mobile_Detect();
    if ($detect->isMobile()) {
        // Any mobile device.
        global $CTX;
        $CTX->set( 'is_mobile', '1' );
    }
</cms:php>

<cms:if is_mobile >
    <cms:embed 'm/news.php' />
<cms:else />
    <cms:embed 'news.php' />
</cms:if>

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


I have tried this but I just get a blank white page on the main index.php

I have got the Mobile_Detect.php file and put that in the main root where the main index.php is

Would it work if I create a m folder and put a index.php inside that and at the top of that file put the following code

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


so that should go up one level and find the couch folder and find the cms.php inside that couch folder, would that work?

If so I can then set the mobile detect php file to the following location

Code: Select all
/* Change path info depending on your file locations */
require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;

if($detect->isMobile()) {
    header('Location: http://yourdomain.com/sites/test/test');
    exit;
}


Kind regards

Ian
I got it working but the main index.php outside of the cms/snippets folder is not picking up the mobile css stylesheet, instead it is picking up the desktop css stylesheet

If I take out includes/header.php on the main index.php in the root, the css goes all together

Any ideas, sorry

Kind regards

Ian
Sorry got another update

I have been playing around with the main index.php in the root and below is the following coding

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

<cms:template title='Home'>
<cms:editable name='page_title' label='title' type='text' />
</cms:template>

<cms:php>
    include 'Mobile_Detect.php';
    $detect = new Mobile_Detect();
    if ($detect->isMobile()) {
        // Any mobile device.
        global $CTX;
        $CTX->set( 'is_mobile', '1' );
    }
</cms:php>

<title><cms:show page_title/></title>

<!--CONTENT-->

   <cms:if is_mobile >
    <cms:embed 'm/includes/header.php' />
    <cms:embed 'm/index.php' />
    <cms:embed 'm/includes/footer.php' />
<cms:else />
   <cms:embed 'desktop/includes/header.php' />
    <cms:embed 'desktop/index.php' />
    <cms:embed 'desktop/includes/footer.php' />
</cms:if>

<!--CONTENT-->

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


It works perfect on desktop view but when I access it on my mobile, it is displaying the mobile version but no css styling is attached with it

Can anyone point me in the right direction and where I am going wrong

Thank you in advance, sorry

Ian
Ian,

For debugging purpose, make the mobile version load on the desktop -
<cms:if "<cms:not is_mobile />" >
<cms:embed 'm/includes/header.php' />
<cms:embed 'm/index.php' />
<cms:embed 'm/includes/footer.php' />
...

Now do a view-source to see the generated HTML.
It'll give you a clue as to why the CSS is not taking effect.
Thank you so much KK, got it

I didn't realise the css styles had to be in the main css folder in the root, I was putting the css stylesheet file in the snippets folder in a folder called m/css

So in the snippets/m/folder, is it just the main files that go in there I take it such as the index.php, news.php and so on, so no css or js files, they go in the root of the site?

That correct?

Kind regards

Ian
Right. It is only the files that define the mobile specific HTML markup that go into that folder.
Thank you for confirming

Just one last question

Regarding the CMS, if they update the desktop index.php, does that automatically update the mobile/index.php or will the client need to update it twice

Kind regards

Ian
Hi,

If you mean update the data in editable regions - that is common to both version so will appear updated in both.
12 posts Page 1 of 2
cron