Sorry if there is an answer out there for this, I've read quite a few posts but have got myself confused. I hope you can point me in the right direction.
I have this code in my EE template:
{exp:switchee variable="{segment_2}" parse="inward"}
{case value="''"}
{exp:channel:entries channel="portfolio" dynamic="no" status="open" disable="pagination|member_data" orderby="date" sort="desc"}
<div class="col-sm-4 col-md-4 col-lg-3">
{cf_portfolio_link}
{cf_portfolio_image}
{title}
</div>
{/exp:channel:entries}
{/case}
{case default="yes"}
{exp:channel:entries channel="portfolio" dynamic="no" category="{segment_2_category_id}" status="open" disable="pagination|member_data" orderby="date" sort="desc"}
<div class="col-sm-4 col-md-4 col-lg-3">
{cf_portfolio_link}
{cf_portfolio_image}
{title}
</div>
{/exp:channel:entries}
{/case}
{/exp:switchee}
I'd like to do the same in Craft - use one template and filter my entries by segment(2).
At present I have this code in my Craft template (the first case works, the second returns a 404):
{% switch craft.request.getSegment(2) %}
{% case "" %}
{% for item in craft.entries.section('portfolioImages').order('id desc') %}
<div class="col-sm-4 col-md-4 col-lg-3 work-item">
<a href="{{ item.websiteLink }}" target="_blank" title="View site">
{% for image in item.image %}
<img src="{{ image.url() }}" alt="{{ item.alternativeText }}" class="img-responsive center-block" />
{% endfor %}
</a>
<p>{{ item.title }}</p>
</div>
{% endfor %}
{% default %}
filtered entries to go here
{% endswitch %}
The URL for my portfolio page is mysite.com/work or mysite.com/work/ecommerce-websites if it has been filtered.
I do have a category group set up in the system called Portfolio with 3 top level categories only:
- ecommerce-websites
- promotion-websites
- product-catalogue-websites
Not sure where to go from here now.
Let me know if you need further information.
Cheers