By Jostein Rosenlund on Friday, 13 December 2013
Posted in Technical Issues
Replies 4
Likes 0
Views 1.1K
Votes 0
This is my function:
Located in "Media/com_easysocial/apps/user/evepos/models/apierror.php"

public function getItems( $userId ) {

$string = "https://api.eveonline.com/eve/ErrorList.xml.aspx";
$xml = simplexml_load_file($string);


foreach ($xml->result->rowset as $row) {
$count = $row->count();
};


$i = "0";
$arraynode ="1";
do {


$errorcode = "error_".$xml->result->rowset->row[0+$i]['errorCode'];
$this->set( $errorcode , $xml->result->rowset->row[0+$i]['errorText']);

$count = $count-1;
$arraynode = $arraynode+1;
$i = $i+1;

}

while ($count > 0);



}


}


in "Media/com_easysocial/apps/user/evepos/views/evepos.php"

Iv coded in

public function display( $userId )


{


$model = $this->getModel( 'apierrors' );
$result = $model->getitems( $userId );

echo $this->error_101;
}


This will put out an error message

Notice: Undefined property: EvePosViewCanvas::$error_101


What the function in the model does, is that it collects data from an api and put them into

$this->error_100 
$this->error101
$this->error102

and so on


What I want here, is to be able to echo $this->error101 in this case in canavas/view.html.php.

So what do i need to do in order to be able to use these values in views as well as in the application themes?
Do i have to write the foreach statement inside view.html.php ? or can i import the values from the module to views and themes somehow?
Solved it:

Edited views.html.php

$poslist =$this->getModel('poslist');
$poslist->POSlist( $userId );
$poslist->get('pos_1');

$this->set( 'pos1' , $poslist->get('pos_1'));



and in the default template, i echoed it out whit. "echo $pos1; "
·
Saturday, 14 December 2013 06:08
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,

You need to understand that within the apps view, using $this now refers to the view and not the model. If you have set properties within a model, you should use $model->error101 or $model->get( 'error101' );

By the way, you can reach me on Skype if you need more dev tips, would love to help you out My Skype id is marklee_777
·
Saturday, 14 December 2013 01:07
·
0 Likes
·
0 Votes
·
0 Comments
·
Tanks, that explained a lot for me. (I'm not awere of how the link betwene the module and the view works. Next step for me were my knowledge about this stops, are at the themes

This is what iv got in my View.html.php
		$poslist = $this->getModel('poslist');
$poslist->POSlist( $userId );


Can echo out $poslist->pos1; in views, but it does not print out anything in


The attached
echo parent::display( 'canvas/default' );


puts out the error


Notice: Undefined variable: poslist in /home/norcorp/public_html/media/com_easysocial/apps/user/evepos/themes/default/canvas/default.php on line 22

Notice: Trying to get property of non-object in /home/norcorp/public_html/media/com_easysocial/apps/user/evepos/themes/default/canvas/default.php on line 22


I'll sneak peak into the already existing code, to se if i can find a hint about how i do it;) "so hopefully I'v learned this as well, before i fell asleep infront of my computer;)
·
Saturday, 14 December 2013 05:46
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Jostein,

I am sorry for the delay of this reply. You need to set the variables to the theme. For instance, if you want to use $posList , you need to add this in the view,


$this->set( 'posList' , $posList );
·
Tuesday, 17 December 2013 00:10
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post