Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#157 2011-07-28 07:09:05

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

Re: smd_bio : store additional biographical info about your users

Whoa! Stunned. Ecstatic!

I’ll report once I’ve had a chance to play a bit more.

Offline

#158 2011-08-01 23:04:34

brunodario
Member
From: Belo Horizonte, Brasil
Registered: 2007-09-19
Posts: 75

Re: smd_bio : store additional biographical info about your users

Can´t wait to the public side editing capabilities to be released. I tried a lot of ways to integrate a public side form to smd_bio, allowing users to edit their own data from the public site, with no success. So far so close now. The widget feature may be a north to take (when i first read your instructions i thought that the widget would actually generate a full form, not only the input fields…)
Anyway, has anyone managed to do something at least similar? Any advice (any at all) will be great.

Offline

#159 2011-08-24 06:47:58

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: smd_bio : store additional biographical info about your users

I found this patch quite useful:

@@ -564,7 +564,7 @@
 					$parent = $widget['val'];
 					$val = ($vals && isset($vals[$widget['name']])) ? $vals[$widget['name']] : '';
 					$where = ($parent) ? "category='".doSlash($parent)."'" : '1=1';
-					$tree = safe_rows('*', 'txp_image', $where);
+					$tree = safe_rows('*', 'txp_image', $where. ' ORDER BY name');
 					$selv = array();
 					foreach ($tree as $row) {
 						$selv[$row['id']] = $row['name'];

Offline

#160 2011-08-24 11:40:49

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

Re: smd_bio : store additional biographical info about your users

wet wrote:

I found this patch quite useful:

Good call, thanks. Fixed and beta download updated.


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

#161 2011-08-25 07:48:11

milosevic
Member
From: Madrid, Spain
Registered: 2005-09-19
Posts: 390

Re: smd_bio : store additional biographical info about your users

brunodario dijo:

Can´t wait to the public side editing capabilities to be released. I tried a lot of ways to integrate a public side form to smd_bio, allowing users to edit their own data from the public site, with no success. So far so close now. The widget feature may be a north to take (when i first read your instructions i thought that the widget would actually generate a full form, not only the input fields…)
Anyway, has anyone managed to do something at least similar? Any advice (any at all) will be great.

This is my “under construction” code for editing user data at de front and it runs ok with smd_bio v0.31 (not with v0.4) ….but now I will wait for v0.4 in order to simplify this terrible form. Lots of thanks Stef :-D

<h2>My personal data</h2>


<txp:mem_simple_form table="smd_bio" id_field="user_ref" id_insert="0">
<txp:mem_form_secret name="string_user_ref" value='<txp:mem_profile var="name" />'/>
<div class="campo"><txp:mem_form_text name="string_tipo" default=''<txp:mem_profile var="name" />' label="Tipo" required="1" break="" class="dato"/></div>
<div class="campo"><txp:mem_form_select name="string_pais" delimiter="," items="España,otros" values="Spain,Others" selected='<txp:smd_bio_info author=''<txp:mem_profile var="name" />'' items="pais" label="" />' label="País" break="" class="dato"/></div>
<div class="campo"><txp:mem_form_select name="string_provincia" delimiter="," items="No resido en España,A Coruña,Álava,Albacete,Alicante,Almería,Asturias,Ávila,Badajoz,Barcelona,Burgos,Cáceres,Cádiz,Cantabria,Castellón,Ceuta,Ciudad Real,Córdoba,Cuenca,Girona,Granada,Guadalajara,Guipuzcoa,Huelva,Huesca,Illes Balears,Jaén,La Rioja,Las Palmas,León,Lleida,Lugo,Madrid,Málaga,Melilla,Murcia,Navarra,Ourense,Palencia,Pontevedra,Salamanca,Santa Cruz de Tenerife,Segovia,Sevilla,Soria,Tarragona,Teruel,Toledo,Valencia,Valladolid,Bizkaia,Zamora,Zaragoza" values=",A CORUÑA,ALAVA,ALBACETE,ALICANTE,ALMERIA,ASTURIAS,AVILA,BADAJOZ,BARCELONA,BURGOS,CACERES,CADIZ,CANTABRIA,CASTELLON,CEUTA,CIUDAD REAL,CORDOBA,CUENCA,GIRONA,GRANADA,GUADALAJARA,GUIPUZCOA,HUELVA,HUESCA,ILLES BALEARS,JAEN,LA RIOJA,LAS PALMAS,LEON,LLEIDA,LUGO,MADRID,MALAGA,MELILLA,MURCIA,NAVARRA,OURENSE,PALENCIA,PONTEVEDRA,SALAMANCA,SANTA CRUZ DE TENERIFE,SEGOVIA,SEVILLA,SORIA,TARRAGONA,TERUEL,TOLEDO,VALENCIA,VALLADOLID,VIZCAYA,ZAMORA,ZARAGOZA" selected='<txp:smd_bio_info author=''<txp:mem_profile var="name" />'' items="provincia" label="" />' label="Provincia" break="" class="dato"/></div>
<div class="campo"><txp:mem_form_text name="string_localidad" default='<txp:smd_bio_info author=''<txp:mem_profile var="name" />'' items="localidad" label="" />' label="Localidad" break="" class="dato"/></div>
<div class="campo"><txp:mem_form_text name="string_direccion" default='<txp:smd_bio_info author=''<txp:mem_profile var="name" />'' items="direccion" label="" />' label="Dirección" break="" class="dato"/></div>
<div class="campo"><txp:mem_form_text name="string_cp" default='<txp:smd_bio_info author=''<txp:mem_profile var="name" />'' items="cp" label="" />' label="Código Postal" break="" class="dato"/></div>
<div class="campo"><txp:mem_form_text name="string_telefono" default='<txp:smd_bio_info author=''<txp:mem_profile var="name" />'' items="telefono" label="" />' label="Teléfono" break="" class="dato"/></div>
<br />
<txp:mem_form_submit />
</txp:mem_simple_form>

Last edited by milosevic (2011-08-28 07:08:29)


<txp:rocks/>

Offline

#162 2011-09-20 15:05:42

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 573
Website GitHub

Re: smd_bio : store additional biographical info about your users

Hi stef,

I’m currently playing around with your smd_bio. I had some difficuties to set cyrillc and arabic chars in the meta fields. By an export of the database I found that smd_bio smd_bio_meta (and other smd_ tables) are created with CHARSET=latin1 and not utf8 as the other Textpattern tables.

That’ strange!

Is that intentional and I have missed something?

Offline

#163 2011-09-20 15:11:06

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

Re: smd_bio : store additional biographical info about your users

trenc wrote:

By an export of the database I found that smd_bio smd_bio_meta (and other smd_ tables) are created with CHARSET=latin1 and not utf8 as the other Textpattern tables…. Is that intentional and I have missed something?

Uhhh, it’s not intentional. I just thought a CREATE TABLE would use the current charset in force for the DB. Guess not and I should be more careful in my SQL CREATE statements to define the charset expliticly.

Thanks for spotting it. I fixed smd_tags to switch it over to UTF-8 on upgrade so I can probably apply the same fix here before official release.


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

#164 2011-12-07 20:38:36

whaleen
Member
From: Portland
Registered: 2006-05-11
Posts: 373
Website

Re: smd_bio : store additional biographical info about your users

Bloke wrote:

…before official release.

Any sort of pre-release, might-do-what-it-will-well-enough, maybe-will-explode, super-beta? :) I’m in a might-explode-phase of a project so I could help report explosions. I’m running v0.40 now but am referring to a public-side-editing-capable beta version as typing out some of the mem_form related stuff to do this can make your eyes say yikes.

Don’t feel obligated to reply in a hyphenated sort-of-way unless that is fun for you too.


txtstrap (Textpattern + Twitter Bootstrap + etc…)

Offline

#165 2011-12-08 00:11:02

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

Re: smd_bio : store additional biographical info about your users

whaleen wrote:

Any sort of pre-release, might-do-what-it-will-well-enough, maybe-will-explode, super-beta?

You’re in luck. I was working on the mem_form side of things on Monday and had it poised for action, then got waylaid by stuffing more features into yab_shop.

I’ve just uploaded the bleeding edge beta and it’s a cracker. No docs yet but the general idea is this:

Step 1: install mem_form.
Step 2: Set up one of these containers:

  • <txp:mem_form type="smd_bio">
  • <txp:mem_self_user_edit>
  • <txp:mem_self_register>

Step 3: Inside the containers you can use regular mem_form tags if you want to update the txp_user / ign_user tables, and/or use <txp:smd_bio_data field="some_field" type="widget" /> to render input fields for your bio items. Remember to wrap a <txp:smd_bio_info> tag around them.

Step 4: Add a <txp:mem_submit /> to the form
Step 5: Take a look at your HTML form in the browser. Edit details, hit save and the data will be stuffed into the correct tables.

An example:

<txp:rvm_if_privileged>

<txp:mem_form type="smd_bio">
   <txp:smd_bio_info>
      <br /><txp:smd_bio_data field="RealName" item="title, widget" break=": " />
      <br /><txp:smd_bio_data field="phone" item="title, widget" break=": " />
      <br /><txp:smd_bio_data field="cell" item="title, widget" break=": " />
      <br /><txp:smd_bio_data field="biog" item="title, widget" break=": " />
   </txp:smd_bio_info>
   <txp:mem_submit />
</txp:mem_form>

<txp:else />
Go away
</txp:rvm_if_privileged>

A few caveats:

  1. Remember that to successfully work on a bio you need an author name. Thus you must either:
    1. be logged in and have $txp_user set
    2. be editing an individual article and wrap <txp:smd_bio_articles> around the <txp:mem_form>
    3. wrap <txp:smd_bio_author> around the <txp:mem_form>
  2. There’s no concept of ‘required’ fields (yet)
  3. Similarly the fields aren’t validated yet either

If you can live with those limitations then by all means take it for a spin and let me know how you get on.

Last edited by Bloke (2011-12-08 00:12:38)


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

#166 2011-12-08 17:47:59

whaleen
Member
From: Portland
Registered: 2006-05-11
Posts: 373
Website

Re: smd_bio : store additional biographical info about your users

Bloke Wrote:

wrap <txp:smd_bio_author> around the <txp:mem_form>

Thusly:

<h3>Profile Information</h3>

	<txp:smd_bio_author author='<txp:cbe_frontauth_whois type="name" />'>

	<txp:mem_form type="smd_bio">
		<txp:smd_bio_info>
			<txp:smd_bio_data field="RealName" item="title, widget" break=": " />
			<txp:smd_bio_data field="email" item="title, widget" break=": " />
			<txp:smd_bio_data field="EtCetera" item="title, widget" break=": " />
		</txp:smd_bio_info>
	<txp:mem_submit />
	</txp:mem_form>

	</txp:smd_bio_author>

The above works great. Note: cbe_frontauth is working well for me as a replacement for the rvm and ign methods previously necessary.

Bloke Wrote:

2. be editing an individual article and wrap <txp:smd_bio_articles> around the <txp:mem_form>

What would a form for “editing an individual article” look like? I’m using mem_public_article now — and attempting to hack together the forms for a logged user to:

  1. Manage Stuff: create, edit, alter status, delete (‘hidden’ may be used and labeled trash…) Articles.
  2. Have Identity Crisis: change bio info. Check! And how great it is to have unlimited bio fields in the game.

I’m all set in the Bio Realm, thanks ever so much to your hard work, but now for narrowing down the ‘Manage Stuff’ aspect for my imaginary users. Am I mistaken in assuming “editing an individual article” is work smd_bio can help with, despite it’s name?


txtstrap (Textpattern + Twitter Bootstrap + etc…)

Offline

#167 2011-12-08 17:54:47

whaleen
Member
From: Portland
Registered: 2006-05-11
Posts: 373
Website

Re: smd_bio : store additional biographical info about your users

One tiny thing I’ve noticed: Per a bio field: <txp:smd_bio_data field="hasemptyvalue" item="title, widget" break=": " /> which has nothing entered in already in the db, the text field does not appear. So if there are parts of a user bio that have not been supplied one cannot add that unless they or I were to go in through /textpattern and get it set. Once set, it all works fine for updates of course.


txtstrap (Textpattern + Twitter Bootstrap + etc…)

Offline

#168 2011-12-08 23:05:29

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

Re: smd_bio : store additional biographical info about your users

whaleen wrote:

The above works great.

Ace!

cbe_frontauth is working well for me as a replacement for the rvm and ign methods

Yep, a great match for this kind of thing.

What would a form for “editing an individual article” look like? <snip> Am I mistaken in assuming “editing an individual article” is work smd_bio can help with, despite it’s name?

Ah, hang on. Crossed wires I think: mea culpa. What I meant was that if you are viewing an individual article, smd_bio is set to (errr, supposed to: must check!) automatically read the author from the current article. This is so you can display bio information in an “about the author of this article” box without much fuss.

Now, if the person viewing the article was actually the author of the piece then you could alter the “about this author” box to contain edit fields so the author could make profile changes directly on that page, instead of visiting a “Your profile” page as a separate step. You could use (and sounds like you are using) mem_public_article on the same page so they could edit the article alongside. But smd_bio is coded to only target the txp_users and smd_bio tables so, no, it won’t offer any help on the article side of things.

a bio field which has nothing entered in already in the db, the text field does not appear

Ahem, I kind of half spotted this yesterday but didn’t get round to investigating fully before I threw the code out there. I’ll check it.

The aim is that using show_empty="1" in your surrounding <smd_bio_info> tag enables you to show missing fields or empty content. Not sure if it’s working how I intended though so I’ll give it a grilling, thanks for reminding me.

EDIT: actually, it was me being made of pork products when I tested this last night: I’d made a typo in my form. I just tried it with show_empty="1" and it works OK so please let me know if it works for you.

Last edited by Bloke (2011-12-08 23:12:50)


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