Jump to content

shadd

Members
  • Posts

    55
  • Joined

  • Last visited

Everything posted by shadd

  1. // Handles paper details class PaperView { // Public variables to be used in fsa template public $mPaper; public $mPaperId; // Private stuff private $_mStudylevelId; private $_mSubjectId; private $_mPaperId; // Class constructor public function __construct($StudylevelId,$SubjectId,$PaperId) { // Variable initialization // Get StudylevelId from query string casting it to int $paginate = new Pag(35); if ($StudylevelId<>'') $this->_mStudylevelId = (int)$StudylevelId; // Get SubjectId from query string casting it to int if ($SubjectId<>'') $this->_mSubjectId = (int)$SubjectId; if ($PaperId<>'')//$_GET['ProductId'])) $this->mPaperId = (int)$PaperId; //$_GET['ProductId']; else trigger_error('PaperId not set'); } } that is the class i used to try to capture the mpaperid variable from the papercontroller class below class papersController extends Controller { //public $paper; public function index($StudylevelId='',$SubjectId='',$PaperId='',$name='') { echo 'PaperId is'. $PaperId;//check wether variables are there require MODEL.'paper_view.php'; //$Paper new PaperView($StudylevelId,$SubjectId,$PaperId); // Retrieve data from the model $this->view('papers\index',new PaperView($StudylevelId,$SubjectId,$PaperId)); $this->view->render(); } the view is here <section class="bg" > <?php //require MODEL.'paper_view.php'; /*$className = str_replace(' ', '', ucfirst(str_replace('_', ' ', substr(basename(__FILE__), 0, strrpos(basename(__FILE__), '.')))));*/ // Create presentation object //$Papersdetail=new PaperView($StudylevelId,$SubjectId,$PaperId); //$Papersdetail = new $className(); ?> <!-- Quiz Box --> <div class="quiz_box"> <header> <div class="title"><?=mPaperId?></div> </header> </div> iam not getting the variable displayed above.how can i do that
  2. I can actually see this, when i render the view page.It is there in the paperscontroller as seen with the echo statement there. it does display at the top of the view page.My issue is that i cannot access this inside the paperview class that needs to use it.
  3. I have this controller: class papersController extends Controller { //public $paper; public function index($StudylevelId='',$SubjectId='',$PaperId='',$name='') { echo 'StudylevelId is'. $StudylevelId; require MODEL.'paper_view.php'; //$Paper new PaperView($StudylevelId,$SubjectId,$PaperId); // Retrieve data from the model //$data = $this->model->getData();// Pass the data to the view //$this->view->render('route_view', ['data' => $data]); $this->view('papers\index',new PaperView($StudylevelId,$SubjectId,$PaperId)); $this->view->render(); } i need to pass the three variables $StudylevelId,$SubjectId,$PaperId in index function() to the paperview model // Handles paper details class PaperView { // Public variables to be used in fsa template public $mPaper; public $mPaperId; // Private stuff private $_mStudylevelId; private $_mSubjectId; private $_mPaperId; // Class constructor public function __construct($StudylevelId,$SubjectId,$PaperId) { // Variable initialization // Get StudylevelId from query string casting it to int $paginate = new Pag(35); if ($StudylevelId<>'') $this->_mStudylevelId = (int)$StudylevelId; // Get SubjectId from query string casting it to int if ($SubjectId<>'') $this->_mSubjectId = (int)$SubjectId; if ($PaperId<>'')//$_GET['ProductId'])) $this->mPaperId = (int)$PaperId; //$_GET['ProductId']; else trigger_error('PaperId not set'); } how can i access the data from paperview model in the actual view below.the echo statement works fine but the variables cannot be accessed in the view page for further use <section class="bg" > <?php //require MODEL.'paper_view.php'; /*$className = str_replace(' ', '', ucfirst(str_replace('_', ' ', substr(basename(__FILE__), 0, strrpos(basename(__FILE__), '.')))));*/ // Create presentation object //$Papersdetail=new PaperView($StudylevelId,$SubjectId,$PaperId); //$Papersdetail = new $className(); ?> <!-- Quiz Box --> <div class="quiz"> <header> <div class="title"><?=$data->mPaperId?><h2> PAPER 1</h2></div> i can't acess $StudylevelId,$SubjectId,$PaperId in the above code. help out
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.