Closed (won't fix)
Project:
Activity
Version:
6.x-1.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Issue tags:
Reporter:
Created:
19 Oct 2008 at 18:19 UTC
Updated:
11 Sep 2010 at 22:08 UTC
Jump to comment: Most recent file
Comments
Comment #1
jaydub commentedThis is really all about theming the activity output and there are a number of other issues that are similar to this. To that end I am going to rework the default activity output pages to make them themable to a greater degree than they are now.
I'll revisit this issue once those changes have gone into the new branches.
Comment #2
zilla commentedcould even just pull user picture to start (if present)
Comment #3
lelizondo commentedI couldn't find anything really helpful about how to accomplish this... I've found at least 2 similar posts but none of them were really useful.
Can anyone post an example or something? Since I couldn't find any documentation available.
Thanks
Luis
Comment #4
zilla commented@lelizondob - if you DO find something, please let us know! just pulling a user picture would be extremely cool and would make the layout look really nice...
Comment #5
lelizondo commentedI found http://drupal.org/node/302216 and http://drupal.org/node/197521 and I would be glad to change this issue to duplicate but none of them were really helpful.
Pulling a user picture would be nice too.
Luis
Comment #6
kleale commentedPlease help me!! I can't theme user pictures on activity page. All I made was default picture. Plese give some example with theming...
Comment #7
lelizondo commentedI'm also asking for some examples. Hope someone finds a solution and share it.
Comment #8
zilla commentedi'm beginning to think that for some reason it is the taxonomy image module that will bridge this path - specifically for the 'show a calendar icon' comment way up above in original post
..and alongside that, a call to the user picture - privatemsg module is now doing this for messages, perhaps a quick look into their code will show how it was done? i can't understand it, but the original thread is here: http://drupal.org/node/170387
but activity module - unlike privatemsg - has nothing like "theme_privatemsg_username" to override directly, we'd need a theme_activity_username to override that would inherit for all contrib modules
here are the core d6 themeable elements: http://api.drupal.org/api/group/themeable
here's one possible solution, but it's a HEAVY hackup: http://drupal.org/node/170387#comment-879371
Comment #9
jaydub commentedOk for the activity pages as seen in /activity or /activity/mine you can now customize the output of the table by using a theme override.
The table is generated in the latest snapshots by the theme_activity_table() function as invoked by activity_page() as seen here:
theme_activity_table() was formerly just activity_table() and so was not able to overridden:
So if you wanted to say remove the table header, add in a picture and move the time to the end of the activity record then you could add a theme override to your template.php like this:
Comment #10
jaydub commentedYou'd probably want to use something other than theme('user_picture') to draw your user avatars if they are as big as one would normally have. Instead you might have your own custom theme override for theme_user_picture so that you can make use of imagecache for example.
Comment #11
zilla commentedthis is excellent, though i'm a bit of a novice when it comes to this - some quick questions:
is this in current dev/release (or over coming days)? for D6 or D5 (this original thread is all about the D5 version)
where is that template.php file? is this the main core template.php file or within a theme folder for site theme?
within template.php, where should such a snippet be pasted? top, bottom, does it matter?
Comment #12
jaydub commentedThe change in the activity page to allow for better theming is changed in both d5 and d6. As far as theming goes and how to handle adding theme overrides to your theme, that's outside the scope of this issue. I suggest you start with the Drupal documentation for theming.
http://drupal.org/theme-guide
And specifically for theme override concepts:
http://drupal.org/node/173880
@lelizondob
with the new theme override possibilities you could change the output as you mentioned to show any arbitrary image based on each row in the table of activity records. For example you could show an image for activity entries for votes, another image for buddylist/User relationships actions, create/update/delete of nodes or comments or even for specific node types.
Comment #13
zilla commentedthanks - it's a bit beyond me so i'll need to read up on it...if it winds up in here as a contrib module (like 'display user pictures in activity'), that would be sweeeeet.....
Comment #14
lelizondo commentedmaybe I'm missing something here
theme_activity_table() was formerly just activity_table() and so was not able to overridden:
are we talking about version 3.0-beta2 or 4? since I couldn't find theme_activity_table
Comment #15
lelizondo commentedAs I supposed, this only work with version 4.
Comment #16
lelizondo commentedThanks Jeff for the answer, just one more thing.. I finally could theme the activity page to add an image in a new column, but can someone please explain a little bit how to get the node type for:
to get something like this:
since I can't get this to work for the blocks..
Thanks in advance,
Luis
Comment #17
jaydub commentedYou can get access to the tokens available for a particular activity message type from the activity array that is available in the last example theme override
For example if I dump the values of the $activity array that is part of this loop:
I have access to these values (for this particular activity record which happens to be votingapiactivity):
So when you are in theme_activity_table or theme_activity_message you have access to all the data that is available for a particular activity record.
Comment #18
lelizondo commentedThanks a lot Jeff, knowing the values of the array is what I was looking for..
I leave the solution if anyone is interested, it is actually really simple..
this outputs
or
Which lets me use css to add an image next to the message. Maybe this should go somewhere in the documentation of the module or the handbook..
Thanks again, great module.
Luis
Comment #19
DerTobi75 commentedI cannot get this work with D6, I copied the phptemplate function into template.php, but it does not overright the existing one :(
Edit: Got it work, sorry, was a caching problem...
Comment #20
minesota commentedWell, I avoided touching any of the files (which perhaps has some advantage) but just do it via the administrative interface.
For example :
come to /admin/settings/activity
click Tokens for nodeactivity
click on Messages visible to the "All" role.
come to Blog entry: Create:
Fill the box with something like
<image align=absmiddle src=whatever_path/whatever.gif> [author] penned [node-title-link] [time-ago] agoComment #21
lost305 commentedI do not get this at all. I placed the phptemplate_activity_table function in my template.php and all it did was switch up my /activity page a little and not add the user's picture.
Just to test i took off the
in the
And no difference. The user name stayed on there.
What am I doing wrong?
Also what I'm looking for is to change this in the block not the page. Doesn't matter to me if it shows it or not on the page but in the block is where I could like to see this change
Please help.
:o(
Comment #22
bflora commentedSo what's the best way to do this? I'm stunned that no one's worked out a way to do this yet. Activity feeds are becoming widespread on the web....and Drupal doesn't seem to have one that can do it just yet. Check out the one on the home page of http://www.faniq.com to see a pretty nice one. Would be great to be able to replicate that in Drupal.
Comment #23
jaydub commentedDid you read the details in #9?
Comment #24
lost305 commentedJaydub,
I did exactly that. Please read #21 and the picture didn't show up.
What can I be doing wrong?
Comment #25
bflora commentedDo we need to rewrite the "phptemplate" part in the function declaration when adding it to our template.tpl.php file?
I pasted in the code from #9 and saw no change on my /activity page or my activity block.
Comment #26
lost305 commented@bflora
I saw a change but I didn't see any user picture and I only saw it in my Activity PAGE, not the block.
What I did was just past that code from #9 in my template.php. Nothing else.
I wish Jaydub would stop ignoring me.
:o(
Comment #27
lost305 commentedCan someone tell me what I'm doing wrong?
Comment #28
lost305 commentedCan someone tell me how to do this correctly?
Comment #29
jaydub commented#28 I know it's hard for you to wait but the reality is that the developers are busy right now with their day jobs. I myself will have a window of time to work on activity over the holiday so if you can be patient and wait for development to proceed eventually you'll get what you need :)
Comment #30
michelleThanks, jaydub. This will be an awesome addition to the module. I see this is tagged for 5.x. Is it planned for 6.x as well?
Michelle
Comment #31
jaydub commentedBoth 5 and 6. The Version drop-down only allows for selecting a single item so what can you do...
Comment #32
michelleYeah, I have the same problem. AF is getting developed in parallel between the branches so I just set them all to 6.x.
Thanks for the info. I'll be watching for it.
Michelle
Comment #33
Rosamunda commentedsubscribing
Comment #34
michelleI'm going to be working on the APK / activity integration later today and this is something I need. If you had a chance to work on anything that isn't committed, I'd appreciate a heads up. The more already done, the less I have to do. ;)
Michelle
Comment #35
jaydub commentedI'm working through the holidays on this and others. I've added user pictures as a feature but the actual implementation of a user image is most likely going to have to be a custom theme override for the average site since all activity can fall back on in the base module is theme('user_picture') which out of the box will likely return a fairly large size avatar.
Comment #36
michelleOh, good, because I only got as far as the panels integration yesterday. Didn't have as much time to work as I'd hoped.
What I plan on doing with my modules (advanced forum, advanced profile kit) is to make use of imagecache if the site has it installed. I haven't decided, yet, if I just want to set a preset name in code or make it an option in settings. Probably the latter. At any rate, wherever I do theme_user_picture, I would check for imagecache and use imagecache instead if it's set. You might want to consider that for this. Then someone just needs to make an "activity" preset with a smaller avatar.
Totally OT to this issue but thought you might be interested in http://groups.drupal.org/node/17847
Michelle
Comment #37
jaydub commentedYeah the way I've got it is to define an activity theme function for images:
So a site can provide whatever image implementation they want by overriding the theme function. I don't want to get into having to account for whether or not imagecache is installed, what is an appropriate imagecache preset etc...
This leaves it all in the hands of the site which is where it belongs I think.
Comment #38
michelleThat makes sense. It does "belong" on the site but I was planning on adding it to my modules just because it makes it easier for the end user and anything that makes it easier cuts down on support requests. :)
Thanks for adding this. I'll grab the latest dev and give it a whirl.
Michelle
[Edit: Actually... The last dev was on Dec 15th and there's no commit messages since then. Am I missing something?]
Comment #39
jaydub commentednot committed to CVS yet! still working on UR integration and other stuff before I do a code dump...
Comment #40
michelleCode dump? Tsk... Whatever happened to discrete commits? :P
Ok. Will wait. Hope it's soon, though. I've got to get this project done this weekend. Got a Monday deadline and my son's having surgery on Monday so I won't be working that day.
Michelle
Comment #41
jaydub commentedNew -dev snapshot has better support for activity user pictures now. Please checkout the handbook page on theming activity: http://drupal.org/node/353445 for details.
Comment #42
Flying Drupalist commentedHi jaydub, thanks for the great module. Can you give me a little more instruction on how to use this please? :D
I have:
function myzensubtheme_activity_user_picture($account) {
return theme('imagecache', 'tinyavatar', 'user_picture', $account);
}
in my template.php.
I see no changes at all.
The imagecache stuff comes from imagecache profiles: http://drupal.org/project/imagecache_profiles
What am I doing wrong? Thanks.
Comment #43
Flying Drupalist commentedAhh I get it, I didn't refresh cache.
But still, my return theme is incorrect. It looks in the imagecache folder but doesn't grab the picture.
I tried return theme('imagecache', 'tinyavatar', $user->picture); as well, but that's also a no go. What are the correct settings?
Thanks.
Comment #44
jaydub commentedWell rather than try to delve into your specific problem, here is an example theme override that I used. This is basically a tweak of what you might see in the old default theme_user_picture theme function.
of course you would substitute your own imagecache preset where applicable.
Comment #45
Flying Drupalist commentedThanks, exactly what I need.
Comment #46
Flying Drupalist commentedComment #47
michellere #44: If this is for D6, you don't want to use phptemplate_user_picture() or you'll prevent any preprocesses from running.
Edit: Nevermind that. I just realized this is overriding the activity theme function, not the core theme function. Sorry.
Michelle
Comment #48
michelleTo prevent anyone else from spending an obscene amount of time missing the obvious, you actually have to add the "[author-picture]" token for this to work. Doh! I can't believe I missed that.
On the plus side, I'm a lot more familiar with the activity codebase now...
Michelle
Comment #49
jaydub commentedActually no you don't HAVE to use the [author-picture] token to show a user picture but you CAN use it to show a picture. It's provided as a convenience in case you want the picture to be inside or at the beginning or end of the activity message, i.e. as part of the message.
If you wanted the picture outside of the message such as in a different table cell or in front of both the activity timestamp and the activity message then you can show the picture as described in this issue and in the theming docs.
Comment #50
michelleWell, my mistake was that, when you said you added picture support, I assumed you had added a call to theme('user_picture') in the code somewhere. And I couldn't figure out where you had done that. Then it finally dawned on me that what you added was the token. So to use this without the token, we'd need to add theme('user_picture') to theme_activity, I'm assuming? That's where I originally looked and got totally confused that theme_activity is never called. Took me a lot of hunting thru code before I finally realized it was because I have Morbus's comment activity on that same site. So it's been a crazy trip thru the activity source code today. LOL
Michelle
Comment #51
jaydub commentedI added the theme function theme_activity_user_picture() to be used in any case where you want to get a user picture. The implementation is left up to the user as stated in this issue since there is no one solution that is going to work for everyone. The author-picture token simply calls this theme('activity_user_picture') with a minimal user object returned from activity_user_load().
In the theming docs: http://drupal.org/node/353445 you can see an example at the bottom where the user picture is shown via the theme call rather than as a token.
Comment #52
walker2238 commentedI know this is for version 6.x but how could I add this for 5 beta 2?
Comment #53
lelizondo commentedversion 5.x-beta2 is old.. why don't you update? this is working for 5.x-4.x-dev..
Comment #54
jaydub commentedThe issue is set as 6.x branch but the same applies for 5.x. The Drupal project module only allows for a single 'Version' tag so when an issue concerns a 5 and 6 branch of a module one has to go ahead and select one even if both apply....
Comment #55
lost305 commentedHas anyone.. that's NOT a developer, gotten this to work?
I mean I'm able to get the user-picture to display in the list on the activity page but on the block all it shows is 1 image and no activities.
???????? :o(
Comment #56
bflora commentedTo build on that last comment, can someone sum up the steps to add images to activity for D5. There are now 50+ posts in this thread, and it appears a solution has been posted, but I'm not sure exactly what it is or where the solution is in the thread.
Comment #57
michelleI know jaydub wants to leave this up to the themer but, given that it can be confusing for a non dev, I thought I'd toss in the code I just added to advanced forum that could easily be adapted to activity. Pretty much just S/R for 'advanced_forum' to 'activity'.
On the settings form:
This lets them choose what preset, if any, to use for the avatars in the forum.
Then the specialized theme function, which already exists in Activity:
So what this does is lets the admin pick a preset on the settings page if they have imagecache installed. When it's time to theme the user picture for the activity item, it checks that picture support is enabled, that the user has chosen a preset, and that imagecache is enabled. If these things aren't true, then it just does the normal core function.
There is a slight gotcha here if they select a preset in AF, then go delete that preset, so a case could be made for checking that the preset still exists. But given the amount of times this function can be called on a given page, I decided to risk an error for foolishness. ;)
Michelle
Comment #58
Flying Drupalist commented@bflora and others asking about pictures. The code posted here are only about using imagecache with pictures or theming pictures in general. To simply add a picture it's one of the tokens available in the activity settings. Just look at the token list and include it, quite simple.
Comment #59
lost305 commentedi tried installing imagecache but it says there's a problem with my php version
no solution without imagecache installed?
Comment #60
lelizondo commentedyo don't need imagecache to use activity with images as you can see in Michelle's code:
but if you want to use it, version 1.x needs php 4.x and version 2.x needs 5.x
Comment #61
michelle@lost305: You could use CSS to squish the images smaller.
Michelle
Comment #62
lelizondo commentedimagecache_profiles is also a good choice
Comment #63
michelle@lelizondob: And that started working without imagecache when? ;)
Michelle
Comment #64
lelizondo commentedmy bad, what I wanned to say is that imagecache_profiles is also a good choice to have different image sizes, instead of using css like you said
Comment #65
michelle@lelizondob: Yes, but I was directing that at the person who said they are unable to use imagecache. So telling him to use imagecache_profiles really isn't going to do him any good.
Michelle
Comment #66
lelizondo commented@Michelle: I think the original problem could be solved as I said with:
but if you want to use it, version 1.x needs php 4.x and version 2.x needs 5.x
I don't think we should be discussing this anymore, but I do agree with some of the users who posted in this issue, seems easy to add images to activity but maybe it's not that easy, or that obvious, maybe we should be working on improving the doc, because http://drupal.org/node/353445 isn't that clear for a non dev.
What I'm saying is that the doc could be a little more straight forward, explaining how to use imagecache, imagecache_profiles, and activity, with and without advanced_profile (great module by the way!).
Too much code could be confusing for a non dev, and let's face it, not everyone here knows how to write code.
Luis
Comment #67
michelle@lelizondob: I didn't even see your post as it was at the same time as mine. Anyway, my #57 was intended as an addition to activity, not something for the average person to be writing. If they add that to activity, then people would be able to choose an imagecache preset from settings and then just add the token to their activity line, also in settings, and be good to go. Docs are nice but easier to use modules are better.
Michelle
Comment #68
lost305 commented@Michelle
Thanks I finally got it working. I didn't know I had to add the IMG to the previous stated class and then I was able to manage the size of the picture.
Now for the initial dilema...
How do I get the user image to display block function?
Comment #69
lost305 commentedI'm still trying to add the user picture to the activity block.
In the following code found in the activity.module file....
I added 'user_picture' to the line
$activities[] = theme('activity', activity_token_replace($item), $item) . activity_delete_link($item);
like this
$activities[] = theme('user_picture', 'activity', activity_token_replace($item), $item) . activity_delete_link($item);
and the picture shows up in the block but not the activity. So it's the user picture plus the X to delete the activity.
Can anyone tell me what I'm doing wrong?
Thanks for you time.
Comment #70
jaydub commentedSetting back to active since there are still a lot of folks needing help with this
Comment #71
jaydub commentedtagging
Comment #72
jaydub commentedComment #73
burn2149 commentedwould anyone be able to give an example of correct code to pull user picture if present, and where to put it?
thx
Comment #74
liliplanet commentedHi,
This is so close to being perfect ..
I've added the following to template.php, but the delete activity link is missing, as well as the image_cache preset, in my case called 'profile_small'.
Please how do I alter the following to add activity link and image_cache preset?
Look forward to any reply, and thank you!
Lilian
Comment #75
lelizondo commentedThis is what I've done, it's not perfect and I could use some help but it works.
First, to make use of imagecache I'll used #44, I have something like this:
For the page (theme_activity_table) something like this works:
Now the part I haven't figured out yet it's the indivicual activity message (theme_activity) I tried adding:
But that only showed the default picture for everyone.
Then, I tried a rudimentary solution:
The complete code it's:
This one works, I'm sure there's a better solution but I'm gonna need some help. I know this doesn't cover *all* the possible uses but giving some easy examples doesn't hurt.
The only problem is when adding the user picture to theme_activity and theme_activity_table, you'll have two images.
Comment #76
lelizondo commentedscreenshot of #75
Comment #77
sirkitree commented@lelizondob - Thank you for contributing your solution! Hopefully we'll get this all summarized and properly documented at some point.
Comment #78
lelizondo commentedI'll do it as soon as I found a better way to do this:
I'm sure there's a way but I'm going to need some help.
Comment #79
michelle@lelizondob: You could adapt the second bit of code in http://drupal.org/node/323380#comment-1217686
Michelle
Comment #80
lelizondo commentedThanks Michelle, I'll give it a try.
Comment #81
lelizondo commentedI'm using in phptemplate_activity:
All I'm getting is the default picture. If I remove the default core function I get nothing.
What am I doing wrong? Is it possible that $account->picture is empty and that's why I'm getting the default picture?
Comment #82
michelleAre you loading the $account variable with a user object before running that code? If not, that's the problem.
Michelle
Comment #83
lelizondo commentedThanks Michelle, but how do I do that?
this is what I'm doing:
But I'm just getting the current user picture. I guess my problem is with:
Comment #84
michelleYes, that would be the problem.
global $usergets you the user object for the logged in user, which you are then re-loading into the $account variable. You need to load the $account variable with the user object of the person you want the picture for. For that, you need their ID. I can't tell you how to get that without knowing what variables are available to that snippet.Michelle
Comment #85
lelizondo commentedThanks Michelle, I realized that $item has the uid of the user who generated the activity, so:
prints the right picture
Comment #86
likewhoa commentedsubscribing
Comment #87
liliplanet commentedHi lelizondob,
Your screenshot is beautiful and wondering if you perhaps have an updated phptemplate override for 6.x-2.x-dev?
I've tried #75, but has made no difference and presuming it's to do with a newer version.
Look most forward to your reply.
Lilian
Comment #88
Scott Reynolds commentedBecause 2.x uses Views, you should use the Views theme information link to figure out how to theme it. The first step is to add the Activity: User relationship. Then add the User: Picture field. Then you can use the theme: Information to figure out how to theme up the picture. For information on how to theme up Views: http://drupal.org/node/352970
http://skitch.com/supermanscott/dy4ei/picture
You can also look into using: http://drupal.org/project/imagecache_profiles
You also shouldn't write a phptemplate_X function, it should be MY_THEME_X function.
Comment #89
Michsk commentedI've seen a lot of code pass by, this is a solution to get this done trough views.
In the Customfield: PHP code, set the following php code.
In the Activity: Type field, check the Exclude from display option.
Now if you want to add another option, let's say user relationships. You just alter the code in the php code field and add another elseif().
How to know what the activity_type is? Just uncheck the Exclude from display option in the Activity: Type field and it will show what type it is.
Comment #90
youkho commentedSubscribe
Comment #91
thelocaltourist commentedsubscribe
Comment #92
sirkitree commentedclosing. 1.x no longer supported.