<?php

/**
 * [BEGIN_COT_EXT]
 * Hooks=market.list.catsparse.childrens
 * [END_COT_EXT]
 */

defined('COT_CODE') or die('Wrong URL.');

require_once cot_incfile('catextratypes', 'plug');

$epArr = array();
$sql = $db->query("SELECT * FROM $db_catextratypes WHERE e_area='market' AND e_catid=".$ctmp['id']." ORDER BY e_title ASC")->fetchAll();
foreach($sql as $val) {
  $epArr[$val['e_id']] = $val['e_title'];
}

if(count($epArr) > 0) {
  foreach($epArr as $epId => $ep) {
    $t->assign(array(
      "ATTR_2_ROW_ID" => $epId,
    	"ATTR_2_ROW_TITLE" => $ep,
      "ATTR_2_ROW_CODE" => 'cet_'.$epId,
      "ATTR_2_ROW_ATTR_LVL" => 2,
      "ATTR_2_ROW_ACTIVE" => ($id_sub_attr == $epId ? 1 : 0)
    ));

    if($id_sub_attr > 0 && $id_sub_attr == $epId) {
      $tmpurl = $list_url_path;
      $tmpurl['id_sub_attr'] = $epId;
      $t->assign(array(
        "CATS_BC_ROW_ID" => $epId,
      	"CATS_BC_ROW_TITLE" => $ep,
        "CATS_BC_ROW_CODE" => 'cet_'.$epId,
      	"CATS_BC_ROW_URL" => cot_url('market', $tmpurl),
        "CATS_BC_ROW_LAST" => 1,
        "CATS_BC_ROW_ISATTR" => 1,
        "CATS_BC_ROW_JJ" => 2,
      ));
      $t->parse("MAIN.CATS_BREADCRUMBS");
    }

    $t->parse("MAIN.CATS_CATALOG.CC_CHILDRENS_1.CC_CHILDRENS_2");
  }

  $ctmpchilds = array();
  $hassubs = 1;
}