Copied to clipboard

Flag this post as spam?

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


  • Andrew Rebane 14 posts 35 karma points
    Apr 23, 2015 @ 22:29
    Andrew Rebane
    1

    cannot access CurrentPage/AssignedContentItem from partial view

     

    It is been set to the model that I gave for the view

    @Html.Partial( "viewname", thisIsNewCurrentPage )

    how can I access the content item that was intitially requested from a view that has a differnet content item as an input?

     

     

  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    Apr 23, 2015 @ 22:38
    Alex Skrypnyk
    0

    Hi Andrew,

    Can you show all your view ?

    Thanks, Alex

  • Andrew Rebane 14 posts 35 karma points
    Apr 23, 2015 @ 22:45
    Andrew Rebane
    0

    TopMenu.cshtml

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        var mainMenu = Umbraco.ContentSingleAtXPath("//Folder[@urlName='main-menu']") as DynamicPublishedContent;
    }

    @CurrentPage.Name * what was initially HTTP requested by browser e.g. @Home*

    <ul class="sf-menu fixed" id="menu">
        @foreach (var menuItem in (mainMenu != null ? mainMenu.Children : Enumerable.Empty<DynamicPublishedContent>()))
        {
            <li>
                @Html.Partial(MyViews.PartialViewPath("Menus/TopMenuItem"), menuItem )
            </li>
        }
    </ul>

    TopMenuItem.cshtml

    @inherits UmbracoTemplatePage<DynamicPublishedContent>

    @CurrentPage.Name * Is changed every time to the assigned menuItem.Name *

  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    Apr 23, 2015 @ 22:51
    Alex Skrypnyk
    0

    CurrentPage is dynamic object Umbraco.AssignedContentItem is PublishedContent

    Do you want to use dynamic objects?

    Thanks, Alex

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies