dev19's avatar
Level 1

I wanted to print it in blade file: $page['body'] = "<h1>{{ __('about-us.metas.meta_title') }} </h1>"

I tried it like {!! $page['body'] !!}. But it prints the HTML dont compile the inner translation code.

0 likes
16 replies
Sinnbeck's avatar

You cannot do it like that.

$page['body'] = '<h1>'. __('about-us.metas.meta_title') }} .'</h1>';

This should work

dev19's avatar
Level 1

@Sinnbeck but I have to store the page body content in the db with its translation data key. so whenever I render the body. All the content should execute. What is the best way to do it. Can you please guide?

Sinnbeck's avatar

@dev19 But can you explain why you are using the database to store things that you should store in blade file? I hope you aren't letting users create them (big security risk) :)

dev19's avatar
Level 1

@Sinnbeck Yes I am allowing the admin to create its own pages like about-us or privacy etc.

Sinnbeck's avatar

@dev19 Ok and they are allowed to access everything on the server? Like database credentials?

This is my h1

<h1><pre>{{file_get_contents(base_path('.env'))}}</pre></h1>
1 like
Sinnbeck's avatar

@dev19 Ok. Just making sure you know the risk. The admin has access to anything on the server that the php user has. And you take daily backup in case someone deletes all users by accident or similar (remember they can do anything they like on the server)

1 like
dev19's avatar
Level 1

@Sinnbeck Yes in real admin is a devOps person so and also Product Manager he will use the Admin Panel. Thanks for your reply. I really appreciate your help. Thanks @sinnbeck .

Sinnbeck's avatar

Also remember to validate the php before saving it :) Just a small reminder. If they write this, the page will no longer work

<h1>{{ __('about-us.metas.meta_title') } </h1>
1 like
dev19's avatar
Level 1

@sinnbeck Is there any other way to generate pages from admin panel if I use the file system.

dev19's avatar
Level 1

Like I have the /pages/{page:slug} when I use db. so what I will do if I use filesystem for routing and for the file content. Whenever the admin generate a page. I will generate file?

Sinnbeck's avatar

@dev19 That just moves the problem to a file, and it would mess with git. I thought it was static coded files by you. So the database is probably fine here, if you understand the security risks :)

1 like

Please or to participate in this conversation.