• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CodeIgniter Template Library on Mobile

#1
[eluser]demogar[/eluser]
Afternoon guys.

I'm using Phil Stugeons' Template library (which is great, btw) on a website at the moment. We needed two different layouts: one for the web/browser based website and another one for the mobile based website.

It was really easy to use different layouts, but the problem is with the different view files, since it wont autoload (depending on the user agent) the view file automatically, for example, if the user agent is a mobile wont analyze if the view is inside a /mobile/ folder (or something similar).

Reviewing the code, it seems the library doesn't try to do it. On line #759 we have this:
Quote:// Grab the content of the view (parsed or loaded)
$content = ($this->_parser_enabled === TRUE AND $parse_view === TRUE)

// Parse that bad boy
? $this->_ci->parser->parse($view, $data, TRUE)

// None of that fancy stuff for me!
: $this->_ci->load->view($view, $data, TRUE);

So it seems it will autoload the view directly. I could make a file_exists("mobile||web/" . $view) (etc..) and just load this, but I'm using Modular Extensions too in some cases, so it's not quite easy to do this dinamycally.

I think the only way to achieve this is by doing template, does anybody have a better idea?

Thanks in advance.

P.S.: Sorry my English, it's not my native language Smile

#2
[eluser]huy[/eluser]
[quote author="demogar" date="1318261543"]Anyways, just for the archive:

I extended the library, modified the _load_view method for adding /mobile/ in front of the $view file for mobile devices and added some minor enhancements/features (base title, simple SEO checking, etc).

For mobile feature, I just made something like this:

Code:
if ($this->_is_mobile)
{
$view = "mobile/" . $view;
}

So it will look for the view file in views/mobile/* folder, directly.

It works for me, any other idea is still appreciated.[/quote]

i Try.

How to check Mobile Version in Localhost??

(sr my bad EL)


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.