"Mark forums read" and Ajax

For support and discussion related to templates, themes, and imagesets in phpBB 3.1.
Scam Warning
Locked
phpusher
Registered User
Posts: 9
Joined: Fri Oct 24, 2014 11:48 pm

"Mark forums read" and Ajax

Post by phpusher »

Hi,
I am trying to create my own template, but got stuck at a problem with ajax.js and the Mark forums read link.
Forum version is a fresh install of phpBB-3.1.0-RC6.

What have I done so far?
  • I changed the forumlist_body.html.
    Original layout:

    Code: Select all

    <li class="row">
      <dl class="icon {forumrow.FORUM_IMG_STYLE}">
        <dt title="{forumrow.FORUM_FOLDER_IMG_ALT}">
    My layout:

    Code: Select all

    <tr class="row">
      <div class="icon {forumrow.FORUM_IMG_STYLE}">
        <td title="{forumrow.FORUM_FOLDER_IMG_ALT}">
    So I only changed the names of the three HTML tags (after the td I changed a little bit more, but looking at the ajax file, that shouldn't matter)
  • Then I also had to change ajax.js, replacing li, dl and dt with tr, div and td.
    My code:

    Code: Select all

    	$('tr.row').find('div[class*="forum_unread"]').each(function() {
    		var $this = $(this);
    
    		$.each(iconsArray, function(unreadClass, readClass) {
    			if ($this.hasClass(unreadClass)) {
    				$this.removeClass(unreadClass).addClass(readClass);
    			}
    		});
    		$this.children('td[title="' + unreadTitle + '"]').attr('title', readTitle);
    	});
    
I can't understand why this won't dynamically update the page. A refresh shows, that the link itself works.
I tried renaming just the three tags back to their original tags (leaving the rest of my code unchanged) and it brought back the functionality. But then of course, my layout didn't look anything near as good as it did before.

Does anybody have an idea what is causing the problem with the Ajax code? I have little to no experience with Ajax, so maybe I am doing something really stupid?

What about this part in the Ajax function:

Code: Select all

	// Mark topics read if we are watching a category and showing active topics
	if ($('#active_topics').length) {
		phpbb.ajaxCallbacks.mark_topics_read.call(this, res, false);
	}
I don't really understand the purpose of that snippet. Why is it necessary (I know, there is a comment, but still don't get it)?
The function mark_topics_read does some things in viewforum_body.html, but I can't see, how this would affect me on forumlist_body.html

Thanks for the help!
- phpusher
User avatar
PayBas
Former Team Member
Posts: 930
Joined: Thu May 25, 2006 12:37 am

Re: "Mark forums read" and Ajax

Post by PayBas »

Well, firstly, you can't do <tr><div><td>. A <tr> can only have <th> or <td> children.

Secondly, does your browser console show any errors?
phpusher
Registered User
Posts: 9
Joined: Fri Oct 24, 2014 11:48 pm

Re: "Mark forums read" and Ajax

Post by phpusher »

Okay, I thought you could put a div just about anywhere in a document. The console didn't show any errors.

I now tried rearranging a little and dropping the div. Now I have just this

Code: Select all

<tr class="forum-row {forumrow.FORUM_IMG_STYLE}">
	<td title="{forumrow.FORUM_FOLDER_IMG_ALT}">
and changed the ajax.js to this:

Code: Select all

$('tr.forum-row').filter('.forum_unread').each(function() {
Weirdly enough it's working now, although I can't imagine it does, because of the div not being allowed in a tr. Anyway, thanks a lot for the quick help! :)
Locked

Return to “[3.1.x] Styles Support & Discussion”