TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,970
  • Latest: bynw
Stats
  • Total Posts: 196,063
  • Total Topics: 21,338
  • Online today: 171
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 185
  • Total: 185

Posts as articles

Started by Greybrow, September 06, 2006, 11:04:50 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Greybrow

On my old site I wrote a script to use first post of specified board(s) as articles.

It has it's limitations since almost no html, and no php could be used, but it's easy enough for users to write them (also no moderation by admin is needed, as board moderators can fix it), and comments to article were actually comments to this first post.

Could TP include such option?
(with block listing first defined number of topics, and display options similiar to articles)

iwyen

Do you mean the frontpage on your current site?

SMF uses one of its SSI functions to call for the first posts of the topics from a board. TP has an option for you to use this function on your frontpage. You can also customize the output by creating a PHP article with the modified codes and set it as the frontpage.

Alternatively, the next version of TP has commenting system and if you enable WYSIWYG editor, your users can use HTML. Of course you must give your users permission to submit article and your moderator to manage submissions.

I'll suggest you download SMF 1.1 RC2 (TP is not RC3 ready yet) + TP v0.8.6 and try them offline.

Greybrow

I already did it all online. http://liero.robal.org/ (polish only)
Links on the left lead to article with "art" variable which is number of topic to display first post, and the article gets the first post, and displays it as a article.

It's just a feature suggestion, to not to have to do it manualy.

iwyen

Firstly, I must apologise I didn't look at which board this is posted  :buck2:

I know nothing about Polish but I can compare alphabets  ;D

To get the first post of a topic in a board to look like the article you have, you need to create a PHP article (per board you want to show) and add:

ssi_boardNews($board = null, $limit = null, $start = null, $length = null, $output_method = 'echo')

Ref: http://www.simplemachines.org/community/index.php?topic=13016.0

$board is the board id, set $limit to 1 since you only want to show from one topic, $length for the length of words to show. But this will only show the first post from the latest commented topic and not the latest created topic (i.e. sorted according to how the board list of topics is sorted). Since you know coding, you can look at the ssi_boardNews function in the SSI.php file and you might be able to vary it for you use. You can also edit it to update the menu links to the article automatically. Read the Advance SSI FAQ (link above) for the steps to modify.

Greybrow

#4
As I wrote, I already did it, and it already works :)
But I use only one php article, which gets topic to display, from first forum posts block links.

The article:
$artykul=((int) $_GET['art']);
global $db_prefix;

if ($artykul > 0)
{
// Find the posts.
$request = db_query("
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE
m.ID_MSG = t.ID_FIRST_MSG
AND t.ID_TOPIC = '$artykul'", __FILE__, __LINE__);

$row = mysql_fetch_assoc($request);
$row['body'] = doUBBC($row['body'], $row['smileysEnabled']);

censorText($row['subject']);
censorText($row['body']);

echo '<table border="0" width="100%" align="center" class="border" cellspacing="0" cellpadding="0">';
echo '<tr>';
align="middle" alt="' . $row['icon'] . '" />'<b>', $row['subject'], '</b><span class="small"></td></tr>';
echo '<td class="titlebg"><b>', $row['subject'], '</b><span class="small"></td></tr>';
'<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>' : $row['posterName'], '</span></td>';
echo '<tr><td>Author:', !empty($row['ID_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>' : $row['posterName'], '</span></td>';
echo '</tr>';
echo '<tr>';
echo '<td  class="windowbg">', $row['body'], '</td>';
echo '</tr>';
echo '<tr>';
echo '<td align="right"><a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['numReplies'] . ' ' . ($row['numReplies'] == 1 ? $txt['smf_news_1'] : $txt['smf_news_2']) . '</a> | <a href="' . $scripturl . '?action=post;topic=' . $row['ID_TOPIC'] . '.' . $row['numReplies'] . '">' . $txt['smf_news_3'] . '</a></td>';
echo '</tr>';
echo '</table>';
}
else
{
echo "No such article";
}


and the block:
echo '<b>Put some title here</b><br>';
// change 24 to your desired board number,
$desired_board = 24;

// change 6 to your desired last topics count
$desired_articles_count = 6;

// number of created article (mine was 13 :) )
$tp_article_number = 13;
$ostatniea = ssi_boardNews($desired_board,$desired_articles_count, null, null, 'ostatniea');

echo '<div style="width: 100%; overflow: hidden;">';
echo '<div style="white-space: nowrap;" class="smalltext">';

foreach ($ostatniea as $news)
{
echo '<a href="/';
echo 'forum/index.php?page='.$tp_article_number.'&art='.$news['id'];
echo '" title="';
echo $news['subject'];
echo '">';
echo '<img src="' . $settings['images_url'] . '/new_some.gif" border="0" />';
echo strlen(un_htmlspecialchars($news['subject'])) > 25 ? htmlspecialchars(substr(un_htmlspecialchars($news['subject']), 0, 22) . '...') : $news['subject'];
echo '</a>';
echo '<br />';
}

echo "</div></div>";


To have listings from more boards, copy/paste it to the same block and change desired_board

If someone could improve that, it would be great.
fixed: Especially I can't get the db prefix from any variable, and have to put it manually :(

jacortina

"global $db_prefix;" at the top doesn't work?

Greybrow

#6
I think I tried. I'll check again.

Works! Thank you! :)

bloc

Basically its grabbing a topic, use first post as main article and the replies as "comments" to it?

That could be something..save the trouble of converting a topic to article and re-converting it when the topic change.

Its not exactly a real article though..you would not edit it through the article system, rather thruogh normal forum functions which would be better at it. It would only be a container for the topic. Like a specialized article.

I like this idea. If more specialized functions could be put together as options for it, this could work well as an equal to html article and php article.

Greybrow

It is.
I use it for a year or sth, and it works fine. And it is useful :)

It would be great (for me) if it would be inside tp, with settings as from which boards to show in block, and how many of them, and others as with usual block.

I'm really lazy, and changes through the code are exhausting ;)

And btw. there is a strange bug (?) in ie, which makes left block appear hidden as long as the longest topic name, and it makes center block move right. Already fixed above adding

echo strlen(un_htmlspecialchars($news['subject'])) > 25 ? htmlspecialchars(substr(un_htmlspecialchars($news['subject']), 0, 22) . '...') : $news['subject'];

This website is proudly hosted on Crocweb Cloud Website Hosting.