简体   繁体   中英

How to Call a function of Controller From Twig

This is my view:

<div class="CSlider">
<div class="CProducts" >
<table>
<tr>
{% for count in 1..result|length %}
<td>
{% block tile %}
{% include 'tile.twig' %}
{% endblock %}
<h1>
{{ result[ count - 1 ].id }}
</h1>
</td>
{% if count is divisible by (6) %}
</tr>
<tr>
{% endif %}
{% endfor %}
</table>
</div>
</div>

And this is my controller:

class COlxMyAdsController extends COlxDatabaseHandler {
protected $view;
public function __construct($container){
parent::__construct($container);
$this->view=$container->view;
}
public function fetchMyLiveAdIdsByUserId( Request $request, Response $response ) {
$args=$request->getParams();
$args=$args['id'];
$results = $this->m_objOlxUserDetails->fetchMyLiveAdIdsByUserId($args);
return $this->view->render($response,'profile.twig',['result' => $results]);
}
}

I want to call a function of the controller from the view. How can I do this using Twig?

Here we can Use Exit_Tags

Through which we can assign a URL to that exit_tag to call this function

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM