Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://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

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-18 07:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found