如何在octobercms页面中插入带有“ file_get_contents”的页面? [关闭]

问题描述 投票:-2回答:1

在通常的PHP页面中,我应该使用此:

<?php echo file_get_contents("https://www.mywebsite.com/folder/index.php?controller=pjFrontEnd&action=pjActionPrint&booking_id=" . $_GET['booking_id']); ?>

但是我不知道如何在octobercms上插入它。有什么建议吗?谢谢!

php file-get-contents octobercms
1个回答
0
投票

您需要使用页面的code部分。

function onStart() {        
    $this['remote_content'] = file_get_contents('https://jsonplaceholder.typicode.com/todos/1');  
    // you can use: https://www.avminho.com/expressos/index.php?controller=pjFrontEnd&action=pjActionPrint&booking_id=" . $_GET['booking_id']  
}

使用onStart生命周期挂钩,并将您的php代码添加到code section中,并将输出存储到remote_content变量中,然后像markup section一样在{{remote_content}}中使用它。

供参考的屏幕截图

[注意:它将减慢您的页面加载时间,因为它将尝试从其他站点获取详细信息,从而使您的其他站点能够快速响应。

enter image description here

[如有疑问请发表评论。

© www.soinside.com 2019 - 2024. All rights reserved.