Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: smd_bio : store additional biographical info about your users
Hello Stef,
I have this very simple question: How do I output the value for a radio button as, Choice A, where the first letter is uppercased and a space between the two words. This value is defined as this the bio config tab. I know the plugin strips out white spaces and returns values in lowercase. I also tried to define special labels with the use of ch1 => Choice A.
No way for it to output, Choice A.
Any glue ?
Thanks !
Last edited by hablablow (2010-10-13 15:05:03)
_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__
Offline
Re: smd_bio : store additional biographical info about your users
hablablow wrote:
No way for it to output, Choice A.
If you mean on your web site then yes there’s a way. Use the {replacement}
variables for this.
For example, if you had a bio item that you defined like this:
Name: contact
Title: Preferred contact mechanism
Type: Radio set
Value: email => E-mail, phone => Landline, cell => Mobile phone[*], post => By post
Then you can use the following code:
<txp:smd_bio_info items="contact">
{smd_bio_info_title}:
<ul>
<li>{smd_bio_contact_label_1}</li>
<li>{smd_bio_contact_label_2}</li>
<li>{smd_bio_contact_label_3}</li>
<li>{smd_bio_contact_label_4}</li>
</ul>
</txp:smd_bio_info>
Which would display this:
Preferred contact mechanism:
- Landline
- Mobile phone
- By post
Is that what you want? I admit that using numbers isn’t the most intuitive way of doing things and I’ll address this (with some more goodies) in future.
Last edited by Bloke (2010-10-13 15:47:20)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: smd_bio : store additional biographical info about your users
Ok Stef it’s perfectly working with:
<txp:smd_bio_info items="w1" label="">{smd_bio_w1_chosen_label_1}</txp:smd_bio_info>
One last thing that is not implemented in your plugin yet:
Would it be possible in another version to be able to add multiples values in the form of
opt1 => red:green:black, opt2 => small:large:extralarge
And then extract these values, for example with the help of:
<txp:smd_bio_info items="w1" label="">{smd_bio_w1_chosen_label_1:3}</txp:smd_bio_info>
Where :3 would pick the third value, black, in the example above…
Does it make sense ?
Thanks again for your help.
_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__
Offline
Re: smd_bio : store additional biographical info about your users
Ok Stef I’m done with the topic above and the previous one by using:
Name: fruits
Title: prefered fruits
Type: Radio set
Value: yellow => bananas, red => apples, green => kiwis
<txp:variable name="tryit" value='<txp:if_variable name="fruits" value="bananas">Try some apples as well</txp:if_variable>
Thanks for this one and the whole menagerie, they add so much flexibility.
Last edited by hablablow (2010-10-14 11:36:01)
_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__
Offline
Re: smd_bio : store additional biographical info about your users
Stef,
Is there any reason why I couldn’t create a second email field (e.g., “encoded_email”) as a textarea and add a Javascript snippet from Enkoder (producing an encoded email link to use on frontside)?
Offline
Re: smd_bio : store additional biographical info about your users
Destry wrote:
Is there any reason why I couldn’t create a second email field (e.g., “encoded_email”) as a textarea and add a Javascript snippet from Enkoder
Hmmm, to what end? So people can see their own encoded e-mail address on the Admin->Users panel? If so, you won’t be able to attach the JS to the field at creation time (Bio Config) but you could write an admin-side hook (plugin) to key off the e-mail field in Admin->Users and populate the encoded_mail field either on submit or in real-time (depending on JS capabilities).
The other approach is to do it at output time. In other words they enter their e-mail address as normal on the admin side but as you do a <txp:smd_bio_info />
on that field, run it through some code to obfuscate it first.
All depends on what you’re trying to achieve. Bottom line: it’s probably doable but not natively in the plugin.
Last edited by Bloke (2010-11-15 12:16:41)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: smd_bio : store additional biographical info about your users
Mmmm… That’s not exactly the objective. (BTW, I’m getting no output whatsoever when trying this, but it could be any number of things I’m doing wrong.)
I want to have a contacts table (replacing the contacts web form) that outputs the following information:
- Role
- Name
- Email (encoded)
- Enquiry type (the kinds of things this person addresses)
- Twitter handle
A sample record would look like:
President | Jon Doe | Contact (enKoded email) | (enquiry types) | (twitter handle)
Role and Enquiry types are just text (no links). The name would be a link to the persons profile (bio) article. The “Contact” link is the encoded email link (Enkoder allows for defining the link label in the js snippet too). Twitter handle will be a link to the relevant twitter account. All of these data are defined in smd_bio for each user. For the “email_encoded” field, it’s a textarea and the whole js snippet as output from Enkoder is pasted in, which is the same, in principle, as I would use it if just directly in a page template.
The context by which I’m pulling the individual user’s data is by the team profile articles, thus why I’m trying an article form at the moment. This might be where things go wrong too, because those articles are actually assigned to a different section. I’m trying to pull their associated data here via a category, but maybe I can’t do that?
Page code:
<div id="contacts">
<txp:smd_bio_info items="teamrole,bioid,urltitle, RealName,email_encoded,enquiry_types,twitter">
<table>
<tr>
<th>Role</th>
<th>Profile</th>
<th>Email</th>
<th>For enquiries about...</th>
<th>Twitter</th>
</tr>
<txp:article_custom category="team" form="contacts-list" />
</table>
</txp:smd_bio_info>
</div>
The pull is the <txp:article_custom category="team" form="contacts-list" />
.
Article Form code:
<tr>
<td><txp:smd_bio_info author='{smd_bio_info_item}' items='teamrole' label='' /></td>
<td><a href="<txp:site_url /><txp:section name='leaders' />/<txp:smd_bio_info author='{smd_bio_info_item}' items='bioid' label='' />/<txp:smd_bio_info author='{smd_bio_info_item}' items='urltitle' label='' />" title="Bio link"><txp:smd_bio_info author='{smd_bio_info_item}' items='RealName' label='' /></a></td>
<td><txp:smd_bio_info author='{smd_bio_info_item}' items='email_encoded' label='' /></td>
<td><txp:smd_bio_info author='{smd_bio_info_item}' items='enquiry_types' label='' /></td>
<td><txp:smd_bio_info author='{smd_bio_info_item}' items='twitter' label='' /></td>
</tr>
Last edited by Destry (2010-11-15 13:21:13)
Offline
Re: smd_bio : store additional biographical info about your users
LOL! I“m looking at the smd_bio code I posted and wondering, what the hell? Let me see if I can clean that up. That would at least be one thing to fix. / shaking head /
=================
OK, maybe it wasn’t so whacked as I thought, but I think I did forget to put this in the opening tag of the container… items="teamrole,bioid,urltitle, RealName,email_encoded,enquiry_types,twitter"
If I understand the docs correctly. Now added to code above.
=================
Well whether or not the items=""
attribute was a problem, I’m still not getting output. I’m guessing it has something to do with the article form tag. I’ll keep poking.
Last edited by Destry (2010-11-15 13:28:54)
Offline
Re: smd_bio : store additional biographical info about your users
Slowly zeroing in, I think.
I realized I didn’t need to have the smd_bio container tags set so wide, so I focused them down directly on the article_custom tag…
<!-- Begin content -->
<div id="contacts">
<p id="section">Contact Us</p>
<table>
<tr>
<th>Role</th>
<th>Profile</th>
<th>Email</th>
<th>For inquires about...</th>
<th>Twitter</th>
</tr>
<txp:smd_bio_info items="teamrole,bioid,urltitle,RealName,email_encoded,enquiry_types,twitter">
<txp:article_custom section="leaders" category="team" form="contacts-list" />
</txp:smd_bio_info>
</table>
</div>
<!-- End content -->
This time the table headers appeared, so it’s clearly something with the plugin or how I have it setup somewhere. Or maybe with that Enkoder js. I guess I should try and remove that field and test next. (Hope that’s not it, though.)
Offline
Re: smd_bio : store additional biographical info about your users
Destry
OK I think I get what you’re doing. And it may be that you have it inside out — which is probably a fault of my documentation and the fact the plugin options are a tad confusing more than anything.
The key thing to note is that <txp:smd_bio_info />
only works on the current author of the individual article unless you override this with the author
attribute. Thus if you’re trying to display a list of people outside an article context you’ll get nothing out.
You can approach it one of two ways.
Method 1: Use SMD_PRIVS to get users of certain roles and iterate over them
<div id="contacts">
<table>
<tr>
<th>Role</th>
<th>Profile</th>
<th>Email</th>
<th>For enquiries about...</th>
<th>Twitter</th>
</tr>
<txp:smd_bio_info author="SMD_PRIVS:1:2:3:4" items="name">
<tr>
<td><txp:smd_bio_info author="{smd_bio_info_item}" items="teamrole" label="" /></td>
<td><a href="<txp:site_url /><txp:section name='leaders' />/<txp:smd_bio_info author="{smd_bio_info_item}" items="bioid" label="" />/<txp:smd_bio_info author="{smd_bio_info_item}" items="urltitle" label="" />" title="Bio link"><txp:smd_bio_info author="{smd_bio_info_item}" items="RealName" label="" /></a></td>
<td><txp:smd_bio_info author="{smd_bio_info_item}" items="email_encoded" label="" /></td>
<td><txp:smd_bio_info author="{smd_bio_info_item}" items="enquiry_type" label="" /></td>
<td><txp:smd_bio_info author="{smd_bio_info_item}" items="twitter" label="" /></td>
</tr>
</txp:smd_bio>
</table>
</div>
Method 2: Use article_custom to get the list of users
<div id="contacts">
<table>
<tr>
<th>Role</th>
<th>Profile</th>
<th>Email</th>
<th>For enquiries about...</th>
<th>Twitter</th>
</tr>
<txp:article_custom category="team">
<tr>
<td><txp:smd_bio_info items="teamrole" label="" /></td>
<td><a href="<txp:site_url /><txp:section name='leaders' />/<txp:smd_bio_info items="bioid" label="" />/<txp:smd_bio_info items="urltitle" label="" />" title="Bio link"><txp:smd_bio_info items="RealName" label="" /></a></td>
<td><txp:smd_bio_info items="email_encoded" label="" /></td>
<td><txp:smd_bio_info items="enquiry_type" label="" /></td>
<td><txp:smd_bio_info items="twitter" label="" /></td>
</tr>
</txp:article_custom>
</table>
</div>
I think the second one is what you want: get a list of articles written by users of the team and display the bios of each person? Although that might duplicate the articles if you have more than one written by a user.
Give something like that a whirl and see if it gets you closer. If the docs are the problem, let me know where the bad bits are and I’ll rewrite them to make it clearer.
Last edited by Bloke (2010-11-15 14:41:04)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: smd_bio : store additional biographical info about your users
That did it. Thanks Stef.
I think my confusion was partly what you observed about iterating over a single author at a time, and partly knowing how to use smd_bio with versions of the article_custom. I went with your latter example; it was close to what I was trying to do.
This is a great plugin, and probably needs richer examples, like maybe this one here, where there’s two ways to solve it in context. The plugin docs, within the plugin, are probably not the best place to get overly demonstrative. Maybe better at your site or in the plugins website, where docs can really be elaborated. That would be my only 2 cents; more demonstrative examples.
Offline
Re: smd_bio : store additional biographical info about your users
Stef,
The plugin seems to be working well in that situation above, but I’m noticing a couple of things:
- If I make a change to a bio data field (specifically those in the scenario previously described at this point), it saves fine in the bio data in admin-side, but does not update in the frontend after a refresh.
- If I edit a default value for a field in the bio field creator/editor (not the user’s account data fields), the edited version appears in the frontend output.
I seem to be able to deal with the first issue by changing something in the related code. I only discovered this by chance from simply messing with my attributes for other reasons. For example in the opening article_custom
tag I can call the relevant articles (from which the bio data is pulled, if I understand that right) by using either section="leaders"
or category="team"
. What I found is that I can refresh the frontend data by switching which of these attributes I use and then save. In other words, if I was using “section”, then I can replace it with the “category” attribute instead (removing section), save the changes in the template, refresh the front-end, it data reflects properly.
For the second issue, that edited default value still appears, but it will clear if I add a true value in the actual user account’s form and run through the funky attribute swap again as described. and only clears if I remove the default value that’s entered in the individual user account (leaving it blank).
But frontend output freezes again between each subsequent edit of the bio data in the admin-side. Strange (thus needing to repeat the swap process).
One other oddity. When I use the Turns out there was a second article (with a different title) in that section, so this is not a oddity as thought.section="leaders"
attribute, one of the user’s data outputs twice in different locations of the contacts table – only one user. This is weird because there is only one account for this user and only one bio article that the data is being referenced from.
Just thought I would pass that along. Maybe I should try the other method of using PRIVS ?
Last edited by Destry (2010-11-16 17:35:19)
Offline