douyi1939 2019-04-04 17:23
浏览 50

如何将控制器数据(php)传递给ContentBuilder的内容块?

i've bought the latest ContentBuilder.js from innovastudio. I've integrated it in my cms and is working fine. Now i have created new static blocks this works fine also. But now i try to make dynamic blocks with php data passed from the controller when the page loads but can't seems to make it work. I know php loads before javascript .But i'm a little bit stuck.

Does someone already have worked with contentbuilder.js and could someone please guide me how to resolve this issue please?

I'm working in laravel 5.8 , i did getelementbyid with javascript and replace the value with the dynamic value . This works but only for single rows and not collections.-

<script type="text/javascript">
    jQuery(document).ready(function ($) {
       var DBaddress = '{{$settings[0]['address']}}';
       var DBnumber = '{{$settings[0]['number']}}';
       var DBpostalcode = '{{$settings[0]['postal_code']}}';
       var DBtown = '{{$settings[0]['town']}}';
       var DBtel = '{{$settings[0]['telephone']}}';
       var DBemail = '{{$settings[0]['email']}}';




        var obj = $.contentbuilder({
            container: '.container_edit',
            imageselect: 'admin/laravel-filemanager',
            cellFormat: '<div class="col-md-12"></div>',
            rowFormat: '<div class="row"></div>',
            framework: 'bootstrap',


        });

        $('#btnViewSnippets').on('click', function () {
            obj.viewSnippets();
        });

        $('#btnViewHtml').on('click', function () {
            obj.viewHtml();
        });

        /*$('#btnSave').on('click', function () {
            save(obj.html());
        });*/

       document.getElementById("address").innerHTML= DBaddress;
       document.getElementById("number").innerHTML= DBnumber;
       document.getElementById("postalcode").innerHTML= DBpostalcode;
       document.getElementById("town").innerHTML= DBtown;
       document.getElementById("tel").innerHTML= DBtel;
       document.getElementById("email").innerHTML= DBemail;

    });
</script>

Here the section where the page builder is set :

@section('content')
<div class="container_edit">
            {!! $page->contentBuilder !!}
        </div>
@if( basename(url()->current()) !== $page->slug)
        <div class="is-tool" style="position:fixed;width:210px;height:50px;border:none;top:250px;bottom:50px;left:auto;right:30px;text-align:right;display:block">
            <button id="btnViewSnippets" class="classic" style="width:70px;height:50px;">+ Add</button>
            <button id="btnViewHtml" class="classic" style="width:70px;height:50px;">HTML</button>
            <button id="btnSave" data-id="{{$editPageDetails[0]->uuid}}" class="classic" style="width:70px;height:50px;">SAVE</button>
        </div>
@endif

@endsection

This is how i could manage to make it work, but again this is for single rows. I would like to have the complete collection so i could create dynamic blocks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用
    • ¥15 微信小程序协议怎么写
    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?