Annotation of /mambo/branches/4.6/modules/mod_related_items.php
Parent Directory
|
Revision Log
Revision 3 - (view) (download)
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | * @version $Id: mod_related_items.php,v 1.1 2005/07/22 01:58:30 eddieajau Exp $ | ||
| 4 : | * @package Mambo | ||
| 5 : | * @copyright (C) 2000 - 2005 Miro International Pty Ltd | ||
| 6 : | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL | ||
| 7 : | * Mambo is Free Software | ||
| 8 : | */ | ||
| 9 : | |||
| 10 : | /** ensure this file is being included by a parent file */ | ||
| 11 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 12 : | |||
| 13 : | $option = trim( mosGetParam( $_REQUEST, 'option', null ) ); | ||
| 14 : | $task = trim( mosGetParam( $_REQUEST, 'task', null ) ); | ||
| 15 : | $id = intval( mosGetParam( $_REQUEST, 'id', null ) ); | ||
| 16 : | $moduleclass_sfx = $params->get( 'moduleclass_sfx' ); | ||
| 17 : | |||
| 18 : | if ($option == 'com_content' && $task == 'view' && $id) { | ||
| 19 : | |||
| 20 : | // select the meta keywords from the item | ||
| 21 : | $query = "SELECT metakey FROM #__content WHERE id='$id'"; | ||
| 22 : | $database->setQuery( $query ); | ||
| 23 : | |||
| 24 : | if ($metakey = trim( $database->loadResult() )) { | ||
| 25 : | // explode the meta keys on a comma | ||
| 26 : | $keys = explode( ',', $metakey ); | ||
| 27 : | $likes = array(); | ||
| 28 : | |||
| 29 : | // assemble any non-blank word(s) | ||
| 30 : | foreach ($keys as $key) { | ||
| 31 : | $key = trim( $key ); | ||
| 32 : | if ($key) { | ||
| 33 : | $likes[] = $database->getEscaped( $key ); | ||
| 34 : | } | ||
| 35 : | } | ||
| 36 : | |||
| 37 : | if (count( $likes )) { | ||
| 38 : | // select other items based on the metakey field 'like' the keys found | ||
| 39 : | $query = "SELECT id, title" | ||
| 40 : | . "\nFROM #__content" | ||
| 41 : | . "\nWHERE id<>$id AND state=1 AND access <=$my->gid AND (metakey LIKE '%"; | ||
| 42 : | $query .= implode( "%' OR metakey LIKE '%", $likes ); | ||
| 43 : | $query .= "%')"; | ||
| 44 : | |||
| 45 : | $database->setQuery( $query ); | ||
| 46 : | if ($related = $database->loadObjectList()) { | ||
| 47 : | echo "<ul>\n"; | ||
| 48 : | foreach ($related as $item) { | ||
| 49 : | if ($option="com_content" && $task="view") { | ||
| 50 : | $Itemid = $mainframe->getItemid($item->id); | ||
| 51 : | } | ||
| 52 : | $href = sefRelToAbs( "index.php?option=com_content&task=view&id=$item->id&Itemid=$Itemid" ); | ||
| 53 : | echo " <li><a href=\"$href\">$item->title</a></li>\n"; | ||
| 54 : | } | ||
| 55 : | echo "</ul>\n"; | ||
| 56 : | } | ||
| 57 : | } | ||
| 58 : | } | ||
| 59 : | } | ||
| 60 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

