This plugin enables one to create placeholders beyond those native to phpList.

The latest version (0.97) of this plugin is given with my post of Sat 08 Oct, 2011.

See my post of Tue 05 Jul, 2011 at 5:59pm, for some changes as to how this plugin is to be implemented.

(The version which was attached here had been updated to version 0.953 on 20110616 to fix problems reported by boxbreak on 14 and 16 June 2011. This version has now been removed. The latest version is 0.97 and attached to my post of Sat 08 Oct, 2011.)

Four types of placeholders are available: HTML, text, PHP:Date, and PHP:Eval. There are in addition four "hard-wired" placeholders (see below).

Enhanced Placeholders use the convention of "{" and "}" -- rather than "[" and "]" -- for placeholder delimiters. This allows "[" and "]" to be used for constructs in emails other than placeholders without creating possible conflicts.

These placeholders can be used in the subject line as well as the content of HTML and text messages. They can also be nested -- i.e., a placeholder can be used as part of a different placeholder.

Placeholders of the form {PLACEHOLDER} can be used instead of those of the form [PLACEHOLDER] for many instances of the latter.

You can create placeholders of a number of different types using the "add a new placeholder" link on the "Enhanced Placeholders" page of the phpList administrative section. Any of the placeholders that you add can then be edited or deleted/removed .

If the type of the placeholder is "HTML," a field is available for entering what should be used in the text portion of an email or in the subject line.

There are four "hard-wired" enhanced placeholders:

{EMAIL}: the email address of the person to whom an email is sent.

{MID}: the message id.

{UID}: the unique id of the person to whom the email is sent.

{VIA_LIST_NAMES}: the names of the lists via which a specific message is sent. The names of the lists are separated by a dash (-).

To install this plugin, put the code from the attached file (EnhancedPlaceholders_0-95.zip) in the phpList plugins directory and insert the lines:

// Use the Enhanced Placeholders plugin to process placeholders before the legacy code does. MDG 10101020 $GLOBALS['plugins']['enhancedPlaceholders']->processEnhancedPlaceholders($messageid, $userdata, $user_att_values, $html, $text, $cached[$messageid]["template"], $htmlmessage, $textmessage, $cached[$messageid]["subject"]);// End of change for use the Enhanced Placeholders plugin to process placeholders before the legacy code does.

at line 239 of sendemaillib.php, just before "## Parse placeholders." (This is the line number for phpList 2.10.12. It may be different for other versions.)

This plugin is still a "beta" version. It has, however, been tested fairly extensively and found to work well for those cases for which it has been tested.

The option to use placeholders which evaluate PHP code has not been thoroughly tested. It is possible even that it may be found to caused more problems than it solves, in which case it will be removed from future versions.

When this plugin is used, in order to process queues using cron jobs one must use something similar to "What finally worked for me was to set up a curl call in a php script as follows:" at http://docs.phplist.com/CronJobExamples. Other approaches seem not to properly initialize the plugin.

Last edited by drmike on 7:45pm, Mon 10 Oct, 2011, edited 10 times in total.

StartedSending in batches of 30 emailsProcessing has started, 2 message(s) to process.Please leave this window open. You have batch processing enabled, so it will reload several times to send the messages. Reports will be sent by email to my@email.comProcessing message 46Looking for usersFound them: 1 to processScript stage: 4Finished, Nothing to doFinished, All done

This may have to do with the fact that phpList will not send the same message twice to the same recipient, except under the specific option to do so. I frequently ran into this feature when testing what I did and had to create a new message for each test.

Are you using PHP 5 and MySQL 5? I developed the plugin in that environment. Perhaps earlier version of PHP and/or MySQL do not play well with it. It has also only been tested with phpList 2.10.12. Perhaps it does not work with the version you are using...

I couldn't get the original code to work, processing the queue seemed to hang, as it is not clear to me whether plugins are loaded when processqueue is run from a command line or cron job.I have changed the modification to sendemaillib.php to create a new instance of the plugin before calling it:

This plugin is a fantastic idea. I installed it, but get the following error within the Admin page (/admin/?page=main&pi=enhancedPlaceholders&id=add_new_placeholder):

Sorry a software error occurred:Please report a bug when reporting the bug, please include URL and the entire content of this page.

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/myhost/public_html/phplist/admin/plugins/enhanced_placeholders/enhancedPlaceholdersAdmin.php on line 78phplist version 2.10.12

Sorry a software error occurred:Please report a bug when reporting the bug, please include URL and the entire content of this page.

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/myhost/public_html/phplist/admin/plugins/enhanced_placeholders/enhancedPlaceholdersAdmin.php on line 78phplist version 2.10.12

Sorry a software error occurred:Please report a bug when reporting the bug, please include URL and the entire content of this page.

Warning: Invalid argument supplied for foreach() in /home/myhost/public_html/phplist/admin/plugins/enhanced_placeholders/enhancedPlaceholdersAdmin.php on line 80phplist version 2.10.12

I do not know if this is relevant, but I had to first make the following change in order to get the Plugin's Admin screen to load, based on my server set-up:

I found the same problems that you describe and also the mysql error messages reported by other posters.

I have made some fixes for those problems and, to solve the mysql error messages, restructured the plugin into two classes, one for the admin and the second for the population of placeholders when a message is sent. The version works fine for me, let me know if you want to try it.

Thank you. The errors persist on the Add New Placeholder screen. Here they are:

Sorry a software error occurred:Please report a bug when reporting the bug, please include URL and the entire content of this page.

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/myhost/public_html/phplist/admin/plugins/enhanced_placeholders/enhancedPlaceholdersAdmin.php on line 78phplist version 2.10.12

Sorry a software error occurred:Please report a bug when reporting the bug, please include URL and the entire content of this page.

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/myhost/public_html/phplist/admin/plugins/enhanced_placeholders/enhancedPlaceholdersAdmin.php on line 78phplist version 2.10.12

Sorry a software error occurred:Please report a bug when reporting the bug, please include URL and the entire content of this page.

Warning: Invalid argument supplied for foreach() in /home/myhost/public_html/phplist/admin/plugins/enhanced_placeholders/enhancedPlaceholdersAdmin.php on line 80phplist version 2.10.12

From the references to line numbers 78 and 80 in file enhancedPlaceholdersAdmin.php it looks like you are still using the old version.

Possibly you did not install the new version correctly. Copy the zip file to your plugins directory and then expand in that directory. Then should have enhancedPlaceholders.php directory enhanced_placeholders containingmain.php enhancedPlaceholdersPopulate.php enhancedPlaceholdersAdmin.php