R_J
R_J

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Badges

Try Vanilla Forums Cloud product

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Update for critical security issue in PHPMailer included in release Vanilla 2.3.1

R_J · Cheerleader & Troubleshooter · Moderator

About

Username
R_J
Location
Munich
Joined
Visits
3,175
Last Active
Roles
Moderator, Developer, Community Developers
Points
3,819
Location
Munich
GitHub
R-J
Country
Germany
Badges
30
  • Re: Reload Page After Submit

    I assume $sender->jsonTarget('', '', 'Refresh'); is already the answer...

    Just some comments to your vision:

    @rbrahmson said:
    1. "Main" window is displayed. It has a button which has the "Popup" pseudoclass which invokes "Form B".
    2. "FormB" has the following (only the first is required):
    2.1 regular "X" on the top right corner (which today closes it and renders "Main").

    Pressing "x"/leaving that popup form doesn't render anything. It removes the popup (with JavaScript)

    @rbrahmson said:
    2.2 A "Submit" button which processed the form. The button has the "Popclose" pseudoclass. When clicked Vanilla captures the "Popclose" class, closes the popup (however it does it, JS, JsonTarget - I don't care) and gives control to the code that opened FormB (and as is the norm Postback is triggered ).

    That is not how it works. Let's look at some pseudo (not even that) code

    public function MainWindow {
        Display "index" view with link to FormB popup
        // No Form handling here!
    }
    
    public function FormBWindow {
        Handle postback
            Cause refresh on postback
        Display view with form
    }
    

    Main window doesn't have a chance to get information on the postback. It simply knows about its own view which only contains a link and no trace of a form.

    FormB has to handle all Form related code. If data shown on Main is changed, reloading Main should be triggered. If not, a simple removal of that FormB popup would be enough. I would try $sender->jsonTarget('.Overlay', '', 'Remove'); for that...

    @rbrahmson said:
    2.3 A "ExampleUrl" button which has both the "Popclose" pseudoclass as well as a url parameter. Vanilla closes the Popup and redirects to the URL (which could be on an external site).

    Looking at the global.js I see the following code:

    switch (item.Type) {
    case 'AddClass':
        $target.addClass(item.Data);
        break;
    case 'Ajax':
        $.ajax({
            type: "POST",
            url: item.Data
        });
        break;
    case 'Append':
        $target.appendTrigger(item.Data);
        break;
    case 'Before':
        $target.beforeTrigger(item.Data);
        break;
    case 'After':
        $target.afterTrigger(item.Data);
        break;
    case 'Highlight':
        $target.effect("highlight", {}, "slow");
        break;
    case 'Prepend':
        $target.prependTrigger(item.Data);
        break;
    case 'Redirect':
        window.location.replace(item.Data);
        break;
    case 'Refresh':
        window.location.reload();
        break;
    case 'Remove':
        $target.remove();
        break;
    case 'RemoveClass':
        $target.removeClass(item.Data);
        break;
    case 'ReplaceWith':
        $target.replaceWithTrigger(item.Data);
        break;
    case 'SlideUp':
        $target.slideUp('fast');
        break;
    case 'SlideDown':
        $target.slideDown('fast');
        break;
    case 'Text':
        $target.text(item.Data);
        break;
    case 'Trigger':
        $target.trigger(item.Data);
        break;
    case 'Html':
        $target.htmlTrigger(item.Data);
        break;
    case 'Callback':
        jQuery.proxy(window[item.Data], $target)();
        break;
    

    Based on that I would say that you can use $sender->jsonTarget('example.com', '', 'Redirect');

    @rbrahmson said:
    That, I posit, is elegant.

    @charrondev, @R_J, @hgtonight - anyone concurs?;-)

    From my understanding the View in MVC should be without any logic. I would prefer to see the action which happens after form submit in the Controller, not encoded in a CSS class of a link in the view.

    So given that the jsonTarget works as I understand it, I would say it is way more elegant. I have tried to alter that small demo plugin from above and that piece of code does exactly what I expect and what I assume that you are looking for:

            $view = $sender->fetchViewLocation('popuptest', '', 'plugins/demonstration');
    
            if ($sender->Form->authenticatedPostBack()) {
                $this->setUserMeta(0, 'Kokolores', $sender->Form->getFormValue('Kokolores'));
                if ($sender->Form->getFormValue('Kokolores') == "nonsense") {
                    // Whatever
                }
                $sender->jsonTarget('', '', 'Refresh');
            }
    
            $sender->render($view);
    
    rbrahmson
  • Re: Hide Tags From Sidebar

    @salamj : Editing core files is the worst approach to change Vanillas behavior. Vanilla is extensible and that's one of its biggest advantages. Please don't give such an advise especially to Vanilla beginners.

    Ewap
  • Re: Hide Tags From Sidebar

    As far as I know there is no way to configure that in your config. You have two possibilities: one is writing a plugin which will remove the module from the panel (those are the terms used in Vanilla for those "widgets" and "sidebar" like things) and the other option would be to hide them via css. The CSSEdit plugin is a great way to apply small style tweaks to your forum.

    K17Ewap
  • Re: Does This Plugin Exist?

    Karma Bank has been already extended by other plugins. You should search for someone extending it to allow users interchanging Karma points, not for someone reinventing everything from bottom up, because that would be a waste of time.

    K17Ewap
  • Re: need firm answer on Digest capability

    You are correct, there is no digest. Even with connection to MailChimp or a similar service you will not be able to send such a digest "automagically". There are still some logic to be coded.

    What you can do, if your forum is no big forum, is enabling the Advanced Notification permission for your users. That way they can choose if they like to be notified on new discussions on a per category level.

    But if your forum is bigger, than this will be a bad choice. In such a case you should thinking about hiring a developer.

    rbrahmsonK17