Jeremy
Jeremy

Reputation: 377

How to link a Symfony CMF StaticContent to an existing route

I am currently using the Symfony CMF stack without the SimpleCMSBundle. In Sonata Admin I am able to create StaticContents including SEO Metadata. This is all working and I can add content pages with SEO metadata this way.

However, how can I link an existing route of a symfony application with a StaticContent (Page)?

For example, I have a MessageController which defines its own routes. Like /messages/inbox/{page}. How can I define SEOMeta (or StaticContent) for these pages?

Upvotes: 0

Views: 80

Answers (1)

Lukas Kahwe Smith
Lukas Kahwe Smith

Reputation: 646

If you use the dynamic routing, then the process is that your route has a reference to the content and using an route enhancer that content is then set as a request attribute "contentDocument" which is then automatically injected by the standard symfony controller resolver: https://github.com/symfony-cmf/ContentBundle/blob/master/Controller/ContentController.php#L75

If you do not use the dynamic router I would recommend to add a default on your route containing the content path. You can then use a transform (see SensioFrameworkExtraBundle) or manually read the document for that path inside your controller action.

Upvotes: 1

Related Questions