Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I would like to include global editable components in a website I am currently making with the 1.4 Symfony framework. Are there any plugin/library/anything that could do that?

My attempts

  • The best solution would have been something like http://www.symfony-project.org/plugins/sfDoctrineEditableComponentPlugin. However:
    • This plugin is still in alpha.
    • I could not have it work (though it may be because I made an error during installation)
    • The slots are not global.
  • One idea would be to use a CMS. I tried with Apostrophe. However I did not succeed in inserting a_slots in templates of "normal" actions. It seems you can only inserts slots in pages created by Apostrophe. A solution could be to create a template for each pages/action. Then I could create an apostrophe page for each of those templates. But that would mean transferring all the Controller part in the templates, losing the assets of a MVC architecture.
  • Doing it myself. I could do that, but I would have the feeling of reinventing the wheel. My needs do not seem quite specific, so I hope someone have done it before.

The context

I am currently making a website for an association of theater, dance and music. We produce an average of 1.5 spectacles by month plus some other events. In the current version of the website, I have done a backend application where you can edit all the informations about a given event. However, some people find it hard/weird to need to go to another page. Sometimes they mistake two fields; WYSIWYGs editable components seem perfect to me. They need to be global (indeed the title of an event appear in multiple pages).

share|improve this question

1 Answer 1

See 'including other templates':-

Quoting from the author...

You'll often want to include the same template or code fragment on several different pages. For example, in an application with "news articles", the template code displaying an article might be used on the article detail page, on a page displaying the most popular articles, or in a list of the latest articles.

When you need to reuse a chunk of PHP code, you typically move the code to a new PHP class or function. The same is true for templates. By moving the reused template code into its own template, it can be included from any other template. First, create the template that you'll need to reuse.

Content to reuse

<!-- src/Acme/ArticleBundle/Resources/views/Article/articleDetails.html.php -->
<h2><?php echo $article->getTitle() ?></h2>
<h3 class="byline">by <?php echo $article->getAuthorName() ?></h3>

<p>
    <?php echo $article->getBody() ?>
</p>

Include example

<!-- src/Acme/ArticleBundle/Resources/Article/list.html.php -->
<?php $view->extend('AcmeArticleBundle::layout.html.php') ?>

<?php $view['slots']->start('body') ?>
    <h1>Recent Articles</h1>

    <?php foreach ($articles as $article): ?>
        <?php echo $view->render('AcmeArticleBundle:Article:articleDetails.html.php', array('article' => $article)) ?>
    <?php endforeach; ?>
<?php $view['slots']->stop() ?>
share|improve this answer
    
Thanks but it answers only partially to my question : What I really want is editable content. The only plugin I found doing it is in alpha version, and I could not have it work. Unless I find a stable plugin with editable component, the question of whether the editable component are global is meaningless. –  matthieuP Mar 1 '12 at 14:34
    
@matthieuP then I would question if Symfony is the right choice for your build - this is a fairly common feature of most frameworks and it sounds like it's too immature for your needs. –  toomanyairmiles Mar 1 '12 at 18:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.