Skip to content

Commit ffe114b

Browse files
authored
Custom404 page (#2348)
* Add custom 404 HTML page structure * Add custom 404 page suggestion script This script retrieves the first three characters of the page_id from the URL and suggests valid related pages based on that. * Create css.js * Add README for custom 404 widget Added usage instructions and use case for custom 404 widget.
1 parent 6ad8423 commit ffe114b

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div>
2+
<h1 class="heading-message">${This page could not be found. Based on your search we have found below valid pages}</h1>
3+
<div class="page-container"> <!-- Container to show valid pages.-->
4+
<ul>
5+
<li ng-repeat="item in data.pageArr"> <!-- List to show valid pages.-->
6+
<a href = {{item.url}} target="_blank">{{item.name}}</a>
7+
</li>
8+
</ul>
9+
</div>
10+
</div>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
**How to use**
2+
1. Add this widget to new portal page.
3+
2. Add the page in "sp_portal" record in 404 field.
4+
5+
**Use Case**
6+
1. Some organizations do not want to show OOB 404 page having game but want to show the suggestions with correct pages.
7+
8+
**Result**
9+
1. This code will search the 3 letters of page_id from URL and will suggest correct pages.
10+
2. The correct links will open the pages in next tab.
11+
12+
<img width="959" height="413" alt="404" src="https://github.com/user-attachments/assets/2480ba26-4ea3-4e12-baf8-bbf89fec548a" />
13+
14+
15+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.heading-message{
2+
color:red;
3+
}
4+
.page-container{
5+
display: flex;
6+
justify-content: space-evenly;
7+
flex-direction:cloumn;
8+
}
9+
ul{
10+
padding: 2rem;
11+
list-style-type: disclosure-closed;
12+
}
13+
li{
14+
padding:1rem;
15+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(function() {
2+
/*
3+
This script will get the 3 characters of page_id from url and suggest valid pages.
4+
*/
5+
data.pageArr = []; // array to store related pages
6+
var pageId = $sp.getParameter('id').toString(); // get page id from url
7+
// get 3 letters of page id
8+
if (pageId && pageId.length() > 3)
9+
pageId = pageId.substring(0, 3);
10+
11+
var relatedPages = new GlideRecord('sp_page');
12+
relatedPages.addEncodedQuery('idLIKE' + pageId);
13+
relatedPages.query();
14+
while (relatedPages.next()) {
15+
var tempList = {}; // temporary object.
16+
tempList.name = relatedPages.getValue('title');
17+
tempList.url = '/' + $sp.getValue('url_suffix') + '?id=' + relatedPages.getValue('id');
18+
data.pageArr.push(tempList); // add related suggested pages to array
19+
}
20+
})();

0 commit comments

Comments
 (0)