Split your links list into columns Print

Version française disponible ici

With time passing , the saved links from the dedicated page of the Textpattern admin interface can become numerous. Display its into columns is more efficient and space saver that into simple lists.

A function stored into a form can make the job. The purpose of this function will be to extract all the links stored into the database table. Two arguments will display the results in paragraphs that can be positioned in floating columns.

Let’s create this form (type misc) that we named “link_list”:

  1. <txp:php>
  2. // column left
  3. echo generate_links('23');
  4. // column right
  5. echo generate_links('23', '46');
  6. function generate_links($start, $end = NULL)
  7. {
  8. $end ? $end = ", ".$end."" : $end = NULL;
  9. $links = safe_rows('url, linkname, linksort, description', 'txp_link', '1=1 ORDER BY linksort ASC limit '.$start.$end);
  10. $out = '<p class="column">';
  11. foreach($links as $id => $value)
  12. {
  13. $out .= '<a href="'.$links[$id][url].'" title="'.$links[$id][description].'" onclick="window.open(this.href);return false;">'.$links[$id][linkname].'</a><br />';
  14. }
  15. $out .= '</p>'."\n\r";
  16. return $out;
  17. }
  18. </txp:php>

In the above example, two calls are made. generate('23') will display the first 23 links, then the second call generate('23', '46') will display the next other 23 links until the 46 th one. Depending of your needs, each call will generate the number of columns chosen.

Happy Christmas for all the txp:fr readers.
Don’t forget to send a donation for the TXP core devs.

Published on | Updated on by Patrick LEFÈVRE.

Related Articles

Display a page on your website for known referrers - Publié le 2012.02.09 By Patrick LEFÈVRE.
Control you blank pages - Publié le 2011.12.22 By Patrick LEFÈVRE.
Compress your CSS & javascript files - Publié le 2012.01.09 By Patrick LEFÈVRE.
Hide your sections for non admin users - Publié le 2011.09.28 By Patrick LEFÈVRE.
Pat_tile, a plugin for your articles title - Publié le 2013.04.26 By Patrick LEFÈVRE.
Access to all article archives

» Previous Article» Next Article
txp:fr supports Textpattern ;·) Textpattern CMS

Need Help? Post your question on Entr'Aide txp:fr website