=========================================== Multiple Content Regions Plugin for phpList =========================================== Plugin Name: PBTS Extra Plugin URI: http://pizzabytheslice.com/phplist/pbts_xtra/ Description: Enables Templates to have multiple content regions and conditional inclusion (and exclustion) of areas based on content availability. Author: Courts Carter Version: 0.04 [beta] Author URI: http://pizzabytheslice.com/ -------------------------------------------- In this Document: 1. Installation (basic) 2. Using included Sample Template 3. Installation, replacing phpList's Editor with PBTS's 4. License (CreativeCommons -- no reselling) == Installation == ------------------ OVERVIEW Time to install: 10 minutes You'll need to edit the config files, unzip the plugin into your plugin directory, and make two modifictions to one phplist file. STEPS 1. open config/config.php and turn off the WSYSIWYG editors via a configuration setting (~line 481): define("USEFCK",0); 2. Double check that TinyMCE is also turned off: define("USETINYMCETEMPL", 0); 3. Lastly, you'll probably want to turn off the auto-generated text email. Or, turn on the manual text message option: define("USE_MANUAL_TEXT_PART",1); 4. If you don't have your plugin directory defined you'll also need to set this: define("PLUGIN_ROOTDIR","plugins"); or you may specify some other path. 5. unzip pbts_xtra.zip files into your plugins directory. 6. Mofifying the SendEmail Library. BACKUP YOUR FILE BEFORE PROCEEDING These last two steps are the only ones requiring mods to core phpList files. Open admin/sendemaillib.php. Add this line to the top of the file: include_once dirname(__FILE__).'/plugins/pbts_xtra/pbts_xtra.inc.php'; Note: if you installed the plugin in a different directory set this as needed. 7. Next we replace the current Template tag substitution with the PBTS_XTRA calls. Locate the following code (about line 180): if ($cached[$messageid]["template"]) # template used $htmlmessage = eregi_replace("\[CONTENT\]",$htmlcontent,$cached[$messageid]["template"]); else { Replace (or comment-out) these lines with this: if ($cached[$messageid]["template"]){ # template used if (!preg_match("/\[PBTS_/is", $cached[$messageid]["template"])) $htmlmessage = eregi_replace("\[CONTENT\]", $htmlcontent, $cached[$messageid]["template"]); else $htmlmessage = pbts_replace_content( $htmlcontent, $cached[$messageid]["template"] ); } else { That's it. (hopefully) == Sample Template == --------------------- In the zip there is a sample_Template.php. Create a Template and import this file as the content. It's important that the WYSIWYG editor be turned off, otherwise it will rewrite my custom region tags, replacing the & with & and that will definitely break this. The sample template is not necessarily a study in "best email layout practices", but serves for illustration purposes. I just had to add that, not that I'm ashamed of this one, but I'd definitely do it differently. == Upgrading Message Editor == ------------------------------ OVERVIEW As of this writing the plug-in structure provides a less than ideal level of integration; if you want to enable the pbts message editor as a replacement of the standard phpList editor follow the basic installation instructions above, then ... EXTRA STEPS (REQUIRED TO MAKE THE PBTS EDITOR THE DEFAULT MESSAGE EDITOR) We're going to modify the core phpList file that emist the message editor. Because this is an important file, please, back it up and keep a good copy in a safe place, just in case. We're going to make three edits to this file. 1. Backup admin/send_core.php 2. Adding the PBTS_XTRA library. Open send_core.php and find this line (should be the first one in the file): require_once dirname(__FILE__).'/accesscheck.php'; add this line immediatley after the above: include_once dirname(__FILE__).'/plugins/pbts_xtra/pbts_xtra.inc.php'; 3. OK, now let's modify where the editor's form fields get emitted. Jump down to around line 1100 and find these statements: } else { $maincontent .= '<textarea name=message cols=65 rows=20>'.htmlspecialchars($_POST["message"]).'</textarea>'; } Replace this line with: } else { # let PBTS emit the form fields based on the Template tags: $maincontent .= pbts_send_core_editor(); # end, PBTS } 4. Lastly, we need to "smarten up" the code that's executed when you clice the Save Edits button. Locate the following statements (about line 270?): if (!$htmlformatted && strip_tags($_POST["message"]) != $_POST["message"]) $errormsg = '<span class="error">'.$GLOBALS['I18N']->get("htmlusedwarning").'</span>'; $query = sprintf('update %s set '. 'subject = "%s", '. 'fromfield = "%s", '. 'tofield = "%s", '. Let's insert a line between the two above: if (!$htmlformatted && strip_tags($_POST["message"]) != $_POST["message"]) $errormsg = '<span class="error">'.$GLOBALS['I18N']->get("htmlusedwarning").'</span>'; # Add PBTS processing to save: if (isset($_POST['pbts_xtra'])) $_POST["message"]= pbts_send_core_save(); # done adding PBTS lines. $query = sprintf('update %s set '. 'subject = "%s", '. 'fromfield = "%s", '. 'tofield = "%s", '. == License == -------------- This work is licensed under a Creative Commons License http://creativecommons.org/licenses/by-nc/2.0/