Dimanche, 20 Mai 2012
Lundi, 11 Avril 2011 15:30

Mise à jour des tags dans le k2

Written by  newgekko
Rate this item
(0 votes)

case 'listetags':
listetags ();
break;

case 'ajoutertags':
ajoutertags();
listetags();
break;

//////////////////////////////////////////////////////////////////////////

function listetags (){

// efface la liste des tags
mysql_query("TRUNCATE TABLE jos_k2_tags_xref");


$db = &JFactory::getDBO();
$query = "SELECT id, name FROM jos_k2_tags ORDER BY name ASC";
$db->setQuery($query);
$tags = $db->loadObjectList();

foreach ($tags as $tag) {
ajoutertags ($tag->name);
echo "<li><a href=\"index.php?option=com_administration&act=ajoutertags&tag=$tag->name\">".$tag->name."</a></li>";
}
}

function ajoutertags ($tag){
// tags
$q8 = mysql_query("SELECT * FROM jos_k2_tags WHERE name = '$tag'");
$r8 = mysql_fetch_array($q8);
$tagid = $r8["id"];
echo "- ".$tagid."<br />";
// mysql_query("DELETE FROM jos_k2_tags_xref WHERE tagID = $tagid");

$tagmiddle = "% ".$tag." %"; // avec espace devant et derriere
$tagend = "% ".$tag; // avec espace devant et rien derriere
$tagfirst = $tag." %";
$tagdot = "% ".$tag.".%";

$tags = "% ".$tag."s %";
$tagsend = "% ".$tag."s"; // avec espace devant et rien derriere
$tagsfirst = $tag."s %";
$tagsdot = "% ".$tag."s.%";

$db = &JFactory::getDBO();
$query = "SELECT id FROM jos_k2_items WHERE title LIKE '$tagend' OR introtext LIKE '$tagend' OR `fulltext` LIKE '$tagend'
OR title LIKE '$tagmiddle' OR introtext LIKE '$tagmiddle' OR `fulltext` LIKE '$tagmiddle'
OR title LIKE '$tagdot' OR introtext LIKE '$tagdot' OR `fulltext` LIKE '$tagdot'
OR title LIKE '$tagfirst' OR introtext LIKE '$tagfirst' OR `fulltext` LIKE '$tagfirst'
OR title LIKE '$tags' OR introtext LIKE '$tags' OR `fulltext` LIKE '$tags'
OR title LIKE '$tagsend' OR introtext LIKE '$tagsend' OR `fulltext` LIKE '$tagsend'
OR title LIKE '$tagsfirst' OR introtext LIKE '$tagsfirst' OR `fulltext` LIKE '$tagsfirst'
OR title LIKE '$tagsdot' OR introtext LIKE '$tagsdot' OR `fulltext` LIKE '$tagsdot'";

$db->setQuery($query);
$items = $db->loadObjectList();
echo "<ul>";
foreach ($items as $item) {
$itemid = $item->id;
mysql_query("INSERT INTO jos_k2_tags_xref SET tagID='$tagid', itemID='$itemid'");
echo"<li><a href=\"index.php?option=com_k2&view=item&cid=$item->id\" target=\"_blank\">".$item->id;
echo"</a></li>";
}
echo"</ul>";
}


Last modified on Lundi, 11 Avril 2011 15:35
newgekko

newgekko

Devenez mon ami sur facebook !

E-mail: Cette adresse email est protégée contre les robots des spammeurs, vous devez activer Javascript pour la voir.
blog comments powered by Disqus

Calendrier

« Mai 2012 »
Lun Mar Mer Jeu Ven Sam Dim
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31