ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Recycling content & links for Mobile interface

July 27, 2011 6:39am

Subscribe [2]
  • #1 / Jul 27, 2011 6:39am

    Vivify

    10 posts

    Hi there,

    I’m currently in the midst of building a mobile version of a website. I’m using

    related_entries

    to re-use content on the site so the customer doesn’t have to maintain a separate set of content for their mobile website.

    This works really well except for one problem I’m hoping someone can help me with.

    The hypertext in the re-cycled content all point to pages on the main (non-mobile) version of the site. I’ve built the mobile site using the following URI convention: mysite.com/mobile/ (everything after mobile follows the same URI convention as the main site.)

    My question is this:

    How can I make any internal hypertext that appears in the content, link to the mobile version of the site?

    For example, I have a link in the ‘About’ page text that points to the contact page: mysite.com/contact/

    In the mobile version of the ‘About’ page I want it to point to: mysite.com/mobile/contact/

    Is there a tag or conditional statement I can add to my links that will achieve this?

    Thanks,

    Nick.

    [Mod Edit: Moved to the Community Help forum]

  • #2 / Jul 27, 2011 7:49am

    Dave @ Exp:resso

    465 posts

  • #3 / Jul 27, 2011 11:50am

    Vivify

    10 posts

    Thanks for that Dave, it worked a treat.

    Just for anyone else out there that’s trying to do a similar thing, this is what I did:

    I downloaded and added the MX Mobile Device Detect plugin and put the following code in my template:

    {exp:channel:entries channel="mobile" limit="1"} 
            {exp:mobile_detect}         
              {related_entries id="page_content"}
                 {page_copy}
              {/related_entries}
             {/exp:mobile_detect}            
            {/exp:channel:entries}


         
    The important thing here was to wrap the mobile_detect tags around my page content. I then added the following conditional to my link:

    <a href="http://{if">Get in touch</a>

    Now if a mobile goes to the mobile page this link will automatically take them to /mobile/contact/ and if a desktop browser views the same content the link will take them to /contact/.

    The only real downside is the clunky conditional that has to be added to each link. Fine for me, but a client might struggle. Still, helluva lot better than how I had it before.

    Nick.

  • #4 / Jul 27, 2011 8:38pm

    Dave @ Exp:resso

    465 posts

    Thanks for sharing the solution Nick! I bet theres a way to do this without the client having to do anything. For example you could have some php in the header that does the detection, then pre-pends /mobile on the uri string (assuming your url structure is the same otherwise). Or you could design the layout so it adapts perfectly to mobile devices using one of those new CSS frameworks - we’re definitely going to explore this for our next project

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases