Copied to clipboard

Flag this post as spam?

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


  • Mark Wakelin 10 posts 79 karma points
    Mar 08, 2021 @ 11:38
    Mark Wakelin
    0

    Page within a page

    Hi everyone,

    This may be very simple to someone, but I have been scratching my head how to do it !

    I have created a Published Page / Document Type and I am looking to insert within this page a carousel displaying featured items.

    The featured items of this carousel are chosen as part of another Document Type (Content Page) with a Data Type (Multi-List) which I have created...

    Here is my issue...

    I am trying to get this featured page within the main page but I cant seem to do it. I always run into the usual errors of Model mis-match etc.

    I have tried adding

    @{ Html.RenderAction("Index", "FeaturedCarouselPage");  }
    

    to the Main Page html and,

    public override ActionResult Index(ContentModel model)
        {
            return CurrentTemplate(model);
        }
    

    in the controller, but I just get this error "No route in the route table matches the supplied values."

    Could anyone be kind enough to help me please?

    Many thanks Mark

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Mar 08, 2021 @ 11:55
    Huw Reddick
    0

    How is your controller defined? Why are you using override?

  • Mark Wakelin 10 posts 79 karma points
    Mar 08, 2021 @ 12:05
    Mark Wakelin
    0

    Hi I have to use override as Index is the RenderMvcController reserved page. I am not passing in any extra parameters so the signature is the same. Therefore i need to use override.

        public class FeaturedPageController : RenderMvcController
    {
        public override ActionResult Index(ContentModel model)
        {
            return CurrentTemplate(model);
        }
    }
    

    something like this..

    thanks Mark

  • Mark Wakelin 10 posts 79 karma points
    Mar 08, 2021 @ 12:07
    Mark Wakelin
    0

    I should also add, i am using "Index" as I thought this was the only way to access the Data Type List i have used on the Content Model of the page...

    Otherwise, I would have just created another ActionResult page

    Thank you Mark

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Mar 08, 2021 @ 14:03
    Huw Reddick
    0

    your fist piece of code references FeaturedCarouselPage

    you say your controller is called FeaturedPageController so you have a mismatch.

    I am not using override, infact VS complains if you do as no overrideable method

  • Mark Wakelin 10 posts 79 karma points
    Mar 08, 2021 @ 14:27
    Mark Wakelin
    0

    Sorry, my mistake.

    The Controller is FeaturedCarouselPageController

    I will try "not" using override now...

    thanks Mark

  • Mark Wakelin 10 posts 79 karma points
    Mar 08, 2021 @ 14:34
    Mark Wakelin
    0

    Hi Huw,

    Just tried it and I get same issue.

    "No route in the route table matches the supplied values."

    Thanks Mark

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Mar 08, 2021 @ 15:02
    Huw Reddick
    0

    I don't think you can call a rendermvc controller using RenderAction, it is meant for hijacking a page url, you should probably be using a surfacecontroller to do what you are trying.

  • Mark Wakelin 10 posts 79 karma points
    Mar 08, 2021 @ 15:41
    Mark Wakelin
    0

    ah ok, I will try that Huw,

    Thank you Mark

  • Mark Wakelin 10 posts 79 karma points
    Mar 08, 2021 @ 15:50
    Mark Wakelin
    0

    looks like by inheriting from SurfaceController, I lose the ability to return CurrentTemplate.

            public ActionResult Index(ContentModel model)
        {
            return CurrentTemplate(model);
        }
    

    as CurrentTemplate does not exist in the current context

    Arghhhh !

    Thanks Mark

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Mar 08, 2021 @ 16:38
    Huw Reddick
    0

    you can't render a page within a page, your carousel should use a partial view that is returned by the controller.

    normally you would define your carousel as a doctype and add that doctype to your main document type where you then add the images etc.

    try looking at the codeshare starter kit, it contains code for a carousel

  • Mark Wakelin 10 posts 79 karma points
    Mar 08, 2021 @ 16:56
    Mark Wakelin
    0

    Hi Huw,

    thanks for helping, i have done this.

    My issue is still that i want the images to be added via Umbraco, and not "hard-coded" onto the partial view.

    Thanks Mark

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Mar 08, 2021 @ 18:12
    Huw Reddick
    0

    Checkout the codeshare starter kit, the images are added via the back office they are not hard coded in the partial view

  • Mark Wakelin 10 posts 79 karma points
    Mar 08, 2021 @ 19:43
    Mark Wakelin
    0

    Thanks Huw, just Googled it.

    Will take a look.

    Mark

Please Sign in or register to post replies

Write your reply to:

Draft