Copied to clipboard

Flag this post as spam?

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


  • dev-thandabantu 41 posts 321 karma points
    Aug 19, 2022 @ 05:58
    dev-thandabantu
    0

    Publish Content from a controller

    I have a list of all unpublished content displayed on a custom dashboard in my umbraco backoffice. I have a "Publish" button on each item that I want to use for publishing selected content. When I press this button, I hit my controller in Visual Studio. My Publish() method is as below: PublishContent Method

    When I hit the breakpoint, and inspect the publishContentModel, it always has 'ContentId = 0'.

    Here is my dashboard.html that passes the Id: enter image description here

    Here is the dashboard.controller.js:

    enter image description here

    More from the js file:

    more from js file

    Does anyone know why my Id is coming in as zero in my PublishContent function of the controller?

  • dev-thandabantu 41 posts 321 karma points
    Aug 20, 2022 @ 14:40
    dev-thandabantu
    100

    It turned out that there was no Id property in the object item in my html file. The Name is a property of the object and the Url as well. The URL has the Id appended at the end, so I ended up extracting the Id from the URL. I am sure there is a better way to get the Id and I will update here when I find it.

    I still don't fully understand how this object is constructed and how it lands up in this html files. So the learning journey continues.

Please Sign in or register to post replies

Write your reply to:

Draft