0

I'm trying to make a little block that links to the logged-in user's profile. I've already created a view block with the necessary information, but I don't know how to make it clickable and link it to the user's profile.

How can I achieve this?


Edit: One can find some more details about the code that fixed this problem at https://stackoverflow.com/questions/23552893/how-to-create-a-clickable-block.

4
  • Can you share a screenshot of the block that you like to be clickable?
    – Jason
    May 8, 2014 at 18:56
  • It's a simple user view that shows four user fields of the currently logged in user. I'll provide a screenshot later.
    – Jeroen
    May 8, 2014 at 19:00
  • Are you displaying the block title? Do you want the block title to be included within the link? So, do you just want to wrap all of the fields within an anchor, such that the path is /user/[uid]?
    – Jason
    May 8, 2014 at 19:02
  • @Jason: No, I don't display the block's title. Indeed, that's what I'd like to achieve.
    – Jeroen
    May 8, 2014 at 19:05

2 Answers 2

0

Here's a possible solution. In your view, exclude all fields add field 'Global: Custom text'. You may also have to add fields to generate the appropriate path to the user profile.

Then, add the token replacement patterns for the excluded fields. You can either 1) wrap this output in an anchor with the appropriate path /user/[uid] (a field you may have to add, or you may be able to use the user's alias), or 2) in the rewrite section, tick 'Output this field as a link' and specify the path there (also use replacement patterns from UID or the alias).

5
  • I succeeded in implementing your second proposal, but it's not completely what I'd like to see. Now, every field is simply turned into a link, but I'd like the whole block to function as a "button", so no seperate clickable fields.
    – Jeroen
    May 8, 2014 at 19:56
  • Can you elaborate what you mean as a "button"?
    – Jason
    May 8, 2014 at 20:00
  • I mean something like the "button" one can find in the upper menu bar on this website. One can go to his/her profile by clicking the image, the medals, etc. I'd like to create something similar.
    – Jeroen
    May 8, 2014 at 20:01
  • Take a look into the markup of what you are referencing. It's a few divs within an anchor. Styles are then added to give it's appearance. It's possible you can achieve a "button" look through css.
    – Jason
    May 8, 2014 at 20:03
  • Yes, I checked it with Firebug too. :) I'll see what I can do.
    – Jeroen
    May 8, 2014 at 20:05
1

If you can't edit the output html and don't want to make a custom template, you could do this with CSS by positioning the link div over the block and expanding it to 100% width & height. Apply it to both the container div and the a. Resize the a text & make transparent to so it should still work with screen-readers, ie:

.block-name .field--type-link,
.block-name .field--type-link a {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
color: transparent;
font-size: 1px;
}
<div class="block-name">
  <h3>title</h3>
  <div class="field--type-content"><p>Content</p></div>
  <div class="field--type-link"><a href="#">Link</a></div>
</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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