Forums / Cotonti / Support / Handy URLs and URL links.

Questions...

lukgoh
#1 2012-05-01 10:41

Hello guys, 

I am completely new to URL transformation and with help I setup my Cotonti to use the Handy URLs, which is perfect. 

I have created a module and to get the same results (www.domain.com/module/$u) I added a page that hooks into urleditor.functions.php like this: 

PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
/* ====================
[BEGIN_COT_EXT]
Hooks=urleditor.rewrite.first
[END_COT_EXT]
==================== */
 
/**
 * Clan Module for Cotonti CMF
 *
 * @package Clan
 * @version 1.0
 * @author DesignLizard
 * @copyright (c) 2012 DesignLizard
 * @license BSD
 */
 
defined('COT_CODE') or die('Wrong URL');
 
if ($path[0] == 'clans')
            {
                 
                // Clan profiles
                $_GET['e'] = 'clans';
                $_GET['u'] = $path[1];
                return;
            }
?>

My question/problem is when creating a url like this: cot_url('clans', 'u=' . $rowgettopclans['clan_name_short']) it outputs a link like this: /clans?u=mli instead of clans/mli which is the correct link. I was wondering what I am doing wrong, or what needs to be done to get the correct url.

Trustmaster
#2 2012-05-01 19:58

I'm sorry that this is undocumented, but out of the box with Handy preset, URLeditor understands 3 types of magic parameters, inherited from 'page' module:

  • c=* is understood as structure category code, and so cot_url('foo', 'c=bar') is transformed into /foo/bar or /foo/path/to/bar (depending on $structure['foo']['bar'] contents).
  • al=* is understood as alias, so cot_url('foo', 'al=baz') is transformed into /foo/baz, but cot_url('foo', 'c=bar&al=baz') will become /foo/bar/baz.
  • id=* is understood as numeric identifier, so cot_url('foo', 'id=123') is transformed into /foo/123.

You don't even need to hook into urleditor to use them.

May the Source be with you!
lukgoh
#3 2012-05-01 20:29

Thanks Trustmaster, I'm now using $c for the clans which is working great. However, if I remove my hook I can no longer view a clan via /clans/clanname

This post was edited by lukgoh (2012-05-01 20:45, 13 years ago)
Trustmaster
#4 2012-05-01 21:27

This is because it looks for an entry in $structure array for your module and that category. As there is no such a record, it falls back to $al. So you'd better use $al instead of $c.

May the Source be with you!
lukgoh
#5 2012-05-01 21:28

oh okay, awesome thank you.