Modify the title and description of the magento page ---- you can write a descroption array to randomly generate a token for the description.

Source: Internet
Author: User

 

Add the following to the block file for use: It is generally set in the block with the largest content, for example, mage_catalog_block_category_view.

 

Protected function _ preparelayout ()

{

Parent: _ preparelayout ();

 

$ This-> getlayout ()-> createblock ('catalog/breadcrumbs ');

 

If ($ headblock = $ this-> getlayout ()-> getblock ('head ')){

$ Category = $ this-> getcurrentcategory ();

If ($ Title = $ category-> getcategoritle ()){

$ Headblock-> settitle ($ title );

}

If ($ description = $ category-> getmetadescription ()){

$ Headblock-> setdescription ($ description );

}

If ($ KEYWORDS = $ category-> getmetakeywords ()){

$ Headblock-> setkeywords ($ keywords );

}

If ($ this-> helper ('catalog/Category ')-> canusecanonicaltag ()){

$ Headblock-> addlinkrel ('canonical', $ category-> geturl ());

}

/*

Want to show RSS feed in the URL

*/

If ($ this-> isrsscatalogenable () & $ this-> istopcategory ()){

$ Title = $ this-> helper ('rss ')->__ (' % s RSS feed', $ this-> getcurrentcategory ()-> getname ());

$ Headblock-> additem ('rss ', $ this-> getrsslink (), 'title = "'. $ title .'"');

}

}

 

Return $ this;

}

 

 

Example:

Protected function _ preparelayout ()

{

$ This-> getlayout ()-> createblock ('catalog/breadcrumbs ');

If ($ headblock = $ this-> getlayout ()-> getblock ('head ')){

If ($ Title = $ this-> getproduct ()-> getaskitle ()){

$ Headblock-> settitle ($ title );

}

// Title = Name is used as title.

Else {$ headblock-> settitle ($ this-> getproduct ()-> getname ());}

 

If ($ keyword = $ this-> getproduct ()-> getmetakeyword ()){

$ Headblock-> setkeywords ($ keyword );

} Elseif ($ currentcategory = Mage: Registry ('current _ category ')){

// Enter keywords here.

$ KEYWORDS = "Replica watches, Rolex watches ";

 

$ Headblock-> setkeywords ($ keywords );

 

// $ Headblock-> setkeywords ($ this-> getproduct ()-> getname ());

}

 

If ($ description = $ this-> getproduct ()-> getmetadeworkflow ()){

$ Headblock-> setdescription ($ description ));

} Else {

//

$ ZZ = $ this-> getproduct ()-> getname ();

// $ Arr1 = array ($ ZZ. & quot; 111 & quot;, $ ZZ. & quot; 222 & quot;, $ ZZ. & quot; 333 & quot;, $ ZZ. & quot; 444 & quot;, $ ZZ. & quot; 555 & quot;, $ ZZ. "666 ");

 

// Rand descroption array! The description to be randomly written here.

$ Arr1 = array (

 

$ ZZ. "On Sale ",

$ ZZ. "For Sale"

 

);

 

 

 

 

$ Ss = array_rand ($ arr1 );

 

 

 

 

//

$ Headblock-> setdescription ($ arr1 [$ SS]);

// $ Headblock-> setdescription ($ this-> getproduct ()-> getdescription ());

}

}

 

Return parent: _ preparelayout ();

}

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.