A painting of me

Building a Link-Log in Textpattern 4.0

   23 March 2006, evening time

While upgrading to the latest version of Textpattern, I decided to clean up the way I implemented my Link-Log. The goal was to minimize the number of hacks needed to get things working. This article should explain what I have done, and should be as terse as possible.

First, download and install the If Section Different plug-in, and install it. Follow the instructions carefully, you will need to change some code in publish.php.

You will need to make 1 change to publish.php. You need to add Section to the select list of the function getNeighbour. The function should now look as follows:

  1. function getNeighbour($Posted, $s, $type)
  2. {
  3. $type = ($type == '>') ? '>' : '<';
  4. $q = array(
  5. "select ID, Title, Section, url_title, unix_timestamp(Posted) as uposted
  6. from ".PFX."textpattern where Posted $type '".doSlash($Posted)."'",
  7. ($s!='' && $s!='default') ? "and Section = '".doSlash($s)."'" : filterFrontPage(),
  8. 'and Status=4 and Posted < now() order by Posted',
  9. ($type=='<') ? 'desc' : 'asc',
  10. 'limit 1'
  11. );
  12.  
  13. $out = getRow(join(' ',$q));
  14. return (is_array($out)) ? $out : '';
  15. }
  16. Download this code: /static/code/2.txt

I store extra information about links in custom fields. I have a custom field to store the following things: url, referrer, and referrer url.

I use the following form template to actually display the links on the page.

  1. <txp:if_article_list>
  2. <txp:rsx_if_next_section_different>
  3. <div class="post">
  4. <ul class="interesting-link">
  5. <li class="first-child">
  6. <txp:else />
  7. <li>
  8. </txp:rsx_if_next_section_different>
  9. <txp:if_custom_field name="url"><a href="<txp:custom_field name="url" />"><txp:title /></a>&nbsp;<txp:body /><txp:else /><txp:body /></txp:if_custom_field><txp:if_custom_field name="referrer"> (via&nbsp;<a href="<txp:custom_field name="referrer url" />"><txp:custom_field name="referrer" /></a>)</txp:if_custom_field>&nbsp;&nbsp;<txp:comments_invite /><txp:rsx_frontend_edit_link prefix="&nbsp;&nbsp;[" suffix="]">Edit</txp:rsx_frontend_edit_link></li>
  10. <txp:rsx_if_prev_section_different>
  11. </ul>
  12. </div>
  13. </txp:rsx_if_prev_section_different>
  14. </txp:if_article_list>
  15.  
  16. <txp:if_individual_article>
  17. <div class="post">
  18. <h2><txp:if_custom_field name="url"><a href="<txp:custom_field name="url" />"><txp:title /> &rArr; </a><txp:else /><txp:permlink><txp:title /></txp:permlink></txp:if_custom_field></h2><p class="inline">&nbsp; &nbsp;<txp:posted />, <txp:rsx_time_of_day /></p>
  19. <p><txp:body /><txp:if_custom_field name="referrer"> This link was found via <a href="<txp:custom_field name="referrer url" />"><txp:custom_field name="referrer" /></a>.</txp:if_custom_field></p><p><span class="float_left"><txp:comments_invite /></span><span class="float_right"><txp:rsx_frontend_edit_link suffix=" | ">Edit</txp:rsx_frontend_edit_link><txp:permlink>Perma-Link</txp:permlink></span>&nbsp;</p>
  20. </div>
  21. </txp:if_individual_article>
  22.  
  23. Download this code: /static/code/3.txt

That should be all there is to it. THere are far more details in the old post on this subject, which are for the most part still valid.

|  

Comments

  1. Awesome! Now I can upgrade :) Thanks!

Don't be shy, you can comment too!

 
Some things to keep in mind: You can style comments using Textile. In particular, *text* will get turned into text and _text_ will get turned into text. You can post a link using the command "linktext":link, so something like "google":http://www.google.com will get turned in to google. I may erase off-topic comments, or edit poorly formatted comments; I do this very rarely.