It's just one page, always the same, the url of the page is like that :
index.php?option=com_annuaire&task=regions&layout=details&id=852&addresse=av.+du+Censuy+11%2C1020%2CRenens+VD%2CCH&Itemid=100036&lang=fr
The component in question is a directory of addresses, so I have a page where I list adresses and user can make some search on those addresses. When I click on an address, I want to display some details, so I go on a detail screen and at this moment i'm deconnected.
Let's see some code, here the fucntion display of my controller :
Code:
function display()
{
$document =&JFactory::getDocument();
$task = JRequest::getVar('task');
$viewType = $document->getType();
$config = &JFactory::getConfig();
$lang = $config->getValue('config.language');
switch($this->getTask()){
case 'regions': // onglet 1
$viewName = 'regions';
break;
case 'cantons': //onglet 1 +
$viewName = 'Cantons';
break;
case 'annuaire': //onglet 2
$viewName = 'Annuaire';
break;
case 'detail': //onglet 2
$viewName = 'Detail';
break;
}
$view = &$this->getView($viewName, $viewType);
$model =&$this->getModel($viewName, 'Model');
if(!JError::isError($model))
{
$view->setModel($model, true);
}
$viewLayout= JRequest::getVar( 'layout', 'default' );
$view->setLayout($viewLayout);
$view->display();
}
The task is "regions" so here is the code of the view.html.php file of regions :
Code:
function display($tpl = null)
{
global $option;
if($this->getLayout() == 'details') {
//echo $this->_task;
$this->detailsDisplay($tpl);
return;
}
............
.............
.............
At first i check the layout var and redirect to the good function, in this case the function detailsDisplay, here is the code of this function :
Code:
function detailsDisplay($tpl = null)
{
global $option;
$user =& JFactory::getUser();
$iduser = $user->get('id');
$id= JRequest::getVar('id');
$this->_id =$id;
$region= JRequest::getVar('region');
$this->_region =$region;
$canton= JRequest::getVar('canton');
$this->_canton =$canton;
$ville= JRequest::getVar('ville');
$this->_ville =$ville;
$type= JRequest::getVar('type');
$this->_type =$type;
$npa= JRequest::getVar('npa');
$this->_npa=$npa;
$flag= JRequest::getVar('flag');
$this->_flag=$flag;
$model = &$this->getModel();
$list_region = $model->getListDetail($this->_id);
$user=$model->getUser($iduser);
$this->assignRef('user', $user);
$this->assignRef('mb_regions', $list_region);
$this->assignRef('region', $this->_region); //pour le mettre en hidden
$this->assignRef('canton', $this->_canton); //pour le mettre en hidden
$this->assignRef('ville', $this->_ville); //pour le mettre en hidden
$this->assignRef('type', $this->_type); //pour le mettre en hidden
$this->assignRef('npa', $this->_npa); //pour le mettre en hidden
$this->assignRef('flag', $this->_flag); //pour savoir sur quel page retourner (dans le template de Detail)
parent::display($tpl);
}
In this function, you can see that I call to functions from my model : getUser and getListDetails, here is the code of those 2 functions :
Code:
function getUser($iduser){
$db = $this->getDBO();
$query="SELECT * FROM #__users WHERE id=".$iduser;
$db->setQuery($query);
$this->_user = $db->loadObject();
return $this->_user;
}
function getListDetail($id)
{
$query='SELECT * FROM #__courtiers WHERE id='.$id;
$this->_courtiers = $this->_getList($query,0,0);
return $this->_courtiers;
}
And final, I display the template detailsDisplay, here is the code :
Code:
<?php defined('_JEXEC') or die();?>
<h1><?php echo JText::_( 'Détails courtier' ); ?></h1>
<div class="ann_navigation">
<a class="ann_left" href="javascript:history.back()" title="Retour" class="languages"><< <?php echo JText::_( 'RETOUR' ); ?></a>
</div>
<div class="ann_main">
<?php foreach($this->mb_regions as $mb): ?>
<p>
Si vous voulez faire de cette personne votre conseiller, il faut vous inscrire sur <a href="http://www.nakama.ch/myb_espace_perso">l'espace personnel</a>.
</p>
<h6 class="ann"><?php echo $mb->Societe;?></h6>
<table id="ann_detail">
<tr>
<td>
<?php echo JText::_( 'ADRESSE' ); ?>:
</td>
<td>
<?php if($mb->Rue){ ?>
<?php echo $mb->Rue; ?><?php } ?>
</td>
<td class="ann_adresse2">
<?php if($mb->Rue2){ ?>
<?php echo JText::_( 'ADRESSE2' ); ?>:
</td>
<td>
<?php echo $mb->Rue2; ?><?php } ?>
</td>
</tr>
<tr>
<td>
<?php //echo JText::_( 'VILLE' ); ?>
</td>
<td>
<?php if($mb->Ville){ ?>
<?php echo $mb->NPA.' '.$mb->Ville; ?><?php } ?>
</td>
<td>
</td>
<td>
<?php if($mb->Ville2){ ?>
<?php echo $mb->NPA2.' '.$mb->Ville2; ?><?php } ?>
</td>
</tr>
<tr>
<td>
<br/>
<?php if($mb->Tel){ ?>
<?php echo JText::_( 'TEL' ); ?>:
</td>
<td>
<br/>
<?php echo $mb->Tel; ?><?php } ?>
</td>
<td colspan="2" rowspan="4" class="ann_adresse2">
<div class="ann_ville">
<?php $this->getTypesCourtier($mb->id);?>
</div>
</td>
</tr>
<tr>
<td>
<?php if($mb->Fax){ ?>
<?php echo JText::_( 'FAX' ); ?>:
</td>
<td>
<?php echo $mb->Fax; ?><?php } ?>
</td>
</tr>
<tr>
<td>
<?php if($mb->Email){ ?>
<?php echo JText::_( 'EMAIL' ); ?>:
</td>
<td>
<?php echo $mb->Email; ?><?php } ?>
</td>
</tr>
<tr>
<td>
<?php if($mb->SiteWeb){ ?>
<?php echo JText::_( 'SITEWEB' ); ?>:
</td>
<td>
<?php echo $mb->SiteWeb; ?> <br/><?php } ?>
</td>
</tr>
</table>
<table id="ann_detail">
<tr>
<td colspan="6" >
<?php if($mb->DescSociete){ ?>
<?php echo JText::_( 'PRESENTATION' ); ?>:
<?php echo $mb->DescSociete; ?>
<br/><br/><?php } ?>
</td>
</tr>
<tr>
<td colspan="6">
<?php if($mb->Photo1){ ?>
<?php echo JText::_( 'NOS_CONSEILLERS' ); ?><?php } ?>
</td>
</tr>
<tr>
<td>
<?php if($mb->Photo1){ ?>
<img src="images/annuaire/<?php echo $mb->Photo1; ?>" /><?php } ?>
</td>
<td class="ann_leg">
<?php if($mb->legende1){ ?>
<?php echo $mb->legende1; ?><?php } ?>
</td>
<td>
<?php if($mb->Photo2){ ?>
<img src="images/annuaire/<?php echo $mb->Photo2; ?>" /><?php } ?>
</td>
<td class="ann_leg">
<?php if($mb->legende2){ ?>
<?php echo $mb->legende2; ?><?php } ?>
</td>
<td>
<?php if($mb->Photo3){ ?>
<img src="images/annuaire/<?php echo $mb->Photo3; ?>" /><?php } ?>
</td>
<td class="ann_leg">
<?php if($mb->legende3){ ?>
<?php echo $mb->legende3; ?><?php } ?>
</td>
</tr>
<tr>
<td>
<?php if($mb->Photo4){ ?>
<img src="images/annuaire/<?php echo $mb->Photo4; ?>" /><?php } ?>
</td>
<td class="ann_leg">
<?php if($mb->legende4){ ?>
<?php echo $mb->legende4; ?><?php } ?>
</td>
<td>
<?php if($mb->Photo5){ ?>
<img src="images/annuaire/<?php echo $mb->Photo5; ?>" /><?php } ?>
</td>
<td class="ann_leg">
<?php if($mb->legende5){ ?>
<?php echo $mb->legende5; ?><?php } ?>
</td>
<td colspan="2">
</td>
</tr>
<tr>
<td colspan="6">
<?php echo JText::_( 'SITUATION' ); ?>
<div id="map">
<img src="http://maps.google.com/maps/api/staticmap
?center=<?php echo $mb->Rue; ?>+<?php echo $mb->NPA; ?>+<?php echo $mb->Ville; ?>&zoom=13&size=500x300&maptype=roadmap
&markers=color:red|color:red|label:.|<?php echo $mb->Rue; ?>+<?php echo $mb->NPA; ?>+<?php echo $mb->Ville; ?>
&sensor=false
&key=ABQIAAAADZzYHfJ8GUBvcCWtyZn4mRT7eXjnWH0h2AQzLVrdi3QyRIc7dBRYtR4P4vEu5GAsA2Ul0lVNYQ1g8Q"/>
</div>
</td>
</tr>
</table>
<?php endforeach;?>
</div>
Then you have all the way my code goes for this screen, do you see something wrong?
Your help is very appreciated, thanks!