How to display user profile (instead of admin profile)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to display user profile (instead of admin profile)

Coleen_Astalos
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):  
<macro name="subscription_saved_url">
    <n.remove_spaces.>
        <n.page_node.base_url/>
        /template/NamlServlet.jtp?macro=subscription_saved&node=<n.page_node.id/>
    </n.remove_spaces.>
</macro> 

 <macro name="subscription_saved" requires="servlet">
    <n.node_page.>
        <n.subscription_msg
            header="[t]Subscription Confirmed[/t]"
            message="[t]Your subscription has been successfully saved.[/t]"
        />
    </n.node_page.>
</macro> 

 <override_macro name="subscription_msg" parameters="header,message">
    <n.html>
        <head>
            <n.title.><n.header/></n.title.>
            <n.main_title_css/>
        </head>
        <body>
            <n.visitor.profile_header/>
            <div class="shaded-bg-color rounded second-font main-title">
                <n.header/>
            </div>
 
            <table style="margin-bottom:1em">
                <tr valign="top">
                    <td><img src="/images/success.png" class="image16"/></td>
                    <td>
                        <b><n.message/></b>
                        <p><a href="[n.display_user_subscriptions_path/]"><t>Return to all Subscriptions Page</t></a></p>
                        <p><a href="[n.page_node.url/]"><t>Return to <t.location.page_node.subject/></t></a></p>
                    </td>
                </tr>
            </table>
        </body>
    </n.html>
</override_macro> 
And copied them to create new "user" versions...
<macro name="subscription_saved_user_url" requires="user">
   <n.set_local_user.this_user/>
   <n.remove_spaces.>
        <n.page_node.base_url/>
        /template/NamlServlet.jtp?macro=subscription_saved_user&node=<n.page_node.id/>&user=<n.local_user.id/>
    </n.remove_spaces.>
</macro>
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)
<macro name="subscription_saved_user" requires="servlet" >
    <n.node_page.>
        <n.subscription_msg_user
            header="[t]Subscription Confirmed[/t]"
            message="[t]User subscription has been successfully saved.[/t]"
        />
    </n.node_page.>
</macro>
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
Reply | Threaded
Open this post in threaded view
|

Re: How to display user profile (instead of admin profile)

Pedro
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.
Reply | Threaded
Open this post in threaded view
|

Re: How to display user profile (instead of admin profile)

Coleen_Astalos
Thanks.  I was able to get this & the unsubscribe user by admin code working.
Coleen