Page 1 of 1
Custom pages menu ordering
Posted: Friday 26 April 2024 12:35
by lost
Hello,
This question was asked quite long ago with no answer at the time:
https://www.domoticz.com/forum/viewtopic.php?t=16517
As I now have several pages, would like to enforce some ordering: And really can't find a logic for the menu buildup as that's not alphabetical, nor page html creation date or anything I could guess!
Using browser/inspect only allows to see created links in the order they appear.
That's minor issue, but if someone have a trick you're welcome!

Re: Custom pages menu ordering
Posted: Friday 26 April 2024 13:37
by habahabahaba
Just tested it.
Its in alphabetic order.

- 2024-04-26_14-35-18.png (16.94 KiB) Viewed 1961 times
Re: Custom pages menu ordering
Posted: Friday 26 April 2024 14:51
by lost
habahabahaba wrote: ↑Friday 26 April 2024 13:37
Just tested it.
Its in alphabetic order.
Thanks for testing, but on my side (+v2024.4/Stable) this is not the case:

- custom.jpg (9.37 KiB) Viewed 1954 times
EDIT: You're observation anyway rings a bell.
First 4 menu items links to some auto-gen'ed pages (from python services of my own that starts after Domoticz as they need it's HTTP/JSON API being up & check for this/delay startup: This may make a difference, but, in my case should IMO not be the case, see hereafter).
Last 3 are html files that never change + Zigbee4Domoticz, so a python plugin Domoticz is aware off.
What's a bit strange to me is all my auto-generated pages are in a templates/myCustomPages directory and under templates there is a fixed html indirection/loading file that does a dated-loading of auto-gen'ed ones to lure domoticz cache management (global: No care for in-page cache management directives & not even allow manual page refresh even with an in-page button).
For instance templates/LastCapturesT.html -> templates/myCustomPages/LastCaptures.html
more LastCapturesT.html
Code: Select all
<div id="dynPage"><div>
<script type="text/javascript">
$(document).ready(function(){
loadUniquePage();});
function loadUniquePage(){
$('#dynPage').load('templates/myCustomPages/LastCaptures.html?t='+Date.now());}
</script>
So I may understand custom html's present at domoticz start (or aware off, like plugins that declare a custom page) may allow alphabetical order but maybe not for what's added after... But in my setup there is the link/dated-loading-trick file always there??!!!
Re: Custom pages menu ordering
Posted: Friday 26 April 2024 16:13
by lost
Currently, if the linked page cannot be loaded (because the service that autogen the page was not started before Domoticz) there was no error handling.
=> I added a error handler building an html line with the error code...
The cache-trick indirection to cope with domoticz web server behavior, in templates, then becomes:
Code: Select all
<div id="dynPage"><div>
<div id="loadError"></div>
<script type="text/javascript">
$(document).ready(function(){
loadUniquePage();});
function loadUniquePage(){
$('#dynPage').load('templates/myCustomPages/phoneFilterLog.html?t='+Date.now(), function(response, status, xhr) {
if ( status == "error" ) {
var msg = "Load Error: ";
$("#loadError").html(msg + xhr.status + " " + xhr.statusText);
}
});}
</script>
I'll see if next time I restart Domoticz (not so often, but I plan a full backup when I'll have some time, maybe this WE) this gets ordered: Maybe the custom menu generation process goes over html file presence check in templates & load is always done so if an error is seen, no menu item added at startup and they then get added as they later load without error?
Re: Custom pages menu ordering
Posted: Friday 26 April 2024 18:02
by waltervl
I think you are on or over the edge of what the the webserver of Domoticz custom pages is designed for (hosting html files).
And it seems you are the only one which could figure out another trick to get the menu ordered the way you want

Re: Custom pages menu ordering
Posted: Friday 26 April 2024 18:27
by lost
waltervl wrote: ↑Friday 26 April 2024 18:02
I think you are on or over the edge of what the the webserver of Domoticz custom pages is designed for (hosting html files).
And it seems you are the only one which could figure out another trick to get the menu ordered the way you want
Yes, must agree I may push this farther than designers expected but that's really simple things & setup another side-server for these basic needs would be really cumbersome IMO... But I did not expect to have custom pages additions done dynamically, but differently if available before or after domoticz startup!
Plugins build much more complex (and nice) pages, believe me!
Re: Custom pages menu ordering
Posted: Friday 26 April 2024 23:19
by waltervl
If you mean python plugins they are instructed to copy their custom html file to the custom templates directory. So they are not hosted from within the plugin.
https://www.domoticz.com/wiki/Developin ... hin_plugin
Re: Custom pages menu ordering
Posted: Saturday 27 April 2024 16:59
by lost
waltervl wrote: ↑Friday 26 April 2024 23:19
If you mean python plugins they are instructed to copy their custom html file to the custom templates directory. So they are not hosted from within the plugin.
That's not so different from what I'm doing out of plugin infrastructure. Looking at the only plugin I use (Z4D), for this one that's just a link to the page managed by the plugin localhost/IP:PORT for instance.
Tried to restart, but ordering unchanged... In fact, looks anything that was present in my last year full reinstall was ordered alphabetically at this time/once, then anything added since then got ordered by time of addition: Z4D was for instance last addition in early February (starting with my 1st zigbee devices), but looks ordering had nothing to do with ZiStick starting by "Z" in hereupper capture: I did a test one of my page name between another domoticz service stop and start, this one is now last position in menu starting by letter "C".
That's no big issue, but I can't see any way of enforcing an order there on an existing setup.