Download & Extend

Remove navigation to answer node

Project:Answers
Version:7.x-3.x-dev
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:fixed

Issue Summary

I've used Answers to create a straightforward Q&A system. There's one little thing that's got me stuck. The answers list generated by the "Answers to a Question" View includes links (via the titles) to specific pages for each answer.

I'd like to remove the < a > tags, so there are no links, but cannot work out how to do this (I've tried modifying the Answer content type and the "Answers to a Question" View but no luck so far).

Any help would be very much appreciated.

Comments

#1

Thanks for this request. This is a great idea. There's no point in having that link and it can be confusing.

Unfortunately, I am not sure of the simplest way to do this. I have posted a question to ask for help.

One way I believe would work would be to rebuild the "Answers to a Question" view using the "Field" row type instead of the "Node" row type. But let's see what suggestions come in.

Once this is settled, I'd like to port this back into the module. Thanks again for raising the idea.

#2

Title:Hyperlinks to answers» Remove navigation to answer node
Status:active» needs review

Patch:

  • Adds onto hook_node_view to do a drupal_goto if you happen to land on node/nid view of an answer (to quesiton node)
  • Adds node--answer.tpl.php (using hook_theme to register the template) to render the node without the title.

Note that this patch is specific to drupal 7; the way to add overriding templates in modules in d6 is different.

AttachmentSize
1371588_answer_remove_navigation_to_answer.patch 5.86 KB

#3

Status:needs review» needs work

Meh, this is a single use case and should be a sub module or such.

#4

I think this is a great idea and should get integrated into the module.

I tried it out and had two questions.

Question 1: I found that the "submitted" text was formatted differently when I used this patch.

Question 2: I found that user pictures on the "submitted" line were omitted.

Both of these may have to do with the base them I am using, which is Bartik.

To have it rendered the same, I needed to use the same code in node-answers.tpl.php for the "submitted" line as used in the Bartik node.tpl.php:

  <?php if ($display_submitted): ?>
    <div class="meta submitted">
      <?php print $user_picture; ?>
      <?php print $submitted; ?>
    </div>
  <?php endif; ?>

This code adds the "meta" class and $user_picture. I'm not experienced in theming. Were these choices intentional?

#5

As both an upgrade path and to support different use caseS (for example, displaying comments on answer, may want answer node page to be useful), it'd prob be best to add a simple configuration.

Hm, I'd need to look into it more, but I believe I just copied the base node.tpl.php and removed the title line. May have copied the wrong one.

#6

So, it looks like you started with the Garland node.tpl.php. And I started with the Bartik node.tpl.php. And the two are a bit different.

On configuration, my thought is that the node-answer.tpl.php is simple enough to edit. So, that's a way to provide great flexibility for those who are comfortable themers.

My thought is that we should simply pick as the base whichever one is most popular. How's that sound? (And if it sounds reasonable, any thoughts on how we could figure that out?)

#7

Bah, I wish node templates had a way to disable title without overriding.

Currently the title is there, so I'd lean to defaulting to that (not sure how to figure out which one is more popular)

#8

Status:needs work» reviewed & tested by the community

OK, sounds good, let's keep what you've already done.

#9

Status:reviewed & tested by the community» needs work

If anyone is currently using the fact it links, this would screw with that, so it does need configuration at least as an upgrade path. Working on that + cleaning up some documentation.

#10

Status:needs work» needs review

Updated patch, trying to add more documentation + adding a setting. I'm so not good at describing settings though.

#11

Version:7.x-3.0» 7.x-3.x-dev

Oh, the patch, I could add it.

AttachmentSize
1371588_answer_remove_navigation_to_answer_9.patch 4.74 KB

#12

Patched tested and validated.

At the same time, I have a thought about how to describe it:

  1. I am starting work on some fairly major retheming of how a question page looks. I am pretty sure that this work will mean that node--answer.tpl.php will get a bunch of additional changes beyond the current one of removing the link on the answer title.
  2. As we add finesse to how answers show up on a question page, what I don't anticipate doing is adding much complexity by offering admins lots of settings to turn features on or off. Rather, I anticipate letting admins do that by creating their own versions of node-answer.tpl.php (and eventually node--question.tpl.php)
  3. I think our major reason to add this current admin setting is so that we do not strand anybody who has implemented answers already and depends on the default template (including the link). I'm not entirely convinced this will be a big need, but I see the motivation

Given all that, here's my thought. How about we describe the setting not so much in terms of the specific feature ("Navigation to answer page") but rather in terms of the general use of the templates (e.g., "Use Answers templates for question and answer nodes" --> "This will ignore the base theme node template and use custom templates. Currently the main difference is that the titles in answer node listings are not linked to their node pages").

We might also make it default to use the custom templates, since I think that will be better for the vast majority of users.

As far as documentation, what I imagine would be helpful would be a little description about how one can customize the look of answers and questions by editing your own templates. We could write that later.

Whaddya think?

#13

Sounds good to me; do you want to update the patch with it?

Since the current behavior is to allow navigation, should likely add an answers_update_x that variable_set's that option (and change the default value).

#14

OK. Done in the attached patch. I also added answers_update_7300. Don't need to set the variable (it has the right default option). But do need to reset the theme cache.

AttachmentSize
1371588-answer-remove-navigation-to-answer-14.patch 7.48 KB

#15

Version:7.x-3.x-dev» 7.x-1.0
Status:needs review» patch (to be ported)

#16

Version:7.x-1.0» 6.x-2.x-dev

I've now ported the patch.

In doing so, I made some changes. The patch had two functions.

Provide an answers node template the removes the link to the answers node

I made these changes:

  1. I insisted on using the answers node template. This is no longer a choice governed by a setting. My thinking is that if a developer wants to override the template, that is simple enough to do.
  2. I used hook_theme_registry_alter to register the template

Redirect users who go to a path that leads to an answer node to the answer's question page, scrolling to the answer itself

I retained a setting for this. I renamed it to 'answers_redirect_from_answer_to_question_nodes_p'.

Patch attached and committed to 6.x-2.x.

AttachmentSize
0001-1371588-by-hefox-chipcleary-Remove-navigation-to-ans.patch 5.71 KB

#17

Version:6.x-2.x-dev» 7.x-3.x-dev

Whoops ... meant to mark this to port *back* to 7.x-3.x

#18

Status:patch (to be ported)» fixed

Ported to 7.x-3.x-dev

nobody click here