I have a brand new site and am trying to show a list of users with a link to their contact page. So far, I'm having no luck getting it to show! Any suggestions?
| Comment | File | Size | Author |
|---|---|---|---|
| #74 | 1021590_12_D7.patch | 2.62 KB | dawehner |
| #68 | 1021590_12_D7.patch | 1.5 KB | infines |
| #58 | views_contact_link-1021590-58.patch | 3.38 KB | llslim |
| #55 | views_contact_link-1021590-55.patch | 4.49 KB | llslim |
| #54 | views_contact_link-1021590-54.patch | 5.96 KB | llslim |
Comments
Comment #1
mariusz.slonina commentedThis patch should fix the problem, however, be sure to check permissions. In D7 Anonymous users are able to use personal contact forms, thus I removed all D6 logic and test access with user_access('access user contact forms'), Also, we should check $account->data['contact'] instead of $account->contact (for case when user disabled own contact page). Hope this helps.
Comment #2
dawehnerPerhaps it's just the patch
But you dont' use $account anymore later?
Comment #3
mariusz.slonina commentedYou're right, the $account in access() isn't needed. The new patch uses only user_access().
Comment #4
dawehnerThis was the d6 logic of contact, right?
Comment #5
mariusz.slonina commentedYes. In D7 with "access user contact form" we can allow Anonymous users to use personal contact forms. So the access() in Views7-3 should be different than Views6-3, I believe.
The _contact_personal_tab_access() checks at the end for "access user contact form", however, using it in access(), will totally hide contact link.
might be missing in both branches (without it we obtain only plain text).
I manually tested the patch for site administrator, authenticated user and anonymous user on D7.0.
Comment #6
dawehnerWhat about changing the signature to a static?
The advantage: less code change
The disadvantage: This can't be applied to 6.x-3.x
Comment #7
mariusz.slonina commentedThis is probably much cleaner solution:
- patch (a) applies both to D6/D7-3 branches, since the contact link (if access is true) is made only when icon option is choosen -- plain text otherwise, even if we have access. For D6-2 branch link is made in both icon/text option.
- patch (b) applies only to D7-3 branch, and is D7 specific: 1) we have a permission to use personal contact forms 2) the user may still choose to enable personal contact form, but the setting for that lives now in $account->data['contact'].
Comment #8
Anonymous (not verified) commentedIs there a patch for this that fixes 6.x-2.x? (the latest patch doesn't work for me)
Would love to get this working on my site...
Comment #9
mariusz.slonina commentedThe patch 1021590_7a should work on 6-3. I thought that the contact link is working for 6-2 branch, I will look at it later today.
Comment #10
mariusz.slonina commentedreattaching 7a patch for latest dev
Comment #11
dawehnerWe need this to 6.x-3.x, too.
Comment #12
mariusz.slonina commentedPatches against current 6-dev/7-dev
Comment #13
Sborsody commentedRTBC for D7 patch only.
Comment #14
Sborsody commentedThe patches refer to a removed image.
$text = theme('image', 'misc/forum-new.png');The forum icons were consolidated into a sprite: #1008580: Fix image references in forum.css Perhaps a new icon is needed so this doesn't have to rely upon the forum module.
BTW, it would be great for this to be made available via a theme function like something similar to theme_feed_icon.
Comment #15
tim.plunkettsub
Comment #16
roam2345 commentedSub
Comment #17
AdamGS commentedsub
Comment #18
danepowell commentedsub- interested in and able to review any 7.x patch
Comment #19
llslim commentedi have applied the 1021590_12_d7 patch to the latest 7.x-3.0-rc1 release, and it works well for making the textual, but the icon picture still depends on the forum module. I say the icon should be the user's profile picture instead of random icon. Just my opinion.
Comment #20
llslim commentedThis fix enables views to display links to users' with both text
and icon types and gives site developers to theme the contact
link icon.
The changes made by the patch in comment #12 are included.
Site Developers can customize the display of the icon by overriding
the base theme_views_contact_link_icon function from with in their theme.
This base theme function is located at the bottom of ~/views/theme/theme.inc
In development the following lulla icon is set as the default icon
located in the image directory of the views module (~/views/images):
- http://www.lullabot.com/files/icons/lullacons_pack1/doc-option-edit.png
I feel this free GPL licensed icon should be included in the views package.
As suggested here: http://drupal.org/node/35416
As the library project matures image resources of the module should
implement that way, but that's a feature request it's beyond the scope
of fixing this issue.
The D6 patch was made against the views git repository commit with sha aa2b24e9982c29bd9dc6235e440b7c336458fa81 made on June 25th 2011
The D7 patch was made against the views git repository commit with sha f9af377bfcdd19d3a047d76d956a1871e1c0aed3 made on June 28th 2011
Comment #21
llslim commentedSorry the attached fixes the white space errors in previous files. This is my first time using git to submit a patch. here are working patches that can be applied cleanly.
Comment #22
llslim commentedsame patch in #21 works with latest dev version.
Comment #23
mariagwyn commentedI applied the patch (worked) but am now getting the following error anytime I visit a view that should show a contact link:
Theme key "views_contact_link_icon" not found.
Comment #24
llslim commented@mariagwyn did the patch apply the modifications to the views.module file where the array key is set?
In the patch review it still shows an eol error before the part in the patch modifying the views_theme function in the views.module file. After submitting the last patch I did changed my eclipse settings to handle unix files. re-rolling my patch for d7 attached to see if the EOL disappears.
Comment #25
llslim commented@mariagwyn that message also may happen if you don't clear the theme cache after applying the patch. you can clear cache by going to the performance page located admin/configuration/development/performance in drupal 7. in drupal 6 you can clear it at admin/settings/performance
Comment #26
mariagwyn commentedI have been using drupal for 6 years, and I still forget to flush the cache. It seems to work for me, though I haven't re-applied #26. Thanks llslim.
Comment #27
mariagwyn commentedI am having some trouble overriding this in my theme. I simply want to change the graphic, but it doesn't seem to be working. And yes, I am sure my template.php file is being registered because if I put the function in and do not change the name, it throws an error. Is there something new in D7 about theming this link?
Here is my renamed function:
I tried it with phptemplate_views_contact as well. No change.
Comment #28
roam2345 commentedCan we get a rerolled patch against D7 ill test?
Comment #29
llslim commented@mariagwyn
It worked on my test with acquia_marina, but you do have to install the fusion base theme with the skinr module, and clear the theme registry cache after creating and saving the new template.php file. Without the base theme and clearing the cache it won't work at all.
For other themes when using the override feature in your theme please follow the procedure as described in the "How to change HTML the Drupal way" on this page: http://drupal.org/node/341628 . Remember to clear the theme registry cache after editing and saving your theme's template.php.
Also you can put the overriding contact link icon image in your theme directory that way you can keep everything together. Using "mythemename" as the theme name of your favorite theme and '/path/to/image.png' as the path with in your theme directory to the overriding image.
Note: if you're copy and pasting the above into a new template.php. Remember to remove the trailing "?>" in the file.
Hope this helps.
Comment #30
llslim commented@jucalme for your review
Just pulled down the new changes to views this morning from the git repository
Attached is the D7 patch against the views-7.x-3.x branch with the commit hash b99032a1019d2100062ddb344c9f95ba01919d87
Please refer to [#20] for full instructions / parameters and [#29] for overriding instructions.
YOUR review is very appreciated.
The re-roll for D6 patch is on it's way soon.
Comment #31
llslim commentedPulled down the new changes to viiews 6.x-3.x from the git repository
Attached is the D6 patch against the views-6.x-3.x branch with the commit hash: a27f545805b2e6973516cba05b1884a8ad39a31a
Please refer to [#20] for full instructions / parameters and [#29] for overriding instructions.
YOUR review is very appreciated.
Comment #32
roam2345 commented@llslim unfortunately you will need a further re-roll of the patches there is trailing white space and a tab should be two spaces.. http://drupal.org/coding-standards#indenting will post back after test.
7.x-patch this is wrong should remove the previous line, no need to set something then straight away overrider it. Assume this was oversite in D7 version as in D6 its correct.
Comment #33
roam2345 commentedPatch does not work, for D7
running
- drupal 7.4
- ctools 7.x-1.x-dev 2011-Jun-24
- views 7.x-3.x-dev 2011-Jul-07 with patch #30
link fails to display I see the label text but no link, set the text to contact link and it never displays.
Comment #34
llslim commentedI completely by hand patched #30 trying to remove whitespace errors in patch and over looked the double rewrite. Sorry about that.
Here is the re rolled D7 patch. The link and icon both worked for me.
Comment #35
llslim commentedDis regard #34. use this instead
Comment #36
mariusz.slonina commentedHi, sorry for late response -- I tested new patches and it seems to work well (D7.4, latest ctools+views), however I'm not convinced with this edit icon, maybe kind of a mail icon would be better?
Comment #37
llslim commentedOkay first I finally figured out how to change tabs to spaces and print white spaces as characters in Eclipse so my patches avoid white space errors. Celebrating small victories. I also apologize for fumbling through this with so many posts, but learning a lot.
Second @marlusz.slonina it can be whatever image you want with it now being themed, but by default I do agree the lulla mail icon (http://www.lullabot.com/files/icons/lullacons_pack1/mail.png) would be a better choice to ship in the views images directory. The edit icon was used in development as a second option to test and force me to override in the theme. Anyhow the final image would be up to the dev who commits the patch I guess.
@jucallme the patch does work as expected, but you have to set the contact form as available in each user profile before the view can access it. Also for the theme function to display the icon the image file has to exist. In the use case I presented in [#20], the image would come with the views module in the images directory as discussed last paragraph. I did add a check to print a message to admins who have 'administer users' access to say "User contact page is not available to be viewed" to help admins know what is wrong in the view.
@jucallme your image does point out another error that the field label shouldn't print when there's no data. That's out the scope of this issue.
Anyway this patch is rolled against the July 7th commit with the hash ba94ee107d639cfc530f652ea99b8faf7a62db5d of the 7.x-3.x branch.
Comment #38
llslim commentedThis is the D6 port of the patch posted in #37 rolled against the July 7th commit with the hash of a27f545805b2e6973516cba05b1884a8ad39a31a of the 6.x-3.x branch.
Comment #39
llslim commentedjust checking in to see if other people had the chance to review the patches in comment #37 and comment #38 . So this issue can be closed.
Comment #40
dawehnerSorry but please keep it simple. If there is no image availible, we basically shouldn't use one and not add one into views. Isn't a link + text enough here?
Comment #41
llslim commented@dereine This issue didn't introduce the icon option as a new feature, but fixed what was already committed to the views project in order to make it work as expected. If the icon option is available, then I just think it should work out of the box no matter what we as developers think trivial. Yes the text + link is sufficient for the majority, but we are just fixing the broken option.
Also as #14 states the image referenced before the fix was outside of views and subject to be more likely missing and can be changed without notice to views,or to the maintainer of the outside referenced image knowing it is being referenced.. With the the image with in the views package changes to the image can be tracked and attached to the changes of code that uses it..
If the image cannot be included, the maybe a warning concerning 'no file exist ' should be presented with in the current theme directory. That way it can tell people to put their icons in the right place.
What do you think?
Comment #42
roam2345 commentedMy two cents but I defer this to @dereine, views should not be inserting a default image. If a page needs an image on this its a little simple css.
For example.
there is no need for a full tpl...especially since we can now add our own classes on fields, all that overhead. I would rather remove it.
Comment #43
llslim commentedSolves contact page link issue #1021590
Customizes the display of a link to a user's contact page by adding an
icon next to the text link instead of replacing it with an image tag.
This is done with the css trick that jucallme suggested here
http://drupal.org/node/1021590#comment-4736618.
This patch changes the 'Type of link' select box to an 'Add icon'
checkbox. When checked, the css class 'contact-link-icon' is applied
to the contact page text link to show an 16px by 16px PNG image to the
left of the text link. The image is referenced from the 'misc' directory
located in the drupal top-level directory where many of the images for
drupal core modules are stored. AS explained in the description of the
checkbox, the name of the image file has to be contact-link-icon.png.
Site developers can customize the size and name of the icon image by
defining their own 'contact-link-icon' class in a stylesheet of the active
theme. Which will override the css definition in the views.css file.
This eliminates the overhead of using template files, and eliminates
the need to add an image to the views module by having clear
instructions in the checkbox description. As both @dereine and
@jucallme pointed out.
this patch is based on the commit with the hash ac214b2e made on july 20th.
Check the patch out and let me know further thoughts.
Comment #44
llslim commentedthis is the d7 port of the patch above. this patch based on commit with the hash 46b999e25 made on july 20th.
Comment #45
llslim commentedFixed whitespace errors in #44 sorry about multiple posts.
Comment #46
dawehnerThis seems to be a decision for merlinofchaos
Personally i don't like such specific things in views.
Comment #47
llslim commented@derenie I understand, just making it functional for those who choose it.
Comment #48
dawehnerJust spend some time with this. There is still this icon provided by drupal, but it's part of a sprite,
so why isn't it possible to write some css which takes this icon and use it?
You don't have to care of the relative path to views, because you could use ctools/includes/css.inc
to write dynamic css.
Comment #49
Vasu commentedsub
Comment #50
llslim commentedJust getting back to this. The issue of using the forum sprite for the image. Is that the sprite is arranged horizontally and not vertically. In order to represent the single icon the width of the element (link) would be reduced to 16px and cutting out the text link. If the sprite was stacked vertically it would work just fine. I thought about adding an extra element to make use of the sprite, but couldn't let site developers override the image element without creating the over head of a theme template. Also adding a empty element just to use a background image I feel would be unnecessary bloat to a page for aesthetics was not a good thing. So while it's a pain to download a new icon,it's the best option I can see. Unless we can convince the forum maintainers to use change the orientation of the sprite, or even to move the "new" icon to the far right position with in the sprite. I am open to suggestions of a way to implement this with the sprite and its current orientation.
I haven't used the ctools functions to write dynamic css before. Can you point me in a good direction for examples? I'll research that soon. Thanks for looking at it and giving comments. I appreciate it.
Comment #51
dawehnerI don't know of an example, but the api is really not hard to use and the file itself has a lot of great documentation.
But this is just an idea.
Comment #52
llslim commentedHere's the latest drupal 7 revision for your review.
Significant updates:
-With using ctools. dynamic css I got the changes limited to only one file
- Using the forum-icons.png by default
- added a check box option for site developers to put their custom icon in the default theme directory.
Dynamic css makes the ctools module a requirement for this scheme to work. It's either that or add to views.css
CSS Background clipping is not standard yet or as prevalent as regular image clipping. Also because css url referencing is relative. The trick that @jucallme suggested in #42 wouldn't work on all installs with symlinks.
I am still debugging the drupal 6 port and will explain those issues in separate comment. Let me know your opinions. Also thanks to those who gave me suggestions. Even though this issue was simple or should be. I've learned a lot. Full commit message below.
#1021590 fixes contact link and adds icon
Customizes the display of a link to a user's contact page by adding an
icon next to the text link instead of replacing it with an image tag.
This is done with using the forum-icons sprite and ctools dynamic css.
This patch changes the 'Type of link' select box to an 'Add icon'
checkbox on field configuration page. When checked, an 16px by 16px PNG
image is placed to the left of the text link. The default image is the
new forum icon from the forum-icons.png image. The image is referenced
from the 'misc' directory located in the drupal top-level directory where
many of the images for drupal core modules are stored. The new
forum-icons.png sprite image comes with all drupal 7 core install.
A second sub-sequent 'customize icon' checkbox has been added to allow for
a customized icon to be placed in the base directory of the drupal theme.
The name of the image file has to be contact-link-icon.png, and preferrably
16px by 16px in size.
Site developers can customize the size and style of the icon image by
defining their own 'contact-link-icon-custom' class in a stylesheet of
the active default theme. Which will override the dynamically created
css definition.This eliminates the overhead of using template files,
and eliminatesthe need to add an image to the views module by having
clear instructions in the checkbox description.
Comment #53
dawehnerviews already requires ctools in drupal7. That's okay :) Does this bug exist on drupal6 as well?
I'm wondering whether it would make sense to be able to define the path in the view, so any kind of icon could be used. But i guess the per-theme is better
Better use the current theme global $theme instead of the variable.
The path shouldn't be absolute here. theme('image')/url should handle it as well. Alternative you could use base_path()
Please call theme('image') here
It would be cool if you could use drupal code style here as well: Add a new space after each argument: foo($bar, $baz, $foo);
There are other code style problems here as well. else {, comments after the line etc. Please also take sure that the output of 'text' is escapped right.
Comment #54
llslim commentedI fixed the drupal code style standard errors suggested by dereine, and made use
of the theme() function instead of theme_image(). Also added base_path to image
paths. Still have to test when drupal is not installed at rot of domain.
The reason I used the theme_default variable and not the global $theme variable
is to take into account for Administration themes. For example 'rootcandy' is a
popular administration theme, and using the $theme variable would reference the
administration theme 'rootcandy' and not the default theme such as 'garland'. I
think that would confused people as I haven't found a global variable that
references the default theme. I may be over looking something though.
I also wonder if defining the path to the image is a good thing to do in the
view, but the priority was getting the functionality to work before focusing on
that. Also since this is not a 'critical' feature the less thinking site
developers have to do the better. Just my thoughts. I can look into it after
everything else is squared away.
@dereine what do you mean? by escape the output? by putting t() around it?
Comment #55
llslim commentedThis is the Drupal 6 version. Functionally works like the Drupal 7. The issue I'm having is getting the ctools dependency work on the views form. I tried to look at documentation, but I'm not having any joy. If someone can point out what I'm doing wrong. That will be great.
Comment #56
kehan commentedsubscribing
Comment #57
infines commentedSubs
Comment #58
llslim commentedHere is the d6 patch for review to be committed. Since I couldn't get dependency to work in D6 like I can in D7 (which #54 needs reviewed also) I removed the custom icon option from D6. Works eautifully. Let me know your thoughts.
Comment #59
infines commentedShouldn't we commit this to D7 dev before moving on to D6?
Comment #60
dawehnerWell at least for d6 this patch will not work because we don't! have ctools available.
Comment #61
justmagicmaria commentedSubscribing. (Need D7 fix.)
Comment #62
infines commentedI don't understand. Is the patch in #54 for Drupal 7? Let me know and I'll test it. And if so then it probably needs to be tweaked and adjusted against the latest dev.
Comment #63
dawehnerI thought of using check_plain.
Comment #64
infines commentedI can confirm that the patch in #54 works wonderfully. It was tested on Views 3.x rc-3.
Comment #65
infines commentedReopening to say that the patch in #54 needs a bit of work as it doesn't disappear if the user unchecks the Personal Contact Form option. It shouldn't render if thats the case.
Comment #66
ahmetucar commentedSubscribing.
Comment #67
dawehnerWould it be possible to write some code in the init() function to take care to migrate existing settings?
Mh this seems to change the string, why not using %user here as well?
Would it be possible to write some code in the init() function to take care to migrate existing settings?
Mh this seems to change the string, why not using %user here as well?
In general it would be cool to have some kind of issue summary here.
Comment #68
infines commentedI tested the patch in #12 against current 7.x-3.x-dev and it works wonderfully. I'm reattaching both patches to these posts, however I'm not rerolling them against the current dev as I have no idea how to do so but this issue has been open for far too long and needs closure. For any further issues, I vote for people to open up a new one. The 6.x patch needs to be tested against the 6.x dev still.
Marking as RTBC.
Comment #69
merlinofchaos commentedSince one of the maintainers (dereine) posted a list of things that need to be improved about the patch, it seems odd to RTBC it without addressing those things.
Comment #70
infines commentedThose changes were for more recent patches, I'm saying that an old patch works fine. The newer patches when tested have removed and changed so much that when tested they don't respect whether a user has their contact form enabled or not. This is an attempt to scale things back and move the issue forward. However let the maintainers do what they feel is right.
Comment #71
infines commentedThose changes were for more recent patches, I'm saying that an old patch works fine. The newer patches when tested have removed and changed so much that when tested they don't respect whether a user has their contact form enabled or not. This is an attempt to scale things back and move the issue forward. However let the maintainers do what they feel is right.
Comment #72
dawehnerI'm a bit confused about this line. The text is set to an image, so it will always need html...
The total issue was about getting the icon back, which requires quite some effort see comment 58.
I'm wondering whether we could try to keep the focus of that issue.
I'm pretty sure that this patch doesn't work for 6.x as it's using $account->data instead of $account->foo directly.
Comment #73
infines commentedI dont understand the big hub bub about the icon. I think this issue is more about getting a functioning contact link in views. If people want an icon they can theme the link with css. Views is for generating queries and lists of objects. Icons and formatting come second hand. That's why i'm trying to move the issue forward. Any issues about an icon for the 1 link that people want it for and the only link that seemingly has it in drupal, should be opened up in a seperate issue.
Comment #74
dawehnerWhat about simply dropping the feature?
You are right about don't care about the icon, if drupal doesn't have a simple icon anymore that's not our fault.
Here is a patch which uses the approach from above but drops the configuration at all.
Maybe someone could write a contrib module with a contact field which has all the features you need.
Comment #75
dawehnerI'm somehow wondering why _contact_personal_tab_access isn't used, just because it's not a public function?
Comment #76
dawehnerSo committed the current version, even it's not perfect. Things can ALWAYS be improved later, so it's actually important to get something working in.
Comment #78
dianacastillo commentedi just overrode my views module with the 7.x-3.x-dev version, ran update (it said nothing to update) and my Views field "User: Link to contact page" still doesnt find the contact page of the user, even though if you go to the user page the contact page exists.
Comment #79
dawehner@dianacastillo
Can you please describe your scenario with a little bit more details? One small interesting details could be to know, whether the user has explicit disabled/enabled the contact page?
Comment #80
dianacastillo commentedThe contact page is enabled explicitly. I made a view and one of the fields I added was the "User: Link to contact page" but the link doesnt appear.
Comment #81
sparker888 commentedI too am running Drupal 7.22 with Views 7.x-3.7, and have enabled contact permissions (for all roles) as well as having (test) users explicitly allow the use of the contact form. the "User: Link to contact page" field is enabled in Views yet nothing is showing up for this field in the view. I'm willing to help describe any further settings or site set up info to help with this issue.
Edit: Tried the latest dev version of Views with the same result.
Comment #82
jippie1948 commentedFor this to work the Token module needs to be enabled.
- Create a new view based on User.
- Add a field User:Uid
- In field settings:
- Untick 'Link this field to its user'
- Tick 'Rewrite the output of this field'
- Add some text e.g. 'contact user'
- Tick 'Output this field as a link'
- Set 'Link Path' to 'user/[uid]/contact'
For me it works. Best wishes, JP