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

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 06:23:30 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,106
  • Total Topics: 21,213
  • Online today: 358
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 254
  • Total: 255
  • davo88

A few questions

Started by [chrisB], January 03, 2023, 09:05:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

@rjen

Add a LIMIT is 10 to the query
Running Latest TP on SMF2.1 at: www.fjr-club.nl

[chrisB]

Quote from: @rjen on January 22, 2023, 07:13:27 PM
Add a LIMIT is 10 to the query

echo ' <div style="float:left;padding-right: 5px;"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></div><strong>Articles</strong></br>' ;
echo ' <hr>' ;

// Configuration
// Specify your categories, comma separated if more than one category.
$categories = array(5,2);
$limit = 2;

// End Config

global $scripturl, $smcFunc;

$request = $smcFunc['db_query']('', '
     SELECT shortname, id, subject, parse
     FROM {db_prefix}tp_articles
     WHERE category IN ({array_int:cats})
          AND approved = {int:approved}
     ORDER BY parse ASC',
     array('cats' => $categories,
          'approved' => 1,
     )
);
echo '
<ul style="list-style-type:disc; margin: 0pt; padding: 0pt 15px;">
';
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!empty($row['shortname']))
{
     echo '<li><a href="', $scripturl, '?page=', $row['shortname'], '">', $row['subject'], '</a></li>';
}
else
{
     echo '<li><a href="', $scripturl, '?page=', $row['id'], '">', $row['subject'], '</a></li>';
}
}
echo '</ul>';
$smcFunc['db_free_result']($request);


I've tried this, but I'm doing something wrong.

@rjen

You declared a variable, but you are not using it in the query...

add here


     ORDER BY parse ASC
     LIMIT 10',





Running Latest TP on SMF2.1 at: www.fjr-club.nl

[chrisB]

Ah, thanks.

I've tried adding the LIMIT 10', - the block seems to break.
$request = $smcFunc['db_query']('', '
     SELECT shortname, id, subject, parse
     FROM {db_prefix}tp_articles
     WHERE category IN ({array_int:cats})
          AND approved = {int:approved}
     ORDER BY parse ASC',
     LIMIT 10',
     array('cats' => $categories,
          'approved' => 1,
     )




Also, would ORDER BY parse DESC', make the newest articles show first?

@rjen

No, parse is the sort field

If you want the newest check for the date field.. check the tp_article tables for the correct field name
Running Latest TP on SMF2.1 at: www.fjr-club.nl

[chrisB]

Guest blocks are visible to admins right?

Can the core code be altered, so that this behaviour is changed so that guest viewable blocks are not shown to admins?

@rjen

There is a setting : admin can see all blocks... deactivate it and admins will only see blocks they haver permissions for
Running Latest TP on SMF2.1 at: www.fjr-club.nl

[chrisB]


[chrisB]

Weird, I can no longer see blocks which I have set admins to be able to see. Only blocks that are viewable are ones in the front panel location.

@rjen

Hmm , I recall it used to work. But tbh it has been ages since I last tried it. I think admins should keep a eye on all blocks.

Otherwise they may easily forget outdated information that is not presented to them
Running Latest TP on SMF2.1 at: www.fjr-club.nl