Using of RenderMacro datatype with actualized parameters
Hi in a 4.11.4 all MVC, I have a document type, used to hold the registration data of an user to an event. I have a MemberPicker field that points at this user. In a tab of the backoffice, I would like to see, with RenderMacro, some data of user's profile. Can I pass to RenderMacro the value of MemberPicker as a parameter ? In this way, the Editors could know (read only) some information about the user (name, phone, etc), without access to the Members section.
So what you're asking is that if you have a member picker property on a document type, would it be possible to have some basic information about this member displayed in the backoffice for the content editors to see?
Eventually, the MemberPicker could be replaced with a label (readonly for editors), written by the surface controller that manages the registration form. in any case, the ID of the member is available.
todayI implementedthis part of thesite andyour suggestionhas been very useful. For those interested, this ismy solution.
I have a DocumentType named "Application" that contains a member picker named"Company" (hidden with uHidesy and for administrative use only).
I created a macro named "CompanyInfo" associated with the razor script below and a DataType named "CompanyInfo Render Macro" obviously based on uComponents Render Macro and with Macro Editor setted at "CompanyInfo" . Then, in "Application" I added a "Company" tab and, within, a field of type "CompanyInfo Render Macro".
The razor script for macro, which render an address field of the member, is this:
@inherits umbraco.MacroEngines.DynamicNodeContext @using umbraco.cms.businesslogic.member; @using System.Web.Profile; @{ string applicationId = Request.QueryString["id"]; var application = Library.NodeById(applicationId); int memberId = application.Company;
Member member = new Member(memberId); var profile = ProfileBase.Create(member.LoginName); } <h2>@member.Text</h2> <div class="propertyItem"> <div class="propertyItemheader">Address</div> <div class="propertyItemContent">@profile["address"]</div> </div>
Using of RenderMacro datatype with actualized parameters
Hi
in a 4.11.4 all MVC, I have a document type, used to hold the registration data of an user to an event. I have a MemberPicker field that points at this user. In a tab of the backoffice, I would like to see, with RenderMacro, some data of user's profile.
Can I pass to RenderMacro the value of MemberPicker as a parameter ?
In this way, the Editors could know (read only) some information about the user (name, phone, etc), without access to the Members section.
Thank you,
Fabry
Hi Fabry and welcome to our :)
So what you're asking is that if you have a member picker property on a document type, would it be possible to have some basic information about this member displayed in the backoffice for the content editors to see?
Or do I misunderstand your question?
Looking forward to hearing from you.
/Jan
Hi Jan
thanks for your quick assistance :-)
Exactly this !
Eventually, the MemberPicker could be replaced with a label (readonly for editors), written by the surface controller that manages the registration form. in any case, the ID of the member is available.
Thanks,
Fabry
Hi Fabry,
Good question. As far as I know, there isn't a way to pass parameters into the macro when using the RenderMacro data-type.
However if the member's ID (property value) is published, then it is possible to retrieve that data from within the macro itself.
Hi Lee,
Thanks for your suggestion!
I'll try and I'll keep you informed :-)
btw, this could be a nice feature for a futur release
Regards,
Fabry
Hi Lee,
today I implemented this part of the site and your suggestion has been very useful.
For those interested, this is my solution.
I have a DocumentType named "Application" that contains a member picker named "Company" (hidden with uHidesy and for administrative use only).
I created a macro named "CompanyInfo" associated with the razor script below and a DataType named "CompanyInfo Render Macro" obviously based on uComponents Render Macro and with Macro Editor setted at "CompanyInfo" . Then, in "Application" I added a "Company" tab and, within, a field of type "CompanyInfo Render Macro".
The razor script for macro, which render an address field of the member, is this:
@inherits umbraco.MacroEngines.DynamicNodeContext
@using umbraco.cms.businesslogic.member;
@using System.Web.Profile;
@{
string applicationId = Request.QueryString["id"];
var application = Library.NodeById(applicationId);
int memberId = application.Company;
Member member = new Member(memberId);
var profile = ProfileBase.Create(member.LoginName);
}
<h2>@member.Text</h2>
<div class="propertyItem">
<div class="propertyItemheader">Address</div>
<div class="propertyItemContent">@profile["address"]</div>
</div>
I hope it can be useful to someone.
Bye,
Fabry
is working on a reply...