最近搜索
没有最近搜索

Trevor Smith
已加入2022年2月08日
·
最后活动2022年2月08日
关注
0
关注者
0
活动总数
3
投票
1
订阅
1
活动概览
标记
文章
帖子
社区评论
文章评论
活动概览
的最新活动 Trevor Smith
Trevor Smith 进行了评论,
Ashleigh,
Thank you so much for this great workaround! I've been looking for a solution to the 30 article limit for some time.
Bruce - are you able to share your complete example? I am also on V1, I was able to get the articles on the second page to show, along with removing the pagination - however, every time it executes, it seems to be overwriting the current article list on the first page. In place of the first-page list, I'm getting '[object HTMLLIElement] ' displayed on the page.
I could technically assign the 'new' list to a different div, but I'd rather append the original div to create one entire list so I can filter through it.
**EDIT - I figured it out - had to change "+=" to just + in this:
the_list = next_page.response.getElementsByClassName("section-tree")[0].innerHTML;
and had to change "=" to "+=" in this:
// Write the new list to the current page.
document.getElementsByClassName("section-tree")[0].innerHTML += the_list;
Here is the full script that now works for me on V1...
// Zendesk Guide section pages without pagination (v2).
// author: Ashleigh Rentz, koresoftware.com
// license: https://mit-license.org/
window.onload = function() {
unpaginatedSections();
};
function unpaginatedSections() {
debugger;
// Only execute this if we're on a paginated section page.
if (document.getElementsByClassName("pagination")[0] == null) return;
// Start with the articles listed on the first page
var the_list = document.getElementsByClassName("pagination-next")[0];
var next_url = the_list.getElementsByTagName("a")[0].getAttribute('href');
// Request the next page
var next_page = new XMLHttpRequest();
next_page.open("GET", next_url);
next_page.responseType = 'document';
next_page.send();
next_page.onload = function() {
// If something went wrong, leave pagination in place.
if (next_page.status !== 200) return;
// Add the articles from this page of results to our list.
the_list = next_page.response.getElementsByClassName("section-tree")[0].innerHTML;
// Check for another page.
try {
var nextlink = next_page.response.getElementsByClassName("pagination-next")[0];
next_url = nextlink.getElementsByTagName("a")[0].getAttribute('href');
}
catch (e) {
// No more pages.
is_finished = true;
}
finally {
if (is_finished) {
// Write the new list to the current page.
document.getElementsByClassName("section-tree")[0].innerHTML += the_list;
// Add a class to allow styling via CSS.
// Remove the pagination controls.
document.getElementsByClassName("pagination")[0].innerHTML = '';
};
};
};
};
Best,
Trevor
查看评论 · 已于 2022年2月08日 编辑 · Trevor Smith
0
关注者
0
投票
0
评论