<p>I suggest to refactor again and use dropdown fields for the path to your partials instead of the channel entries with asset fields you currently have. This also keeps your twig files more secure (your asset folder is above the web root!).</p>

<p>Set up three dropdown fields ('pathSideBar', 'pathPrimary' and 'pathFullPage') to do
the grouping and one Matrix Block for each of them. </p>

<pre><code>{% if block.type == 'widgetSideBar' %}

    {% set widgetPath = '_includes/sidebar/' ~ block.pathSideBar ~ '.html' %}
    {% include widgetPath only %}

{% elseif block.type == 'widgetPrimary' %}

    {# ... #}

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

CC BY-SA 3.0
2015-02-07T17:04:02.150Z
I am actually keeping this Asset path above the web root, so technically if I tried to access the files publicly I wouldn't be able to. (I set the public path to /404/). Or is there something I am missing here that makes this unadvisable?
Jeremiah
CC BY-SA 3.0
2015-02-07T17:22:40.203Z
@Jeremiah I never tried putting an assets folder above web root, because I thought this would also restrict access for the CP. But good to know this actually works. I still wouldn't use it in this case for template files, as I struggle to see the benefits for the user to be able to select and upload them. Setting the paths up with dropdown values (as I suggested above) or completely doing this template task from within the templates makes way more sense to me.
carlcs
CC BY-SA 3.0
2015-02-06T13:58:08.727Z
2015-02-06T13:58:08.727Z
carlcs
<p>After a finally returning to an extensive recode of my first commercial Craft based site, I have successfully implemented several new (to me) features from the latest builds. One thing I am making extensive use of is entry types.</p>

<p>To make it easy to update my layouts, I have a section called "Widgets". Each widget entry simply points to a template file via an assets select. Presently I have three kinds of widgets: a side bar widget (Which is more compact as the name would suggest), a primary (much larger widget), and a full page widget. To keep things organized, I am sorting this based on three entry types.</p>

<p>So each page of my site (ex: site.com/blog) is part of a structure, which inside the structure is a Matrix field. This allows me to insert inline text, images, and the previously mentioned widgets via a related entry, though there is one major problem... I cannot seem to limit the Widget block in the Matrix field based on entry types.</p>

<p>My workaround I suppose would be to have 3 separate sections: one for each type of Widget, but that solution is far from elegant. SO, any ideas, guys? Here's to hoping that this would be a fairly minor update that could make it out in an upcoming release... Thanks in advance guys!</p>

CC BY-SA 3.0
2015-02-06T13:29:03.377Z
If I got you right, you're looking for a solution to have entries in an EntriesField pre-filtered by Entry Type?
carlcs
CC BY-SA 3.0
2015-02-06T13:33:55.593Z
A feature request for more options when setting up EntriesFields was already made some time ago (→ [g+ feedback post](https://plus.google.com/112173526450245116573/posts/2NHbdQTsKiL)).
carlcs
<matrix><entry-type><sorting>
Limit by entry type in Matrix field
# Limit by entry type in Matrix field

(Asked by: username_0 on 2015-02-06)

After a finally returning to an extensive recode of my first commercial Craft based site, I have successfully implemented several new (to me) features from the latest builds. One thing I am making extensive use of is entry types.

To make it easy to update my layouts, I have a section called "Widgets". Each widget entry simply points to a template file via an assets select. Presently I have three kinds of widgets: a side bar widget (Which is more compact as the name would suggest), a primary (much larger widget), and a full page widget. To keep things organized, I am sorting this based on three entry types.

So each page of my site (ex: site.com/blog) is part of a structure, which inside the structure is a Matrix field. This allows me to insert inline text, images, and the previously mentioned widgets via a related entry, though there is one major problem... I cannot seem to limit the Widget block in the Matrix field based on entry types.

My workaround I suppose would be to have 3 separate sections: one for each type of Widget, but that solution is far from elegant. SO, any ideas, guys? Here's to hoping that this would be a fairly minor update that could make it out in an upcoming release... Thanks in advance guys!

**Tags:** matrix, entry-type, sorting

> **Comments:**
> **username_1**: If I got you right, you're looking for a solution to have entries in an EntriesField pre-filtered by Entry Type?  
> **username_1**: A feature request for more options when setting up EntriesFields was already made some time ago (→ [g+ feedback post](https://plus.google.com/112173526450245116573/posts/2NHbdQTsKiL)).  

---

## 1 answers

### Answer by username_1 on 2015-02-06. Score: 1

I suggest to refactor again and use dropdown fields for the path to your partials instead of the channel entries with asset fields you currently have. This also keeps your twig files more secure (your asset folder is above the web root!).
Set up three dropdown fields ('pathSideBar', 'pathPrimary' and 'pathFullPage') to do
the grouping and one Matrix Block for each of them. 
{% if block.type == 'widgetSideBar' %}

    {% set widgetPath = '_includes/sidebar/' ~ block.pathSideBar ~ '.html' %}
    {% include widgetPath only %}

{% elseif block.type == 'widgetPrimary' %}

    {# ... #}

{% endif %}

> **Comments:**
> **username_0**: I am actually keeping this Asset path above the web root, so technically if I tried to access the files publicly I wouldn't be able to. (I set the public path to /404/). Or is there something I am missing here that makes this unadvisable?  
> **username_1**: @username_0 I never tried putting an assets folder above web root, because I thought this would also restrict access for the CP. But good to know this actually works. I still wouldn't use it in this case for template files, as I struggle to see the benefits for the user to be able to select and upload them. Setting the paths up with dropdown values (as I suggested above) or completely doing this template task from within the templates makes way more sense to me.  

---

