items_from_path
Hey guys,
Thanks for adding request.uri, that's awesome.
I've now got another issue.
I thought I'd be able to offer a list of alternative pages on my error page likes this:
{{ request.uri | split: '/' | last | assign_to: 'errorpath' }}
{{ errorpath | item_from_path | assign_to: 'altpages' }}
{% if altpages.size > 0 %}
<h3>Perhaps you were looking for {% if altpages.size > 1 %}one of {% endif %}the following page{% if altpages.size > 1 %}s{% endif %}</h3>
<ul>
{% for page in altpages %}
<li>{{ page | link_to_item_with_widont }}</li>
{% endfor %}
</ul>
{% endif %}
But it seems there are a couple reasons why this won't work.
item_from_pathonly returns a single item; not multiple matching items in an array- doesn't seem to look in blog articles; only pages
There are two things that would make Harmony even better:
items_from_pathobject filter that returns a collection of pages/articlesitem_from_{fieldname}or, perhaps more practical with liquid,search: {fieldname}, {value}which would enable you to search on any field
I also think the site object should contain ALL pages AND articles; I think it just returns pages at present which makes it impossible to iterate through every "page" on a site for the likes of sitemaps etc.
Hope this makes sense. Keen to hear your thoughts.
Cheers,
Galen
2 Posted by John Nunemaker on 30 Dec, 2010 05:55 PM
Galen,
All of the things you are doing revolve around us having a better way to search through content. Search, the way we want to do it, is a beast of a feature and is most likely a ways off.
item_from_path should find any item in the system by path no matter the type -- blog, blog post, page, etc.
Are you working on a sitemap or a more friendly error page? Our friends at Collective Idea have blogged about how they created their sitemap here:
http://collectiveidea.com/blog/archives/2010/06/14/sitemapxml-in-ha...