Hi there ...
after heaving the great feature with Comments included via InsertNode, i tried the next step, to post back the user to the
page the forum-topic is attached too, because generally, replying some comment, would automaticly forward you to that forum thread.
Doing this by core-hacks isn't a nice solution so I came up with a combination of Cookies and JS code.
First of you need jquery_cookie.js.
next in my design theme I added a js file which is loaded on each page. This is for some JS hacks, and now also used for
that cookie stuff.
In there I got this code placed
/**
* Reply button for comments
* Store where the user has been when commenting, and bring him back there
* afterwards
*/
$("a[href*='comment/reply']").click(function () {
$.cookie('reply_topic_url', location.href);
});
$("a[href*='comment/edit']").click(function () {
$.cookie('reply_topic_url', location.href);
});
$("a[href*='comment/delete']").click(function () {
$.cookie('reply_topic_url', location.href);
});
/**
* Check on each forum site, if the cookie has been placed, if so, we now
* a forum thread has been created
*/
$("div[class='breadcrumb']").children().each(function(){
if($(this).attr("href") == '/drupal/?q=forum')
{
var loc = $.cookie('reply_topic_url');
if(loc != null || loc != undefined)
{
$.cookie('reply_topic_url', "");
document.location.href = loc + '#attached_comment_start';
}
}
});
This code simply does following:
1. If the user clicks on the reply/edit/delete button on an attached comment, the JS stores that action inside
a cookie.
2. Now after that process the process directs you to a page of the forum.
3. Every forum page is checked, if the cookie is set. If so you are beeing sent back to the location stored in it, and the cookie cleared. Otherwhise nothing happens.
Hope this helps someone out ...
Greetings
Zewa
Comments
Comment #1
AlexisWilke commentedZewa,
Interesting, but your code would not work for me. After several hours, I finally found out why. Your code is specific to forums.
I just could not see how testing the bread crumbs would work on any one site. Many people turn OFF that feature!
This being said, it gave me a great start and you now will get that functionality (if jQuery Plugins are installed that is.)
The module automatically adds the necessary scripts so you should remove them from your theme! The good thing is that way the scripts are added only if both modules are turned on (this module and the jQuery Plugins)
Thank you.
Alexis Wilke
Comment #2
zewa commentedHi ...
As I'm doing that for my company, it's always quite specific stuff.
So pardon me, if those ways how I accomplish things are kinda dirty, but
I always search for the fastest and quite realiable solution.
Thx for your solution ill give it a try ...
Greetings
Zewa
Comment #4
jesss commentedHow does this actually work? I've installed and enabled the -dev version of this module as well as the current release of jQuery plugins. I've cleared the cache, and re-saved the view where I've inserted the node into the footer.
However, when I make a comment, instead of being returned to the view where the node has been inserted, I am instead returned to the full node page.
Is there a setting somewhere that I need to turn on?
Comment #5
AlexisWilke commentedJesss,
It uses a cookie. If you have too many cookies or cookies are turned off then it would fail. But if you can log in a Drupal account, I would think you have a cookie.
Otherwise, you must make sure you have both: this module and jQuery enabled.
Thank you.
Alexis
Comment #6
jesss commentedCookies are turned on. I have InsertNode (6.x-1.x-dev), jQuery Update (6.x-1.1) and jQuery plugins (6.x-1.10) installed and enabled. But, it keeps returning me to the node instead of the view where the node is embedded.
Comment #7
AlexisWilke commentedOh! Yes. The comment area for a node is created in that node and thus the return path is for the node... I'm not sure how we could do that for the view. I guess we'd need to get the path in a more dynamic way or maybe I can just change the current code to use $_GET['q']... (or a safe equivalent.)
I'd have to have a closer look to make sure it's doable.
Thank you.
Alexis Wilke
Comment #8
jesss commentedGlad it's not just me doing something wrong!
If you make a patch, I'd be happy to help test it.
Comment #9
premanup commentedTake a look http://drupal.org/node/739060
Comment #10
AlexisWilke commentedpremanup,
I don't think that #739060: Coming back at the right place when adding/editing/deleting comments is directly in link with the problems with the view. I may be wrong though. Anyway, that other problem is fixed so maybe it will be time to try this issue again and see whether it was fixed.
Thank you.
Alexis