Macro content simplified to eliminate other errors.

Macro:

public function getDeliveryAjax($template = 'default') { list( $templateBlock, $templateLineItem, $templateMapItem, $templateJavascript ) = def_module::loadTemplates('emarket/delivery/'.$template, 'delivery_tab_block', 'delivery_line_item', 'delivery_map_item', 'delivery_javascript' ); $block_arr['attribute:delivery_line_items'] = 'text1'; $block_arr['attribute:delivery_map_items'] = 'text2'; $block_arr['attribute:delivery_javascript_items'] = 'text3'; return def_module::parseTemplate($templateBlock, $block_arr); } 

The default.tpl template is located on the tpls / emarket / delivery / default.tpl path:

 <?php $FORMS = Array(); $FORMS['delivery_tab_block'] = <<<END <div> <table class="b-order_delivery"> %delivery_line_items% </table> <table class="b-order_delivery"> %delivery_map_items% </table> <div id="map"> %delivery_javascript_items% </div> </div> END; 

I launch the link via the browser: http://site.ru/udata/emarket/getDeliveryAjax

At the exit I get:

 <udata xmlns:xlink="http://www.w3.org/TR/xlink" delivery_line_items="text1" delivery_map_items="text2" delivery_javascript_items="text3" module="emarket" method="getDeliveryAjax" generation-time="1.222877"/> <!-- This page generated in 2.299103 secs by XSLT, HTTP SCHEME MODE --> 

How to display macro data with a template?

I do everything on the example of other macros.

    1 answer 1

    For php-template I use the following code:

     public function getDeliveryAjax() { // ваш код $template = 'emarket/delivery/default'; $currentTemplater = cmsController::getInstance()->getCurrentTemplater(); $templatesSource = $currentTemplater->getTemplatesSource(); $templater = new umiTemplaterPHP($templatesSource); $buffer = OutputBuffer::current('HTTPOutputBuffer'); $buffer->push($templater->render($result, $template)); $buffer->end(); return $result; } 

    And put the php template in the emarket / delivery / default.phtml file

    Call as site.ru/emarket/getDeliveryAjax/

    • Unfortunately both options do not work - md5hash
    • I have a site on phtml templates, I want to receive a call on a macro call, a rendered block with html markup. And without pushing the html markup into the macro itself. And I plan to call the macro from ajax. - md5hash
    • But the information about the php-template engine should be immediately published. Updated the answer. - Arthur Shiriev
    • In. thank! more than a month looking for a solution to this problem. And where is it described, in the documentation I did not find such a thing? - md5hash
    • I pulled it out of the source somewhere - Arthur Shiriev