Hi i've been trying out Typolight for the last 3 weeks for a project. Was good so far. Tried most modules custom sections etc. Now i tried to make a custom module based on a tutorial from Leo. I was able to get his example to work.
So then i tried on my own. Everything came fine in the back end. But nothin appeared in the front end.
This is the folder structure
modules/home_link
modules/home_link/templates
modules/home_link/config
modules/home_link/html
modules/home_link/dca
This is my config.php
Code:
$GLOBALS['BE_MOD']['content']['home_link'] = array
(
'tables' => array('tl_hl'),
'icon' => 'system/modules/home_link/html/house_link.png'
);
array_insert($GLOBALS['FE_MOD']['miscellaneous'], (count($GLOBALS['FE_MOD']['miscellaneous'])+1), array
(
'home_link' => 'ModuleHomeLink')
);
This is my database.sql
Code:
--
-- Table `tl_hl`
--
CREATE TABLE `tl_hl` (
`id` int(10) unsigned NOT NULL auto_increment,
`tstamp` int(10) unsigned NOT NULL default '0',
`title` varchar(64) NOT NULL default '',
`content` text NOT NULL,
`image` varchar(150) NOT NULL default '',
`size` varchar(64),
`href` varchar(150),
PRIMARY KEY (`id`),
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
This is code in tl_hl.php in dca folder
Code:
$GLOBALS['TL_DCA']['tl_hl'] = array
(
// Config
'config' => array
(
'dataContainer' => 'Table',
'enableVersioning' => true
),
// List
'list' => array
(
'sorting' => array
(
'mode' => 1,
'fields' => array('title'),
'flag' => 1,
'panelLayout' => 'search,limit'
),
'label' => array
(
'fields' => array('title', 'content'),
'format' => '%s <span style="color:#b3b3b3; padding-left:3px;">[%s]</span>'
),
'global_operations' => array
(
'all' => array
(
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
'href' => 'act=select',
'class' => 'header_edit_all',
'attributes' => 'onclick="Backend.getScrollOffset();"'
)
),
'operations' => array
(
'edit' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_hl']['edit'],
'href' => 'act=edit',
'icon' => 'edit.gif'
),
'copy' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_hl']['copy'],
'href' => 'act=copy',
'icon' => 'copy.gif'
),
'delete' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_hl']['delete'],
'href' => 'act=delete',
'icon' => 'delete.gif',
'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"'
),
'show' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_hl']['show'],
'href' => 'act=show',
'icon' => 'show.gif'
)
)
),
// Palettes
'palettes' => array
(
'default' => 'title;image,size;content',
),
// Fields
'fields' => array
(
'title' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_hl']['title'],
'inputType' => 'text',
'search' => true,
'eval' => array('mandatory'=>true, 'maxlength'=>64)
),
'image' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_hl']['image'],
'inputType' => 'fileTree',
'eval' => array('files'=>true, 'fieldType'=>'radio')
),
'size' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_hl']['size'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('multiple'=>true, 'size'=>2, 'rgxp'=>'digit', 'nospace'=>true, 'tl_class'=>'w50')
),
'content' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_hl']['content'],
'inputType' => 'textarea'
)
)
);
This is the tl_module.php
Code:
$GLOBALS['TL_DCA']['tl_module']['palettes']['home_link'] = 'name,type,headline;align,space,cssID';
This is the ModuleHomeLink.php
Code:
<?php if (!defined('TL_ROOT')) die('You can not access this file directly!');
class ModuleHomeLink extends Module
{
/**
* Template file
* @var string
*/
protected $strTemplate = 'mod_home_link';
/**
* Get all records and add them to an array
*/
protected function compile()
{
$arrCds = array();
$objCds = $this->Database->execute("SELECT * FROM tl_hl ORDER BY title");
while ($objCds->next())
{
$arrCds[] = array
(
'title' => $objCds->title,
'content' => $objCds->content,
'image' => $objCds->image,
);
}
$this->Template->cds = $arrCds;
}
}
?>
I made a tpl in the templates folder named mod_home_link.tpl. I gave some static html just to see whether it was getting loaded but it wasn't. Can anyone tell me what the problem is? Im still not sure about the naming conventions like for files etc.
Bookmarks