NP_CustomURL provides a Fancy URL scheme that gives a lot of configurability in setting the URLs on your site. English is a supported language for the plugin. I use it on http://r2strategypartners.com - ftruscot

:np_customurl.gif

General Plugin info
Author: shizuki
Current Version: 0.3.7FIX3 (2009/03/17)
Download: http://japan.nucleuscms.org/bb/download/file.php?id=908
Source: NP_CustomURL.php
Forum Thread: http://forum.nucleuscms.org/viewtopic.php?t=20428
Japanese Wiki: http://japan.nucleuscms.org/wiki/plugins:customurl
Translation of Japanese wiki: Google Translation
Japanese Forum: http://japan.nucleuscms.org/bb/viewtopic.php?t=2236

Features

  • You can freely customize the URLs of your website
  • Easy to install
  • Great with multiple blogs
  • Generating the RSS feed no longer requires xml-rss2.php/atom.php or rss1.xml/rss2.xml/atom.xml, as URLs become static and easy to access
  • Files related to some plugins (NP_ExtraSkinJP, etc.) are eliminated, and there is less clutter in the root directory
  • TrackBack URLs can be shorter
  • When an irregular URL is accessed, an appropriate response header is returned; this is not related to how URLs look but rather to SEO
  • Your URLs can have a shallow, simply expressed hierarchy, which also seems to favor SEO

Installation

  1. Download and unzip NP_CustomURL using the link above. Upload the NP_CustomURL.php file and the customurl directory to the nucleus/plugin directory on your server.
  2. Set URL mode to “Fancy” in Admin > Configuration. Do not follow the instructions for “How to activate fancy URLs”.
  3. Add the following code to an .htaccess file in the root of your installation. Or add a new .htaccess file, checking to make sure that you are not overwriting a hidden .htaccess file.
    RewriteEngine on
     RewriteCond% {REQUEST_FILENAME}!-F
     RewriteCond% {REQUEST_FILENAME}!-D
     RewriteRule ^(.*)$ index.php? Virtualpath =$1 [L, QSA]

    Using a conditional mod rewrite may avoid a 500 error if a necessary module isn't installed. Apache offers mod_rewrite dcoumentation.

  4. Open index.php (located in the root of your installation) and revise the code to read as follows:
    <?
     $ CONF = array ();
     $ CONF ['Self'] ='';
    
     include ('. / config.php');
    
     selector ();
    
     ?>
  5. Use the Nucleus Admin GUI to register the NP_CustomURL plugin into Nucleus. When installed, click the Update Subscription List button.
  6. For help, review the help files bundled with the installation and accessible from admin > Plugins.

How To Use This Plugin

Assign a URL for each blog category or item. With this, your blog or CMS will have a regular directory hierarchy.

You may set a custom path for each article you add to your blog. When adding an item, scroll down to Extra Plugin Options. Using this setting may overriding other settings, so be careful. This is optional.

Plugin Options

You can modify default prefixes and directory names in Edit Options on the plugins page.

Default Virtual Directory Filenames

Below are the default filenames for the virtual directory created by CustomURL:

Virtual File Directory Name Default
Virtual Blog directory name Blog shortname
Virtual category directory name category_catid
Virtual subcategory directory name subcategory_subcatid
Virtual file name of member login-name.html
Virtual Archive List directory name archives
Virtual Archive directory name archive
Virtual file name of item item_itemid.html

Change Displayed URL

Use the plugin admin section (accessible through the plugin page or quick links) to change the displayed URL for each blog item or category. On the main admin page for the plugin, click on [Manage item URI] or [Manage category URI]. On the next screen, type your change into the appropriate box under Access path and click Update Settings.

Supports the NP_MultipleCategories plugin for subcategories (for infinite hierarchy).

SkinVar

The skinvar associated with NP_CustomURL is <%CustomURL%>.

Output A Link URL

Here is the basic skinvar syntax:

<%CustomURL(i/12/i,LinkTest,LinkTitle)%>

The first parameter:

  • When only a number is written for the first parameter, the number is processed as blogid
  • When the third is omitted, the second is processed as id
  • Only the id can be used to link to the item

The second parameter is LinkText. It specifies the link text. The second parameter is optional.

The third parameter is LinkTitle. LinkTitle specifies the title attribute of the <a> tag. If this parameter is omitted, LinkText will be used for the title attribute.

Examples

<%CustomURL(,,)%>

  • The current blog URL is printed without a link

<%CustomURL(,Home Page,)%)

  • Home Page is displayed as a link and title attribute

<%CustomURL(,Home Page,Click For Home Page)%)

  • Home Page is displayed as a link and Click For Home Page is displayed as title attribute

<%CustomURL(i/12/i,,)%>

  • Setting only the first parameter outputs text only with no link

<%CustomURL(12,LinkTest,LinkTitle)%>

  • The number is processed as itemid, and the item is outputted in a link

<%CustomURL(i/12,LinkTest,LinkTitle)%>

  • The second is processed as item id

Examples are still being tested and feedback is appreciated. Make corrections right here in this wiki or post to the http://forum.nucleuscms.org/viewtopic.php?t=20428/English forum and I'll make changes here.

TemplateVar

Use parameters with <%CustomURL%> to create trackbacks, a method for bloggers to request notification when somebody links to one of their documents. Trackbacks lost popularity after spammers discovered how to abuse them, although many bloggers still happily use them.

Also see NP_Trackbank. Using NP_Trackback with NP_CustomURL requires editing NP_TrackBack.php.

Trackback Examples

<%CustomURL(trackback)%>

<%CustomURL(trackback,ext)%>

Note: this implementation does not result in a clickable link.

Options

Global Options

:screenshot-customurl-global-options.jpg

  • The name of the path to the virtual archive directory
  • The name of the path to the virtual archivelists directory
  • The name of the path to the member directory
  • URI for new items. The default virtual URL when new items are added.
    • Example.com/item/name-of-item.html can become example.com/yourselection/name-of-item.html.
    • Using <%year%>,<%month%>,<%day%> you can use the date posted.
    • Using QuickLinks > URL CUSTOMIZE > Manage item URI allows you set the URL for any item, overwriting this setting.
  • URI for categories. The default virtual URL for categories.
    • Example.com/category/specific-category can become example.com/yourselection/specific-category
  • URI for subcategories.
  • Delete tables upon uninstall? Yes or no.
  • Do you want to add a shortcut to the quick menu? By default, this is set to yes
  • Behavior to display when a URL is not found
    • 404 Not Found - returns the 404 error page
    • It returns 303 response header

Blog Options

:screenshot-customurl-blog-options02.jpg These options are set for each blog: home > your weblogs > settings > scroll down to Options for NP_CustomURL

  • Output custom URI's in this weblog? Yes activates NP_CustomURL for this blog. Apparently when no is checked, access to the blog using CustomURL-style URIs may still function
  • Does it redirect to the fancy (or custom) URL when the blog is accessed with a normal URL (index.php?itemid=123)?
  • See search words in the URL when the blog is searched? Clicking no will result in a URL similar to example.com/index.php?query=search_string while yes will redirect to example.com/search/search_string
  • The name of the blog to access the virtual directory

Category Options

When publishing a post, a new category may be selected resulting in the following screen:

:screenshot-customurl-category-options03.jpg

Set a virtual URI for this category under Options for NP_CustomURL.

Member Options

Optional: how a member appears in a URL may be set in QuickMenu > Members > Edit:

:screenshot-customurl-member-options-02.jpg

The extension .html will be added automatically.

RSS/ATOM

RSS and ATOM links are as usual:

<%sitevar(url)%>xml-rss2.php?blogid=n
  • Replace n with the blogid
  • If the Nucleus installation has one blog, the number is likely to be 1 and the feed could also be written
    <%sitevar(url)%>xml-rss2.php

    Turn it into a link using html:

    <a href="<%sitevar(url)%>xml-rss2.php">Feed</a>

Feeds can also be written as a SiteVar:

<%blogsetting(url)%>rss2.xml

The follow feed links can be either a SiteVar or blogsetting:

  • RSS1.0 → index.rdf or rss1.xml
    • Installation of the corresponding skin is needed
  • RSS2.0 → rss2.xml
  • ATOM → atom.xml

Modify File Name Or Skin Name Of The Feed

Here is part of the header transmission

case 'rss1.xml':
case 'index.rdf':
case 'rss2.xml':
case 'atom.xml':

When you change the skin name, also change the file name extension and/or skin name in NP_CustomURL.php around line 1406 (or 1904) so that it corresponds to the new skin name:

switch (end($path_arr)) {
case 'rss1.xml':
case 'index.rdf':
	$skinName = 'feeds/rss10';
	break;
case 'rss2.xml':
	$skinName = 'feeds/rss20';
	break;
case 'atom.xml':
	$skinName = 'feeds/atom';
	break;
 }

Support For Other Plugins

NP_CustomURL supports several other plugins. Information is listed below.

NP_Analyze

CustomURL supports NP_Analyze, however this plugin is not recommended due to a security issue.

NP_ContentsList

Apparently the following modifications are not required when using the latest version of NP_ContentsList.

This changes the normal URL output of NP_ContentsList. Line numbers are those of version 2.0. Rewrite from line 467 to use the global function here

// sub category ---

Line 486 is enclosed in a block

$ Subdata ['Sublink'] = Addlinkparams ($ Catdata ['Catlink'], array ($ Subrequest => $ Subdata ['Subcatid']));

The Next line says:

 if ( $CONF [ 'URLMode' ] == 'pathinfo' && $manager -> pluginInstalled ( 'NP_CustomURL' ) ) { if ($ CONF ['URLMode'] == 'pathinfo' & & $ manager -> pluginInstalled ('NP_CustomURL')) {
	$customurls = $manager -> getPlugin ( 'NP_CustomURL' ) ; $ Customurls = $ manager -> getPlugin ('NP_CustomURL');
	$subdata [ 'sublink' ] = $customurls ->_addLinkParams ( $catdata [ 'catlink' ] , array ( $subrequest => $subdata [ 'subcatid' ] ) ) ; $ Subdata ['Sublink'] = $ Customurls -> _Addlinkparams ($ Catdata ['Catlink'], array ($ Subrequest => $ Subdata ['Subcatid']));
} }

And insertion of 465 from line to line 396

// Categories --------------------

After the block, line 466

if ( $CONF [ 'URLMode' ] == 'pathinfo' && $manager -> pluginInstalled ( 'NP_CustomURL' ) ) { if ($ CONF ['URLMode'] == 'pathinfo' & & $ manager -> pluginInstalled ('NP_CustomURL')) {
	$catdata [ 'catlink' ] = createCategoryLink ( $catdata [ 'catid' ] ) ; $ Catdata ['catlink'] = createCategoryLink ($ catdata ['catid']);
} }

Last line 348

$ Data ['self'] = $ data ['blogurl'];

Front row

if ( $CONF [ 'URLMode' ] == 'pathinfo' && $manager -> pluginInstalled ( 'NP_CustomURL' ) ) { if ($ CONF ['URLMode'] == 'pathinfo' & & $ manager -> pluginInstalled ('NP_CustomURL')) {
    $data [ 'blogurl' ] = createBlogidLink ( $data [ 'blogid' ] ) ; $ Data ['blogurl'] = createBlogidLink ($ data ['blogid']);
} }

Add you're done.

Note: Implementation of this translation has not been tested.

NP_TagEX

When both NP_CustomURL and NP_TagEX are installed, URLs that include tags do not display correctly. The following modifications allow correct URL formation.

creatTagLink()

Find:

return addLinkParams($link, $linkparams);

And insert the following code directly before it:

global $manager;
if ($manager->pluginInstalled('NP_CustomURL')) {
    $customurls = $manager->getPlugin('NP_CustomURL');
    $link = 'tag/' . $ready . $sep . $this->_rawencode($tag);
    return $CONF['BlogURL'] . '/' . $customurls->_addLinkParams($link, $linkparams) . '/';
}

With this change, the tag will appear at the end of the URL.

NP_TrackBack

Trackbacks from other websites increase with the following changes from around the 2479th line of NP_Trackback:

function handleLocalPing($itemid, $title, $excerpt, $blog_name, $ping_url){ global $manager;

Between

} elseif ( preg_match("/itemid=([0-9]+)/",$ping_url,$idnum) ){
			$tb_id = intval($idnum[1]);
		}

And

if ((!$manager->existsItem($tb_id,0,0)) && ($this->getOption('CheckIDs') == 'yes'))
			return _ERROR_NOSUCHITEM . "[ $tb_id ]";

The following code is inserted:

		if ($manager->pluginInstalled('NP_CustomURL')) {
			$plugin =& $manager->getPlugin('NP_CustomURL');
			$tmp_url = parse_url($ping_url);
			$$tmp_url['path'] = trim($tmp_url['path'], '/');
			$path_arr = explode("/", $$tmp_url['path']);
			$i = count($path_arr) - 1;
			if (substr($path_arr[$i], -5) == '.html') {
				$item_name = $path_arr[$i];
				$trush = array_pop($path_arr);
			} elseif (substr($path_arr[$i], -10) == '.trackback') {
				$item_name = (substr($path_arr[$i], 0, -10)) . '.html';
			}
			$trush = array_pop($path_arr);
			$blog_url = $tmp_url['scheme'] . '://' . $tmp_url['host'] . '/' . implode('/', $path_arr);
			$blog_url = preg_replace('|[^a-zA-Z0-9-~+_.?#=&;,/:@%]|i', '', $blog_url);
			$tbbid = quickQuery('SELECT bnumber as result FROM '.sql_table('blog').' WHERE burl = "'.$blog_url.'"');
			$tbbid = intval($tbbid);
			if (!empty($tbbid) && $plugin->getBlogOption(intval($tbbid), 'use_customurl') == 'yes') {
				$item_name = preg_replace('|[^a-zA-Z0-9-_.]|i', '', $item_name);
				$que = 'SELECT obj_id as result FROM %s WHERE obj_param = "item" AND obj_name = "%s" AND obj_bid = %d';
				$tbiid = quickQuery(sprintf($que, sql_table('plug_customurl'), $item_name, intval($tbbid)));
				if (!empty($tbiid)) $tb_id = intval($tbiid);
			}
		}

It can handle both /trackback/item_123.html and /item_123.trackback.

Tips & Tricks

To include the category name in the URL

Not only for how it looks, but may also prevent search engines from counting the same page multiple times and creating a duplicate content issue.

<%categorylink%><%CustomURL(path)%>

Duplicate Content Issues

Even with this plugin active, index.php?itemid=xxx access is possible. This may result in duplicate content issues with search engines. To limit such issues, add the following to robots.txt:

User-agent: *
Disallow: /index.php?*
User-agent: Googlebot
Noindex: /index.php?*

Plugin review

  • NP_CustomURL 0.3.7 works with Nucleus CMS version 3.31 - 2007-11-02 ftruscot
  • In translating this wiki page and testing CustomURL, I used Nucleus version 3.64 and NP_CustomURL version 0.3.7FIX2-3 without issues. (I did not test NP_CustomURL in conjunction with other plugins.) - 2011-05-13 tcc
  • Plugin dependency reported by adityak: If you have multiplecategories You must update it to the latest version - 0.5.1j (maintained here : http://japan.nucleuscms.org/wiki/plugins:multiplecategories. This will avoid failure in customurl.

Wish List

  1. Create more examples
  2. Use this wiki page to rewrite the included help file, then create an English language download with English language help

Bugs

No bug reports are listed on the main wiki page, however there may be plugin dependencies or conflicts that have not been documented.

History

For version history, see Japanese Wiki

customurl.txt · Last modified: 2011/05/16 19:02 (external edit)
 
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