Forums / Addon Templates / Mobile template CSS

Mobile template CSS

Started by jeking on 12 Oct 2009, 6:01 PM · Views: 51,715

Results 21 to 40 of 51
25 Jan 2011, 9:45 PM
#21
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Mobile template CSS

Good philosophical (and technical) information on "responsive design" which is relevant to deciding how to address mobile devices:
http://www.alistapart.com/articles/responsive-web-design/
Also a recent Sitepoint article:
http://blogs.sitepoint.com/2011/01/11/responsive-web-design-with-html5-and-the-less-framework-3/

31 Jan 2011, 12:12 PM
#22
calljj avatar

calljj

Zen Follower

Join Date:
Mar 2007
Posts:
253
Plugin Contributions:
2

Re: Mobile template CSS

Quick question for Vittorio.

thanks for the mod, works perfectly for me.

If using the overides, can you provide a solution that allows the customer to view the "usual" version of the site if they choose too?

I was thinking about adding a link in the footer where the mobile user can click to view the full version of the site, thinking of using session variables in order to do this, but running out of skill level rapidly!

31 Jan 2011, 8:37 PM
#23
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,879
Plugin Contributions:
7

Re: Mobile template CSS

This is a useful tool to test functionality of the Opera Mobile browser on a pc/mac, to make code changes that display in real time using this emulator in conjunction with Opera Dragonfly:
http://www.opera.com/developer/tools/

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

4 Feb 2011, 2:14 PM
#24
calljj avatar

calljj

Zen Follower

Join Date:
Mar 2007
Posts:
253
Plugin Contributions:
2

Re: Mobile template CSS

To answer my own question, if using the browscap method as Vittorio posted and you want iphone customers to see the full site, then this is how i did it.

  1. Create a new file called redirect.php and place it in the public_html folder

  2. put the following code in it -changing the domain name to you own

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<?php
$value = 'full';
setcookie("TestCookie", $value);
setcookie("TestCookie", $value, time()+1800); /* expire in 1/2 hour */ 
?>
<head>
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yourdomain.com/">
</head>
</html>
  1. On your site, put a link to the redirect.php file for users to click on to see the full site

  2. Alter the code slightly that vittorio posted to look like this

* Determine if client is a mobile device or not ($mobile = 1 ==> it is | $mobile = 0 ==> it is not)
*/
$browser = get_browser($_SERVER['HTTP_USER_AGENT'], true);
$mobile = ($browser['ismobiledevice'] == null ? 0 : $browser['ismobiledevice']);
$platform = strtolower($browser['browser']);

/**
* Check if user wants full version or not use it
*/

 $is_mobile = "true";

if(isset($_COOKIE['TestCookie'])){
 $is_mobile = "false";
}


/**
* Check if there is a specific template for this mobile platform and use it
*/
if ($mobile == 1){
if ($is_mobile == "true"){
  $exists_mobile = file_exists(DIR_WS_TEMPLATES . $template_dir . '_mobile');
  $exists_platform = file_exists(DIR_WS_TEMPLATES . $template_dir . '_mobile_' . $platform);
  if ($exists_platform) {
    $template_dir .= '_mobile_' . $platform;
  } else {
    if ($exists_mobile) {
      $template_dir .= '_mobile';
    }
  }
}
}

/**
* EOF : SPECIFIC TEMPLATE FOR MOBILE CLIENT

Hope this helps someone out with creating mobile based zen cart templates for iphones etc

25 Feb 2011, 4:58 PM
#25
kburner avatar

kburner

Totally Zenned

Join Date:
Apr 2008
Location:
Flint, Michigan
Posts:
684
Plugin Contributions:
0

Re: Mobile template CSS

I noticed when looking through my site's awstats that there are blackberry and android users. My husband has an android and my site shows with just a little corner snippet. I am very interested in this process.

From the postings I am gathering that you...

1st. create a new stylesheet post #6
2nd override init_templates.php with coding given in post #19 from includes/init_includes/overrides, restart Apache, load browscap.ini, not sure what to do after that.....

This should allow customers with handheld internet devices to view my site and login and purchase.

Has anyone completed the steps with it working? and have orders come through?

Thanks, Kim

kburner
Burner Christian Bookstore
https://www.burnerbooks.com

17 Mar 2011, 12:44 PM
#26
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: Mobile template CSS

Good information, thanks everyone.

I'm presently in the planning stages for a default mobile template for Zen Cart and I see the checkout as a bottleneck. I tried Numinix's Ajax checkout but I couldn't even login to checkout on my iPhone.

I'm thinking a jQuery checkout would be better.

Any thoughts on this.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

23 Apr 2011, 7:30 AM
#27
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: Mobile template CSS

You can check the general look by viewing in Opera.
open the a site in the opera browser click view and then "small screen"
Latest Opera no longer has this option...instead use following method:-
Opera 11 for Windows: View -> Developer Tools -> Page Information -> View button -> Small Screen.
:smile:

Dezina ZenCart Templates
Please do not PM for support queries..Post in forums..help others

12 May 2011, 5:53 PM
#28
xcergy avatar

xcergy

Zen Follower

Join Date:
Feb 2009
Location:
Landrum SC
Posts:
141
Plugin Contributions:
0

Re: Mobile template CSS

clydejones:

first name the css file "handheld_stylesheet.css and upload it to:

includes/templates/YOUR_TEMPLATE/css

next

open includes/templates/YOUR_TEMPLATE/common/html_header.php

find the following section of code:

/**

  • load printer-friendly stylesheets -- named like "print*.css", alphabetically
    */
    $directory_array = $template->get_template_part($template->get_template_dir('.css',DIR_WS_TEMPLATE, $current_page_base,'css'), '/^print/', '.css');
    sort($directory_array);
    while(list ($key, $value) = each($directory_array)) {
    echo '<link rel="stylesheet" type="text/css" media="print" href="' . $template->get_template_dir('.css',DIR_WS_TEMPLATE, $current_page_base,'css') . '/' . $value . '" />'."\n";
    }

immediately after add the following:

/**

  • load handheld-friendly stylesheets -- named like "handheld*.css", alphabetically
    */
    $directory_array = $template->get_template_part($template->get_template_dir('.css',DIR_WS_TEMPLATE, $current_page_base,'css'), '/^handheld/', '.css');
    sort($directory_array);
    while(list ($key, $value) = each($directory_array)) {
    echo '<link rel="stylesheet" type="text/css" media="handheld" href="' . $template->get_template_dir('.css',DIR_WS_TEMPLATE, $current_page_base,'css') . '/' . $value . '" />'."\n";
    }

OK, so I took post #6 and named it handheld_mobile.css
THEN followed the directions in this post.

No change in the size or format on my Verizon Android Vortex smart phone.

I'm sure I missed something.... any clues?
http://www.thedumbdog.com (freeyellow.com is the host)
TIA
Keith

12 May 2011, 6:09 PM
#29
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: Mobile template CSS

View source shows

<link rel="stylesheet" type="text/css" media="handheld" href="includes/templates/dd/css/handheld_stylesheet.css" /> which indicates that there is a file named handheld_stylesheet.css. Does it exist? Does it have any content? Does handheld_mobile.css exist on your server?
12 May 2011, 6:29 PM
#30
xcergy avatar

xcergy

Zen Follower

Join Date:
Feb 2009
Location:
Landrum SC
Posts:
141
Plugin Contributions:
0

Re: Mobile template CSS

gjh42:

View source shows

<link rel="stylesheet" type="text/css" media="handheld" href="includes/templates/dd/css/handheld_stylesheet.css" /> which indicates that there is a file named handheld_stylesheet.css. Does it exist? Does it have any content? Does handheld_mobile.css exist on your server?

I have it in the dir includes/templates/CUSTOM_TEMPLATE/css

My bad. I do not have a handheld_mobile.css file I can find that where? Sorry, I'm not up to speed on css technology.

12 May 2011, 6:42 PM
#31
xcergy avatar

xcergy

Zen Follower

Join Date:
Feb 2009
Location:
Landrum SC
Posts:
141
Plugin Contributions:
0

Re: Mobile template CSS

xcergy:

I have it in the dir includes/templates/CUSTOM_TEMPLATE/css

My bad. I do not have a handheld_mobile.css file I can find that where? Sorry, I'm not up to speed on css technology.
Sorry ... bad post. The file I named from post number 6 is handheld_stylesheet.css , not handheld_mobile.css I hate it when the brain is not connected to typing fingers :censored:

12 May 2011, 7:13 PM
#32
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: Mobile template CSS

I see the handheld_stylesheet.css on your server, and there doesn't seem to be anything wrong with it.

Check post 16 for a suggestion that may be relevant to you.

12 May 2011, 7:58 PM
#33
xcergy avatar

xcergy

Zen Follower

Join Date:
Feb 2009
Location:
Landrum SC
Posts:
141
Plugin Contributions:
0

Re: Mobile template CSS

gjh42:

I see the handheld_stylesheet.css on your server, and there doesn't seem to be anything wrong with it.

Check post 16 for a suggestion that may be relevant to you.

Hmmm... revisions made. It did nothing.

The good news is it didn't crash the site! LOL
That is my greatest fear.

24 May 2011, 2:32 PM
#34
pb4 avatar

pb4

Totally Zenned

Join Date:
Nov 2007
Posts:
555
Plugin Contributions:
0

Re: Mobile template CSS

I'm trying to set up my site to work on a mobile and I can't get the top bit of my site to show correctly...

LINK TO SITE

I presume I need to add in a link to point to the stylesheet within another file or two??
(other than in the html header file)

Can anyone help?

Thank you!

24 May 2011, 3:54 PM
#36
pb4 avatar

pb4

Totally Zenned

Join Date:
Nov 2007
Posts:
555
Plugin Contributions:
0

Re: Mobile template CSS

Thanks...how come it doesn't show very well??

24 May 2011, 4:00 PM
#38
pb4 avatar

pb4

Totally Zenned

Join Date:
Nov 2007
Posts:
555
Plugin Contributions:
0

Re: Mobile template CSS

I am viewing it in Opera (mini screen) and it isn't showing right...I presume this is an accurate test?

24 May 2011, 4:12 PM
#39
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: Mobile template CSS

You have in your handheld_stylesheet.css

@media handheld {

which should only apply to media that recognize that @rule. Maybe it would help if you used the alternate rule in post 16.

24 May 2011, 4:35 PM
#40
pb4 avatar

pb4

Totally Zenned

Join Date:
Nov 2007
Posts:
555
Plugin Contributions:
0

Re: Mobile template CSS

Thanks again but this didn't work, just made it narrower. Its the top jquery slider thats not working as well as the header login strip...both are not scaling down (in width)?

Any more ideas?

Thanks