* This article is part of the original Jobeet Tutorial, created by Fabien Potencier, for Symfony 1.4.
If you are looking for a job, you will probably want to be informed as soon as a new job is posted. Because it is not very convenient to check the website every other hour, we will add several job feeds here to keep our Jobeet users up-to-date.

Template Formats

Templates are a generic way to render content in any format. And while in most cases you’ll use templates to render HTML content, a template can just as easily generate JavaScript, CSS, XML or any other format.

For example, the same “resource” is often rendered in several different formats. To render an article index page in XML, simply include the format in the template name:

  • XML template name: AcmeArticleBundle:Article:index.xml.twig
  • XML template filename: index.xml.twig

In reality, this is nothing more than a naming convention and the template isn’t actually rendered differently based on its format.

In many cases, you may want to allow a single controller to render multiple different formats based on the “request format”. For that reason, a common pattern is to do the following:

The getRequestFormat on the Request object defaults to html, but can return any other format based on the format requested by the user. The request format is most often managed by the routing, where a route can be configured so that /contact sets the request format to html while /contact.xml sets the format to xml.

To create links that include the format parameter, include a _format key in the parameter hash:



Supporting different formats is as easy as creating different templates. To create an Atom feed for the latest jobs, create an index.atom.twig template:

In the Jobeet footer, update the link to the feed:

Add a <link> tag in the head section of the layout to allow automatic discover by the browser of our feed:

In the JobController change the indexAction to render the template according to the _format:

Replace the Atom template header with the following code:

From the JobController (index action) we have to send the lastUpdated and feedId to the template:

To get the date of the latest post, we have to create the getLatestPost() method in the JobRepository:

The feed entries can be generated with the following code:


One of the goals of Jobeet is to help people find more targeted jobs. So, we need to provide a feed for each category.

First, let’s update the links to category feeds in the templates:

Update the CategoryController showAction to render the corresponding template:

Eventually, create the show.atom.twig template:

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.