i have the following problem.
I made a simple app and installed it to my site. The purpose of the app is simply providing another favicon and splash-screen.
Then i created a public folder, which was correctly integrated via “bench build” into the assets. Into this folder i copied my elements.
The i introduced this into my hooks.py of the app.
normally the splash and the favicon should be replaced with the given elements here. But nothing happens.
For testing i changed the website_context in the hooks.py of erpnext. Then my splash and favicon has been adjusted. But i wanted not to modify the hooks.py of erpnext.
Because i can set the website_context in the hooks.py of erpnext itself whitelabeling is easy.
But not being able to set the website_context in the hooks.py of the app is a weak design, because the philosophy of the apps is doing things without hitting the kernel.
An interesting question is really the sequence of action while working down the hooks.py of more than one installed apps.
Is there a certain order we must consider?
Or can the order be influenced by the developer?
This can be of interest, when hooking into events of the document.
In cases where more than one values is set (for e.g. splash), the only way to decide is by setting a rule, either the first one, or the last one. Currently the app that is installed first, gets access to splash, that is “erpnext”, maybe it could be the last one.
@Idat-Consulting
You can try below code. put below code in your app directory (Ex. yourapp/template/page/utils.py)
import frappe
from frappe import _
def update_website_context(context):
if frappe.auth.get_logged_user() != "Guest":
context["check_student"]=True
else:
context["check_student"]= False
context["student_menu"]= [
{"label": _("Dashboar"), "url": "dashboard", "class": "cart-count"},
{"class": "divider"}
]
# Set Techbeeo Logo on reload
via_hooks = frappe.get_hooks("website_context")
for key in via_hooks:
context[key] = via_hooks[key]
if key not in ("top_bar_items", "footer_items", "post_login") \
and isinstance(context[key], (list, tuple)):
context[key] = context[key][-1]
if not frappe.local.conf.get("website_context"):
frappe.local.conf['website_context'] = {}
frappe.local.conf['website_context'].update(context)
So you can call any function that you put in your hooks.py just like that? Because I did the exact thing but my function just "print"s something to the console. But that isn’t showing up. Where is documented that you can implement your own functions like that?