Wie ich bereits sagte, das ist reine Gewohnheitssache und ich verwende den Tag vorwiegend aus Gewohnheit nicht.
Aber wo wir gerade beim Thema "Übersichtlichkeit" sind, schaut euch mal den Vergleich an:
Original:
PHP-Code:
<?php $lang = $GLOBALS['TL_LANG']['tl_foo_bar']; ?>
<h1 id="tl_welcome"><?php echo $lang['headline']; ?></h1>
<div id="tl_soverview">
<div id="tl_license">
<h2><?php echo $lang['license']; ?></h2>
<p><?php
printf($lang['licensed'], 'Martin Mustermann', '01.12.2012');
?></p>
</div>
<div id="tl_statistic">
<h2><?php echo $lang['statistic']; ?></h2>
<table>
<tr>
<td colspan="3" class="total"><?php echo $this->totalCategoryCount; ?></td>
<td><?php echo $lang['totalCategoryCount']; ?></td>
</tr>
<tr>
<td class="published" title="<?php echo specialchars($lang['published']); ?>">
<?php echo $this->totalPublishedVehicleCount; ?>
</td>
<td>/</td>
<td class="total" title="<?php echo specialchars($lang['total']); ?>">
<?php echo $this->totalVehicleCount; ?>
</td>
<td><?php echo $lang['totalVehicleCount']; ?></td>
</tr>
<?php foreach ($this->categoryVehicleCount as $count): ?>
<tr<?php if (!$count['published']): ?> class="unpublished"<?php endif; ?>>
<td class="published" title="<?php echo specialchars($lang['published']); ?>">
<?php echo $count['publishedVehicles']; ?>
</td>
<td>/</td>
<td class="total" title="<?php echo specialchars($lang['total']); ?>">
<?php echo $count['vehicles']; ?>
</td>
<td><a href="contao/main.php?do=fahrzeugmanager_vehicle&table=tl_fahrzeugmanager_vehicle&id=<?php echo $count['id']; ?>"><?php printf($lang['categoryVehicleCount'], $count['category']); ?></a></td>
</tr>
<?php endforeach; ?>
</table>
</div>
<div id="tl_moverview">
<?php
foreach ($GLOBALS['foo_bar'] as $group => $modules)
{
?>
<h2><?php echo $lang[$group]; ?></h2>
<?php
foreach ($modules as $module)
{
if ($module[0] == '!') {
$module = substr($module, 1);
?>
<div class="tl_module_desc">
<h3><a style="color:#cfcfcf;" class="navigation <?php echo $module; ?>"><?php echo $lang[$module][0]; ?></a></h3>
<p><?php echo $lang[$module][1]; ?></p>
</div>
<?php
}
else {
?>
<div class="tl_module_desc">
<h3><a href="contao/main.php?do=foo_bar&table=tl_foo_bar_<?php echo $module; ?>" class="navigation <?php echo $module; ?>"><?php echo $lang[$module][0]; ?></a></h3>
<p><?php echo $lang[$module][1]; ?></p>
</div>
<?php
}
}
}
?>
</div>
</div>
Mit <?=
PHP-Code:
<?php $lang = $GLOBALS['TL_LANG']['tl_foo_bar']; ?>
<h1 id="tl_welcome"><?= $lang['headline']; ?></h1>
<div id="tl_soverview">
<div id="tl_license">
<h2><?= $lang['license']; ?></h2>
<p><?php
printf($lang['licensed'], 'Martin Mustermann', '01.12.2012');
?></p>
</div>
<div id="tl_statistic">
<h2><?= $lang['statistic']; ?></h2>
<table>
<tr>
<td colspan="3" class="total"><?= $this->totalCategoryCount; ?></td>
<td><?= $lang['totalCategoryCount']; ?></td>
</tr>
<tr>
<td class="published" title="<?= specialchars($lang['published']); ?>">
<?= $this->totalPublishedVehicleCount; ?>
</td>
<td>/</td>
<td class="total" title="<?= specialchars($lang['total']); ?>">
<?= $this->totalVehicleCount; ?>
</td>
<td><?= $lang['totalVehicleCount']; ?></td>
</tr>
<?php foreach ($this->categoryVehicleCount as $count): ?>
<tr<?php if (!$count['published']): ?> class="unpublished"<?php endif; ?>>
<td class="published" title="<?= specialchars($lang['published']); ?>">
<?= $count['publishedVehicles']; ?>
</td>
<td>/</td>
<td class="total" title="<?= specialchars($lang['total']); ?>">
<?= $count['vehicles']; ?>
</td>
<td><a href="contao/main.php?do=fahrzeugmanager_vehicle&table=tl_fahrzeugmanager_vehicle&id=<?= $count['id']; ?>"><?php printf($lang['categoryVehicleCount'], $count['category']); ?></a></td>
</tr>
<?php endforeach; ?>
</table>
</div>
<div id="tl_moverview">
<?php
foreach ($GLOBALS['foo_bar'] as $group => $modules)
{
?>
<h2><?= $lang[$group]; ?></h2>
<?php
foreach ($modules as $module)
{
if ($module[0] == '!') {
$module = substr($module, 1);
?>
<div class="tl_module_desc">
<h3><a style="color:#cfcfcf;" class="navigation <?= $module; ?>"><?= $lang[$module][0]; ?></a></h3>
<p><?= $lang[$module][1]; ?></p>
</div>
<?php
}
else {
?>
<div class="tl_module_desc">
<h3><a href="contao/main.php?do=foo_bar&table=tl_foo_bar_<?= $module; ?>" class="navigation <?= $module; ?>"><?= $lang[$module][0]; ?></a></h3>
<p><?= $lang[$module][1]; ?></p>
</div>
<?php
}
}
}
?>
</div>
</div>
Twig:
PHP-Code:
{% set lang = _lang.tl_foo_bar %}
<h1 id="tl_welcome">{{ lang.headline }}</h1>
<div id="tl_soverview">
<div id="tl_license">
<h2>{{ lang.license }}</h2>
<p>{{ lang.licensed|format('Martin Mustermann', '01.12.2012')|raw }}</p>
</div>
<div id="tl_statistic">
<h2>{{ lang.statistic }}</h2>
<table>
<tr>
<td colspan="3" class="total">{{ totalCategoryCount }}</td>
<td>{{ lang.totalCategoryCount }}</td>
</tr>
<tr>
<td class="published" title="{{ lang.published }}">
{{ totalPublishedVehicleCount }}
</td>
<td>/</td>
<td class="total" title="{{ lang.total }}">
{{ totalVehicleCount }}
</td>
<td>{{ lang.totalVehicleCount }}</td>
</tr>
{% for count in categoryVehicleCount %}
<tr{% if not count.published %} class="unpublished"{% endif %}>
<td class="published" title="{{ lang.published }}">
{{ count.publishedVehicles }}
</td>
<td>/</td>
<td class="total" title="{{ lang.total }}">
{{ count.vehicles }}
</td>
<td><a href="contao/main.php?do=fahrzeugmanager_vehicle&table=tl_fahrzeugmanager_vehicle&id={{ count.id }}">
{{ lang.categoryVehicleCount|format(count.category) }}
</a></td>
</tr>
{% endfor %}
</table>
</div>
<div id="tl_moverview">
{% for group, modules in settings %}
<h2>{{ lang[group] }}</h2>
{% for module in modules %}
{% if module|slice(0,1) == '!' %}
{% set module = module|slice(1) %}
<div class="tl_module_desc">
<h3><a style="color:#cfcfcf;" class="navigation {{ module }}">{{ lang[module][0] }}</a></h3>
<p>{{ lang[module][1] }}</p>
</div>
{% else %}
<div class="tl_module_desc">
<h3><a href="contao/main.php?do=foo_bar&table=tl_foo_bar_{{ module }}" class="navigation {{ module }}">{{ lang[module][0] }}</a></h3>
<p>{{ lang[module][1] }}</p>
</div>
{% endif %}
{% endfor %}
{% endfor %}
</div>
</div>
Gegenüber dem Twig Template finde ich sogar die PHP Variante mit <?= sehr unübersichtlich