Hereby a guide.
First add these lines to mylinks/xoops_version.php
le="color: #000000"><?php $modversion['blocks'][3]['file'] = "mylinks_top.php"; $modversion['blocks'][3]['name'] = _MI_MYLINKS_BNAME3; $modversion['blocks'][3]['description'] = "Shows random web links"; $modversion['blocks'][3]['show_func'] = "b_mylinks_random"; $modversion['blocks'][3]['edit_func'] = "b_mylinks_random_edit"; $modversion['blocks'][3]['options'] = "random|1|19"; $modversion['blocks'][3]['template'] = 'mylinks_block_random.html';
after
le="color: #000000"><?php $modversion['blocks'][2]['file'] = "mylinks_top.php"; $modversion['blocks'][2]['name'] = _MI_MYLINKS_BNAME2; $modversion['blocks'][2]['description'] = "Shows most visited web links"; $modversion['blocks'][2]['show_func'] = "b_mylinks_top_show"; $modversion['blocks'][2]['edit_func'] = "b_mylinks_top_edit"; $modversion['blocks'][2]['options'] = "hits|10|25"; $modversion['blocks'][2]['template'] = 'mylinks_block_top.html';
Add the following to mylinks/languages/english/modinfo.php
le="color: #000000"><?php define("_MI_MYLINKS_BNAME3","Random Link");
Replace the file mylinks/blocks/mylinks_top.php with this one:
<?php // $Id: mylinks_top.php,v 1.11 2004/12/26 19:11:56 Onokazu Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // // <https://xoops.org/> // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // // the Free Software Foundation; either version 2 of the License, or // // (at your option) any later version. // // // // You may not change or alter any portion of this comment or credits // // of supporting developers from this source code or any supporting // // source code which is considered copyrighted (c) material of the // // original comment or credit authors. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // /****************************************************************************** * Function: b_mylinks_top_show * Input : $options[0] = date for the most recent links * hits for the most popular links * $block['content'] = The optional above content * $options[1] = How many reviews are displayes * Output : Returns the desired most recent or most popular links ******************************************************************************/ function b_mylinks_top_show($options) { global $xoopsDB; $block = array(); $myts =& MyTextSanitizer::getInstance(); $result = $xoopsDB->query("SELECT lid, cid, title, date, hits FROM ".$xoopsDB->prefix('mylinks_links')." WHERE status>0 ORDER BY ".$options[0]." DESC",$options[1],0); while($myrow = $xoopsDB->fetchArray($result)){ $link = array(); $title = $myts->makeTboxData4Show($myrow["title"]); if ( !XOOPS_USE_MULTIBYTES ) { if (strlen($myrow['title']) >= $options[2]) { $title = $myts->makeTboxData4Show(substr($myrow['title'],0,($options[2] -1)))."..."; } } $link['id'] = $myrow['lid']; $link['cid'] = $myrow['cid']; $link['title'] = $title; if($options[0] == "date"){ $link['date'] = formatTimestamp($myrow['date'],'s'); }elseif($options[0] == "hits"){ $link['hits'] = $myrow['hits']; } $block['links'][] = $link; } return $block; } function b_mylinks_random( $options ) { global $xoopsDB, $xoopsModuleConfig; $block = array(); $myts =& MyTextSanitizer::getInstance(); $result = $xoopsDB->query("SELECT lid, cid, title, url, date, logourl FROM ".$xoopsDB->prefix('mylinks_links')." WHERE status>0 ORDER BY RAND() LIMIT 1 "); while($myrow = $xoopsDB->fetchArray($result)){ $title = $myts->makeTboxData4Show($myrow["title"]); if ( !XOOPS_USE_MULTIBYTES ) { if ( strlen( $title ) >= $options[2] ) { $title = substr( $title, 0, ( $options[2] -1 ) ) . "..."; } } $block['id'] = $myrow['lid']; $block['cid'] = $myrow['cid']; $block['title'] = $title; $block['url'] = $url; $block['logourl'] = $myrow['logourl']; $block['date'] = formatTimestamp($myrow['date'],'s'); //$block['random'][] = $random; } return $block; } function b_mylinks_top_edit($options) { $form = ""._MB_MYLINKS_DISP." "; $form .= "<input type='hidden' name='options[]' value='"; if($options[0] == "date"){ $form .= "date'"; }else { $form .= "hits'"; } $form .= " />"; $form .= "<input type='text' name='options[]' value='".$options[1]."' /> "._MB_MYLINKS_LINKS.""; $form .= " <br>"._MB_MYLINKS_CHARS." <input type='text' name='options[]' value='".$options[2]."' /> "._MB_MYLINKS_LENGTH.""; return $form; } function b_mylinks_random_edit( $options ) { $form = "" . _MB_MYLINKS_CHARS . " "; $form .= "<input type='text' name='options[]' value='" . $options[2] . "' /> " . _MB_MYLINKS_LENGTH . ""; return $form; } ?>
Create a file called mylinks_block_random.html in the folder mylinks/templates/blocks. This is the code for this file:
le="color: #000000"><?php <div align="center"> <a href="<{$xoops_url}>/modules/mylinks/visit.php?cid=<{$block.cid}>&lid=<{$block.id}>"><{$block.title}></a> <br /> <{$block.date}> <br /> <a href="<{$xoops_url}>/modules/mylinks/visit.php?cid=<{$block.cid}>&lid=<{$block.id}>" target="_blank"> <img src="<{$xoops_url}>/modules/mylinks/images/shots/<{$block.logourl}>" width="88" height="31" alt=""/></a> </div>
Good luck!!!