News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Theme adjustment - Unread Posts list categories

Started by NoRad, August 31, 2004, 08:33:31 PM

Previous topic - Next topic

mytreo

Quote from: Radianation on January 05, 2005, 01:04:55 PM
Now I'm not showing any new posts whenever I hit the site. My users are having the same problem since the upgrade from rc2 to 1.0 ... Is it a theme incompatability issue or maybe the cookies?

That's bad news. I'm not sure, it's working okay for me but I took the chance to do a fresh install to 1.0 then made the mods to my theme again from scratch. Did you check the modifications you made are all still there, perhaps some files were overwritten? Does it all work ok using the Default theme?
Treo forum - Powered by SMF, of course
Treo news - powered by MovableType and integrated with SMF
Treo downloads - hacked from phpNuke and integrated with SMF
Treo knowledge base - powered by Wikka and integrated with SMF
Treo 650 | Treo 700w | Treo 700p

NoRad

I did a full install of 1.0 and re-applied my mods. THe only mod that didn't give me an option to reapply was the buddylist mod.

[Unknown]

Strange... it might be losing the session somewhere and restarting it.... but I'm not sure why that'd happen.

You still have the option to show "all" unread topics.

-[Unknown]

NoRad

It appears to be working now. Might have been that mod from the other night. I still notice that the boards are displayed out of order, though.

mytreo

Quote from: mytreo on January 05, 2005, 10:17:14 AM
3. Also an additional mod I'd like to make will be the ability to selectively mark a board or topic as read directly from the results page, this allows you to quickly filter all topics you're not interested in.

Update: I have now done this and I am very happy with the results. See screenshot below, if people are interested then I could possibly make this into mod?

Click for bigger image:


Chris
Treo forum - Powered by SMF, of course
Treo news - powered by MovableType and integrated with SMF
Treo downloads - hacked from phpNuke and integrated with SMF
Treo knowledge base - powered by Wikka and integrated with SMF
Treo 650 | Treo 700w | Treo 700p

NoRad

I'd love to see that as a mod. Would make this easier for updating.

NoRad

#26
Hey guys, I turned this into a mod but it's acting kind of strange. It looks like sources/recent.php was updated in 1.0.3 to already have this adjustment, so I made my modifications to recent.template.php like we discussed previously in this thread. The problem is, it spits out all of the unread posts under each forum category so that there end up being many duplicates.

Any ideas? Here's my code from the package manager:

(Run this package at your own risk, it's not 100% complete yet)



<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>Radianation:UnreadSort</id>
<version>1.0</version>
<file name="$themedir/Recent.template.php">
<operation>
<search position="replace"><![CDATA[
else
echo '
<td width="100%" colspan="7">', $context['showing_all_topics'] ? $txt[151] : $txt['unread_topics_visit_none'], '</td>';
echo '
</tr>';

foreach ($context['topics'] as $topic)
{
echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" /></td>
<td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $settings['images_url'] . '/post/' . $topic['first_post']['icon'] . '.gif" alt="" border="0" align="middle" /></td>
<td class="windowbg" valign="middle" width="48%">
' . $topic['first_post']['link'] . ' <a href="' . $scripturl . '?topic=' . $topic['id'] . '.from' . $topic['newtime'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a> <span class="smalltext">' . $topic['pages'] . '</span>
<div class="smalltext"><i>' . $txt['smf88'] . ' ' . $topic['board']['link'] . '</i></div></td>
<td class="windowbg2" valign="middle" width="14%">
' . $topic['first_post']['member']['link'] . '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
' . $topic['replies'] . '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
' . $topic['views'] . '</td>
<td class="windowbg2" valign="middle" width="22%">';
if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
echo '
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
echo '
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span></td>
</tr>';
}
]]></search>
<add><![CDATA[
else
echo '
<td width="100%" colspan="7">', $context['showing_all_topics'] ? $txt[151] : $txt['unread_topics_visit_none'], '</td>';
echo '
</tr>';

$boards = array();
foreach ($context['topics'] as $topic)
$boards[$topic['board']['id']] = $topic['board'];

foreach ($boards as $board)
{
echo '
<tr class="catbg">
<td colspan="7">', $board['link'], '</td>
</tr>';

foreach ($context['topics'] as $topic)
{
if ($topic['board']['id'] != $board['id'])

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" /></td>
<td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $settings['images_url'] . '/post/' . $topic['first_post']['icon'] . '.gif" alt="" border="0" align="middle" /></td>
<td class="windowbg" valign="middle" width="48%">
' . $topic['first_post']['link'] . ' <a href="' . $scripturl . '?topic=' . $topic['id'] . '.from' . $topic['newtime'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a> <span class="smalltext">' . $topic['pages'] . '</span>
</td>
<td class="windowbg2" valign="middle" width="14%">
' . $topic['first_post']['member']['link'] . '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
' . $topic['replies'] . '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
' . $topic['views'] . '</td>
<td class="windowbg2" valign="middle" width="27%">
<span class="smalltext">' . $topic['last_post']['time'] . '<br />' . $txt[525] . ' ' . $topic['last_post']['member']['link'] . '</span></td>
</tr>';
}
}
]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[
else
echo '
<td width="100%" colspan="7">' . $txt[151] . '</td>';
echo '
</tr>';

foreach ($context['topics'] as $topic)
{
echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" /></td>
<td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $settings['images_url'] . '/post/' . $topic['first_post']['icon'] . '.gif" alt="" border="0" align="middle" /></td>
<td class="windowbg" valign="middle" width="48%">
' . $topic['first_post']['link'] . ' <a href="' . $scripturl . '?topic=' . $topic['id'] . '.from' . $topic['newtime'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a> <span class="smalltext">' . $topic['pages'] . '</span>
<div class="smalltext"><i>' . $txt['smf88'] . ' ' . $topic['board']['link'] . '</i></div></td>
<td class="windowbg2" valign="middle" width="14%">
' . $topic['first_post']['member']['link'] . '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
' . $topic['replies'] . '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
' . $topic['views'] . '</td>
<td class="windowbg2" valign="middle" width="22%">';
if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
echo '
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
echo '
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span></td>
</tr>';
}
]]></search>
<add><![CDATA[
else
echo '
<td width="100%" colspan="7">' . $txt[151] . '</td>';
echo '
</tr>';

$boards = array();
foreach ($context['topics'] as $topic)
$boards[$topic['board']['id']] = $topic['board'];

foreach ($boards as $board)
{
echo '
<tr class="catbg">
<td colspan="7">', $board['link'], '</td>
</tr>';

foreach ($context['topics'] as $topic)
{
if ($topic['board']['id'] != $board['id'])

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" /></td>
<td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $settings['images_url'] . '/post/' . $topic['first_post']['icon'] . '.gif" alt="" border="0" align="middle" /></td>
<td class="windowbg" valign="middle" width="48%">
' . $topic['first_post']['link'] . ' <a href="' . $scripturl . '?topic=' . $topic['id'] . '.from' . $topic['newtime'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a> <span class="smalltext">' . $topic['pages'] . '</span>
</td>
<td class="windowbg2" valign="middle" width="14%">
' . $topic['first_post']['member']['link'] . '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
' . $topic['replies'] . '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
' . $topic['views'] . '</td>
<td class="windowbg2" valign="middle" width="27%">
<span class="smalltext">' . $topic['last_post']['time'] . '<br />' . $txt[525] . ' ' . $topic['last_post']['member']['link'] . '</span></td>
</tr>';
}
}
]]></add>
</operation>
</file>
</modification>

[Unknown]

What does the test_modification.php from the package SDK say?

-[Unknown]

NoRad

Test Results
The file you uploaded was parsed and the following results were returned.

   1. The file I:\louipimps\forum/Themes/default/Recent.template.php was opened for output.
   2. A search and replace operation in I:\louipimps\forum/Themes/default/Recent.template.php succeeded.
   3. A search and replace operation in I:\louipimps\forum/Themes/default/Recent.template.php succeeded.
   4. The file I:\louipimps\forum/Themes/default/Recent.template.php was saved.

The modification would have installed properly, had this not been a test.


It says there are no problems with my actual package. I think it's just that something has changed in the way the sort is handed or perhaps the array is built differently? I don't know...

NoRad

Yeah, the categories are all off in my code or something?

Check attached screenshot. Notice how some of the topics are duplicated? This happens for every "new" topic. They appear all under each category once instead of sorting only once into the proper category.

mytreo

Hey Radiation, good to see you are working on this.

I am still using this mod on my board (1.0.3) and I can send you my modified Sources and Template files if you like? In fact I modified it further so that the user can choose which view, either sorted by date/time (default) or sorted by category/board. I even made a new SMF button called 'change view'. You wanna get together and try making a proper mod out of this?

Best,
Chris
Treo forum - Powered by SMF, of course
Treo news - powered by MovableType and integrated with SMF
Treo downloads - hacked from phpNuke and integrated with SMF
Treo knowledge base - powered by Wikka and integrated with SMF
Treo 650 | Treo 700w | Treo 700p

NoRad

That would be great. Mine worked up until 1.0.3 and then something went awry. Send me what you have and I can try to make it into the mod.

mytreo

Ok no problem, I even went one better and put together the steps that need to be taken to modify the Sources/Recent.php and Sources/Subs-Boards.php files.

I also have this in a properly formatted text file in case the spacing doesn't come out well on here, ping me an IM with your email addy and I will send you that as well as the new Recent.template.php and the image :)


Advanced-Recent-View Mod for SMF.

This mod does two things, both of which are very nice.

Follow these instructions from a fresh copy of v1.0.3 files.

File: Sources/Recent.php

1a) Find the following:

// Find the 10 most recent messages they can *view*.

1b) Add AFTER:

$context['start'] = (int) $_REQUEST['start'];

2a) Find the following:

LIMIT 10", __FILE__, __LINE__);

2b) REPLACE with:

LIMIT $context[start], 11", __FILE__, __LINE__);

3a) Find the following:

if (empty($messages))
{
$context['posts'] = array();
return;
}

3b) Add BEFORE:

// Create prev/next links into the template.
if (isset($messages[10]))
{
unset($messages[10]);
$context['next'] = $context['start'] + 10;
}
if ($context['start'] > 0)
$context['prev'] = $context['start'] > 9 ? $context['start'] - 10 : 0;


4a) Find the following:

// Are we specifying any specific board?
if (!empty($board))
$query_this_board = 'b.ID_BOARD = ' . $board;

4b) Add BEFORE:

// Modification - How do we want to sort results?
if (isset($_GET['sort'])) {
$orderby = 'b.boardOrder, ml.ID_MSG DESC';
$context['board_sort'] = True;
} else {
$orderby = 'ml.ID_MSG DESC';
$context['board_sort'] = False;
}

5a) Find the following:

// Make sure the starting place makes sense and construct the page index.
if (empty($board))
$context['page_index'] = constructPageIndex($scripturl . '?action=' . $_REQUEST['action'] . ($context['showing_all_topics'] ? ';all' : ''), $_REQUEST['start'], $num_topics, $modSettings['defaultMaxTopics']);
else
$context['page_index'] = constructPageIndex($scripturl . '?action=' . $_REQUEST['action'] . ($context['showing_all_topics'] ? ';all' : '') . ';board=' . $board, $_REQUEST['start'], $num_topics, $modSettings['defaultMaxTopics'], true);
$context['current_page'] = (int) $_REQUEST['start'] / $modSettings['defaultMaxTopics'];

5b) REPLACE with:

// Make sure the starting place makes sense and construct the page index.
if (empty($board))
$context['page_index'] = constructPageIndex($scripturl . '?action=' . $_REQUEST['action'] . ($context['board_sort'] ? ';sort=board' : '') . ($context['showing_all_topics'] ? ';all' : ''), $_REQUEST['start'], $num_topics, $modSettings['defaultMaxTopics']);
else
$context['page_index'] = constructPageIndex($scripturl . '?action=' . $_REQUEST['action'] . ($context['board_sort'] ? ';sort=board' : '') . ($context['showing_all_topics'] ? ';all' : '') . ';board=' . $board, $_REQUEST['start'], $num_topics, $modSettings['defaultMaxTopics'], true);
$context['current_page'] = (int) $_REQUEST['start'] / $modSettings['defaultMaxTopics'];

6a) Find the following:

ORDER BY ml.ID_MSG DESC

6b) REPLACE with:

ORDER BY $orderby

7a) Find the following:

ORDER BY ml.ID_MSG DESC

7b) REPLACE with:

ORDER BY $orderby

8a) Find the following:

ORDER BY ml.ID_MSG DESC

8b) REPLACE with:

ORDER BY $orderby


Just a bit more magic..

File: Sources/Subs-Boards.php

9a) Find the following:

elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies')
{
// Make sure all the boards are integers!
$topics = explode('-', $_REQUEST['topics']);

$setString = '';
foreach ($topics as $ID_TOPIC)
{
$ID_TOPIC = (int) $ID_TOPIC;
$setString .= "
(" . time() . ", $ID_MEMBER, $ID_TOPIC),";
}

db_query("
REPLACE INTO {$db_prefix}log_topics
(logTime, ID_MEMBER, ID_TOPIC)
VALUES" . substr($setString, 0, -1), __FILE__, __LINE__);

redirectexit('action=unreadreplies');
}

9b) Add AFTER:

elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unread')
{
// Make sure all the boards are integers!
$topics = $_REQUEST['markasread'];
if ($topics == '')
fatal_lang_error('no_topics_selected');

$setString = '';
foreach ($topics as $ID_TOPIC)
{
$ID_TOPIC = (int) $ID_TOPIC;
$setString .= "
(" . time() . ", $ID_MEMBER, $ID_TOPIC),";
}

db_query("
REPLACE INTO {$db_prefix}log_topics
(logTime, ID_MEMBER, ID_TOPIC)
VALUES" . substr($setString, 0, -1), __FILE__, __LINE__);
if (isset($_REQUEST['all'])) {
if (isset($_REQUEST['sort'])) {
redirectexit('action=unread&sort=board;all');
} else { 
redirectexit('action=unread;all');
}
} else {
redirectexit('action=unread');
}
}


10) Replace File: Themes/your_theme/Recent.template.php with the new one.
11) Copy the image to your images directory.

Treo forum - Powered by SMF, of course
Treo news - powered by MovableType and integrated with SMF
Treo downloads - hacked from phpNuke and integrated with SMF
Treo knowledge base - powered by Wikka and integrated with SMF
Treo 650 | Treo 700w | Treo 700p

NoRad

Still waiting on an Email or IM from you. Check your PM. I really would prefer to integrate it with my site so that there is no user choice. I like to keep things consistent.

NoRad

I have been without this in quite some time. Has anybody tested it with 1.1? I tried making a package awhile back and it failed to install properly so I gave up. =(

Rasyr

I just made the changes as suggested on the first page to the recent.template and things are looking ok, except that the boards are not sorting in the order where they show on the main index.

I could not find that line in the sources file that [unknown] was talking about. I think it may have been changed.

If anybody has any suggestions, I would very much appreciate it.


Rasyr

#36
To get this working in 1.1 RC1, just complete the following steps:

Please note that I was using an HTML editor which displayed line numbers, so I will be giving approximate line numbers with the code changes as well.

File 1 - default theme - recent.template.php - Approximately Line 121 (CLassic Template starts a few lines earlier)

Find: foreach ($context['topics'] as $topic)
{
echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" /></td>
<td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" border="0" align="middle" /></td>
<td class="windowbg" valign="middle" width="48%">
' . $topic['first_post']['link'] . ' <a href="' . $topic['new_href'] . '"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a> <span class="smalltext">' . $topic['pages'] . '</span>
<div class="smalltext"><i>' . $txt['smf88'] . ' ' . $topic['board']['link'] . '</i></div></td>
<td class="windowbg2" valign="middle" width="14%">
' . $topic['first_post']['member']['link'] . '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
' . $topic['replies'] . '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
' . $topic['views'] . '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span></td>
</tr>';
}

And replace it with:$boards = array();
foreach ($context['topics'] as $topic)
$boards[$topic['board']['id']] = $topic['board'];

foreach ($boards as $board)
{
echo '
<tr class="catbg">
<td colspan="7">', $board['link'], '</td>
</tr>';

foreach ($context['topics'] as $topic)
{
if ($topic['board']['id'] != $board['id'])
    continue;

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" /></td>
<td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $settings['images_url'] . '/post/' . $topic['first_post']['icon'] . '.gif" alt="" border="0" align="middle" /></td>
<td class="windowbg" valign="middle" width="48%">
' . $topic['first_post']['link'] . ' <a href="' . $scripturl . '?topic=' . $topic['id'] . '.from' . $topic['newtime'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a> <span class="smalltext">' . $topic['pages'] . '</span>
<td class="windowbg2" valign="middle" width="14%">
' . $topic['first_post']['member']['link'] . '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
' . $topic['replies'] . '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
' . $topic['views'] . '</td>
<td class="windowbg2" valign="middle" width="27%"><a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>
<span class="smalltext">' . $topic['last_post']['time'] . '<br />' . $txt[525] . ' ' . $topic['last_post']['member']['link'] . '</span></td>
</tr>';
}
}


File 2 - Sources folder- recent.php

In the UnreadTopics() function, there are 5 locations that contain ORDER BY statements. In my file, they occured on lines: 727, 789, 919, & 950.

All 5 lines begin with:
ORDER BY " .

I changed all 5 to begin as follows:
ORDER BY b.boardOrder," .

I do not know if all 5 changes were required, but I have not had any problems so far.

With these changes, the link Show unread posts since last visit now displays the topics/threads with new posts sorted by the Forum that they appeared in, sorted by the most recently active topic within each forum. The order that the forums are displayed is static, and matches the same order as is on the Main Index. Please note that Child Forums show up after the regular forums in a given category, rather than beneath its parent forum.


Update: removed the change to line 908 (and removed it from list of changes to make as well) as it messed up the Recent Replies to your posts link.

NoRad

I will give it a shot and let you know. Unfortunately, I am reading this while intoxicated.  :D

NoRad

Line 908 gave me an error message as well. Any idea how to get it working for unread replies?

Rasyr

Quote from: Radianation on December 18, 2005, 02:50:33 AM
Line 908 gave me an error message as well. Any idea how to get it working for unread replies?

Do you mean "new replies to your posts"? If so, then sorry, no I don't. If you are talking about "Show unread posts since last visit." Then following the directions above as the things I suggested above do make it work (do NOT make the change to 908, that caused problems).

Then they requested a specific button for it.
What I did was to later add a button across the top of my forums (where the logout, register, profile, etc. are located)  that went directly to  the following page/url :


This makes it easier for folks. (note: the above link will take you to a login page if you do not have an account). But feel free to register so that you can check it out.


Advertisement: