Pesquisas recentes
Sem pesquisas recentes

Trevor Smith
Entrou em 08 de fev. de 2022
·
Última atividade em 08 de fev. de 2022
Seguindo
0
Seguidores
0
Atividade total
3
Votos
1
Assinatura
1
VISÃO GERAL DA ATIVIDADE
MEDALHAS
ARTIGOS
PUBLICAÇÕES
COMENTÁRIOS NA COMUNIDADE
COMENTÁRIOS EM ARTIGOS
VISÃO GERAL DA ATIVIDADE
Atividade mais recente por Trevor Smith
Trevor Smith comentou,
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
Exibir comentário · Editado 08 de fev. de 2022 · Trevor Smith
0
Seguidores
0
Votos
0
Comentários