Skip to content
This repository has been archived by the owner on Nov 28, 2017. It is now read-only.

Updated guide #19

Open
wants to merge 4 commits into
base: step-5-adding-a-menu-variable-request
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions helloworld.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component"
version="2.5.0"
method="upgrade">
<extension type="component" version="3.2.0" method="upgrade">

<name>Hello World!</name>
<!-- The following elements are optional and free of formatting constraints -->
<creationDate>November 2009</creationDate>
<creationDate>January 2014</creationDate>
<author>John Doe</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>http://www.example.org</authorUrl>
Expand All @@ -16,16 +14,16 @@
<!-- The description is optional and defaults to the name -->
<description>Description of the Hello World component ...</description>

<update> <!-- Runs on update; New in 2.5 -->
<update> <!-- Runs on update; New since J2.5 -->
<schemas>
<schemapath type="mysql">sql/updates/mysql</schemapath>
</schemas>
</update>

<!-- Site Main File Copy Section -->
<!-- Note the folder attribute: This attribute describes the folder
to copy FROM in the package to install therefore files copied
in this section are copied from /site/ in the package -->
to copy FROM in the package to install therefore files copied
in this section are copied from /site/ in the package -->
<files folder="site">
<filename>index.html</filename>
<filename>helloworld.php</filename>
Expand All @@ -36,11 +34,11 @@

<administration>
<!-- Administration Menu Section -->
<menu>Hello World!</menu>
<menu link='index.php?option=com_helloworld'>Hello World!</menu>
<!-- Administration Main File Copy Section -->
<!-- Note the folder attribute: This attribute describes the folder
to copy FROM in the package to install therefore files copied
in this section are copied from /admin/ in the package -->
to copy FROM in the package to install therefore files copied
in this section are copied from /admin/ in the package -->
<files folder="admin">
<!-- Admin Main File Copy Section -->
<filename>index.html</filename>
Expand Down
15 changes: 11 additions & 4 deletions site/controller.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_helloworld
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla controller library
jimport('joomla.application.component.controller');

/**
* Hello World Component Controller
*
* @since 0.0.1
*/
class HelloWorldController extends JControllerLegacy
{
}
}
13 changes: 9 additions & 4 deletions site/helloworld.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_helloworld
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import joomla controller library
jimport('joomla.application.component.controller');

// Get an instance of the controller prefixed by HelloWorld
$controller = JControllerLegacy::getInstance('HelloWorld');

Expand All @@ -13,4 +18,4 @@
$controller->execute($input->getCmd('task'));

// Redirect if set by the controller
$controller->redirect();
$controller->redirect();
28 changes: 17 additions & 11 deletions site/models/helloworld.php
Original file line number Diff line number Diff line change
@@ -1,43 +1,49 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_helloworld
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla modelitem library
jimport('joomla.application.component.modelitem');

/**
* HelloWorld Model
*
* @since 0.0.1
*/
class HelloWorldModelHelloWorld extends JModelItem
{
/**
* @var string msg
* @var string message
*/
protected $msg;
protected $message;

/**
* Get the message
* @return string The message to be displayed to the user
* @return string The message to be displayed to the user
*/
public function getMsg()
{
if (!isset($this->msg))
if (!isset($this->message))
{
$jinput = JFactory::getApplication()->input;
$id = $jinput->get('id', 1, 'INT');

switch ($id)
{
case 2:
$this->msg = 'Good bye World!';
$this->message = 'Good bye World!';
break;
default:
case 1:
$this->msg = 'Hello World!';
$this->message = 'Hello World!';
break;
}
}

return $this->msg;
return $this->message;
}
}
1 change: 1 addition & 0 deletions site/models/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
10 changes: 9 additions & 1 deletion site/views/helloworld/tmpl/default.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_helloworld
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');
?>
<h1><?php echo $this->msg; ?></h1>
<h1><?php echo $this->msg; ?></h1>
9 changes: 4 additions & 5 deletions site/views/helloworld/tmpl/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
type="list"
label="COM_HELLOWORLD_HELLOWORLD_FIELD_GREETING_LABEL"
description="COM_HELLOWORLD_HELLOWORLD_FIELD_GREETING_DESC"
default="1"
>
<option value="1">Hello World!</option>
<option value="2">Good bye World!</option>
</field>
default="1">
<option value="1">Hello World!</option>
<option value="2">Good bye World!</option>
</field>
</fieldset>
</fields>
</metadata>
24 changes: 19 additions & 5 deletions site/views/helloworld/view.html.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_helloworld
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla view library
jimport('joomla.application.component.view');

/**
* HTML View class for the HelloWorld Component
*
* @since 0.0.1
*/
class HelloWorldViewHelloWorld extends JViewLegacy
{
// Overwriting JView display method
/**
* Display the Hello World view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*/
function display($tpl = null)
{
// Assign data to the view
Expand All @@ -23,7 +36,8 @@ function display($tpl = null)

return false;
}

// Display the view
parent::display($tpl);
}
}
}