1. 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

Discussion in 'XenForo Development Discussions' started by AndyB, Feb 11, 2014.

  1. AndyB

    AndyB Well-Known Member

    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.

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


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


    This is what the URL should have been:

  2. Chris D

    Chris D XenForo Developer Staff Member

    The route part of the link (calendar) should not have a trailing slash.

    <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 likes this.
  3. AndyB

    AndyB Well-Known Member

    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.
  4. Chris D

    Chris D XenForo Developer Staff Member

    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?

    Highly unlikely. Similar code used in XenForo and other add-ons works fine.
    AndyB likes this.
  5. AndyB

    AndyB Well-Known Member

    Interesting. I was not able to make it work correctly using the current version v2.1 when Friendly URLs is not checked.

    Correct. I was thinking that was the problem so I created a development version using a route.

    You nailed it! Yes I'm using a route prefix calendar now. It's much cleaner this way and more logical.
  6. Chris D

    Chris D XenForo Developer Staff Member

    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 likes this.
  7. AndyB

    AndyB Well-Known Member

    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.
  8. Mike

    Mike XenForo Developer Staff Member

    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 likes this.
  9. AndyB

    AndyB Well-Known Member

    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:

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

    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
    Last edited: Feb 11, 2014
  10. AndyB

    AndyB Well-Known Member

    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: Feb 11, 2014
  11. AndyB

    AndyB Well-Known Member

    I would like to understand what @Mike is referring to:

    I might like to go back to using the GET method in my form.

    Hoping someone can explain.

    Thank you.

Share This Page