<p>Based on your response to the answer from @Andre, you could make a "Featured" lightswitch field and use that in your query.</p>

<p>So, you would add a Lightswitch Field called "Featured" (handle: featured) or something of the sort. Then, from the entry itself you Toggle this on for the one you want to show up on the homepage.</p>

<p>The code would change to:</p>

<pre><code>{% set featuredEntry = craft.entries.section('offices').featured(1).first %}
{{ featuredEntry.title }}
</code></pre>

<p>This has the tertiary benefit of the CMS controlling which office hours show up on the homepage should they need to be changed by the client. Just be wary if multiple lightswitches are turned "on". I believe it would take the first one in the sort order in that case.</p>

<p><strong>Update</strong></p>

<p>Based on the comment below, you could solve this by creating a Drop Down field with days of the week as the Key => Value pairs, and then query your entries based on the day of the week it is:</p>

<p>Dropdown field with a handle of <code>featuredDay</code> with options:</p>

<pre>
 -----------------
| label  | value  |
 -----------------
| Sunday | sunday |
 -----------------
| Monday | monday |
</pre>

<p>etc.</p>

<p>Then in your template:</p>

<pre><code>{% set featuredEntry = craft.entries.section('offices').featuredDay(now|date('l')|lower).first %}
{{ featuredEntry.title }}
</code></pre>

CC BY-SA 3.0
2014-09-30T15:17:23.693Z
thx for your input, great idea, but the openings hours will be visible for certain days in the week. Monday > Albuquerque, Tuesday > Boston, etc..
eek-a-edge
CC BY-SA 3.0
2014-09-30T16:58:26.750Z
Sure. So, there's a number of ways you could handle this, but one way using the above method would be use a featured Drop down field instead. I've updated the answer with this use case.
Peter Tell
CC BY-SA 3.0
2014-09-30T18:17:31.457Z
thx.. it did it like this `{% for entry in craft.entries.section('offices').level(2) %}
{% if entry.dayOfEvent == "now" | date("l") %}
 {# output #}
{% endif %}
{% endfor %}`
eek-a-edge
CC BY-SA 3.0
2014-09-30T15:00:43.470Z
2014-09-30T17:05:53.397Z
2014-09-30T17:05:53.397Z
Peter Tell
<p>To get a specific entry you need to know the id or slug of the entry. If the slug for Chicago is "chicago" (you find the slug in the side panel of the entry edit screen), you can get it like this:</p>

<pre><code>{% set chicagoEntry = craft.entries.slug('chicago') %}
</code></pre>

<p>But hardcoding slugs and id's into templates is rarely a good idea. If you explain a bit more what you're trying to achieve, maybe we can provide a more helpful answer.</p>

<p>If you're trying to turn the structure into a menu of sorts, have a look at the <a href="http://buildwithcraft.com/docs/templating/nav" rel="nofollow">documentation for the {% nav %} function</a>, it was made specifically for this.</p>

CC BY-SA 3.0
2014-09-30T11:01:34.070Z
Thx.. Indeed i'm trying to avoid hardcoding as much as possible. I'm trying to understand how structures work and how i can target certain pages within my structure. I need to give a listing of all offices and  also list the openingshours of a certain office on the home page.
eek-a-edge
CC BY-SA 3.0
2014-09-30T10:48:39.270Z
2014-09-30T10:48:39.270Z
André Elvan
<p>In a structure like the following:</p>

<pre><code>Offices             US          Albuquerque
[offices]                       Boston
                                Chicago
                                Denver

                    Mexico      Acapulco
                                Buenavista
                                Chihuahua

                    Canada      Ajax
                                Brampton
</code></pre>

<p>writing this code on the offices overview page</p>

<pre><code>{% for entry in craft.entries.section('offices') %}

&lt;h2&gt;{{ entry.title }}&lt;/h2&gt;

{% endfor %}
</code></pre>

<p>gives me an output of everything in the whole structure</p>

<p>when writing:</p>

<pre><code>{% for entry in craft.entries.section('offices').level(1) %}

&lt;h2&gt;{{ entry.title }}&lt;/h2&gt;

{% endfor %}
</code></pre>

<p>I get the title from the entry in the first level.</p>

<p>But how do i target a specific entry in the structure?
Let's say only Albuquerque, Chicago &amp; Chihuahua?</p>

<p>I looked around but can't seem to find anything in the docs about that. Who can point me in the right direction?</p>

<structure><entry>
Targeting entries in a structure
# Targeting entries in a structure

(Asked by: username_0 on 2014-09-30)

In a structure like the following:
Offices             US          Albuquerque
[offices]                       Boston
                                Chicago
                                Denver

                    Mexico      Acapulco
                                Buenavista
                                Chihuahua

                    Canada      Ajax
                                Brampton

writing this code on the offices overview page
{% for entry in craft.entries.section('offices') %}

{{ entry.title }}

{% endfor %}

gives me an output of everything in the whole structure
when writing:
{% for entry in craft.entries.section('offices').level(1) %}

{{ entry.title }}

{% endfor %}

I get the title from the entry in the first level.
But how do i target a specific entry in the structure?
Let's say only Albuquerque, Chicago & Chihuahua?
I looked around but can't seem to find anything in the docs about that. Who can point me in the right direction?

**Tags:** structure, entry


---

## 2 answers

### Answer by username_1 on 2014-09-30. Score: 2 | Accepted answer

Based on your response to the answer from @Andre, you could make a "Featured" lightswitch field and use that in your query.
So, you would add a Lightswitch Field called "Featured" (handle: featured) or something of the sort. Then, from the entry itself you Toggle this on for the one you want to show up on the homepage.
The code would change to:
{% set featuredEntry = craft.entries.section('offices').featured(1).first %}
{{ featuredEntry.title }}

This has the tertiary benefit of the CMS controlling which office hours show up on the homepage should they need to be changed by the client. Just be wary if multiple lightswitches are turned "on". I believe it would take the first one in the sort order in that case.
Update
Based on the comment below, you could solve this by creating a Drop Down field with days of the week as the Key => Value pairs, and then query your entries based on the day of the week it is:
Dropdown field with a handle of featuredDay with options:

 -----------------
| label  | value  |
 -----------------
| Sunday | sunday |
 -----------------
| Monday | monday |

etc.
Then in your template:
{% set featuredEntry = craft.entries.section('offices').featuredDay(now|date('l')|lower).first %}
{{ featuredEntry.title }}

> **Comments:**
> **username_0**: thx for your input, great idea, but the openings hours will be visible for certain days in the week. Monday > Albuquerque, Tuesday > Boston, etc..  
> **username_1**: Sure. So, there's a number of ways you could handle this, but one way using the above method would be use a featured Drop down field instead. I've updated the answer with this use case.  
> **username_0**: thx.. it did it like this `{% for entry in craft.entries.section('offices').level(2) %} {% if entry.dayOfEvent == "now" | date("l") %}  {# output #} {% endif %} {% endfor %}`  

---

### Answer by username_2 on 2014-09-30. Score: 2

To get a specific entry you need to know the id or slug of the entry. If the slug for Chicago is "chicago" (you find the slug in the side panel of the entry edit screen), you can get it like this:
{% set chicagoEntry = craft.entries.slug('chicago') %}

But hardcoding slugs and id's into templates is rarely a good idea. If you explain a bit more what you're trying to achieve, maybe we can provide a more helpful answer.
If you're trying to turn the structure into a menu of sorts, have a look at the documentation for the {% nav %} function, it was made specifically for this.

> **Comments:**
> **username_0**: Thx.. Indeed i'm trying to avoid hardcoding as much as possible. I'm trying to understand how structures work and how i can target certain pages within my structure. I need to give a listing of all offices and  also list the openingshours of a certain office on the home page.  

---

