e107help.org Q&A
0 like 0 dislike
Is it possible to use sef urls without the id like news.php and page.php?

$data = array(
'forum_sef' => 'my-sef-forum-name',
'thread_id' => 2,
'thread_sef' => 'my-forum-topic'
);
$url = e107::url('forum','topic', $data);

$config['topic'] = array(
'regex' => '^forum/(.*)/(d*)-([w-]*)/???(.*)',
'sef' => 'forum/{forum_sef}/{thread_id}-{thread_sef}/',
'redirect' => '/e107_plugins/forum/forum_viewtopic.php?id=$2'
);
e107 version 2.2.1
in Plugins by (31 points) 2 6 10

2 Answers

0 like 0 dislike
Yes it is possable.

One of the plugins I am working on has two pages, game.php, and games.php - To get to a selected 'game' the url would use game.php?id={Number} - to change that I added sef_url into the plugin_sql.php.

Then in my e_url.php I have two config's - one for games, and other for game <--- that has the numbers

$config['game'] = array(
            //'alias'         => 'league/game',
            'regex'            => '^league/game\/([^\/]*)\/?\??([^\/]*)?$',
            'sef'            => 'league/game/{game_sef}/',
            'redirect'        => '{e_PLUGIN}games/game.php?sef=$1',
            'legacy'        => '{e_PLUGIN}games/game.php?id={game_id}'            
        );
by (459 points) 16 35 50
0 like 0 dislike

Shortly, possibilities are endless 

it is just array and you need to know correct regex, nothing more (it is a little problem for me)

but I had already generated e_url items in some plugin,  or used with e_QUERY directly and for example 

$config['stories'] = array(

            'alias'         => 'stories.php',

'regex' => '^{alias}\/?([\?].*)?\/?$', 

'sef' => '{alias}', 

'redirect' => '{e_PLUGIN}efiction/stories.php$1',  

); 

        

$config['rules'] = array(

            'alias'         => 'submission.php',

'regex' => '^{alias}', 

'sef' => '{alias}', 

'redirect' => '{e_PLUGIN}efiction/viewpage.php?page=rules',  

); 

this is an example of how to completely change paths...  (all stats from root )

Alias with legacy version (file.php) is used for historical purposes, it could be anything 

The important part is that this is used for 2 purposes:

- correct redirection 

- getting sef-URL version

The latest one works only if you use correct data - keys have to be the same as in "sef" key.  For first one only regex and redirect are needed.

Legacy key is used if sef version doesn't have enough data (in e107::ulr()) 

 

ago by (2.0k points) 18 48 58
Welcome to e107 Q&A, where you can ask questions and receive answers from other members of the e107 community.
988 questions
1,384 answers
2,511 comments
2,511 users