Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Free Nodelet gets templating features ("add this" advanced example)

by tye (Sage)
on May 08, 2005 at 07:50 UTC ( #454985=note: print w/replies, xml ) Need Help??

in reply to Free Nodelet gets templating features

Here we have a more advanced example to show more of the power available.

Paste the following into your Free Nodelet (at Free Nodelet Settings) and you'll have a numbered list of favorite nodes where you can add nodes either to the top of the list or the bottom:

[href://?node_id=`author_id`;op=_freer;at=first;_id=`id`| `author_name&` rocks!] <ol> <!--<li>[id://`_id`] by `title&` </li>-first--> <!--last-<li>[id://`_id`] by `_who&` </li>--> </ol> [href://?node=free nodelet settings;op=_freer;at=last;_id=`id`;_who=`a +uthor_name%`| Append `author_name&` above]

{[href://?node_id=`author_id`} starts a link that goes to the current node's author's home node. {;op=_freer;at=first} makes the link insert an expanded copy of the "first" template. {;_id=`id`|} gives an extra URL parameter that can be used by the "first" template and sets it to the node ID of the current node. {`author_name&` rocks!]} finishes the link, providing the text to click on. Of course, {`author_name&`} gets replace with the monk name of the current node's author, encoded to display correctly.

{<ol>} starts our numbered list. {<!--} opens an HTML comment and starts our first template. {<li>[id://`_id`] by `title&`} and {</li>} form the body of the template. {-first-->} closes the HTML comment and gives the template its name, "first".

Putting the template name at the end means that the expanded template will be inserted after the HTML comment. This means that each expansion gets inserted above the previous expansions.

So clicking the first link will cause your browser to go to the home node of the author of the current node with an extra URL parameter named "_id" set to the ID of the node we came from. It also causes the _freer opcode to expand the "first" template. {`_id`} from the body of the template gets replaced with the starting node ID taken from the "_id" URL parameter. {`title&`} gets replaced with the title of the current node, that is, the author's name, escaped to display correctly.

On to the next part of our example: {<!--last-} starts another template and names it "last". {<li>[id://`_id`] by `_who&`} and {</li>} form the body of the template and {-->} ends it. {</ol>} ends our numbered list.

{[href://?node=free nodelet settings} starts a link to Free Nodelet Settings (where we can edit our Free Nodelet contents). {;op=_freer;at=last;_id=`id`} makes the link expand the "last" template and passes in the ID of the starting node (just like the previous link). {;_who=`author_name%`} also passes the name of the starting node's author in a URL parameter ("_who") and properly escapes it for the URL. {|} and {Append `author_name&` above]} end our link and give the text to display (the author's name will be expanded, of course).

So click the first link to add the current node to the top of your numbered list and jump to the author's node. Click on the second link to add the current node to the bottom of your numbered list and jump to Free Nodelet Settings in case you want to move it up higher in the list or otherwise adjust your Free Nodelet contents.

Updated: s/User Settings/Free Nodelet Settings/g.

- tye        

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://454985]
[choroba]: Yes, tried now. Login didn't show the login window at all, timed out, but worked for the second time instantly.
[choroba]: Trying the daemon log...
[choroba]: It seems very slow. But the internet is weird here in Vietnam...
[choroba]: again, stopping it and trying for the second time fixed the problem
[marto]: good morning all

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2017-02-22 09:14 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (325 votes). Check out past polls.