Thursday, October 21, 2010

Dynamic page titles for mighty resource article listing

For SEO purposes duplicate page titles is a headache the following hack will solve the problem.

open the file:


components\com_resource\views\list\tmpl\default.php

in line 50 add the following code:


                    /*START: Page title override */
                        $doc =& JFactory::getDocument();
                       
                       
                        $meta_description = $doc->getMetaData("description");
                        $meta_keywords = $doc->getMetaData("keywords");
                       
                        $Unique_page_title =  $doc->getTitle()." ".$pages;
                       
                        $Unique_page_description = $meta_description." - ".$pages;
                       
                        $Unique_page_keywords = $meta_keywords.",".$pages;
                       
                       
                        $doc->setTitle($Unique_page_title);
                       
                        $doc->setMetaData( 'description', $Unique_page_description );
                       
                        $doc->setMetaData( 'keywords', $Unique_page_keywords );

                       
                    /*END: Page title override */

the above code will generate unique page titles, description and keywords to your article list pages. example "Category Name Page 1 of 10".


Now search engines can index your article listing by page.

Note you can customize the code above by modifying the  $Unique_page_title variable.

Enjoy!

No comments:

Post a Comment