rahy
April 18, 2021, 3:29pm
1
In order to display the default company name in the navbar, I put this code in the navbar.html in frappe/frappe/public/js/frappe/ui/toolbar/navbar.html
.
<span class="company-name-header">{{ frappe.db.get_value('Global Defaults', None, 'company_name') }}</span>
But it doesn’t display the company name. And there is error when I run bench build --app frappe
:
SyntaxError: Unexpected token (2:481)
1 :
2 : frappe.templates['navbar'] = ' <div class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container"> #and the rest of the html here...
Is the code I use wrong?
What is the correct way/code to use ?
Thank you.
rahy
April 18, 2021, 5:54pm
2
I changed the quote sign in the code to
<span class="company-name-header">{{ frappe.db.get_single_value("Global Defaults", "default_company") }}</span>
and now the navbar shows
[object Promise]
rahy
April 18, 2021, 11:10pm
3
If I use this code:
<span class="company-name-header">
{% set comp = frappe.db.get_single_value("Global Defaults", "default_company") %}
{{ comp }}
</span>
The bench build
doesn’t show error but the whole navbar is not displayed on the desk.
snv
April 20, 2021, 2:02pm
4
I’ll give you a hint: the file you’re trying to modify doesn’t use Jinja.
rahy
April 20, 2021, 5:18pm
5
I was thinking it uses Jinja because I saw these:
{{ avatar }}
{%= frappe.user.full_name() %}
{%= __("My Profile") %}
Then please how to solve my problem?
I guess I have to use js, which I don’t know
Thanks.
You need to modify the toolbar.js file as well.
toolbar.js
navbar.html
If you don’t want to change core file you can check this app.
1 Like
rahy
April 22, 2021, 6:31pm
8
Thanks @Maheshwari_Bhavesh ,
I have other changes so I don’t use your app.
But thanks anyway.