1
gooberlx
Re: How to put news on index page
  • 2004/8/20 4:34

  • gooberlx

  • Just popping in

  • Posts: 3

  • Since: 2004/8/14


well that could be done....but for some reason that didn't seem to work either, I probably need to set the start page to news....which is not what I want.

Here're my files in their current form:
*remember you'll need to update the news module from the config pages.*

news_block_top.html
<{foreach item=news from=$block.stories}>
  <
div class="itemHead"><span class="itemTitle">
      <
a href="<{$xoops_url}>/modules/news/article.php?storyid=<{$news.id}>"><{$news.title}></a>
  </
span></div>
  <
div class="itemBody">
    <
class="itemText"><{$news.text}></p>
  </
div>
  <
div class="itemFoot"><span class="itemPermaLink">
      <
a href="<{$xoops_url}>/modules/news/article.php?storyid=<{$news.id}>"><{$news.comments}></a>
  </
span></div>
<{/foreach}>


new_top.php
<?php
// $Id: news_top.php,v 1.1 2004/01/29 14:45:49 buennagel 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_news_top_show($options) {
    global 
$xoopsDB;
    
$myts =& MyTextSanitizer::getInstance();
    
$block = array();
    
$sql "SELECT storyid, title, hometext, comments, published, expired, counter FROM ".$xoopsDB->prefix("stories")." WHERE published < ".time()." AND published > 0 AND (expired = 0 OR expired > ".time().") ORDER BY ".$options[0]." DESC";
    
$result $xoopsDB->query($sql,$options[1],0);
    while ( 
$myrow $xoopsDB->fetchArray($result) ) {
        
$news = 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)))."...";
            }
        }
        
$news['title'] = $title;
        
$text str_replace("n""<br />"$myrow['hometext']);
        
$news['text'] = $text;
        if( 
$myrow['comments'] != ){
            
$news['comments'] = (string)$myrow['comments']." comment(s). Read More...";
        } else{
            
$news['comments'] = "Post Comment/Read More...";
        }
        
$news['id'] = $myrow['storyid'];
        if ( 
$options[0] == "published" ) {
            
$news['date'] = formatTimestamp($myrow['published'],"s");
        } elseif ( 
$options[0] == "counter" ) {
            
$news['hits'] = $myrow['counter'];
        }
        
$block['stories'][] = $news;
    }
    return 
$block;
}

function 
b_news_top_edit($options) {
    
$form ""._MB_NEWS_ORDER."&nbsp;<select name='options[]'>";
    
$form .= "<option value='published'";
    if ( 
$options[0] == "published" ) {
        
$form .= " selected='selected'";
    }
    
$form .= ">"._MB_NEWS_DATE."</option>n";
    
$form .= "<option value='counter'";
    if(
$options[0] == "counter"){
        
$form .= " selected='selected'";
    }
    
$form .= ">"._MB_NEWS_HITS."</option>n";
    
$form .= "</select>n";
    
$form .= "&nbsp;"._MB_NEWS_DISP."&nbsp;<input type='text' name='options[]' value='".$options[1]."' />&nbsp;"._MB_NEWS_ARTCLS."";
    
$form .= "&nbsp;<br>"._MB_NEWS_CHARS."&nbsp;<input type='text' name='options[]' value='".$options[2]."' />&nbsp;"._MB_NEWS_LENGTH."";


    return 
$form;
}
?>


Image of my start page



2
gooberlx
Re: How to put news on index page
  • 2004/8/16 1:24

  • gooberlx

  • Just popping in

  • Posts: 3

  • Since: 2004/8/14


Done and Done...
SO here's what I did, for the curious:

I decided to just use the use/change the "Top News" block template. It now looks like this (basically I just stole selected parts of the formatting from the news_item.html template):
<{foreach item=news from=$block.stories}>
  <
div class="itemHead"><span class="itemTitle">
     <
a href="<{$xoops_url}>/modules/news/article.php?storyid=<{$news.id}>"><{$news.title}></a>
  </
span></div>
  <
div class="itemBody">
    <{
$story.imglink}>
    <
class="itemText"><{$news.text}></p>
  </
div>
  <
div class="itemFoot"><span class="itemPermaLink">
    <
a href="<{$xoops_url}>/modules/news/article.php?storyid=<{$news.id}>">Read More...</a>
  </
span></div>
<{/foreach}>


And I also had to change the news_top.php to get the "Scoop" text into $news. Additions were these:
$sql "SELECT storyid, title, [b]hometext[/b], published, expired, counter FROM ".$xoopsDB->prefix("stories")."
WHERE published < "
.time()." AND published > 0
AND (expired = 0 OR expired > "
.time().")
ORDER BY "
.$options[0]." DESC";

... and ...

$news['text'] = str_replace("n""<br />"$myrow['hometext']); [i]<--- text formatting good![/i]


I'm sure I could make it more fancy schmancy, but this works just fine for me.

Hope this helps someone.



3
gooberlx
Re: How to put news on index page
  • 2004/8/14 22:13

  • gooberlx

  • Just popping in

  • Posts: 3

  • Since: 2004/8/14


I know exactly what he's talking about and I'd like to know too.

Basically I have "none" selected for the module start page, because then those news posts span the entire page at the bottom.

I'd like a selectable number of news posts to display (+ scoop text, not just title) that will be fitted into whichever block area I select.

So, for me, I'm trying to get the 2 most recent news posts to be placed as the first items (weight 0) in my center-left block area.

I have no idea how to accomplish this, and none of the existing blocks/modules seem to do this either.




TopTop



Login

Who's Online

158 user(s) are online (101 user(s) are browsing Support Forums)


Members: 0


Guests: 158


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