Here is some JS codes I use in the custom HTML.
Maybe it can help you. If you think my code can be improve, let me know here
If you have ideas to share, tell me too.
If my English is poor, just let me know too
- You can add this JS in Configuration, Custom HTML, Add code before tag </body>. You need to add code in a tag script "<script>CODE HERE</script>"
- Remember JS can be access with source of the page, so don't use confidential or privacy datas
- If just one record on the listing (it works with table listing), redirect to it
Code: Select all
if (window.location.href.endsWith("/index.php?module=items/items&path=12")) { //if the url ends with; 12 is the entity ID
var intervalCheck = setInterval(function() { //check but with a delay to make sure all records are loaded
var numberRecord = $(".listing-table-tr").length;
if (numberRecord === 2) {
clearInterval(intervalCheck);
window.location.href = $(".item_heading_link").attr("href");
}
}, 500); //500 milliseconds
}
- To hide entity you don't want to show (like an entity you already have in a report, like Kanban) (with my tests it doesn't work with custom CSS) (edited on 2024-01-03)
Code: Select all
$('ul.sub-menu a.menu-itemsitems12').hide(); //12 is the entity ID and IF in a sub-menu, IF not delete "ul.sub-menu" part
(where 12 is the ID)
- To hide filter panel of all Kanbans
Code: Select all
$('.kanban-div').prev().hide();
- To redirect the page of an entity you already have in a report, like Kanban
Code: Select all
if (window.location.href.endsWith("/index.php?module=items/items&path=12")) { //if the page is the entity ID 12
window.location.href = "/index.php?module=ext/kanban/view&id=1"; //redirect to Kanban ID 1
}
I hope it can help you