COAddOns project site-Add-Ons for MiaCMS, Mambo & Joomla CMS

 Home arrow FAQs arrow How-To arrow How to create a Mambo Component?
Pick Language to Auto Translate:
AR | BG | CA | CS | DA | DE | EL | ES | FI | FR | HI | HR | ID | IT | IW | JA | KO | LV | LT | NO | NL | PL | PT | RO | RU | SK | SR | SL | SV | TL | UK | VI | ZH | ZT
SiteMap :: Contact Us :: About Us :: Member Blog :: Newsfeeds :: How-To :: News :: CMS Info :: MosNews :: Web Tools :: IRC Chat  

Main Menu
Home
Forums
Downloads
CMS Category
Web Links
FAQs
Blog
MoseCMS
COAddOns Wiki
COAddOns Docs
Drupal resources
Who's Online
We have 498 guests online
MosCmenuTree

FAQs

Feature Sites
Web Hosting
Q's quickdeals
OpensourceCMS
CMS Matrix
Joomla Extensions
Joomla Templates
Login Form
Username

Password

Remember me
Password Reminder
No account yet? Create one
Donate
Support OngETC in making a small donation:
Syndicate

MosNewsWriter

How to create a Mambo Component? Print E-mail
User Rating: / 10
PoorBest 
How to create a Mambo Componente?

Note: This is just a skeleton component, no error checking no validation, etc.

The overview: You create a zip file that you can use to do an install using Mambo installer
What is needed: yourmcomponent.php, yourcomponent.xml and admin.yourcomponent.php.  Use these three files to create com_yourcomponent.zip.  (See below for more optional files)
What is yourcomponent.xml: This is a file that the installer need to know some info regarding your module and do the install
What is yourcomponent.php: This is a file where you put the logic of your component to be executed by Mambo
What is admin.yourcomponent.php: This is a file where you put the logic of your component to be executed by Mambo backend admin area

Here is a sample content would go in your yourcomponent.xml

<?xml version="1.0" encoding="iso-8859-1"?>
<mosinstall type="component">
 <name>yourcomponent</name>
  <creationDate>09/25/2006</creationDate>
  <author>Your Name</author>
  <copyright>(C) 2003-2013 Your Name</copyright>
  <license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
  <authorEmail> </authorEmail>
  <authorUrl>www.yoursite.com</authorUrl>
  <version>0.1</version>
  <description>Your component description</description>
<files>
  <filename>yourcomponent.php</filename>
 </files>
<administration>
    <menu>YourComponent</menu>
<files>
    <filename>admin.yourcomponent.php</filename>
</files>
</administration>
</mosinstall>

Here is a content would go in your yourcomponent.php
Let say you want to get some data from your database and I just use the content table as an example here. This is very simple version of a component like a "hello world" type you can expand on this to utilize the admin and toolbar in the back which I will cover below and to add more customization to your component or add more data validation routine. It is only limit to your imagination!

<? // beginning of component
// must have to protect from potential security risk
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
// declare your database
global $database;
// get the latest 5 articles
$qry="SELECT * FROM #__content WHERE published = '1' ORDER BY id DESC LIMIT 5";
$database->setQuery($qry);
// get and load the records from the query
$rows = $database->loadObjectList();
// process each row, build and print the URL of the comment
foreach($rows as $row) {
echo "Article:<br />".$row-introtext." ".$row->fulltext."<br>";
}
// end of component
?>

Note: If you are going to have admin backend then you will need a few more files: admin.yourcomponent.html.php, toolbar.yourcomponent.php, toolbar.yourcomponent.html.php

Here is a content of yourcomponent.php.  (Note: no admin backend here but need to have a dummy file for component)
<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
require_once( $mainframe->getPath( 'admin_html' ) );
// a dummy backend file for admin area
?>

Here some optional files that if you have an admin area for your component

Here is a content of admin.yourcomponent.html.php. 
<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
class YOURCOMPONENT {
// some html related stuff used to show your admin backend  
} //end class
?>

Here is a content of toolbar.yourcomponent.php. 
<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
require_once( $mainframe->getPath( 'toolbar_html' ) );
if ($task) {
// do something for the toolbar
}
?>

Here is a content of toolbar.yourcomponent.html.php. 
<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
class YOURCOMPONENT {
// do some html related stuff for your toolbar
}
?>

That's it and enjoy!
Comments

There are no comments yet. Feel free to add one using the form below.

You are not authorized to leave comments. Please login first.
<Previous   Next>




Sponsors

Reseller hosting (free)

000webhost (free)

HostUpon (w/ ssh)

Hosting24 (w/ ssh)

Free TK domain

CO.CC:Free Domain

Get Chitika Premium

Free Windows Hosting


Arizona Landscaping - Credit Counseling - United Specialties - Renegade Motorhomes
Validate XHTML
Validate CSS