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 ?
Link to comment
Share on other sites

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 :-(
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.