Copied to clipboard

Flag this post as spam?

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


  • Jon 7 posts 88 karma points
    Jan 27, 2015 @ 00:53
    Jon
    0

    Partial view macro for a custom data table

    I have a site written in Umbraco 4.7 which I am rewriting in 7.2.1 to make it more mobile friendly. I'm new to MVC and to grid layout.

    I have a custom DB table which contains text strings. In 4.7 I used an xslt extension and an xslt macro to retrieve and display the appropriate string. I now want to retrieve a string and display it in a layout grid cell on the front page. It seems the way to do this would be to write a partial view macro and include it in the front page grid layout. (I have some other partial view macros which access standard Umbraco published content and they work fine.)

    What should the custom controller inherit from?

    public class customStringController : <????>

    How do I access that controller from the .cshtml partial view macro file?

    @inherits Umbraco.Web.Macros.PartialViewMacroPage<???>

    Do I need to write a model or can I just access the DB from the controller? (The strings are not changed or updated from the web site, just displayed.)

    Is there an example somewhere where this has already been answered?

    Thanks - Jon

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jan 27, 2015 @ 07:02
    Dennis Aaen
    0

    Hi Jon and welcome to our,

    Perhaps this video  http://www.aptitude.co.uk/videos/using-custom-tables-data-in-umbraco/ from Aptitude can help you how to make a Partial view macro for a custom data table  and try to see this topic as well. http://our.umbraco.org/forum/developers/api-questions/49406-Get-data-from-custom-table-into-view,-using-petapoco-

    Hope this helps,

    /Dennis

  • Jon 7 posts 88 karma points
    Jan 27, 2015 @ 16:08
    Jon
    0

    Thank you - I'll look at them.

Please Sign in or register to post replies

Write your reply to:

Draft