Nucleus Core

Login!
Register as a new userLost password?

for Project:

This is the tracker for the Core of the Nucleus CMS-project (Nucleus CMS Website)

FS#12 — generate-url-event

Attached to Project— Nucleus Core
Opened by Jeroen Budts (TeRanEX) - Wednesday, 09 March 2005, 12:28AM
Last edited by Wouter Demuynck (karma) - Thursday, 28 July 2005, 04:33PM
Feature Req.
Plugin API
CLOSED
Wouter Demuynck
All
Low
Normal
CVS
3.3
Undecided
100%
generate-url-event: this was already discussed at the devlist and will enable plugins to alter look of url’s generated by Nucleus  NP_ReplaceURL.zip   NP_ReplaceURL2.zip   NP_ReplaceURL3.zip
This task depends upon

This task blocks these from closing
Closed by  Edmond Hui (ehui)
Date:  Thursday, 05 July 2007, 05:23PM
Reason for closing:  Implemented
Additional comments about closing:  tested and going into 3.3
Comment by Wouter Demuynck (karma) - Tuesday, 26 July 2005, 02:38PM

Maybe this can also be added to the core: <a href="http://karma.nucleuscms.org/item/93">Nucleus Hack: Custom Fancy URL Keywords</a>


Comment by Wouter Demuynck (karma) - Thursday, 28 July 2005, 04:32PM

I committed a version to CVS which adds GenerateURL and ParseURL events, and allows custom keywords (as described in the hack linked from my previous comment)

Events:

<b>ParseURL</b>

- $data['type'] => 'item', 'member', ... (= name of the stub file through which the request entered)
- $data['info'] => contains serverVar('PATH_INFO')
- $data['completed'] => when a plugin succeeded in parsing the URL, it should set $data['completed'] to true. A plugin should also check for $data['completed'] at the start of the event_ParseURL method and return when another plugin already parsed the URL.

<b>GenerateURL</b>

- $data['type'] => 'item', 'member', ... (NOT the stub names in this case!)
- $data['params'] => array. e.g. for 'item' links this is array('itemid' => 1234, 'extra' => array())
- $data['url'] => when the plugin manages to generate an URL, it should be written into this variable
- $data['completed'] => works in the same way as with ParseURL: set to true when an URL as been generated, skip URL generation when $data['complete'] == true on method entrance

Data in $data['params'] for GenerateURL: (where $params = $data['params'])

- 'item' type: $params['itemid'], <span style="color:red">$params['title'] <em>(not always present!)</em>, $params['timestamp'] <em>(not always present!)</em></span>
- 'member' type: $params['memberid'], <span style="color:red">$data['name'] <em>(not always present!)</em></span>
- 'category' type: $params['catid'], <span style="color:red">$data['name'] <em>(not always present!)</em></span>
- 'archivelist' type: $params['blogid']
- 'archive' type: $params['blogid'] & $params['archive']
- 'blog' type: $params['blogid']

The title & timestamp on 'item' type events are only present when the callers knows there, and are there to prevent plugins from having to query the database for the title/timestamp each time an URL is requested.

Keywords:

$CONF['ItemKey'], $CONF['MemberKey'], $CONF['ArchiveKey'], $CONF['ArchivesKey'], $CONF['BlogKey'], $CONF['CategoryKey']

I've attached an NP_ReplaceURL plugin to this task which demonstrates the events. When the item id is 1, it generates /item/test. Also, when the /item/test URL is requested, the URL is parsed to itemid 1

Note that you'll need updated stub files for this to work (also in CVS). Otherwise, the stub files will overwrite the itemid after the plugin parsed the URL.


Comment by Roel (roel) - Tuesday, 23 August 2005, 10:41PM

I installed NP_ReplaceURL(3.zip) on a 3.22 site, and it works! Out of the box, even. Very nice. (see http://roelg.nl for an example)

The only thing that looks somewhat odd at the moment (in the url's) is the lack of 0's in the months before October. I don't know why, but for some reason I expect those url's to look like site/item/2005/08/title instead of item/2005/8/title (maybe that's just me ;) )


Comment by Wouter Demuynck (karma) - Wednesday, 24 August 2005, 05:38PM

Some remaining problems (listing them here so I won't forget):

- I tried installing ReplaceUrl3 on demuynck.org and ran into a problem where smoe of the links looked like /item/1969/. This probably happens when <%itemlink%> is used in one of the comment-related templateparts.

- some upgrade instructions were missing for users upgrading to 3.22 from older versions: the fancyurl stub files have changed. The new files need to be copied from the /extra/fancyurls directory to the root. Also, fancyurls.config.php is different, and a change is required in index.php (documented in fancyurls.config.php). Withouth these changes, the plugin won't work (URLs will be created, but trying to parse one would fail)


Comment by Roel (roel) - Thursday, 25 August 2005, 01:13PM

I can hereby confirm the first of the two problems you mention. On roelg.nl, all the <%itemlink%> var's used in the commet template parts generate an url that looks like roelg.nl/item/1970

Regarding the 2nd point you make: maybe the stub files can be moved to the root of the nucleus download zip? It won't harm anyone (except in situatiosn where they try to create a directory that's named like one of the stubs).


Comment by Wouter Demuynck (karma) - Monday, 19 September 2005, 06:12PM

The /item/1970 or /item/1969 problem should have been fixed in CVS.

Moving the stub files to the root is a good idea, I think. A task was created for this (http://dev.nucleuscms.org/tracker/?do=details&id=96)