G
G
Greg Plitt2016-06-17 15:10:50
PHP
Greg Plitt, 2016-06-17 15:10:50

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.
8d2f14095fef4a67b7d3f22f9c0c8a38.pnga68ca112e41441bdb151fcd1f9b4ca32.png
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

2 answer(s)
N
no_one_safe, 2016-06-20
@bit24yes

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']);
        }
        
    }    
}

file /bitrix/templates/elektro_flat/components/bitrix/catalog/.default/bitrix/catalog.element/.default/lang/ru/template.php [if not, you need to create, if there is, add to the end]
<?
$MESS["#TEXT_1#"] = "Первый текст";
$MESS["#TEXT_2#"] = "Второй текст";
$MESS["#TEXT_3#"] = "Третий текст";
?>

in the "Change product -> Details" tab you write something like
Text blah blah blah #TEXT_1#, here is the continuation of blah blah blah #TEXT_2#. And finally #TEXT_3#.

S
SharuPoNemnogu, 2016-06-17
@SharuPoNemnogu

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 question

Ask a Question

731 491 924 answers to any question