THELIA Forum

Welcome to the THELIA support and discusssion forum

Announcement

Rejoignez la communauté sur le Discord Thelia : https://discord.gg/YgwpYEE3y3

Offline


Hello,

I've created module and I have a problem with routing. After update record I would like to redirect to another route. I use this code:

$this->redirectToRoute('admin.productComment.update')

My route definition:

<route id="admin.productComment.update" path="/admin/productComment/update">
     <default key="_controller">ProductComment\Controller\Admin\ProductCommentController::updateAction</default>
</route>

Is this method available only for routes defined in Config/Resources/routing/admin.xml ? - so only for Thelia base routes ?.

What's working for me is this:

URL::getInstance()->absoluteUrl('admin/productComment')

But the best solution is to usign the rout id not the path. Path can change later

  • manu
  • faï tot petar miladiu

Offline


Hello,

each module had his own router, if you want to use it, you have to redifine currentRouter property in your controller using setCurrentRouter() method in your constructor for example.

class ProductCommentController extends BaseAdminController
{
   public function __controller()
   {
       $this->setCurrentController('router.ModuleCode');
   }
}

After that you can use redirectToRoute method as you describe in your post.


http://doc.thelia.net/
http://thelia.net/modules
http://raynaud.io
PGP public Key : 0xC6E546A6