Jump to content

Errors when inserting tags in custom pages [SOLVED]


Recommended Posts

Posted (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 by Imanol
Posted (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 by DisposableHero
Posted

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}}.

Posted
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

  • 2 weeks later...
Posted
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!

  • Like 1
  • Imanol changed the title to Errors when inserting tags in custom pages [SOLVED]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...