Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by tye (Cardinal)
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        


Comment on Re: Free Nodelet gets templating features ("add this" advanced example)
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://454985]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2014-12-29 03:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (184 votes), past polls