To participate you must create an account on apostrophenow.org. If you have already done so, click Login.

Ticket #304 (closed defect: fixed)

Opened 22 months ago

Last modified 21 months ago

Pushing and popping target engine pages is gross, add an a_url_for helper

Reported by: boutell Owned by: boutell
Priority: major Milestone: 1.4
Component: apostrophePlugin Version: 1.0
Keywords: engines, routing Cc: agilbert
Symfony version: 1.4

Description

We should add an a_url_for helper, as an optional alternative to regular url_for. It would grab the engine_page option if it sees it and do an implicit push and pop. link_to doesn't mind if your URL has already been url_for'd, so you could write link_to('foo', a_url_for('my/action', array('engine_page' => '/admin/media')))

No pushes to forget to pop that way.

This helper should call an aTools::genUrl method which becomes an alternative way to do the same thing from an actions class.

In Symfony 2.0 we need to approach all this with dependency injection and killt he static methods.

Change History

Changed 22 months ago by boutell

  • version set to 1.0
  • milestone set to 1.1

Changed 22 months ago by boutell

  • status changed from new to accepted

Changed 22 months ago by agilbert

We just discussed a few alternatives to the a_url_for solution which I'm hoping you can follow up on, Tom. I think our first goal to be to embed this logic in a place where the developer working with Apostrophe doesn't need to think about it, i.e. the aRoute class.

1. For actions like selecting media, we now have a standard default media engine URL that is expected to be present in every Apostrophe site (/admin/media. The aRoute class should know this and take care of this function for us.

2. For situations where I want to link to a media or blog item on a specific (non-default) engine page, I should be able to pass a parameter to the regular url_for helper to accomplish this. Perhaps this would be done similarly to how sfDoctrineRoutes can do magical things with the sf_subject parameter.

Check these possibilities out and either update this ticket or create new ones. Cool.

Changed 21 months ago by boutell

I'll review this and make sure I was right the first time about my reasons for considering this Difficult. There's a difference between what sfObjectRoute does (replacing the object with an id parameter in the route) and what engine routes do (dynamically turning the engine page into the prefix of the URL and treating the rest of it like a normal route). I don't think the normal Symfony routing engine will be able to split:

/path/to/enginepage/actionname/argument

Into two different parameters /path/to/enginepage and /actionname/argument.

I'll review it a little more and then implement a_url_for, which is an improvement and can always become a wrapper for something else if we have an insight later.

Changed 21 months ago by boutell

  • status changed from accepted to closed
  • resolution set to fixed

I did better! You can now pass an engine-slug parameter to any engine route. This must be the slug, not the page object, but if you have the latter you can just do 'engine-page' => $page->slug.

If you pass this option, then the engine page you specify is used. If you don't, the usual best-guess algorithm applies.

pushTargetEnginePage and popTargetEnginePage are still supported, and are used internally in the implementation.

Fixed in [1408]

Note: See TracTickets for help on using tickets.