Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2010-03-25 18:36:51

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: Allow website users to create new articles

Mem_moderation is very powerful and I agree it’s not very easy to get your head around so here’s an example of an event submission form copied wholesale out of an event submit form. I’m strapped for time at the moment so can’t go into it in all that much detail but perhaps you can make head or tail of the following. Note that it may not quite exactly match the current iteration of mem_moderation but the principle is similar.

You can see the various mem_form_... tags which work much like zem_contact_reborn for text inputs, selects, textareas. The hidden or secret ones can be used to auto-allocate to a section (here events) without that having to be filled out. The name attribute correspondes to the respective field in the textpattern table in the database (you might want to look at it with phpmyadmin / sequel pro etc. to familiarise yourself with it). The complicated looking format="..." bits are not normally necessary, they’re just to limit date formats in a particular format which I needed for my auto-expiring event list.

This snippet went in the respective page template:

<p>Use this form to submit an event for inclusion in the calendar of events.
Please note that your event will only appear in the list once it has been verified and approved by a moderator.</p>
<txp:mem_moderation_article_form 
 form="mod_article_event" 
 thanks_form="mod_article_success" 
 label="Submit an event" 
 />

This is the form called mod_article_event:

 <h3>Submit an event</h3>
 <div><txp:mem_form_text name="title" required="1" class="long" label="Name of the event" break="" /></div>
 <div><txp:mem_form_text name="custom_5" required="1" class="short" label="Start date" example="(YYYY-MM-DD)" break="" 
format="/^(20[0-9]{2})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/" /></div>
 <div><txp:mem_form_text name="custom_6" required="1" class="short" label="End date" example="(YYYY-MM-DD)" break="" 
format="/^(20[0-9]{2})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/" /></div>
 <div><txp:mem_form_text name="custom_7" required="1" label="Venue, Country" break="" /></div>
 <div><txp:mem_form_text name="custom_8" required="1" label="Organiser" break="" /></div>
 <div><txp:mem_form_text name="custom_9" required="1" label="Event Homepage" break="" /></div>
 <div><txp:mem_form_textarea name="body" required="1" class="txtarea_big" label="Description" break="" /></div>
 <div><txp:mem_form_textarea name="note" class="txtarea_medium" label="Additional notes for the moderator (e.g. your name and email)" break="" required="0" /></div>
 <txp:mem_form_hidden name="section" value="events" />
 <txp:mem_form_submit button="1" name="action"><span>Submit event details</span></txp:mem_form_submit>

… and this is the form called mod_article_success:

 <txp:mem_if_step name="article_delete">
 <div id="mod_deleted">
 	<h2>Event listing deleted</h2>
 	<p>Your submission has been deleted and will not be posted on this site.</p>
 </div>
 <txp:else />
 <div id="mod_submitted">
 	<h2>Event listing submitted</h2>
 	<p>Thank you for submitting your event. It will be reviewed by a moderator before being posted to the site.</p>
 </div>
 </txp:mem_if_step>

You can style it how you like and use different markup. I’ve forgotten where the “article_delete” step comes in. Anyhow, this is what it looks like:

I added a date plausibility check (date not in the past, start date not after end date – see this thread) and a honeypot trap to reduce spam (see this thread) and then spruced it up a bit with a jquery date picker that helps reduce erroneous inputs and a textarea expander. The notes field is just a helper and is lost once you accept the entry so it’s not for anything important. By comparison, the edit area in the backend is not very pretty but you know what you’re doing.

Last edited by jakob (2010-03-25 18:42:07)


TXP Builders – finely-crafted code, design and txp

Offline

#14 2010-03-25 22:29:46

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

Re: Allow website users to create new articles

I managed to have moderation with mem_public_article.
Just set a mem_form_secret field which sets the article status to 3:
<txp:mem_form_secret name="Status" value="3" />

For more security, I test there is not too many articles waiting moderation. (with jmd_if_count)

P.S woaw thanks Jakob for the great example! I’m doing something very similar, but a lot less polished for now! I chose mem_public_article because of the possibility to edit articles, which I’ll try to add in the future.

Last edited by PascalL (2010-03-25 22:35:37)

Offline

#15 2010-03-26 09:12:22

Algaris
Member
From: England
Registered: 2006-01-27
Posts: 535

Re: Allow website users to create new articles

Jakob that’s absolutely amazing, just the sort of thing I was looking for. I haven’t had time to test it yet, but I’m looking forward to trying. What you’ve posted makes a lot of sense to me. Thank you so much.

I really need to get into this javascript and jquery thang, neither of which I know anything about as yet.

One question I completely forgot to ask. If something is sitting in the moderation queue can you edit it there as though it’s an article before approving it or at least publish it as hidden so you can edit it before going live? I’ll probably find this out when I’ve had to time to do more testing.

Last edited by Algaris (2010-03-26 09:14:31)

Offline

#16 2010-03-26 12:03:13

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: Allow website users to create new articles

If something is sitting in the moderation queue can you edit it there as though it’s an article before approving it or at least publish it as hidden so you can edit it before going live?

Yes, you see a simplified list of submitted articles a bit like the articles pane but without whistles and bells and there’s an edit pane which shows the submitter’s notes at the top followed by the various fields one below the next – not terribly pretty but it works. You can edit the details and choose between “Save” (= edit but keep in the moderation queue), “Accept” (=becomes a txp article) and “Reject” (= delete).
I believe there’s even a tag to output the articles currently in the moderation queue in the front end but I’ve not tried that.


TXP Builders – finely-crafted code, design and txp

Offline

#17 2010-03-26 14:08:58

Algaris
Member
From: England
Registered: 2006-01-27
Posts: 535

Re: Allow website users to create new articles

Next question (sorry I’m asking an awful lot here). If I want people to be able to upload an image and associate it and its thumbnail with an article is that fairly easy to do? I noticed the mem_moderation_image plugin so I’m assuming I can mix this in with the mem_moderation form and give it the appropriate textpattern table name for the article image or custom field.

Offline

#18 2010-09-09 14:58:55

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 220
Website

Re: Allow website users to create new articles

WOw thanks a lot jakob. You really almost helped me to make the perfect ticket system (for me) =)
There are only two little issues left. For any reason when user initialy write an article with mem_moderation i as the admin get no email notificaton about the fact that there is something new in the queue. Any idea how that can be done? I use comments as suggested somewhere by stef to handle the back and forth of the user and the admin. I get an email notification there by using the rvm_mail_comments plugin. So that works fine.

The second thing is… I would like to search through comments. Is that possible somehow. As a ticket system it only makes sense if later the user can search for any words that are mentioned in the comments.
Hopefully I can at least solve one of those two issues to get the system finally running.

Offline

#19 2010-09-10 15:53:04

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 220
Website

Re: Allow website users to create new articles

OK…. i was too stupid to see that there are additonal preferences to be made in “preferences” …almost to ashamed to write that down.. but maybe it saves someone some time.
For the comments thing i haven´t found a solution yet. I am thinking of playing around with articles belonging to certain categories (ticket number) for example. Dont know if that works because I will end up with a lot of categories then. just an idea for now.

Offline

#20 2010-09-16 08:35:11

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

Re: Allow website users to create new articles

trying to get to work my (simpler) form using jakob’s as an example

but, after installation and activation mem_admin_parse, mem_moderation, mem_moderation_article and mem_form i get blank page with this error:

Fatal error: Call to undefined function mem_form() in /home/np34630/domains/hm-kodulehed.ee/public_html/textpattern/lib/txplib_misc.php(594) : eval()'d code on line 1170

what this refers to?

Offline

#21 2010-09-17 07:19:41

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

Re: Allow website users to create new articles

is it something wrong with my code or plugin?

Offline

Board footer

Powered by FluxBB