I have added a new field for article teaser Image like below in my custom module-> MyMod/dca/tl_article:
Code:
/* article teaser image */
$GLOBALS['TL_DCA']['tl_article']['fields']['atImage'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_article']['atImage'],
'exclude' => true,
'inputType' => 'fileTree',
'eval' => array('filesOnly'=>true, 'fieldType'=>'radio', 'tl_class'=>'clr'),
'sql' => "varchar(255) NOT NULL default ''"
);
// Augment the pallette
$GLOBALS['TL_DCA']['tl_article']['palettes']['default'] = str_replace('teaser;', 'teaser, atImage;', $GLOBALS['TL_DCA']['tl_article']['palettes']['default']);
In the template mod_artcle I wanted to out put this image. But doing <?php echo $this->atImage; ?> gives only the ID of an Image.
At the moment I am doing like:
Code:
<?php
$objFile = \FilesModel::findByPk($this->atImage);
echo $objFile->path;
?>
inside the template (mod_article), which I am not satisfied. I think there is a better way of setting up template variables with real image path. Can some one suggest please.
Bookmarks