Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I added a new view (block) with FIELDS type. I added "Content: Comment count" to see the comments number, and in "Rewrite results" I clicked to "Output this field as a link", and added the token "[comment_count] == Content: Comment count" as link.
This link doesn't work.

When I add a different token, such as "[body] == Content: Body" or "[title] == Content: Title," the links still don't work.

Am I doing anything wrong?

share|improve this question
    
To what do you want to link? First, only [body] is the token and what you should use. But you probably actually need the nid/cid token, depending what you want to link to. –  Berdir Jun 5 '11 at 14:39
    
Hi. I actually make it to work. I have used "Exclude from display" and somehow manage it to work like I wanted to. I still need to add some field x2 but it seems to work just fine. –  bart Jun 5 '11 at 18:23
    
Please create an answer, explain in detail what you did and accept it as an answer for this question once you can (you have to wait 24h I think). Then, the question is correctly marked as resolved and if someone else lands here with the same problem, they know how to fix it. We are trying to build a database of good questions and answers here :) Additionally, someone might give you a hint on how to solve it easier. –  Berdir Jun 5 '11 at 20:40
    
No problem - if u can't add token just create field the token link to and make it "Exclude from display". Then u can make use of the token it self. So if u want use token [comment_count] u need first to crate a Comment Count, and if u don't need it (don't want the text and count) just make it "Exclude from display". The rest depend of what you want to achieve. Remember that u can create some field x2 or even x3. For example u can make one link that make link from all body content and second one that make a link from comment count (first u need to create body and comment field). –  bart Jun 5 '11 at 22:20
1  
@bart: You need to do that as an answer, not a comment :) There should be a blue button at the end of the page, allowing you to answer your own question. Also, I still don't really get what kind of link you are creating, it does not make any sense to me to use comment_count and similar tokens in a link. So, provide your actual and exact configuration as an example, if possible. You could even provide screenshots of your configuration, that would be awesome :) –  Berdir Jun 5 '11 at 23:19
show 2 more comments

1 Answer

I wanted to do the same thing. I had a view of blog posts and at the bottom of the post I wanted to put a link that had a comment count that was a hyperlink (as I've seen this done on many other blogs). The way I did it was like this:

Originally my view was set up to just display the full nodes. I clicked to edit the view and went to Page Details->FORMAT->Show and changed the setting from "Content" to "Fields".

Added the following fields:

Content: Title
Content: Body
Content: Path
Content: Comment count

The key and answer to this post is: Even though I don't want to display the path on my view I need to add it as a field so that I can later use it when building the link for the comment count. Also I believe the order of the paths is important, so the path field must come before the comment count field. For the Content: Path field I checked the "Exclude from display" check box. This hides the path from showing up in the view. Next under "REWRITE RESULTS", I checked "Use absolute link (begins with "http://")". This is necessary for a proper URL when using the path as token below.

For the Content: Comment count field, under "REWRITE RESULTS" I checked "Output this field as a link" and in the "Link path" box I put [path].

share|improve this answer
    
The order of the fields in your list is important as User says: If you try to user [comment_count] as a token in title, body, or path in the above list of Fields, it will not work. You need to make sure that the field you want to use as a token is BEFORE the field you want to use the token in. –  Mike May 27 '12 at 15:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.