<p>Since you're just expecting one, you should only look for one. Then you don't have to use a for loop. Plus, fullName is already an attribute of user models. So you can do this for the title:</p>

<pre><code>{% set thePartner = craft.users.username( craft.request.getSegment(2) ).first() %}
&lt;title&gt;{{ thePartner.fullName }} | {{ siteUrl }} &lt;/title&gt;
</code></pre>

<p>If you're still having trouble, it may be with what segments you are pulling from the URL.</p>

CC BY-SA 3.0
2014-08-02T13:12:34.870Z
2014-08-02T13:12:34.870Z
Bryan Redeagle
<p>I am trying to pass a member's <code>firstName</code> and <code>lastName</code> to the title on a member profile page. I am using segment 2 to capture the username. This works well in the <code>for</code> loop in the <code>block</code>:</p>

<pre><code>{% set thePartner = craft.users.username( craft.request.getSegment(2) ) %}
{% for partner in thePartner %}
First Name and Last Name: {{ partner.firstName}} {{ partner.lastName }}
{% endfor %)
</code></pre>

<p>Outside the <code>block</code>, where I set the <code>&lt;title&gt;</code>, it doesn't work. Essentially, I would like to set the full name and use it in the title, like: </p>

<pre><code>{% set fullname = partner.firstName ~ ' ' ~ partner.lastName %}
</code></pre>

<p>with something like the following in _layout: </p>

<pre><code>&lt;title&gt;{{ fullname }} | {{ siteUrl }} &lt;/title&gt;
</code></pre>

<p>How can I pass the full name through?</p>

CC BY-SA 3.0
2014-08-02T17:00:54.683Z
As you probably don't have only profile pages on your site, remember to only render `fullname` into the `<title>` of your `_layout` template if the var is actually set: `{{ fullname ? fullname ~ '|' }}`!
carlcs
<templating><users>
How do I pass a user's first name and last name from a user profile page to the title in _layout?
# How do I pass a user's first name and last name from a user profile page to the title in _layout?

(Asked by: username_0 on 2014-08-02)

I am trying to pass a member's firstName and lastName to the title on a member profile page. I am using segment 2 to capture the username. This works well in the for loop in the block:
{% set thePartner = craft.users.username( craft.request.getSegment(2) ) %}
{% for partner in thePartner %}
First Name and Last Name: {{ partner.firstName}} {{ partner.lastName }}
{% endfor %)

Outside the block, where I set the , it doesn't work. Essentially, I would like to set the full name and use it in the title, like: 
{% set fullname = partner.firstName ~ ' ' ~ partner.lastName %}

with something like the following in _layout: 
{{ fullname }} | {{ siteUrl }} 

How can I pass the full name through?

**Tags:** templating, users
> **Comments:**
> **username_1**: As you probably don't have only profile pages on your site, remember to only render `fullname` into the `<title>` of your `_layout` template if the var is actually set: `{{ fullname ? fullname ~ '|' }}`!  

---

## 1 answers

### Answer by username_2 on 2014-08-02. Score: 5 | Accepted answer

Since you're just expecting one, you should only look for one. Then you don't have to use a for loop. Plus, fullName is already an attribute of user models. So you can do this for the title:
{% set thePartner = craft.users.username( craft.request.getSegment(2) ).first() %}
{{ thePartner.fullName }} | {{ siteUrl }} 

If you're still having trouble, it may be with what segments you are pulling from the URL.


---

