Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 12-27-2010 07:16:50

Design_Wholesale
Member
From: England!
Registered: 11-21-2008
Posts: 1104
Website

Default Skin For Mobile Browsing - How Do I Do This?

I am trying to change the skins in my webstore to accomodate mobile browsing, - I have configured Tera-WURFL for use with the site (although it does not appear to be working quite as it should at the moment) and need to make it so I can use a different skin whenever a mobile browser is detected.

This is the all important code (modified slightly) that detects whether or not the site is dealing with a mobile browser:

Code:

<?php
// Include the Tera-WURFL file
require_once('./TeraWurfl.php');
 
// instantiate the Tera-WURFL object
$wurflObj = new TeraWurfl();
 
// see if this client is on a wireless device (or if they can't be identified)
if($wurflObj->getDeviceCapability("is_wireless_device")){
     echo "<h2>Welcome To Our Mobile Site!</h2>";
}
 
?>

...and I need to make it so that when the above happens it also changes the skin.

I've already located the section in  that deals with setting the default skin...

Code:

// +--
// | Set our display skin to the default.  Hopefully this will be
// | overridden somewhere along the line.
// +--

$this->globals('khxc_display.skin','skin.Default');

...but how do I bring the two together to make the display always use skin  if a mobile user is detected, or to otherwise use whatever skin I have selected to use in the backend settings?


I have tried the following, but either WURFL does not work as it should (which is what I am beginning to suspect having tried it with several online simulators) or the code is wrong somewhere:

Code:

// +--
// | Set our display skin to the default.  Hopefully this will be
// | overridden somewhere along the line.
// +--

// Include the Tera-WURFL file
require_once('wurfl/TeraWurfl.php');
 
// instantiate the Tera-WURFL object
$wurflObj = new TeraWurfl();
 
// see if this client is on a wireless device (or if they can't be identified)
if($wurflObj->getDeviceCapability("is_wireless_device")){

$this->globals('khxc_display.skin','skin.Ecom');

} else {

$this->globals('khxc_display.skin','skin.Default');

} // End of if statement.

Last edited by Design_Wholesale (12-27-2010 08:17:33)

Offline

 

#2 12-27-2010 10:42:22

Design_Wholesale
Member
From: England!
Registered: 11-21-2008
Posts: 1104
Website

Re: Default Skin For Mobile Browsing - How Do I Do This?

Tera-WURFL would appear to be working okay on our setup after some further testing, but there is something wrong with the code.

works for re-directing mobile browsers to a different site (not what I want):

Code:

// +--
// | Set our display skin to the default.  Hopefully this will be
// | overridden somewhere along the line.
// +--

require_once 'wurfl/TeraWurfl.php';
$wurflObj = new TeraWurfl();
$wurflObj->getDeviceCapabilitiesFromAgent();
 
// see if this client is on a wireless device (or if they can't be identified)
if($wurflObj->getDeviceCapability("is_wireless_device")){

header("Location: http://litez.mobi/");

} else {

$this->globals('khxc_display.skin','skin.Default');

} // End of if statement.

...however,  does not work for forcing a different skin for mobile browsers (and this is what I  wanting to do):

Code:

// +--
// | Set our display skin to the default.  Hopefully this will be
// | overridden somewhere along the line.
// +--

require_once 'wurfl/TeraWurfl.php';
$wurflObj = new TeraWurfl();
$wurflObj->getDeviceCapabilitiesFromAgent();
 
// see if this client is on a wireless device (or if they can't be identified)
if($wurflObj->getDeviceCapability("is_wireless_device")){

$this->globals('khxc_display.skin','skin.Ecom');

} else {

$this->globals('khxc_display.skin','skin.Default');

} // End of if statement.

Could someone please tell me if I am wasting my time with this, or point me in the right direction with the code?

Last edited by Design_Wholesale (12-27-2010 10:44:46)

Offline

 

#3 12-27-2010 10:56:32

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: Default Skin For Mobile Browsing - How Do I Do This?

Don't you really want to simply use a different style file? There really should be no reason to use an entirely different skin.

Offline

 

#4 12-27-2010 12:19:34

Design_Wholesale
Member
From: England!
Registered: 11-21-2008
Posts: 1104
Website

Re: Default Skin For Mobile Browsing - How Do I Do This?

No, I don't. - To make various parts of the site available for mobile content I am going to need to change most of the major page elements and drastically streamline the display throughout the store.  To even consider trying to do that using stylesheets (bearing in mind that I would have to also generate trigger events for when and when not to use the amended style coding) is crazy when all that is required is to do what I have been trying to do.

...so what's the problem? - It cannot be that difficult (I would have thought that my code would have worked until I tested it and found that it won't), or does this touch on something already in progress or already implemented in CCP 7.0, I wonder?

Last edited by Design_Wholesale (12-27-2010 12:19:45)

Offline

 

#5 12-27-2010 12:28:49

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: Default Skin For Mobile Browsing - How Do I Do This?

The actual including of the skin is done in KHXC_Display in the function named include_skin ... that is likely where you'll need to do your test and changing of the skin.

Offline

 

#6 12-27-2010 12:42:02

Design_Wholesale
Member
From: England!
Registered: 11-21-2008
Posts: 1104
Website

Re: Default Skin For Mobile Browsing - How Do I Do This?

Yes, I know now, - I managed to find and identify where I needed to make the changes. - Thank-you for confirming where the changes needed to made, though, - it is appreciated.

...and for anyone else trying to implement Tera-WURFL into their store (should work for CCP 7.0, too, if you can work out which file(s) to modify)...

{private}

Code:

// +--
// | If our interface is BackEnd we set our skin to the default management
// | interface skin and do not allow overrides.
// +--

require_once 'wurfl/TeraWurfl.php';
$wurflObj = new TeraWurfl();
$wurflObj -> getDeviceCapabilitiesFromAgent();
 
// see if this client is on a wireless device (or if they can't be identified)
if($wurflObj->getDeviceCapability("is_wireless_device")){

$skin = 'skin.Ecom';

} elseif (($this->globals('khxc.interface') == 'BackEnd') && ($skin != $backendskin) && ($skin != 'skin.Error') && (!($this->globals('khxc_mail.active')))) {

     if ($this->debug) {$this->debugger("include_skin: BackEnd interface detected.  Skin '{$skin}' replaced with '{$backendskin}'.");}

     $skin = $backendskin;

} elseif (($this->globals('khxc.interface') == 'FrontEnd') && ($skin == $backendskin)) {

     if ($this->debug) {$this->debugger("include_skin: FrontEnd interface detected and '{$backendskin}' requested.  Set skin to 'skin.Default'.");}

     $skin = 'skin.Default';

} elseif (empty($skin)) {

     if ($this->debug) {$this->debugger("include_skin: No skin was present. Set skin to 'skin.Default'.");}

     $skin = 'skin.Default';

} // End of if statement.

The Ecom skin is just for testing, and the code is purely to show how to implement WURFL (which, in my case, is installed in a directory called WURFL in my main webstore directory).  .

Last edited by Design_Wholesale (12-27-2010 12:46:01)

Offline

 

#7 12-28-2010 14:57:39

Design_Wholesale
Member
From: England!
Registered: 11-21-2008
Posts: 1104
Website

Re: Default Skin For Mobile Browsing - How Do I Do This?

I am not entirely sure how the skin process works but, after further testing, I think that the following,  that shown above, should be used:

Code:

// +--
// | Determine the skin file filename.
// +--

require_once 'wurfl/TeraWurfl.php';
$wurflObj = new TeraWurfl();
$wurflObj -> getDeviceCapabilitiesFromAgent();
 
// see if this client is on a wireless device (or if they can't be identified)
if($wurflObj->getDeviceCapability("is_wireless_device")){

$xskin = 'Mobile';

} else {

$xskin = preg_replace('/skin\./','',$skin);

}

$file        = $this->globals('khxc.path_public');
$file       .= '/skins/' . $xskin . '/';
$filename    = 'skin.php';

Also, ensure that there are no skin overrides in place for entries in the  /  and  tables otherwise, obviously, these will prevent the any mobile browser skin from displaying for those pages or in those namespaces.

Last edited by Design_Wholesale (12-29-2010 11:59:39)

Offline

 

#8 01-05-2011 20:16:27

Design_Wholesale
Member
From: England!
Registered: 11-21-2008
Posts: 1104
Website

Re: Default Skin For Mobile Browsing - How Do I Do This?

To use Tera-Wurfl in an  statement you would use something like the following to include the WURFL side of things:

Code:

require_once realpath(dirname(__FILE__) . '/../../wurfl/TeraWurfl.php');
$wurflObj = new TeraWurfl();
$wurflObj -> getDeviceCapabilitiesFromAgent();

// see if this client is on a wireless device (or if they can't be identified)
if($wurflObj->getDeviceCapability("is_wireless_device")){

Take care with the

Code:

require_once realpath(dirname(__FILE__) . '/../../wurfl/TeraWurfl.php');

part. - It does vary from that given on the installation pages for WURFL, but the more basic code shown in those examples will cause payment gateway relays in your webstore to fail, as will failing to set the path and directory depth right depending on where in your store you are using the code (: which pages and scripts you are adding it to and whether they are located in the main web directory (the skin file, for example), or in the {private} install directory.

Last edited by Design_Wholesale (01-05-2011 20:17:21)

Offline

 

Board footer