Re: How to display user profile (instead of admin profile)
Posted by
Pedro on
Feb 28, 2014; 12:58pm
URL: https://support.nabble.com/How-to-display-user-profile-instead-of-admin-profile-tp7589589p7589598.html
There are 3 ways to pass values to a macro: url, parameters and requires
1 url: This is when the argument is given via a "get" parameter in the url.
For example: www.url.com?var1=a&var2=b&var3=c
In order to use it at a macro you would have to call like this:
n.get_parameter name="val1" , n.get_parameter name="val2" and n.get_parameter name="val3". You would get the values a, b and c respectively.
In your case, since you used the user id at the url:
/template/NamlServlet.jtp?macro=subscription_saved_user&node=<n.page_node.id/>&user=<n.local_user.id/>You have to get this user in this way:
<n.set_local_user.get_user_from_id user_id="[n.get_parameter name='user'/]" />
2 parameters: example:
<macro name="macro_1">
<n.macro_2 val1="a"/>
</macro>
<macro name="macro_2" parameters="val1">
<n.val1/>
</macro>
Example in your code, you can pass an user object:
<macro name="save_field_values_user" requires="user">
<n.set_local_user.this_user/>
<n.set_local_subscription.page_node.subscription_for email="[n.local_user.user_email/]" />
<n.if.equal value1="save-subscription" value2="[n.action_parameter/]">
<then>
<n.local_subscription.save
to="[n.subscription_to_field.value/]"
type="[n.subscription_type_field.value/]"
/>
<n.page_node.sub_descendants_user user="[n.local_user/]"/> <----- parameter name is "user"
<n.redirect_to.subscription_saved_url/>
</then>
</n.if.equal>
</macro>
<macro name='sub_descendants_user' requires='node' parameters='user'>
<n.set_local_user.user/> <------- Getting the the value inside the parameter named as "user", and setting the local user
<n.set_local_subscription.page_node.subscription_for email="[n.local_user.user_email/]" />
....
3 requires:
Calling:
<n.user.macro_2/>
Using:
<macro name="macro_2" requires="user">
<n.set_local_user.this_user/>
</macro>