This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » eZ Publish 5 Platform » Fetch Object from URL without...

Fetch Object from URL without ezpublish.yml (EZ 5.4)

Fetch Object from URL without ezpublish.yml (EZ 5.4)

Monday 02 March 2015 5:24:44 pm - 2 replies

I know I can extend ezpublish.yml and match a location_view full and match the content type "article" f.e. to a controller action. This will pass the $locationId as a parameter to the specified controller action. You can then fetch content/children based on that $locationId.

On the other hand, how can the same thing be purely done (fetching the $locationId without touching any .yml files), from a controller. I can grab the uri for a custom route in routing.yml and pass it to a controller action like this:

    path:     /about
    defaults: { _controller: CustomDemoBundle:Page:about }

But now in the Page controller, the aboutAction($locationId) of course will not have any value, as nothing is passing it. So two questions arise that I must ask:

1. Is there a way to bind that url of /about to pull the object location id and pass it to the about action (f.e. a parameter like bind: locationId) or any other way?

2. Is there a way to lookup the uri "/about" in the aboutAction from the db, and return the location id for it to further work with?

Working code examples, tutorials, or github resources are welcome.

Modified on Monday 02 March 2015 5:27:02 pm by Big Mike

Monday 02 March 2015 5:33:10 pm

hi. lookup method in UrlAlias Service could help with this. it could be something like

There you'll have the locationId corresponding to that url if present. 

Edit: And if you already know the locationId, you can pass it from the routing. it could be something like

being 200 the id of your "about" location. 

Modified on Monday 02 March 2015 5:36:02 pm by Carlos Revillo

Monday 02 March 2015 5:57:00 pm

Cheers Carlos! This should definitely be part of 5.4 documentation.


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from