0

I've a Joomla website with K2 items and pagination.

I show the pagination on the bottom of page, and this will generate links to previous and next article on the bottom of the page (and it assign each link a specified css class).

I would ask if is there a (maybe php?) code to show these links also on the right bar of the website (so using a module, cause I've a plugin to insert php or javascript inside modules).

How can I copy that links showed on the bottom of page, into another place of the website?

rene
  • 41,474
  • 78
  • 114
  • 152
MagenNew
  • 21
  • 4
  • I removed the [thank you](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts) from your post. I also tried to improve your title. You may want to revisit [ask] if you wonder why I did that. – rene Mar 06 '15 at 08:53

1 Answers1

0

You can get the href of the specific a tag using jquery's Attr.

A demo is shown below:

var x = $('.prev').attr("href");
$('nav div:first-child').text("Prev = " + x);
var y = $('.next').attr("href");
$('nav div:last-child').text("Next = " + y);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav>
  <div>Prev:</div>
  <div>Next:</div>
</nav>

<a href="www.facebook.com" class="prev">link prev</a>
<a href="www.google.com" class="next">link next</a>
jbutler483
  • 24,074
  • 9
  • 92
  • 145
  • Hi, thankyou for your answer. Could you suggest me how to put this code? So, should i insert the script in an external file? or maybe inside the – MagenNew Mar 07 '15 at 14:21
  • you could do either - for this situation, I would suggest to place it in an external js file and include the reference in your head declaration if used multiple times throughout your project.. – jbutler483 Mar 07 '15 at 14:25
  • Hi, thankyou. I will use this only in the page where i will have that module, so maybe i could insert it also in that module? And if yes, how can i insert this? I only know that i can insert javascript on module inside the {source} tag (this is the way the plugin works). Or better, this show only the 2 links and the "Prev" and "Next" text. But trying to insert the code in that way, nothing appens... – MagenNew Mar 13 '15 at 11:37
  • @MagenNew: I'm using (here) by selecting on the 'class name'. I can't tell, but how are you differentiating what the 'next' and 'prev' links are? (in my example, I have a class name called 'next' and 'prev', which is only appearing on the two links) – jbutler483 Mar 13 '15 at 11:40
  • Thankyou for your fast reply: i'm only thesting if works your code with your same div class. I copyed and pasted the code into my joomla module. But maybe the script doesn't work. – MagenNew Mar 13 '15 at 12:08
  • should be fine as long as your 'prev' and 'next' classes are unique on each page (i.e. you don't reuse them on the exact same page). They would also need to be placed in the a tag with href's on them – jbutler483 Mar 13 '15 at 12:21
  • Tried this too...but nothing change.. :( – MagenNew Mar 13 '15 at 13:38