1
jfmoore
Recent News titles to include topic?
  • 2004/12/18 15:07

  • jfmoore

  • Quite a regular

  • Posts: 360

  • Since: 2004/6/6 5


Hope this is the right place to ask this:

I would like the topic to be displayed along with the titles in the "Recent News" block. Is there a relatively easy way to do this, and, if so, how?

Thanks,

JFM

2
Anonymous
Re: Recent News titles to include topic?
  • 2004/12/18 15:19

  • Anonymous

  • Posts: 0

  • Since:


Try Lykos Blocks Module

3
jfmoore
Re: Recent News titles to include topic?
  • 2004/12/18 16:11

  • jfmoore

  • Quite a regular

  • Posts: 360

  • Since: 2004/6/6 5


Quote:

Mowaffak wrote:
Try Lykos Blocks Module


Thanks for the suggestion. Installed the blocks, but, when I set one to visible on the top page, all I get is a blank page.
Maybe they won't work with News 1.21?

JFM

4
jfmoore
Re: Recent News titles to include topic?
  • 2004/12/18 16:38

  • jfmoore

  • Quite a regular

  • Posts: 360

  • Since: 2004/6/6 5


Okay, got Lykos Blocks working on another site where Topics Blocks were not installed. Probably cannot have both. Anyway, the block looks just like any other recent news block--no topic in the title.

I am curious, though, why did you think that the topic would be included in the Lykos block with the article title? Is there an option, perhaps, that I have overlooked?

JFM

5
Anonymous
Re: Recent News titles to include topic?
  • 2004/12/19 7:41

  • Anonymous

  • Posts: 0

  • Since:


After u install it, gp to system admin >> blocks >> Lykos block >> Edit, then put <{$news.hometext}>

Try this as example :
<{foreach item=news from=$block.stories}>
<
div class="xf_block">
<
li><h1><b>[<{$news.date}>]</b></li>
<{if 
$news.image_display !=""}>
<
span style="float: <{$news.topicalign}>;background-color: transparent; margin-right: 15px; margin-top: 3px;">
<
img src="<{$xoops_url}>/modules/news/images/topics/<{$news.image_display}>" alt="<{$news.title}>" /></span>
<{/if}>
<{
$news.hometext}> ..... <a href="<{$xoops_url}>/modules/news/article.php?storyid=<{$news.id}>"><font color="#9c0000"><{$news.readmorelink}></font></a></h1>
</
div>
<{/foreach}>

6
jfmoore
Re: Recent News titles to include topic?
  • 2004/12/19 17:23

  • jfmoore

  • Quite a regular

  • Posts: 360

  • Since: 2004/6/6 5


Okay, I'm going to risk a double post, but my last entry is not appearing here, so here it is again, as well as I can remember:

Mowaffak,

Thanks for your input, but I don't think we are talking about the same thing. Lykos Blocks, like Topics Blocks, just show 1 topic at a time. That's not what I want.

What I want is a block, like the News module's "Recent News" block (which shows articles in ALL topics), to display the topic along with the article title like so:

==========================================
Recent News
------------------------------------------
* NATIONAL :: Godzilla Eats Baltimore!
* LOCAL :: Mayor Resigns & Opens Casino
==========================================

etc.

So, what I assume I need to do is modify the "Recent News" block template. The question is how? Any suggestion on this?

JFM

7
Anonymous
Re: Recent News titles to include topic?
  • 2004/12/21 14:17

  • Anonymous

  • Posts: 0

  • Since:


Hi,
can u send what u wwhat as photo

8
jfmoore
Re: Recent News titles to include topic?
  • 2005/1/3 17:41

  • jfmoore

  • Quite a regular

  • Posts: 360

  • Since: 2004/6/6 5


Sorry it took so long to get back. The holidays, you know.

Quote:

Mowaffak wrote:
Hi,
can u send what u wwhat as photo


I haven't seen it done anywhere, or I could probably have asked the site owner how he did it. So I can't send a screen shot. Sorry.

If you will picture, however, the below as a representation of the "Recent News" block on the home page, I think you will see what I want to do:

==========================================
Recent News
------------------------------------------
* NATIONAL :: Godzilla Eats Baltimore!
* LOCAL :: Mayor Resigns & Opens Casino
==========================================

In the above example, "NATIONAL" and "LOCAL" are topics.

"Godzilla Eats Baltimore!" and "Mayor Resigns & Opens Casino" are the article titles. Normally, only the titles appear in the block. I want the topics, too.

Surely this can't be very hard to do, or can it?

Thanks.

9
rowdie
Re: Recent News titles to include topic?
  • 2005/1/3 20:36

  • rowdie

  • Just can't stay away

  • Posts: 846

  • Since: 2004/7/21


It's not hard to do, but you will need to change the PHP file news_top.php, found in modules/news/blocks/.

Best to first make a copy of news_top.php, in case something goes wrong

Then you need to replace the sql statements in the function b_news_top_show with the following code :
if ( $options[3] == ) {
        
$sql "SELECT storyid, title, published, expired, counter, topic_title FROM
              "
.$xoopsDB->prefix("stories")." , ".$xoopsDB->prefix("topics")." t WHERE published < ".time()."
              AND published > 0 AND (expired = 0 OR expired > "
.time().") AND topicid = t.topic_id ORDER BY
              "
.$options[0]." DESC";
    }
    else {
        
$sql "SELECT storyid, title, published, expired, counter, topic_title FROM
                   "
.$xoopsDB->prefix("stories")." , ".$xoopsDB->prefix("topics")." t WHERE published < ".time()."
                   AND published > 0 AND (expired = 0 OR expired > "
.time().") AND topicid in
                   "
.$topicpick." AND topicid = t.topic_id ORDER BY ".$options[0]." DESC";
    }    
$result $xoopsDB->query($sql,$options[1],0);


Next, find $news = array(); in the same function.
After that replace the $title = with the following code :

$topic_title $myts->makeTboxData4Show($myrow["topic_title"]);
$title $topic_title " :: " $myts->makeTboxData4Show($myrow["title"]);


The complete function should look like this :
function b_news_top_show($options) {
    global 
$xoopsDB;
    
$myts =& MyTextSanitizer::getInstance();
    
$block = array();
    
$options_new array_slice $options);
    
$topicpick '('.implode ','$options_new ).')';
    if ( 
$options[3] == ) {
        
$sql "SELECT storyid, title, published, expired, counter, topic_title FROM
              "
.$xoopsDB->prefix("stories")." , ".$xoopsDB->prefix("topics")." t WHERE published < ".time()."
              AND published > 0 AND (expired = 0 OR expired > "
.time().") AND topicid = t.topic_id ORDER BY
              "
.$options[0]." DESC";
    }
    else {
        
$sql "SELECT storyid, title, published, expired, counter, topic_title FROM
                   "
.$xoopsDB->prefix("stories")." , ".$xoopsDB->prefix("topics")." t WHERE published < ".time()."
                   AND published > 0 AND (expired = 0 OR expired > "
.time().") AND topicid in
                   "
.$topicpick." AND topicid = t.topic_id ORDER BY ".$options[0]." DESC";
    }    
$result $xoopsDB->query($sql,$options[1],0);
    while ( 
$myrow $xoopsDB->fetchArray($result) ) {
        
$news = array();
    
$topic_title $myts->makeTboxData4Show($myrow["topic_title"]);
        
$title $topic_title " :: " $myts->makeTboxData4Show($myrow["title"]);
    if (
strlen($title) > $options[2]) {
        
$title xoops_substr($title,0,$options[2]+3);
    }

        
$news['title'] = $title;
        
$news['id'] = $myrow['storyid'];
        if ( 
$options[0] == "published" ) {
            
$news['hits'] = formatTimestamp($myrow['published'],"s");
            
$news['date'] = formatTimestamp($myrow['published'],"s");
        } elseif ( 
$options[0] == "counter" ) {
            
$news['hits'] = $myrow['counter'];
            
$news['date'] = $myrow['counter'];
        }
        
$block['stories'][] = $news;
    }
    return 
$block;
}


Hope that helps, I'm not very good at explaining how to make code changes - I'm better at just doing it

Rowd

10
dionesku
Re: Recent News titles to include topic?
  • 2005/1/3 20:57

  • dionesku

  • Just popping in

  • Posts: 3

  • Since: 2004/12/23


Try this:

Modify the file modules/news/blocks/news_top.php
this way:

insert ", topicid" between "counter" end "FROM" in this line:
$sql = "SELECT storyid, title, published, expired, counter FROM like this
$sql = "SELECT storyid, title, published, expired, counter, topicid FROM

and after these lines:


$news['title'] = $title;
$news['id'] = $myrow['storyid'];


insert the following code:


$topic_id = $myrow['topicid'];
$query = "SELECT topic_title FROM ".$xoopsDB->prefix("topics")." WHERE topic_id='$topic_id'";
$res = $xoopsDB->query($query,$options[1],0);
$res = mysql_fetch_array ($res);
$news['topic_title']=$res['topic_title'];
$news['topic_id']=$myrow['topicid'];


Then, goto templates management system, "news" category and replace the code for "news_block_new" with this code:


<ul>
<{foreach item=news from=$block.stories}>
<li><a href="<{$xoops_url}>/modules/news/index.php?storytopic=<{$news.topic_id}>"><{$news.topic_title}></a> - <a href="<{$xoops_url}>/modules/news/article.php?storyid=<{$news.id}>"><{$news.title}></a> (<{$news.date}>)</li>
<{/foreach}>
</ul>



That should do it.
Be well

Login

Who's Online

297 user(s) are online (182 user(s) are browsing Support Forums)


Members: 0


Guests: 297


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