Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2023-02-24 14:17:17

Pemischl
Member
From: Vienna, Austria
Registered: 2012-01-14
Posts: 22
Website

Re: etc_post: post anything from the public side

Thank you for the hint! I have tried several variations but I still do not fully understand the etc_post logic and could not initiate a change of the Author (the author exists and is active).

V1 fix values for selected[] and AuthorID in tag

<txp:etc_post event="list" step="list_multi_edit" edit_method="changeauthor" selected[]="1894" AuthorID="someone">
</txp:etc_post>

V2 fix values for selected[] and AuthorID enclosed

<txp:etc_post event="list" step="list_multi_edit" edit_method="changeauthor" post="">
   selected[]=1894
   AuthorID=someone
</txp:etc_post>

V3 values for selected[] and AuthorID submitted through form

<txp:etc_post event="list" step="list_multi_edit" edit_method="changeauthor" post="selected[], AuthorID">
</txp:etc_post>

I have no idea what to change and would appreciate every hint.

Best,
Peter

Offline

#26 2023-02-24 18:54:04

etc
Developer
Registered: 2010-11-11
Posts: 5,090
Website GitHub

Re: etc_post: post anything from the public side

The tags own attributes are user, event and step. The rest is populated from $_POST data or from the tags content. You can try this:

<txp:etc_post user="pemishl" event="list" step="list_multi_edit">
edit_method=changeauthor
selected[]=1894
AuthorID=someone
</txp:etc_post>

Offline

#27 2024-06-30 01:54:30

ironmangary
Member
From: United States
Registered: 2022-10-13
Posts: 34

Re: etc_post: post anything from the public side

I’m trying to post a new article using etc_post. I tried two different ways, using different fields for testing, and in all cases, the article did not post. Also, despite having debugging turned on, there were no errors.

First, I tried:

<form action="<txp:page_url />" method="post">
  <input name="custom_1" placeholder="League Name" value='<txp:page_url type="custom_1" />' required="required" />
  <input name="Title" placeholder="Short Name/Abbreviation" value='<txp:page_url type="Title" />' required="required" />
  <input type="submit" />
</form>

<txp:if_request type="post" name="name" value>
<txp:etc_post user="admin" event="article" step="save" post="custom_1, Title">
Section=articles
Status=3
publish_now=1
</txp:etc_post>
</txp:if_request>

When that failed to post an article, I tried to make my code more like the example etc uses in the plugin documentation. I have a page with this:

<p><h3>New League</h3></p>

<p>
<form action="index.php?f=post_league" method="post">
  <input name="Title" placeholder="League Name" value='<txp:page_url type="Title" />' required="required" />
  <input name="custom_1" placeholder="Short Name (Abbreviation)" value='<txp:page_url type="custom_1" />' required="required" />
  <input type="submit" />
</form>

Then the form post_league’:

<txp:etc_post user="admin" event="article" step="save" post="custom_1, Title">
Section=articles
Status=3
publish_now=1
</txp:etc_post>
<txp:header name="Location" value='<txp:site_url />' />

Same results: the form displays, there is no error with submission, but the article does not post. I’ve tried different fields, I’ve tried switching around the order of posted fields, but no dice. I’m using 4.9.0 Dev. If anyone has any thoughts… Thanks!

Last edited by ironmangary (2024-06-30 03:13:41)

Offline

#28 2024-06-30 08:05:51

etc
Developer
Registered: 2010-11-11
Posts: 5,090
Website GitHub

Re: etc_post: post anything from the public side

Make sure first that admin user exists and has been recently (like within 3 month) logged in.

In your example, the form does not contain name input, so <txp:if_request type="post" name="name" value /> block is not processed.

You can try adding debug="r" attribute to <txp:etc_post /> to see what server responds to the plugin’s request. Don’t hesitate to come back if it does not help.

Offline

#29 2024-07-01 01:45:37

ironmangary
Member
From: United States
Registered: 2022-10-13
Posts: 34

Re: etc_post: post anything from the public side

It was the bad <txp:if_request /> tag values. Works great now. Thank you!

Offline

#30 2024-07-08 15:32:48

ironmangary
Member
From: United States
Registered: 2022-10-13
Posts: 34

Re: etc_post: post anything from the public side

I have a follow up issue. After getting the new article to post, I decided to create a form to allow users to edit the articles they’ve created. Here’s the form code:

<form action="<txp:page_url />" method="post">
<input type="hidden" name="action" value="save_league_edits" />
<label for="custom_1">League Name</label>
<input type="text" id="custom_1" name="custom_1" value='<txp:custom_field name="league_name" />' maxlength="30" size="30" required />

<label for="Title">Short Name/Abbreviation</label>
<input type="text" id="Title" name="Title" value='<txp:title />' maxlength="10" size="10" required />

<label for="custom_20">League Logo (URL - only .jpg or .gif)</label>
<input type="text" id="custom_20" name="custom_20" value='<txp:custom_field name="image_url" />' pattern=".*\.(jpg|gif)$" />

<label for="custom_2">League Owner or Fed Head</label>
<input type="text" name="custom_2" id="custom_2" value='<txp:custom_field name="league_ceo" />' maxlength="30" size="30" />

<label for="custom_3">Headquarters</label>
<input type="text" name="custom_3" id="custom_3" value='<txp:custom_field name="league_hq" />' maxlength="30" size="30" />

<label for="Body">League Description</label>
<input type="textarea" id="Body" name="Body" cols="60" rows="20" value='<txp:body />' />

  <input type="submit" value="Update League" />
</form>

<txp:if_request type="post" name="action" value="save_league_edits">
<txp:etc_post user="admin" event="article" step="save" post="custom_1, Title, custom_20, custom_2, custom_3, Body">
category1=league
Section=test
Status=4
publish_now=1
</txp:etc_post>
</txp:if_request>

The page pulls up the desired info, populating the HTML form perfectly. However, after I modify the form and click Update, the data is not updated. There are no errors and I am using the “admin” user to avoid any permissions issue, as this is my main user account. For the step, I have tried both “save” and “edit”. I’m not sure what I’m doing wrong.

Offline

#31 2024-07-09 15:44:32

etc
Developer
Registered: 2010-11-11
Posts: 5,090
Website GitHub

Re: etc_post: post anything from the public side

Saving published articles looks a bit inconsistent: event="article" step="edit". But you also need to append at least two (hidden?) inputs to your form or the plugin: ID=## and save=something. Probably some other article fields are mandatory, I’m not sure. Try saving some article on the admin side and inspecting the request in the browsers console to see what is typically sent by txp.

Offline

Board footer

Powered by FluxBB