Summary: Talk Page for the EditAttributes bundle
Maintainer: Eemeli Aro
Categories: Editing, GUI

Please leave new comments at the top of the page (but below this line).

Is the update to php 7.2 scheduled or will the recipe be abandoned? - Frank November 15, 2018, at 03:07 PM

How can I delete pages when the recipe is adding titles and stuff?

add a line like

     if (preg_match("/$DeleteKeyPattern/",$_POST['text'])) return;

near the very top of the recipe. (bhoc 25 Jul 2017)

How can I create select lists that work with EditAttributes?

Adjust the conditional starting on line 151. Eemeli, please consider adding this to the core!

		if(preg_match('/\stype=([\'"]?)checkbox\1/', $InputTags["e_$fn"][':html'])){
			$InputTags["e_$fn"]['value'] = '1';
			if(!empty($new[$fn])) $InputTags["e_$fn"]['checked'] = '1';

		}elseif(preg_match('/<select/', $InputTags["e_$fn"][':html'])){
			if(empty($new[$fn])) $new[$fn] = '';

			$InputTags["e_$fn"][':html'] = preg_replace(
				"value='".$new[$fn]."' selected='selected'",

Q: DaveG -- 2-Nov-2009: Is there a way to display a field as a select list? It seems like it may be possible by setting :html, but I'm not sure how to handle the multiple select values.

I'm looking at the best way to:

  • use this recipe only on certain pages in a group
  • have it automagically pick up all the page text variables on a page
have you any suggestions on how this might best be achieved?

Thanks simon September 08, 2009, at 03:01 AM

If I understand correctly, the recipe could handle PageTextVariables like this:

$EditAttrFields = array( 'Summary' => array('attribute' => 0, 'markup' => '(:Summary:$1:)');
Is this correct?

Yes. This probably could do with some more testing, but that should work. You could even have just array( 'Summary' => array( 'markup' => '(:Summary:$1:)' )

Does 'attribute' => 0 mean that only the page text is modified, but no additional page attribute is created?

Yes. Setting attribute to a value that equates to false or leaving it undefined prevents any additional page attribute from being generated. Leaving both attribute and markup false or undefined is probably silly, unless you're doing something odd with a filter function.

And in that case, attribute<2, is the change visible in Page?action=diff?

If you're modifying the page text, then those changes will be seen under action=diff. If you're working just with page attributes, action=diff won't unfortunately show you those changes.

In your own example, you seem to actually remove the (:title XX:) markup from the page.


I found a problem with this setting - page cannot be searched by terms in title. So it's better to keep the (:title:) markup in page text ('markup' => '(:title $1:)'). Roman

Where is the attribute "history" saved? --Petko March 20, 2009, at 06:52 AM

When saving a page, if attribute has a value greater than 1, an additional attribute is stored with a name [attribute name]:[timestamp] and the new attribute value, much the same way as eg. the author and change summary of an edit is stored. Unfortunately, the PrintDiff() function in pagerev.php isn't very customisable, so I haven't bothered so far to provide a custom version of it that would report changes in other fields than the page text. --Eemeli Aro March 29, 2009, at 04:39 AM

Found a conflict with NewPageBoxPlus. With EditAttributes installed (:newpagebox template=Group.PageTemplateName:) has no effect - page text from template is ovewritten. Is there a way to resolve it?
Addition: Conflict is not only with NewPageBoxPlus, but generally with page templates Roman April 21, 2009, at 07:36 AM

I haven't been able to duplicate this on my sites; EditTemplates and NewPageBoxPlus appear to work as intended. Can you give more details about your setup and configuration for the two recipes? —Eemeli Aro May 18, 2009, at 05:01 AM

Found and fixed as of 2009-06-01. The title autofill was making the page contents non-empty so EditTemplates() wouldn't trigger. —Eemeli Aro June 01, 2009, at 04:46 AM

Could we include the recipe only if $action=='edit'?

Yes. I've now updated the usage instructions above to do just that.

I'm unclear as to the the difference between, or the difference in use of, page attributes and page text variables.

I'd like to use the recipe to update a set of PTVs currently used across a number of pages in a group. The PTVs are used to generate new pages of content. simon September 20, 2009, at 08:15 PM

Using PHP5.5 I see my text automatically having the following inserted (especially around IF statements): EditAttrKeep('

Upgrade to release 2015-03-16 or newer. This resolves the preg_replace changes due to PHP5.5

I am getting "Strict Standards: Only variables should be passed by reference in ... cookbook/editattr.php on line 153" (sroberts 7 Apr 2015)

The lines involved are:

    $pat = empty($fa['markup'])
            ? FALSE
            : ( is_array($fa['markup'])
                ? reset(array_keys( $fa['markup'] ))
                : str_replace( array('\$0','\$1'), '(.*?)', preg_quote($fa['markup'],'/') ) );

Talk page for the EditAttributes recipe (users).