Admun's NUDN

admun

  • San Francisco, CA

Navigation

Navigation

Categories

The Creation of permalink

I saw it sometimes when a plugin writer directly construct a permalink (also called item link) by doing this:

...
...
echo "<a href=\"index.php?itemid=".$itemid."\">".$title."</a>";
... ...

This works fine usually, but the link will be incorrect in a FancyURL setup.

So next time when your plugin need to generate a permalink, do this:

...
...
$url   = createItemLink($itemid);
echo "<a href=\"index.php?itemid=".$url."\">".$title."</a>";
...
...
createItemLink takes care of constructing the item link for you and takes into account of whether FancyURL is enabaled.

However, there is a problem currently (as of Nucleus 3.0) that createItemLink() is broken when CONF['Self'] is empty. This happens in most of the cases except during skinVar processing (ie doSkinVar()).

The solution for now is to add the following code before you call createItemLink:
...
...
// a little hack to get a working permanent URL for the item
if (!$CONF['ItemURL'])
  $CONF['ItemURL'] = $blog->getURL();                                                                                
...
...

11:55:56 on 06/14/04 by Admun - Category: Developer Notes - tags: none - print

Comments

karma wrote:

One note: don't forget to add "global $CONF;" in your method if you want this to work

06/14/04 14:09:17

Admun wrote:

Saw some good info about URL generation from the wiki. See section 3, http://wakka.xiffy.nl/tipsA...

07/07/04 15:40:47

Add Comments