backdrop-contrib / icon_browser

An interface to browse the fonts that are available on a Backdrop site.
GNU General Public License v2.0
2 stars 3 forks source link

Module Configuration Page is empty #1

Closed stpaultim closed 6 months ago

stpaultim commented 6 months ago

Atten @laryn

I installed and enabled the module on a fresh local site using the latest dev version of Backdrop CMS. Which I click on the link to go to the configuration page, it's blank/empty.

Debug Report ``` Backdrop CMS: 1.28.x-dev Installation profile: standard PHP version: 8.2.18 Drupal 7 compatibility: on Database server: 10.11.7-MariaDB-1:10.11.7+maria~ubu2204-log Web server: nginx/1.24.0 jQuery version: 3.7.1 jQuery UI version: 1.13.2 CKEditor 5 version: 40.2.0 Used in formats: Basic Themes ====== Default theme: Basis (basis) 1.28.x-dev Admin theme: Seven* (seven) 1.28.x-dev *used when editing or creating content Enabled modules =============== Core ---- admin_bar 1.28.x-dev block 1.28.x-dev ckeditor5 1.28.x-dev color 1.28.x-dev comment 1.28.x-dev config 1.28.x-dev contextual 1.28.x-dev dashboard 1.28.x-dev date 1.28.x-dev dblog 1.28.x-dev email 1.28.x-dev entity 1.28.x-dev field 1.28.x-dev field_sql_storage 1.28.x-dev field_ui 1.28.x-dev file 1.28.x-dev filter 1.28.x-dev image 1.28.x-dev installer 1.28.x-dev layout 1.28.x-dev link 1.28.x-dev list 1.28.x-dev menu 1.28.x-dev node 1.28.x-dev number 1.28.x-dev options 1.28.x-dev path 1.28.x-dev redirect 1.28.x-dev search 1.28.x-dev system 1.28.x-dev taxonomy 1.28.x-dev telemetry 1.28.x-dev text 1.28.x-dev update 1.28.x-dev user 1.28.x-dev views 1.28.x-dev views_ui 1.28.x-dev Other ----- icon_browser prerelease-dev icon_browser prerelease-dev ```

image

Why is this a theme_hook error? This is a module, not a theme.

jenlampton commented 6 months ago

@stpaultim theme_hooks are what you use to register all theme functions (most commonly defined by modules). Themes can override them, but the "theme" markup usually starts from modules :)

In this case there is probably code calling theme('icon_browser_page') - maybe even from a renderable using #theme - but if icon_browser_page hasn't been defined yet in a hook_theme() implementation, backdrop doesn't know how to connect that to the function theme_icon_browser_page().

Found it the use here:

$output = array(
    '#theme' => 'icon_browser_page',
    '#icons' => $icons,
    '#attached' => array(
      'css' => array(
        backdrop_get_path('module', 'icon_browser') . '/css/icon_browser.css',
      ),
    ),
  );

But no https://docs.backdropcms.org/api/backdrop/core%21modules%21system%21system.api.php/function/hook_theme/1 in the .module file (yet!).

stpaultim commented 6 months ago

@jenlampton Thanks for reply. This function is in the icon_browser_theme file. Does it need to be in the .module file?

/**
 * Implements hook_theme().
 */
function icon_browser_theme() {
  return array(
    'icon_browser_page' => array(
      'variables' => array(
        'icons' => array(),
      ),
    ),
  );
}

I have to say, I suspect that this just isn't finished yet. Maybe @laryn pushed the wrong code or didn't push it all.

stpaultim commented 6 months ago

Ohh, that was it. When I moved that function to the .module file, it suddenly works! Thanks @jenlampton

stpaultim commented 6 months ago

I submitted a PR based upon my fork of the module that get's the browser working. It may not be the correct fix and there are still errors being generated, but it at least allows one to test the progress of the module.

I simply moved the hook_theme function into the .module file (at least for now).

https://github.com/stpaultim/icon_browser

stpaultim commented 6 months ago

In Zulip, @laryn suggested clearing the caches. I tried that and after clearing the cache, the configuration page works without my PR.

laryn commented 6 months ago

Thanks @stpaultim and @jenlampton -- yes, the cache clear was a temporary fix. I hadn't had time to track down what was going on there but the fact that I accidentally put the hook_theme implementation in the .admin file instead of the main .module explains it. Thanks!