Main Menu
collapse

Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

User Info

Welcome Guest.
Please log in.

Who's Online

  • Dot Guests: 1317
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]


NEED HELP? If you're looking for support with Simple Portal, look no further than the Support Board!

Block with links to topics of chosen board

Started by jelence, April 16, 2011, 06:00:40 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

jelence


Hello!
Is it possible to make custom php block (or to change board news or recent posts/topics) to look like list of links from chosen board?

for example, to look like:

Name of block

Link to topic 1
Link to topic 2
Link to topic 3

and so on?

Thanks!

AngelinaBelle

Yes. This is essentially creating an index of one board. This idea is very similar to the navigation block, which very much needs updating to SMF 2.0.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

jelence


Thanks.
I suppose that it should be something similar to code in this topic: http://simpleportal.net/index.php?topic=8653.0, only for smf2?

AngelinaBelle

Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

jelence


He is using  smf1 and it does not work for smf2.

I get this error message when I try his code:

QuoteFatal error: Call to undefined function db_query() in /home8/asekonom/public_html/Sources/PortalBlocks.php(3351) : eval()'d code on line 17

I don't know how to fix that  :'(.

[SiNaN]

You can use this in a Custom PHP block:

global $db_prefix, $scripturl;

$id_board = 1;

$request = db_query("
SELECT t.ID_TOPIC, m.subject
FROM {$db_prefix}topics AS t
INNER JOIN {$db_prefix}messages AS m ON (m.ID_MSG = t.ID_FIRST_MSG)
WHERE t.ID_BOARD = {$id_board}
ORDER BY m.subject", __FILE__, __LINE__);
$topics = array();
while ($row = mysql_fetch_assoc($request))
$topics[$row['ID_TOPIC']] = $row['subject'];
mysql_free_result($request);

echo '
<ul>';

if (empty($topics))
{
echo '
<li>There aren\'t any topics.</li>';
}
else
{
foreach ($topics as $id => $subject)
echo '
<li><a href="', $scripturl, '?topic=', $id, '.0">', $subject, '</a></li>';
}

echo '
</ul>';


Change $id_board as the id of the board you want to fetch topics from.
And slowly, you come to realize... It's all as it should be...

jelence


Hello [SiNaN], thanks for responding!

I tried code you gave me and I get this error :

QuoteFatal error: Call to undefined function db_query() in /home8/asekonom/public_html/Sources/PortalBlocks.php(3351) : eval()'d code on line 5

:(...

[SiNaN]

Sorry. For some weird reason I thought you were using SMF 1.1. Try this one:

global $smcFunc, $scripturl, $modSettings;

$id_board = 1;

$request = $smcFunc['db_query']('', '
SELECT t.id_topic, m.subject
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
WHERE t.id_board = {int:board}' . ($modSettings['postmod_active'] ? '
AND t.approved = {int:approved}
AND m.approved = {int:approved}' : '') . '
ORDER BY m.subject',
array(
'board' => $id_board,
'approved' => 1,
)
);
$topics = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$topics[$row['id_topic']] = $row['subject'];
$smcFunc['db_free_result']($request);

echo '
<ul>';

if (empty($topics))
{
echo '
<li>There aren\'t any topics.</li>';
}
else
{
foreach ($topics as $id => $subject)
echo '
<li><a href="', $scripturl, '?topic=', $id, '.0">', $subject, '</a></li>';
}

echo '
</ul>';
And slowly, you come to realize... It's all as it should be...

jelence

#8
This is working great  :thumbsup:!!
Thanks [SiNaN]    :)!

Perhaps this should be a part of standard SP installation?
As far as I can see, there is a lot of people trying to use Recent Posts/Topics for this purpose.
With possibility to put 10 or 20 last topics instead of all of them, it should do the job!





[SiNaN]

If you want to limit the topics:

Code (Find) Select
ORDER BY m.subject',

Code (Replace) Select
ORDER BY m.subject
LIMIT {int:limit}',


Code (Find) Select
'approved' => 1,

Code (Replace) Select
'approved' => 1,
'limit' => 10,


If you want to change the sort order to the newest first:

Code (Find) Select
ORDER BY m.subject

Code (Replace) Select
ORDER BY t.id_topic DESC
And slowly, you come to realize... It's all as it should be...

jelence

 
This solved a lot of my 'problems', thanks again  :applause:!

[SiNaN]

And slowly, you come to realize... It's all as it should be...

natasa

Hello!

I really like this modification  :thumbsup:.
And have a question: how to 'center' it ?
It is a bit moved on right side of menu, so when menu is on the left it does not look so good.
And, how can I put my own images instead of black bullets on the beginning of each item on the list?

I tried to do this on my own, but no luck.

natasa

OK, this can be done like this, for example:

global $scripturl;

$pages = sportal_get_pages(null, true);

echo '
<p>';

foreach ($pages as $page)
echo '
<p><img src="http://probe.serbianpress.com/Themes/default/images/sp/dot5.png"/>   <a href="', $scripturl, '?page=', $page['page_id'], '">', $page['title'], '</a></p>';

echo '
</p>';

natasa

For boards:

global $smcFunc, $scripturl, $modSettings;

$id_board = 1;

$request = $smcFunc['db_query']('', '
SELECT t.id_topic, m.subject
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
WHERE t.id_board = {int:board}' . ($modSettings['postmod_active'] ? '
AND t.approved = {int:approved}
AND m.approved = {int:approved}' : '') . '
ORDER BY m.subject',
array(
'board' => $id_board,
'approved' => 1,
)
);
$topics = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$topics[$row['id_topic']] = $row['subject'];
$smcFunc['db_free_result']($request);

echo '
<p style="list-style-type: none; padding-left:20px;">';

if (empty($topics))
{
echo '
<p>There aren\'t any topics.</p>';
}
else
{
foreach ($topics as $id => $subject)
echo '
<p><img src="http://probe.serbianpress.com/Themes/default/images/sp/dot6.png"/>   <a href="', $scripturl, '?topic=', $id, '.0">', $subject, '</a></p>';
}

echo '
</p>';

Tonymura

Hi
I have a similar question to ask as the one posted right here. Should i start a new topic?
And I looked into the eyes of our beloved Saint Pope John Paul the II for a sign of his blessing to my new mod and quietly he utters the silent word beneath his breath

[SiNaN]

And slowly, you come to realize... It's all as it should be...