Joomla.it Forum
Joomla! 1.5.x (versione con supporto terminato) => Joomla! 1.5 => : legolasgs 08 Jan 2009, 19:34:08
-
Ciao ragazzi, per prima cosa voglio congratularmi con tutto il team per la disponibilità nel dedicare il loro tempo a persone che vogliono imparare, e poi mi sono deciso ad iscrivermi dopo aver letto penso tutte le guide su internet ma non aver ben compreso lo sviluppo di componenti seguendo l'mvc pattern.
Girando qua e la ho trovato l'ottimo componente di Odino per le prenotazioni, però visto che mi servivano altre carateristiche ho pensato di modificarlo o riscriverlo così che possa anche fare un po' di pratica.
Chiaramente ::)... mi sono arenato quasi subito, in quanto non ho ben capito la logica che sta dietro l'mvc.
In pratica ho creato/modificato lato frontend questa struttura:
- preventive.php
<?php
defined('_JEXEC') or die('Restricted access');
require_once (JPATH_COMPONENT.DS.'controller.php');
if($controller = JRequest::getVar('controller')) {
require_once (JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php');
}
$classname = 'preventiveController'.$controller;
$controller = new $classname( );
$controller->execute( JRequest::getVar('task'));
$controller->redirect();
?>
controller.php
<?php
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.controller');
class preventiveController extends JController
{
function display()
{
if (!JRequest::getCmd( 'view' ) ) {
JRequest::setVar('view', 'preventive' );
}
parent::display();
}
function sendpreventive(){
JRequest::setVar('view', 'sendpreventive' );
//parent::display();
}
}
?>
views/preventive/view.html.php
<?php
defined('_JEXEC') or die('Restricted access');
jimport( 'joomla.application.component.view');
class preventiveViewpreventive extends JView
{
function display($tpl = null)
{
global $mainframe;
//$greeting = "";
$db = &JFactory::getDBO();
$model = &$this->getModel();
$document = &JFactory::getDocument();
$user = &JFactory::getUser();
$params = &$mainframe->getParams();
$document->addScript("includes/js/joomla.javascript.js");
$query = "SELECT * FROM #__preventive ORDER BY ID";
$db->setQuery($query);
$rooms = $db->loadObjectList();
foreach ($rooms as $k=>$v) {
$optionlist = null;
$list = null;
for ($i=1; $i<=$rooms[$k]->maxnum; $i++)
{
$optionlist[] = JHTML::_('select.option', $i, $i );
}
$lists['optionlist'] = JHTML::_('select.genericlist', $optionlist, 'room_'.$rooms[$k]->id, 'class="inputbox"', 'value', 'text', '' );
$rooms[$k]->list=$lists;
}
//$this->assignRef( 'greeting', $greeting );
$this->assignRef( 'rooms', $rooms );
$this->assignRef( 'params', $params );
parent::display($tpl);
}
}
?>
views/preventive/tmpl/default.php
<div id="gsbooking<?php echo $this->params->get( 'pageclass_sfx')?>">
<?php
$mainframe->set('joomlaJavascript', 1);
defined('_JEXEC') or die('Restricted access');
JHTML::_( 'behavior.calendar' );
if ( $this->params->def( 'show_page_title', 1 ) ) {
?>
<div class="componentheading">
<?php echo $this->params->get('page_title'); ?>
</div>
<?php
}
if ( $this->params->get('show_name',1)) {
?>
<div class="componentheading">
<?php echo $this->params->get('name'); ?>
</div>
<?php
}
?>
<div class="contentpane">
<?php
if ($this->params->def('show_comp_description', 1) ){
?>
<div class="contentdescription">
<?php
echo $this->params->get('comp_description');
?>
</div>
<?php
}
if ($this->params->get('show_intro')){
?>
<div class="intro"><?php echo $this->params->get('intro');?></div>
<?php
}
?>
<div class="form">
<form method="post" action="<?php echo JRoute::_('index.php?option=com_preventive&task=sendpreventive&Itemid='.JRequest::getVar( 'Itemid', 0, '', 'int'))?>">
<table class="input_form" cellpadding="0" cellspacing="0">
<tr>
<td><?php echo JText::_('ARRIVAL')?></td>
<td>
<input class="inputbox data" onclick="return showCalendar('arrival', '<?php echo $this->params->get('date_format')?>');" onfocus="return showCalendar('arrival', '<?php echo $this->params->get('date_format')?>');" type="text" name="arrival" id="arrival" maxlength="10"/>
</td>
</tr>
<tr>
<td><?php echo JText::_('DEPARTURE')?></td>
<td>
<input class="inputbox data" onclick="return showCalendar('departure', '<?php echo $this->params->get('date_format')?>');" onfocus="return showCalendar('departure', '<?php echo $this->params->get('date_format')?>');" type="text" name="departure" id="departure" maxlength="10"/>
</td>
</tr>
<?php
foreach ($this->rooms as $rooms){
?>
<tr>
<td><?php echo $rooms->room ?></td>
<td><?php echo $rooms->list['optionlist']?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="2" class="inputSend">
<input type="submit" name="confirm" value="<?php echo $this->params->get('submit_preventive')?>" />
<input type="hidden" value="2" name="step"/>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
views/sendpreventive/view.html.php
VUOTA
views/sendpreventive/tmpl/default.php
VUOTA
ecco.. praticamente non ho capito come impostare la funzione sendpreventive() che dovrebbe mostrare a video il preventivo e un nuovo form (come nello script originale) il quale poi dovrebbe inviare una mail e salvare i dati sul db....
vi ringrazio in anticipo dell'aiuto
:)