Laravel 5.2 + Unicode - laravel

when I use a single view file with uni-code in it, it shows the the content correctly but when I make a layout and extends with it from another page it doesn't show the uni-code character it shows ????
#extends('layouts/custom_layout.blade')

Check what encoding is used in your other view. Convert it to UTF-8 and it will work fine.
To avoid encoding related problems, use popular IDEs or text editors like Sublime Text or Notepad++ for editing files.

In custom_layout.blade.php file:
````
<div class="container">
<div class="content">
<div class="title">Laravel 5</div>
गृह
</div>
</div>
````
In home.blade.php file:
#extends('custom_layout')
And off course I have used meta tag charset="utf-8" in head tag.

My friend I had the same problem with the unicode characters it turns out that the IDE was causing the problem , I use Jetbrains PHPStorm. I edited the file with sublime and it turns alright.

Related

Dispay Laravel blade content to user as is

I have laravel template.blade.php
<div class="classone">
<div class="classtwo">
text
</div>
<div class="classtwo">
text
</div>
</div>
And I would like to display the code to the user as it is. Incluing new line and indents.
I was playing around with {!! !!}, nl2br(view()->render() even Blade::compileString but was unable to find an elegant solution. Everytime I was able to make it work it was difficult to maintain and every small change to the displayed code was laber intense.
I would like to ask for a suggeston how to display more complex html/css/js code to user. I though it will be fairy often topic but was unable to find anything which would help me.
Thank you in advance.
I tried some things out. They may seem a little bit 'hacky' but I think they will suit your purpose. I used a freshly created Laravel 8 application as an example.
<pre>{{ file_get_contents( resource_path('views/welcome.blade.php')) }}</pre>
You can use the Blade facade to compile your blade file to plain php if you want:
<pre>{{ Blade::compileString(file_get_contents( resource_path('views/app.blade.php'))) }}</pre>
I put <pre></pre> tags around the output to show line breaks. It makes the code more readable.

Prevent TinyMce in Joomla to modify inserted html code

I'm using joomla (last version) and just added this template in tinymce :
<a href="/test" class="darkimagediv">
<img src="/images/logo2.png">
<div>
<div>
Test
</div>
</div>
</a>
It displays fine in the popup dialog just before inserting, but when I do it is inserted like that:
<p><a class="darkimagediv" href="test"> <img src="images/logo2.png" /></a></p>
<div>
<div>Test</div>
</div>
<p> </p>
Which is very bad.
I'm superuser and text filtering is off in the global configuration. I don't find any cleanup option in tinymce, so I need to find which script modify my html but I don't even know if I must search tinymce or joomla itself.
If you are pasting code Don't use a rich text editor.
The editor is doing what it is supposed to and correcting your incorrect markup. Either way, if you want to insert markup, incorrect or not, then don't use a rich text editor.

CKEditor HTML Autocorrection Issue

I have few lines of HTML in my database. I want to edit the content in CKEditor. But when I open that in editor the HTML gets break down. The HTML gets rearranged.
Below is the HTML which is in database:
<span class="sec_title">
<h1><span>Web</span> Engineering</h1>
<hr>
</span>
And when I open it in CKEditor the HTML looks likes below:
<h1><span class="sec_title"><span>Web</span> Engineering</span></h1>
<hr />
Some one please help me. I tried config.allowedContent = true; but it is also not stopping the CKEditor to do the modifications.
CKEditor works with a valid HTML only and <h1> is not a valid content of <span>. Quoting CKEditor basic concepts:
CKEditor is not a tool that will let you input invalid HTML code. CKEditor abides by W3C standards so it will modify code if it is invalid.

SimpleXML extract text between two tags

I am sorry if this is a stupid question but i am new to programming. I just want to know how to extract text between two tags. For example, if i have the html below:
<div class="s1">
Hi
</div>
<div class="s2">
Hello
</div>
The expected output is to extract the #href in class s1 and the text Hi.
I know that this is easy in JavaScript with the JQuery Library. In PHP it is also possible (php jquery like selector engine)

CKEditor , how to disable HTML indented format

I'd like to ask if there is a way to disable indented format of HTML source code in CKEditor. I don't want the HTML to be formatted because I want to store it in a database and there is no need for extra characters (line breaks and spaces). I just want the raw html without spaces and lines.
for example
the HTML output in CKEditor is
<p>
test 1</p>
<p>
test 2</p>
<p>
test 3</p>
but what I need is
<p>test 1</p><p>test 2</p><p>test 3</p>
This doc at the CKEditor howto shows how you can modify the formatting of the output, so you just have to specify the rules that you want: http://docs.cksource.com/CKEditor_3.x/Howto/FCKeditor_HTML_Output

Resources