Forums

Creating Router.php

Bosle 08 Oct, 2013
Hey Guys,

first of all I want to thank you for that great component. Its just unbelievable what you can do with it. It makes many other components simply redundant.

I'm about to set up a website for a social project. Right now, CF its still free licence, but as soon as I see that everything I plan can be done with CF, I will buy a premium licence of course.

Problem:

So, I set up some forms and listing forms. The only thing I missed was the router.php, or some other way to handle handsome urls. So I created one router.php in the component folder (added of course also to .xml).

The Router.php looks like that

function chronoformsBuildRoute( &$query )
{
       $segments = array();
	  
	 if(isset($query['chronoform']))
       {
                $segments[] = $query['chronoform'];
                unset( $query['chronoform'] );
       }
	
	 if(isset($query['token']))
       {
                $segments[] = $query['token'];
                unset( $query['token'] );
       } 
	
	 
	  return $segments; 
}

function chronoformsParseRoute( $segments )
{
       $vars = array();
       switch($segments[0])
       {
                case 'view_my_form':
				   $vars['chronoform'] = 'view_my_form';
				   $vars['token'] = '';
				   break;
            	 case 'view_my_second_form':
				   $vars['chronoform'] = 'view_my_second_form';
				   break;
	          case 'view_my_third_form':
				   $vars['chronoform'] = 'view_my_third_form';
				   break;	   
            
       }
       return $vars;
}


So, working so far --> URL looks like that
http://*mysite*/*lang*/*itemname*/*formname*/*token*

for example
http://www.thisisagreatsite.com/en/menu_one/view_my_form/8duswsa9hdw39jcds233w

But I'm struggling with the token. Whatever I put in the ParseRoute $vars['token'] its not parsing anything. Does maybe someone have a hint for me?

Thank you!
rmishka 10 Oct, 2013
did you make it work? I
m trying to do something similar
Bosle 15 Oct, 2013
Has someone found out anything?
Max_admin 17 Oct, 2013
Hi,

If you have a menu item of type Chronoforms then the form link will be SEF like the link to our contact form here, I don't advise building SEF router for Chronoforms because this may have some side effects (which I can't remember now), but regarding your code, I think that the "chronoformsParseRoute" function has some problem, try to use "print_r" to check the values available in the $segments array and build your code based on that.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Bosle 01 Nov, 2013
Thank you for your answer. Unfortunately I couldn't get any further. When I print the arrays ->

Array ( [chronoform] => myrightform [token] => 22 )

So, both is correct, but its not working and I have no clue why. Its leading to the right form, but it's not parsing the ID somehow.

Has someone already found the solution?
Max_admin 07 Nov, 2013
How do you know that its not parsing the id ?

did you print the $segments or the $vars ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.