Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

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        

In reply to Re: Free Nodelet gets templating features ("add this" advanced example) by tye
in thread Free Nodelet gets templating features by tye

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (5)
    As of 2015-11-29 10:57 GMT
    Find Nodes?
      Voting Booth?

      What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

      Results (750 votes), past polls