Answer the question
In order to leave comments, you need to log in
Complex component development, how to transfer CNC data?
Good afternoon. Dear tell me, I can not create the structure of a complex component.
There are 2 template files list and element
Now it is necessary to resolve their connection in the components file with and without CNC enabled.
Here is my code from component
$arDefaultUrlTemplates404 = array(
"list" => "",
"element" => "#MANUFACTURER_ID#/"
);
$arDefaultVariableAliases404 = array();
$arDefaultVariableAliases = array();
$arComponentVariables = array("MANUFACTURER_ID");
if ($arParams["SEF_MODE"] == "Y") {
$arVariables = array();
$arUrlTemplates = CComponentEngine::MakeComponentUrlTemplates($arDefaultUrlTemplates404 , $arParams["SEF_URL_TEMPLATES"]);
$arVariableAliases = CComponentEngine::MakeComponentVariableAliases($arDefaultVariableAliases404 , $arParams["VARIABLE_ALIASES"]);
$componentPage = CComponentEngine::ParseComponentPath($arParams["SEF_FOLDER"] , $arUrlTemplates , $arVariables);
if (StrLen($componentPage) <= 0)
$componentPage = "list";
CComponentEngine::InitComponentVariables($componentPage , $arComponentVariables , $arVariableAliases , $arVariables);
$SEF_FOLDER = $arParams["SEF_FOLDER"];
} else {
$arVariables = array();
$arVariableAliases = CComponentEngine::MakeComponentVariableAliases($arDefaultVariableAliases , $arParams["VARIABLE_ALIASES"]);
CComponentEngine::InitComponentVariables(false , $arComponentVariables , $arVariableAliases , $arVariables);
$componentPage = "";
if (IntVal($arVariables["MANUFACTURER_ID"]) > 0)
$componentPage = "element";
else
$componentPage = "list";
}
$arResult = array(
"FOLDER" => $SEF_FOLDER,
"URL_TEMPLATES" => $arUrlTemplates,
"VARIABLES" => $arVariables,
"ALIASES" => $arVariableAliases
);
$this->IncludeComponentTemplate($componentPage);
Answer the question
In order to leave comments, you need to log in
For CNC, you need to edit urlrewrite.php
for example:
array(
"CONDITION" => "#^/catalog/(\\d+)/(\\d+)/id(\\d+)/[^\/]*$#",
"RULE" => "SECTION_ID=\$1&SUBSECTION_ID=\$2&ELEMENT_ID=\$3",
"ID" => "galament:shop",
"PATH" => "/catalog/index.php",
),
if(isset($arVariables["action"]) && in_array($arVariables["action"], $arCompareCommands))
$componentPage = "compare";
elseif(isset($arVariables["ELEMENT_ID"]) && intval($arVariables["ELEMENT_ID"]) > 0)
$componentPage = "element";
elseif(isset($arVariables["ELEMENT_CODE"]) && strlen($arVariables["ELEMENT_CODE"]) > 0)
$componentPage = "element";
elseif(isset($arVariables["SECTION_ID"]) && intval($arVariables["SECTION_ID"]) > 0)
$componentPage = "section";
elseif(isset($arVariables["SECTION_CODE"]) && strlen($arVariables["SECTION_CODE"]) > 0)
$componentPage = "section";
elseif(isset($_REQUEST["q"]))
$componentPage = "search";
else
$componentPage = "sections";
$this->IncludeComponentTemplate($componentPage);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question