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
| 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 |
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.
<?
$ CONF = array ();
$ CONF ['Self'] ='';
include ('. / config.php');
selector ();
?>
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.
You can modify default prefixes and directory names in Edit Options on the plugins page.
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 |
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).
The skinvar associated with NP_CustomURL is <%CustomURL%>.
Here is the basic skinvar syntax:
<%CustomURL(i/12/i,LinkTest,LinkTitle)%>
The first parameter:
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.
<%CustomURL(,,)%>
<%CustomURL(,Home Page,)%)
<%CustomURL(,Home Page,Click For Home Page)%)
<%CustomURL(i/12/i,,)%>
<%CustomURL(12,LinkTest,LinkTitle)%>
<%CustomURL(i/12,LinkTest,LinkTitle)%>
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.
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.
<%CustomURL(trackback)%>
<%CustomURL(trackback,ext)%>
Note: this implementation does not result in a clickable link.
These options are set for each blog: home > your weblogs > settings > scroll down to Options for NP_CustomURL
When publishing a post, a new category may be selected resulting in the following screen:
Set a virtual URI for this category under Options for NP_CustomURL.
Optional: how a member appears in a URL may be set in QuickMenu > Members > Edit:
The extension .html will be added automatically.
RSS and ATOM links are as usual:
<%sitevar(url)%>xml-rss2.php?blogid=n
<%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:
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;
}
NP_CustomURL supports several other plugins. Information is listed below.
CustomURL supports NP_Analyze, however this plugin is not recommended due to a security issue.
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.
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.
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.
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)%>
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?*
No bug reports are listed on the main wiki page, however there may be plugin dependencies or conflicts that have not been documented.
For version history, see Japanese Wiki