Stuck with register URI and 404

Stuck with register URI and 404, a forum discussion on Jojo CMS. Join us for more discussions on Stuck with register URI and 404 on our Plugin Support forum.

Back to Forum Index : Back to Plugin Support   RSS
glouk glouk

31 May 2008
Posts: 46

I am making tiny steps with my demo reel plugin and here is the situation :

i have created 3 php file for 3 different functions :

glouk_demo.php (list of films) real code with list of films and links
glouk_demo_film.php (list of shots for a selected film) dummy code
glouk_demo_plan.php (shot page) dummy code

subsequently i added the following code to api.php :

$_provides['pluginClasses'] = array(
'Jojo_Plugin_glouk_demo' => 'liste des films',
'Jojo_Plugin_glouk_demo_film' => 'film + liste de plans',
'Jojo_Plugin_glouk_demo_plan' => 'fiche plan',
);

Jojo::registerURI("film/[id_film:integer]/[titre:string]", 'JOJO_Plugin_glouk_demo_film');
Jojo::registerURI("film/[titre:string]", 'JOJO_Plugin_glouk_demo_film');
Jojo::registerURI("film/[id_film:integer]", 'JOJO_Plugin_glouk_demo_film');
Jojo::registerURI("plan/[nom:string]", 'JOJO_Plugin_glouk_demo_plan');
Jojo::registerURI("plan/[id_plan:integer]", 'JOJO_Plugin_glouk_demo_plan');
Jojo::registerURI("plan/[id_plan:integer]/[nom:string]", 'JOJO_Plugin_glouk_demo_plan');
Jojo::registerURI("plan/[titre:string]/[id_plan:integer]/[nom:string]", 'JOJO_Plugin_glouk_demo_plan');
Jojo::registerURI("plan/[titre:string]/[nom:string]", 'JOJO_Plugin_glouk_demo_plan');

then i created 3 pages in edit page with technical link to the corresponding plugin function.

the glouk_demo/films works, but when i click on film link, or type glouk_demo/film/8, i get a 404.

I also tried to add this line, to test the getformdata function :
Jojo::registerURI("films/[id_film:integer]/[titre:string]", 'JOJO_Plugin_glouk_demo');

but i was surprised to see that demo_glouk/films/6/test returns a 404...

What is it i did not understand ? am i far from it ?
Harvey

Core Developer

Harvey

31 May 2008
Posts: 327

That looks like you ahve it right. One thing to watch for is that api.php is cached to improve performance. You will need to either do your testing with debug mode enabled (set in config.php) or wipe the cache after changing api.php (use the button on /admin/). Note this caching is independent of the content cache setting.

But it looks like you are on the right track.
glouk glouk

1 Jun 2008
Posts: 46

however, the cache is cleared, and i still get the 404. :(

can't see what's wrong...
glouk glouk

1 Jun 2008
Posts: 46

OK got it : forgot to define the class JOJO_Plugin_glouk_demo_film. No 404, but also no uri parsing : the url is rewritten out of my control...

in api.php :
Jojo::registerURI("film/[id_film:integer]", 'JOJO_Plugin_glouk_demo_film');

i call glouk_demo/film/8, and i try to recover 8, i.e. id_film.

if i enter "film" in the url field of the film page, the resulting url is "glouk_demo/film/", and id_film is empty and _GET contains [uri] => "film/".

if i clear the url field of the film page and clear the cache, i get a 404.

1. why isn't my url kept ?

2. why isn't it parsed ? (this one i think i know : i guess parsing happens after url rewriting)

3. what do i have to do to make this work ?

4. i entered specific urls for each film, how do i specify they have to be used for url rewriting ? like film/8 would become film/8/hitman.

step__by__step...

btw you did not answer my question in the other thread, about the ajax tree menu, that i would like to bring to my front-end.

thanx
Harvey

Core Developer

Harvey

1 Jun 2008
Posts: 327

You may have noticed a getCorrectUrl function in some of the plugins. This is Jojo's way of preventing duplicate content. getCorrectUrl's job is to read the GET variables and return what the correct URL should be. Jojo will then redirect to that URL if it's on the wrong URL.
To see this in action, try changing the last part of the URL in any forum topic - you will see it redirects back. This is a pretty cool feature for SEO purposes, but a bit of a hassle to program around.

I would suggest starting off by using the getCorrectUrl function supplied with empty_plugin, which basically disables this feature. Once you have everything else working, you can have a go at customizing this function.

Apologies if my answers aren't too detailed, it's the weekend over here and I'm trying to spend most of it with the family. I can give proper answers during the week though.
glouk glouk

2 Jun 2008
Posts: 46

Sorry Harvey, didn't mean to ruin your week-end.

I finally understood why it was not working : the "_" character seems not to be allowed in variable names inside the registerURI function.

Once i removed it, it worked fine.

I'll let you know next time i stumble ;)
Harvey

Core Developer

Harvey

2 Jun 2008
Posts: 327

We do have a page in the docs on registerURI which may help. Note that the "string" type we have defined is only numbers, letters and dashs. If you use "phrase" instead, you can have a much wider range of characters. Or, for total control, put your own regex into there instead.

Generally, we recommend dashes rather than underscores. Some non-technical folk don't know what an underscore is (which makes giving out URLs over the phone harder), and if you underline an underscore in a link, it looks just the same as a space, which can be confusing. Google no longer cares which you use for separating words.

No worries about the weekend thing, it 's a long weekend in New Zealand and it looks like the rest of the team are off enjoying it. We are normally pretty responsive on the forums, but I guess it wasn't a flash idea doing a new release before a long weekend (but always better to do something now rather than putting off until tomorrow right?).
Back to Forum Index : Back to Plugin Support   RSS
You must be logged in to post a reply



You need to Register or Log In before posting on these forums.