List Info

Thread: Liquid error: undefined method 'url' for nil:NilClass




Liquid error: undefined method 'url' for nil:NilClass
country flaguser name
United States
2007-04-17 17:30:49
Howdy Folks,

I'm trying to do a sidebar section which iterates across
sections
which have single pages in them. Here's the snippet of
liquid code:

{% if site.page_sections %}
<h2>Sections</h2>
<ul>
{% for page in site.page_sections %}
	<li> {{ page | link_to_section }} </li>
	{% if page.pages.size > 0 %}
	<ul>
		{% for subpage in page.pages %}
		   <li> {{ subpage | link_to_page }} </li>
		{% endfor %}
	</ul>
	{% endif %}
{% endfor %}
</ul>
{% endif %}

This works fine for most situations but when I do a search,
the
'subpages' come up as

"Liquid error: undefined method 'url' for
nil:NilClass"

It would appear that there are subpages (hence it enters the
loop) and
it is fully populated BUT the link_to_page method doesn't
work.
Perhaps the code that attaches methods doesn't get executed
hence the
error?

Help?


--~--~---------~--~----~------------~-------~--~----~
Mephisto: http://mephistoblog.com |
Mephisto Help: http://mephisto.stikipad
.com

To post to this group, send email to MephistoBloggooglegroups.com
To unsubscribe from this group, send email to
MephistoBlog-unsubscribegooglegroups.com
For more options, visit this group at http
://groups-beta.google.com/group/MephistoBlog
-~----------~----~----~----~------~----~------~--~---


Re: Liquid error: undefined method 'url' for nil:NilClass
user name
2007-04-17 17:52:50
On 4/17/07, Jason N. <jason.nahgmail.com> wrote:
>
> Howdy Folks,
>
> I'm trying to do a sidebar section which iterates
across sections
> which have single pages in them. Here's the snippet of
liquid code:
>
> {% if site.page_sections %}
> <h2>Sections</h2>
> <ul>
> {% for page in site.page_sections %}
>         <li> {{ page | link_to_section }}
</li>
>         {% if page.pages.size > 0 %}
>         <ul>
>                 {% for subpage in page.pages %}
>                    <li> {{ subpage | link_to_page
}} </li>
>                 {% endfor %}
>         </ul>
>         {% endif %}
> {% endfor %}
> </ul>
> {% endif %}
>
> This works fine for most situations but when I do a
search, the
> 'subpages' come up as
>
> "Liquid error: undefined method 'url' for
nil:NilClass"
>
> It would appear that there are subpages (hence it
enters the loop) and
> it is fully populated BUT the link_to_page method
doesn't work.
> Perhaps the code that attaches methods doesn't get
executed hence the
> error?

link_to_page uses the current section if it's not defined. 
But
searches don't have a section.  Try this:

{{ subpage | link_to_page: page }}


-- 
Rick Olson
http://lighthouseapp.com

http://weblog.techno-
weenie.net
http://mephistoblog.com

--~--~---------~--~----~------------~-------~--~----~
Mephisto: http://mephistoblog.com |
Mephisto Help: http://mephisto.stikipad
.com

To post to this group, send email to MephistoBloggooglegroups.com
To unsubscribe from this group, send email to
MephistoBlog-unsubscribegooglegroups.com
For more options, visit this group at http
://groups-beta.google.com/group/MephistoBlog
-~----------~----~----~----~------~----~------~--~---


Re: Liquid error: undefined method 'url' for nil:NilClass
user name
2007-04-17 18:03:26
Works... ta...

On 4/18/07, Rick Olson <technoweeniegmail.com> wrote:
>
> On 4/17/07, Jason N. <jason.nahgmail.com> wrote:
> >
> > Howdy Folks,
> >
> > I'm trying to do a sidebar section which iterates
across sections
> > which have single pages in them. Here's the
snippet of liquid code:
> >
> > {% if site.page_sections %}
> > <h2>Sections</h2>
> > <ul>
> > {% for page in site.page_sections %}
> >         <li> {{ page | link_to_section }}
</li>
> >         {% if page.pages.size > 0 %}
> >         <ul>
> >                 {% for subpage in page.pages %}
> >                    <li> {{ subpage |
link_to_page }} </li>
> >                 {% endfor %}
> >         </ul>
> >         {% endif %}
> > {% endfor %}
> > </ul>
> > {% endif %}
> >
> > This works fine for most situations but when I do
a search, the
> > 'subpages' come up as
> >
> > "Liquid error: undefined method 'url' for
nil:NilClass"
> >
> > It would appear that there are subpages (hence it
enters the loop) and
> > it is fully populated BUT the link_to_page method
doesn't work.
> > Perhaps the code that attaches methods doesn't get
executed hence the
> > error?
>
> link_to_page uses the current section if it's not
defined.  But
> searches don't have a section.  Try this:
>
> {{ subpage | link_to_page: page }}
>
>
> --
> Rick Olson
> http://lighthouseapp.com

> http://weblog.techno-
weenie.net
> http://mephistoblog.com
>
> >
>


-- 
Cheers,
Jason

--~--~---------~--~----~------------~-------~--~----~
Mephisto: http://mephistoblog.com |
Mephisto Help: http://mephisto.stikipad
.com

To post to this group, send email to MephistoBloggooglegroups.com
To unsubscribe from this group, send email to
MephistoBlog-unsubscribegooglegroups.com
For more options, visit this group at http
://groups-beta.google.com/group/MephistoBlog
-~----------~----~----~----~------~----~------~--~---


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )