Keyword

Meta data from article text, tags, custom fields ?

More
14 years 9 months ago #79446 by BBCYP
On a Joomla 1.0 site i admin with the jReviews component (slideshow customer!!) i somehow managed to edit the relevant and use cmsFramework::meta('keywords',$predefinedvariableofyourchoice); to use custom fields from jReviews tied to the article to 'automate' the meta data for the article.  The logic being that the article and its associated table data already contained the META data so why should i sit and key in meta data for 500+ businesses .....
Anyway it worked really well for good listings so no this new site with K2 i`m wondering how to achieve something similar. item.php (.../components/com_k2/templates/default/) appears to be the right location for this to be coded in, any suggestion or pointers to get there ?

Such as 

- appending the article/item title/meta-title to include the K2 category and/or custom fields ;

- cycling through the item tags and then adding a divider between then (eg a comma) to make the meta keywords ;

-  append the keywords above after the sites main meta description then append the first xx characters of the article/item to make the pages meta description

Please Log in or Create an account to join the conversation.

More
14 years 9 months ago #79447 by BBCYP
I have done the following and it appears to do what i want



$document =& JFactory::getDocument();

$defaultmetadesc = $document->getMetaData('Description');
$defaultkeywords = $document->getMetaData('Keywords');
$defaulttitle = $this->item->title;
$itemcategory = $this->item->category->name ;

$shortenedintro = substr(strip_tags($this->item->introtext),1,100);
$newmetadesc = $shortenedintro. ',' .$defaultmetadesc ;
$document->setMetadata('Description', $newmetadesc);

foreach ($this->item->tags as $tag):
$doctags = $tag->name. ' ' .$doctags ;
endforeach;
$newmetakeywords = $doctags.$defaultkeywords ;
$document->setMetadata('Keywords', $newmetakeywords);

$newmetatitle = $itemcategory. ' - ' .$defaulttitle ;
$document->setMetadata('Title', $newmetatitle);

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum