Jump to content

adding weight to keywords


SchweppesAle

Recommended Posts

alright,so basically I just need to add a weight to each of these keywords should duplicates be stored within the array.  I'm not really sure how to approach this problem though.  Here's the code

 

<?php

// Check to ensure this file is included in Joomla!
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.plugin.plugin' );

class plgContentLinkplugin extends JPlugin
{

public function onPrepareContent(&$article, &$params, $limitstart)
{		
	global $mainframe;

	$content = $article -> text;		
	$current = JURI::current();

	$link = $this->params->get('link_color');
	$hover = $this->params->get('hover_color');
	$visited = $this->params->get('visited_color');


	$font = '<style type = "text/css">						.link_platform{display:inline;	margin-right:2px;		}						.link_platform a:link{			color:'.$link.';			}			.link_platform a:visited{			color:'.$visited.';			}			.link_platform a:hover{			color:'.$hover.';			}									</style>';




$query = 'SELECT * FROM jos_keyword_keys WHERE (state = 0 AND (((DATEDIFF(CURDATE(), StartDate) >= 0 AND DATEDIFF(CURDATE(), EndDate) <= 0) OR (StartDate = 0000-00-00 AND EndDate = 0000-00-00)) AND (((TIMEDIFF(CURTIME(), StartTime) >= 0) AND (TIMEDIFF(CURTIME(), EndTime) <= 0)) OR (StartTime = "00:00:00"  AND EndTime = "00:00:00"))))';


	$query = mysql_query($query);

	$i = 0;
	$keywords;
	$Links;


	$date = date("Y-m-d");
	$todays_date = strtotime($date);

	while($row = mysql_fetch_array($query))
	{
	$words[$i] = $row['Word'];
	$KID[$i] = $row['ID'];
	$Links[$i] = $row['Destination'];
	$title[$i] = $row['Title'];
	$i++;
	}





$number = count($words);
/*$count = 0;*/
if($words[0] != NULL)
{
   for($i = 0; $i < $number; $i++)
   {


   
$Links[$i] = '<div class = "link_platform"><b><a href = "../?option=com_keywordstats&destination='.urlencode($Links[$i]).'&location='.urlencode($current).'&KID='.$KID[$i].'" rel = "nofollow" title = "'.$title[$i].'">'.$words[$i].'</a></b></div>';
$words[$i] = '/\b' . preg_quote($words[$i], '/') . '(?![^<]*?>)\b/';
/*$count++;
*/
   }
   
   
  
   $content  = preg_replace($words, $Links, $content);
   $article -> text = $content.$font;
  
}
   
}
}

Link to comment
https://forums.phpfreaks.com/topic/165806-adding-weight-to-keywords/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.