1

I am building a simple blog but I would like to use the CKeditor for the blog message so users can style the blog message a little bit. I have never used CKeditor before and I am a bit new to Laravel also. So I managed to turn my textarea in a CKeditor field and I also build a function to store the blog posts. Thats not a problem, I see data in my database and also at my blog overview page.

But, CKeditor/Laravel will obviously store the tags, that are generated by CKeditor, in the database and will display them as just text. How can I display the text just like code?

Blog message now:

enter image description here

CKeditor

enter image description here

My code

Form

       <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label for="bericht">Nieuwsbericht <span class="required">*</span></label>
                            <textarea class="form-control" id="bericht" name="bericht" required></textarea>
                        </div>
                    </div>
                </div>

                <script type="text/javascript">
                    CKEDITOR.replace( 'bericht' );
                </script>

Display a blog post

<div class="blog-post">
                        <div class="row">
                            <div class="col-md-12">
                                <h1>{{ $blog->name }}</h1>
                            </div>

                            <div class="col-md-12">
                                <h3>{{ $blog->subtitel }}</h3>
                            </div>

                            <div class="col-md-12">
                                <p class="date">{{ $blog->created_at->formatLocalized('%A %d %B %Y') }}, Door {{$blog->user->name}}</p>
                            </div>

                            <div class="col-md-12">
                                <p class="blog-message">

                                    {{ $blog->bericht }}

                                </p>
                            </div>
                        </div>

                    </div>

1 Answer 1

6

Instead of {{ $blog->bericht }} try {!! $blog->bericht !!}

Info Here : https://laravel-news.com/laravel-5-0-blade-changes

Sign up to request clarification or add additional context in comments.

2 Comments

Nice! I already figured out I had to escape the data but didn't know how I would ever do that. Will accept your answer in 2 minutes :)
Glad to hear that .

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.