Copied to clipboard

Flag this post as spam?

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


  • kylepauljohnson 70 posts 108 karma points
    Jul 01, 2010 @ 21:36
    kylepauljohnson
    0

    Rendering Macro Content via User Controls

    Hey there guys, I am using a user control to pull in content ID's that I want to display on a page.  I have split and can itterate through them getting the data from each, however some contain macro's in the RichTextArea's.

    How via .net can I tell those Macro's to render?  Code example below...

    Partial Class usercontrols_Widgets_sidebar_content
        Inherits System.Web.UI.UserControl
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim nodeId As New Integer
            Dim sideBarIds As String
            Dim contentId As Integer
    
            nodeId = umbraco.presentation.nodeFactory.Node.GetCurrent.Id
            uxTemp.Text = nodeId
            Dim myNode As New umbraco.presentation.nodeFactory.Node(nodeId)
    
            sideBarIds = myNode.GetProperty("sideBarContent").Value ' GET THE COMMA SEPERATED LIST OF ID'S
    
            Dim idArray As Object
            idArray = Split(sideBarIds, ",")
    
            For Each itm In idArray
                Integer.TryParse(itm, contentId)
                Dim dynamicNode As New umbraco.presentation.nodeFactory.Node(contentId)
                Response.Write("Your ID is: " & contentId)
                Response.Write(dynamicNode.GetProperty("pageContent").Value.ToString())
    
    
            Next itm
    
        End Sub
    End Class
  • kylepauljohnson 70 posts 108 karma points
    Jul 01, 2010 @ 21:46
    kylepauljohnson
    1

    YEAH!  I figured it out.  To close the loop and help anyone with the same issue, using the API you can do something like this for example.

    Response.Write(umbraco.library.RenderMacroContent(contentString, contentId))
  • Brian Scott 21 posts 41 karma points
    Jul 07, 2011 @ 15:36
    Brian Scott
    0

    Awesome, this post finally solved my issue for me today. I was unable to use the umbraco item server field in my masterpage as the data had to go through some token parse / replace functionality. Using your function I was then able to get my macros to render after drawing the page content through as a standard .net class property fetch.

    Thanks..

  • Brian Scott 21 posts 41 karma points
    Jul 07, 2011 @ 15:38
    Brian Scott
    0

    Although, the postback from within the macro is not working now. Hmmm.

    I might have to dig out a build of the umbraco source code at this rate and push my custom property retrieval logic into the underlying fetch mechanism.

Please Sign in or register to post replies

Write your reply to:

Draft