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, my English version of the homepage name is index1include 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

<?phpsession_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 modified part

1. The default template does not have to be modified, you need to modify the template in the English state, here you will need to add a level column

(1) Select the "Content" tab and click "Add Column" to add the information.

(2) When you go to the "Template Settings" section, select "Available Style"---"is the style name of the site management" This is not to become; "Column homepage template"---"Is your English homepage template"; "list page, content page"----"is the corresponding English template file"

(3) The "submit" will be done.

2. To add the menu column under the English column, the normal menu column can be added.

3. Other content pages, list pages are normal to add content on it.

Here, the backstage changes are over.

Third, the overall look at the effect can be

The above is to carry out a bilingual switching step, only to modify the header file and the value of the processing page in English, you need to add 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 all the files of the default template can be.

Yue Yue Blog Address: http://www.cnblogs.com/nuanai/

Bb. Phpcms Complete PC and mobile switch (same domain) Yue Yue Blog address: http://www.cnblogs.com/nuanai/

I. Creation and modification of mobile-phone files

1. Create a new phone-side 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 this template style file to create a folder, I here called Content_m, This folder is used to make mobile websites.

2. Copy the file of your mobile Web page to this Content_m folder, and split into Phpcms used classification file (normal Web file split: Head, tail, center, etc.), and then modify the file path of each file can be, here do not say much, 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 judging 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 a http_x_wap_profile must be a mobile device if (Isset ($_server[' http_x_wap_profile ')) {return true;} If 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 Truereturn stristr ($_server[' Http_via '], "WAP")? True:false;} Brain residue method, determine the mobile phone sent by the client flag, compatibility to be improved if (Isset ($_server[' http_user_agent ')) {$clientkeywords = array (' Nokia ', ' Sony ', ' Ericsson ', ' mot ', ' Samsung ', ' HTC ', ' SGH ', ' lg ', ' sharp ', ' sie-', ' Philips ', ' Panasonic ', ' Alcatel ', ' Lenovo ', ' iphone ', ' ipod ', ' blackberry ', ' Meizu ', ' Android ', ' NetFront ', ' Symbian ', ' UCWeb ', ' windowsce ', ' palm ', ' operamini ', ' Operamobi ', ' Openwave ', ' nexusone ', ' cldc ', ' MIDP ', ' wap ', ' mobile ');//Find the keyword if (Preg_match ("/(") in the phone browser from Http_user_agent. Implode (' | ', $clientkeywords). ")/I", Strtolower ($_server[' http_user_agent '))) {return true;}} Protocol law, because there may be inaccuracies, put to the Last Judgment if (Isset ($_server[' http_accept ')) {//If only WML is supported and HTML is not supported that must be a mobile device// If WML and HTML are supported but WML is before HTML 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.

Yue Yue Blog Address: http://www.cnblogs.com/nuanai/

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)

Related Article

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.