[Add-on] Display posts anywhere 1.2.0 RC5

Stand-alone scripts designed for a specific function, but not neccessarily part of normal forum browsing.
Forum rules
Image Please feel free to download any Scripts here, support for each Script is located it's own thread.

To post your own Script, please first read the MOD / Script Guidelines

Re: [Add-on] Display posts anywhere

Postby Aratgel » 19 Jan 2007, 16:22

thx a lot, I try it tonight( I live in Québec) a unficial nation in Canada!
Aratgel    
Translator
Translator
 
Posts: 31
Joined: 14 Jan 2007, 19:43
Location: Montréal Québec
Favorite Team: Canadiens
Gender: Male




phpBB Academy at StarTrekGuide
Support STG
Using PayPal Donate

Re: [Add-on] Display posts anywhere

Postby EXreaction » 19 Jan 2007, 21:01

If you want to have an extra section to display the latest topics(the first post in the last X number of topics) you can check this out:

Spoiler:
Code: Select all
function phpbb_fetch_posts($forum_sql, $number_of_posts, $text_length, $time, $type)
{
    global
$db, $user, $phpbb_root_path, $phpEx, $auth;
    
    
$from_forum = ($forum_sql != '') ? 't.forum_id IN (' . $forum_sql . ') AND' : '';
    
$post_time = ($time == 0) ? '' : 't.topic_time > ' . (time() - $time * 86400) . ' AND';

    if (
$type == 'announcments')
    {
        
$topic_type = '( t.topic_type = 2 OR t.topic_type = 3 ) AND';
    }
    else if (
$type == 'news_all')
    {
        
$topic_type = '';
    }
    else
    {
        
$topic_type = 't.topic_type = 0 AND';
    }

    
$sql = 'SELECT
            t.forum_id,
            t.topic_id,
            t.topic_time,
            t.topic_title,
            p.post_text,
            u.username,
            t.topic_replies,
            p.bbcode_uid,
            t.forum_id,
            t.topic_poster,
            p.post_id,
            p.enable_smilies,
            p.enable_bbcode,
            p.enable_magic_url,
            p.bbcode_bitfield,
            p.bbcode_uid,
            t.topic_attachment,
            t.poll_title
        FROM
            '
. TOPICS_TABLE . ' AS t,
            '
. USERS_TABLE . ' AS u,
            '
. POSTS_TABLE . ' AS p
        WHERE
            '
. $topic_type . '
            '
. $from_forum . '
            '
. $post_time . '
            t.topic_poster = u.user_id AND
            t.topic_first_post_id = p.post_id AND
            t.topic_first_post_id = p.post_id AND
            t.topic_status <> 2 AND
            t.topic_approved = 1
        ORDER BY
            t.topic_time DESC'
;

    if(!(
$result = $db->sql_query($sql)))
    {
        die(
'Could not query topic information');
    }

    
$posts = array();
    
$i = 0;
    while ( (
$row = $db->sql_fetchrow($result)) && ( ($i < $number_of_posts) || ($number_of_posts == '0') ) )
    {
        if ( (
$auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0') )
        {
            
$posts[$i]['post_text'] = censor_text($row['post_text']);
            
$posts[$i]['topic_id'] = $row['topic_id'];
            
$posts[$i]['forum_id'] = $row['forum_id'];
            
$posts[$i]['topic_replies'] = $row['topic_replies'];
            
$posts[$i]['topic_time'] = $user->format_date($row['topic_time']);
            
$posts[$i]['topic_title'] = $row['topic_title'];
            
$posts[$i]['username'] = $row['username'];
            
$posts[$i]['poll'] = ($row['poll_title'] != '') ? true : false;
            
$posts[$i]['attachment'] = ($row['topic_attachment']) ? true : false;

            
$len_check = $posts[$i]['post_text'];

            
$len_check = strip_post($len_check, $row['bbcode_uid'], $text_length);

            if ((
$text_length != 0) && (strlen($len_check) > $text_length))
            {
                
$posts[$i]['post_text'] = substr($len_check, 0, $text_length);
                
$posts[$i]['post_text'] .= '...';
                
$posts[$i]['striped'] = true;
            }

            include_once(
$phpbb_root_path . 'includes/bbcode.' . $phpEx);
            
$bbcode = new bbcode($row['bbcode_bitfield']);
            
$posts[$i]['post_text'] = censor_text($posts[$i]['post_text']);

            
$bbcode->bbcode_second_pass($posts[$i]['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield']);
            
$posts[$i]['post_text'] = smiley_text($posts[$i]['post_text']);
            
$posts[$i]['post_text'] = str_replace("\n", '<br />', $posts[$i]['post_text']);
            
$i++;
        }
    }

    return
$posts;
}


It is the function I made for phpBBsp(it needs some code removal for what you would use, but its pretty much done for ya). Smile
My phpBB3 Mods: Advertisement Management | Anti-Spam ACP | Auto Database Backup | Enable HTML | Advanced Subscriptions | Custom Profile Groups | From Author PM List | FAQ Manager | Forum Anniversary List | One Click Ban | Forum Sponsors | Smilies Categories | Drag 'n Drop Forum List | Soft Delete

Interested in becoming a Jr MOD Validator and helping out validation of mods @phpBB.com? Apply here
User avatar
EXreaction    
Supporter
Supporter
 
Posts: 1316
Joined: 03 Jun 2006, 09:10
Location: Plymouth, WI
Gender: Male

Re: [Add-on] Display posts anywhere

Postby Handyman » 19 Jan 2007, 21:12

I just found a default phpBB3 function that will be able to cut down on my code on this one.
Please contact me if you have any news to submit to SCOFF News.
SCOFFing at the candidates while you sleep.
My Mods || My Mod Queue
Image
User avatar
Handyman    
Rear Fleet Admiral
Rear Fleet Admiral
 
Posts: 7454
Joined: 08 May 2006, 04:45
Location: Where no man has gone before!
Favorite Team: Seattle Seahawks
Gender: Male

Re: [Add-on] Display posts anywhere

Postby EXreaction » 19 Jan 2007, 22:50

Whats it called and where? Grin
My phpBB3 Mods: Advertisement Management | Anti-Spam ACP | Auto Database Backup | Enable HTML | Advanced Subscriptions | Custom Profile Groups | From Author PM List | FAQ Manager | Forum Anniversary List | One Click Ban | Forum Sponsors | Smilies Categories | Drag 'n Drop Forum List | Soft Delete

Interested in becoming a Jr MOD Validator and helping out validation of mods @phpBB.com? Apply here
User avatar
EXreaction    
Supporter
Supporter
 
Posts: 1316
Joined: 03 Jun 2006, 09:10
Location: Plymouth, WI
Gender: Male

Re: [Add-on] Display posts anywhere

Postby Aratgel » 21 Jan 2007, 21:06

hi I have some trouble whit the new function get_last_posts

I get the felowing error: Parse error: syntax error, unexpected '}' in /home/julie/public_html/Forum/cache/tpl_subSilver_post_anywhere.html.php on line 10


at line 8 to 11 the code is :

Code: Select all
<tr>
    <td>subjet: <?php echo $this->_tpldata['posts'][$this->_posts_i]['POST_SUBJECT']; ?>
<?php
}} ?></td>
  </tr>



my exact template code is:


Code: Select all
<table width="200" border="1">
  <
tr>
    <
td>{POST_ICON}</td>
  </
tr>
  <
tr>
    <
td>{POST_SUBJECT}</td>
  </
tr>
  <
tr>
    <
td>sujet: {posts.POST_SUBJECT}
<!--
END posts --></td>
  </
tr>
  <
tr>
    <
td>{POST_SUBJECT4}</td>
  </
tr>
  <
tr>
    <
td>{POST_SUBJECT5}</td>
  </
tr>
</
table>



(is't final, it is just a test)
Last edited by EXreaction on 21 Jan 2007, 21:29, edited 1 time in total.
Reason: Put code in code BBcodes
Aratgel    
Translator
Translator
 
Posts: 31
Joined: 14 Jan 2007, 19:43
Location: Montréal Québec
Favorite Team: Canadiens
Gender: Male

Re: [Add-on] Display posts anywhere

Postby EXreaction » 21 Jan 2007, 21:31

I don't exactly see what your trying to do, but try removing one of the } on line 10...
My phpBB3 Mods: Advertisement Management | Anti-Spam ACP | Auto Database Backup | Enable HTML | Advanced Subscriptions | Custom Profile Groups | From Author PM List | FAQ Manager | Forum Anniversary List | One Click Ban | Forum Sponsors | Smilies Categories | Drag 'n Drop Forum List | Soft Delete

Interested in becoming a Jr MOD Validator and helping out validation of mods @phpBB.com? Apply here
User avatar
EXreaction    
Supporter
Supporter
 
Posts: 1316
Joined: 03 Jun 2006, 09:10
Location: Plymouth, WI
Gender: Male

Re: [Add-on] Display posts anywhere

Postby Handyman » 22 Jan 2007, 03:23

EXreaction wrote:Whats it called and where? Grin

Code: Select all
<?php $rowset = $db->sql_fetchrowset();

That makes $rowset an array with all the details from the query... so it can be used anywhere in the page with a foreach Smile

Thinking about it now, I'm not sure if it will cut down on my code or not, but It will come in handy in the future.
Please contact me if you have any news to submit to SCOFF News.
SCOFFing at the candidates while you sleep.
My Mods || My Mod Queue
Image
User avatar
Handyman    
Rear Fleet Admiral
Rear Fleet Admiral
 
Posts: 7454
Joined: 08 May 2006, 04:45
Location: Where no man has gone before!
Favorite Team: Seattle Seahawks
Gender: Male

Re: [Add-on] Display posts anywhere

Postby Handyman » 22 Jan 2007, 03:25

<table width="200" border="1">
<tr>
<td>{POST_ICON}</td>
</tr>
<tr>
<td>{POST_SUBJECT}</td>
</tr>
<tr>
<td>sujet: {posts.POST_SUBJECT}
<!-- END posts -->

This is the reason why it's giving you errors.
Sorry I didn't put an example in the install file... but to make this work, you have to have a <!-- BEGIN posts -->
so here is an example:

Code: Select all
<!-- BEGIN posts -->
Subject: {posts.POST_SUBJECT}
Post: [posts.POST_TEXT}
<!-- END posts -->
Please contact me if you have any news to submit to SCOFF News.
SCOFFing at the candidates while you sleep.
My Mods || My Mod Queue
Image
User avatar
Handyman    
Rear Fleet Admiral
Rear Fleet Admiral
 
Posts: 7454
Joined: 08 May 2006, 04:45
Location: Where no man has gone before!
Favorite Team: Seattle Seahawks
Gender: Male

Re: [Add-on] Display posts anywhere

Postby Aratgel » 23 Jan 2007, 20:49

thx a lot now it work !!!
Aratgel    
Translator
Translator
 
Posts: 31
Joined: 14 Jan 2007, 19:43
Location: Montréal Québec
Favorite Team: Canadiens
Gender: Male

Re: [Add-on] Display posts anywhere

Postby Handyman » 23 Jan 2007, 21:22

Sure!!!

I need to know what everybody wants this to be able to do... I'm going to add more features to it.

Here is what I have currently (not for download yet)
  • Username
  • Username Link
  • Avatar
  • Poster Rank
  • Rank Image

If you want me to add anything else, post and let me know and I'll add it.
I'll be updating this sometime before next week.
Please contact me if you have any news to submit to SCOFF News.
SCOFFing at the candidates while you sleep.
My Mods || My Mod Queue
Image
User avatar
Handyman    
Rear Fleet Admiral
Rear Fleet Admiral
 
Posts: 7454
Joined: 08 May 2006, 04:45
Location: Where no man has gone before!
Favorite Team: Seattle Seahawks
Gender: Male

PreviousNext

Return to Scripts

Who is online

Users browsing this forum: No registered users and 4 guests