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,973
  • Latest: NonStop
Stats
  • Total Posts: 196,231
  • Total Topics: 21,353
  • Online today: 606
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 277
  • Total: 277

alphabetical topics index

Started by deniz, December 28, 2006, 07:01:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

deniz

i need alphabetical index for all topics like user list.

is it possible ?

JPDeni

Sure. Anything that's in the database can be pulled out of the database.

So you want pages of topic titles -- 30 per page? And you probably want to be able to search by the first letter, too.

It all can be done, but it's not the sort of thing that someone can just whip out in a few minutes.

deniz

#2
i know you can do that :)

i can make just this:

SELECT * FROM 'smf_messages'  ORDER BY 'subject' ASC

:P


JPDeni

That will give you a list of messages, not a list of topics, unless you only have one message per topic.

The SQL that you would need is


SELECT *
FROM {$db_prefix}messages, {$db_prefix}topics
WHERE ID_FIRST_MSG = ID_MSG
ORDER BY subject


That will give you an alphabetical list of the subject of the first message in all of your topics. If that's all you want, then that's fine. I was under the impression you wanted a little bit more, though, because you said, "like user list." That would mean that there would be a limited number per page and that you could access the titles that start with a certain letter of the alphabet. And I thought you might be interested in some nice formatting.

But if all you needed was the SQL, this is it. :)

deniz

#4
of course i need as my first message.
like userlist format.

my code in second message just my newbie stupid code    :idiot2:



looks like this: http://wikkawiki.org/PageIndex

may be this wikka code will be helpfull:

<?php
/**
* Display an alphabetical list of pages of the wiki.
*
* This action checks user read privileges and displays an index of read-accessible pages.
*
* @package    Actions
* @name    pageindex
*
* @author    {@link http://wikkawiki.org/GiorgosKontopoulos GiorgosKontopoulos} (added ACL check, first code cleanup)
* @author    {@link http://wikkawiki.org/DarTar DarTar} (adding doc header, minor code and layout refinements, i18n)
*
* @since    1.1.6.2
*
* @output   a list of pages accessible to the current user
* @documentation  {@link http://wikkawiki.org/ColorActionInfo}
*/

// i18n strings
define('PAGE_HEADING',"Page Index");
define('INDEX_CAPTION',"This is an alphabetical list of pages you can read on this server.");
define('ALL_PAGES',"All");
define('PAGE_OWNER'," . . . . Owner: %s");
define('OWNED_PAGES_CAPTION',"Items marked with a * indicate pages that you own.");
define('ERROR_NO_PAGES_FOUND', "No pages found.");

if (
$pages = $this->LoadAllPages())
{
// filter by letter
if (isset($_REQUEST['letter'])) $requested_letter = $_REQUEST['letter']; else $requested_letter = '';
if (!$requested_letter && isset($letter)) $requested_letter = strtoupper($letter);

// get things started
$cached_username = $this->GetUserName();
$user_owns_pages = false;
$link = $this->href('', '', 'letter=');
$alpha_bar = '<a href="'.$link.'">'.ALL_PAGES.'</a>&nbsp;'."\n";
$index_header = INDEX_CAPTION;
$index_output = '';
$current_character = '';
$character_changed = false;

// get page list
foreach ($pages as $page)
{
// check user read privileges
if (!$this->HasAccess('read', $page['tag'])) continue;

$page_owner = $page['owner'];
// $this->CachePage($page);

$firstChar = strtoupper($page['tag'][0]);
if (!preg_match('/[A-Za-z]/', $firstChar)) $firstChar = '#'; //TODO: Internationalization
if ($firstChar != $current_character) {
$alpha_bar .= '<a href="'.$link.$firstChar.'">'.$firstChar.'</a>&nbsp;'."\n";
$current_character = $firstChar;
$character_changed = true;
}
if ($requested_letter == '' || $firstChar == $requested_letter) {
if ($character_changed) {
$index_output .= "<br />\n<strong>$firstChar</strong><br />\n";
$character_changed = false;
}
$index_output .= $this->Link($page['tag']);

if ($cached_username == $page_owner) {                      
$index_output .= '*';
$user_owns_pages = true;
} elseif ($page_owner != '(Public)' && $page_owner != '') {
$index_output .= sprintf(PAGE_OWNER, $page_owner);
}
    $index_output .= "<br />\n";    
}
}
// generate page
$index_header .= ($user_owns_pages) ? '---'.OWNED_PAGES_CAPTION : '';
echo $this->Format('===='.PAGE_HEADING.'==== --- <<'.$index_header.'<< ::c:: ---');
echo "\n<strong>".$alpha_bar."</strong><br />\n".$index_output;
} else {
echo ERROR_NO_PAGES_FOUND;
}
?>

JPDeni

Okay. :)

What columns do you want? Naturally, the first column will be the name of the topic, with a link to the topic. What else? You can have when it was first started, who started it (with a link to that person's profile and/or email), the icon that is associated with it, how many replies there have been, how many views there have been, whether or not it's locked or sticky or both, when the last post was added to it and by whom. You could even have the first x number of characters of the first post, if you wanted to.

Of course, there's only so much room on a page. :D

You also might want to think about limiting the topics to only those that are available for guests to read or for all members to read. Or maybe you want to only have specific boards.

deniz

#6
page can be like this:


Alphabetical  Topic Index Page

A B C D ... Z

topic names with links | starters | start date | message count | view
--------------------------------------------------------------------------
A is first letter           | me        | 28.12.06   | 1                    | 5
...
..
.
and page should not be limited with 30 items etc.

   

JPDeni

Okay. This should work for you.



global $db_prefix, $user_info, $scripturl, $modSettings;

$page = $_GET['page'];
if (isset($_GET['letter']))
  $search = ' AND subject LIKE "'.$_GET['letter'].'%"';
else
  $search = '';

$request = db_query("
        SELECT t.ID_TOPIC, posterTime, ID_MEMBER, subject, posterName, b.ID_BOARD, numReplies, numViews, memberGroups
        FROM {$db_prefix}messages AS mes, {$db_prefix}topics AS t, {$db_prefix}boards AS b
        WHERE ID_FIRST_MSG = ID_MSG
        AND b.ID_BOARD = t.ID_BOARD
        AND $user_info[query_see_board] $search
        ORDER BY subject", __FILE__, __LINE__);

$lastLetter = '';
echo '<table>';
echo '<tr><td colspan="5">';
echo '<a href="' , $scripturl , '?page=' , $page , '">All</a>   ';
for ($i = 65; $i < 91; ++$i)
  echo '<a href="' , $scripturl , '?page=' , $page , ';letter=' , chr($i) , '"><b>',  chr($i) , '</b></a> ';
echo '</td></tr>';

while ($row = mysql_fetch_assoc($request))
{
        $row['subject'] = html_entity_decode($row['subject'],ENT_QUOTES);
        if ($lastLetter <>  strtoupper($row['subject']{0}))
        {
          $lastLetter = strtoupper($row['subject']{0});
        echo '<tr><td colspan="5"> </td></tr>';
        echo '<tr><td colspan="5"><b>' , $lastLetter , '</b></td></tr>';
        echo '
        <tr><td>Topic title</td>
                <td>Started by  </td>
                <td>Start date </td>
                <td align="center"> Replies </td>
                <td align="center"> Views </td></tr>
        <tr><td colspan="5"><hr /></td></tr>';
        }
        $startdate = $row['posterTime'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
        echo '<tr>
        <td> <a href="' , $scripturl , '?topic=' , $row['ID_TOPIC'] , '.0">' , $row['subject'] , ' </td>
        <td> <a href="' , $scripturl , '?action=profile;u=' , $row['ID_MEMBER'] , '">', $row['posterName'] , '</a> </td>
        <td> ', date('d.m.y',$startdate) , ' </td>
        <td align="center"> ' , $row['numReplies'] , ' </td>
        <td align="center"> ' , $row['numViews'] , ' </td></tr>';
}
echo '</table>';

mysql_free_result($request);



You may want to play around with the formatting a bit to make it look exactly like you want it to.

One little quirk... If a topic title starts with punctuation or a number, the topic will be sorted with others that start with that same punctuation or number. However, there is no punctuation or numbers in the list. I can add them easily enough. In my forum, the punctuation marks that are used to start topic titles are single-quotes, double-quotes, open parentheses and open brackets -- ' " ( and [. This seems to be the same as your Wikka list. If you want it different, let me know.

deniz

#8
thank you very much.

but i want to start page with letter "A" and "all" option should be at the end of list.

like this:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ALL

Topic title    Started by    Start date    Replies    Views

A is first letter ....



and page can be limitited items like 50. becuse some forums has a lot of topics.

deniz

#9
Quote from: JPDeni on December 28, 2006, 11:44:22 PM
You may want to play around with the formatting a bit to make it look exactly like you want it to.

One little quirk... If a topic title starts with punctuation or a number, the topic will be sorted with others that start with that same punctuation or number. However, there is no punctuation or numbers in the list. I can add them easily enough. In my forum, the punctuation marks that are used to start topic titles are single-quotes, double-quotes, open parentheses and open brackets -- ' " ( and [. This seems to be the same as your Wikka list. If you want it different, let me know.

yes please.. and we need to add other language spesific characters. for example: "Ã...ž", "İ", "ÃÅ"", "ö".

but i can use together "Ã...ž" in "S" tab, "İ" in "I" tab, "ÃÅ"" in "U" tab and "ö" in "O" tab.

and maybe we can add "others" tab.

2. bord name column  will be helpfull.

This website is proudly hosted on Crocweb Cloud Website Hosting.