Almost all web applications need to show announcement to the users, especially if the information is urgent and need to be displayed immediately. Some of the announcements are need to be displayed based on the certain language and also for the certain duration of dates.
The question is, how can we display the announcement that supports for Multi-Language based on the current selected language and Auto-Publish based on the certain range of dates? As we know, implementing the multi-languages content including publishing them for the certain duration of dates in a web application was never easy. Hey, no worries! Now you can simply display it easily by using MasinoFixedWidthSite10 extension. I just updated the extension including the demo project file so that you can implement it into your own PHPMaker project easily and quickly.
Demo Project File
In the demo project file, you can see how we can manage the announcement records that separated in the announcement table, especially while you (as Admin) are inserting or updating the announcement records. We just need to add few lines of code into Row_Inserting and Row_Updating server events to handle some possibilities. The rest of it has been handled nicely by MasinoFixedWidthSite10 extension. You can download the complete project file which has included this feature from this link, and follow this article: Step by Step to Implement Masino Extensions in a New Project of PHPMaker 10 if you want to implement it into your new project.
Extensions Advanced Settings
By default, this feature is disabled in MasinoFixedWidthSite10 extension. In other words, if this feature is disabled, then the languages table is used instead. Please note that if you use languages table, then it only has the ability to display the announcement in multi-language and only one record for one language, but not to display the announcement based on the duration of dates. So, if you want to enable multi-language and auto-publish for the announcement and also you want to manage many announcement for one language, then simply enable SeparatedAnnouncementTable and define the table name from AnnouncementTable under the Advanced Settings of MasinoFixedWidthSite10 extension. By using the announcement table, now you can set the certain announcement published based on the certain date duration and it also supports for multi-language. Please note that you must create a new table named announcement (you can change this table name from the Advanced Settings of the extension).
New Table
If you want to create the announcement table without using the complete demo project file above, then make sure you have already created the following new table in your database:
DROP TABLE IF EXISTS `announcement`; CREATE TABLE `announcement` ( `Announcement_ID` int(11) unsigned NOT NULL AUTO_INCREMENT, `Is_Active` enum('N','Y') NOT NULL DEFAULT 'N', `Topic` varchar(50) NOT NULL, `Message` mediumtext NOT NULL, `Date_LastUpdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `Language` char(2) NOT NULL DEFAULT 'en', `Auto_Publish` enum('Y','N') DEFAULT 'N', `Date_Start` datetime DEFAULT NULL, `Date_End` datetime DEFAULT NULL, `Date_Created` datetime DEFAULT NULL, `Created_By` varchar(200) DEFAULT NULL, `Translated_ID` int(11) DEFAULT NULL, PRIMARY KEY (`Announcement_ID`) ) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
Of course, you may manage the announcement records by generating the table above and enhance the related field, for example, set Language as lookup field to the languages table.
The Challenges
The challenge of implementing this feature is how we can handle the possibility of the intersection dates among the announcement records. Of course, we must not allowing there are more than one record in the same language which have the intersection of duration dates, since if that happened, then it will cause the collision while displaying some announcement records at that time. On the other side, we must allow more than one record in the different language which will have the same duration dates, since this is important in order to implement the multi-language announcement properly. See what I mean? 🙂
Not only that, we have to handle also how to make the relationship among the announcement records so that they can be implemented as the multi-language content. Let's say after we inserted a new announcement record in English, then we need to translate the content into the other language(s). For this purpose, we can simply use Copy record feature. But, how can we make the relationship among those records? We need to handle the duration dates for those records must be the same, right? Again, no worries! I have successfully handled it nicely from the demo project above. 🙂
Demo Link
Want to see the demo? Simply click on this link, and then login using username admin and password master to manage the announcement records. To see the announcement in action, then make sure you have enabled Show Announcement by clicking this link.
Download
Download the Demo project and the extension files from here.
Hello Masino,
is there a Chance to find a tip for just implementing the Language FormRow into the Header Row? This is all i Need. I don`t want a big solution like an Extension for that.
Besides that .. i love ilovephpmaker.com!
Hi Huelya,
Yes. You may customize the PHPMaker template instead. See the related code in “template.php” file. Please read “Customizing Template” in the help file for more information.
In addition, you may also read the articles that related to how to customize the template under Customize Template menu in this site.
Thanks for loving ilovephpmaker.com. 🙂
View, Edit, Copy, Delete have been disappeared at my script after doing steps to install FixedWidthSite extension. Any feedback for this neccessary? Thanks before.
Make sure you have downloaded and enabled ALL the Masino Extensions for PHPMaker version 10 and then regenerate all the script files again.
Announcement doesn’t appear at my script after activating it, why?
1. Make sure you have added the records into “announcement” table which have the valid duration time with today so that it will be displayed properly.
2. Make sure the value of “Show_Announcement” field in “settings” table has been changed become “Y”.
3. It is recommended for your to try PHPMaker 10.0.5 Demo Project Files by yourself in your local computer. Also, try to play with this demo project to see it in action and compare it with your demo project file above.
Fatal error: Call to undefined method stdClass::SaveProfileToDatabase() in D:\xampp\htdocs\women\logout.php on line 193
Appears when click logout link, why?
Make sure you have downloaded and enabled ALL the Masino Extensions for PHPMaker version 10 and then regenerate all the script files again.