1

Possible Duplicate:
jQuery Pagination Plugin

I am trying to add a pagination of some kind on my website: www.metallica-gr.net and although I tried some of the jquery ones I had a hard time understanding how I would implement it on my site.

Here's how my site is built, and how articles are displayed. Is it possible to make pagination for this?

http://imageshack.us/a/img268/249/paginationq.jpg

Community
  • 1
  • 1
Tasos
  • 1,622
  • 4
  • 28
  • 47
  • yes this will do but you'll surely have a hard time if there are new files or folders – abc Oct 24 '12 at 08:38

1 Answers1

1

If you only have a bunch of static files then you would probably be better off just creating the links yourself. I think these types of things are more useful with dynamic websites. Something to this effect.

<html>
<head>
<script type="text/javascript">

var baseUrl="www.mysite.com?page=";

var forwardLinkId ="fwdLink";

var backwardLinkId = "bwdLink";

function SetForwardUrl(forwardLink)
{
  var page = gup(pageNumber)

  var fwd = document.getElementById(forwardLink);
  var fwd.href = baseUrl + (page.ToNumber() + 1);
}


function SetBackworddUrl(backwordLink)
{
   var page = gup(pageNumber)

  var bwd = document.getElementById(backwordLink);
  var bwd .href = baseUrl + (page.ToNumber() - 1);
}

function gup(name)
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

document.onload = function() { 
SetForwardUrl(fwdLink); 
SetBackwardUrl(bwdLink);
}

</script>
</head>
<body>
<a id="fwdLink" /> <a id="bwdLink" /> 
</body>
</html>
awright18
  • 2,255
  • 2
  • 23
  • 22
  • That was my intention, but what about the next/previous buttons? Wouldn't they be needed if pages were too many?(although I suppose that won't happen). – Tasos Oct 24 '12 at 08:38
  • Depends how you are rendering the pagination control. Are you going to create it each time on every page? Or Will they just be static links too? If they are static you will know where they go. – awright18 Oct 24 '12 at 08:40
  • get the value of the current page, you can pass it in url. then just increment or decrement by 1 when next/previous buttons were clicked – abc Oct 24 '12 at 08:41
  • Can you give me an example this sounds like it would work since I haven named the folders like so. – Tasos Oct 24 '12 at 08:46