Hello everyone.
I am trying to call a new controller from order_package_list.tpl file like this:
<form class="js-oxValidate" name="fertig" action="index.php?force_admin_sid=siccb6fc2adu8mcuidsejolre3&stoken=4F66373A&cl=fertig&fnc=fertig_gepacht" method="post" role="form" novalidate="novalidate">
[{$oViewConf->getHiddenSid()}]
<input type="hidden" name="cl" value="fertig">
<input type="hidden" name="fnc" value="fertig_gepacht">
<input type="hidden" name="ordernr" value="[{ $order->oxorder__oxordernr->value}]">
<input type="submit" value="Fertig gepackt!">
</form>
This is how my controller looks like in application/controller/admin/fertig.php:
class fertig extends oxAdminDetails
{
/**
* Executes parent method parent::render(), fetches order info from DB,
* passes it to Smarty engine and returns name of template file.
* "order_package.tpl"
*
* @return string
*/
public function fertig_gepacht(){
// $fertig = oxNew('fertig');
//$fertig -> update_order();
$myConfig = $this->getConfig();
parent::render();
$aOrders = oxNew('oxlist');
$aOrders->init('oxorder');
$sSql = "select * from oxorder where oxorder.oxsenddate = '0000-00-00 00:00:00' and oxorder.oxshopid = '" .
$myConfig->getShopId() . "' order by oxorder.oxorderdate asc limit 5000";
$aOrders->selectString($sSql);
$this->_aViewData['resultset'] = $aOrders;
return "order_package.tpl";
}
}
Problem is that I am getting front page of the shop
check your exception log.
Iâm not sure abould older oxid versions, but in new versions templates are only rendered if returned by the render() function, while other functions cause a redirect.
Basically, i think you are redirecting the user to controller âorder_package.tplâ which does not exist.
It the exception message confirms that, you will have to add a proper render() function, like in all the other controllers.
I am running shop version 4.10 on localhost xampp. How can view exception logs?
I am new to oxid. I am trying to use the same function written in another admin controller, so order_package.tpl does exist.
I have changed order_package_list.tpl to
<form class="js-oxValidate" name="fertig" action="index.php?force_admin_sid=siccb6fc2adu8mcuidsejolre3&stoken=4F66373A&cl=fertig" method="post" role="form" novalidate="novalidate"
and fertig.php controller to:
class Fertig extends oxAdminDetails
{
/**
* Executes parent method parent::render(), fetches order info from DB,
* passes it to Smarty engine and returns name of template file.
* "order_package.tpl"
*
* @return string
*/
public function render()
{
$myConfig = $this->getConfig();
parent::render();
$aOrders = oxNew('oxlist');
$aOrders->init('oxorder');
$sSql = "select * from oxorder where oxorder.oxsenddate = '0000-00-00 00:00:00' and oxorder.oxshopid = '" .
$myConfig->getShopId() . "' order by oxorder.oxorderdate asc limit 5000";
$aOrders->selectString($sSql);
$this->_aViewData['resultset'] = $aOrders;
return "order_package.tpl";
}
}
But it is not going to render function now. I checked with debugger.
What will be the correct way to call the render function from tpl file?
Please read the Module Documentation Module resources â OXID eShop developer documentation 6.1.0 documentation
You have to make the controller known via a module.
I am using oxid version 4.10.2. Do i need to use module in this version aswell?
Not sure.
You can orientate yourself on my blog article series for the OXID eShop series 4.8, this comes closest to your version.
A lot has changed from Series 6 onwards.
You could have my articles translated into English.
My blog articles series Modulentwicklung | Professionelle Modulentwicklung and the source code GitHub - Indianer3c/bisQuestionAnswer: How to Module Development Tutorial for OXID eShop Community Edition Series 4.8 (2015)
You donât need to call a render function. Variables are set in this method to get them in the View: $this->_aViewData[âresultsetâ] = ;
Why do i need to use modules, if i can do some database queries by making new controllers and calling them?
Thanks for your reply.
I dont need get variable in view right now. I just want to pass a variable to module and update database value
Something like :
UPDATE oxorder
SET OXFOLDER
= âORDERFOLDER_FINISHEDâ WHERE OXORDERNR
= current order nr;
For testing you donât need a module. You can copy your file to
application/controllers/admin
and call it like the others in admin.
You can do this too. Then you have to use getRequestParameter(âordernrâ); to work with
Thanks for your reply. It is very helpful.
My question is that since I am able to do what I want to without using module.
Then what is the need to create a module?
Download the demo:
Sofern immer noch die Startseite im Tab geladen wird, anbei auf Basis von http://www.foxido.de/demomodul1-backend das obige Beispiel , sodass ein neuer Artikel-Tab âarticle_wasweissichâ mit dem Text âPut in my fieldsâ erscheint. Jetzt noch analog zum Tab article_main die Daten anzeigen lassen (render) und ĂŒber ein Input-Feld das Speichern ermöglichen (save, saveinlang usw.). Das steht alles mehrfach im Forum.
In metadata.php add something like this:
'files' => array(
'fertig' => 'modulfolder/modulename/controllers/admin/fertig.php'
),
and copy your file in this folder.
Thank you for your answers. I will read more about module development.
1 Like
system
Closed
February 23, 2022, 1:03pm
18
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.