I’ve updated my Va_custom_member plugin to version 2.0, with major new functionality.
The Va_custom_member Plugin has three main functions. First, it outputs the contents of one custom member data field--useful for including inside a weblog:entries tag, for instance. Or a forum template....
Second, It also allows for dynamically selecting categories based on the contents of member custom data.
Third, it will translate a category name into a category id. Useful for weblog entry tags.
To install: expand the download and drop the file in your system/plugin folder. It’s now available for use. You can read the instructions in your admin page/ utilities page and then the plugin manager.
Full instructions are in the plugin page once installed.
Here’s a summary of what this plugin does:
1) First usage
This plugin allows the contents of a member’s custom data field to be output. In a single tag, not a tag pair. This can be anywhere, in any template. That’s right, you can use this in a forum template, too. Ever wish you could output each poster’s custom field on their post? You can now. I’ve included explicit instructions on how to do that as well.
2) This plugin allows you to dynamically select a category based on an equivalent custom member field. In other words, each member’s custom data can control what category your weblog entries field runs.
Consider the value of a category. It’s useful, for sure… but how can you tie a category to each member dynamically? With this function, you can, say, get a list of teams as a category. For instance, lets say you have a weblog that has team news for every NFL team. You can create a category, with each NFL team as a separate category. You can ALSO create the exact same list for a drop-down in the member profile field, as a custom member data field. Members can then select the team they are a fan of. With this function, you can then in your weblog entries tag dynamically assign the category you want displayed based on what team the member chose in their custom member field.
Example: Your site has news about professional American football. You've set up a category group with the names of each professional football team as it's own category. You also set up a custom member field that is a drop down list; each line of the list is the same name as the category you've chosen. One member of your site is a fan of the football team Chicago Bears. They have selected the Bears in their member custom profile data. In your weblog, you have a category for each team name. You have a story for the Bears. With this function, when your member that's a Bears fan visits this template with this weblog entries, this plugin will generate the category that corresponds to the Bears, based on the members custom data. The category is only the Bears, and the weblog tag only shows the Bears category. The next member is a New York Giants fan, and THEY have a category that corresponds to the New York Giants.
This opens up lots of possibilities, clearly.
3)
Third usage: Category name to category ID translation (thanks, Lisa, for the suggestion!)
Your weblog entries tags have to have a category ID to govern category displays, right? Which sucks if you are using category URL names, but on one page you want this to be different. This plugin also will translate your category name into a category ID for the weblog entries tag. It also means you can use any segment of your URL as the category name… or even if the category name feature is turned off, you can still use it sporadically with this plugin. Can be useful sometimes.
I hope this plugin is useful– I think it opens up a powerful set of possibilities for category and member data synchronization, plus forum customization. It’s my first plugin, so I hope I’ve done things right… and let me know, please, of the no doubt numerous errors there are in here. Thanks!
Edit: Added a EE 2 version. Completely untested for the moment, it will no doubt be updated. And it’s updated some
Wow this seems to be really promising and I will definitely will use it for a future project (if we can develop it in EE).
I’ve got one question though: I assume your extension can be used within {exp:weblog:entries} tag as well. If that’s the case it should be possible to compare member-data to custom-weblog-fields. So to take your example: inside my weblog I have a custom field where I could select any of the NFL teams.
Am I correct if I then could use the following bit in my template?
{if {exp:va_custom_member data="field_name"} == "custom_field"}You are a Fan! You really should read this!
{if:else}You're not a fan.. why are you even reading this?
{/if}
An additional question: if the code above is correct, will it work with Mark Huot’s extensions called checkboxes?
Thanks for the questions! As far as I know, it shouldn’t conflict with the checkboxes extension; my plugin does not modify EE in any way. So it should work just peachy with any other plugins, modules, etc. It’s not an extension at all, just to make clear–it’s a plugin. As such, it’s installed in the plugin folder, and installed via the plugin manager in the administration panel… not the extensions panel. Just like any other plugin.
I am fairly confident it works inside the weblog:entries tag; I see no reason why it wouldn’t work like you want it to. If it doesn’t, I’d be surprised. But let me examine your example. Your code would be testing for something like this:
{if "bears" == "custom_field"} You are a fan! You really should read this!
{if:else}You're not a fan.. why are you even reading this?
{/if}
My plugin will be replaced by the value of the data in that custom member field. So, in this case, the {exp:va_custom_member data="field_name"} is replaced by the contents of the field for the member… so if we used data=”team_name”, it would be replaced with “bears” say. So then, in your weblog entries tag, or this if statement, you can test for whether the member selected the team name “bears.”
In other words, your statement should read something like this:
{if {exp:va_custom_member data="team_name"} == "bears"}You are a Fan! You really should read this!
{if:else}You're not a fan.. why are you even reading this?
{/if}
Hope that helps!
Oh, as a note–if the member never selected any data (the field is blank)–this plugin will faithfully show that–it returns an empty string (if the default parameter was not set). Not a Null or anything…. perhaps the next revision will allow a parameter to return a FALSE or something similar in those cases.
If it’s not clear, let me know!
I have added two custom profile fields to my forum - studying and Study_Method and want those to appear in the forums.
I have installed the Va_custom_member plugib and inserted the following code into my forums themes_threads.php template as follows:
Unforunately nothing is returned.
The plugin is working because I can the default to “Not selected” and that appears or set member_id=”x” and get the correct data for member x.
I just wonder if I need to tell it which member to return the data for?
Can anyone help please?
Thanks
Mark
Thanks for trying out my plugin!
This is interesting, I’ve not used this in a forum setting. But you say it works if you set the member_id specifically? Intriguing. I assume that you actually HAVE data in the studying and Study_method custom member fields for this user? I know that I’ve been caught out when I didn’t have any data in my custom member fields.
Okay, you’ll have to use the member_id parameter. Reason being is the plugin in its default state assumes you want the info of the currently logged in user. In a thread setting, you’ll want this to be for each poster’s post, so that will change. So, hmmmmmm. Try using this as a parameter in my plugin: member_id=”{author}” and tell me what happens. Also try it with {author_id} and see what happens. It may just work!
I’ve updated this plugin with a TON of new functionality. Now you can use this in the forum, MagicMarkuk. You now only have to have unique category names within a category group, not totally unique. You can use this plugin to translate category names into category id’s for, say, weblog entry tags.
You can now reset the plugin and use multiple member’s data on a template; you can use the username and not just the member Id anymore. This plugin will, I think, be far more useful.
I’ve edited the first post with the new download. Full instructions and descriptions of how to use it are in the plugin, once installed.
I hope this new version is useful! Please post any questions/bugs etc here!
Is there any way this plugin could spit out multiple categories?
I have this:
–category heading —-sub-heading 1 —-sub-heading 2
And I have a field in the member field which corresponds to the category heading name. When I use the plugin it gives me one category ID number. Perfect.
{exp:weblog:category_archive weblog="proofing" backspace="6" show="{exp:va_custom_member:category data='company_name' auto_format='no'}" parse="inward"}
{categories}
<h3>{category_name}</h3>
{/categories}
{entry_titles}
<a href="http://{path=SITE_INDEX}">{title}</a>
{/entry_titles}
{/exp:weblog:category_archive}
This gives me the one heading, but is there any way to pull out and children ids of the same heading? If so, this would solve alot of problems in an extranet I am trying to build.
OR is there a way that I could assign a category group with the same name as my custom member field? This way I could assign a category group a company_name, then pull this ID number in with the plugin. This would allow me to display multiple categories per member login, instead of limiting it to one category specifically.
Make sense?
Interesting. Right now, this plugin is aimed primarily at a single tag setting; mostly to facilitate much of the purposes of this plugin. Expanding it to an opening/closing tag could be done, I guess.
The second suggestion would fit the plugin better. I’ll see if I can update the plugin with that functionality.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.