Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Node ids by node titles

by monarch (Priest)
on Nov 01, 2006 at 11:08 UTC ( #581651=monkdiscuss: print w/replies, xml ) Need Help??

I would like to make a development request to Perl Monks.

Specifically, I would like to see the ID of a node next to the subject title of that node. This is presently displayed at the top of a thread, but not on each node (or reply) displayed underneath on a page.

Why would I want this? Because I like to refer to nodes in the chatbox and also in private messages to other users. I like the [id://nnnnn] notation (where nnnnn is the node ID consisting entirely of digits).

At present I obtain this number by right-clicking on the node subject, copying the URL, then pasting the URL, and then trimming out the URL excluding the node ID itself. I would find it easier to just copy and paste the ID itself.

Would others find this a convenience also.. or perhaps it might be viewed as clutter?

Update: emphasised that I want to see the node id on each sub-node on a page, not just the node id of the thread at the top of the page. Suggested by jdporter.

Update 2: many thanks to bobf and demerphq for implementing this change as an option in Display Settings (see this reply).

Replies are listed 'Best First'.
Re: Node ids by node titles
by McDarren (Abbot) on Nov 01, 2006 at 11:27 UTC
Re: Node ids by node titles (patch applied)
by bobf (Monsignor) on Nov 02, 2006 at 03:42 UTC

    There is an option in Display Settings called "Show a ID tags on notes?" which, if checked, will add the node ID (in [id://nnnnnn] format) to the title/author bar for each reply in a thread.

    It didn't take long for hossman to discover the patch. :-) In fact, he was a bit too quick - I started working on it this afternoon and demerphq finished it up and applied it. The format will be tweaked slightly, but the functionality is there. Enjoy.

      This is fantastic! Thank you muchly for providing this, I've switched it on, and I've got a smile all over my face! I wasn't too fussed about the format being [id://1234] or a simple (1234), so this is just what I wanted!
Re: Node ids by node titles
by bmann (Priest) on Nov 01, 2006 at 21:15 UTC
    Good idea, it'd be nice to have the node id easily accessible for each reply.

    Put this snippet in your free nodelet - it'll add "#node_id" after the reply title (ie #581764 for this node).

    <script language="javascript"><!-- function add_node_ids() { var trs = document.getElementsByTagName('tr'); var i; for ( i = 0; i < trs.length; i++ ) { if ( trs[i].className == 'reply' ){ var anch = trs[i].getElementsByTagName( 'a' ); var id = anch[0].href.match( /\d+$/ ); var txt = document.createTextNode( " #" + id ); //or for [id://nnnnnn] style, //var txt = document.createTextNode( " [id://" + id + "]" ); anch[0].parentNode.insertBefore( txt, anch[0].nextSibling +); } } } add_node_ids(); </script><!-- end add_node_ids -->

    Update: Tested on Firefox 1.507 & IE 6
    Update 2: Only showed ids for new replies. Fixed to show id's for all replies. Added [id://nnnnnn].

      Due to a recent patch, the above code no longer works.
      The following illustrates the necessary fix, which I've flagged with XXX:

      function add_node_ids() { var trs = document.getElementsByTagName('tr'); var i; for ( i = 0; i < trs.length; i++ ) { if ( trs[i].className == 'reply' ){ var anch = trs[i].getElementsByTagName( 'a' ); var id = anch[0].name; // XXX var ntre = document.createElement('input'); ntre.type = 'text'; = 'see_Free_Nodelet_Settings'; ntre.value = "[id://" + id + "]"; anch[0].parentNode.insertBefore( ntre, anch[0].nextSibling.nextS +ibling ); } } }
      A word spoken in Mind will reach its own level, in the objective world, by its own weight
Re: Node ids by node titles
by zentara (Archbishop) on Nov 01, 2006 at 13:21 UTC
    I'm not sure what you are really asking, but I just click "print" or "w replies" link, and easily mouse-paste the id number from the giant url at the top of the page.

    So if you are saving a node for personal reference, save the print or print_w_replies link.

    I guess it would be convenient to have that node_id prominently displayed on the node itself.

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum

      I think his scenario is something along the lines of:

      • Interesting post occurs 5 layers down in a thread (c.f. the recent threading discussion in meditations)
      • He'd like to msg someone a pointer directly to that post, but to do so he's got to:
        • Copy the link from the node's title
        • Paste it into the msg box
        • Clean it up manually down to the [id://] format

      If the nodes had a copy of the id number (perhaps next to the node's tile in a div that's hidden by default in the stock CSS) he could cut and paste from that easily, just like you can cut and paste from the Node Status Nodelet for the node you're actually looking at.

Re: Node ids by node titles
by sauoq (Abbot) on Nov 01, 2006 at 17:12 UTC

    I just hover on the link and type the node id as it appears in the URL in my status bar. I find that to be faster than cutting and pasting. I think your suggestion is a fine one though.

    "My two cents aren't worth a dime.";
Re: Node ids by node titles
by GrandFather (Sage) on Nov 01, 2006 at 12:13 UTC

    Add &#91;id://`id`] to your Free Nodelet Settings and (if it's not already) turn it on in Nodelet Settings.

    Update: Golly, the mess you can stir up by answering something quickly when half awake in the small hours of the morning! First off I didn't grok the question so I answered what I though it said, not what it actually said. Then I looked at the Node Status nodelet, but decided OP didn't have it available for some reason (note the first problem). Then I remembered I had something like the magic string in my Free Node (for reasons I don't recall) so I cargo culted that into an answer.

    monarch's question is good and McDarrens solution looks like a good way of avoiding updating any PM code.

    I leave you to ponder what else could be put in back ticks in a string that PM will render as HTML. ;)

    DWIM is Perl's answer to Gödel
      The Status Nodelet also provides that (but not what the OP suggests) out of the box.

      That doesn't do what the OP is asking for.

        I disagree. This does do what the OP asked for, but with a caveat. If you do as Grandfather suggested, you will have a nice [id://XXXX] string in your Personal Nodelet for the root node, but not all sub-nodes. Solution: just click on the sub node, load the page, and your Personal Nodelet will be updated accordingly. Problem: you do introduce another server hit, but is it really that big of a deal?

        I think the best solution is what McDarren suggested: Monk Links - Copy Perlmonks-links to the clipboard in on-site-format. And by the way, don't you think a /msg to Grandfather would have been a bit more tactful than simply replying with "you are wrong" and not adding a solution yourself?

        UPDATE: I'm sorry, but there is this little saying called "There is more than one way to do it." Grandfather merely offered what he thought was an acceptable work around. I simply took this a bit further to show how the work around could be applied so that OP could get the info they needed. There is nothing wrong nor right about this. I hate to do this but thanks to jdporter's reply below, i would like to point out jdporter's original reply to Grandfather.


        (the triplet paradiddle with high-hat)
Re: Node ids by node titles
by hossman (Prior) on Nov 02, 2006 at 00:32 UTC

    I was pretty sure this would be fairly easy to do using some a simple custom CSS adition, but when I went to test it I discovered that the Display Settings node seems to have a "Show a ID tags on notes?" option which does exactly what is discussed here.

    I have no idea if this has been arround for a while, or if was added by someone recently in response to this thread (I see no comment in this thread to that effect)

Re: Node ids by node titles
by castaway (Parson) on Nov 03, 2006 at 09:25 UTC
    Hmm, we could add it to the Node Nodelet, it's already on the Approval Nodelet for considerations..


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://581651]
Approved by tinita
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2017-01-18 15:19 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (161 votes). Check out past polls.