Have you ever encountered situations where you want to display the announcement for all of your users in all pages of your website that created with PHPMaker? Well, I have. So I created the following modification by customizing the template in order to implement it each time I generate my website using PHPMaker. Now you can display your announcement easily by setting it up the related constant in your configuration file. Besides that, you have to define the announcement itself from the .xml language files for the content of the announcement. Why must we define it in .xml language file? Because it has to support for multi language, right?
This announcement feature is very useful to broadcast some important information that need to be known by all of your users. By using this customization, you will know how to create the new constants and using it for all pages. Also, you will know how to create a user-defined style into your .css file according to the style or theme you are using for your website. Lastly, you will know how to implement the global code inside the PHPMaker application that will be used in all of your pages.
All we have to do is customizing PHPMaker template files and adding some code into Server Events section of PHPMaker. In other words, we will not modify the generated script files.
Updated on May 30, 2012: This customization has been implemented in PHPMaker version 9.0.2, it matches to each other, and as a result, it works properly.
Updated on July 21, 2012: This customization has been implemented in PHPMaker version 9.0.3, it matches to each other, and as a result, it works properly.
Updated on September 4, 2012: This customization has been implemented in PHPMaker version 9.0.4, it matches to each other, and as a result, it works properly.
Updated on November 28, 2012: This customization has been implemented in PHPMaker version 9.1.0, it matches to each other, and as a result, it works properly.
Updated on February 9, 2013: This customization has been implemented in PHPMaker version 9.2.0, it matches to each other, and as a result, it works properly.
Updated on June 17, 2013: This customization below has been handled by using MasinoFixedWidthSite extension. You don’t need to implement the customization below if you use my extensions together with the original PHPMaker Template and Extension files.
[hidepost]
-
Open your C:\Program Files\PHPMaker 9\languages\english.xml file, and find this code:
</global>
before that line, please insert the following code:
<phrase id="AnnouncementText" value="This is the sample of announcement text, just change this sentence from your language file ..."/>
Do the same way with your another .xml language file. For example, I am also using Indonesian, then I add the same phrase into my C:\Program Files\PHPMaker 9\languages\indonesian.xml file:
<phrase id="AnnouncementText" value="Ini adalah contoh teks pengumuman, cukup ubah kalimat ini dari berkas bahasa ..."/>
-
Open your C:\Program Files\PHPMaker 9\themes\ew.css file, and find this code:
/*END_SYSTEM_STYLES*/
before that line, please insert this following code:
/* announcement */ .msAnnouncement { font-family: Tahoma; /* font name */ font-size: 8pt; /* font size */ background-color: #98FB98; background: #98FB98 url(../phpimages/info.gif) 5px 5px no-repeat; padding: 0.5em; padding-left: 25px; border-left: 1px solid #98FB98; border-right: 1px solid #98FB98; border-top: 1px solid #98FB98; border-bottom: 1px solid #98FB98; display: block; } /* announcement */
-
Open your \Script\ewcfg.php file, and find this code:
// General
before that line, please insert the following code:
// Begin of modification Announcement in All Pages, by Masino Sinaga, May 12, 2012 define("MS_SHOW_ANNOUNCEMENT", FALSE, TRUE); // Announcement status, set the second parameter to TRUE to show the announcement in all pages. define("MS_ANNOUNCEMENT_TEXT", "", TRUE); // Announcement text, the value is derived from the .xml languages files // End of modification Announcement in All Pages, by Masino Sinaga, May 12, 2012
-
Open your \Script\template.php file, and find this code:
<!--##=SYSTEMFUNCTIONS.CSSFile()##-->
before that line, please insert the following code:
<?php // Begin of modification Announcement in All Pages, by Masino Sinaga, May 12, 2012 ?> <?php if (MS_SHOW_ANNOUNCEMENT==TRUE) { ?> <?php if (MS_ANNOUNCEMENT_TEXT!="") { ?> <span class="msAnnouncement"><?php echo MS_ANNOUNCEMENT_TEXT; ?></span> <?php } ?> <?php } ?> <?php // End of modification Announcement in All Pages, by Masino Sinaga, May 12, 2012 ?>
-
Next step, still on your PHPMaker application, click on one of your tables from the left panel, and see in the right panel of your PHPMaker application click on the Code (Server Events, Client Scripts and Custom Templates) tab, and then click on Server Events -> Global -> All Pages -> Page_Loading, and find this code:
// Page Loading event function Page_Loading() {
after that line, please insert the following code:
// Begin of modification Announcement in All Pages, by Masino Sinaga, May 12, 2012 global $Security; global $Language; if (MS_SHOW_ANNOUNCEMENT) { @define("MS_ANNOUNCEMENT_TEXT", ew_JsEncode($Language->Phrase("AnnouncementText")).' ', FALSE); } // End of modification Announcement in All Pages, by Masino Sinaga, May 12, 2012
-
Finally, re-generate your script files using PHPMaker as always. If you want to display the announcement, then change this code:
define("MS_SHOW_ANNOUNCEMENT", FALSE, TRUE);
become:
define("MS_SHOW_ANNOUNCEMENT", TRUE, TRUE);
[/hidepost]
Leave a Reply
You must be logged in to post a comment.