1 of 2
1
Editing a weblog entry through the web
Posted: 07 April 2008 01:57 PM   [ Ignore ]
Member
Avatar
RankRankRank
Total Posts:  274
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
RankRankRankRankRank
Total Posts:  8223
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 ]
Member
Avatar
RankRankRank
Total Posts:  274
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
RankRankRankRankRank
Total Posts:  8223
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 ]
Member
Avatar
RankRankRank
Total Posts:  274
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
 
 
Posted: 14 January 2009 09:09 AM   [ Ignore ]   [ # 5 ]
Newbie
Rank
Total Posts:  19
Joined  2008-11-21

Pie Man,

Can you please clarify why you need all those hidden fields?  What is their purpose in the code?  I don’t have much background in forms, so I sense there is a fundamental concept here I am missing.

Profile
 
 
Posted: 14 January 2009 09:31 AM   [ Ignore ]   [ # 6 ]
Administrator
Avatar
RankRankRankRankRank
Total Posts:  8223
Joined  2006-10-18
Craig Uffman - 14 January 2009 09:09 AM

Can you please clarify why you need all those hidden fields?  What is their purpose in the code?

Certainly smile

There are two types there… well 3, sort of grin

1. Every custom field requires it’s Formatting type to be listed as well, otherwise EE takes a guess and messing things up raspberry
Example:

<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>
<
input type="hidden" name="{exp:form_helper:field_grabber field_name='body' which='format'}" value="xhtml" /></p

2. a) Some of the fields I’ve chosen to hide because (in my typically scenarios anyway) I do not want those fields to be editable by the member that will be editting the content. Or, sometimes that data stays the same no matter what, so it’s less clutter on the page when you hide it.
Example:

<input name="entry_date" type="hidden" value="{entry_date format='%Y-%m-%d %g:%i %A'}" maxlength="23" /> 

2. b) Some of the fields are required to be in the form. If you leave them out the data for them will be lost:
Example:

{categories}<input type="hidden" id="category[]" name="category[]" value="{category_id}" />{/categories} 

Even though the Category for my scenario will/should NEVER change, I still have to specify it, or EE will lose that data.

Though I’ve never tested it, I’m sure close to half of my fields I have hidden in the example don’t even need to be there, but the intention is keeping the data from being lost. I haven’t tested it, but I’m sure if you left out ones like these, the data for those values would not be lost or change: smile

<input type="hidden" name="allow_comments" value="n" />
<
input type="hidden" name="allow_trackbacks" value="n" />
<
input type='hidden' name='dst_enabled' value='y' /> 
 Signature 
Profile
 
 
Posted: 14 January 2009 09:37 AM   [ Ignore ]   [ # 7 ]
Newbie
Rank
Total Posts:  19
Joined  2008-11-21

Ah.  I get it. Thanks!

Profile
 
 
Posted: 14 January 2009 11:21 AM   [ Ignore ]   [ # 8 ]
Newbie
Rank
Total Posts:  19
Joined  2008-11-21

I copied your example and adjusted it for my weblog fields.  But I am getting the following error condition:

Link to the Channel
http://www.mylinktochannel

” id=“form_channel_link” maxlength=“150” >


I have attached an image of what is happening so you can see it on the edit form.  Notice that this does not happen on other fields with the same syntax and of the same field type (text input).

Here’s the code I am using.

<p><label for="form_channel_title">Short Title for the Channel</label><br /><input type="text" name="channel_title" value="{channel_title}" id="form_channel_title" maxlength="350" /></p

  Can you tell me what I am doing wrong?

Image Attachments
uffman_error_condition_saef_edit.png
Profile
 
 
Posted: 14 January 2009 11:25 AM   [ Ignore ]   [ # 9 ]
Newbie
Rank
Total Posts:  19
Joined  2008-11-21

I am guessing that the problem is that the field in question is formatted as xhtml, and did not declare that.  Will check.

Profile
 
 
Posted: 14 January 2009 11:28 AM   [ Ignore ]   [ # 10 ]
Administrator
Avatar
RankRankRankRankRank
Total Posts:  8223
Joined  2006-10-18

Hey Craig,

The code you’ve provided appears to be for the title… would I be able to see ALL the code (at least in that surrounding area)? smile

And what is the exact output of one of these “Link to the Channel” fields supposed to output? smile

 Signature 
Profile
 
 
Posted: 14 January 2009 11:40 AM   [ Ignore ]   [ # 11 ]
Newbie
Rank
Total Posts:  19
Joined  2008-11-21

Sure.  Here it is.

The output of the field should be the text string for a url.  We are storing the url in the channel_link field, so that what renders when the field is displayed on a form is a hyperlink to the channel.

<div class="editform">
{exp:weblog:entries rdf="off" show_future_entries="yes" show_expired="yes"}
{exp
:weblog:entry_form weblog="channels" return="/saef/successful_entry"}

<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='channel_description' which='format'}" value="xhtml" />

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

<
p><label for="form_channel_link">Link to the Channel</label><br />
<
input type="text" name="{exp:form_helper:field_grabber field_name="channel_link"}" value="{channel_link}" id="form_channel_link" maxlength="350"/>
<
input type="hidden" name="{exp:form_helper:field_grabber field_name='channel_link' which='format'}" value="xhtml" /></p>


<
p><label for="form_channel_title">Short Title for the Channel</label><br /><input type="text" name="channel_title" value="{channel_title}" id="form_channel_title" maxlength="350" />
<
input type="hidden" name="{exp:form_helper:field_grabber field_name='channel_title' which='format'}" value="xhtml" /></p>

<
p><label for="form_channel_description">Description of the Channel</label><br />
<
textarea name="{exp:form_helper:field_grabber field_name="channel_description"}" id="form_channel_description" rows="3" cols="70">
{exp:form_helper:field_parser parse=""}{channel_description}{/exp:form_helper:field_parser}</textarea>
<
input type="hidden" name="{exp:form_helper:field_grabber field_name='channel_description' which='format'}" value="xhtml" /></p>

<
p><label for="form_copyright">Copyright</label><br /><textarea name="{exp:form_helper:field_grabber field_name="copyright"}" id="form_copyright" rows="10" cols="70">
{exp:form_helper:field_parser parse=""}{copyright}{/exp:form_helper:field_parser}</textarea>
<
input type="hidden" name="{exp:form_helper:field_grabber field_name='copyright' which='format'}" value="xhtml" /></p>

<
p><input type="submit" name="submit" value=" Submit " class="submit" /></p>
{/exp:weblog:entry_form}
{
/exp:weblog:entries}
</div
Profile
 
 
Posted: 14 January 2009 12:09 PM   [ Ignore ]   [ # 12 ]
Newbie
Rank
Total Posts:  19
Joined  2008-11-21

Pie Man,
Can you clarify what is supposed to go in the permalink path field to the edit form?

Never mind.  I found I had a stray bracket causing the problem.

Profile
 
 
Posted: 14 January 2009 01:30 PM   [ Ignore ]   [ # 13 ]
Newbie
Rank
Total Posts:  19
Joined  2008-11-21

I notice that the problem seems to be connected with the fact that this is a custom field for which the data consists of url’s and for which the formatting option is set to xhtml.  It seems to choke on that field, but the next field is one for which I copied that same code and simply changed the field names.  And it works fine.

Profile
 
 
Posted: 14 January 2009 02:40 PM   [ Ignore ]   [ # 14 ]
Newbie
Rank
Total Posts:  19
Joined  2008-11-21

Pie Man,
I am attaching another screen shot that I think makes the problem more visible.  I think it has something to do with the parsing of urls.  Perhaps there is code in your parser to handle this?  In the database, there is simply the text string of the url.  But the field coming back has the anchor syntax, and part of that seems to be put into the input, and then part of that seems to flow out of the input and act like a label.

In the example in the image, the database has “http://covenant-communion.com”.  Using the code that I sent above, EE seems to surround that value with the html tag, and that flows out of the input box.

Any ideas?

Image Attachments
uffman_error_condition_saef_edit.png
Profile
 
 
Posted: 15 January 2009 08:22 AM   [ Ignore ]   [ # 15 ]
Administrator
Avatar
RankRankRankRankRank
Total Posts:  8223
Joined  2006-10-18

Hey Craig,

What does the actual parsed source code look like for that area?

What happens if you add the field_parser to that field? smile

{exp:form_helper:field_parser parse=""}{hamgrits}{/exp:form_helper:field_parser} 
 Signature 
Profile
 
 
   
1 of 2
1
 
‹‹ jwysiwyg      First steps with Form Helper... ››