Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#145 2011-07-14 17:04:18

stephan
Plugin Author
From: Bochum, Germany
Registered: 2004-07-26
Posts: 196
Website

Re: smd_bio : store additional biographical info about your users

Thanks, I got the update. Actually it was michaelkpate who should get all the credit for finding this bug :-)


Yoko for Textpattern – A free blog themeMinimum Theme – If all you want to do is write.
Note: I am currently not actively using Textpattern, so I am not in the forums very often

Offline

#146 2011-07-14 18:51:27

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: smd_bio : store additional biographical info about your users

stephan wrote:

Actually it was michaelkpate who should get all the credit for finding this bug

Oki doke. BTW, when I said earlier about using smd_if_bio, I broke my own rules. smd_if_bio goes inside an smd_bio_info tag.


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

#147 2011-07-25 12:11:25

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: smd_bio : store additional biographical info about your users

Stef,

How might I setup a conditional output for a given field (e.g., inside of an article form output).

E.g., let’s say I’m collecting Linkedin profile URLs and Twitter IDs. But not everyone uses both. So when outputting, there needs to be a conditional so that that if data doesn’t exist, it’s not showing anything.

Here’s how the form code looks at the moment, with the social links at bottom that need to be conditional somehow. I’m trying to get my head around using a variable condition, but not sure that will work, or if so how…

<div id="bio-list">
  <txp:smd_bio_info fields="url_only_title, headshot" label="">
   <a href="<txp:site_url /><txp:section name='board' />/{smd_bio_url_only_title}" title="Profile link">
      <img class="hs" src="<txp:site_url />images/{smd_bio_headshot}.jpg">
   </a>
  </txp:smd_bio_info>
</div><!-- end bio-list -->

<h2><a href="<txp:site_url /><txp:section />/<txp:article_url_title />"><txp:title /></a></h2>

<txp:smd_bio_info fields="iabc_fr_affil" label="">
   <p>{smd_bio_iabc_fr_affil}</p>
</txp:smd_bio_info>

<txp:body />

<txp:smd_bio_info fields="linkedin, twitter" label="">
   <p><a href="{smd_bio_linkedin}">Linkedin profile</a></p>
   <p><a href="http://twitter.com/{smd_bio_twitter}">Twitter</a></p>
</txp:smd_bio_info>

Offline

#148 2011-07-25 12:18:30

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: smd_bio : store additional biographical info about your users

Destry

Look up a few posts :-p

Try:

<txp:smd_bio_info fields="linkedin, twitter" label="">
   <txp:smd_if_bio field="linkedin">
      <p><a href="{smd_bio_linkedin}">Linkedin profile</a></p>
   </txp:smd_if_bio>
   <txp:smd_if_bio field="twitter">
      <p><a href="http://twitter.com/{smd_bio_twitter}">Twitter</a></p>
   </txp:smd_if_bio>
</txp:smd_bio_info>

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

#149 2011-07-25 12:27:44

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: smd_bio : store additional biographical info about your users

Arg! Sorry… It’s even in the doc. / flogging myself /

Offline

#150 2011-07-25 13:04:54

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: smd_bio : store additional biographical info about your users

Hmm. Conditional is working great in relation to the single article form, but not the list article form (per example above), which seems not to be recognizing the conditional. Same conditional code in both forms. Nothing looks visibly out of place in the list form….

I’ll try looking at it later with fresh eyes.

Offline

#151 2011-07-25 13:11:26

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: smd_bio : store additional biographical info about your users

Destry wrote:

not the list article form

Odd.

Stab-in-the-dark: you are pulling out the twitter and linkedin fields into your smd_bio_info tag, right?

<div id="bio-list">
  <txp:smd_bio_info fields="url_only_title, headshot, linkedin, twitter" label="">
...

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

#152 2011-07-25 13:16:47

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: smd_bio : store additional biographical info about your users

Not the first instance of it (like you’re showing there), but I am in the instance where the conditionals come into play, just like in you’re previous code suggestion.

Should I put them in the first instance?

Offline

#153 2011-07-25 13:25:38

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: smd_bio : store additional biographical info about your users

Destry

Ah, ok, no ignore my suggestion: that’s just me being stupid. So that form up there is your entire list form?

In which case it is odd: if it’s pulling out the headshot and other bio info correctly above the <txp:body />, then it should also do the same with the bio info below it. Can you do me a favour and throw debug="1" in either of the <txp:smd_if_bio> conditionals and see what you get back. You should see an array with the data in it if the relevant field exists, and should see an empty array() for those people in which it’s missing. If you can post some sample output (obfuscated of course) then that might help me pinpoint the problem. Ta.


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

#154 2011-07-25 13:47:25

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: smd_bio : store additional biographical info about your users

I get something curious, actually. I’ll send you an email cause it’s full of privvy data, but here’s what I’m seeing.

There’s an instance of one guy who does not have a Twitter ID. That should be an empty array. But, in fact, it’s showing up with a Twitter value that belongs with another account; so the twitter ID is showing in to two places even thought it’s not really like that in their account profiles.

I have a sneaking suspician it’s due to the Twitter field title I used.

Email coming.

Last edited by Destry (2011-07-25 13:48:37)

Offline

#155 2011-07-25 14:23:30

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: smd_bio : store additional biographical info about your users

Thanks Destry. Bug confirmed. New beta for anyone using the current version.


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

#156 2011-07-27 23:41:47

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: smd_bio : store additional biographical info about your users

I know I promised to release v0.40 in tandem with smd_user_manager but I dont have time right now to polish it so here’s yet another beta.

It now integrates more smoothly with smd_user_manager (there’s a beta of smd_prognostics v0.20 available as well to go with this) and I’ve begun work on an experimental feature for capturing data from the public side.

The following holds true about this version of the plugin:

  • Without smd_user_manager, only Publishers can edit a user’s Bio from the admin side
  • With smd_user_manager, individual users are given access to their bio data on the admin side
  • With smd_tabber and mem_form you can create your own custom interface for administering bio data on either the admin or public sides (although it’s not easy)

This latest beta introduces a new item type to <txp:smd_bio_data> (or replacement tag): item="widget". So this, slightly wordy code:

<txp:smd_bio_info show_empty="1">
   <br /><txp:smd_bio_data field="department" item="title" />
   : <txp:smd_bio_data field="department" item="widget" />
   <br /><txp:smd_bio_data field="jobtitle" item="title" />
   : <txp:smd_bio_data field="jobtitle" item="widget" />
</txp:smd_bio_info>

will render labels for the department and jobtitle fields, and alongside those items it will put input fields to allow them to be edited. The default value of the input fields will be set to whatever the current values are (I’m considering allowing multiple items with a wraptag/class/break to reduce typing bt haven’t got that far yet).

Why not just create your own fields with mem_form, I hear you cry? Well, you could, but you have to get everything just perfect. And you need to know the types of data in advance because they have to be hard coded in the form. Not with smd_bio. It always renders the appropriate type of input control to match the definition of the field on your Bio Config page. If your department is a select list, that’s what you’ll see when you display the widget. If you change it to a radio set, you get those instead.

In theory the output is HTML 5 compliant because it renders things like type="datetime", type="email" and so on. Older browsers will revert to boring type="text" but HTML 5 aware browsers can take advantage of the new input controls and render advanced input features. I’ve not enabled all the types yet (and it still outputs self-closed tags), but you can start to play around a bit.

What this means in practice is undecided. I’m not sure if you can integrate this with mem_form because I think mem_form/mem_simple_form need to be told what fields to expect. And they can only update one table unless you start hooking plugins into the callbacks: smd_bio uses (potentially) two tables which need to be updated simultaneously.

However, you may be able to utilise smd_query to fashion an INSERT based on the values submitted when you hit a Save button you create on the page. While this solution won’t have mem_form’s nonce stuff built in and all the lovely goodness that comes with a Manfre joint, it might be a poor man’s public-side bio editor.

I’ll be exploring ways to improve this over the coming months but I’d be interested to hear how you get on with it. Although the rest of the plugin is beta, the widget stuff is definitely alpha code as I only finished it ten minutes ago. Please report any findings here, as well as ways it could be improved or bugs (I know of one so far: see code) and I’ll see what I can do before v0.40 officially hits the streets.


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

Board footer

Powered by FluxBB