Keyword

k2 comment form outside of <div id="maincontent">

  • Matt
  • Matt's Avatar Topic Author
  • Offline
  • Senior Member
More
12 years 9 months ago - 12 years 9 months ago #60955 by Matt
Hello, I want to know how I can put k2 comment form <div class="itemComments"> outside of <div id="maincontent">. I want the native comment system in a separate div container beneth the maincontent div.

Currently my comment forms location is basically this:
<div id="maincontent">
    <div id="k2Container">
        <div class="itemComments">
        </div>
   </div>
</div>

But I want it to be this:
<div id="maincontent">
    <div id="k2Container">
    </div>
</div>
<div class="itemComments">
</div>

How can I accomplish this? Thanks for any help.

Please Log in or Create an account to join the conversation.

  • Matt
  • Matt's Avatar Topic Author
  • Offline
  • Senior Member
More
12 years 9 months ago #60956 by Matt
Sorry I have to push this thread due to the massive amount of spam.

Please Log in or Create an account to join the conversation.

  • Andrey Miasoedov
  • Andrey Miasoedov's Avatar
  • Offline
  • Senior Member
More
12 years 9 months ago - 12 years 9 months ago #60957 by Andrey Miasoedov
Replied by Andrey Miasoedov on topic Re: k2 comment form outside of <div id="maincontent">
Hello, Matt.

There are no standart ways to do something like this. But you can use jQuery. Sample code:
var comments = jQuery("itemComments").html();
jQuery("div.newComments").html("<div class='itemComments'>" + comments + "</div>");

Please Log in or Create an account to join the conversation.

  • Matt
  • Matt's Avatar Topic Author
  • Offline
  • Senior Member
More
12 years 9 months ago #60958 by Matt

Andrey Miasoedov wrote: Hello, Matt.

There are no standart ways to do something like this. But you can use jQuery. Sample code:
var comments = jQuery("itemComments").html();
jQuery("div.newComments").html("<div class='itemComments'>" + comments + "</div>");


Thank you for the reply :) I'm afraid my knowledge about jQuery is limited. I understand that k2 uses the jQuery library, but I do not know how to implement jQuery code in the k2 layout. Trial and error didn't help :( Where should I put your sample code? In the item.php file (that didn't work)?

Best regards
Matt

Please Log in or Create an account to join the conversation.

  • Andrey Miasoedov
  • Andrey Miasoedov's Avatar
  • Offline
  • Senior Member
More
12 years 9 months ago - 12 years 9 months ago #60959 by Andrey Miasoedov
Replied by Andrey Miasoedov on topic Re: k2 comment form outside of <div id="maincontent">
Add this code in your template's index.php
templates/your_template/index.php in <head> section
replace "newItemComments" with your container class

<script>

jQuery.noConflict();

jQuery(window).load(function() {

var comments = jQuery("div.itemComments").html();
jQuery("div.itemComments").html("");
jQuery("div.newItemComments").html("<div class='itemComments'>" + comments + "</div>");
alert("OK");

});

</script>

Please Log in or Create an account to join the conversation.

  • Matt
  • Matt's Avatar Topic Author
  • Offline
  • Senior Member
More
12 years 9 months ago #60960 by Matt
Hello, I did that, but it only disabled everything inside <div class="itemComments"> :(

Please Log in or Create an account to join the conversation.

  • Andrey Miasoedov
  • Andrey Miasoedov's Avatar
  • Offline
  • Senior Member
More
12 years 8 months ago #60961 by Andrey Miasoedov
Replied by Andrey Miasoedov on topic Re: k2 comment form outside of <div id="maincontent">
Do you replace this line with your right?
jQuery("div.newItemComments").html("<div class='itemComments'>" + comments + "</div>");

Please Log in or Create an account to join the conversation.

  • Matt
  • Matt's Avatar Topic Author
  • Offline
  • Senior Member
More
12 years 8 months ago #60962 by Matt
I'm sorry I don't understand what you mean. What do you mean by replacing with my right? My right what?

I was under the impression that your code removes the <div class='itemComments'> from the maincontent div and puts its outside as new <div class='newitemComments'>,but it didn't do anything. For some reason after I tried it today the script appeared in plain text with an empty container on the top of the page above the header and the normal comment form was still there. Thank you again for your kind help.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum