Home > Backend Development > PHP Tutorial > wap web page - thinkphp3.0 project already has a PC version. How to add a mobile version of the website?

wap web page - thinkphp3.0 project already has a PC version. How to add a mobile version of the website?

WBOY
Release: 2016-08-20 09:04:09
Original
1529 people have browsed it

Just like the title

The following project directory structure. How to configure the mobile website. I found the is_mobeli() function on the Internet to make a judgment. How to configure it specifically? Please give me some advice
wap web page - thinkphp3.0 project already has a PC version. How to add a mobile version of the website?

Reply content:

Just like the title

The following project directory structure. How to configure the mobile website. I found the is_mobeli() function on the Internet to make a judgment. How to configure it specifically? Please give me some advice
wap web page - thinkphp3.0 project already has a PC version. How to add a mobile version of the website?

You mean to start a new module, and then that module displays the wap page. The page entry should be judged based on is_mobile. Now you have BIND_MOUDLE an App

Judged in the entry file. It is best to rewrite the controller of the mobile phone separately. Of course, if the gap between the mobile phone and PC is not too big, you can use the same set.

This is what we do when we do it. PC-side pages are inherited from Base/PcBase.html, and PcBase.html contains content such as header footer. Then put a js script in PcBase.html to detect whether it is a mobile device. If it is a mobile device, it will automatically jump to the mobile terminal.
It depends on the size of your project. If the project is not large, you can directly create a MobileContoller under Home. If it is large, pull a MobileMoudle to do it.
We did not use is_mobile, but used js script to judge. Use the one you like.

Is it an old thinkphp3.0 project?

Then first update config.php, add a Mobile group, and set the command yourself, as follows

<code>'APP_GROUP_LIST' => 'Admin,Home,Member,Mobile'
</code>
Copy after login

Then add the Mobile directory to Action, add the Mobile directory to Tpl, and continue developing various controllers, models, and views

Finally, if your Home group all inherits a base class such as

<code>class IndexAction extends BaseAction {</code>
Copy after login

Then you add the is_mobile function judgment to the _initialize function in BaseAction, so that all controller requests will trigger the judgment

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template