The Articles Topic

All updates to the site will be posted here.

Moderator: CricketMX Forum Moderators

Five reasons to watch Chuck on NBC

Postby Articles Bot » Sat Jan 08, 2011 4:41 pm

Until mid 2010 I had never seen Chuck, but thanks to the heated (passionate?) discussion about Chuck at TVByTheNumbers.com due to its bubble status on NBC I was intrigued enough to trial the show. As it turns out, it is a very good show and I'm thankful it ha...


Read more
View all articles at http://www.cricketmx.com/articles/
I'm only a forum bot!
Articles Bot
Forum Bot
Forum Bot
 
Posts: 94
Joined: Thu Jan 10, 2008 8:05 am

Re: Working example of displaying latest posts on external p

Postby planetmelb » Tue Jan 11, 2011 5:00 am

Articles Bot wrote:
This article is a follow-on from the blog post I made at phpBB.com not too long ago. I recommend reading that post first before reading this, as all of the information you need might be in that po...


Read more


Hello

Firstly thanks for this script.

Initally I tried following the information at the top link without success but the updated one here was much better given my lack of programming ability.

However, I would really like to have my posts appear as per the first example i.e. "EXAMPLE 1: Display latest topics from specified forums". When I try and play around with the code I crash it, but when I use your home.php for Example 4 it works fine. Do you have a similar download for Example 1?

Thanks in advance
planetmelb
Greenhorn
Greenhorn
 
Posts: 1
Joined: Tue Jan 11, 2011 4:32 am

Re: The Articles Topic

Postby battye » Wed Jan 12, 2011 5:15 pm

Hello planetmelb, welcome to CMX :)

I've had a look on my computer, I believe this is the example file for example one... give it a try and let me know if it works :)

Don't forget to change the file external_body.html to reflect the new templating variables (search for // LOOK UNDER THIS LINE FOR TEMPLATE VARS in the code below for the list of template variables). If you have any questions feel free to ask me :)

Code: Select all
<?php
/*
* home.php
* Description: example file for displaying latest posts and topics
* by battye (for phpBB.com MOD Team)
* September 29, 2009
*/

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');

/* create_where_clauses( int[] gen_id, String type )
* This function outputs an SQL WHERE statement for use when grabbing
* posts and topics */

function create_where_clauses($gen_id, $type)
{
global $db, $auth;

    $size_gen_id = sizeof($gen_id);

        switch($type)
        {
            case 'forum':
                $type = 'forum_id';
                break;
            case 'topic':
                $type = 'topic_id';
                break;
            default:
                trigger_error('No type defined');
        }

    // Set $out_where to nothing, this will be used of the gen_id
    // size is empty, in other words "grab from anywhere" with
    // no restrictions
    $out_where = '';

    if( $size_gen_id > 0 )
    {
    // Get a list of all forums the user has permissions to read
    $auth_f_read = array_keys($auth->acl_getf('f_read', true));

        if( $type == 'topic_id' )
        {
            $sql     = 'SELECT topic_id FROM ' . TOPICS_TABLE . '
                        WHERE ' .  $db->sql_in_set('topic_id', $gen_id) . '
                        AND ' .  $db->sql_in_set('forum_id', $auth_f_read);

            $result     = $db->sql_query($sql);

                while( $row = $db->sql_fetchrow($result) )
                {
                        // Create an array with all acceptable topic ids
                        $topic_id_list[] = $row['topic_id'];
                }

            unset($gen_id);

            $gen_id = $topic_id_list;
            $size_gen_id = sizeof($gen_id);
        }

    $j = 0;   

        for( $i = 0; $i < $size_gen_id; $i++ )
        {
        $id_check = (int) $gen_id[$i];

            // If the type is topic, all checks have been made and the query can start to be built
            if( $type == 'topic_id' )
            {
                $out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' ';
            }

            // If the type is forum, do the check to make sure the user has read permissions
            else if( $type == 'forum_id' && $auth->acl_get('f_read', $id_check) )
            {
                $out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' ';
            }   

        $j++;
        }
    }

    if( $out_where == '' && $size_gen_id > 0 )
    {
        trigger_error('A list of topics/forums has not been created');
    }

    return $out_where;
}

$search_limit = 5;

    $forum_id = array(2, 5);
    $forum_id_where = create_where_clauses($forum_id, 'forum');

    $topic_id = array(20, 50);
    $topic_id_where = create_where_clauses($topic_id, 'topic');

$topics = 'SELECT * FROM ' . TOPICS_TABLE . '
            ' . $forum_id_where . '
              AND topic_status <> ' . ITEM_MOVED . '
              AND topic_approved = 1
            ORDER BY topic_id DESC';

   $topics_result = $db->sql_query_limit($topics, $search_limit);

      while( $topics_row = $db->sql_fetchrow($topics_result) )
      {
         $topic_title       = $topics_row['topic_title'];
         $topic_author       = get_username_string('full', $topics_row['topic_poster'], $topics_row['topic_first_poster_name'], $topics_row['topic_first_poster_colour']);
         $topic_date       = $user->format_date($topics_row['topic_time']);
         $topic_last_post    = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=" . $topics_row['topic_last_post_id'] . "#" . $topics_row['topic_last_post_id']);
         $topic_last_author    = get_username_string('full', $topics_row['topic_last_poster_id'], $topics_row['topic_last_poster_name'], $topics_row['topic_last_poster_colour']);
         $topic_link       = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=" . $topics_row['topic_id']);

         // LOOK UNDER THIS LINE FOR TEMPLATE VARS
         $template->assign_block_vars('announcements', array(
         'TOPIC_TITLE'       => censor_text($topic_title),
         'TOPIC_AUTHOR'       => $topic_author,
         'TOPIC_DATE'       => $topic_date,
         'TOPIC_LAST_POST'    => $topic_last_post,
         'TOPIC_LAST_AUTHOR' => $topic_last_author,
         'TOPIC_LINK'       => $topic_link,
         ));
      }

page_header('External page');

    $template->set_filenames(array(
        'body' => 'external_body.html'
    ));

    page_footer();
?>
CricketMX.com.. home of bat's, rat's and other farmyard animals...
My articles: view all articles by battye

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
battye
Site Admin
Site Admin
 
Posts: 14270
Joined: Sun Jan 11, 2004 8:26 am
Location: Victoria Falls, Zimbabwe

Save time in Linux with bash_aliases

Postby Articles Bot » Sat Jan 22, 2011 7:12 am

Recently I installed LAMP under Ubuntu and the kind folk in the #ubuntu IRC channel gave me some fantastic - not to mention time saving! - advice.

If you have any long commands you can easily shorten them through the use of aliases.

For instance, with LAMP the command to start Apache was the long ...


Read more
View all articles at http://www.cricketmx.com/articles/
I'm only a forum bot!
Articles Bot
Forum Bot
Forum Bot
 
Posts: 94
Joined: Thu Jan 10, 2008 8:05 am

Re: Save time in Linux with bash_aliases

Postby Rat » Sat Jan 22, 2011 9:52 pm

Recently I installed LAMP under Ubuntu and the kind folk in the #ubuntu IRC channel gave me some fantastic - not to mention time saving! - advice.

If you have any long commands you can easily shorten them through the use of aliases.

For instance, with LAMP the command to start Apache was the long ...


etc etc.... I didn't realise you were tinkering with linux battye. I also didn't realise you were playing with web server software. Can I feel a new home for CMX coming on?
User avatar
Rat
Drain Brain
Drain Brain
 
Posts: 4398
Joined: Mon Jun 14, 2004 9:38 am
Location: in the dark

Re: Save time in Linux with bash_aliases

Postby battye » Sun Jan 23, 2011 1:53 pm

Rat wrote:etc etc.... I didn't realise you were tinkering with linux battye. I also didn't realise you were playing with web server software. Can I feel a new home for CMX coming on?


No :)

I wanted to have a local web server set up so I could test PHP scripts and the like, primarily something I am helping to work on with the MOD Team at phpBB.com.
CricketMX.com.. home of bat's, rat's and other farmyard animals...
My articles: view all articles by battye

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
battye
Site Admin
Site Admin
 
Posts: 14270
Joined: Sun Jan 11, 2004 8:26 am
Location: Victoria Falls, Zimbabwe

How the formation of The Young Veins benefits Panic At The Disco

Postby Articles Bot » Thu Mar 17, 2011 4:42 pm

It was incredibly hard to create a title to summarise this article. I like The Young Veins a lot and I didn't want to imply that the depatures of Ryan Ross and Jon Walker automatically made Panic! At The Disco, hot on the heels of their new album "Vices & Virtues" a better band.

The ...


Read more
View all articles at http://www.cricketmx.com/articles/
I'm only a forum bot!
Articles Bot
Forum Bot
Forum Bot
 
Posts: 94
Joined: Thu Jan 10, 2008 8:05 am

Re: How the formation of The Young Veins benefits Panic At T

Postby moongirl » Fri Apr 01, 2011 4:55 pm

Articles Bot wrote:
It was incredibly hard to create a title to summarise this article. I like The Young Veins a lot and I didn't want to imply that the depatures of Ryan Ross and Jon Walker automatically made Panic! At The Disco, hot on the heels of their new album "Vices & Virtues" a better band.

The ...


Read more




Track listing for "Take A Vacation!" by The Young Veins
1. Change
2. Take A Vacation!
3. Cape Town
4. Maybe I Will, Maybe I Won't
5. Young Veins (Die Tonight)
6. Everyone But You
7. The Other Girl
8. Dangerous Blues
9. Defiance
10. Lie To The Truth
11. Heart Of Mine
12. Security
13. When You Walk In The Room

Good article Battye.
I sampled the tracks and have added: Take A Vacation! to my iTunes library.
The track listings are slightly different on iTunes to those listed above.
Image
That's not the man in the moon...that's me ;)
Click To Play Online-Scrabble - Click To Play Quizzes
~~~In the year 2040...I'll have 100,000 posts!!~~~
User avatar
moongirl
Moderator
Moderator
 
Posts: 18846
Joined: Mon Jan 12, 2004 8:07 am

How to get the most out of iPhone Tracker on Leopard and how does it impact our privacy

Postby Articles Bot » Sat Apr 23, 2011 7:43 am

Recently people have been talking about how iPhones are tracking movements of users and how the Mac app iPhone Tracker is displaying this data visually. Personally I don't see it as a huge problem because the phone companies already know this information, and many Apps require location data anyway. ...


Read more
View all articles at http://www.cricketmx.com/articles/
I'm only a forum bot!
Articles Bot
Forum Bot
Forum Bot
 
Posts: 94
Joined: Thu Jan 10, 2008 8:05 am

Community on NBC continues to please with a few paintballs

Postby Articles Bot » Fri May 13, 2011 2:57 pm

Abed said on the season finale of Community that "sequels are almost always disappointing" - but that rule doesn't apply to paintball.

Spoiler alert for below.

Community has done what few other sitcoms can do and use what is widely regarded as their best episode (S01E23, Modern W...


Read more
View all articles at http://www.cricketmx.com/articles/
I'm only a forum bot!
Articles Bot
Forum Bot
Forum Bot
 
Posts: 94
Joined: Thu Jan 10, 2008 8:05 am

Re: Working example of displaying latest posts on external p

Postby neljan » Sun Jul 17, 2011 12:39 am

Articles Bot wrote:
This article is a follow-on from the blog post I made at phpBB.com not too long ago. I recommend reading that post first before reading this, as all of the information you need might be in that po...


Read more

Hello :)

Firstly, thank you very much for taking the time to write this very useful guide.

A question if I may trouble you:

I would like to have one block retrieving x amount of latest posts from a specific forum (*done*) and several other blocks (9 in fact) retrieving x amount of latest posts from other specified forums. What is the best way to achieve this please?

The code I'm using for the 1st block is this:

1st segment

Code: Select all
/* create_where_clauses( int[] gen_id, String type )
* This function outputs an SQL WHERE statement for use when grabbing
* posts and topics */

function create_where_clauses($gen_id, $type)
{
global $db, $auth;

$size_gen_id = sizeof($gen_id);

switch($type)
{
case 'forum':
$type = 'forum_id';
break;
case 'topic':
$type = 'topic_id';
break;
default:
trigger_error('No type defined');
}

// Set $out_where to nothing, this will be used of the gen_id
// size is empty, in other words "grab from anywhere" with
// no restrictions
$out_where = '';

if ($size_gen_id > 0)
{
// Get a list of all forums the user has permissions to read
$auth_f_read = array_keys($auth->acl_getf('f_read', true));

if ($type == 'topic_id')
{
$sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $gen_id) . '
AND ' . $db->sql_in_set('forum_id', $auth_f_read);

$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))
{
// Create an array with all acceptable topic ids
$topic_id_list[] = $row['topic_id'];
}

unset($gen_id);

$gen_id = $topic_id_list;
$size_gen_id = sizeof($gen_id);
}

$j = 0;

for ($i = 0; $i < $size_gen_id; $i++)
{
$id_check = (int) $gen_id[$i]; // If the type is topic, all checks have been made and the query can start to be built if( $type == 'topic_id' ) { $out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' '; } // If the type is forum, do the check to make sure the user has read permissions else if( $type == 'forum_id' && $auth->acl_get('f_read', $id_check) )
{
$out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' ';
}

$j++;
}
}

if ($out_where == '' && $size_gen_id > 0)
{
trigger_error('A list of topics/forums has not been created');
}

return $out_where;
}


2nd segment:

Code: Select all
$search_limit = 3;

$forum_id = array(337);
$forum_id_where = create_where_clauses($forum_id, 'forum');

$topic_id = array(0, 0);
$topic_id_where = create_where_clauses($topic_id, 'topic');


3rd segment:

Code: Select all
$topics = 'SELECT * FROM ' . TOPICS_TABLE . '
' . $forum_id_where . '
AND topic_status <> ' . ITEM_MOVED . '
AND topic_approved = 1
ORDER BY topic_id DESC';

$topics_result = $db->sql_query_limit($topics, $search_limit);

while ($topics_row = $db->sql_fetchrow($topics_result))
{
$topic_title = $topics_row['topic_title'];
$topic_author = get_username_string('full', $topics_row['topic_poster'], $topics_row['topic_first_poster_name'], $topics_row['topic_first_poster_colour']);
$topic_date = $user->format_date($topics_row['topic_time']);
$topic_last_post = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=" . $topics_row['topic_last_post_id'] . "#" . $topics_row['topic_last_post_id']);
$topic_last_author = get_username_string('full', $topics_row['topic_last_poster_id'], $topics_row['topic_last_poster_name'], $topics_row['topic_last_poster_colour']);
$topic_link = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=" . $topics_row['topic_id']);

$template->assign_block_vars('announcements', array(
'TOPIC_TITLE' => censor_text($topic_title),
'TOPIC_AUTHOR' => $topic_author,
'TOPIC_DATE' => $topic_date,
'TOPIC_LAST_POST' => $topic_last_post,
'TOPIC_LAST_AUTHOR' => $topic_last_author,
'TOPIC_LINK' => $topic_link,
));
}


Would I need to duplicate all segments (renaming all the strings) or just the last 2 segments? or can I somehow use this same code in a seperate file yet have the results appear on the same template with different assign_block_vars definitions?

Sorry to bother, I'm learning...

Thanks for your time.
neljan
Greenhorn
Greenhorn
 
Posts: 5
Joined: Tue Jun 28, 2011 4:18 pm

Re: The Articles Topic

Postby neljan » Sun Jul 17, 2011 1:11 am

I think I'm getting somewhere actually, so don't waste your time just yet :P
neljan
Greenhorn
Greenhorn
 
Posts: 5
Joined: Tue Jun 28, 2011 4:18 pm

Re: The Articles Topic

Postby neljan » Sun Jul 17, 2011 2:21 am

I managed to figure it out. If another noob finds this, then this is how I did it:

forum/main.php:

Code: Select all
<?php

define('IN_PHPBB', true);

$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);

include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'a_new_folder_to_contain_your_files/functions.' . $phpEx);


// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');

page_header('Page_Title');

include($phpbb_root_path . 'a_new_folder_to_contain_your_files/news_block_1.' . $phpEx);
include($phpbb_root_path . 'a_new_folder_to_contain_your_files/news_block_2.' . $phpEx);

$template->set_filenames(array(
   'body' => 'main.html',
));

page_footer();

?>


forum/a_new_folder_to_contain_your_files/functions.php:

Code: Select all
<?php

define('IN_PHPBB', true);

/* create_where_clauses( int[] gen_id, String type )
* This function outputs an SQL WHERE statement for use when grabbing
* posts and topics */

function create_where_clauses($gen_id, $type)
{
global $db, $auth;

$size_gen_id = sizeof($gen_id);

switch($type)
{
case 'forum':
$type = 'forum_id';
break;
case 'topic':
$type = 'topic_id';
break;
default:
trigger_error('No type defined');
}

// Set $out_where to nothing, this will be used of the gen_id
// size is empty, in other words "grab from anywhere" with
// no restrictions
$out_where = '';

if ($size_gen_id > 0)
{
// Get a list of all forums the user has permissions to read
$auth_f_read = array_keys($auth->acl_getf('f_read', true));

if ($type == 'topic_id')
{
$sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $gen_id) . '
AND ' . $db->sql_in_set('forum_id', $auth_f_read);

$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))
{
// Create an array with all acceptable topic ids
$topic_id_list[] = $row['topic_id'];
}

unset($gen_id);

$gen_id = $topic_id_list;
$size_gen_id = sizeof($gen_id);
}

$j = 0;

for ($i = 0; $i < $size_gen_id; $i++)
{
$id_check = (int) $gen_id[$i]; // If the type is topic, all checks have been made and the query can start to be built if( $type == 'topic_id' ) { $out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' '; } // If the type is forum, do the check to make sure the user has read permissions else if( $type == 'forum_id' && $auth->acl_get('f_read', $id_check) )
{
$out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' ';
}

$j++;
}
}

if ($out_where == '' && $size_gen_id > 0)
{
trigger_error('A list of topics/forums has not been created');
}

return $out_where;
}

?>


forum/a_new_folder_to_contain_your_files/news_block_1.php:

Code: Select all
<?php

define('IN_PHPBB', true);

$search_limit = 5;

$forum_id = array(123);
$forum_id_where = create_where_clauses($forum_id, 'forum');

$topic_id = array(123);
$topic_id_where = create_where_clauses($topic_id, 'topic');

$topics = 'SELECT * FROM ' . TOPICS_TABLE . '
' . $forum_id_where . '
AND topic_status <> ' . ITEM_MOVED . '
AND topic_approved = 1
ORDER BY topic_id DESC';

$topics_result = $db->sql_query_limit($topics, $search_limit);

while ($topics_row = $db->sql_fetchrow($topics_result))
{
$topic_title = $topics_row['topic_title'];
$topic_author = get_username_string('full', $topics_row['topic_poster'], $topics_row['topic_first_poster_name'], $topics_row['topic_first_poster_colour']);
$topic_date = $user->format_date($topics_row['topic_time']);
$topic_last_post = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=" . $topics_row['topic_last_post_id'] . "#" . $topics_row['topic_last_post_id']);
$topic_last_author = get_username_string('full', $topics_row['topic_last_poster_id'], $topics_row['topic_last_poster_name'], $topics_row['topic_last_poster_colour']);
$topic_link = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=" . $topics_row['topic_id']);

$template->assign_block_vars('news_block_1', array(
'TOPIC_TITLE' => censor_text($topic_title),
'TOPIC_AUTHOR' => $topic_author,
'TOPIC_DATE' => $topic_date,
'TOPIC_LAST_POST' => $topic_last_post,
'TOPIC_LAST_AUTHOR' => $topic_last_author,
'TOPIC_LINK' => $topic_link,
));
}

?>


forum/a_new_folder_to_contain_your_files/news_block_2.php:

Code: Select all
<?php

define('IN_PHPBB', true);

$search_limit = 5;

$forum_id = array(456);
$forum_id_where = create_where_clauses($forum_id, 'forum');

$topic_id = array(456);
$topic_id_where = create_where_clauses($topic_id, 'topic');

$topics = 'SELECT * FROM ' . TOPICS_TABLE . '
' . $forum_id_where . '
AND topic_status <> ' . ITEM_MOVED . '
AND topic_approved = 1
ORDER BY topic_id DESC';

$topics_result = $db->sql_query_limit($topics, $search_limit);

while ($topics_row = $db->sql_fetchrow($topics_result))
{
$topic_title = $topics_row['topic_title'];
$topic_author = get_username_string('full', $topics_row['topic_poster'], $topics_row['topic_first_poster_name'], $topics_row['topic_first_poster_colour']);
$topic_date = $user->format_date($topics_row['topic_time']);
$topic_last_post = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=" . $topics_row['topic_last_post_id'] . "#" . $topics_row['topic_last_post_id']);
$topic_last_author = get_username_string('full', $topics_row['topic_last_poster_id'], $topics_row['topic_last_poster_name'], $topics_row['topic_last_poster_colour']);
$topic_link = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=" . $topics_row['topic_id']);

$template->assign_block_vars('news_block_2', array(
'TOPIC_TITLE' => censor_text($topic_title),
'TOPIC_AUTHOR' => $topic_author,
'TOPIC_DATE' => $topic_date,
'TOPIC_LAST_POST' => $topic_last_post,
'TOPIC_LAST_AUTHOR' => $topic_last_author,
'TOPIC_LINK' => $topic_link,
));
}

?>


styles/template/main.html

Code: Select all
<!-- INCLUDE overall_header.html -->
   
<div>
<!-- BEGIN news_block_1 -->
   <ul class="topiclist">
      <li class="row">
         <a href="{news_block_1.TOPIC_LINK}" class="topictitle">{news_block_1.TOPIC_TITLE}</a><br />
      </li>
   </ul>
<!-- END news_block_1 -->
</div>

<div>
<!-- BEGIN news_block_2 -->
   <ul class="topiclist">
      <li class="row">
         <a href="{news_block_2.TOPIC_LINK}" class="topictitle">{news_block_2.TOPIC_TITLE}</a><br />
      </li>
   </ul>
<!-- END news_block_2 -->
</div>


Sorry for spamming your forum.
neljan
Greenhorn
Greenhorn
 
Posts: 5
Joined: Tue Jun 28, 2011 4:18 pm

Re: The Articles Topic

Postby battye » Mon Jul 18, 2011 3:54 pm

No worries neljan. Off the top of my head, a more efficient way would have been to put all of the forums you wanted to extract topics from into this array:

Code: Select all
$forum_id = array(337, 338, 339, ..., 350); // for example


And then inside the while loop...

Code: Select all
while ($topics_row = $db->sql_fetchrow($topics_result))
{
... // etc


Have some method of distinguishing between the forums. For instance, have an if statement to see if $topics_row['forum_id'] == 337 and if it does put the result into some array. And so on for each forum you want to distinguish results by. You could use a switch statement if you had many forums (9 in total I think you mentioned).

Then later on you could worry about the templating variables for each individual array.

If you have a working result though, I can understand you not wanting to change anything and you may ignore this post :)
If you are keen to keep learning about PHP (and phpBB) I recommend trying to reduce redundancy (ie. news_block_2.php and news_block_1.php are almost identical) and achieving the same result with as little code as possible :)
CricketMX.com.. home of bat's, rat's and other farmyard animals...
My articles: view all articles by battye

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
battye
Site Admin
Site Admin
 
Posts: 14270
Joined: Sun Jan 11, 2004 8:26 am
Location: Victoria Falls, Zimbabwe

Re: Working example of displaying latest posts on external p

Postby markoff » Mon Jul 18, 2011 8:22 pm

Articles Bot wrote:
This article is a follow-on from the blog post I made at phpBB.com not too long ago. I recommend reading that post first before reading this, as all of the information you need might be in that po...


Read more



Hello, I was wondering if you had any tips for adding a "View older entries" at the bottom of the blog posts, from the main page. So I could display 10 blog posts, and then click the link to view another 10 older posts.

Thanks. Using your blog code now and it helped me out a lot
markoff
Greenhorn
Greenhorn
 
Posts: 2
Joined: Mon Jul 18, 2011 8:20 pm

PreviousNext

Return to Updates

Who is online

Users browsing this forum: No registered users and 1 guest

cron