Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Parth 10 posts 100 karma points
    Nov 15, 2018 @ 09:06
    Parth
    0

    How to Hide Preview Button..

    hey there can any one tell me how to hide preview button? using java-script??.

  • Julien Kulker 75 posts 427 karma points c-trib
    Nov 15, 2018 @ 10:38
    Julien Kulker
    0
  • Parth 10 posts 100 karma points
    Nov 15, 2018 @ 11:07
    Parth
    0

    hey julien kulker Backoffice Tweaking package ignore all admin user.. i want to hide preview button for all user.

  • Julien Kulker 75 posts 427 karma points c-trib
    Nov 15, 2018 @ 12:21
    Julien Kulker
    0

    Hi Parth,

    It isn't with javascript but this would work:

    step 1: Go to the editfile: ~/Umbraco/Views/components/content/edit.html

    step 2: replace the button preview with

                <umb-button
                    alias="preview"
                    ng-if="!page.isNew && content.allowPreview"
                    type="button"
                    button-style="info"
                    action="preview(content)"
                    label="Preview page test"
                    class="hide-preview-button"
                    label-key="buttons_showPage">
                </umb-button>
    

    step 3: create a new folder "CustomCss" inside the App_Plugins folder:

    step 4: create inside the CustomCss folder a new manifest file with this config:

    {
       "propertyEditors": [],
       "javascript": [],
       "css": [
       "~/App_Plugins/CustomCSS/style.css"
     ]
    

    }

    step 5: Inside the CustomCss folder create the style.css

    step 6: add the following style:

    .hide-preview-button {
    display: none;
    

    }

    So this only hides it not disabling it. If you want to disable it maybe you should override the preview event to do nohting on the action. if possible.

    Good luck!

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Nov 15, 2018 @ 13:13
    Dave Woestenborghs
    101

    Hi Parth,

    This can be done pretty easy hooking into one of the EditorModel events provided by Umbraco : https://our.umbraco.com/documentation/Reference/Events/EditorModel-Events/

    Here you can find a sample on how to disable preview : https://github.com/dawoe/umbraco-journey-into-the-unknown/blob/master/App_Code/EditorModelEvents.cs

    Dave

  • Joe 32 posts 136 karma points
    Apr 26, 2022 @ 05:42
    Joe
    0

    Simpliest perfect answer!

Please Sign in or register to post replies

Write your reply to:

Draft