( Laravel ) Break lines not working ; Balise aren't displayed anymore but it won't start a new line - laravel

I'm trying to break a line but it's always displayed whatever I do so I guess I'm doing something wrong.
Here is my line from my php file
But it's displayed like this :
My site is designed to help content creators on the web, create a free account and start \nmaking money now.
Can you help me please ?

Replace \n with <br>
Use <p></p>
My site is designed to help content creators on the web, create a free account and start making money now
Use CSS white-space property for \n (example)

try to use <br> on blade, and if you use {!! !!} i think that must be inner html inside your string. cmiiw

You can save your html text as variable like this
$subtitle_welcome = "<p>My site is designed to help content creators on the web, create a free account and start </p> <p> making money now.</p>";
OR
$subtitle_welcome = "My site is designed to help content creators on the web, create a free account and start <br/> making money now.";
And you have to show in blade
{!! $subtitle_welcome !!}

Related

how to ignore iframe on blade Laravel

#Asking
Help me for my problem, when i built a website with Laravel
i am render my post with syntax like this :
<div>
<p>{!! $post->content !!}</p>
</div>
but i have problem, when i insert a i frame inside post, because the html has been removed with {!! !!}.
i have to try use {{ $post->content }}, but all content rendered with HTML
Any solution to this problem? ?
Thanks very much
With {!! you paste content "as is", in other words you become vulnerable to all types of issues like allowing <script> tags to be placed into your templates.
The {{ syntax will escape any HTML thus what you see is the actual html characters without actually parsing it (i.e. doing {{ '<b>bold</b>' }} will not result in a bold font but in the text <b>bold</b>).
Now with your problem: there are some cumbersome ways to filter out any html tags yourself and leave the <iframe>'s in there (something like {!! only_iframe($content) !!}), but it is quite difficult and will likely not result in a safe solution.
Your own answer which stated that you used {!!html_entity_decode($post->content)!!} simply means that your HTML was encoded to start with, which is not something I can deduct from your question. Note that you are now vulnerable to malicious code injection if you are not certain you can control the contents of $post->content.

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.

php preg_match value within multiple div

I want to extract the version number of a webserver. the version number is showed on the admin login page.
i tried this:
$content = file_get_contents('URL/login.jsp');
preg_match("/<div class=\"product-version\".*div>/", $content);
echo "content: $content";
It does show the version number but also a large part of the rest of the page.
part of the page i want to have preg_match look in:
<div class="product-logo" style="background-image:url(images/product/icon-system-admin.png)">
<div class="product-version">10.3</div>
</div>
</h2>
Is this possible? or to edit the preg_match to just use the 4 characters after product-version is found?
#Toto that solved it, thanks!
Next thing is to get this working for a bunch of urls.
Want to have the script read urlcustomers.txt in the same directory and show all the version of the webserver for each customer in a table.

Display ID within QR Code

I'm trying to get the current survey id to show within my QR code, however it's only displaying
$survey->id
I'm sure there is something simple I'm missing (first laravel project). Any help would be appreciated.
Reference simple software QR
View
<img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->size(200)->generate('localhost:8000/survey/view/$survey->id')) !!} ">
Currently you are echoing $survey->id as a string, you want to use the value of said variable.
To do this you will need to remove it from the string and instead place it as the variable inside your url.
<img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->size(200)->generate('localhost:8000/survey/view/'.$survey->id)) !!} ">
Furthermore you might want to change the way your generate your link and instead use route names or the actions instead of the hardcoded local host, this might give trouble when deploying your application.

PJAX Scroll Loading

I'm working on a news publishing site that needs to load in stories from an RSS feed below the current news page. I've been using InfiniteAjaxScroll (http://infiniteajaxscroll.com/) to some success however, I've hit a brick wall. There is not way for me to dynamically change what story should load in next as you scroll down the page.
Does anyone know of any other plugins, tutorials, examples that replicate behavior like this. I've searched but come up with nothing that meets these requirements.
I'm trying to create something similar to what the Daily Beast has implemented on their site.
http://www.thedailybeast.com/articles/2014/11/05/inside-the-democrats-godawful-midterm-election-wipeout.html
How do they know what stories to load in?
Thanks!
If you're using the InfiniteAjaxScroll library, the "next story" is whatever link you define as the next URL which can be dynamic for each story you load.
Imagine your first story's HTML as something like this
<div class="stories">
<div class="story">
...
</div>
</div>
<div id="pagination">
next
</div>
Then in the storyC.html you have
...
<div id="pagination">
next
</div>
Assuming you're using some sort of dynamic backend, you would use some sort logic to grab a related story and just set that URL as the "next" URL.

Resources