Thursday, May 17, 2012

Create your own CMS-Part 14

Before creating our blog module,just make sure to do the following modifications.
  • In engine.php ,add the following line to start all the enabled modules before the line $theme->load_css();
$module->start_all_enabled_modules();
  • Update show_msg function in functions.php in main folder.
/**************************************
showing a message
EG:-  show_msg('TITLE OF YOUR MESSAGE','CONTENT');
******************************************/
function show_msg($title,$msg)
{
echo '<script type="text/javascript" src="'.BASE.'/jquery.js"></script>
 <script type="text/javascript" src="'.BASE.'/jquery.freeow.js"></script>';
echo '<script type="text/javascript">
  (function ($) {
  $(document).ready(function() {

   var title, message, opts, container;
   message="'.$msg.'";
   title="'.$title.'";   
   $("#freeow-tr").freeow(title,message);

  });
}(jQuery));
</script>
';
}
  • Add some more function to work with modules and themes.
/***************************
Get the list of modules present in the cms
returns both installed and uninstalled modules
****************************/
function get_modules_list()
{
global $module;
$modules_list=$module->get_modules_list();
return $modules_list;
}
/***************************
Get the list of themes in the cms
****************************/
function get_themes_list()
{
global $theme;
$themes_list=$theme->get_themes_list();
return $themes_list;
}
/************************
checks whether a module is enabled
**************************/
function is_module_enabled($module_name)
{
global $module;
return $module->is_active($module_name);
}
function register_module($name)
{
global $module;
$module->register_module($name);
}
/************************
checks whether a module is installed
**************************/
function is_module_installed($module_name)
{
global $module;
return $module->is_module_installed($module_name);
}
/*************************************
get the details of a module from its
manifest file.
************************************/
function get_module_details($name)
{
$module_details=xml2array(MODULESPATH.'/'.$name.'/manifest.xml');
$module_details['picture']=BASE.'/'.MODULESPATH.'/'.$name.'/pic.png';
return $module_details;
}
The function register module is to add the module to the database.The description and details of a module will be present in the manifest.xml file inside the directory of corresponding module.So we need a function to parse the xml file.

The function will be provided in the upcoming tutorial.

As we are advancing a little bit,the default theme will have to be modified very much.Instead ,You can download the 'fbtheme' for next stage.

Download fbtheme

1 comment:

  1. Is there any more on this topic as this seems to be the last tutorial I can find.

    ReplyDelete