1
fmiguel
changes in Spotlight module
  • 2006/7/29 18:33

  • fmiguel

  • Just popping in

  • Posts: 17

  • Since: 2006/3/29


Hi all;

I'm trying to modify spotlight module in this way: show 3 news, category news in one block (c-left) and other 3 news category events in other block (c-right).
My first step is: show the last three news in spotlight block like the first notice choice, in preferences of module and not with topics. Include three thumb images.

My code:

<?php
//kuht_head.php

include_once(XOOPS_ROOT_PATH.'/class/xoopsstory.php');
include_once(XOOPS_ROOT_PATH.'/class/module.textsanitizer.php');
function b_head_kuht_show($options)
{
global $xoopsDB, $xoopsConfig;
$myts =& MyTextSanitizer::getInstance();
$fhometext = "";
$block = array();
$block['title'] = _MB_KUHT_TITLE_SPOTLIGHT;
$tdate = mktime(0,0,0,date("n"),date("j"),date("Y"));

$block['lang_by'] = _MB_KUHT_BY;
$block['lang_read'] = _MB_KUHT_READ;
$block['lang_comments'] = _MB_KUHT_COMMENTS;
$block['lang_write'] = _MB_KUHT_WRITE;
$block['lang_othernews']= _MB_KUHT_OTHERNEWSTEXT;


$result = $xoopsDB->query("SELECT storyid, uid, title, hometext, comments FROM ".$xoopsDB->prefix("stories")." WHERE published < ".time()." AND published > 0 AND (expired = 0 OR expired > ".time().") ORDER BY published DESC LIMIT 3",1,0);


while ( $block = mysql_fetch_array ( $result, MYSQL_ASSOC )){
foreach ($block as $chave => $valor){
$block[$chave][] = $valor;
}
}

for ( $i=0; $i<3; $i++){
if (!$block[$i]['id'] && !$block["$i"]['title']) {
$block["$i"]['message'] = _MB_KUHT_NOTSELECT;
} else {
if ($auto_image == 0) {
$block["$i"]['image'] = $image;
} //else {
//$var_image = $xoopsDB->query("SELECT topicid FROM ".$xoopsDB->prefix("stories")." WHERE storyid=".$number."",1,0);
//list ($patt_image) = $xoopsDB->fetchblock($var_image);
//$var_image2 = $xoopsDB->query("SELECT topic_imgurl FROM ".$xoopsDB->prefix("topics")." WHERE topic_id=".$patt_image."",1,0);
//list ($image_display) = $xoopsDB->fetchblock($var_image2);
$block["$i"]['image_display'] = $image_display;
}

if (!XOOPS_USE_MULTIBYTES) {
if (strlen($block["$i"]['title']) >= $options[0]) {
$block["$i"]['title'] = substr($block["$i"]['title'],0,($options[0] -1))."...";
}
}
$block["$i"]['title'] = $myts->makeTboxData4Show($block["$i"]['title']);
//$block['uid'] = $myts->makeTboxData4Show($uidutente);
//$block['author'] = $myts->makeTboxData4Show($fautorevero);
$block["$i"]['hometext'] = $myts->xoopsCodeDecode($block["$i"]['hometext']); // BB Codes
$block["$i"]['hometext'] = $myts->nl2Br($block["$i"]['hometext']);
$block["$i"]['storyid'] = $myts->makeTboxData4Show($block["$i"]['storyid']);
$block["$i"]['comments'] = $myts->makeTboxData4Show($block["$i"]['comments']);

}
mysql_free_result ( $result );
return $block;

function b_head_kuht_edit($options)
{
$form = _MB_KUHT_TITLECHARS.'&nbsp;<input type="text" name="options[]" value="'.$options[0].'" />&nbsp;'._MB_KUHT_TITLELENGTH.'&nbsp;<br />';
$form.= '<b>'._MB_KUHT_OTHERNEWS.'</b><br />';
$form.= _MB_KUHT_ORDER.'&nbsp;<select name="options[]">';
$form.= '<option value="published"';
if ($options[1] == "published") {
$form .= ' selected="selected"';
}
$form.= '>'._MB_KUHT_DATE.'</option>';
$form.= '<option value="counter"';
if ($options[1] == "counter") {
$form .= ' selected="selected"';
}
$form.= '>'._MB_KUHT_HITS.'</option>';
$form.= '</select>';
$form.= _MB_KUHT_DISP.'&nbsp;<input type="text" size="2" name="options[]" value="'.$options[2].'" />&nbsp;'._MB_KUHT_ARTCLS.'<br />';
$form.= _MB_KUHT_CHARS.'&nbsp;<input type="text" size="2"name="options[]" value="'.$options[3].'" />&nbsp;'._MB_KUHT_LENGTH.'<br />';
$form.= _MB_KUHT_TOPICS.'&nbsp;<input type="text" size="2" name="options[]" value="'.$options[4].'" />';
return $form;
?>

my template:

<div class="blockContent">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<{foreach item=block from=$block}>
<tr>
<td valign="top">
<{if $block.image != ""}>
<img src="<{$xoops_url}>/modules/spotlight/images/<{$block.image}>">
<{else}>
<img src="<{$xoops_url}>/modules/news/images/topics/<{$block.image_display}>">
<{/if}>
</td>
<td>
<{$block.hometext}>
<b>
<a href="<{$xoops_url}>/modules/news/article.php?storyid=<{$block.storyid }>">
<{$block.lang_read}>
</a>
</b>
</td>
</tr>
<{if $xoops_userid != ""}>
<tr align="right">
<td colspan="2" valign="top">
<{$block.comments}>&nbsp;<{$block.lang_comments}>&nbsp;|
<a href="<{$xoops_url}>/modules/news/comment_new.php?com_itemid=<{$block.storyid}>">
<{$block.lang_write}>
</a>
</td>
</tr>
<{/if}>
</foreach>
</table>
</div>

Anyone can help???

Thank you!

XOOPS Version: 2.0.13
Module Name/Version: Spotlight 1.4
PHP Version: 5
Web Server Software (Apache/IIS/Other): Apache
Operating System: Windows XP
Theme you are using: Default (for test)
Custom template: (Yes/No) I hope
PHP Debug Messages:
Warning [PHP]: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in file C:\apachefriends\xampp\htdocs\dev\modules\spotlight\blocks\kuht_head.php line 57
Notice [PHP]: Undefined offset: 0 in file C:\apachefriends\xampp\htdocs\dev\modules\spotlight\blocks\kuht_head.php line 68

Login

Who's Online

132 user(s) are online (69 user(s) are browsing Support Forums)


Members: 0


Guests: 132


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits