tags:

views:

32

answers:

2

Hey folks. I'm looking for the best way to do something simple in symfony.

Basically, I have a module in which all the pages will contain the same header and footer. That module also shares the same general layout as the other modules.

I'm just wondering, should I create one file and have my content pages called up as partials or should all files have their own content and somehow call the two other templates.

I made a quick example of my setup: http://grab.by/3Riy

Hopefully, it'll help understand what I'm trying to do.

Thanks!

A: 

You should do this that way:

  1. Create layout.php file that will contain:
    1. Website header
    2. include_slot (for Module header)
    3. echo $sf_content (module template/content)
    4. include_slot (for Module footer)
    5. Website footer
  2. In module's templates you define slots for module header and footer.
Crozin
A: 

I decided to go with partials instead.

indexSuccess.php

<?php include_partial("header"); ?>
Content
<?php include_partial("footer"); ?>

This way, it still work with my original layout.php as well.

Pierre
If you're able to pass all needed variables to the partials from all the actions in the module in question (or don't need to pass anything), I'd also go with partials. I think Crozin's solution is fine too but would require you to always define the slot or use a default, which may or may not be appropriate across all your modules, depending on the overall structure of the site.
Tom