Jump to content

a joomla module linkable rndom image - help .


krembo99

Recommended Posts

Hi guys

you 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 access
defined( '_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 = '&amp;Itemid='. $Itemid;
}

$link = sefRelToAbs( 'index.php?option=com_content&amp;task=view&amp;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&amp;task=view&amp;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 ?
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 :-(
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 ?

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.