Ecshop Network Program Optimization-Automatically generate category page keywords, desciption Meta

Source: Internet
Author: User

Ecshop supports customizing keywords, Description meta information for each new class, so it doesn't have to help SEO or let the browser know what the page is, but if there are hundreds of classes, it's a bit tiring to write these classes manually (we don't do manual labor. Live), took a bit of time, wrote a PHP script to automatically generate keywords, description, support four-level classification, the principle is that the sub-category contains the Father category, Grandpa category ... To the top-level category name as the keyword, and then a sentence to describe the words, including the name of these class purposes. You can make a simple change according to your needs.

Usage, in your background class, the default is the admin inside create a new php file, file name customization, the following code is copied into the can, need to generate, access to this file is automatically generated.

<?PHPSet_time_limit(600);Define(' In_ecs ',true);require(dirname(__file__) . '/includes/init.php ');$sql _1= "Select Cat_id,cat_name from".$ecs->table (' category '). "Where parent_id = 0 ORDER by cat_id ASC";$res _1=$db->query ($sql _1);//first-Class circular while($row _1=$db->fetchrow ($res _1)){//access to first class sub- category$sql _2= "Select Cat_id,cat_name from".$ecs->table (' category '). "Where parent_id =".$row _1[' cat_id ']. " ORDER by cat_id ASC ";$res _2=$db->query ($sql _2);Print"* * * Level classification:".$row _1[' Cat_name ']. " <br> ";//First Class sub-category circular$keyword _1= ' ';$c 2= 0; while($row _2=$db->fetchrow ($res _2)){$c 2=$c 2+ 1;if($c 2< 7){//generate first Class purpose keywords and descriptions, take the top x$keyword _1=$keyword _1. Replace_cat_name ($row _2[' Cat_name ']) . ", ";}//=====================================================================//obtained class two category sub-category item$sql _3= "Select Cat_id,cat_name from".$ecs->table (' category '). "Where parent_id =".$row _2[' cat_id ']. " ORDER by cat_id ASC ";$res _3=$db->query ($sql _3);Print"****** level Two classification:".$row _2[' Cat_name ']. " <br> ";//Class two sub-category circular$keyword _2= ' ';$c 3= 0; while($row _3=$db->fetchrow ($res _3)){$c 3=$c 3+ 1;if($c 3< 7){//generate two Class purpose keywords and descriptions$keyword _2=$keyword _2. Replace_cat_name ($row _3[' Cat_name ']) . ", ";}//=====================================================================//obtained class three category sub-category item$sql _4= "Select Cat_id,cat_name from".$ecs->table (' category '). "Where parent_id =".$row _3[' cat_id ']. " ORDER by cat_id ASC ";$res _4=$db->query ($sql _4);Print"********* Level Three classification:".$row _3[' Cat_name ']. " <br> ";//Class three sub-category circular$keyword _3= ' ';$c 4= 0; while($row _4=$db->fetchrow ($res _4)){$c 4=$c 4+ 1;if($c 4< 7){//generate three class purpose keywords and descriptions$keyword _3=$keyword _3. Replace_cat_name ($row _4[' Cat_name ']) . ", ";}//Direct Write level three class purpose valuePrint"************ level Four classification:".$row _4[' Cat_name ']. " <br> ";$cat _name_4_str= Replace_cat_name ($row _4[' Cat_name ']);$keyword _4_str=$cat _name_4_str. "Products, Online shopping, Taobao Agent, Taobao dropship";$desc _4_str= "Online shopping".$cat _name_4_str." Products from ".$GLOBALS[' _cfg '] [' Shop_name ']. ", Factory Price, Worldwide shipping!";$db->query ("UPDATE".$ecs->table (' category '). "SET keywords = '".$keyword _4_str. "', Cat_desc = '".$desc _4_str."‘ WHERE cat_id = ".$row _4[' cat_id ']. "");}//processing updates for Level three class string$cat _name_3_str= Replace_cat_name ($row _3[' Cat_name ']);if(substr($keyword _3,-2) = = ', '){$keyword _3=substr($keyword _3, 0,strlen($keyword _3)-2);}if($keyword _3= = "'){$keyword _3_str=$cat _name_3_str. "Products";$desc _3_str= "Online shopping".$cat _name_3_str." Products, Browse Through our Category of ".$cat _name_3_str. "Products and more from".$GLOBALS[' _cfg '] [' Shop_name ']. ", Factory Price, Worldwide shipping!";}Else{$keyword _3_str=$cat _name_3_str. ", ".$keyword _3. "Products";$desc _3_str= "Online shopping".$cat _name_3_str." Products, Browse Through our Categories of ".$keyword _3. "Products and more from".$GLOBALS[' _cfg '] [' Shop_name ']. ", Factory Price, Worldwide shipping!";}$db->query ("UPDATE".$ecs->table (' category '). "SET keywords = '".$keyword _3_str. "', Cat_desc = '".$desc _3_str."‘ WHERE cat_id = ".$row _3[' cat_id ']. "");}//processing updates for Level two class string$cat _name_2_str= Replace_cat_name ($row _2[' Cat_name ']);if(substr($keyword _2,-2) = = ', '){$keyword _2=substr($keyword _2, 0,strlen($keyword _2)-2);}if($keyword _2= = "'){$keyword _2_str=$cat _name_2_str. "Products";$desc _2_str= "Online shopping".$cat _name_2_str." Products, Browse Through our Category of ".$cat _name_2_str. "Products and more from".$GLOBALS[' _cfg '] [' Shop_name ']. ", Factory Price, Worldwide shipping!";}Else{$keyword _2_str=$cat _name_2_str. ", ".$keyword _2. "Products";$desc _2_str= "Online shopping".$cat _name_2_str." Products, Browse Through our Categories of ".$keyword _2. "Products and more from".$GLOBALS[' _cfg '] [' Shop_name ']. ", Factory Price, Worldwide shipping!";}$db->query ("UPDATE".$ecs->table (' category '). "SET keywords = '".$keyword _2_str. "', Cat_desc = '".$desc _2_str."‘ WHERE cat_id = ".$row _2[' cat_id ']. "");//=====================================================================}//processing updates for a first-level category string$cat _name_1_str= Replace_cat_name ($row _1[' Cat_name ']);if(substr($keyword _1,-2) = = ', '){$keyword _1=substr($keyword _1, 0,strlen($keyword _1)-2);}$keyword _1_str=$cat _name_1_str. ", ".$keyword _1. "Products";$desc _1_str= "Online shopping".$cat _name_1_str." Products, Browse Through our Categories of ".$keyword _1. "Products and more from".$GLOBALS[' _cfg '] [' Shop_name ']. ", Factory Price, Worldwide shipping!";$db->query ("UPDATE".$ecs->table (' category '). "SET keywords = '".$keyword _1_str. "', Cat_desc = '".$desc _1_str."‘ WHERE cat_id = ".$row _1[' cat_id ']. "");}functionReplace_cat_name ($cate _name){$str=Str_replace(‘ ,‘,‘,‘,Str_replace(‘ ‘,‘ ‘,Str_replace(' & ', ', ',Str_replace(' & ', ', ',Str_replace(‘ /‘,‘/‘,Str_replace(‘/‘,‘, ‘,addslashes($cate _name)))))));return $str;}?>

Reprint: http://blog.sina.com.cn/s/blog_70ea94110101h5dd.html

Ecshop Network Program Optimization-Automatically generate category page keywords, desciption Meta

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.