Answer the question
In order to leave comments, you need to log in
Display the language file in the Item Description field. How to insert php there?
The essence of the question, it would seem simple, but the brain is already blown up.
There is a folder in Bitrix in the bitrix template:catalog
/lang/ru/ there, in the template.php file, I filled in new phrases
. If I then output these phrases through editing in the /catalog.element/.default/template.php template, then everything is displayed well. I just insert for example
<?=GetMessage('MOY_TEST')?>
But, I need to display it in the product description. In other words, so that my content manager would simply insert such variables into the product description.
As a result, in html mode, inserting php code leads to the fact that an empty paragraph is then displayed in place.
How can this be fixed? Do I need to convert the code somehow, or maybe there are plugins that allow php code to be inserted into the product description, and not just html?
Answer the question
In order to leave comments, you need to log in
File result_modifier.php
file /bitrix/templates/elektro_flat/components/bitrix/catalog/.default/bitrix/catalog.element/.default/result_modifier.php [if not, you need to create, if there is, add to the end]
<?
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true)
die();
//если файл result_modifier.php есть, код выше добавлять не надо
if(strlen($arResult['DETAIL_TEXT']) > 0){
$re = "/#(\\w+)#/";
preg_match_all($re, $arResult['DETAIL_TEXT'], $matches);
if(count($matches) > 0){
foreach($matches[0] as $match){
$TEXT_VALUE = GetMessage($match);
$arResult['DETAIL_TEXT'] = str_replace($match, $TEXT_VALUE, $arResult['DETAIL_TEXT']);
}
}
}
<?
$MESS["#TEXT_1#"] = "Первый текст";
$MESS["#TEXT_2#"] = "Второй текст";
$MESS["#TEXT_3#"] = "Третий текст";
?>
make tags like {{MY_TEST}} and when saving on the server, parse them from the content and replace them with GetMessage('MY_TEST');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question