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).
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 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. 🙂
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 the Demo project and the extension files from here.