Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-06-16 07:46:50

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Oddity in $_POST when duplicating pages

I’m not sure if this is a bug because it doesn’t seem to affect anything, but it looks odd and is a change in behaviour from TXP 4.5, so I thought I’d mention it.

The scenario here is duplicating pages and I’m looking at the resulting posted data.

In 4.5, copy page “original” as “new_page”:

$_POST=
array (
  '_txp_token' => '110110397318befbe1a274661e12e85c',
  'copy' => 'Copy',
  'event' => 'page',
  'html' => 'some page content',
  'name' => 'original',
  'newname' => 'new_page',
  'step' => 'page_save',
)

In 4.6 duplicate page “original” -> “original_copy”:

$_POST=
array (
  '_txp_token' => 'd2a0dbb696eec537380ad0df2ef309db',
  'copy' => '1',
  'event' => 'page',
  'html' => 'some page content',
  'name' => 'original',
  'newname' => 'original',
  'step' => 'page_save',
)

Note element ‘newname’ in 4.6 – it’s not set to the new name of the page, whereas in 4.5 it is.

Offline

#2 2015-06-16 09:16:07

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: Oddity in $_POST when duplicating pages

gomedia wrote #291563:

Note element ‘newname’ in 4.6 – it’s not set to the new name of the page, whereas in 4.5 it is.

If you let Txp decide the name of your new Page then yes, newname will be the same as the current name. The _copy bit is added server-side. If, however, you alter the name of the page prior to hitting Duplicate you’ll see that newname takes on the name you gave it.

Bottom line: don’t worry about it, it’s designed that way to give you the flexibility to pre-name your Pages or to have Txp do it behind the scenes. You’ll notice the same behaviour wherever Duplicate occurs on the admin side.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2015-06-16 09:53:50

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Oddity in $_POST when duplicating pages

Bloke wrote #291567:

Bottom line: don’t worry about it,

Great, thanks for looking into it. Didn’t occur to me that you could change the name before hitting duplicate. You learn something every day!

Offline

#4 2015-06-16 10:30:06

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: Oddity in $_POST when duplicating pages

gomedia wrote #291569:

Didn’t occur to me that you could change the name before hitting duplicate.

Yeah it’s currently an undocumented feature. Eyes only stuff ;-)

4.6.x has the notion of inline help baked in. You can try it out on some panels in the admin_layout_update branch by adding entries in your txp_lang file that start with instructions_. Some of the places where inputLabel() is used have been upgraded to permit such inline help. Panels that spring to mind are:

  • Article
  • Page
  • Form
  • Style
  • File

For example, add a suitable lang string under the name instructions_page_name and then refresh the Presentation->Pages panel. You’ll see the help appear right under the input field. That may be where we’ll put hints like how to duplicate stuff, if the text can be made succinct enough.

Just grep through the files in the include directory for instructions_ and you’ll find all the places it’s been enabled. Pull requests welcome, btw, if you fancy helping us add them to other places in the UI ;-)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2015-06-16 12:28:50

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Oddity in $_POST when duplicating pages

Bloke wrote #291572:

4.6.x has the notion of inline help baked in.

Thanks, very interesting. I had a stab at doing tooltips with adi_notes a while ago and failed miserably. I know redbot produced bot_admin_tooltips but it’ll be good to see something in the core.

Would it be something plugins could make use of?

Last edited by gomedia (2015-06-16 12:29:46)

Offline

#6 2015-06-16 12:42:17

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: Oddity in $_POST when duplicating pages

gomedia wrote #291579:

Would it be something plugins could make use of?

Absolutely. The main protagonist is inputLabel() so plugins can use that directly when building UI widgets. If you pass an array as the $help attribute, the first element is the usual popHelp topic, the second is the inline help key. It degrades gracefully too, so if the nominated inline help lang string isn’t available in a particular language, nothing is output there. We’ve chosen instructions_ as the prefix; plugins can use their own author/plugin prefixes.

inputLabel() is also overridable via pluggable_ui() so plugins can tinker with any widget prior to it being rendered. Lots of scope for customisation.

Last edited by Bloke (2015-06-16 12:47:03)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB