It would be nice to be able to choose a Page Layout of "Clicking on question opens/hides answer under question" and have the FAQ module give each question an anchor link as it does when "Clicking on question takes user to answer further down the page" is chosen. This would allow FAQ items to be directly linked to. The current faq.js already is already setup to detect the URL fragment and expand the referenced answer.
We've modified includes/faq.hide_answer.inc to support this, however the anchors generated are just "n" followed by the FAQ node's NID. This could possibly be adjusted to use the same anchor naming system which is used elsewhere - for my purposes NIDs were unique enough.
Please consider the attached patch which implements this feature.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | anchor-everywhere-1023468-1.patch | 1.49 KB | jcisio |
| faq.patch | 528 bytes | msielski |
Comments
Comment #1
jcisio commented+1 for this feature. Tested without any problem.
I also add more thing into faq.js so that the URL fragment changes when an answer is open. It makes an answer bookmarkable. Tested with IE 8/Fx 3.5/Safari 5 (Windows) and Fx 4/Chrome 11 (Linux).
Comment #2
jcisio commentedComment #3
stella commentedYour patch wasn't quite extensive enough - only dealt with one possible layout and none of the categorized layouts. Though it looks like the anchors were already added to the dev version as part of #829368: Link directly to faq questions on the faq page when linking to question nodes is disabled in any case.
However the js change wasn't present and is quite useful, so have added that to the D6 and D7 branches, thanks!
Thanks for the patches!
Comment #4
jcisio commentedI saw that #829368: Link directly to faq questions on the faq page when linking to question nodes is disabled is marked "won't fix" and there is nothing else since Nov 2010. I was quite surprise because my patch in May was against the latest git. In fact there is a commit http://drupalcode.org/project/faq.git/commit/fe0753dacc53a8d79d83f94b3af... for that issue.
Anyway, it's great that this issue is fixed ;)
Comment #5
stella commentedYep, that commit was for categorized layouts, which neither issue actually provided a patch for :(