Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

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
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
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

#21 2009-10-04 22:52:06

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: mem_public_article

Regarding on how to append a unique ID to the url-title, you could try rvm_counter, which keeps incrementing the count on the server side, that is, on the database.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#22 2009-10-04 23:13:38

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

Re: mem_public_article

Manfre wrote:

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.

Yes, and it’s the reason my minimal form works without url_title input.

My problem comes from duplicate titles. This is for an event calendar, with very similar kinds of events, and I’m sure we’ll see more than one “Dance workshop in Geneva”, well, same in french, but you get the idea ;) When ever this happens, you plugin rightly reports the duplicate url_title.

I just noticed that textpattern has no problem with accented characters and spaces in the article URL field. Everything is passed to the url, via some url encode I suppose. Spaces are replaced by “+”. This is not very elegant, but well… it opens the possibility to use mem_public_article_ps to grab the title.
The only problem left is uppercase letters, that’s where your mem_filter tag comes to the rescue !

This gives:

<txp:mem_form_secret name="url_title" value='<txp:mem_filter name="lcase"><txp:mem_public_article_ps name="Title" /></txp:mem_filter>' label="url_title" />

Now, I just have to append something unique at the end of the title in order to be sure that no duplicates will bite my users; and, as soon as I write this…

maniqui wrote :

Regarding on how to append a unique ID to the url-title, you could try rvm_counter, which keeps incrementing the count on the server side, that is, on the database.

… I have it, thanks Maniqui !

jakob wrote :

With jquery you can do something like the following…

Thank you Jakob ! For now, I feel more at ease doing it serverside. Given that it seems possible, thanks to the power of Manfre’s plugins.

Manfre wrote :

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

In fact I absolutely want some moderation to take place ! Btw, the moderation queue is very, very nice! I’ll test this plugin as well, it’s already installed. But it’s still desactivated as I write because I’m hit by what seems to be an incompatibility with glz_custom_fields

Cheers and thanks for your help !

Last edited by PascalL (2009-10-04 23:48:20)

Offline

#23 2009-10-05 00:24:11

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

Re: mem_public_article

PascalL wrote:

Spaces are replaced by “+”. This is not very elegant, but well…

problem solved with rah_replace, and now I have something like:

<txp:mem_form_secret name="url_title" value='<txp:rah_replace from="à|é|è| " to="a|e|e|-" delimiter="|"><txp:mem_filter name="lcase"><txp:mem_public_article_ps name="Title" /></txp:mem_filter></txp:rah_replace>' />

and the next great thing is that rvm_counter will do the trick ! It’s able to display a count without incrementing, and I’ll trigger increments in the success_form called by mem_public_article.

Last edited by PascalL (2009-10-05 00:24:45)

Offline

#24 2009-10-05 13:18:33

Gallex
Member
Registered: 2006-10-08
Posts: 1,289

Re: mem_public_article

PascalL wrote:

<txp:mem_form_text name="title" label="Title" /> <br />
<txp:mem_form_text name="section" label="Section" />  <br />
<txp:mem_form_textarea name="body" label="Body" />  <br />
<txp:mem_form_text name="author" label="Auteur" />  <br />

<txp:mem_form_submit />

i use this pascal form for a testing. where i need to put mem_public_article tag to get it work?
because nothing happens right now if i click “save”

Offline

Board footer

Powered by FluxBB