<p>I've found a solution.</p>

<pre><code>{% paginate craft.entries({
    search: queryWords|join(' OR '),
    subLeft: true,
    subRight: true,
    order: 'score'
}).section('and, not sectionName').id('not ' ~ entry.id).limit(10) as pageInfo, items %}
</code></pre>

<p>When i add this .section('and, not sectionName') a section without urls is not included in the search.</p>

CC BY-SA 3.0
2017-02-28T09:30:21.917Z
2017-02-28T09:30:21.917Z
Remi
<p>Got this solution from Andrew Welch/nystudio107 over on Discord:</p>

<p>Query for ':notempty:' in the URI, for example:</p>

<pre><code>craft.entries().uri(':notempty:').all()
</code></pre>

<p>Docs: <a href="https://docs.craftcms.com/v3/entries-fields.html#templating" rel="nofollow noreferrer">':empty:' and ':notempty:'</a></p>

CC BY-SA 4.0
2019-08-26T18:27:30.687Z
2019-08-26T18:27:30.687Z
missmatsuko
<p>If at all possible, I'd probably try and use <a href="https://craftcms.stackexchange.com/questions/19153/search-only-in-entries-with-own-urls-checked/19160#comment25944_19160">Lindsey's answer</a> in his follow-up comment.</p>

<p>The alternative is, you'd have to create a <a href="https://pluginfactory.io" rel="nofollow noreferrer">plugin</a> that grabbed every section and looped through them, checks their settings and see if they have the "Entries in the section have their own URLs" set. If so, collect an array of them and pass them back to the template via a <a href="https://craftcms.com/docs/plugins/variables" rel="nofollow noreferrer">Template Variable</a>.</p>

<p>You don't want to do that on every request, though, since it's overhead and you'll probably end up caching the data, which at that point, you might as well have went with Lindsey's solution.</p>

CC BY-SA 3.0
2017-02-27T18:49:52.350Z
2017-02-27T18:49:52.350Z
Brad Bell
<p>At the risk of oversimplifying your problem... just hard-code the sections with the "own URL" option checked.</p>

<pre><code>{% paginate craft.entries({
    section: ['sectionA', 'sectionB'],
    ...
</code></pre>

<p>The "own URL" checkbox happens at the section level, and section configurations rarely change (once the site is fully developed).</p>

<p><a href="https://i.sstatic.net/vo2x1.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/vo2x1.png" alt="Entries in this section have their own URLs"></a></p>

<p>In theory, you already know which sections allow URLs, and can simply hard-code the <a href="https://craftcms.com/docs/templating/craft.entries#section" rel="nofollow noreferrer">section handles</a> into your code.</p>

<blockquote>
  <p>Accepted values include a section handle, <strong>an array of section handles</strong>, or a SectionModel object.</p>
</blockquote>

CC BY-SA 3.0
2017-02-27T07:49:45.400Z
We have 26 sections. The code would become very long when we do it this way.
Remi
CC BY-SA 3.0
2017-02-27T08:03:32.690Z
In that case, I'd recommend creating a [Twig global variable](http://craftcms.stackexchange.com/questions/16491/does-twigs-addglobal-exist-in-craft/16492#16492), to represent an array of all 26 sections. Then you could easily feed it into your queries as `section: sectionsArray`.
Lindsey D
CC BY-SA 3.0
2017-02-24T17:02:12.630Z
2017-02-24T17:02:12.630Z
Lindsey D
<p>Is it possible to search only in entries that have the own URLs option checked.</p>

<p>Now i've this code:</p>

<pre><code>{% set query = craft.request.getParam('q') %}
{% set queryWords = query|split(' ') %}

{% paginate craft.entries({
    search: queryWords|join(' OR '),
    subLeft: true,
    subRight: true,
    order: 'score'
}).id('not ' ~ entry.id).limit(10) as pageInfo, items %}
</code></pre>

CC BY-SA 3.0
2017-02-24T11:25:00.503Z
What do you mean with "own URLs"?
Justin Dekkers
CC BY-SA 3.0
2017-02-27T09:02:19.177Z
Own urls is a option when you create a section
Remi
<templating><entries>
Search only in entries with own urls checked
# Search only in entries with own urls checked

(Asked by: username_0 on 2017-02-24)

Is it possible to search only in entries that have the own URLs option checked.
Now i've this code:
{% set query = craft.request.getParam('q') %}
{% set queryWords = query|split(' ') %}

{% paginate craft.entries({
    search: queryWords|join(' OR '),
    subLeft: true,
    subRight: true,
    order: 'score'
}).id('not ' ~ entry.id).limit(10) as pageInfo, items %}

**Tags:** templating, entries
> **Comments:**
> **username_1**: What do you mean with "own URLs"?  
> **username_0**: Own urls is a option when you create a section  

---

## 4 answers

### Answer by username_0 on 2017-02-28. Score: 0 | Accepted answer

I've found a solution.
{% paginate craft.entries({
    search: queryWords|join(' OR '),
    subLeft: true,
    subRight: true,
    order: 'score'
}).section('and, not sectionName').id('not ' ~ entry.id).limit(10) as pageInfo, items %}

When i add this .section('and, not sectionName') a section without urls is not included in the search.


---

### Answer by username_2 on 2019-08-26. Score: 4

Got this solution from Andrew Welch/nystudio107 over on Discord:
Query for ':notempty:' in the URI, for example:
craft.entries().uri(':notempty:').all()

Docs: ':empty:' and ':notempty:'


---

### Answer by username_3 on 2017-02-27. Score: 0

If at all possible, I'd probably try and use [Lindsey's answer](https://craftcms.stackexchange.com/questions/19153/search-only-in-entries-with-own-urls-checked/19160#comment25944_19160) in his follow-up comment.

The alternative is, you'd have to create a [plugin](https://pluginfactory.io) that grabbed every section and looped through them, checks their settings and see if they have the "Entries in the section have their own URLs" set. If so, collect an array of them and pass them back to the template via a [Template Variable](https://craftcms.com/docs/plugins/variables).

You don't want to do that on every request, though, since it's overhead and you'll probably end up caching the data, which at that point, you might as well have went with Lindsey's solution.


---

### Answer by username_4 on 2017-02-24. Score: 0

At the risk of oversimplifying your problem... just hard-code the sections with the "own URL" option checked.
{% paginate craft.entries({
    section: ['sectionA', 'sectionB'],
    ...

The "own URL" checkbox happens at the section level, and section configurations rarely change (once the site is fully developed).

In theory, you already know which sections allow URLs, and can simply hard-code the section handles into your code.

Accepted values include a section handle, an array of section handles, or a SectionModel object.

> **Comments:**
> **username_0**: We have 26 sections. The code would become very long when we do it this way.  
> **username_4**: In that case, I'd recommend creating a [Twig global variable](http://craftcms.stackexchange.com/questions/16491/does-twigs-addglobal-exist-in-craft/16492#16492), to represent an array of all 26 sections. Then you could easily feed it into your queries as `section: sectionsArray`.  

---

