Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

January 29, 2023, 06:07:34 PM

Login with username, password and session length
Members
  • Total Members: 3856
  • Latest: Bixby
Stats
  • Total Posts: 193887
  • Total Topics: 21127
  • Online today: 49
  • Online ever: 3540
  • (September 02, 2022, 06:38:54 PM)
Users Online
Users: 0
Guests: 36
Total: 36

Author Topic: A few questions  (Read 709 times)

0 Members and 1 Guest are viewing this topic.

Offline @rjen

  • Support Team
  • *
  • Posts: 3450
    • FJR-club Nederland
Re: A few questions
« Reply #20 on: January 22, 2023, 12:13:27 PM »
Add a LIMIT is 10 to the query
Running Latest TP on SMF2.1 at: www.fjr-club.nl

Offline [chrisB]

  • Jr. Member
  • **
  • Posts: 56
Re: A few questions
« Reply #21 on: January 22, 2023, 12:31:03 PM »
Add a LIMIT is 10 to the query

Code: [Select]
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.

Offline @rjen

  • Support Team
  • *
  • Posts: 3450
    • FJR-club Nederland
Re: A few questions
« Reply #22 on: January 22, 2023, 12:52:00 PM »
You declared a variable, but you are not using it in the query...

add here

Code: [Select]
     ORDER BY parse ASC
     LIMIT 10',




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

Offline [chrisB]

  • Jr. Member
  • **
  • Posts: 56
Re: A few questions
« Reply #23 on: January 22, 2023, 01:12:11 PM »
Ah, thanks.

I've tried adding the LIMIT 10', - the block seems to break.
Code: [Select]
$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?

Offline @rjen

  • Support Team
  • *
  • Posts: 3450
    • FJR-club Nederland
Re: A few questions
« Reply #24 on: January 22, 2023, 01:26:20 PM »
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

Offline [chrisB]

  • Jr. Member
  • **
  • Posts: 56
Re: A few questions
« Reply #25 on: January 27, 2023, 02:24:25 PM »
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?

Offline @rjen

  • Support Team
  • *
  • Posts: 3450
    • FJR-club Nederland
Re: A few questions
« Reply #26 on: January 27, 2023, 02:26:03 PM »
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

Offline [chrisB]

  • Jr. Member
  • **
  • Posts: 56
Re: A few questions
« Reply #27 on: January 27, 2023, 02:30:17 PM »
Thanks again, rjen.

Offline [chrisB]

  • Jr. Member
  • **
  • Posts: 56
Re: A few questions
« Reply #28 on: January 27, 2023, 02:33:47 PM »
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.

Offline @rjen

  • Support Team
  • *
  • Posts: 3450
    • FJR-club Nederland
Re: A few questions
« Reply #29 on: January 27, 2023, 02:39:14 PM »
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