Hi,
In this thread -- http://drupal.org/node/32059 -- I was looking for a way to list the posts of a given user for a particular flexinode content type. When I found out that the feature is non-existent, I decided to take the matter into my own hands and created a module which I'm calling flexilist. :)
This is my first module and I learned a lot tinkering with the blog and flexinode modules, from which most of flexilist's functions are patterned/swiped. :)
Half of the time, I don't know what's happening in flexilist, but the good news is that it works. :)
So here are the features of flexilist:
1) Given a node of a certain flexinode type -- teaser of full view -- it creates, at the bottom of the node, a link to all the user's posts in that flexinode type. The link's format is flexilist/ctype_id/uid where ctype_id is the content type id, and uid is the user's id (both numbers).
2) When you click on the aforementioned link, a teaser list of all the user's posts in that flexinode content type is displayed, including an rss feed for this particular list.
Other notes:
In the teaser list itself, the link still appears in each node. I don't know how to address the quirk, but perhaps somebody out there can teach me how to make the link disappear.
This one's addressed to Drupal programming newbies like me -- the module uses a couple of functions from the flexinode module.
I don't know much about security issues in modules, so any comments or mentorship would be greatly appreciated. :)
That's about it. Hope this module helps some of you, guys. :)
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | flexilist_0.module | 4.33 KB | noid |
| flexilist.module | 3.59 KB | noid |
Comments
Comment #1
sethcohn commentedNice... looks like it could use a little cleanup in places, and it requires using flexinode ctype #'s instead of names, but those can be added to improve this.. Good job for a first attempt!
Comment #2
noid commentedThanks, Seth! Enjoyed creating the program although the cache -- http://drupal.org/node/32813 -- gave me problems, at first. :)
Re ctype #'s, do you mean the url?
Comment #3
sethcohn commentedre: Ctype #s, yes.... in other words, correct me if I'm wrong:
means that you must put the # of the flexinode in instead of the name...
(The output is smart though, and puts out the name of the flexinode using $ctype->name
It would be nice (and should be fairly trivial) to allow using the
name and just look up which ctype_id that is, if it's not a number already.
Same with uid and username.... allow either...
http://drupalexamplesite/flexilist/1/1 is fairly meaningless....
But I know that the flexinode-1 is named 'review' and user #1 is webmaster
then http://drupalexamplesite/flexilist/review/webmaster is a nicer url
path aliases might allow this.... haven't tried that yet...
It's a nitpick, not a flaw in the code.
Comment #4
Marandb commentedAwesome module. This just happens to be exactly what I was looking for.
One question, instead of seeing the link to the list in the "links" portion of the page, is there a way I can call up some code, (PHP placed somewhere on the page) to get the link?
Reason being, is that I have taken out the links section of my node.php.tpl.
Thanks again, awesome work.
-- Marand B.
Comment #5
noid commentedSeth,
Aok. :) The content type name part of your feature request can be implemented, but I think the module will need further work. Regarding the user name part, am not sure because user names can be more than one word. Am sticking for the moment with the current url format since the module will need overhauling for the url's to be more meaningful. What's important right now is that the module works. We'll see.:)
Marandb,
Honestly, I don't have any idea -- have tried to think of other ways, but so far I've come up empty. Other more experienced coders might be able to help. At any rate, for the moment, I've included another feature which you might find useful. Using hook_user, one of the content types appear at the user profile, e.g., Literature - view recent literature entries. Have tried adding for all types, but hook_user I think can only return one array of strings, thus only one link (if any of you more experienced programmers know how to iterate through all the flexinode types, would be glad to know :)). Here's the added code (already in the latest attached module file) -- just replace 6 with your desired content type id.
/**
* Implementation of hook_user().
*/
function flexilist_user($type, &$edit, &$user) {
$ctype_id = 6;
$ctype = flexinode_load_content_type($ctype_id);
if ($type == 'view' && user_access('access content', $user)) {
return array(t('History') => form_item(t(ucfirst($ctype->name)), l(t("view recent $ctype->name entries"), "flexilist/$ctype->ctype_id/$user->uid", array('title' => t("Read %username's latest $ctype->name entries.", array('%username' => $user->name))))));
}
}
Also added hook_help for the admin/modules part so that the module description is included. :)
Comment #6
Marandb commentedLooking Great! I just added your latest revision & it works well. Just wanted to mention again that this is EXACTLY what I have been looking for.
A few questions concerning the new feature:
1) Is it possible / how would one add another hook for an additional flexinode type?
2) Is it possible to change where on the user profile page the flexinode links appear? (This may be more of a theming issue)
I am not a coder by any means, but let me know if I could help out testing anything. www.minifigcustomizationnetwork.com
Thanks again.
-- Marand B.
Comment #7
noid commentedMarand,
Your reply reminded me that I figured this out before I went to sleep. Thanks. :)
Just create another module. For example say you have a "review" content type, then create review.module with hook_user as the code. Review.module would have the following code (say, with 7 as content type id):
The only way I know is to change the category -- that is change 'History' to say 'User Content.' It will create another category in another part of the profile page.
Comment #8
Bèr Kessels commentedPlease do not post new modules as patches. Provide them as modules in the CVS contrib instead!
Comment #9
noid commentedHi Ber,
Sorry about that. When I was creating the module, my immediate goal was just to create a quick and dirty solution, so to speak, and didn't have the time to study how to format the code of a module nor how to contribute to the CVS. And I'm not even sure if I'll have the time to study now. But who knows. :)
Comment #10
noid commentedHi Ber,
Sorry about that. When I was creating the module, my immediate goal was just to create a quick and dirty solution, so to speak, and didn't have the time to study how to properly format the code of a module nor how to contribute to the CVS. And I'm not even sure if I'll have the time to study now. But who knows. :)