Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Как вывести на странице товара с другой таблицы данные

Recommended Posts


у меня вот такой код есть в контролере:


$data['doctor3s'] = [];
$doctor3s_seller = $this->model_catalog_product->getDoctor3sSeller($product_info['seller_id']);
    foreach($doctor3s_seller as $d){
        $data['doctor3s'][] = array(
            'doctor3_id' => $d['doctor3_id'],
            'doctor_name' => $d['doctor_name'],
            'rating' => $d['rating'],
            'date' => $d['date']
$data['doctor3_count'] = count($data['doctor3s']);



и тогда в цикле я выводил данные в product.twig (шаблоне):


{% for d in doctor3s %}
<span>{{ d.name }}</span><br>
<span>{{ d.date }}</span>
<span>{{ d.doctor_name}}</span>
<span>{{ d.rating}}</span>
 {% endfor %}


а я хочу вывести без цикла 2 переменных. Чтобы была перенная {{ doctor3s_name }} и {{ doctor3_rating }}

как мне это сделать?

Link to comment
Share on other sites

$data['doctor3s_name'] = (!empty($doctor3s_seller[0]['doctor_name']) ? $doctor3s_seller[0]['doctor_name'] : '');

$data['doctor3_rating'] = (!empty($doctor3s_seller[0]['rating']) ? $doctor3s_seller[0]['rating'] : '');

  • +1 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.