Topic: Latest Topics on Frontpage

I think I've asked this question before but I am not 100% sure. Anyway, what I would like to know is if I can show the latest topics on my frontpage like this site

http://www.powelly.com/index.php

I would like to call it from the main.tpl file. If someone can point me in the right direction to a mod, that would be great.

Bingiman

Re: Latest Topics on Frontpage

extern.php

Re: Latest Topics on Frontpage

I knew I was going to get that exact response. The problem is I do not know how to include this as a seperate file for example <pun_newtopics> in main.tpl which in turn calls a file in the user folder. Can you tell me how I can do it? The extern file really doesn't' tell me how this could be done.

Thanks

Re: Latest Topics on Frontpage

include/user/recenttopics.inc.php

<div class="block">
  <h2><span>Last 10 Topics</span></h2>
  <div class="box">
    <div id="recenttopics" class="inbox">
<?php
echo "<ul>";
include("http://yourwebsite/extern.php?action=new&show=10");
echo "</ul>";
?>
    </div>
  </div>
</div>

and then in the .tpl

<pun_include "recenttopics.inc.php">

Re: Latest Topics on Frontpage

Thank you so much kierownik. I was dying to get this. It works great.

Bingiman

Re: Latest Topics on Frontpage

your welcome smile

Re: Latest Topics on Frontpage

I added it to my production site and I am getting the following errors?

Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/ztunavmk/public_html/shednotes/include/user/recenttopics.inc.php on line 7

Re: Latest Topics on Frontpage

A good discussion of similar issue and solution is here:

http://www.aprelium.com/forum/viewtopic.php?t=10796 on the web site of the people who make the very nice Aprelium web server.

The issue is either that your php.ini config doesn't have 'allow_url_fopen = on' set.

Or (more likely) that you are trying to call the included URL via a http:/etc etc call, like

include("http://yourwebsite/extern.php?action=new&show=10");

Try it as just a file path link instead - eg include("/extern.php?action=new&show=10");

9 (edited by bingiman 2007-06-26 23:15)

Re: Latest Topics on Frontpage

Actually it is set to on. I checked the PHP info and it definitely on. I also tried everything else and nothing works.

Re: Latest Topics on Frontpage

Try using cURL.

Re: Latest Topics on Frontpage

I;'ve asked my host to turn on: allow_url_include

Re: Latest Topics on Frontpage

What is cURL?

13

Re: Latest Topics on Frontpage

bing, here is the latesttopics script that i use...
put this in the include/user folder and pun_include it in the main.tpl..

Q

 <div class="block">
     <h2 class="block2"><span>Top News Topics</span></h2>
        <div class="box">       
                   <?
$result = $db->query('SELECT subject, id FROM '.$db_prefix.'topics ORDER BY last_post DESC LIMIT 4') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

while($cur_topic = $db->fetch_assoc($result))
{
    
?>
    
        
<li>»<a href="viewtopic.php?id=<?php echo $cur_topic['id']; ?>"><?php echo $cur_topic['subject']; ?></a> </li>


 
<?
}
?>

              
                  
    </div>
</div>
My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: Latest Topics on Frontpage

cURL is a library for loading external pages.
http://be2.php.net/manual/en/ref.curl.php

Re: Latest Topics on Frontpage

Well, can someone please help modify Quaker's code to truncate the subject lines?

Thakns

16

Re: Latest Topics on Frontpage

bingiman wrote:

Well, can someone please help modify Quaker's code to truncate the subject lines?

Thakns

Hell no. big_smile big_smile (I remember what happened last time I helped with truncation). big_smile big_smile

Re: Latest Topics on Frontpage

<div class="block">
     <h2 class="block2"><span>Top News Topics</span></h2>
        <div class="box">       
                   <?php
$trunc_len = 50; // Fill this in
$result = $db->query('SELECT subject, id FROM '.$db_prefix.'topics ORDER BY last_post DESC LIMIT 4') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

while($cur_topic = $db->fetch_assoc($result))
{
    
?>
<li>»<a href="viewtopic.php?id=<?php echo $cur_topic['id']; ?>"><?php echo substr($cur_topic['subject'], 0, $trunc_len); ?></a> </li>
<?php
}
?>
    </div>
</div>

18 (edited by bingiman 2007-07-02 11:57)

Re: Latest Topics on Frontpage

This works fine for me but when I am in my forums viewing a post the text at the top disappears. Here is an example:


* Index     *  » missing text    *  » missing text

The names should be displayed where it says missing text but it is not there. Once I remove the code it works normal. Any ideas?

Thanks
Bingiman

19

Re: Latest Topics on Frontpage

need to add a require lang file... sound like it...hehe..

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: Latest Topics on Frontpage

Well, I tried adding every language file possible and it still doesn't work right

Re: Latest Topics on Frontpage

I had to change any call for $cur_topic to $cur_topic2 and it now works.

22

Re: Latest Topics on Frontpage

u be the man... remember the cur_post issues ..hehe...

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: Latest Topics on Frontpage

I managed to use the code from this mod: http://www.punres.org/viewtopic.php?pid=18346#p18346 and I got this thing working perfectly now. Here is my code:

<?php

showRecent(10); // Set amount of posts to be displayed here

function showRecent($show=5) {
    global $lang_common, $db, $pun_config, $db_prefix;

    $order_by = 't.last_post';
    $forum_sql = '';

//$show = isset($_GET['show']) ? intval($_GET['show']) : 5;
        //if ($show < 1 || $show > 50) $show = 5;

$trunc_len = 15; // Set amount of text to be displayed in subject.

// Fetch $show topics
    $result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$forum_sql.' ORDER BY '.$order_by.' DESC LIMIT '.$show) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());


    echo '<div class="block"><h2><span>Recent 10 Posts</span></h2>';
    echo '<div class="box"><div class="inbox"><dl>';
            while ($cur_topic = $db->fetch_assoc($result)) {
        if ($pun_config['o_censoring'] == '1')
     $cur_topic['subject'] = censor_words($cur_topic['subject']);
    $subject_truncated = pun_htmlspecialchars($cur_topic['subject']);
 



    echo '<dd><a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.substr($cur_topic['subject'], 0, $trunc_len).'</a>...</dd>'."\n";
    }
    echo '</dl></div></div></div>';
    return;
}