|go ahead... be a heretic|
Re: Free Nodelet Hack: Add parent & root links to nodes in 'Nodes You Wrote' (or anywhere)by tye (Sage)
|on Dec 17, 2006 at 22:14 UTC||Need Help??|
I think that if you avoid overgeneralizing and just hard code "redir to root" and "redir to parent", then the code can become much simpler, you don't need to depend on AJAX components (so it is easier to make work more places), and you avoid waiting for one round-trip to the server.
Actually, the amount of hard-coding you need to do would be minimal, just a case statement on the fields that make sense, with the Free Nodelet templatung filling in values for you.
Just check if "redir" parameter was specified, then switch on the parameter's value to redirect to the appropriate next field (not including the "redir" parameter, of course). And then add an on-load function to use the DOM to transform links of type ?node_id=... to be three links, the original plus one that includes ;redir=parent and one that includes ;redir=root. It seems like this strategy even makes it easy to provide the feedback that you note you didn't include.
Okay, here is a working redirector that adds links to your Free Nodelet that will send you to the grandparent of a reply or to the author of the node that this node was in reply to:
The on-load code to transforms node_id= links is left as an exercise.