Welcome to Geeklog, Anonymous Tuesday, March 19 2024 @ 07:10 am EDT

About Autolinks And Autotags

  • Saturday, November 27 2004 @ 06:30 am EST
  • Contributed by:
  • Views: 30,812
Geeklog

One of the new features in Geeklog 1.3.10 are the so-called autolinks which provide new tags (called autotags) to link to objects under a plugin's control. For example,

[staticpage:cvs Learn all about the Geeklog CVS]
will be displayed as this link: Learn all about the Geeklog CVS

But the full potential of this new form of links has yet to be explored. For example, autolinks could provide a solution to the often requested ability to let normal users upload images with their stories. If you have Gallery installed and allow image upload for your users there, a plugin could provide an autotag that not only links to the image in Gallery but also displays the preview in the story. Another example would be a request from a client I had who asked for attachments to stories (just like attachments in an email), which could be done by adding autotags to the File Management plugin.

To add support for autotags to your plugin, you only have to implement one function, plugin_autotags_pluginname. See the function I wrote for the FAQ Manager plugin for an example. And if you want to add support for autolinks, i.e. that other plugin's autotags will be interpreted by your plugin, then you only have to call the plugin API function PLG_replaceTags (see lib-plugins.php) before displaying your plugin's content.

There's one drawback of autolinks, though: Since they are interpreted when the post (story, comment, ...) is displayed, they use a bit of the webserver's CPU. So on really busy sites, you may have to disable them to ensure sufficiently fast display of your site (at which point the autotags will be displayed verbatim). The new config.php option $_CONF['disable_autotags'] has been introduced for precisely that purpose.