Plugin: LMFancierURL

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

General plugin info
Author:Leo
Current version:3.0.2
Download:NP_LMFancierURL_v302.zip
Support: Plugin comments or forum thread
Compability:Nucleus CMS 3.50, NP_LMURLParts 1.1.1

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.

In version 3 of the plugin was custom base URLs introduced. With this functionality can you make the different blogs in a Nucleus installation has different domains and/or Nucleus directories. It is also possible to set the custom base URL for a blog to also identify the blog. With this option set will not a blog URL part be needed in the URL to any pages in the blog.

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, xml-rss2.php and atom.php files which you can find in your Nucleus installation directory. Change the value of the $CONF['Self'] variable from the default value (the name of the php-file) to the URL that points to your Nucleus installation 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.
  • After you have done the configuration for the NP_LMFancierURL plugin, update the URL in the Blog settings for each blog to the new fancier URL for the blog.

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 or later 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 or later 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.
  • Redirect to default blog index page - Choose if the plugin should redirect to the URL of the default blog index page when a base URL is used. The redirect used is a temporary redirect. Set this option to yes if you want only 1 valid URL for the index page of the default blog. This option is only valid when Hide /blog/name for default blog option is set to no. Example: If this option is set to yes will the http://yourdomain.com/directory URL be redirected to the http://yourdomain.com/directory/blog/name URL. If the option is set to no will both URLs show the index page of the default blog, and you will have 2 different URLs that shows the same content.

The NP_LMFancierURL plugin has also options on the blog level. The default value for most 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.
  • Include blog urlpart in member link - Choose if a blog urlpart should be included in member links on this blog. Set this option to yes if you have blogs with the same base URL (default or custom), but with different skins. This ensures that any member page linked from this blog will be shown in the skin of this blog.

Custom base URLs is set up on the plugin admin page. The custom base URL options for a blog are:

  • Custom Base URL - The custom base URL for this blog. It must be an URL that is different from the default base URL for your nucleus installation directory that you have set in the index.php file. The custom base URL must be a valid URL that points to the same Nucleus installation directory as the default base URL. As the default base URL, must the custom base URL be registered without the ending slash. Example of a custom base URL: http://yourotherdomain.com/yourNucleusDirectory
  • Enabled - Is custom base URL handling enabled for this blog.
  • Default Blog - Is this blog the default blog for this custom base URL. If you have blogs that have the same custom base URL, you should set one of them as the default blog.
  • Identifies Blog - Is the custom base URL of this blog used to identify the blog. If this option is set to yes is no blog urlpart used in links to pages on this blog. No other blogs on the Nucleus site can use the same custom base URL as this blog.

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.

The main purpose of the custom base URL functionality is to be able to set up blogs with different domians on the same Nucleus installation. Each custom base URL must point to the same directory on the web-server as the default base URL. The default base URL is the URL you assigned to the $CONF['Self'] variable in the index.php file.

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.

Plugin support

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. 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.

NP_ShowBlogs

The NP_ShowBlogs plugin can be used together with the NP_LMFancierURL plugin without extra set up.

NP_TechnoratiTags

If you want to use the NP_LMFancierURL plugin together with the NP_TechnoratiTags plugin you have to do the following:

  • Use the NP_LMFancierURL rewrite rules and set up the $CONF['Self'] variable as described in the NP_LMFancierURL Installation documentation.
  • Do not make a tags.php file as described in the NP_TechnoratiTags documentation.
  • Make a skin called tags as described in the NP_TechnoratiTags documentation where the main index includes the <%TechnoratiTags(tagsearch)%> skin variable.

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.1. 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.
  • v3.0.0 2012-07-29: by Leo (http://www.slightlysome.net)
    • Possible to set a custom base URL for each blog. This will let you host blogs with different domains on the same Nucleus installation.
    • Option to redirect to the URL of the default blog index page when a base URL is used.
    • Option to include blog in generated member links to ensure the correct skin is used on the member page.
    • Fixed problem where the urlpart of a new item got a -2 postfix if the item was auto saved to draft before it was saved.
    • Fixed problem with search in other blogs than the default blog.
    • Support for other plugins to manipulate parameters when generating URLs, and to get URL parse result.
    • Requires version 1.1.1 of the NP_LMURLParts plugin.
  • v3.0.1 2013-05-20: by Leo (http://www.slightlysome.net)
    • Changes for PHP 5.4.
  • v3.0.2 2014-02-15: by Leo (http://www.slightlysome.net)
    • Support for the NP_TechnoratiTags plugin.

Download

Download NP_LMFancierURL v3.0.2. The latest version of the NP_LMFancierURL plugin can be downloaded from the NP_LMFancierURL plugin page.

The latest version of the NP_LMURLParts plugin can be downloaded from the NP_LMURLParts plugin page.


Comments

  • Posted by Tim Harrison on 14/02-14 22:44.

    This plugin seems to interfere with NP_TechnoratiTags, making the links to the "tags" fail (resulting in "skin error") and generating a blank result when attempting the "old-fashioned" hand-entered URL of domain.com/tags.php?tag=some+tag.

    Any thoughts on how to fix?

  • Posted by Leo on 15/02-14 18:08.

    I have made an update to the plugin, so that it ignores the NP_TechnoratiTags additions to the URL.

    My NP_LMLabels plugin may be an better option for tagging/labeling items than NP_TechnoratiTags. :)

  • Posted by Lord Matt on 17/09-14 17:48.

    Is it possible to have the URL parser set the category ID without passing the category in the URL and without the category being added to the URL at any time.

    Such that:
    example.com/myblog/my-item == example.com/index.php?catid=1&itemid=2&blogid=3

  • Posted by Leo on 17/09-14 23:26.

    Lord Matt: Is it possible to have the URL parser set the category ID without passing the category in the URL and without the category being added to the URL at any time.
    No, but I have added this to my ToDo list.

  • Posted by Tim on 19/12-14 07:40.

    Hey Leo,

    Thanks for the help last winter with this, it all worked out then, but in trying to correct a rather large kerfuffle with that same site I've had to reinstall this plugin and it is once again screwing up the tags. Apparently what is in your zip file is now version 3.01 rather than 3.02?

  • Posted by Tim on 19/12-14 11:37.

    Addendum: I see this version of the file DOES have technoratitags related code in it around line 705, so maybe this is 3.02 despite being listed as 3.01. However, it's not working and I get the same "skin error" page no matter what when using a tag. Any thoughts?

  • Posted by Tim on 20/12-14 11:31.

    Further addendum: I got around the problem with an .htaccess hack. Thanks anyway!

Add Comment

Spam and off topic comments will be deleted.

Allowed BBCode:[b] [i] [u] [s] [color=] [size=] [quote] [code] [email] [url]