News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

AJAX Recent Topics

Started by live627, July 08, 2008, 07:15:38 PM

Previous topic - Next topic

Mikeric

Quote from: SlammedDime on February 11, 2009, 07:38:21 PM
I'll probably work on this tomorrow.  I'm probably going to rewrite it like I did the sitemap mod to use more 2.0 native methods.  Might introduce some new features too... ;)

Have you done anything on this mod yet? Just wondering since it is probably the most requested one since i updated.

SlammedDime

Since I'm trying to use some of SMF's more native functions, it's a little bit more difficult to do exactly what needs to be done, but I almost have it working.  The javascript needs to be reworked to function properly since the layout is changing, and I'm still working on finding a way to dynamically update the time it was posted, so it just doesn't say '0 minutes ago' and never changes.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

Antechinus

Cool. Will be happy to help test the thing once you have it going.

qubbah

how to put it in block for tinyportal?

SlammedDime

SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

ZOR0

Any word on the release for rc1?
Sorry if this is nagging. It's such a great mod, even though i can't get it functional yet.

erdem86

Hi,

Is there any way to make Recent Topic page to be updated only when a topic is posted.. I mean I don't want topics to go up when they receive reply. I want to show the newest topics on top no matter which one received a reply or not.

And how can I integrate the thumbnails generated by this mod (http://custom.simplemachines.org/mods/index.php?mod=1151) to the recent topics page?

qubbah

IM using this code to put it in the block like for tp.
//recent post
   
   
   echo '
      <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;"' : '', '>
         <table border="0" width="100%" cellspacing="0" cellpadding="4" class="bordercolor" id="topicTable">
            <tr>';

   // Are there actually any topics to show?
   echo '
               <td width="15%" class="catbg3"><strong>', $txt['smf82'], '</strong></td>
               <td class="catbg3"><strong>', $txt[118], '</strong></td>
               <td width="50" class="catbg3" align="center"><strong>', $txt[110], '</strong></td>
               <td width="150" class="catbg3" align="center"><strong>', $txt[109], '</strong></td>
               <td width="150" class="catbg3" align="center"><strong>', $txt[22], '</strong></td>
               <td width="16" class="catbg3"></td>';

   // No topics.... just say, "sorry bub".
   if (empty($context['topics']))
      echo '
            </tr>
            <tr id="no_topics">
               <td class="windowbg2" width="100%" colspan="6"><strong>', $txt[151], '</strong></td>';

   echo '
            </tr>';
   
   foreach ($context['topics'] as $topic)
   {
      echo '
            <tr class="windowbg2" id="topic_', $topic['id'], '">
               <td class="smalltext" style="padding-left: 10px; border-bottom: 1px solid rgb(204, 204, 204);">', $topic['board']['link'], '</td>
               <td style="padding-left: 10px; border-bottom: 1px solid rgb(204, 204, 204);">', $topic['link'], '</td>
               <td align="center" class="smalltext" style="border-bottom: 1px solid rgb(204, 204, 204);">', $topic['replies'], '</td>
               <td align="center" class="smalltext" style="border-bottom: 1px solid rgb(204, 204, 204);">', $topic['firstPoster']['link'], '<br />', $topic['firstPoster']['time'], '</td>
               <td align="center" class="smalltext" style="border-bottom: 1px solid rgb(204, 204, 204);">', $topic['lastPoster']['link'], '<br />', $topic['lastPoster']['time'], '</td>
               <td align="center" style="border-bottom: 1px solid rgb(204, 204, 204);"><a href="', $topic['lastPost']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" /></a></td>
            </tr>';
   }
   
   echo '
         </table>
      </div>';
   
   // Now for all of the javascript stuff
   echo '
      <script language="Javascript" type="text/javascript"><!-- // -->
         var last_post = ', (!empty($context['last_post_time']) ? $context['last_post_time'] : 0), ';
         var time_interval = ', $settings['number_recent_topics_interval'] * 1000, ';
         var max_topics = ', $settings['number_recent_topics'], ';
         
         var interval_id = setInterval( "getTopics()", time_interval);

         function getTopics()
         {
            if (window.XMLHttpRequest)
               getXMLDocument("', $scripturl, '?action=recenttopics;latest=" + last_post + ";xml", gotTopics);
            else
               clearInterval(interval_id);
         }
         
         function gotTopics(XMLDoc)
         {
            var updated_time = XMLDoc.getElementsByTagName("smf")[0].getElementsByTagName("lastTime")[0];
            var topics = XMLDoc.getElementsByTagName("smf")[0].getElementsByTagName("topic");
            var topic, id_topic, board, subject, replies, firstPost, lastPost, link;
            var myTable = document.getElementById("topicTable"), oldRow, myRow, myCell, myData, rowCount;
           
            // If this exists, we have at least one updated/new topic
            if (updated_time)
            {
               // Update the last post time
               last_post = updated_time.childNodes[0].nodeValue;
               
               // No Messages message?  Ditch it!
               // Note, this should only happen if there are literally zero topics
               // on the board when a user visits this page.
               if (document.getElementById("no_topics") != null)
                  myTable.deleteRow(-1);
               
               // If the topic is already in the list, remove it
               for (var i = 0; i < topics.length; i++)
               {
                  topic = XMLDoc.getElementsByTagName("smf")[0].getElementsByTagName("topic")[i];
                  id_topic = topic.getElementsByTagName("id")[0].childNodes[0].nodeValue;
                  if ((oldRow = document.getElementById("topic_" + id_topic)) != null)
                     myTable.deleteRow(oldRow.rowIndex);
               }
               
               // Are we going to exceed the maximum topic count allowed?
               while (((myTable.rows.length - 1 + topics.length) - max_topics) > 0)
                  myTable.deleteRow(-1);
               
               // Now start the insertion
               for (var i = 0; i < topics.length; i++)
               {
                  // Lets get all of our data
                  topic = XMLDoc.getElementsByTagName("smf")[0].getElementsByTagName("topic")[i];
                  id_topic = topic.getElementsByTagName("id")[0].childNodes[0].nodeValue;
                  board = topic.getElementsByTagName("board")[0].childNodes[0].nodeValue;
                  subject = topic.getElementsByTagName("subject")[0].childNodes[0].nodeValue;
                  replies = topic.getElementsByTagName("replies")[0].childNodes[0].nodeValue;
                  firstPost = topic.getElementsByTagName("first")[0].childNodes[0].nodeValue;
                  lastPost = topic.getElementsByTagName("last")[0].childNodes[0].nodeValue;
                  link = topic.getElementsByTagName("lastLink")[0].childNodes[0].nodeValue;
                 
                  // Now to create the new row...
                  myRow = myTable.insertRow(1);
                  myRow.id = "topic_" + id_topic;
                  myRow.className = "windowbg";
                 
                  // First the Board
                  myCell = myRow.insertCell(-1);
                  myCell.className = "smalltext";
                  myCell.style.paddingLeft = "10px";
                  myCell.style.borderBottom = "1px solid rgb(204, 204, 204)";
                  setInnerHTML(myCell, board);
                 
                  // Then subject
                  myCell = myRow.insertCell(-1);
                  myCell.style.paddingLeft = "10px";
                  myCell.style.borderBottom = "1px solid rgb(204, 204, 204)";
                  setInnerHTML(myCell, subject);
                 
                  // replies
                  myCell = myRow.insertCell(-1);
                  myCell.className = "smalltext";
                  myCell.align = "center"
                  myCell.style.borderBottom = "1px solid rgb(204, 204, 204)";
                  setInnerHTML(myCell, replies);
                 
                  // first post
                  myCell = myRow.insertCell(-1);
                  myCell.className = "smalltext";
                  myCell.align = "center"
                  myCell.style.borderBottom = "1px solid rgb(204, 204, 204)";
                  setInnerHTML(myCell, firstPost);
                 
                  // last post
                  myCell = myRow.insertCell(-1);
                  myCell.className = "smalltext";
                  myCell.align = "center"
                  myCell.style.borderBottom = "1px solid rgb(204, 204, 204)";
                  setInnerHTML(myCell, lastPost);
                 
                  // last post
                  myCell = myRow.insertCell(-1);
                  myCell.align = "center"
                  myCell.style.borderBottom = "1px solid rgb(204, 204, 204)";
                  setInnerHTML(myCell, link);
               }
            }
         }
      // ]]></script>';


But the problem is i want to make the last poster name and the time only show in one row.. then i delete the BR code from <td align="center" class="smalltext" style="border-bottom: 1px solid rgb(204, 204, 204);">', $topic['lastPoster']['link'], '<br />', $topic['lastPoster']['time'], '</td>

but there is nothing change.

Also i try to change last_post.gif to my custom one..
i have change it to , '/icons/last_post2.gif"
also nothing change i can see...

what must i do?

qubbah

how can i change to make when users click the last topic it bring them to the new-latest post in that topic?

SlammedDime

qubbah - i can't really help you on putting it into a block, i'm not familiar with how TP works and I'm almost 99% sure that it will not work in a block.

And it should be taking users to the newest post that they haven't yet read
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

ttuu

i have one problem.
if i use recenttopics;board=19.0 function.
i see the Recent Topics from this moard. but after 10 sec the page refresh to recenttopics function and i see Recent Topics from all boards.
u can fix?

ryanhellyer

Great plugin! It spat out an error saying that it couldn't update index.template.php, but since I'm not using the default theme I ran with it anyway and everything seems to working flawlessly so far :)

Keep up the good work!

noaccess

Has anyone attempted to change the history length (the number of shouts shown) in the shoutbox? Where exactly is tha piece of code located so I can change it?  O:)

SlammedDime

I think you have the wrong topic...
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

noaccess

Quote from: SlammedDime on August 03, 2009, 05:14:16 AM
I think you have the wrong topic...
Heh, yeah it would seem so. I interpreted the title the wrong way...

digit

Since there are no permission settings for this - is there a quick hack where I can say ...

if ($context['member']['post_group'] == 9)

{

}

?

I think that URL was made public, and it MAY be bogging my server down.

Thanks in advance.

Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

SlammedDime

If you just want to eliminate guests from viewing it... you can do this in Recent.php

Code (Find) Select
loadTemplate('Recent');
$context['page_title'] = $txt['recent_topics'];
$context['sub_template'] = isset($_REQUEST['xml']) ? 'recent_xml' : 'recent';


Code (Add Above) Select
if (in_array(-1, $user_info['groups']))
redirectexit();
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

digit

I only want user in groups 9,1 and 2 to view it - if you could help with that - that would be awesome :)
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

SlammedDime

if (array_intersect($user_info['groups], array(1,2,9)) == array())
      redirectexit();

Compare the current user's groups to that of 1, 2, and 9.  If the resulting array is empty, that member is not part of those groups, thus redirect out.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

digit

Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Advertisement: