On Jan 29, 2008 9:42 PM, Sean Cribbs <[EMAIL PROTECTED]> wrote:

> It seems it might be appropriate for your PersonPage to be virtual and
> the PeoplePage to override find_by_url as well.


Hi Sean,

Thanks for the reply. Both of the PersonPage and the BioPage are virtual,
and in PeoplePage I have:

  def find_by_url(url, live = true, clean = false)
    url = clean_url(url) if clean
    if url =~ %r{#{self.url}/?\d+/?$}
      children.find_by_class_name 'PersonPage'
    else
      super
    end
  end

  def child_url(child)
    clean_url "#{url}/#{child.id}"
  end

I can get the pages by Page.find_by_url for the

/people/
/people/18

but it doesn't work for

/people/18/bio

Its a wildest guess, but does it have anything to do with the fact that I'm
redefining find_by_url in a virtual page (per se)? I'd say no, but just to
be on the safe side...


nn wrote:
> I have the following setup:
>
> Home Page
>   |
>   -- People (PeoplePage)
>        |
>        -- Person (PersonPage)
>             |
>             -- Bio (BioPage)
>             -- Contact (ContactInfoPage)
>
> I made an extension with some Page Types (in parentheses) wich are used to
> display the list of people in the company and the data about a particular
> person, respectively (the latter being a virtual page).
>
> Since a person object carries plenty of data I need to split the data into
> several pages, like:
>
> /people/18                       # 18 is an ID of a existing object
(Person)
> /people/18/bio
> /people/18/contact
> ...
>
> It seems I have a problem with find_by_url in PersonPage:
>
>   def virtual?
>     true
>   end
>
>   def find_by_url(url, live = true, clean = true)
>     url = clean_url(url) if clean
>     if url =~ %r{#{parent.url}/\d+/bio/?$}
>       children.find_by_class_name 'BioPage'
>     else
>       super
>     end
>   end
>
> This looks fine to my untrained eye, but:
>
> $ script/console
> Loading development environment.
>
>>> p = Page.find_by_url('/people/18/bio/')
>>>
> => #<FileNotFoundPage:0xb709db54 @attributes={"virtual"=>"1",
> "class_name"=>"FileNotFoundPage", "slug"=>"file-not-found",
> "updated_at"=>"2008-01-24 00:47:14", "title"=>"File Not Found",
> "created_by"=>"1", "breadcrumb"=>"File Not Found", "lock_version"=>"2",
> "updated_by"=>"1", "id"=>"3", "published_at"=>"2008-01-20 23:51:27",
> "status_id"=>"100", "layout_id"=>nil, "parent_id"=>"2",
> "created_at"=>"2008-01-20 22:51:27"}>
>
> Then, this works in the same console:
>
>   p = Page.find_by_url('/people/18/')
>   p.children.find_by_class_name 'BioPage'
>
> Regexp looks fine too, as far as I can tell. I know this is a cockpit
> problem, but I need someone to point a finger at it, since I must be
(code)
> blind or something. BioPage is declared virtual, too (if it matters). Can
> anyone suggest what could be wrong?

> > _______________________________________________
> > Radiant mailing list
> > Post:   [email protected]
> > Search: http://radiantcms.org/mailing-list/search/
> > Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
> >
> >
>
> _______________________________________________
> Radiant mailing list
> Post:   [email protected]
> Search: http://radiantcms.org/mailing-list/search/
> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
>
_______________________________________________
Radiant mailing list
Post:   [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to