Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Correct route to make Cancel button go to the category you are in?

danmerhardanmerhar New
edited April 2013 in Vanilla 2.0 - 2.8

I can't seem to wrap my head around the correct route to make the cancel button go back to the particular category you decided to make a post in.

Is there something really simple I'm neglecting to see?

Any help would be greatly appreciated.

Comments

  • 422422 MVP
    edited April 2013

    add javascript history -1 to the onclick handler

    http://www.w3schools.com/jsref/met_his_back.asp

    There was an error rendering this rich post.

  • I'm not a developer by any means, but I am comfortable enough to poke around in the code and make changes. Which file is the code for the cancel button hiding? I saw on the forums earlier that there is a wiki (which I'll be sure to check out).

    This is all kind of overwhelming, but I feel like Vanilla is an excellent way to understand php and js.

  • in views/post the cancel url is defaulted to /vanilla/discussions/

    Line 1 thru 7 ( i am on 2.0.81) Somewhat bemused myself now...my setup is.

    < ?php if (!defined('APPLICATION')) exit();
    $Session = Gdn::Session();
    $CancelUrl = '/discussions';
    if (C('Vanilla.Categories.Use') && is_object($this->Category))
       $CancelUrl = '/discussions/0/'.$this->Category->CategoryID.'/'.Gdn_Format::Url($this->Category->Name);
    
    ? >
    

    Seemingly, the routing is cockeyed, when cancelling from a category new discussion. Perhaps its a bug

    There was an error rendering this rich post.

  • It happens on both the "back to discussions" link and from an edit. I used to code in Flash (AS3) and JS is kind of similar. I figured it out.

    Thanks for the help!

  • so if you figured it out. Share your code , thats the way its done round here

    There was an error rendering this rich post.

  • danmerhardanmerhar New
    edited April 2013

    To fix the back to discussions link:

    add this after line 305 in vanilla/js/discussions.js:

    $('a.Back');
    
    function goBack(evt) {
        history.go(-1);
        return false;
    }
    

    I can't figure out how to fix it on the edit discussion screen, though. It should be just as simple?

  • how are you triggering that to an ID, as it is that will be applied to all a href's ( unless you have added class .Back to another place

    There was an error rendering this rich post.

  • danmerhardanmerhar New
    edited April 2013

    I... don't know. It fixed the problem, though.

    edit: actually - you're right. I neglected to think about the button when you access from any other part of the forums.

  • peregrineperegrine MVP
    edited April 2013

    I re read you question - possible answer for you to try, worked for me.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited April 2013

    try this:
    in /applications/vanilla/views/post/discussion.php

    change from

        if (C('Vanilla.Categories.Use') && is_object($this->Category))
        $CancelUrl = '/discussions/0/'.$this->Category->CategoryID.'/'.Gdn_Format::Url($this->Category->Name);
    
    to:
    
    if (C('Vanilla.Categories.Use') && is_object($this->Category))
       $CancelUrl = '/vanilla/categories/' .Gdn_Format::Url($this->Category->Name);
      //  $CancelUrl = '/discussions/0/'.$this->Category->CategoryID.'/'.Gdn_Format::Url($this->Category->Name);
    

    then add

    $Configuration['Vanilla']['Categories']['Use'] = TRUE;
    

    to your conf/config.php

    should take you back to the category with a cancel.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • I am using a custom theme I've been working on myself, but the default theme is guilty as well. There is no actual "button", just a link.

    http://forums.danmerhar.com/

    I switched to the default theme. I'm using Version 2.0.18.4

  • we cross-posted - see may answer above.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • That solved the cancel issue when editing a discussion, but the problem still remains with the "back to discussions" button. I will just hide it with CSS, it's not really a necessity.

  • peregrineperegrine MVP
    edited April 2013

    The shifting question routine :)

    Correct route to make Cancel button go to the category you are in?

    That solved the cancel issue when editing a discussion,

    @danmerhar asked a question, and then wanted me to read his mind as well :)

    but the problem still remains with the "back to discussions"

    thx. the question you never asked - you've solved I take it.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Oh, oops. The two are quite similar in scope. My bad!

    Thanks for the help.

Sign In or Register to comment.