krembo99 Posted December 13, 2006 Share Posted December 13, 2006 Hi guysyou all know joomla/mambo right ?I have a module to enhance the random image module and make the images linked to their content item of origin.[code]<?php/*** @version $Id: mod_randomimagelink.php $* @package Joomla* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php* Joomla! is free software. This version may have been modified pursuant* to the GNU General Public License, and as distributed it includes or* is derivative of works licensed under the GNU General Public License or* other free or open source software licenses.* See COPYRIGHT.php for copyright notices and details.*/// no direct accessdefined( '_VALID_MOS' ) or die( 'Restricted access' );global $mosConfig_offset, $mosConfig_live_site, $mainframe;$moduleclass_sfx = $params->get( 'moduleclass_sfx' );$now = date( 'Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60 );$access = !$mainframe->getCfg( 'shownoauth' );$nullDate = $database->getNullDate(); $query = "SELECT * FROM #__content WHERE images != '' ORDER BY RAND() LIMIT 1"; $database->setQuery( $query ); $rows = $database->loadObjectList();# ONLY ONE ROW$row = $rows[0]; $bs = $mainframe->getBlogSectionCount(); $bc = $mainframe->getBlogCategoryCount(); $gbs = $mainframe->getGlobalBlogSectionCount();?><?php $Itemid = $mainframe->getItemid( $row->id, 0, 0, $bs, $bc, $gbs ); // Blank itemid checker for SEF if ($Itemid == NULL) { $Itemid = ''; } else { $Itemid = '&Itemid='. $Itemid; } $link = sefRelToAbs( 'index.php?option=com_content&task=view&id='. $row->id . $Itemid ); ?> <?php $thumbnail = explode("\n", $row->images); //$thumbnail = explode("|", $thumbnail[1]); $thumbnail = explode("|", end($thumbnail)); $thumbnail = $thumbnail[0]; ?> <div class="<?php echo "modulediv". $moduleclass_sfx; ?>"> <a href="<?php echo $link; ?>"> <img src="images/stories/<?php echo $thumbnail; ?>" alt="<?php echo $thumbnail; ?>" border='0' /> </a> </div>[/code]Now this code actes strangely.At first when I installed it, it seemed to work just great, but then I have noticed, that for some reason, it keeps cycling between 6 articles I had PRIOR to it's installation, and does not really see new ones I am inserting.I am a quite a complete noobie but I see that here : [code]$link = sefRelToAbs( 'index.php?option=com_content&task=view&id='. $row->id . $Itemid );[/code]The [code]$row->id[/code] is where the module searches for the link itself.Could that ID be the problem when I change articles/modules?can it be done in another way ? anyone has an idea why it could fail ? Quote Link to comment Share on other sites More sharing options...
artacus Posted December 13, 2006 Share Posted December 13, 2006 Just run the query "SELECT * FROM #__content WHERE images != '' ORDER BY RAND()" and see if it is selecting other records. Quote Link to comment Share on other sites More sharing options...
krembo99 Posted December 13, 2006 Author Share Posted December 13, 2006 no, it's not selecting other images...the funny thing is that it was supposed to look at the content items in the table, pick the FIRST image that the content item has, and display it with the link to the item.I even tried to uninstall and re-install again, but to no result :-( Quote Link to comment Share on other sites More sharing options...
artacus Posted December 13, 2006 Share Posted December 13, 2006 Well I'm wondering if they are going into another table. Quote Link to comment Share on other sites More sharing options...
krembo99 Posted December 15, 2006 Author Share Posted December 15, 2006 I was wondering the same thing... ;)now the problem is resolved... I do not know quite why and how.But i have another question. the script was intended to search for the FIRST image in the content item, and instead now it outputs the LAST image.why ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.