Editing a weblog entry through the web
Posted: 07 April 2008 01:57 PM   [ Ignore ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  133
Joined  2008-03-04

With the cheerful assistance of Pie Man, I have been able to create an effective SAEF web form that feeds into a weblog. I can access and edit it through the Control Panel, but would like to be able to edit it through a webform as well.

I would like to be able to change the author to one of the multi-author list names, change the status (open, closed, etc) and perhaps add more content by way of custom fields. I am open to suggestions.

Thanks in advance.

Forrest

Profile
 
 
Posted: 08 April 2008 06:51 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3343
Joined  2006-10-18

First,

You’ll obviously need to download a copy of FormHelper
Secondly, build a new template where you will link to from entries in another template.

You’ll find full documentation on how to do this in the FormHelper plugin, but I’ll provide a basic template below.

<div class="editform">
{exp:weblog:entries rdf="off" show_future_entries="yes" show_expired="yes"}
{exp
:weblog:entry_form weblog="my_weblog" return="template_group/template"}

<input type="hidden" name="entry_id" value="{entry_id}" />
<
input type="hidden" name="allow_comments" value="n" />
<
input type="hidden" name="allow_trackbacks" value="n" />
<
input type='hidden' name='dst_enabled' value='y' />
<
input type="hidden" name="status" value="{status}" />
<
input type="hidden" name="author_id" value="{author_id}" />
{categories}<input type="hidden" id="category[]" name="category[]" value="{category_id}" />{/categories}
<input name="entry_date" type="hidden" value="{entry_date format='%Y-%m-%d %g:%i %A'}" maxlength="23" />
<
input type="hidden" name="url_title" id='url_title' value="{url_title}" size="50" maxlength="75" />
<
input type="hidden" name="{exp:form_helper:field_grabber field_name='body' which='format'}" value="xhtml" />

<
p><label for="form_title">Title</label><br /><input type="text" name="title" value="{title}" id="form_title" maxlength="150" /></p>

<
p><label for="form_desc">Description</label><br /><textarea name="{exp:form_helper:field_grabber field_name="body"}" id="form_desc" rows="10" cols="10">
{exp:form_helper:field_parser parse=""}{body}{/exp:form_helper:field_parser}</textarea></p>

<
p><label for="form_favoritecolor">Favorite Colour</label><br /><textarea name="{exp:form_helper:field_grabber field_name="favoritecolor"}" id="form_favoritecolor" rows="10" cols="10">
{exp:form_helper:field_parser parse=""}{favoritecolor}{/exp:form_helper:field_parser}</textarea></p>

<
p><input type="submit" name="submit" value=" Submit " class="submit" /></p>
{/exp:weblog:entry_form}
{
/exp:weblog:entries}
</div>

As you can see, FormHelper makes it a little easier whereas you can specify the “short_name” of the field…
I’ve also set my Categories to show as hidden… you can populate them as a dropdown like this:

<select multiple name="category[]">
{exp:form_helper:categories entry_id="{entry_id}" parent_id="1"}
<option value="{cat_id}" {checked}>{cat_name}</option>
{/exp:form_helper:categories}
</select>

The key thing is to have a Weblog Entries loop wrapped around the form and have the form linked to dynamically so that the data is populated.
You can easily make links to the Edit form by putting code like this on your frotn end templates (within the weblog:entries loop):

{if logged_in_group_id == "1" || logged_in_group_id == "6"}<a href="{permalink='path_to/edit_form'}">Edit Entry</a>{/if}

The code above allows for both Group ID #1 and #6 to see a link that will set itself to the Edit Form smile

 Signature 
Profile
 
 
Posted: 08 April 2008 11:38 AM   [ Ignore ]   [ # 2 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  133
Joined  2008-03-04

Ahoy!

Hi. I just had a breakthrough and a glitch all in one move.

The last entry in the form is a text box with details about the entry. I tried to list this as textarea with rows and cols but nothing was showing up in the text area. I changed it to input="text" and it now has data in it, but also is only one line and not too easy to edit.

The edit form is showing up properly when I click on the Edit Entry link, however, when I make a change and click submit I get the following error:

Invalid GET Data - Array

How do I enlarge the text area for the text box and what might be happening on the submit that would cause the error?

Thanks,

Forrest

Profile
 
 
Posted: 08 April 2008 11:48 AM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3343
Joined  2006-10-18

Forrest,

You’ll need to make textareas formatted like this:

<textarea name="{exp:form_helper:field_grabber field_name="hamgrits"}" cols="10" rows="4">
{exp:form_helper:field_parser parse="<br />"}{hamgrits}{/exp:form_helper:field_parser}
</textarea>

 Signature 
Profile
 
 
Posted: 08 April 2008 11:51 AM   [ Ignore ]   [ # 4 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  133
Joined  2008-03-04

Pie Man,

Well done on the text area. I just need to strip out the formatting and it will look good.

thanks,

Forrest

Profile
 
 
   
 
 
‹‹ jwysiwyg      First steps with Form Helper... ››