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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 219
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 112
  • Total: 112

got a question about how to use this code - please help

Started by knat, July 25, 2007, 03:37:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

knat

in my sources/messageindex.php i have this code that allows me to sort the topics in some of my boards by subject.. it works fine.. but now i need it for 10-20 boards and my question is:

Do i copy the code for every board like shown in this example or is there an easy way to add multiple boards to this code ??

example with two boards being sorted by subject

// View all the topics, or just a few?
$maxindex = isset($_REQUEST['all']) && !empty($modSettings['enableAllMessages']) ? $board_info['num_topics'] : $modSettings['defaultMaxTopics'];
if (!isset($_REQUEST['sort']) && $board == 131)
$_REQUEST['sort'] = 'subject';
if (!isset($_REQUEST['sort']) && $board == 184)
$_REQUEST['sort'] = 'subject';


So do i have to make more of this


if (!isset($_REQUEST['sort']) && $board == XXX)
$_REQUEST['sort'] = 'subject';


where XXX is the board ID, or is there another way..  ::)

I know this is not actualy TP related but i need an answer this week.. and i know this is easy to answer for some of you here on TP

Thanks to anyone who can tell me

jacortina

I think this would work:

Change
// View all the topics, or just a few?
$maxindex = isset($_REQUEST['all']) && !empty($modSettings['enableAllMessages']) ? $board_info['num_topics'] : $modSettings['defaultMaxTopics'];
if (!isset($_REQUEST['sort']) && $board == 131)
$_REQUEST['sort'] = 'subject';
if (!isset($_REQUEST['sort']) && $board == 184)
$_REQUEST['sort'] = 'subject';


To:
// View all the topics, or just a few?
$maxindex = isset($_REQUEST['all']) && !empty($modSettings['enableAllMessages']) ? $board_info['num_topics'] : $modSettings['defaultMaxTopics'];
$sort_boards = array(131, 184, 9999, 9999, 9999, 9999, 9999, 9999, 9999);
if (!isset($_REQUEST['sort']) && in_array($board, $sort_boards))
$_REQUEST['sort'] = 'subject';


Just have to have the right list of bord numbers going into the array $sort_boards. And instead of indivdually checking values, the in_array() function checks if, well, the first argument is in the array which is the second argument.

knat

Thanks alot.. i will try it and let you know the result  :) Thanks alot  :D

knat

Just did it and it works like a charm.. just what i needed..  :D

Thanks for the quick support and sorry for posting non TP related issues  ::)

This website is proudly hosted on Crocweb Cloud Website Hosting.