• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

how to... <xen:if is="not self">

dieketzer

Well-known member
#1
i am trying to hide something on a users profile page from them.
specifically, the status input box.
i see the form, but i cannot remove it or else nobody can leave a message on their profile. id like to use something like xen:if is="{$user.is_notself}" to hide this, but i am not sure what conditional will accomplish this.
what can i use to accomplish xen:if is="{$user.is_notself"?
 

Jake Bunce

XenForo moderator
Staff member
#2
Are you talking about this posting box on profile pages?

Screen shot 2010-11-27 at 9.51.43 AM.png

Admin CP -> Appearance -> Templates -> member_view

Change the first line of this code:

Code:
				<xen:if is="{$canPostOnProfile}">
					<form action="{xen:link members/post, $user}" method="post"
						class="messageSimple profilePoster AutoValidator primaryContent" id="ProfilePoster"
						data-optInOut="optIn">
						<xen:avatar user="$visitor" size="s" />
						<div class="messageInfo">
							<xen:if is="{$visitor.user_id} == {$user.user_id}">
								<textarea name="message" class="textCtrl StatusEditor Elastic" placeholder="{xen:phrase update_your_status}..." rows="3" cols="50" data-statusEditorCounter="#statusEditorCounter"></textarea>
							<xen:else />
								<textarea name="message" class="textCtrl Elastic" placeholder="{xen:phrase write_something}..." rows="3" cols="50"></textarea>
							</xen:if>
...like so:

Code:
				<xen:if is="{$canPostOnProfile} AND {$visitor.user_id} != {$user.user_id}">
					<form action="{xen:link members/post, $user}" method="post"
						class="messageSimple profilePoster AutoValidator primaryContent" id="ProfilePoster"
						data-optInOut="optIn">
						<xen:avatar user="$visitor" size="s" />
						<div class="messageInfo">
							<xen:if is="{$visitor.user_id} == {$user.user_id}">
								<textarea name="message" class="textCtrl StatusEditor Elastic" placeholder="{xen:phrase update_your_status}..." rows="3" cols="50" data-statusEditorCounter="#statusEditorCounter"></textarea>
							<xen:else />
								<textarea name="message" class="textCtrl Elastic" placeholder="{xen:phrase write_something}..." rows="3" cols="50"></textarea>
							</xen:if>
That gives you the "and user not viewing their own profile" condition. The result is that the posting box only shows if you are viewing some one else's profile. But you can still reply to existing profile comments.

Try it out to see if this is what you wanted.
 

dieketzer

Well-known member
#3
you are a god amongst men!
would you know of the location of something like a list of known conditionals?

this is great, it solves a real annoyance for me; people accidentally posting profile comment replies as status updates!
i love you jake :)
 

Jake Bunce

XenForo moderator
Staff member
#4
would you know of the location of something like a list of known conditionals?
There isn't a comprehensive list. But if you know how to find the root template and the viewParams for a page then you have all of the tools to build conditionals:

http://xenforo.com/community/threads/1-0-0-b1-how-to-identify-the-root-template-of-a-page.5591/
http://xenforo.com/community/threads/1-0-0-b1-finding-variables-available-to-templates.6071/

Though you don't always have to dig into the code to find variables to use. Your conditional was actually used elsewhere in the member_view template:

Code:
{$visitor.user_id} == {$user.user_id}
I just changed it to "not equal" for your purposes:

Code:
{$visitor.user_id} != {$user.user_id}