Copied to clipboard

Flag this post as spam?

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


  • Mihail 39 posts 142 karma points
    Sep 07, 2016 @ 09:55
    Mihail
    0

    How to access a macro view in url

    Hi,

    I created a macro for rendering an RSS feed.

    I created a partial view in MacroPartials folder and there I put a cshtml file.

    After that, I registered that view in Developer->Macro (in Umbraco CMS) and I add one called Feed and specified the relative url to cshtml file.

    FeedMacro.cshtml

    // logic here to construct RSS feed
    

    I created another view, in Views folder called Feed.cshtml and I wrote:

    @inherits UmbracoTemplatePage
    
    @{
       Layout = null;
       Response.ContentType = "application/xml";
    }
    
    @Umbraco.RenderMacro( "Feed" )  // which is registered in Developer section
    

    I want to access that feed like:

    http://blabla.com/feed

    What should I do ? What I missed ?

    Thanks

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Sep 07, 2016 @ 10:29
    Dave Woestenborghs
    1

    HI Mihail,

    Is this Feed.cshtml created as a template in Umbraco. Than you would be able to call with the url that you specified.

    Or with http://blabla.com/feed?altTemplate=feed

    Dave

  • Tommy Enger 72 posts 277 karma points c-trib
    Sep 07, 2016 @ 11:33
    Tommy Enger
    100

    I assume that you've created a document type using the Feed.cshtml as it's view? And that you added a page of this document type to the content tree and named it "Feed"?

    What message do you get when accessing http://blabla.com/feed ? 404?

    Why do you wan't the logic in a macro instead of the view?

  • Mihail 39 posts 142 karma points
    Sep 07, 2016 @ 12:35
    Mihail
    0

    Creating the template did the trick. Thanks

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Sep 07, 2016 @ 12:37
    Dave Woestenborghs
    0

    Hi Mihail,

    Nice to see you got it working. Don't forget to mark the post with a solution so others can find it quickly as well.

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft