I have some personal customization of PhpBB and I have a custom view on topics with their posts in one special forum, where there are topics with calendar mono events. It is inspired
here. And I would like to insert the event date range into topic description the same way it looks in the standard topic view.
Is it possible to insert it by some easy way? I can take the columns with event data from topic table and manually convert it to string and insert in the page, but it will not be so sophistic and driven by extension configuration. Here is my external page:
Code: Select all
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
/**
*/
/**
* @ignore
*/
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');
/* 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 = 100;
$forum_id = array(4); // Fixed ID of forum in DB
$forum_id_where = create_where_clauses($forum_id, 'forum');
$posts_ary = array(
'SELECT' => 'p.*, t.*, u.username, u.user_colour',
'FROM' => array(
POSTS_TABLE => 'p',
),
'LEFT_JOIN' => array(
array(
'FROM' => array(USERS_TABLE => 'u'),
'ON' => 'u.user_id = p.poster_id'
),
array(
'FROM' => array(TOPICS_TABLE => 't'),
'ON' => 'p.topic_id = t.topic_id'
),
),
'WHERE' => str_replace( array('WHERE ', 'forum_id'), array('', 't.forum_id'), $forum_id_where) . '
AND t.topic_status <> ' . ITEM_MOVED . '
AND t.topic_visibility = 1',
'ORDER_BY' => 't.topic_time ASC, p.post_time ASC',
);
$posts = $db->sql_build_query('SELECT', $posts_ary);
$posts_result = $db->sql_query_limit($posts, $search_limit);
$old_topic_id = '';
while ($posts_row = $db->sql_fetchrow($posts_result)) {
$topic_id = $posts_row['topic_id'];
$topic_title = $posts_row['topic_title'];
$post_author = get_username_string('full', $posts_row['poster_id'], $posts_row['username'], $posts_row['user_colour']);
$post_date = $user->format_date($posts_row['post_time']);
$post_link = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $posts_row['forum_id'] . '&t=' . $posts_row['topic_id'] . '&p=' . $posts_row['post_id']) . '#p' . $posts_row['post_id'];
$post_text = nl2br($posts_row['post_text']);
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
$bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']);
$post_text = smiley_text($post_text);
$template->assign_block_vars('announcements', array(
'TOPIC_TITLE' => censor_text($topic_title),
'TOPIC_SWITCH' => $topic_id != $old_topic_id,
'POST_AUTHOR' => $post_author,
'POST_LINK' => $post_link,
'POST_TEXT' => censor_text($post_text),
));
$old_topic_id = $topic_id;
}
$template->assign_vars(array(
'U_FORUM_RESERVATIONS' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . 4))
);
page_header('Reservations overview');
$template->set_filenamesp(array(
'body' => 'reservations.html'
));
page_footer();
and associated html template is following:
Code: Select all
<!-- INCLUDE overall_header.html -->
<h1 style="text-align: center; display: block; margin-left: auto; margin-right: auto; margin-bottom: 15px;">
<a href="{U_FORUM_RESERVATIONS}">>>> Reservations overview - edit <<<</a>
</h1>
<!-- BEGIN announcements -->
<!-- IF announcements.TOPIC_SWITCH -->
<!-- IF not announcements.S_FIRST_ROW -->
</ul>
</div>
</div>
<!-- ENDIF -->
<div class="forumbg">
<div class="inner">
<ul class="topiclist">
<li class="header">
<dl class="row-item">
<dt>
<div class="list-inner">
<a href="{announcements.POST_LINK}">{announcements.TOPIC_TITLE} : {announcements.POST_TEXT}</a>
</div>
</dt>
</dl>
</li>
</ul>
<ul class="topiclist topics">
<!-- ELSE -->
<li class="row<!-- IF announcements.S_ROW_COUNT is even --> bg1<!-- ELSE --> bg2<!-- ENDIF -->">
<dl class="row-item">
<dt style="min-height: 0px">
<div class="list-inner" style="padding-left: 5px;">
<b>{announcements.POST_AUTHOR}:</b> {announcements.POST_TEXT}
</div>
</dt>
</dl>
</li>
<!-- ENDIF -->
<!-- IF announcements.S_LAST_ROW -->
</ul>
</div>
</div>
<!-- ENDIF -->
<!-- END announcements -->
<!-- INCLUDE overall_footer.html -->