• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Use Full Friendly URLs not checked problem

AndyB

Well-known member
#1
My Calendar add-on is working great as long as the admin has the Use Full Friendly URLs checked.

The problem occurs when the admin does not have the Full Friendly URLs checked.

This form will not create a proper URL link when the submit button is clicked.

Code:
<form action="{xen:link 'calendar/', $thread}" method="get" data-redirect="on">
...
The URL before the Submit button is clicked:

http://www.example.com/forums/index.php?calendar/&month=02&year=2014

This is the incorrect URL after the Submit button is clicked:

http://www.example.com/forums/index.php?month=03&year=2014

This is what the URL should have been:

http://www.example.com/forums/index.php?calendar/&month=03&year=2014
 

Chris D

XenForo developer
Staff member
#2
The route part of the link (calendar) should not have a trailing slash.

Code:
<form action="{xen:link calendar, $thread}" method="get" data-redirect="on">
Technically, it doesn't need quotes around it either. The above should be valid and should work.
 

AndyB

Well-known member
#3
Hi Chris,

Thank you kindly for looking into this issue for me.

I tried your above advice, but I have the same exact result. Perhaps it's a bug and I should report it as such.
 

Chris D

XenForo developer
Staff member
#4
Does this pertain to the current version of your add-on?

If so it works fine with or without friendly URLs.

But you extend the threads controller so the links should be {xen:link threads/calendar, $thread}.

Or is it not working with a development version? If so have you started using your own calendar route prefix and controller?

Perhaps it's a bug and I should report it as such.
Highly unlikely. Similar code used in XenForo and other add-ons works fine.
 

AndyB

Well-known member
#5
Does this pertain to the current version of your add-on?

If so it works fine with or without friendly URLs.
Interesting. I was not able to make it work correctly using the current version v2.1 when Friendly URLs is not checked.

But you extend the threads controller so the links should be {xen:link threads/calendar, $thread}.
Correct. I was thinking that was the problem so I created a development version using a route.

Or is it not working with a development version? If so have you started using your own calendar route prefix and controller?
You nailed it! Yes I'm using a route prefix calendar now. It's much cleaner this way and more logical.
 

Chris D

XenForo developer
Staff member
#6
Yeah so the current version works fine with/without friendly URLs... but the fact that you're having issues with it maybe explains why you're having issues with the new version too. Is there something wrong with your dev install? Maybe a non-default .htaccess file or something?

Failing that, then it's almost definitely an issue with how your route prefix is set up or your route controller.

Can you post screenshots or upload your current version or at least the files that relate to the new "calendar" route.

I agree a separate route is the right way to go.
 

AndyB

Well-known member
#7
I just tried on a completely stock XF version 1.23. Calendar is the only add-on. I also checked the .htaccess file and it's untouched.

Thank you for confirming that a separate route is the way to go.

I'll create a the new version Calendar v2.2 for you to test and send a link via Conversation.

Thank you.
 

Mike

XenForo developer
Staff member
#8
You need to submit your form via POST or you need to (for non-friendly URLs) submit the route via the "_" param. This is because of how browsers submit GET forms when it comes to query strings on the action.
 

AndyB

Well-known member
#9
Hi Mike,

Thank you for looking into this.

Changing the submit to POST works as long as I'm not logged in. However if I log and submit the form I get the following error message:

Code:
Security error occurred. Please press back, refresh the page, and try again.
Edit: I was missing this code in the template below the submit.

Code:
<input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
 
Last edited:

AndyB

Well-known member
#10
submit the route via the "_" param.
I hope someone can explain how to do this. :)

Edit: Now that I got it to work using the POST method, I don't really need this explained. It's actusally nicer using POST so the URL looks a bit cleaner.
 
Last edited:

AndyB

Well-known member
#11
You need to submit your form via POST or you need to (for non-friendly URLs) submit the route via the "_" param. This is because of how browsers submit GET forms when it comes to query strings on the action.
I would like to understand what @Mike is referring to:

submit the route via the "_" param
I might like to go back to using the GET method in my form.

Hoping someone can explain.

Thank you.