Federico Posted March 15, 2018 Share Posted March 15, 2018 Hello pw community, is it possible to add some hook functions to the Uikit theme as well? I see all others themes (default and Reno) have extensive hooks capabilities, whereas the Uikit based theme in the admin has only the ___breadcrumb available. I am looking specifically to hook the masterhead navigation, but I believe the array of requests might be larger. I was discussing this on another thread @ryan sorry to bother you, maybe you already gave it some thoughts about. Do you think this will require intense work? Thank you very much! Link to comment Share on other sites More sharing options...
bernhard Posted March 15, 2018 Share Posted March 15, 2018 hi federico, sorry for you that you didn't get any answers so far. the community is usually really fast and helpful Unfortunately I cannot help you with your question, but maybe it's worth looking at the AdminOnSteroids module. tpr does a lot of adjustments there - so it should be definitely possible to adopt the themes to your needs. Maybe you can elaborate your case more in detail and get better answers Link to comment Share on other sites More sharing options...
Federico Posted March 15, 2018 Author Share Posted March 15, 2018 Hi @bernhard, my use case is to find this type of hook for the main navigation and prepend or append something to it. In Reno Admin theme (but also in the default admin theme too) we could achieve this with the following code $wire->addHookAfter('AdminThemeRenoHelpers::topNavItems', function($event) { $out = $event->return; $out .= '<li><img src="path/image.png"></li>'; $event->return = $out; }); Whereas you cannot leverage a similar hook to the Uikit theme (the latter soon to be the default theme). Am I correct? 1 Link to comment Share on other sites More sharing options...
Macrura Posted March 15, 2018 Share Posted March 15, 2018 i have a request in also to add hook to UI Kit theme, especially for being able to manipulate css files; i was able to sort out my issue (FontAwesomePro module) using another way, but i do think it is important to add api hooks in key/strategic areas on the admin themes, for customization. https://github.com/processwire/processwire-requests/issues/120 4 Link to comment Share on other sites More sharing options...
Robin S Posted March 15, 2018 Share Posted March 15, 2018 In terms of adding markup to admin themes, the following hookable methods are common to all admin themes: AdminThemeFramework::getUserNavArray Allows you to add items to or remove items from the "user" dropdown menu (Edit Profile, etc). AdminTheme::getExtraMarkup Allows you to add markup to the following regions of the admin template: head notices body masthead content footer sidebar For example... $wire->addHookAfter('AdminTheme::getExtraMarkup', function(HookEvent $event) { $regions = $event->return; $regions['masthead'] .= '<p>hello</p>'; $event->return = $regions; }); So not every place in the admin theme markup is covered (I don't see how it could be), but it allows for simple additions to the admin theme. No doubt you would need some custom admin CSS to position and style whatever markup you add. Other approaches... Manipulate the rendered markup string For some cases this might do the job. For example... $wire->addHookAfter('Page::render', function(HookEvent $event) { $page = $event->object; if($page->template == 'admin') { $out = $event->return; $out = str_replace('<div class="uk-navbar-right">', '<div class="uk-navbar-right"><p>hello</p>', $out); $event->return = $out; } }); Copy your preferred admin theme module from /wire/modules/AdminTheme/ to /site/modules/ Make whatever changes you need to the copied files, perhaps by including a separate PHP file at the right place in the template markup. That will make it easier to update the admin theme module from the core version when you choose to. 3 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now