Results 1 to 8 of 8

Thread: Can't view my custom module in the FE [Solved]

  1. #1
    User
    Join Date
    02-18-10.
    Posts
    32

    Default Can't view my custom module in the FE [Solved]

    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.

  2. #2
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Can't view my custom module in the FE

    You have gone to layout:modules and made a new module of type home link, then embedded it in an article or page layout?

  3. #3
    User
    Join Date
    02-18-10.
    Posts
    32

    Default Re: Can't view my custom module in the FE

    I added my module to the page layout. I added the module from the tutorial and it was displayed but there was no html for the module made.

    This was the tutorial i reffered to
    http://dev.typolight.org/wiki/1/TutorialsExtension

    I kinda figured out the backend customisation. But cant seem to get it displayed in the front end. Thanks for the reply. If u know the problem please help.

  4. #4
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Can't view my custom module in the FE

    Seems good to me....Probably something to do with your .tpl template???
    Perhaps post that here.
    Is anything showing in html "view source?" on your page (the module block etc??)
    Is your css preventing it from showing?
    If you give your FE module a headline can you see that?
    Can't think of much else.

  5. #5
    User
    Join Date
    02-18-10.
    Posts
    32

    Default Re: Can't view my custom module in the FE

    This is my mod_home_link.tpl
    Code:
    <div class="<?php echo $this->class; ?>"<?php echo $this->cssID; ?><?php if ($this->style): ?> style="<?php echo $this->style; ?>"<?php endif; ?>>
    <?php if ($this->headline): ?>
    
    <<?php echo $this->hl; ?>><?php echo $this->headline; ?></<?php echo $this->hl; ?>>
    <?php endif; ?>
    
    <table cellpadding="4" cellspacing="0" summary="My CD collection"><?php foreach ($this->cds as $cd): ?> 
      <tr>
        <td>[img]<?php echo $cd['src']; ?>[/img]" /></td>
        <td><?php echo $cd['title']; ?> (<?php echo $cd['artist']; ?>)
    
    <?php echo $cd['comment']; ?></p></td>
      </tr><?php endforeach; ?> 
    </table>
    
    </div>
    <?php echo "hey";?>
    I just cant figure whats wrong.

  6. #6
    User
    Join Date
    02-18-10.
    Posts
    32

    Default Re: Can't view my custom module in the FE

    Made the same thing again with table name tl_hns. Changed files names to tl_hns. Some how the output came. Still dont know what the problem was. But i got some problems like, the field names are not coming from my langauge file. Why does that happen. This is the code to my lang file
    Code:
    $GLOBALS['TL_LANG']['tl_hns']['title']   = array('Title', 'Please enter the CD title.');
    This is the code in the DCA file
    Code:
    'title' => array
    		(
    			'label'                   => &$GLOBALS['TL_LANG']['tl_hns']['title'],
    			'inputType'               => 'text',
    			'search'                  => true,
    			'eval'                    => array('mandatory'=>true, 'maxlength'=>64)
    		)
    But still the label dhows 'title' . The capital 'T' is not shown.

  7. #7
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Can't view my custom module in the FE

    It all looks fine to me. Browser/server caching problem perhaps?
    Going to User Functions:Personal data and purging data may help.
    Also you can turn on debugging in Settings if you haven't already.
    If you attach a zip of your test module i'll install and try it on my system.

  8. #8
    User
    Join Date
    02-18-10.
    Posts
    32

    Default Re: Can't view my custom module in the FE

    I guess it was a caching problem. Now all my new modules are working fine. I also did the purge data thing. Anyways its working now. Thanks for all the help.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •