PHP code after result.write()...


Author Message
Jurek

Posted: 7/25/2012
Quote message 

Hello
This is code from export.js :
$('.art-content').html('<?php include (\'main_menu.php\'); if ($g_is_main) {include (\'include/rand_link.php\');} include (\'include/rss.php\'); ?>');

after starting export.js in result8-) code is:
<?---php and ?-->

I want it to be:
<?php and ?>

 
Khachatur

Posted: 7/25/2012
Quote message 

Hi!

The '<?php...' is not valid for jquery/DOM.

you need something like this:


var placeholders = {
content: '<?php include (\'main_menu.php\'); if ($g_is_main) {include (\'include/rand_link.php\');} include (\'include/rss.php\'); ?>'
};
$('.art-content').html('{content}');

result.write(
'export.php',
$('body').html().replace(
/(\{[a-z_][a-z0-9_\-]+?)\}/gi,
function (str, ph) { return placeholders[ph] || ph; }
)
);


or this:


$('.art-content').html('{content}');

result.write(
'export.php',
$('body').html().replace(
/(\{[a-z_][a-z0-9_\-]+?)\}/gi,
function (str, placeholder) { return template.read('fragments/' + placeholder + '.php'); }
)
);


where the php code snippet is placed in template / fragments.