NP_LMFancierURL.php

The NP_LMFancierURL plugin provides the posibility to use search engine optimized URLs for a Nucleus CMS blog site.

General Plugin info
Author: Leo
Current Version: v2.1.1
Download: NP_LMFancierURL_v211.zip
Code:
Demo: http://www.slightlysome.net and http://www.slightlysome.net/test
Forum Thread: here

Plugin overview

The NP_LMFancierURL plugin provides the posibility to use search engine optimized URLs for a Nucleus CMS blog site. A URL friendly version of each blog name, member name, item title, category name and extra skin name is generated by the plugin. These URL friendly values are then used when the URL for blogs, members, categories, items and extra skin is parsed or generated. These values can be edited by the blog administrator or the site super administrator.

This plugin was originally made to replace the NP_FancierURL2 plugin that have several bugs and problems. Version 2 of the NP_LMFancierURL plugin was rewritten from scratch to be able to include the new version 2 features.

The plugin offers 3 different URL schemes. What URL scheme to use can be configured globaly for the site or for each blog.

Available URL schemes are:

  • Fancier - This is the old URL scheme used in NP_FancierURL2. URLs are build up with a keyword/value structure. The keywords and values used are editable. Example: www.example.com/blog/myblog/item/an-item-title
  • Compact - This is a new URL scheme introduced in version 2 of NP_FancierURL plugin. It's like Fancier URL scheme, but drops the keywords from the URL. The makes the URL more compact. The values used are editable. Example: www.example.com/myblog/an-item-title
  • Classic - This is simmular to the URL scheme you get when you activate FancyURL in Nucleus configuration, but don't install a FancyURL plugin. URLs will be build up as with the Fancier URL scheme, but will use interal id numbers instead of text values. The keywords used are editable. Example: www.example.com/blog/1/item/53

In addition to the 3 URL schemes is it possible to use freeform item URL parts. With freeform item URL parts can you enter the URL part that you want to use to identify an item in a blog. Unlike normal URL parts can a freeform item URL part consist of one or more / character. With this you can simulate directory structures more freely with freeform item URL than with normal URL parts. Templates can be used to automatically generate freeform item URL parts from the item data.

The NP_LMFancierURL plugin uses a helper plugin for handling the URL part values. This plugin is called NP_LMURLParts and is used to store and edit the URL part values to be used in the generated URLs. This plugin must be installed before the NP_LMFancierURL plugin can be installed. The NP_LMURLParts plugin can be downloaded from the NP_LMURLParts plugin page.

Installation

  • Before you can install the NP_LMFancierURL you must install the NP_LMURLParts helper plugin.
  • Upload the NP_LMFancierURL.php file and the lmfancierurl directory from the zip file to the Nucleus CMS plugins directory (nucleus/plugins) on your web server.
  • Go to the Plugins page in the admin area. You should be able to select the plugin in the dropdown list under the “Install New Plugin” section and press the “Install Plugin” button.
  • You now need to make some changes to your Nucleus CMS installation.
  • Create a ”.htaccess” file to the root directory of your Nucleus CMS installation with the following contents:

<IfModule mod_rewrite.c>

            RewriteEngine on
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php?virtualpath=$1 [L,QSA]
    </IfModule>
  • Edit the “index.php” file which you can find in your root directory. Change value of the “CONF['Self']” from the default value (”'index.php'”) to the URL that points to your root directory (without the ending slash), for example:
   $CONF['Self'] = 'http://yourdomain.com/yourNucleusDirectory'; 
  • Edit the “xml-rss2.php” file which you can find in your root directory. Change value of the “CONF['Self']” from the default value (”'xml-rss2.php'”) to the URL that points to your root directory (without the ending slash), for example:
   $CONF['Self'] = 'http://yourdomain.com/yourNucleusDirectory'; 
  • Enable the 'Fancy URLs' in the Nucleus admin area, you can find this setting under Management > Configuration.

Upgrade

If you upgrade from a V1 version of the NP_LMFancierURL plugin or from NP_FancierURL2 you have to uninstall the old plugin before you can install this version of NP_LMFancierURL using the normal install procedure.

If you upgrade from a V2 version of the NP_LMFancierURL plugin, use the following upgrade procedure:

  • Take a backup of the current plugin files. You will need these if you want to rollback to the previous version after the upgrade.
  • Take a backup of the database used for you Nucleus installation.
  • Replace the old plugin files with the new ones by uploading the NP_LMFancierURL.php file and the lmfancierurl directory from the zip file to the Nucleus CMS plugins directory (nucleus/plugins) on your web server. Do not uninstall the plugin.
  • Go to the Plugins page in the admin area and press the “Update subscription list” button.
  • If a plugin data upgrade is needed, will an upgrade plugin data option be available on the NP_LMFancierURL plugin admin page. Choose this option to upgrade the plugin data.
  • After the plugin data upgrade has been performed may a rollback option and a commit option be available on the NP_LMFancierURL plugin admin page. Not all upgrades support the rollback and commit option.
  • If you are not pleased with the new version of the plugin you may use the rollback option to rollback the plugin data upgrade. After the rollback of the plugin data upgrade you have to replace the new plugin files with the old plugin files.
  • If you are pleased with the new version of the plugin you should use the commit option to commit the plugin data upgrade. After the commit of the plugin data upgrade will any rollback and commit options disappear.

Since the URLs generated by V2 versions of NP_FancierURL is not guarantied to be equal to the URLs generated in earlier versions, or the URLs generated by NPFancierURL, you may want to use the NP_LMRedirectToItem plugin to be able to keep old item URLs valid. You must install the NP_LMRedirectToItem plugin and generate the redirects before you uninstall the old fancier URL plugin.

Configuration

The NP_LMFancierURL plugin has the following options on the global level:

  • Delete NP_LMFancierURL data on uninstall? - Choose if all data should be deleted when the plugin is uninstalled.
  • Hide /blog/name for default blog - Choose if blog identification should be included in URLs generated for content on the default blog.
  • Select global URL scheme - Choose which URL scheme to be used globally. Default value is to use Fancier URL scheme.
  • Include the date in URLs for items - Choose if month/date is to be included in generated item URLs for the site. (Example: www.example.com/blog/myblog/item/2011-06-20/item-title)
  • Include the category in URLs for items - Choose if the category of an item is to be included in generated item URLs.
    • Always: Will always include the item category in the generated URL.
    • System Decide: Will only include the item category in the generated URL if the category is selected. This is the default value. With this option set is there more than one URL that points to an item (with and without category). To avoid duplicate item entries in search engines you may want to set up a canonical link in the item page <head> section (see the usage section below).
    • Never: Never include the item category in the generated URL.
  • Parse the category in URLs for items - Choose if the category is to be parsed when parsing item URLs. When the category is parsed should next item and previous item links generated on the item page link to an item in the same category as the current item.
    • Always: Will always parse any category in the item URL. This is the default value.
    • Never: Will not parse any category in the item URL.
  • Allow freeform item URL part input on - Choose when a input field for the freeform item URL part should be available.
    • Never: Never show the input field for the freeform item URL part. This is the default value.
    • Item Create: Show the input field for the freeform item URL part on item create page only.
    • Item Create+Update: Show the input field for the freeform item URL part on both item create and item update page.
  • Freeform item URL part template - Set up template for generating freeform item URL part. The template uses variables that will be substituted with item data. If no URL part template is given will the following template will be used: ”/%cat%/%itemid5%/%yy%-%mm%-%dd%/%title%”. The variables that can be used is:
    • ”%title%“: Title of the item.
    • ”%itemid%“: Item id of the item. Use ”%itemid3%”, ”%itemid4%”, ”%itemid5%” or ”%itemid6%” to show the item id as a zero prefixed string of 3, 4, 5 or 6 digits.
    • ”%cat%“: Name of the category the item belongs to.
    • ”%yy%“: Year the item was posted as a 2 digit number.
    • ”%yyyy%“: Year the item was posted as a 4 digit number.
    • ”%mm%“: Month the item was posted as a 2 digit number.
    • ”%dd%“: Day of the month the item was posted as a 2 digit number.
  • Use freeform item URL part template on - When should the freeform item URL part template be used.
    • Never: Never generate a freeform item URL part from the template. This is the default value.
    • Item Create: Generate a freeform item URL part from the template when a new item is created only. If Allow freeform item URL part input on is set to show a input field for the freeform item URL part, will the freeform item URL part only be generated from the template if the input field for the freeform item URL part was empty.
    • Item Create+Update: Generate a freeform item URL part from the template both when a new item is created or an existing item is updated. If Allow freeform item URL part input on is set to show a input field for the freeform item URL part, will the freeform item URL part only be generated from the template if the input field for the freeform item URL part was empty.

The NP_LMFancierURL plugin has also options on the blog level. The default value for all blog options is to use the value of the globally defined options. See the global options description for a description of the options values. Available blog options are:

  • Select blog URL scheme - Choose which URL scheme to be used by the blog.
  • Include the date in URLs for items - Choose if month/date is to be included in generated item URLs for the blog.
  • Include the category in URLs for items - Choose if the category of an item is to be included in generated item URLs for this blog.
  • Parse the category in URLs for items - Choose if the category is to be parsed when parsing item URLs for this blog.
  • Allow freeform item URL part input on - Choose when a input field for the freeform item URL part should be available.
  • Freeform item URL part template - Set up template for generating freeform item URL part.
  • Which freeform item URL part template to use - Select if globally defined template or blog defined template should be used to generating freeform item URL parts.
  • Use freeform item URL part template on - When should the freeform item URL part template be used.

Usage

After you have installed the NP_LMFancierURL plugin and set the options you are all set, and don't need to do anything unless you want to customize keywords or URL parts.

If you change an item title or name of any other blog object will also the URL part for this object be changed to reflect the new title or name. If you want to use a custom URL part for a blog object or lock the URL part so any changes to the blog object doesn't update the URL part you can use the NP_LMURLParts plugin admin page. See the NP_LMURLPart plugin help page for more information on using the NP_LMURLParts plugin admin page. You can also use the NP_LMURLParts plugin admin page to edit the URL part keywords that NP_LMFancierURL should use.

Because of a shortcoming in the Nuclues core can the NP_LMFancierURL plugin not automatically catch special skin parts that are added to or removed from a skin after the plugin is installed. After you have added or removed a special skin part must you use the “Update special skin part URL parts” function on the NP_LMFancierURL admin page to update the URL parts stored in the NP_LMURLParts plugin.

When you change URL scheme, will old URLs to blog objects not be valid anymore. If you want to keep the old item URLs valid you can use the NP_LMRedirectToItem plugin to redirect the old URLs to the new ones.

When there is more than one URL that points to one blog item is it a chance that this blog item get duplicate entries in search engines. To avoid this can a <link> tag with rel=“canonical” in the <head> section of the item page be used to point to the unique URL to use for the blog item. The NP_LMFancierURL plugin has a skin variable to help you add a canonical URL for blog items. Add the following to the <head> section of the item skin to set the canonical URL for the blog item:

<link rel="canonical" href="<%LMFancierURL(canonicalitemlink)%>" />

When you change URL scheme or change the URL part for an item will the item get a new canonical URL. If you want to notify search engines of the URL change you can use the NP_LMRedirectToItem plugin to set up a redirect for the old item URL.

With freeform item URL parts you can freely specify the content of the item URL. The freeform item URL part must always start with a / character and is relative to the blog URL. Freeform item URL parts are independently of the configured URL scheme.

When a freeform item URL part is registered for an item, will the freeform item URL part always be used to generate the URL for the item. If a freeform item URL part is used to generate an item URL will not urlparts for other blog objects besides the item be added to the URL. URL parts for other blog object can be added manually to the freeform item URL part, but they can not be parsed. Freeform item URL parts is by default disabled.

Support and Bug reports

For additional support and/or bug reports please use the Nucleus forum plugin announce thread or the plugin page comment section.

Some plugins adds their own parts to generated URLs. These plugins must either use NP_LMURLParts to register the values used, or support for these plugins must be added to the NP_LMFancierURL plugin. If not will the NP_LMFancierURL plugin return a 404 HTML error when the URL includes parts it don't know. So far has support for the NP_ShowBlogs plugin been added to NP_LMFancierURL. If you use plugins that adds their own parts to the URL that are not supported, please report about these plugins in the Nucleus forum plugin announce thread or in the plugin page comment section.

Compability

This version of the NP_LMFancierURL is tested against version 3.64 of Nucleus CMS. The minimum version of Nucleus CMS needed for using this plugin is 3.50 and the minimum version of the NP_LMURLParts plugin needed by this plugin is version 1.1.0. The mod_rewrite module must be enabled on the web server.

Version History

  • v1.0.0 2011-02-20: by Leo (http://www.slightlysome.net)
    • Based on NP_FancierURL2 v0.6 by various authors.
    • The parameters in the generated URL is now in a fixed order.
    • Fix: The “extra” parameters are now included in the generated URL with the correct defined parameter names.
    • Fix: Handling of categories in a mulitblog environment.
    • Fix: Handling of categories in combination with archive and archives parameters.
    • The title part of item URLs is now unique for a blog. Also changed handling of duplicate titles.
    • The member name in member URLs is now made URL-friendy because it could include spaces and mixed case.
    • New option to make /blogid/name part of generated URLs optional for the default blog.
    • Workaround for bug in Nucleus core when parsing /specical/name URLs.
    • Fix: Error handling when URL is referring to unknown blogs, items, categories and members.
  • v2.0.0 2011-06-27: by Leo (http://www.slightlysome.net)
    • Rewritten from scratch.
    • 2 new URL schemes: Compact and Classic. URL schemes are configurable on site and blog level.
    • All URL parts are editable.
    • Uses NP_LMURLParts plugin to handle and edit URL parts and keywords. The editing is done in the NP_LMURLParts plugin admin page. A user can edit the parts and keywords for the blogs he is admin for. The superadmin can edit global parts and keywords and the parts and keywords for all blogs.
    • Keywords are configurable on site and blog level.
    • Support for extra skin parts.
    • Better handling of non ASCII 7-bit characters when making URL friendly text values.
    • How to handle category in item URLs is configurable on site and blog level.
    • Archive URL values are added to the plugin and are also editable. This mean you can have custom URL parts for each month and date used in the archives.
    • Will return a 404 not found HTML error using the error skin when the URL contain unknown parts.
    • Item skinvar that return a canonical item URL that can be used as canonical link in item page <head> section.
  • v2.0.1 2011-08-06: by Leo (http://www.slightlysome.net)
    • Fixed problem with identifying used url scheme when parsing an url.
  • v2.1.0 2011-08-27: by Leo (http://www.slightlysome.net)
    • Freeform item URL parts.
    • Implemented my suggested plugin data upgrade handling. The plugin does the upgrade handling by itself, and is not dependent of any core changes or other handling plugins.
    • Implemented my suggested AdminPluginNotification event in the plugin. Used AdminPrePageFoot event to trigger the AdminPluginNotification event. Will show the notification on the bottom of the admin pages instead on the top as suggested. Used for notification on upgrade handling status and NP_LMURLParts version status.
    • Admin page with possibility to rebuild URL parts and show help page.
  • v2.1.1 2011-09-17: by Leo (http://www.slightlysome.net)
    • Added function on the admin page to update special skin part URL parts. Because the plugin can't catch special skin parts being added to a skin or removed from a skin, must this function be used after a special skin part has been added to a skin or removed from a skin.
    • Uses Nucleus admin page notification to inform if a special skin part URL parts update is neccesary.

Download

Download NP_LMFancierURL v2.1.0. The latest version of the NP_LMURLParts plugin can be downloaded from the NP_LMURLParts plugin page.

lmfancierurl.txt · Last modified: 2012/02/27 20:37 by ftruscot
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki