Jump to content

rewrite the entire view through plugin's controller


Recommended Posts

Posted
I want to create my own layout for a particular page on admin side through my plugin but still no clue how to do this.

This kind of works but the default blesta assets still showing on the DOM.

plugins/blesta_my_plugin/controllers/admin_my_plugin.php:
class AdminMyPlugin extends BlestaMyPluginController
{
    /**
     * Setup
     */
    public function preAction()
    {
        parent::preAction();
    }

    public function index()
    {
        $this->setDefaultView('default');
    }
}

plugins/blesta_my_plugin/views/admin_my_plugin.pdt:
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div>my plugin</div>
</body>
</html>

result:
<!DOCTYPE html>
<html dir="ltr" lang="en">
<head>
    <meta name="referrer" content="never">
    <meta charset="utf-8">
    <link rel="shortcut icon" href="/app/views/default/images/favicon.ico">
    <link rel="stylesheet" href="/app/views/default/css/application.min.css">
    <link rel="stylesheet" href="/app/views/default/css/font-awesome.min.css">
    <link rel="stylesheet" href="/app/views/default/css/font-awesome-shims.min.css">
    <title></title>
</head>
<body>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>

<div>my plugin</div>
<script src="/app/views/default/javascript/jquery.min.js"></script>
<script src="/app/views/default/javascript/jquery-migrate.min.js"></script>
<script src="/app/views/default/javascript/bootstrap.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        displayParts();
        $("input[name='agree']").change(displayParts);

        function displayParts() {
            if ($("input[name='agree']").is(':checked')) {
                $(".requirements").show();
                $(".db_info").show();
            }
            else {
                $(".requirements").hide();
                $(".db_info").hide();
            }
        }

        $("form").submit(function(e) {
            $("input[type='submit']").hide();
            $(".install_progress .progress").show();

            setInterval(animateProgress, 500);
        });

        $("#reload").click(function () {
            $("#reload").prop('type', 'submit');
            $("#reload").submit();
        });

        var progressWidth = 0;
        function animateProgress() {
            var step = 5;
            var elem = $(".install_progress .progress-bar");
            progressWidth = Math.min(95, progressWidth + step);
            elem.width(progressWidth + '%');
        }
    });
</script>
</body>
</html>

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...