Copied to clipboard

Flag this post as spam?

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


  • sheva29 5 posts 114 karma points
    Nov 28, 2016 @ 23:39
    sheva29
    0

    Preview element that has no template

    Hi,

    I'm new Umbraco. I'm using the latest version with Razor MVC. I have a WSMaster page for layout that loads all the different views depending where the user navigates. WSMaster loads WHome, which is my landing page. I have created a document type called SideRail. When in WSHome, I'm parsing a collection of those objects in order to display a side rail in my WSHome, this content is static and doesn't link to pages inside the the application but outside.

    Which means that my SideRail document type doesn't have a template. I just need the document type to parse my side rail and display information on the WSHome page. This is a problem for the content manager when creating content for this componenet because the only thing I have on my template is:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
    Layout = "WSMaster.cshtml";
    }
    

    This is something Umbraco created by default when creating my SideRail type in the CMS. When I hit preview after creating a SideRail component nothing renders of course.

    Is there a way for me to have my template point to WSHome so that content managers can see a preview of what they are building?

    Again, I'm new to Umbraco so perhaps building my SideRail has a document type wasn't the best approach. Any help will be much appreciated.

    Thanks!

  • sheva29 5 posts 114 karma points
    Nov 29, 2016 @ 00:06
    sheva29
    0

    One way that I was able to solve it, which is bit hacky, is by doing a redirecting through JS:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = "WSMaster.cshtml";
    }
    
    
    
    <script type="text/javascript">
    (function(){
    
        window.location = "/";
    
    })();
    </script>
    

    Again, not the most elegant way, more interested on learning the Umbraco way

    Thanks again,

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Nov 30, 2016 @ 23:22
    Alex Skrypnyk
    100

    Hi Sheva,

    Another way to try it is to use Umbraco.RenderTemplate() method and parent page as param, because we need to render parent page here:

    @Html.Raw(Umbraco.RenderTemplate(Umbraco.AssignedContentItem.Parent.Id))
    

    Thanks,

    Alex

  • sheva29 5 posts 114 karma points
    Dec 06, 2016 @ 21:13
    sheva29
    0

    Alex,

    Thanks for your reply! This worked like a charm. For taxonomy purposes I made the parent of my SideRails a SideRail repository. which doesn't have a template. But I set the layout of my template to Null and loaded WSHome by passing its ID like this:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
    Layout = null;
    }
    
    @Html.Raw(Umbraco.RenderTemplate(1074))
    
Please Sign in or register to post replies

Write your reply to:

Draft