Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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: 5,230
Website GitHub

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,331

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

#25 2009-10-05 13:28:51

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

Re: mem_public_article

Gallex, this form of mine was not working at all, that’s the reason I posted it!

you should try my later samples of a minimal working form instead.

Offline

#26 2009-10-05 13:37:31

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

Re: mem_public_article

PascalL wrote:

Gallex, this form of mine was not working at all, that’s the reason I posted it!
you should try my later samples of a minimal working form instead.

same story, nothing happens after submitting. what i’m missing?

Last edited by Gallex (2009-10-05 13:45:34)

Offline

#27 2009-10-05 13:59:58

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

Re: mem_public_article

I simply put the mem_public_article tag inside a page template, like this:

<txp:mem_public_article form="public-article" success_form="public-article-success" />

Put the code from one of my examples inside a form, here it’s called “public-article”.
The public-article-success form is there to confirm the user that the form has been submitted. Fill it with whatever you want.

P.S: btw, did you look at the admin articles tab ? be aware that the submitted article is set to “pending” status, you won’t see it on your site without changing manually to “live”

Last edited by PascalL (2009-10-05 14:06:43)

Offline

#28 2009-10-06 13:07:38

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

Re: mem_public_article

PascalL wrote:

I simply put the mem_public_article tag inside a page template, like this:
<txp:mem_public_article form=“public-article” success_form=“public-article-success” />

putted

Put the code from one of my examples inside a form, here it’s called “public-article”.

putted exactly this code

btw, did you look at the admin articles tab ?

…didn’t get any errors after submitting but still nothing showing up into articles tab….wierd

Last edited by Gallex (2009-10-06 13:18:23)

Offline

#29 2009-11-03 17:58:36

ideasweforgottosteal
New Member
Registered: 2009-10-28
Posts: 1

Re: mem_public_article

Hey everyone, first time poster, I’ve been reading through this forum for the past couple months. First off, a big thank you to Manfre for this plug-in!

So far I’ve built a simple working form for registered users to post with. Now I’m trying to add an image upload option, and I don’t know where to go after adding the <txp:mem_form_file /> tag.

Ideally, the form will allow users to upload a single image, and insert that single image tag (with <txp:mem_form_secret /> ?) into the post body.

I’m not much of a programmer and any help would be sincerely appreciated!

Offline

#30 2010-08-03 13:15:52

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: mem_public_article

Is this plugin compatible with 4.2?

Like Gallex, I have used the sample code provided by Pascal but although I get the ‘success’ message nothing is showing up in the database.

Thanks. Falllback option is to use smd_query but that scares me!

Offline

Board footer

Powered by FluxBB