AJAX thread title edit when viewing the thread

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • David Grove
    Senior Member
    • Apr 2008
    • 3507
    • 5.5.x

    AJAX thread title edit when viewing the thread

    1. Add the following to the bottom of the SHOWTHREAD template, right before </body>.
    2. Now anyone who has permission to do so (admins, mods, and the thread starter, if you have it set up like that) can double-click the thread title within the first post and edit it. (Just like you can do on forumdisplay)
    3. If you want the clickable/editable element to be something other than the first post title-- for example in the breadcrumbs or a custom title at the top of the thread-- then just add id="thread_title_XXX" to that element, replacing XXX with the thread id. Make sure the element you add the ID to is wrapped by some other element, such as a div, because the parent element is actually what becomes clickable.

    Code:
    <if condition="$show['editthread'] OR ($thread['open'] AND $thread['postuserid'] == $vbulletin->userinfo['userid'] AND ($forumperms & $vbulletin->bf_ugp_forumpermissions['caneditpost']) AND ($thread['dateline'] + $vbulletin->options['editthreadtitlelimit'] * 60) > TIMENOW)">
    <script type="text/javascript" src="clientscript/vbulletin_ajax_threadslist.js?v=$vboptions[simpleversion]"></script>
    <script type="text/javascript">
    (function(){
        // add id to the post title element
        if (!YAHOO.util.Dom.get('thread_title_' + $thread[threadid]))
        {
            var firstpost = YAHOO.util.Dom.get('td_post_' + $thread[firstpostid]);
            var titlediv = YAHOO.util.Dom.getFirstChildBy(firstpost, function(el){return(el.nodeName == 'DIV');});
            var title = YAHOO.util.Dom.getFirstChildBy(titlediv, function(el){return(el.nodeName == 'STRONG');});
            YAHOO.util.Dom.setAttribute(title, 'id', 'thread_title_' + $thread[threadid]);
        }
    
        // add handler
        if (!YAHOO.util.Dom.get('thread_title_wrapper_' + $thread[threadid]))
        {
            YAHOO.util.Dom.setAttribute(YAHOO.util.Dom.get('thread_title_' + $thread[threadid]).parentNode, 'id', 'thread_title_wrapper_' + $thread[threadid]);
        }
        YAHOO.util.Event.on('thread_title_wrapper_' + $thread[threadid], 'dblclick', vB_AJAX_ThreadList_Events.prototype.threadtitle_doubleclick, '', false);
    })();
    </script>
    </if>
    ~~~~~
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...