Page 1 of 1

Newbe needs help with first module

Posted: Fri Feb 05, 2010 8:14 pm
by musicscore
I'm trying to build my first simple module.
I managed to create the install and uninstall part.
After installing the module I file the database with 2 record.
But there is now output in my page

This is my code

Code: Select all


/* Your initial Class declaration. This file's name must be "[class's name].module.php", or, in this case,
   Catlist.module.php
*/ 
class Catlist extends CMSModule
{

    function GetName()
    {
        return 'Scim';
    }

    function GetFriendlyName()
    {
        return $this->Lang('friendlyname');
    }

    function GetVersion()
    {
        return '0.1';
    }
         
    function IsPluginModule()
    {
         return true;
    }
	
	// Install - Unstall Messages 
	function InstallPostMessage()
	{
		return $this->Lang('postinstall');
	}
	
	function UninstallPreMessage()
	{
		return $this->Lang('uninstall_confirm');
	}

	function UninstallPostMessage()
	{
		return $this->Lang('postuninstall');
	}
	
	function DoAction($action, $id, $params, $returnid=-1)
	{
		if ($action == 'default')
		{
			$db =& $this->GetDb();
			$sql = 'SELECT * FROM ' . cms_db_prefix().'module_scim_players';
			$dbresult =& $db->Execute($sql);
     
			$list = "Spelers<br /><br />\n";
			$list .= "<ul>\n";
			while ($dbresult && $row = $dbresult->FetchRow())
			{                    
				$list .= "<li><b>" . $row['voorletters'] . '</b><br />';
				
				$list .= $row['roepnaam'] . '<br />';
				$list .= $row['tussenvoegsel'] . '<br />';
				$list .= $row['achternaam'] . '<br />';
				$list .= "</li>\n";
			}
		$list .= "</ul>\n";
		$list .= "<br /><br />\n";
		}
	
	// assign to Smarty
	global $gCms;
	$this->smarty->assign('list', $list);
	/**
    *Insert: {cms_module module='Scim'}{$list}
    *in your page template
    *But there has to be a way for this to work without the {$list} tag...
    **/
	return;
	}
}
?>
I then enter the tag on my page. No error, but also no output.
What is going wrong. Please help me.
I tryed to use the manual on the documentation page of cmsmadesimple.org

Musicscore

Re: Newbe needs help with first module

Posted: Fri Feb 05, 2010 8:28 pm
by Jos
Do you have a template for frontend display of your module?

In the default action goes the code:

Code: Select all

// Display template
echo $this->ProcessTemplateFromDatabase($template);


For this example to work, you need to have a template for your module in the database.

In that template you can display with {$list}

It's nicer to make $list an array and have a smarty foreach to loop throught the $list array, and add the html code there, in stead of in your php code

You may want to install the skeleton module for a nice example.