Imanol Posted November 15, 2023 Report Posted November 15, 2023 (edited) 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. Edited December 1, 2023 by Imanol Quote
DisposableHero Posted November 15, 2023 Report Posted November 15, 2023 (edited) 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 Edited November 15, 2023 by DisposableHero Quote
Imanol Posted November 16, 2023 Author Report Posted November 16, 2023 Hi @DisposableHero. 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}}. Quote
DisposableHero Posted November 16, 2023 Report Posted November 16, 2023 16 hours ago, Imanol said: Hi @DisposableHero. 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 Quote
Imanol Posted December 1, 2023 Author Report Posted December 1, 2023 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 @DisposableHero, 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.