Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

add headline block to block templates #8165

Closed
fritzmg opened this issue Dec 15, 2015 · 1 comment
Closed

add headline block to block templates #8165

fritzmg opened this issue Dec 15, 2015 · 1 comment

Comments

@fritzmg
Copy link
Contributor

fritzmg commented Dec 15, 2015

It frequently happens that users want to change the headline part of specific module or content element templates. Currently, if you want to change that part of the template, you have to ditch the template extension and simply copy over the complete block_… template to your target template (while preserving the original content block in the target template).

Wouldn't it be better if, for instance, the block_unsearchable template was set up like this:

<!-- indexer::stop -->
<div class="<?= $this->class ?> block"<?= $this->cssID ?><?php if ($this->style): ?> style="<?= $this->style ?>"<?php endif; ?>>

  <?php $this->block('headline'); ?>
    <?php if ($this->headline): ?>
      <<?= $this->hl ?>><?= $this->headline ?></<?= $this->hl ?>>
    <?php endif; ?>
  <?php $this->endblock(); ?>

  <?php $this->block('content'); ?>
  <?php $this->endblock(); ?>

</div>
<!-- indexer::continue -->

This way you could do the follwing in, let's say, a mod_newsarchive template:

<?php $this->extend('block_unsearchable'); ?>

<?php $this->block('headline'); ?>
  <h1>My custom headline</h1>
<?php $this->endblock(); ?>

<?php $this->block('content'); ?>

  <?php if (empty($this->articles)): ?>
    <p class="empty"><?= $this->empty ?></p>
  <?php else: ?>
    <?= implode('', $this->articles) ?>
    <?= $this->pagination ?>
  <?php endif; ?>

<?php $this->endblock(); ?>

And thus preserving at least the wrapper of the original block_… template - instead of having to copy over the rest of the block_unsearchable template like this:

<!-- indexer::stop -->
<div class="<?= $this->class ?> block"<?= $this->cssID ?><?php if ($this->style): ?> style="<?= $this->style ?>"<?php endif; ?>>

  <h1>My custom headline</h1>

  <?php if (empty($this->articles)): ?>
    <p class="empty"><?= $this->empty ?></p>
  <?php else: ?>
    <?= implode('', $this->articles) ?>
    <?= $this->pagination ?>
  <?php endif; ?>

</div>
<!-- indexer::continue -->
@fritzmg
Copy link
Contributor Author

fritzmg commented Mar 24, 2016

Implemented in contao/core-bundle#457

@fritzmg fritzmg closed this as completed Mar 24, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant