Hi there,
1. For the specific case you're describing, you can do this by customizing the mod_newslist template (copy it into /templates/your-theme-folder/).
Change the headline portion of the the template accordingly:
Code:
// If a headline is set in the module
<?php if ($this->headline): ?>
// If there are tags currently active...
<?php if ($this->tags_activetags[0]): ?>
// Then display this headline, using the first active tag..
<<?php echo $this->hl; ?>>Read Articles About <?php echo $this->tags_activetags[0]; ?></<?php echo $this->hl; ?>>
// If there are no active tags...
<?php else: ?>
// Then just display the headline set in the module as you normally would...
<<?php echo $this->hl; ?>><?php echo $this->headline; ?></<?php echo $this->hl; ?>>
<?php endif; ?>
<?php endif; ?>
Active tags are included as a template variable, as you can see above. If your implementation allows multiple tags to be selected, you can modify the above to loop through $this->tags_activetags and display each one (or use implode() or something).
2. Even if you couldn't do the above, you should never really need to modify the core files -- Contao is designed specifically with this in mind. By doing so, you are risking breaking it whenever you do an update (since you will likely overwrite your changes).
One of the many ways you can extend it is by using hooks (http://www.contao.org/hooks.html). In your case, you can use the "replaceInsertTag" hook to create your own custom insert tags. The system will pass any insert tags it doesn't recognize to a custom function that you specify.
For example:
Code:
// If this was the tag you used in your template or module...
{{current-tag}}
Code:
<?php
// This is in a new file: /system/modules/MyInsertTags/MyInsertTags.php
class MyInsertTags
{
public function ReplaceMyInsertTags($strTag)
{
// $strTag will be be passed in as the string "current-tag"
if ($strTag === 'current-tag')
{
// You can then do what you want with it... Maybe incorporate the other guy's code, for example...
}
return $strTag;
}
}
?>
Code:
<?php
// And then one more new file: /system/modules/MyInsertTags/config/config.php
// This tells Contao to run your custom code above when it finds an insert tag that it doesn't recognize.
$GLOBALS['TL_HOOKS']['replaceInsertTags'][] = array('MyInsertTags', 'ReplaceMyInsertTags');
?>
Bookmarks