0

I want push this php code to javascript variable like a string, is it posible?

$APPLICATION->IncludeComponent("wt:static.content", "bonus10", array(
        "DEFAULT_LANG" => array(
        0 => "",
),
    "LANGUAGE_ID" => "",
    "USE_DEFAULT" => "Y",
    "INCLUDE_LANGUAGE" => "",
    "CACHE_TYPE" => "Y",
    "CACHE_TIME" => "3600"
),
false,
array(
    "ACTIVE_COMPONENT" => "Y",
    "HIDE_ICONS" => "N"
)
);
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>
2
  • It might help if you explain why you want to do this. Generally, PHP should be kept on the server, so this is a little out of the ordinary. If you need to use part of this code on the client, you could output HTML with a JS script tag and echo the PHP variable there. Commented Jan 17, 2017 at 12:50
  • im doing it via nodejs, for automatic template creator Commented Jan 17, 2017 at 12:51

1 Answer 1

2
var string = '$APPLICATION->IncludeComponent("wt:static.content", "bonus10", 
                                            array("DEFAULT_LANG" => array(0 => "",),
                                            "LANGUAGE_ID" => "",
                                            "USE_DEFAULT" => "Y",
                                            "INCLUDE_LANGUAGE" => "",
                                            "CACHE_TYPE" => "Y",
                                            "CACHE_TIME" => "3600"),
                                            false,array("ACTIVE_COMPONENT" => "Y",
                                                            "HIDE_ICONS" => "N"));
                                                            require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php"‌​);?>';
Sign up to request clarification or add additional context in comments.

3 Comments

thank you very much all most done, but when it writing this string to file i saw this result: $APPLICATION->IncludeComponent("wt:static.content", "bonus10", array(NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN is it posible to fix?
var string = '$APPLICATION->IncludeComponent("wt:static.content", "bonus10", array(' +' "DEFAULT_LANG" => array( ' + '0 => "",'+ +'),'+ +' "LANGUAGE_ID" => "", ' + ' "USE_DEFAULT" => "Y", ' + ' "INCLUDE_LANGUAGE" => "", ' + '"CACHE_TYPE" => "Y", ' +'"CACHE_TIME" => "3600"' +'),' +'false,' +' array(' +'"ACTIVE_COMPONENT" => "Y",' +' "HIDE_ICONS" => "N"' +')' +');' +' require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>';
Yep! var string = '$APPLICATION->IncludeComponent("wt:static.content", "bonus10", array("DEFAULT_LANG" => array(0 => "",),"LANGUAGE_ID" => "","USE_DEFAULT" => "Y","INCLUDE_LANGUAGE" => "","CACHE_TYPE" => "Y","CACHE_TIME" => "3600"),false,array("ACTIVE_COMPONENT" => "Y","HIDE_ICONS" => "N"));require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.