how to make multi version in codeigniter for mobile and desktop |
We have a codeigniter website for desktop and we don’t want it to be responsive for desktop browsers. But we need mobile version of website in a way that be responsive for all kinds of mobiles and tablets. Also we know we need to use is_mobile function in user agent library but we don’t know where and how should we use them? And we want to use both of desktop version and mobile version in the same domain. Please kindly guide us about this problem and let us know how we can find good tutorial?
11-11-2017, 12:37 PM
(This post was last modified: 11-11-2017, 12:43 PM by PaulD. Edit Reason: Added link )
I think the docs are pretty clear on this.
https://www.codeigniter.com/user_guide/l...:is_mobile In essence, you test to see if it is a mobile device, and if it is, load a specific view, or if not, load a different view. If you just load views in your controller, you might do something like the example given in the docs and load different views. If you keep your different views in different sub folders, you could use the if statement to set the folder name and use that variable in your view call. You might need some checks to see if the view exists or not as well. Alternatively, if you have created a template library of some sort, you would only have to do the mobile check once in your template library, also very easy to modify rather than changing all your controllers. If you show a sample of how you load your views we might be able to offer a bit more specific advice. As with everything CI, how you actually use the tools provided varies on how you have decided to implement your website. Paul More info here: https://stackoverflow.com/questions/6209...odeigniter Or here: https://digitizor.com/codeigniter-mobile-browser/ And lots more on Bing (11-11-2017, 12:37 PM)PaulD Wrote: I think the docs are pretty clear on this. Thanks for the help in apps\third_party\MX\Loader We made these change : public function view($view, $vars = array(), $return = FALSE) { $this->load->library('user_agent'); if ($this->agent->is_mobile()) { list($path, $view) = Modules::find($view, $this->_module, 'mobile_views/'); } else { list($path, $view) = Modules::find($view, $this->_module, 'views/'); } function _ci_load($_ci_data) { foreach (array('_ci_view', '_ci_vars', '_ci_path', '_ci_return') as $_ci_val) { $$_ci_val = ( ! isset($_ci_data[$_ci_val])) ? FALSE : $_ci_data[$_ci_val]; } if ($_ci_path == '') { $_ci_file = strpos($_ci_view, '.') ? $_ci_view : $_ci_view.EXT; $_ci_path = $this->_ci_view_path.$_ci_file; } else { $_ci_file = end(explode('/', $_ci_path)); } if ( ! file_exists($_ci_path)) show_error('Unable to load the requested file: '.$_ci_file); if (is_array($_ci_vars)) $this->_ci_cached_vars = array_merge($this->_ci_cached_vars, $_ci_vars); extract($this->_ci_cached_vars); ob_start(); if ((bool) @ini_get('short_open_tag') === FALSE AND CI::$APP->config->item('rewrite_short_tags') == TRUE) { echo eval('?>'.preg_replace("/;*\s*\?>/", "; ?>", str_replace('<?=', '<?php echo ', file_get_contents($_ci_path)))); } else { include($_ci_path); } log_message('debug', 'File loaded: '.$_ci_path); if ($_ci_return == TRUE) return ob_get_clean(); if (ob_get_level() > $this->_ci_ob_level + 1) { ob_end_flush(); } else { CI::$APP->output->append_output(ob_get_clean()); } } And the following code has control functions : $data['include']='article/view_article'; $this->load->view('container',$data); But this message is displayed: Unable to load the requested file: container.php You can get more guidance Thank a lot edram (11-11-2017, 10:53 AM)edram Wrote: We have a codeigniter website for desktop and we don’t want it to be responsive for desktop browsers. But we need mobile version of website in a way that be responsive for all kinds of mobiles and tablets. Also we know we need to use is_mobile function in user agent library but we don’t know where and how should we use them? And we want to use both of desktop version and mobile version in the same domain. Please kindly guide us about this problem and let us know how we can find good tutorial? go download sprintphp from github by @kilishan I think it has feature u looking for, and based on CI3 https://github.com/ci-bonfire/Sprint |
Welcome Guest, Not a member yet? Register Sign In |