Errors when inserting tags in custom pages [SOLVED]

Hello,

 

I built my own skin using Bootstrap but I’m having some issues using the PHP and language tags.

 

I want the user’s name to appear in the navbar header when they log in. I placed the tag {{ $user->name }} but it only works in templates that already come default with PHPVMS 7, for example with home, dashboard, etc. When I open one of the custom pages I have a 500 error.

 

On the other hand, language tags also don’t work when I insert them into a custom page. For example: @lang(‘common.profile’), does not appear rendered as “Perfil” (“Profile” in Spanish) but instead appears directly as “@lang(‘common.profile’)”.

 

Thanks in advance.

What is a “custom page” ? Do you have the user model accessible on that custom page you referring ? What does the error details say ?

 

If you can follow the “Getting Help” guide, it will be more easy for others to understand and try helping you out.

 

https://docs.phpvms.net/help#information-required

 

Good luck

 

Hi . Thanks for your reply. For “custom page” I mean those you can add from admin panel through the option config -> pages/links.

 

By the way, I could fix the issue with the tags like {{ $user->name }} modyfing them to {{Auth::user()->name}}.

16 hours ago, Imanol said:

Hi . Thanks for your reply. For “custom page” I mean those you can add from admin panel through the option config -> pages/links.

 

By the way, I could fix the issue with the tags like {{ $user->name }} modyfing them to {{Auth::user()->name}}.

 

Understood… 

 

The problem is simple, those pages do not have a controller providing you data to use. This is why {{ $user->name }} fails but {{ Auth::user()->name }} works. To be able to use for example $flight, $user or $aircraft you need it to be prepared in the backend (controller) and passed to the view (that page you are visiting), otherwise you will get errors and those pages are not designed to provide you those details.

 

Same applies to translations and helpers (@lang is a helper), try using {{ __(‘common.profile’) }} instead of @lang(‘common.profile’), it may work.

 

https://laravel.com/docs/10.x/localization#retrieving-translation-strings

 

Good luck

On 11/16/2023 at 4:52 PM, DisposableHero said:

 

Understood… 

 

The problem is simple, those pages do not have a controller providing you data to use. This is why {{ $user->name }} fails but {{ Auth::user()->name }} works. To be able to use for example $flight, $user or $aircraft you need it to be prepared in the backend (controller) and passed to the view (that page you are visiting), otherwise you will get errors and those pages are not designed to provide you those details.

 

Same applies to translations and helpers (@lang is a helper), try using {{ __(‘common.profile’) }} instead of @lang(‘common.profile’), it may work.

 

https://laravel.com/docs/10.x/localization#retrieving-translation-strings

 

Good luck

 

Hi ,

 

I have done some tests but {{ __(‘common.profile’) }} is not working either. However, I solved this creating a module per section. Thanks for your help!

1 Like