Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Note: I had this on my home node for a long time, but it was just cluttering it up so I decided to put it here.

Wiki-ing in style

When writing on a wiki, please only add new entries at the top. Having the chronological order of posts move in different spatial directions is confusing to read. Also, please precede your entry with Username, YYYY-MM-DD.

Patch navigation

To view just the code of a patch instead of getting the usual diff, follow the "view code" link in the PmDev Nodelet. To see how the patch affected things, view it, hit the "related patches" link, and go to the previous patch. It will show what the new patch changed - in reverse, of course. This will work even for the first real patch as the gods take care to create new nodes empty and put the data in via a patch.

Coding tidbits

htmlcode

PM uses a htmlcode modified by tye. In addition to embedding [{textarea:fieldname,10,80}] into HTML template code or calling htmlcode('textarea','fieldname,10,80') from Perl code, the new and preferred call style is htmlcode('textarea','','fieldname',10,80) [note the empty second argument, '', which is required]. You can even mix the two: htmlcode('textarea','fieldname,10',80,'virtual'). This allows to fix calls to parselinksinstring to avoid using a global (which can cause very strange things when two different bits of code both want to use that function). So code that used to read:
$HTMLVARS{embed_node}{doctext} = $U->{scratchpad}; return htmlcode( 'parselinksinstring', '0' );
should be changed to:
return htmlcode( 'parselinksinstring', '', 0, '', $U->{scratchpad} );
where parselinksinstring takes 3 arguments:
  1. whether or not to process <readmore> tags
  2. the ID of the node the readmore link should go to
  3. the text of the node.

For backward compatibility $HTMLVARS{embed_node}{doctext} will be used when (3) is missing.

$q

Nowadays, $q is exported along with $query. The latter will still work but should be considered deprecated.

Avoid hard-coded HTML

Do not write non-trivial hard-coded HTML - use $q->htmlshortcut(...) and co instead. They can do intelligent defaulting based on input parameters and will automatically HTML-escape text. $q->table(...) and the like should also become smarter so they will handle CSS and other special processing some day.

$AUTHOR

You don't need to fetch $NODE->{author_user}'s user node manually anymore - you can use $AUTHOR for that.



Makeshifts last the longest.


In reply to pmdevil's cave map by Aristotle
in thread Aristotle by Aristotle

Title:
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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (8)
    As of 2014-04-23 21:13 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (555 votes), past polls