It can be done at the theme layer, but what about allowing to select a rel="nofollow" attribute for all the links in a given view ? The links to the nodes and the pagination. It would be nice for those wanting to scult their Pagerank.

Comments

drewish’s picture

it would be kind of tricky because you'd have to do it on every field handler... and that wouldn't take care of the ones in other contrib modules.

todd nienkerk’s picture

+1

Checking "Add field as link" (or whatever the text is) could display an option to nofollow that field. This is particularly useful for aggregator-based views and any other view that natively creates or overrides link output.

As drewish mentioned above, contributed modules would have to provide their own nofollow option.

chawl’s picture

Using theme suggestion just for rel="nofollow" attribute is an overkill. Also there are many other rel attributes which you might want to set.

IMHO this field should be included in "Output this field as a link" at least.

Tx.

dawehner’s picture

As alternative there could be a hook_views_field_render_advanced_alter, which allows to alter the link array, to add a nofollow attribute.

chawl’s picture

Even a simple "extras" field can be useful, which you can add not only rel but also other events or attributes like onClick, lang, style, id, name etc. manually.

In fact whole link functionality can be reduced to a single tokenized field for maximum freedom, but may be cryptic for the ones who are not familiar with (X)HTML links anyway.

jmcintyre’s picture

+1.

I need to build a link to open a page into a Shadowbox, so I need to find a way to add a rel="" attribute. I guess I can just rewrite the field output and build my own a tag, but that doesn't seem like the "right" way.

miruoss’s picture

subscribe

cerup’s picture

Easiest way is just to "rewrite output of the field" like:

<a target="_blank" rel="nofollow" href="[url]">[title]</a>

Where [url] is the replacement pattern link. Make sure to switch the 'display' field setting to 'url as plain text'. [title] can either be another replacement pattern field (above the current one) or just text you put in. This is what I'm currently using. I guess if you need to do it to every field link, you could theme it somehow.

jarizaro’s picture

Thanks, this solved my issue. And it gave me a hint about the other problem i were having.

If you try to use it in a Link CCK field...:

   [x] Rewrite the output of this field:
    <a target="_blank" rel="nofollow" href="[field_url_url]">[title]</a>

In the output you'll get (source):

<a class="views-processed" href="%3Ca%20href=" http:="" www.airberlin.com="" target="_blank" rel="nofollow">Air Berlin</a>"&gt;Air Berlin</span>
  </div>

which is not correct.

To solve this issue:

- in cck link field: [x] exclude from display, and Display: URL, as plain.
- create a new Global: CustomText field. and:

    [x] Rewrite the output of this field:
    <a target="_blank" rel="nofollow" href="[field_url_url]">[title]</a>
    

Thanks.

Bazookatooth’s picture

ok, but where are you getting [url] from? I want to do what you are doing, but i need the URL to be the node's url.

So the end result is the node's title listed in a view and when you click on it it opens the node in a lightframe. So i need the rel="lightframe" in the link.

A Romka’s picture

is there a way to add JS into a link?
i.e. have something like this -

<a href="#" onclick="window.open('player/[nid]','player','other window params'); return false;" rel="nofollow">Open Player</a>

the whole "onclick=..." gets stripped out for me .. any suggestions?

dawehner’s picture

#11
No.

This is a security hole and no clean way of developing a website. Better you add a class/id and have your js logic in a extra js file.

WorldFallz’s picture

Status: Active » Closed (works as designed)

queue cleanup: this issues has deviated from the original request which is handled by the 'rewrite' option.