HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Chinese Zodiac and a plugin question relating to a page refresh or redirect after form save.

In developing this plugin. I wanted to redirect the page back to the profile after the settings were saved in the profile so the icon would reset.

I tried putting a redirect in several different places in the plugin, but none would do what I wanted, so if you know how to do this, I would learn something new.

Anybody got a working solution, that i could try. Even a panel update would be fine too.

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

Comments

  • To better understand, what do you mean with after "after the settings were saved in the profile"? I'm asking because, if you are referring to the popup window, the redirect would affect only that window and a bit of JavaScript work would be required to refresh the calling page.

  • peregrineperegrine MVP
    edited June 2013

    @businessdad said:
    To better understand, what do you mean with after "after the settings were saved in the profile"? I'm asking because, if you are referring to the popup window, the redirect would affect only that window and a bit of JavaScript work would be required to refresh the calling page.

    popup yes.

    a bit of JavaScript work. - I'm open for a snippet of code :).. If you see image 1 on the plugin description page. I would like the image in the panel to update after a save in the popup selection name.

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

  • @peregrine said:
    a bit of JavaScript work. - I'm open for a snippet of code :)

    I would be happy to help, but, unfortunately, I can't right now. I have a Server to resurrect and it's already late night here (the bad thing of Linux is that, when it dies, it dies for good). If nobody else will post a solution, I will look at it later. :)

  • good look with the resurrection.

    I suppose I have to search for the element and do a .on click function. I'll give it a try.

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

  • One way would be to call a JS function on form save that updates the symbol through AJAX.

    $('Form save button selector').click(function (){
      var url = gdn.url('/plugin/symboledit/getflair/');
    
      $.ajax({
        url: url + userID,
        global: false,
        type: "GET",
        data: null,
        dataType: "json",
        success: function(Data){
          $(".MySymbol img").attr('src', Data.url);
        }
      });
    });
    

    You will have to get the user ID from somewhere. Then you have to create a function in your plugin that will some return a user's symbol url via json.

    e.g.

    public function PluginController_GetFlair_Create($Sender) {
      $UserID = $Sender->RequestArgs[1];
      $symboldir = C('Plugins.SymbolEdit.SymbolDir', 'CZodiac');
      $SymbolUser = Gdn::SQL()->GetWhere('User', array('UserID' => $UserID))->FirstRow(DATASET_TYPE_ARRAY);
      if ($SymbolUser > 0) {
        $Data = array('url' => 'plugins/SymbolEdit/design/images/' . $symboldir . '/' . $SymbolUser . '.png');
      }
      echo json_encode($Data);
    }
    

    The $Sender->RequestArgs[1] might be different. But I am sure you could figure it out. :D

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • solved it. apparently the redirect does work.

    after the saved

    $Sender->RedirectUrl = Url('profile/');

    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 June 2013

    thanks @hgtonight

    for jscript example. It's gonna be useful for future plans. :).

    meanwhile, I've added "Put A Bird On It" option in the plugin due to popular demand :).

    http://www.ifc.com/portlandia/videos/portlandia-put-a-bird-on-it

    my connection is too slow to watch the link, but I think it is the one.

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

  • edited June 2013

    Vey cool plugin I am a dragon , maybe adding the elements would be nice- earth water wood metal fire, I am a wood dragon and have also some snake :)

  • peregrineperegrine MVP
    edited June 2013

    By the way, no need to send a donation on this

    http://vanillaforums.org/addon/1126/symboledit

    my way of putting a bird on it for the vanilla community. :)

    I expect this plugin to be as hot as the bootstrap theme. (delusional thinking, some might say).

    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 June 2013

    @vrijvlinder said:
    Vey cool plugin I am a dragon , maybe adding the elements would be nice- earth water wood metal fire, I am a wood dragon and have also some snake :)

    Actually, I think this would be cool, all joking aside, if people uploaded zips of plugin sets with revisions to the symboluser_Other.php and a suibdirectory image set.

    e.g. earth elements set would have

    5 images.

    so you would have.
    
    plugins/SymbolEdit/design/images/EarthWindFire
    1.png        //image of earth
    2.png        //image of fire
    3.png        // image of water
    4.png        //image of metal
    5.png        //image of wood.
    
    
    and then clone
    
    plugins/SymbolEdit/views/symboluser_Other.php
    and call it
    
    plugins/SymbolEdit/views/symboluser_EarthWindFire.php
    
    with the options changed to
    
    
    $optionarray[0] = 'None';
    
    $optionarray[1] = 'earth';
    $optionarray[2] = 'fire';
    $optionarray[3] = 'water';
    $optionarray[4] = 'metal';
    $optionarray[5] = 'wood';
    
    
    and then change
    
    config statement to
    
    ``$Configuration['Plugins']['SymbolEdit']['SymbolDir'] = 'EarthWindFire';``
    

    somebody could make futbol team icons set of images,,,,

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

  • yea that is going to make the plugin complete for sure, I much prefer the chinese horoscope to the western hocuscope , I studied that philosophy for a couple years and is based on psychology not astrology . So it makes more sense to me. And it is more interesting since the combination does not get repeated but every 60 years.

  • @vrijvlinder

    yea that is going to make the plugin complete for sure

    Well, the chinese horosope is good. But I prefer, to run the "Put A Bird on It" option in the plugin (it shows up better with the latest version. I, personally, would never run a forum without the "put a bird on it" option in the plugin. gee.

    I could have been a millionaire if I sold this as a premium plugin :). Then i could've retired from the forum.

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

  • well , Los ricos tambien lloran , if it makes you feel any better :(

Sign In or Register to comment.