Hi everyone! Well i don't speak english so much, so sorry about anything what i write wrong.
Well, I have a problem when i need to get the segment 3 or anything other 4,5,6.
This is my code which the action is register and when it's called, the action get the 3 param of the uri where is set in a link button <a href="House/register/{idhouse_via_template_engine}">Edit the House</a> which is the id of a house for example.
Well, until then everything is okay . But when I click a link where I am coming back to the parent controller , for example , standing on the registration page with the third segment , all working ok and I click on a button to return to the management page : <a href = " House / index " > Back to the management </a> .
My URL , rather than "House/index" is "House/register/House". I don't know what the url doesnt "reset", and symple redirect to the House/index
PHP Code:
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
include_once(APPPATH . 'controllers/IdwellerController.php');
class House extends IdwellerController{
public function __construct() {
parent::__construct();
$this->load->helper('url');
$this->load->model('houses');
}
public function index() {
$this->setTitle('House management');
$allHouses= $this->houses->returnAllHouses();
$rows = array();
foreach($allHouses as $arrayValues){
$rows[] = $arrayValues;
}
$dataToView= array(
'bloco_lista_residencia' => $rows
);
$this->pushToScreen($dataToView);
}
public function register(){
if($this->uri->segment(3, 0)){
$this->setTitle('House editing');
$idHouse= $this->uri->segment(3,0);
$dadosParaView = $this->houses->returnHouseForId($idHouse);
}else{
$this->setTitle('House register');
$dataToView= array(
'idHouse' => '',
'number' => '',
'local' => ''
);
}
$this->pushToScreen($dataToView);
}
}