mobile / Ipad Redirect

Developer Networks
Developer Networks
@developer-networks
11 years ago
566 posts
I am using some flash in the design for desktop users and I am also creating a stripped version for mobile and ipad users.

When i attempted to do a redirect it says forbidden.

You dont have permission to access /skins/myskin/mobile/ on this server

How do i tell the Jamroom routing system i need use of another directory in my skin?
updated by @developer-networks: 12/10/13 01:02:35PM
Developer Networks
Developer Networks
@developer-networks
11 years ago
566 posts
Also as a work around i tried a redirect sending any mobile or ipad user trying to access index.tpl to mobileindex.tpl inside the skin directory it shows up on my ipad as the source code not as a viewable page.

I have also copied a htaccess file to the directory /skins/myskin/mobile/
and re-routed all mobile and ipad devices trying to access index.tpl inside my skin directory but no avail.

Im not quite understanding this routing system.

Thanks.
updated by @developer-networks: 11/08/13 06:28:31PM
michael
@michael
11 years ago
7,718 posts
use the template functions
{if jrCore_is_mobile_device()}
    // do something for a mobile
{elseif jrCore_is_tablet_device()}
    // do something for a tablet
{/if}

will that work?

A diagram of the routing system is here:
https://en.wikipedia.org/wiki/File:A_diagram_of_the_routing_system_used_in_Jamroom_5.png

you don't need to copy the .htaccess to your module.
updated by @michael: 11/08/13 09:50:07PM
michael
@michael
11 years ago
7,718 posts
oops, missed a question:
Q:"How do i tell the Jamroom I need use of another directory in my skin? "

{jrCore_list module="jrPage" order_by="_created desc" tpl_dir="jrFlashback" template="articles_row.tpl" ......

The above is a jrCore_list function for gettting a list of something. using the tpl_dir="jrFlashback" will go looking for that articles_row.tpl file in the jrFlashback skin.

If your using a template {jrCore_include template="header.tpl"} try adding that tpl_dir="xxYourModule" to get the function to look in your modules /template/ folder for the template your trying to include.
Developer Networks
Developer Networks
@developer-networks
11 years ago
566 posts
I understand what your saying in your responce.

Let me explain in more detail whats going on.



I put this in the site myskin main index.tpl

<script type="text/javascript"> // <![CDATA[
	if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) {
		document.location = "http://www.yoursite.com/skins/myskin/mobile/";
	} // ]]>
</script>

So when an Ipad hits my site it automatically redirects to /skins/myskin/mobile/index.tpl

Which is a copy of the entire /myskin/index.tpl with out the flash


* However... I have recieved this error.

Quote: You don't have permission to access /skins/myskin/mobile on this server

The files all have correct server permissions and so does the folder /mobile.

(1 - I assume this is somehow controlled by eather a htaccess

(2 - or somehow i have not asked for /mobile/ to be called by the Jamroom routing for that skin?


Im getting blocked from the page when i view it with the Ipad.

Ive got it to also open up that directory and use the skins/myskin/mobile/index.tpl if the device is Ipad but the screen only loads the script context not the actual "view" of the entire index.tpl


Feels like im just missing a simple concept to how this system works..

Thanks


updated by @developer-networks: 11/09/13 12:54:46AM
michael
@michael
11 years ago
7,718 posts
Right, your trying to by-pass the routing system. don't.

Use the routing system to get what you want.

The routing system is really powerful if you use it.

did you look at the routing diagram? routing diagram

The first way that comes to mind to me is to just make one skin and use different sections, but that doesn't seam to be what you want to do, so the second thing I would think of would be:

using an include in the main section of the index template..... (hold on)

Why your redirect is not working is because that is not a location. When you want to access index.tpl, you dont go to:
yoursite.com/skins/myskin/

you go to
yoursite.com/

so do the same for your mobile.

make a template at:
/skins/myskin/m_index.tpl

Then with your javascript redirect point it to:
http://www.yoursite.com/m_index

That will get m_index displaying.

would that work for you?
updated by @michael: 11/09/13 01:26:48AM
brian
@brian
11 years ago
10,148 posts
This is not going to work like this - you can't have 2 skins active at the same time in Jamroom (at least not without doing something custom). Instead, simply place all the mobile site templates in your active skin directory, but start them all with "mobile" - i.e. mobile_index.tpl.

Then you can do:

<script type="text/javascript"> // <![CDATA[
 	if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) {
 	 	document.location = "http://www.yoursite.com/mobile_index";
 	} // ]]>
</script>

Let me know if that helps.

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
Developer Networks
Developer Networks
@developer-networks
11 years ago
566 posts
Thanks guys. I was able to easily get it up and working today.

Ill post what i did and your responces were right. But to help anyone else trying this, heres what i did.

<script type="text/javascript"> // <![CDATA[
 	if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) {
 	 	document.location = "http://www.yoursite.com/mobile_index";
 	} // ]]>
</script>

I posted this at the top of my index.tpl of my skin

and created a file "mobile_index" saving it to myskin directory.

and it works.

when i view the site with an ipad it automatically redirects to the mobile_index.tpl file.


Thanks everyone for the help!

Hope this helps anyone else trying to do this.


* One thing i notice however is the ipad user after logging in is not passed. Every time it redirects to the mobile_index page its credentials are lost and not being passed.

updated by @developer-networks: 11/09/13 02:14:22PM
brian
@brian
11 years ago
10,148 posts
The logged in/out status of a user is not dependent on the template or site location - I would double check to make sure you are redirecting to the proper www/non-www version of your domain, and make sure they are the same.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
Developer Networks
Developer Networks
@developer-networks
11 years ago
566 posts
Thanks Brian.

Ok so what i was doing wrong here was the redirect i had a www. as you can see in the above code.

the right code is this:

<script type="text/javascript"> // <![CDATA[
 	if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) {
 	 	document.location = "http://yoursite.com/mobile_index";
 	} // ]]>
</script>

Thank you so much for clarifying all of this with me and showing me how this works.


updated by @developer-networks: 11/09/13 04:53:26PM

Tags