fancierurl2

NP_FancierURL2

NP_FancierURL2 provides search engine optimized URLs for Nucleus 3.22 and higher.

General Plugin info
Author: Kai Greve
Current Version: v0.6
Download: NP_FancierURL2_v06.zip
Code: NP_FancierURL2_code and .htaccess_code
Demo: -
Forum Thread: here

Installing

  1. Unzip the file
  2. upload the .htaccess file to the root directory of you Nucleus installation
  3. upload NP_FancierURL2 into you plugin directory
  4. install the plugin in the plugin manager
  5. enable Fancy URLs in you global settings (Please don’t follow the instructions under “How to activate fancy URLs” because the plugin uses a different solution.)
  6. add a line with your URL to your config.php
$CONF['Self']="http://yourdomain.com/yourdirectory";

before the last three lines

// include libs
include($DIR_LIBS.'globalfunctions.php');
?>

From Fancy URL to FancierURL

If you have already installed the default Fancy URL solution you have to move or remove some files first:

.htaccess 
archive
archives
blog
category
item
member

The best way is to move them to a subdirectory like old.

After that you only need to follow step 1 to 4 (because you have already done step 5 and 6).

Upgrade

If you upgrade from version 0.1 to 0.2 it is important to uninstall the old version of the plugin in the Nucleus plugin manager and then upload and install the new version.

If you simply overide the old plugin you get some error messages and the new version can’t work. In this case you can uninstall and then install the plugin in the plugin manager to get it working.

How to use the plugin

Available SkinVars and/or TemplateVars

Because NP_FancierURL2 uses the new events ParseURL and GenerateURL, from Nucleus 3.22 and higher it is not necessary to make changes to your skins to provide the new URLs.

This Skinvar <%FancierURL2%> also makes it possible to provide the Fancier URLs in your Feed templates like RSS and ATOM.

Here is an example for the RSS feed:

<item>
 <title><%title(xml)%></title>
 <link><%blogurl%><%FancierURL2%></link>
<description><![CDATA[<%body%><%more%>]]></description>
 <category><%category%></category>
<comments><%blogurl%><%FancierURL2%>#c</comments>
 <pubDate><%date(rfc822)%></pubDate>
</item>

Options

  • Include the date in URLs for items (/item/yyyy/mm/title) or not (/item/title) [default:yes]
  • Compatibility mode: support also old style fancy urls (e.g. item/1234) [default:no]

The Compatibility mode is usefull if your weblog has used the old style Fancier URLs from Nucleus and you have already links to these pages (e.g. /item/10). The only drawback is that you can’t use numbers as titles (e.g. if you write an article with the title “10” is resolved as item with the id 10 and not the real id).

New option in version 0.4:

  • Choose encoding automatic (AUTO) or manual (ISO-8859-1, UTF-8 or ASCII)

Hint: For German is the setting ISO-8859-1 right.

Tips and Tricks

First and Foremost...

After you installed FancierURL2, make sure go to the plugin menu and move the plugin’s order to the top (using “move up”). This plugin need to run before all other plugins in order to generate the URL correctly.

Change FURL2 Structure

If you do not like the url to be http://www.domain.tld/item/item-name, you can change the item into other names.

Place this code in the config.php

// custom keywords to use in fancy URLs 
  $CONF['ItemKey'] = 'article'; // default: $CONF['ItemKey'] = 'item'; 
  $CONF['ArchiveKey'] = 'archive'; 
  $CONF['ArchivesKey'] = 'archives'; 
  $CONF['MemberKey'] = 'author'; // default: $CONF['MemberKey'] = 'member'; 
  $CONF['BlogKey'] = 'blog'; 
  $CONF['CategoryKey'] = 'department'; // default: $CONF['CategoryKey'] = 'category';

This will change the url structure to: http://www.domain.tld/article/item-name

Error 404

Problem:
NucleusCMS returns error 404 for all links after FancyURL2 is installed.

Solution:

  1. Check that the .htaccess file is uploaded to the right location.
  2. Check that the URL in the blog settings is correct
  3. Check that the CONF[’Self’] in the index.php and config.php is correct.
  4. The addition of “RewriteBase /” as the first line in .htaccess per the suggestion for Error 500 below may cause an Error 404 in some installations.

Error 500

Problem:
NucleusCMS returns error 500 for all links after FancyURL2 is installed.

Solution:

  1. Check that the .htaccess file has RewriteBase / on the first line.
RewriteBase /
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?virtualpath=$1 [L,QSA]
RewriteRule ^(item/[^/]+)/.*$ /$1 [R=301,L] 
</IfModule>

Wishlist

Bugs

  • The parameter startpos is getting lost so that the inbuild pagaination of Nucleus CMS doesn’t work.

History

  • Version 0.1, released 2006-11-10
    • initial release
  • Version 0.2, released 2007-01-07
    • table plug_urls is also included in the database backup
    • categories are also in the look up table to support characters from other languages
    • option added: whether the date is included in item urls or not
  • Version 0.3, released 2007-06-13
    • compatibility mode added which support old style fancy urls: item/1234, member/1234, category/1234 and blog/1234
    • use the global variable $virtualpath for Nucleus version 3.3 and higher
  • Version 0.3eh 2007-06-18 Edmond Hui (http://edmondhui.homeip.net/blog)
    • add utf-8/Chinese (un)friendly url fallback
    • fix category generateURL handling
    • subscribe to delete event to cleanup mapping table on item and category delete
  • Version 0.4 2007-12-02 Kai Greve (http://kgblog.de):
    • change the way in which encoding is interpreted and add a new option for the encoding to avoid problems if mb_detect_encoding fails
    • Overwerite the clearOptionValueCache function of the parent class (NucleusPlugin) because it has a bug: doesn’t set the variable plugin_options to zero (needed to refresh the url table after the PostPluginOptionsUpdate event)
    • Repair the code that counts the entries with the same title that are published before
  • v0.6 2009-03-21 Kai Greve (http://kgblog.de):
    • fixed bug: if an item is updated the category with the same ID isn’t changed
    • changed formatting and more comments

Plugin Review

  • NP_FancierURL2 version 0.3 works with Nucleus CMS version 3.31 - 2007-11-03 kg
  • NP_FancierURL2 version 0.6 works with Nucleus CMS version 3.41 - 2009-03-21 kg
  • NP_FancierURL2 version 0.6 works with Nucleus CMS version 3.51 - 2009-11-21 wp
 
fancierurl2.txt · Last modified: 2009/11/21 22:22 by willyp