You can a public method in your Pages class called getMenuSlug

public function getMenuSlug()
{
  // or something like that
  return $this->getMenu()->getSlug();
}


link_to("@my_route?menu_slug=".$page->getMenuSlug()."&slug=".$page->getSlug())

Alternativelly, you could do on save method an overide in order to
save menu slug inside the page slug like

public function save(propelPDO $con)
{
// you will have to see what is the real name
// do not use $this->getSlug() as it will add a lot of
// $this->getMenu()->getSlug() on later edits of the object

  $title = slugify($this->getTitle());
  $this->setSlug($this->getMenu()->getSlug().'/'.$title);
  parent::save($con)
}

then your route would look:

my_page:
  url: /:slug
as the category slug is allready embeded into the page's slug

this second alternative is cool to save queries on database as you
will not need to select for each page object the asociated page menu.

Alecs

On Thu, Dec 17, 2009 at 2:42 PM, Rob Wilkerson <[email protected]> wrote:
> I'm starting a new project - my first with Symfony - and I'm trying to
> figure out how to construct a route that incorporates information
> about an associated object. The documentation that I can find is
> light, to say the least, and I'm struggling. I'm using v1.4.1 w/
> Propel (backwards compatibility with some existing stuff) and have:
>
> A navigation menu (`Menu`) that `has_many` pages (`Page`) `through` a
> navigation item (`NavItem`)
>
> I realize that syntax doesn't really apply to Propel, but you get the
> idea, I hope. I'd like to access a page through a URI that includes
> it's menu and page slugs. For example, to display the page named
> **Find an Audience** on the **Audiences** menu, I'd like to use `/
> audiences/find`. The route, then, for `...@page_show` would look
> something like `/:menu_slug/:slug`.
>
> The relevant snippet of the schema lays out like this:
>
>    Menu:
>      id: ...
>      name: ...
>      slug: ...
>
>    Page:
>      id: ...
>      name: ...
>      slug: ...
>
>    NavItem:
>      menu_id: ...
>      page_id: ...
>      display_order: ...
>
> Note that the preferred URI includes components of both a page and its
> menu.
>
> I may also be off on some of the routing specifics, but what I'm not
> sure how to do is configure my route in its entirety (including how to
> reference it in my layouts/templates using the `link_to()` and `url_for
> ()` helpers).
>
> Solutions or anything just to get me started in the right direction
> would be much appreciated.
>
> Thanks.
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "symfony users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/symfony-users?hl=en.
>
>
>



-- 
Have a nice day!
Alecs

As programmers create bigger & better idiot proof programs, so the
universe creates bigger & better idiots!
I am on web:  http://www.alecslupu.ro/
I am on twitter: http://twitter.com/alecslupu
I am on linkedIn: http://www.linkedin.com/in/alecslupu
Tel: (+4)0748.543.798

--

You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.


Reply via email to