Copied to clipboard

Flag this post as spam?

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


  • DuaneA 6 posts 86 karma points notactivated
    Apr 28, 2022 @ 13:27
    DuaneA
    0

    USkinned - get page name or title from ComponentOutro

    Umbraco 8.17.1 using uSkinned Wireframe

    I have a button, for example in the Outro section of a Grid component. This uses the Partials/MiscPageElements/ComponentOutro partial. I want to get the title of the overall page, or its name or onPageTitle.

    In other partials like pods I can use:

    @inherits USNStarterKit.ViewPages.USNViewPage<USNBlock>
    var content = (Usn_Pb_TextImage)Model.BlockContent;
    strQS =  content.PodHeading.Text;
    

    But that doesn't work in this case because it's not inheriting USNBlock. Code of the Partial is as follows

    
    @inherits USNStarterKit.ViewPages.USNViewPage

    Thanks

  • DuaneA 6 posts 86 karma points notactivated
    Apr 28, 2022 @ 13:28
    DuaneA
    0

    @inherits USNStarterKit.ViewPages.USNViewPage

    @{

    var content = (Usn_Cmp_IntroOutro)Model.BlockContent;
    string strQS = "";
    strQS = content.outroHeading.Text;
    <div>@strQS</div>
    
    if (Model != null && Model.DisplayOutro)
    {
        USNAnimation animation = (USNAnimation)ViewData["animation"];
        string colorLabel = ViewData["backgroundColorLabel"].ToString();
        string themeFolder = ViewData["themeFolder"].ToString();
        string textAlignmentClass = Model.OutroTextAlignment.HasValue() ? Model.OutroTextAlignment : "justify-content-start text-left";
        Usnstyle websiteStyle = (Usnstyle)Umbraco.Content(ViewData["websiteStyleId"]);
    
        <!-- Outro -->
        <div class="component-outro row @textAlignmentClass @animation.AnimationClass" data-os-animation="@animation.AnimationStyle" data-os-animation-delay="@animation.AnimationDelay" data-os-animation-duration="@animation.AnimationDuration">
            <div class="info col">
    
                @Html.Partial(themeFolder + "/MiscPageElements/Headings", new ViewDataDictionary { { "headingOrder", websiteStyle.StyleLayout.headingOrder }, { "animation", null }, { "heading", Model.OutroHeading }, { "secondaryHeading", Model.OutroSecondaryHeading }, { "backgroundColorLabel", colorLabel }})
    
                @if (Model.OutroText.HasValue())
                {
                    <div class="text @(colorLabel)-text">
                        @Html.Raw(Model.OutroText)
                    </div>
                }
                @if (Model.OutroButtons.HasValue())
                {
                    <p class="link">
                        @foreach (var button in Model.OutroButtons)
                        {
    
    
    
        if (USNThemeService.DisplayLink(button))
        {
            string buttonBgClass = USNThemeService.GetBackgroundColorClass(button.color.sortOrder, "button", websiteStyle);
            string buttonBgHoverClass = USNThemeService.GetBackgroundColorClass(button.color.sortOrder, "buttonHover", websiteStyle);
                                <a class="arrowbtn arrowbtnsmall" href="@button.link.LinkUrl" @Html.Raw(button.link.LinkTarget) @Html.Raw(button.link.LinkTitle)>
    
                                    @Html.Raw(button.icon)@Html.Raw(button.link.LinkText)@Html.Raw(button.link.LinkTargetIcon)
                                </a>
                            }
                        }
                    </p>
                }
            </div>
        </div>
        <!--// Outro -->
    }
    

    }

  • Marc Love (uSkinned.net) 432 posts 1691 karma points
    Apr 28, 2022 @ 13:36
    Marc Love (uSkinned.net)
    101

    Have a look at the view that calls ComponentOutro.cshtml

    ~/Views/Partials/uSkinned/BlockContainers/ComponentSection.cshtml

    You can pass anything you like into this view as ViewData

    Cheers,

    Marc

  • DuaneA 6 posts 86 karma points notactivated
    Apr 28, 2022 @ 13:40
    DuaneA
    0

    Thanks a million Marc - makes so much sense now you say it! Thanks for the prompt reply.

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    Apr 28, 2022 @ 14:17
    Paul Seal
    1

    Hi

    You can also get it like this from within ComponentOutro view:

    <p>Page Name: @(Umbraco.AssignedContentItem.Name)</p>
    

    Kind regards

    Paul

  • Marc Love (uSkinned.net) 432 posts 1691 karma points
    Apr 28, 2022 @ 15:34
    Marc Love (uSkinned.net)
    0

    Nice one @Paul Seal, never thought of that.

Please Sign in or register to post replies

Write your reply to:

Draft