Using PHPCMS to switch between Chinese and English Web pages (no need to resolve the two-level domain name), phpcms to complete the PC and mobile phone-side switching (the same domain)

Source: Internet
Author: User

Aa. Phpcms for bilingual switching (no resolution of level two domains)

Phpcms two languages to switch, there is a part of the people are the two-level domain name of the resolution, so that there may be a part of the trouble, I have a method here can not resolve the two-level domain name can be, but because it is a template so it may be troublesome, but really do not contact do not know, You can learn further by touching something that is not in use. Yue Yue Blog Address: http://www.cnblogs.com/nuanai/

Here I use the method is to carry out the first level of column reading, through the different level of the different content of the column to be transferred. As long as you modify the ID of the first level of the column, which requires a different ID, so the header file modification, the other list page or content page of things do not have to be modified. But how to judge the current page I should be the language of the first level column ID? This is the question I need to consider, but this problem has been solved, see how I solve it. Here is the steps to Phpcms, because PHPCMS installation steps to add content, change template style and so on in the previous blog has written, here is not much to say, directly from how to replace the language. Yue Yue Blog Address: http://www.cnblogs.com/nuanai/

Replacement of two language templates (Chinese---English) default homepage if it is Chinese

1. Template structure function if same, copy the exact default file (including all files) directly in your content folder.

2. Change the name of the file, and the default Chinese file name area to separate, so that the template switch in English

3. Find your Chinese template header file, I here is the header.html file, open the header file, make the following changes

(1) Find the location where you want to switch the language, change the point of your language to the path is a PHP processing file

<!--find the place you want to switch between bilingual, here is the English version of the switch--><a href= "qhe.php" >English</a>

  

Note: The PHP file pointed to here is to be placed under the "Phpcmswm\install_package" folder, or the PHP file will go wrong

(2) to write this PHP processing file

<?php    //Open Cache    session_start ();          Give a default value, here is the default value of the English language, the default value you can define yourself    $_session[' qhz '] = 1;          Jump to your PHPCMS home page, using window.location.href = ' own phpcms home path '    echo ' <script type= ' text/javascript ' > window.location.href = '/phpcmswm/install_package/' </script> '?>

 

(3) After writing the end of the PHP processing files, the default home page jump processing files to modify

First, locate the index.php file under this path and open it, the path to the file is: phpcmswm\install_package\phpcms\modules\content\index.php

Second, a. Turn on caching in the index.php file

Turn on cache session_start ();

B. Find this sentence in the file, about 31 lines

Include template (' content ', ' index ', $default _style);

Replace it with the following, which is the interpretation

Determine whether the value of the session passed is empty, yes, jump to the default Chinese homepage, not the English homepage if (Empty ($_session["qhz")) {    include template (' content ', ' index ', $default _style);} else{    //This is the English version of the homepage, the name of my English page is index1    include template (' content ', ' index1 ', $default _style);      }

 

To here about the Chinese version of the header file modification is over.

4. The Chinese header file is finished, then the English header file (same as the 3rd step above)

Note: The different place is your English PHP processing file, do not point to the same processing file, so for the new processing of the file, in addition to the file name and the value is not the same, the others are actually the same.

(1) Chinese header file

<!--to toggle Chinese pointing file--><a href= "qhz.php" > Chinese </a>

(2) PHP-processed pages

<?php    session_start ();    $_session[' qhz '] = 0;   The value of the transmitted Chinese state    echo "<script type= ' text/javascript ' >window.location.href = '/phpcmswm/install_package/' < /script> "?>

 

(3) phpcmswm\install_package\phpcms\modules\content\  index.php This index.php file is not necessary to modify, because the inside of the judgment has been written empty is the default Chinese interface, the value is empty actually and 0 is the same, so no other changes. This is where the Chinese and English templates need to be modified. Second, phpcms the background of the Modification Section 1. The default template does not have to be modified, you need to modify the template in the English state, here you need to add a level column (1) Select the "Content" tab, click "Add Column" to add information (2) to the "Template Settings" column, select " Available Style "---" is the style name of the site management "This is not to become;" The column homepage template "---" Is your English homepage template ";" The list page, the content page "----" are the corresponding English template Files "(3)" Submit "can be 2. To add the menu column under the English section , the normal Add menu column can be 3. Other content pages, list pages are normal to add content can be here, the background of the changes to the end of the third, the overall effect can be the above is to carry out the bilingual switching steps, modified only in English and Chinese header file and Value processing page, Need to add in the background is your English column, the other thing is to pass the ID value of the content switch can be, because the function is kind, so directly copied the default template of all files on it. Yue Yue Blog Address: Http://www.cnblogs.com/nuanai/BB. Phpcms Complete PC and phone-side switching (same domain) Yue Yue Blog address: http://www.cnblogs.com/nuanai/. Create and modify mobile-phone files 1. Build a new mobile-phone web file under this file path Phpcmswm\install_ PACKAGE\PHPCMS\TEMPLATES\WM This path is the background of the "site management" in the template style file, under the template style file to create a folder, I am called Content_m, this folder is used to do mobile site 2. Copy the file of your mobile Web page to this Content_m folder, split into the phpcms used by the classification file (normal Web file splitting: Head, tail, center, etc.), and then modify the file path of each file can be, here not many say, The path changes have been explained in detail in the previous blog. Second, modify the first page to jump processing files 1. Find this index.php file, that is, the processing file path of the homepage jump: PHPCMSWm\install_package\phpcms\modules\content\index.php 2. Copy the Code of the judgment device into the class method of index (the class name is about line 8th), and the code of the device is as follows: 

Determine if the phone-side function IsMobile () {//If there is http_x_wap_profile, it must be a mobile device if (Isset ($_server[' http_x_wap_prof        ILE ']) {return true; }//If the VIA information contains WAP, it must be a mobile device, some service associations block the information if (Isset ($_server[' Http_via ')) {//cannot be found for flase, otherwise True return Stristr ($_server[' Http_via '), "WAP")?        True:false;  }//Brain residue method, determine the mobile phone sent by the client flag, compatibility needs to be improved if (Isset ($_server[' http_user_agent ')) {$clientkeywords =                Array (' Nokia ', ' Sony ', ' Ericsson ', ' mot ', ' Samsung ', ' HTC ', ' SGH ', ' lg ', ' sharp ', ' sie-', ' p                Hilips ', ' Panasonic ', ' Alcatel ', ' Lenovo ', ' iphone ',                ' ipod ', ' blackberry ', ' Meizu ', ' Android ', ' NetFront ', ' sYmbian ', ' ucweb ', ' windowsce ', ' palm ', ' Operamini ',                ' Operamobi ', ' Openwave ', ' nexusone ', ' cldc ', ' MIDP ',            ' WAP ', ' mobile '); Look for the keyword if (Preg_match ("/(") of the phone's browser from Http_user_agent. Implode (' | ', $clientkeywords).            ")/I", Strtolower ($_server[' http_user_agent '))) {return true; }}//protocol method, because it may not be accurate, put to the Last Judgment if (Isset ($_server[' http_accept '))) {//If only WML is supported and H is not supported Tml that must be mobile devices//If WML and HTML are supported but WML before HTML is the mobile device if ((Strpos ($_server[' http_accept '), ' vnd.wap.wml ')! = = False) && (Strpos ($_server[' http_accept '), ' text/html ') = = = = False | |            (Strpos ($_server[' http_accept '), ' vnd.wap.wml ') < Strpos ($_server[' http_accept '], ' text/html '))))            {return true; }        }       return false; 

3. Locate this code in the processing file (all of the code that handles the file is replaced)

Include template (' content ', $template);

Replace with the following code:

if ($this->ismobile ()) {    ///The first parameter is the mobile page folder name you want to jump to    include template (' Content_m ', $template);} else{    include template (' content ', $template);}

4. Locate the code in the processing file

Include template (' content ', ' index ', $default _style);

Replace with the following code:

if ($this->ismobile ()) {    //This is the mobile-side web page include template (' Content_m ', ' index ', $default _style);} else{     include template (' content ', ' index ', $default _style);         }

  

Here is the PC and mobile phone switching process is basically over, you can use the Firefox phone simulator to see if it can be modified. Yue Yue Blog Address: http://www.cnblogs.com/nuanai/

 

Two of the above is the project I encountered in the time of the new problems, has now been resolved, so share the process, the need for comrades can check

Using PHPCMS to switch between Chinese and English Web pages (no need to resolve the two-level domain name), phpcms to complete the PC and mobile phone-side switching (the same domain)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.