Hi everyone,

Can anyone help on how to rewrite the output from a field in views to replicate the teaser view inline links? I am using the Content: Comment count as a field and have it currently output as a link using the following:

node/[nid]/#comments

This gives me something like: mysite/node/200/#comments <-- pathauto doesn't correct this for some reason - maybe I need a new replacement in pathauto settings for blog posts? I use the pattern 'blog/[node:title]' for all blog posts.

However, in the teaser view you get a much nicer url like: blog/my-blog-post#comments

And also the links are inline on the teaser with a ul class so the list can be easily styled. My current output is:

<span><a href="/blog/my-second-blog-post">Read more</a></span>
<span><a href="/node/200/#comments">3 comments</a></span>
<span><a href="/comment/reply/200#comment-form">Add new comment</a></span>

Which is pretty impossible to style. They need to be in a list, preferably with the classes node-links and inline-links like on teaser display.

Huge thanks if anyone can help!

Comments

peterjlord’s picture

Can't you add the path to the fields Content: Path (Path): put it at the top and exclude it from being displayed and then put in [path] in the rewrite.

samwillc’s picture

Thanks, that sounds like a solution, will try later when I get in.

I still need help in outputting my 3 links as a list though, have been googling 'lists inside views', 'inline links in views fields', 'recreating teaser view with fields' etc but no luck so far.

PraMdrupalexpert’s picture

Hello,

This module will helpful for you, http://drupal.org/project/globalredirect
As it redirect your comment path URL to same as your pathauto module..

samwillc’s picture

Ok, so I am trying to rewrite the output of a 'read more' link to test the theories. So far I have a list like so after rewriting the results which is nearer but still a bit off the mark:

<a href="/about"><nav class="node-links"><ul><li>Read more</li></ul></nav></a>

I ideally wanted:

<nav class="node-links"><ul><li><a href="/about">Read more</a></li></ul></nav>

Any ideas anyone?

samwillc’s picture

Ok, so stepping it up a bit:

<div class="node-links-wrapper">
<div class="node-links"><a href="/blog/my-second-blog-post">Read more</a></div>
<div class="node-links">3 comments</div>
</div>

Ok so far with one link and then some plain text. The problem with the output I get when I make comment count output as a link [path]/#comments is this:

<a  href="/blog/my-second-blog-post/#comments"></a>
<div class="node-links-wrapper">
<a  href="/blog/my-second-blog-post/#comments"></a>
<div class="node-links">
<a href="/blog/my-second-blog-post/#comments"></a>
<a  href="/blog/my-second-blog-post">Read more</a>
</div>
<div class="node-links">3 comments</div>
</div>

??

Thanks.

samwillc’s picture

Worked it out after many hours of annoyance! Here's how:

http://drupal.org/node/1329052