Created
June 1, 2022 07:59
-
-
Save xlawok/0820256bc8fbe1ca7cb31e5760faa6ae to your computer and use it in GitHub Desktop.
Presta - pagination loaded with ajax - add page number to title and h1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
{literal} | |
window.setTimeout(function(){ | |
// on click refresh variables | |
if (document.documentElement.lang == "pl"&&(window.location.hostname).includes("amberdream")){ | |
var awgetpageno = (new URLSearchParams(window.location.search.slice(1))).get('page'); | |
var content = " - strona "+awgetpageno; | |
var theh1=document.querySelector('#category .box-breadcrumb h1.category-name'); | |
var thetitle=document.title; | |
// replace old " - strona XX" string with new | |
var category_a= (theh1.innerHTML).split(' - strona '); | |
category_a[1]=" - strona " + awgetpageno; | |
var title_a= thetitle.split(' - strona '); | |
title_a[1]=" - strona " + awgetpageno; | |
if(typeof awgetpageno!="undefined"&&awgetpageno!=="1"&&awgetpageno!==null){ | |
theh1.innerHTML =category_a.join(''); | |
document.title = title_a.join(''); | |
// console.log(category_a.join('')); | |
} | |
else{ | |
theh1.innerHTML =category_a[0]; | |
// console.log(category_a[0]); | |
document.title = title_a[0]; | |
} | |
// console.log(awgetpageno); | |
} | |
}, 1000); | |
{/literal} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment