Discussion:
[oxid-dev-general] Create new articlelist
Roland Gruber
2009-11-14 01:14:42 UTC
Permalink
Hi everybody



I'm trying do create my first extension for oxid. It should be a new view
for the products of the last x days. I just wrote the code below (with some
help of the community), saved it in the file newestarticles.php and copied
this file to the folder /view/. So if I call now the class newestarticles
with www.myshop.de/index.php?cl=newestarticles, I can see in the debug-mode,
that the object 'newestarticles' has been created, but it has no value
(null). Of course, the query "SELECT * FROM oxarticles LIMIT 10" gets the
values, which I'd like to have in 'newestarticles'.

Can anybody give me a hint, what I have to change to get the values out of
the query into 'newestarticles'?



Kind regards

Roland







<?php

class newestarticles extends oxUBase {



public function init()

{

parent::init();

$this->_sThisTemplate = 'newestarticles.tpl';

}





public function render()

{

$this->_aViewData['newestarticles'] = $this->getnewarticles();

parent::render();



return $this->_sThisTemplate;

}



public function getnewarticles()

{

$sQuery = "SELECT * FROM oxarticles LIMIT
10";



$aList = oxNew('oxarticlelist');

$this->_aList =
$aList->selectString($sQuery);



return $this->_aList;

}



}

?>
Manuel Reiß
2009-11-16 08:45:24 UTC
Permalink
Hi Roland,
as you can see in the comments of oxarticlelist's selectString-method (*
@return bool), the return value would be boolean.
Therefore your expression
$this->_aList = $aList->selectString($sQuery);
will just set $this->_aList to a boolean value. (But even this won't happen,
since the parent (oxList) will return null ;) )
Therefore, one solution would be: skip this class-member ($this->_aList) and
just return your object:

$aList = oxNew('oxarticlelist');
$aList->selectString($sQuery);
return $aList;

have a nice week.

***@mediaopt.de | www.mediaopt.de

derksen mediaopt gmbh
galvanistrasse 6 | 10587 berlin | +49 (30) 34 09 42-77? fax-66 | ust.-id
de265886017 | gesch?ftsf?hrer dipl.-ing. philipp derksen | amtsgericht
charlottenburg | hrb 120935 b

-----Urspr?ngliche Nachricht-----
Von: dev-general-***@lists.oxidforge.org
[mailto:dev-general-***@lists.oxidforge.org] Im Auftrag von Roland
Gruber
Gesendet: Samstag, 14. November 2009 02:15
An: dev-***@lists.oxidforge.org
Betreff: [oxid-dev-general] Create new articlelist

Hi everybody



I'm trying do create my first extension for oxid. It should be a new view
for the products of the last x days. I just wrote the code below (with some
help of the community), saved it in the file newestarticles.php and copied
this file to the folder /view/. So if I call now the class newestarticles
with www.myshop.de/index.php?cl=newestarticles, I can see in the debug-mode,
that the object 'newestarticles' has been created, but it has no value
(null). Of course, the query "SELECT * FROM oxarticles LIMIT 10" gets the
values, which I'd like to have in 'newestarticles'.

Can anybody give me a hint, what I have to change to get the values out of
the query into 'newestarticles'?



Kind regards

Roland







<?php

class newestarticles extends oxUBase {



public function init()

{

parent::init();

$this->_sThisTemplate = 'newestarticles.tpl';

}





public function render()

{

$this->_aViewData['newestarticles'] = $this->getnewarticles();

parent::render();



return $this->_sThisTemplate;

}



public function getnewarticles()

{

$sQuery = "SELECT * FROM oxarticles LIMIT
10";



$aList = oxNew('oxarticlelist');

$this->_aList =
$aList->selectString($sQuery);



return $this->_aList;

}



}

?>
Roland Gruber
2009-11-14 01:14:42 UTC
Permalink
Hi everybody



I'm trying do create my first extension for oxid. It should be a new view
for the products of the last x days. I just wrote the code below (with some
help of the community), saved it in the file newestarticles.php and copied
this file to the folder /view/. So if I call now the class newestarticles
with www.myshop.de/index.php?cl=newestarticles, I can see in the debug-mode,
that the object 'newestarticles' has been created, but it has no value
(null). Of course, the query "SELECT * FROM oxarticles LIMIT 10" gets the
values, which I'd like to have in 'newestarticles'.

Can anybody give me a hint, what I have to change to get the values out of
the query into 'newestarticles'?



Kind regards

Roland







<?php

class newestarticles extends oxUBase {



public function init()

{

parent::init();

$this->_sThisTemplate = 'newestarticles.tpl';

}





public function render()

{

$this->_aViewData['newestarticles'] = $this->getnewarticles();

parent::render();



return $this->_sThisTemplate;

}



public function getnewarticles()

{

$sQuery = "SELECT * FROM oxarticles LIMIT
10";



$aList = oxNew('oxarticlelist');

$this->_aList =
$aList->selectString($sQuery);



return $this->_aList;

}



}

?>
Manuel Reiß
2009-11-16 08:45:24 UTC
Permalink
Hi Roland,
as you can see in the comments of oxarticlelist's selectString-method (*
@return bool), the return value would be boolean.
Therefore your expression
$this->_aList = $aList->selectString($sQuery);
will just set $this->_aList to a boolean value. (But even this won't happen,
since the parent (oxList) will return null ;) )
Therefore, one solution would be: skip this class-member ($this->_aList) and
just return your object:

$aList = oxNew('oxarticlelist');
$aList->selectString($sQuery);
return $aList;

have a nice week.

***@mediaopt.de | www.mediaopt.de

derksen mediaopt gmbh
galvanistrasse 6 | 10587 berlin | +49 (30) 34 09 42-77? fax-66 | ust.-id
de265886017 | gesch?ftsf?hrer dipl.-ing. philipp derksen | amtsgericht
charlottenburg | hrb 120935 b

-----Urspr?ngliche Nachricht-----
Von: dev-general-***@lists.oxidforge.org
[mailto:dev-general-***@lists.oxidforge.org] Im Auftrag von Roland
Gruber
Gesendet: Samstag, 14. November 2009 02:15
An: dev-***@lists.oxidforge.org
Betreff: [oxid-dev-general] Create new articlelist

Hi everybody



I'm trying do create my first extension for oxid. It should be a new view
for the products of the last x days. I just wrote the code below (with some
help of the community), saved it in the file newestarticles.php and copied
this file to the folder /view/. So if I call now the class newestarticles
with www.myshop.de/index.php?cl=newestarticles, I can see in the debug-mode,
that the object 'newestarticles' has been created, but it has no value
(null). Of course, the query "SELECT * FROM oxarticles LIMIT 10" gets the
values, which I'd like to have in 'newestarticles'.

Can anybody give me a hint, what I have to change to get the values out of
the query into 'newestarticles'?



Kind regards

Roland







<?php

class newestarticles extends oxUBase {



public function init()

{

parent::init();

$this->_sThisTemplate = 'newestarticles.tpl';

}





public function render()

{

$this->_aViewData['newestarticles'] = $this->getnewarticles();

parent::render();



return $this->_sThisTemplate;

}



public function getnewarticles()

{

$sQuery = "SELECT * FROM oxarticles LIMIT
10";



$aList = oxNew('oxarticlelist');

$this->_aList =
$aList->selectString($sQuery);



return $this->_aList;

}



}

?>

Continue reading on narkive:
Loading...