Ok, I'm pulling my hair out. I just don't understand the NAML well enough to figure out how to make the change to show the users profile who I just edited in the subscription_msg code (instead of the Admin users). <n.visitor.profile_header/> gives me my admin user profile and I know that's what I need to change. So this is what I've done...
So I started with this (base Nabble): And copied them to create new "user" versions... I wasn't sure if I needed to add the &user to the URL to be able to get the user info into the subscription_saved_user macro. Then I updated the subscription_saved_user macro to this (just changing to call subscription_msg_user instead) But I couldn't figure out how to change subscription_msg_user to get the "user" information to it. When I tried to add the requires="user" to the macro name line, it doesn't like it. So then I tried to add "user" to the parameter list and pass it in as a parameter - which appeared worked, but then it didn't like the setting of local_user to either "this_user" or just "user", so I could change the profile header line to <n.local_user.profile_header/> I'm sure it's probably something relatively simple that I'm just not getting. I was hoping if I could figure this out, then maybe I could figure out how to make the "unsubscribe" work for the administrator on the user_nodes page we set up. I'm really trying to do this without pestering you too much as I know you've probably had enough of me right now. Thanks, Coleen |
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>
My test forum.
|
Thanks. I was able to get this & the unsubscribe user by admin code working.
Coleen |
Free forum by Nabble | Edit this page |