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!

  • If I got you right, you're looking for a solution to have entries in an EntriesField pre-filtered by Entry Type?
    – carlcs
    Feb 6, 2015 at 13:29
  • A feature request for more options when setting up EntriesFields was already made some time ago (→ g+ feedback post).
    – carlcs
    Feb 6, 2015 at 13:33

1 Answer 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 %}
  • 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
    Feb 7, 2015 at 17:04
  • @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
    Feb 7, 2015 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.