Copied to clipboard

Flag this post as spam?

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


  • Mark Lawson 5 posts 25 karma points
    Feb 21, 2011 @ 06:41
    Mark Lawson
    0

    Specify macro alias from generic property

    I have made a Document Type that allows a macro property to be set. Within the page template I have the following;

    <umbraco:Macro Alias="[#PageMacro]" runat="server" ></umbraco:Macro>

    However the macro is not being executed. Any tips as to what I may be doing wrong?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 21, 2011 @ 08:17
    Jan Skovgaard
    0

    Hi Mark

    I'm not sure it's possible to use page values in the alias attribute...but I could be wrong here.

    Is the macro working if you hardcode the value into the alias?

    /Jan

  • Mark Lawson 5 posts 25 karma points
    Feb 22, 2011 @ 01:41
    Mark Lawson
    0

    Hi Jan,

     

    Yes the macro works fine when hardcoded. I thought perhaps using XSLT to produce the <umbraco:Macro> might work however I have had no luck.

  • Brad Hunt 26 posts 57 karma points
    Feb 22, 2011 @ 03:53
    Brad Hunt
    0

    Mark,

    Does your macro use XSLT or a .NET user control? Are you able to post the XSLT or .NET code to see how the property is implemented?

    Brad

  • Mark Lawson 5 posts 25 karma points
    Feb 22, 2011 @ 04:02
    Mark Lawson
    0

    It is implemented as a .NET control. As you can imagine I am trying to use a template on many pages, each of which can use a different macro on it. I cant post the code at this stage but it and the others I intend to use work fine when I hardcode the alias.

  • Brad Hunt 26 posts 57 karma points
    Feb 22, 2011 @ 04:09
    Brad Hunt
    0

    Mark-

    It sounds like you are trying to dynamically change the macro that is rendered on the template at run time based on which page is being rendered. Is that right? so all pages might have common header, footer, navigation, but the news page loads the news macro and the calendar page loads the calendar macro or something along those lines?

    Brad

  • Mark Lawson 5 posts 25 karma points
    Feb 22, 2011 @ 04:15
    Mark Lawson
    0

    Yes that is correct :)

  • Brad Hunt 26 posts 57 karma points
    Feb 22, 2011 @ 04:32
    Brad Hunt
    0

    Mark-

    In that case, could the .NET control handle all the logic that you are trying to dictate with the property? For example, using request.querystring inside the control and letting it vary the output based on the querystring or URL, etc? Or if your architecture allows, just keep the macros seperated out into different logical parts and then add the specific macro to the page itself in the content tree - just use the insert macro button in the rich text editor for the page.

    Brad

  • Mark Lawson 5 posts 25 karma points
    Feb 23, 2011 @ 02:01
    Mark Lawson
    0

    I like the idea of having a .NET control that is responsible for determining the output. I will investigate this, thank you :)

    There still is the greater issue of why can't I see the macro alias from a page property... perhaps it is a bug?

  • Brad Hunt 26 posts 57 karma points
    Feb 23, 2011 @ 03:54
    Brad Hunt
    0

    In my experience, passing variables from the macro to the .NET control is something like the following:

    1) create public properties in your usercontrol:

     

    private string _EmailReceipent;
        public string EmailReceipent
        {
            get { return _EmailReceipent; }
            set { _EmailReceipent = value; }
        }
        private string _EmailSender;
        public string EmailSender
        {
            get { return _EmailSender; }
            set { _EmailSender = value; }
        }
        private string _SMTPServer;
        public string SMTPServer
        {
            get { return _SMTPServer; }
            set { _SMTPServer = value; }
        }

     

    2) pass the values into the code from the macro like this:

    <div class="umbMacroHolder" title="This is rendered content from macro" umbpageid="1107" umbversionid="af03cb68-2aab-4e8c-b590-179db53aea7d" onresizestart="return false;" ismacro="true" umb_emailsender="[email protected]" umb_emailreceipent="[email protected]" umb_macroalias="ContactForm" umb_smtpserver="mail.mail.com">
    </div>
    

    ...but that still does not make the property dynamic at run time. It is still "static" in the declarative code.

Please Sign in or register to post replies

Write your reply to:

Draft