items_from_path

Galen King's Avatar

Galen King

21 Dec, 2010 09:07 PM via web

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.

  1. item_from_path only returns a single item; not multiple matching items in an array
  2. doesn't seem to look in blog articles; only pages

There are two things that would make Harmony even better:

  1. items_from_path object filter that returns a collection of pages/articles
  2. item_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

  1. 2 Posted by John Nunemaker on 30 Dec, 2010 05:55 PM

    John Nunemaker's Avatar

    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...

Reply to this discussion

Internal reply

Formatting help or Preview

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Recent Discussions

17 May, 2012 10:45 PM
20 Mar, 2012 05:05 PM
26 Apr, 2012 01:40 AM
07 Mar, 2012 04:42 PM