| changes in Spotlight module |
| by fmiguel on 2006/7/29 18:33:33 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.' <input type="text" name="options[]" value="'.$options[0].'" /> '._MB_KUHT_TITLELENGTH.' <br />'; $form.= '<b>'._MB_KUHT_OTHERNEWS.'</b><br />'; $form.= _MB_KUHT_ORDER.' <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.' <input type="text" size="2" name="options[]" value="'.$options[2].'" /> '._MB_KUHT_ARTCLS.'<br />'; $form.= _MB_KUHT_CHARS.' <input type="text" size="2"name="options[]" value="'.$options[3].'" /> '._MB_KUHT_LENGTH.'<br />'; $form.= _MB_KUHT_TOPICS.' <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}> <{$block.lang_comments}> | <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 |