ExtraLicense - Buy, Sell, & Trade Your Licenses

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Username Variable in XenForo Template

Dan

Well-known member
Valued Member
Vincent! :p

I am trying to add the code you gave me (below) into an addon so I don't have to manually edit the templates.

Code:
<xen:if is="{$post.isFirst} AND !{$isQuickReply}">
<center>
<a href="conversations/add?to={$user.username}" title="Send a PM">Send a PM</a>
</center>
</xen:if>
However, when called via a hook, none of the {} variables are working. What am I doing wrong?

 
This is normal.

There are quite a few add-ons who use that, for example [LN] Blog :)

Take a look at that.

"It's better to learn Dan how to fish then catching him fish", so go learn how to do it :D

If you really can't do it, feel free to contact me again :)

 
Update: I got the username worked out but this

Code:
<xen:if is="{$post.isFirst} AND !{$isQuickReply}">
Still doesn't work. Off to play some more.

 
What you can do best is tell the hook to read the code from a new template.

I have no idea how to do it the other way myself :D

 
Vincent! :p
I am trying to add the code you gave me (below) into an addon so I don't have to manually edit the templates.

Code:
<xen:if is="{$post.isFirst} AND !{$isQuickReply}">
<center>
<a href="conversations/add?to={$user.username}" title="Send a PM">Send a PM</a>
</center>
</xen:if>
However, when called via a hook, none of the {} variables are working. What am I doing wrong?
I would not use center tag's ever on my site. The problems you can get from them are just not worth it imo

use css to center it.

 
  • Like
Reactions: Dan
I would not use center tag's ever on my site. The problems you can get from them are just not worth it imouse css to center it.
Yeah true,

I've done it quickly previous time but I'm not sure on how far Dan is with adding this as a hook :D if he needs help he can contact me

 
well, right now I cannot get

Code:
{$post.isFirst}
to pass to the hook, which is pretty important to the functionality we are trying to achieve. I thought I read that the $post variable will be exposed in 1.03. So I am not sure this is even possible at the moment. Once I get that variable passed, the only thing left to do is create a css template for the addon and we are golden.

I think once I figure out what xenforo is doing, I will like it. Right now, I think vBulletin is much easier to code for.




 
Right now, I think vBulletin is much easier to code for.
Sometimes I think the same :/

this might help I see your post above you have "AND" try "&&"

example

Code:
<xen:if is="!{$visitor.user_id} && !{$post.isFirst}">
 
Code:
<xen:if is="!{$visitor.user_id} && !{$post.isFirst}">
Ah, right you are. However still doesn't pass. :confused: Close to posting on xenforo for help but want to make sure I don't make an ass out of myself :p

 
Ah, right you are. However still doesn't pass. :confused: Close to posting on xenforo for help but want to make sure I don't make an ass out of myself :p
What are you trying to do? care to explain some more?

 
Ah, right you are. However still doesn't pass. :confused: Close to posting on xenforo for help but want to make sure I don't make an ass out of myself :p
Mate, I have time tonight, I'll do it :)

Then you can look at the code afterworth and learn out of it :D

 
  • Like
Reactions: Dan
@Vincent had a brilliant idea to add a "Send a Message" link to the OP in the Swap Shop section only to make it easier to make an offer. See screenshot. However, we only want this message to show on the OP. So all we are doing is checking if it is the first post, checking to make sure we are in the right forum (using array admin options to check node id) and displaying the link below the avatar.

The problem: I have a template with the following contents (well it has since changed but doesn't matter)

Code:
<xen:if is="{$post.isFirst} AND !{$isQuickReply}">
<center>
<a href="conversations/add?to={$user.username}" title="Send a PM">Send a PM</a>
</center>
</xen:if>
Works great by editing the correct template and using:

Code:
<xen:include template="whatever" />
But the minute I call it with a templateHook listener, $post.isFirst dies.

Clear as mud? :p

Capture.JPG

 
Mate, I have time tonight, I'll do it :) Then you can look at the code afterworth and learn out of it :D
Thought the idea of a forum is to post. Looking at this site the more content viewable to the public is better...

 
@Vincent had a brilliant idea to add a "Send a Message" link to the OP in the Swap Shop section only to make it easier to make an offer. See screenshot. However, we only want this message to show on the OP. So all we are doing is checking if it is the first post, checking to make sure we are in the right forum (using array admin options to check node id) and displaying the link below the avatar.
The problem: I have a template with the following contents (well it has since changed but doesn't matter)

Code:
<xen:if is="{$post.isFirst} AND !{$isQuickReply}">
<center>
<a href="conversations/add?to={$user.username}" title="Send a PM">Send a PM</a>
</center>
</xen:if>
Works great by editing the correct template and using:

Code:
<xen:include template="whatever" />
But the minute I call it with a templateHook listener, $post.isFirst dies.

Clear as mud? :p

View attachment 6
Works fine for me

with a simple template edit.

Code:
<xen:require css="message_user_info.css" />

<div class="messageUserInfo" itemscope="itemscope" itemtype="http://data-vocabulary.org/Person">
<div class="messageUserBlock">
   <xen:hook name="message_user_info_avatar" params="{xen:array 'user={$user}', 'isQuickReply={$isQuickReply}'}">
       <div class="avatarHolder">
           <xen:avatar user="$user" size="m" />
           <!-- slot: message_user_info_avatar -->
       </div>
   </xen:hook>

<xen:if is="!{$isQuickReply}">
   <xen:hook name="message_user_info_text" params="{xen:array 'user={$user}', 'isQuickReply={$isQuickReply}'}">
       <h3 class="userText">
           <xen:username user="$user" itemprop="name" rich="true" />
           <xen:if hascontent="true"><em class="userTitle" itemprop="title"><xen:contentcheck>{xen:helper userTitle, $user}</xen:contentcheck></em></xen:if>
           <!-- slot: message_user_info_text -->
       </h3>
   </xen:hook>

   <xen:if hascontent="true">
       <div class="extraUserInfo">
           <xen:contentcheck>
<xen:if is="{$post.isFirst} AND !{$isQuickReply}">
<a href="http://localhost/index.php?conversations/add&to={$user.username}" title="Send a PM">Send a PM</a>
</xen:if>
           <xen:hook name="message_user_info_extra" params="{xen:array 'user={$user}', 'isQuickReply={$isQuickReply}'}">
               <xen:if is="@messageShowRegisterDate">
                   <dl class="pairsInline">
                       <dt>{xen:phrase member_since}:</dt>
                       <dd>{xen:date $user.register_date}</dd>
                   </dl>
               </xen:if>

               <xen:if is="@messageShowMessageCount">
                   <dl class="pairsInline">
                       <dt>{xen:phrase message_count}:</dt>
                       <dd><a href="{xen:link search/member, '', 'user_id={$user.user_id}'}" class="concealed">{xen:number $user.message_count}</a></dd>
                   </dl>
               </xen:if>

               <xen:if is="@messageShowTotalLikes">
                   <dl class="pairsInline">
                       <dt>{xen:phrase likes_received}:</dt>
                       <dd>{xen:number $user.like_count}</dd>
                   </dl>
               </xen:if>

               <xen:if is="@messageShowTrophyPoints">
                   <dl class="pairsInline">
                       <dt>{xen:phrase trophy_points}:</dt>
                       <dd><a href="{xen:link 'members/trophies', $user}" class="OverlayTrigger concealed">{xen:number $user.trophy_points}</a></dd>
                   </dl>
               </xen:if>

               <xen:if is="@messageShowGender AND {$user.gender}">
                   <dl class="pairsInline">
                       <dt>{xen:phrase gender}:</dt>
                       <dd itemprop="gender"><xen:if is="{$user.gender} == 'male'">{xen:phrase male}<xen:else />{xen:phrase female}</xen:if></dd>
                   </dl>
               </xen:if>

               <xen:if is="@messageShowOccupation AND {$user.occupation}">
                   <dl class="pairsInline">
                       <dt>{xen:phrase occupation}:</dt>
                       <dd itemprop="role">{xen:string censor, $user.occupation}</dd>
                   </dl>
               </xen:if>

               <xen:if is="@messageShowLocation AND {$user.location}">
                   <dl class="pairsInline">
                       <dt>{xen:phrase location}:</dt>
                       <dd><a href="{xen:link 'misc/location-info', '', 'location={xen:string censor, $user.location}'}" target="_blank" rel="nofollow" itemprop="address" class="concealed">{xen:string censor, $user.location}</a></dd>
                   </dl>
               </xen:if>

               <xen:if is="@messageShowHomepage AND {$user.homepage}">
                   <dl class="pairsInline">
                       <dt>{xen:phrase home_page}:</dt>
                       <dd><a href="{xen:string censor, $user.homepage}" rel="nofollow" target="_blank" itemprop="url">{xen:string censor, $user.homepage}</a></dd>
                   </dl>
               </xen:if>

               <xen:comment>
               <xen:foreach loop="{$user.identities}" key="$service" value="$account">
                   <dl class="pairsInline">
                       <dt>{$service}</dt>
                       <dd>{$account}</dd>
                   </dl>
               </xen:foreach>
               </xen:comment>

           </xen:hook>
           </xen:contentcheck>
       </div>
   </xen:if>

</xen:if>

   <span class="arrow"><span></span></span>
</div>
</div>
fine.jpg

 
@Vincent had a brilliant idea to add a "Send a Message" link to the OP in the Swap Shop section only to make it easier to make an offer. See screenshot. However, we only want this message to show on the OP. So all we are doing is checking if it is the first post, checking to make sure we are in the right forum (using array admin options to check node id) and displaying the link below the avatar.
The problem: I have a template with the following contents (well it has since changed but doesn't matter)

Code:
<xen:if is="{$post.isFirst} AND !{$isQuickReply}">
<center>
<a href="conversations/add?to={$user.username}" title="Send a PM">Send a PM</a>
</center>
</xen:if>
Works great by editing the correct template and using:

Code:
<xen:include template="whatever" />
But the minute I call it with a templateHook listener, $post.isFirst dies.

Clear as mud? :p

View attachment 6
Could you give me temporary FTP and Admin mod at the site?

You can remove it afterworth :D

I'll create the hook and explain it after :)

 
@Vodka

Well, I hope you understand some sellers don't like to talk business in public ;)

And we already got that, but Dan is trying to do it with a hook and he doesn't know how :(

Therefor I'll create the mod to learn :D

 
Works fine for mewith a simple template edit.
Yes, it does work when editing the template, but when calling that code with a templateHook, it does not.

Could you give me temporary FTP and Admin mod at the site?You can remove it afterworth :D

I'll create the hook and explain it after :)
Yes sir, give me a minute.

 
@VodkaWell, I hope you understand some sellers don't like to talk business in public ;)

And we already got that, but Dan is trying to do it with a hook and he doesn't know how :(

Therefor I'll create the mod to learn :D
Ah I see such a small mod :) am lazy template edit would do fine for me :D

 
  • Like
Reactions: Dan
Yes, it does work when editing the template, but when calling that code with a templateHook, it does not.


Yes sir, give me a minute.
Thanks :D

And I had that error too in the beginning :p

Now, after seeing some code, I understand ;)

 
Top