Textpattern Forum

You are not logged in. Register | Login | Help

#11 2009-10-03 21:39:28

PascalL
Member
From: Switzerland
Registered: 2009-03-09
Posts: 132
Website

Re: mem_public_article

Ok, after many trials and errors, here is a working form called by the mem_public_article tag .
All the fields are required and their absence causes errors. The “Section” field is a bit more tolerant, but will cause an error in the write tab later on.

<txp:mem_form_text name="Title" label="Title" />
<br />
<txp:mem_form_textarea name="Body" label="Contenu" /> 
<br />
<txp:mem_form_select name="textile_body" label="Balises d'article" items="Utiliser textile,Convertir les retours à la ligne,Laisser le texte tel quel" values="1,2,3" />
<br />
<txp:mem_form_select name="textile_excerpt" label="Balises de résumé" items="Utiliser textile,Convertir les retours à la ligne,Laisser le texte tel quel" values="1,2,3" />
<br />
<txp:mem_form_text name="Author" label="Auteur" default="invité" /> 
<br />
<txp:mem_form_select_section name="Section" Label="Section" />
<br />
<txp:mem_form_select name="Status" label="Statut" items="Brouillon, En attente de validation,Publié" values="1,3,4" /> 
<br />
<txp:mem_form_submit />

Now, I’d like to find a way to fill some of those fields silently, without presenting them to the users.

Offline

#12 2009-10-03 22:43:50

PascalL
Member
From: Switzerland
Registered: 2009-03-09
Posts: 132
Website

Re: mem_public_article

Now, I’d like to find a way to fill some of those fields silently, without presenting them to the users.

The mem_form_secret tag does it. Here is the modified minimal form:

<txp:mem_form_text name="Title" label="Title" />
<br />
<txp:mem_form_textarea name="Body" label="Content" /> 
<br />
<txp:mem_form_text name="Author" label="Auteur" default="guest" />
<br />
<txp:mem_form_secret name="textile_body" value="1" label="textile body" />
<txp:mem_form_secret name="textile_excerpt" value="1" label="textile excerpt" />
<txp:mem_form_secret name="Section" value="articles" Label="Section" />
<txp:mem_form_secret name="Status" value="3" label="Status" /> 

<txp:mem_form_submit />

Keep in mind this doesn’t allow to reuse the same title between articles. It is probably better to fill the url_title field with a unique id. Still have to figure out how.

Last edited by PascalL (2009-10-03 22:53:34)

Offline

#13 2009-10-04 00:47:11

uli
Moderator
From: Cologne/Köln
Registered: 2006-08-15
Posts: 3,085

Re: mem_public_article

Thanks for sharing what you found out, Pascal! I’m sure I can make use of this one day.

PascalL wrote:

It is probably better to fill the url_title field with a unique id. Still have to figure out how.

<txp:variable name="new_id" value='<txp:article_custom sort="ID desc" limit="1"><txp:article_id /></txp:article_custom>' />
<txp:mem_form_secret name="url_title" value='<txp:adi_calc name="new_id" add="1" />' label="url_title" />

At least something along these lines. Please note I haven’t worked yet with neither of these plugins, so the exact values or appliance may be different, but one way or another this might help you.

Last edited by uli (2009-10-04 00:51:46)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#14 2009-10-04 12:54:48

PascalL
Member
From: Switzerland
Registered: 2009-03-09
Posts: 132
Website

Re: mem_public_article

Hi Uli, thanks for your idea!

same with some corrections:

<txp:variable name="new_id" value='<txp:article_custom sort="ID desc" limit="1"><txp:article_id /></txp:article_custom>' />

<txp:adi_calc name="new_id" add="1" />

<txp:mem_form_secret name="url_title" value='<txp:variable name="new_id" />' label="url_title" />

Sadly, this only works if the posted articles are set to live. txp:custom tag doesn’t provide a way to list pending, draft nor hidden articles ! At least that I know of. The consequence is that the article ID is retrieved from the latest live article, and if two outsiders post in a row, the url_title is no more unique ! And naturally I can’t let the users post live articles without moderation.

Last edited by PascalL (2009-10-04 12:56:40)

Offline

#15 2009-10-04 14:30:08

PascalL
Member
From: Switzerland
Registered: 2009-03-09
Posts: 132
Website

Re: mem_public_article

Ideally I would fill the url_title field with the Title field and something after, the date for example. For that, the Title should be normalized, i.e uppercase changed to lowercase and special characters removed. I’ve found the mem_filter plugin which helps for letter-case. But that’s not sufficient (still have to test it though).
Have an idea?

P.S: sad , mem_filter is not available anymore

Last edited by PascalL (2009-10-04 14:34:11)

Offline

#16 2009-10-04 15:07:12

Manfre
Plugin Author
From: North Carolina
Registered: 2004-05-22
Posts: 588
Website

Re: mem_public_article

An easier option would be to use javascript to set a mem_form_hidden field.

mem_filter

Offline

#17 2009-10-04 15:30:34

PascalL
Member
From: Switzerland
Registered: 2009-03-09
Posts: 132
Website

Re: mem_public_article

Thanks a lot Manfre!

aarrrh it’s a pain to admit I can’t do javascript :D
btw I’m not far from a solution, I’m sure I’ll find out.
I’ll try mem_moderation_article too, but I’m not sure to understand if it works with non-registered contributors.
The project is aimed at absolutely non-techies folk, therefore I try to make article posting as easy as possible. I’m glad this is possible, thanks to your plugins !!!

Offline

#18 2009-10-04 17:07:16

Manfre
Plugin Author
From: North Carolina
Registered: 2004-05-22
Posts: 588
Website

Re: mem_public_article

mem_moderation_article will work, but it’s not possible to bypass the moderation queue.

Offline

#19 2009-10-04 20:58:45

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 1,914
Website

Re: mem_public_article

An easier option would be to use javascript to set a mem_form_hidden field.

aarrrh it’s a pain to admit I can’t do javascript :D

With jquery you can do something like the following.

First in your form you need a mem_form_hidden field behind your regular title entry as Michael suggests:

	<txp:mem_form_text name="Title" label="Title" required="1" />
	<txp:mem_form_hidden name="url_title" value="" label="" />

Then in your page template, link to jquery.js and then do something along these lines:

$(document).ready(function()
{
    $("form").submit(function() {

          $("input[name=url_title]").val($("#Title").val());

    });

});

This intercepts the form submission when you click the button, grabs the value you entered in Title field and sticks it into the empty hidden form element called url_title. If your form elements are named differently, you’ll need to change them accordingly.

Between the two you still need to filter the url. There’s this that will do the equivalent of the php htmlspecialchars function with js and a quick google turned up this promising-looking make safe url function in javascript which may produce an url title along the lines of txp’s own. If it’s not quite right, the function dones’t look too hard to modify. You’ll need to include the makeSafe function in your HEAD area (or put in a file and link it), then replace the line above with these two:

          var clean_url  = makeSafe($("#Title").val());
          $("input[name=url_title]").val(clean_url);

I’ve not tested this precise setup but successfully done something similar before.


TXP Builders – finely-crafted code, design and txp

Offline

#20 2009-10-04 22:09:02

Manfre
Plugin Author
From: North Carolina
Registered: 2004-05-22
Posts: 588
Website

Re: mem_public_article

If url_title is empty on post, the plugin will follow the txp behavior of converting the title. The javascript bit is only needed if you want something other than just the standard url_title.

Offline

Board footer

Powered by FluxBB