Hey Tom!

I understand what you're trying to do now! I'm not sure if there's a
way to do that, but I'll run some tests and let you know the results.

Meanwhile, an alternate solution would be to consider using partials
and/or components on your layout.php file. That way, you'll be able to
update parts of the layout which are "outside" the view area (on the
decoration part). That might also be a more elegant design choice,
thinking on the MVC pattern and on the code/design separation talks :)

Take a look at the chapter "Inside the View Layer >> Code Fragments"
on the symfony book, you might get some ideas from there!




On Apr 9, 5:19 pm, "Tom Haskins-Vaughan" <[email protected]>
wrote:
> Thanks Thiago.
>
> Essentially my problem is that I need access to the property object in 
> layout.php.
>
> I am using the doctine route class:
>
> property:
>    url:     /:id/:action
>    class:   sfDoctrineRoute
>    options: { model: Property, type: object }
>    param:   { module: property }
>    requirements:
>      id: \d+
>      sf_method: [get]
>
> And I have no trouble accessing the property object from the routing and I 
> can use this in actions and templates. However, I cannot pass this object to 
> the layout.
>
> In the layout I need to know the property_id, property_name, etc but I have 
> no idea how to access them. I think you used to be able to in sf1.0.
>
> I thought about using a component, but I couldn't access the property object 
> from the route in a component either.
>
> I'm sure there must be something simple that I'm over looking, but I can't 
> put my finger on it.
>
> Anyone?
>
> Cheers,
>
> Tom
>
> ----- Start Original Message -----
> Sent: Thu, 9 Apr 2009 08:00:55 -0700 (PDT)
> From: Campezzi <[email protected]>
> To: symfony users <[email protected]>
> Subject: [symfony-users] Re: Accessing doctrine route object in layout.php
>
>
>
>
>
> > Hi Tom,
>
> > I believe you can get access to the routing from the layout by using
> > the $sf_context variable. $sf_context->getRouting() should return a
> > sfRouting object (http://www.symfony-project.org/api/1_2/sfRouting).
> > You can then use the getRoutes() method of this object in order to get
> > access to a collection of sfRoute objects (http://www.symfony-
> > project.org/api/1_2/sfRoute). I haven't tested this, but in theory it
> > should give you access to what you want :)
>
> > However, I'm not too sure if this is a good practice. Depending on
> > what you want to achieve, it would be best to simply set different
> > routing rules. For example, for the photos section you would have a
> > routing rule like this:
>
> > photos:
> >   url: /:id/photos.htm
> >   param: { module: property, action: photos }
>
> > then on the actions for this module you can use the ID passed by the
> > user to do whatever:
>
> >   public function executePhotos(sfWebRequest $request)
> >   {
> >    $this->image = $request->getParameter('id') .'.png';
> >   }
>
> > and then obviously you could use this variable on the view:
>
> > <img src=". $image ." />
>
> > Hope to have helped!
>
> > Best Regards,
>
> > Thiago Campezzi
>
> > On Apr 9, 12:09 am, Tom Haskins-Vaughan <[email protected]>
> > wrote:
> > > Hi,
>
> > > I have a website where the people are given a url from some off-line
> > > source. e.g.
>
> > > example.com/22
>
> > > I'm using the doctrine routing object for my routes.
>
> > > 22 is the id of a property and needs to be included in the routing in
> > > order to see other parts of the property:
>
> > > example.com/22/photos.htm
> > > example.com/22/town-info.htm
> > > example.com/22/view-property.htm
>
> > > So in layout.php I'd like to have access to the route object, but I
> > > don't see a way of accessing the route object in the layout. Is there a 
> > > way?
>
> > > Thanks in advance.
>
> > > Tom
>
> ----- End Original Message -----
--~--~---------~--~----~------------~-------~--~----~
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