The first improvement to add to your site is the possibility to archive old articles. If you use your site in a more intensive manner, you may end up having users view articles from months ago, which have no relevance in the present context. Archiving is a more useful option than deletion, because you might need the files for future use.
The visible_pag field makes the archiving implementation very simple. This field determines whether an article will be displayed or not. You could edit each article and set the field to 0 (not visible), but for a large number of articles this takes a lot of time. This is why you will create a new administration page, allowing you to select a date from a calendar. All records that were posted before that date, are to be set as invisible.
To create this page, follow the next steps:
In the admin folder, create a new file, called archive Open it in Dreamweaver.
Since this is an administrative page, you should apply a Restrict Access to Pageserver behaviorA server behavior is a reusable component for server-side development. They add blocks of code to your pages for accomplishing specific tasks. Dreamweaver comes with several default server behaviors and the InterAKT extensions add many more to this list...
Next, you must insert the field that will allow selecting a date. To implement both the form elements and the SQL logic, use the Custom Form Wizard, that is accessible from the MX Kollection tab of the Insert bar.
Once the Custom Form Wizard opens, configure it in the following manner:
In the Connection drop-down select the databaseA database refers to data organized and stored on a computer that can be searched and retrieved by a computer program. Most industrial-strength and many smaller database applications can be addressed using SQL (Structured Query Language). connection used in your site. If you do not have a connection, create a new one, by clicking on the Define button.
In the When finished, go to text field, enter the page that will be opened when the operation finishes: index
In the second step of the wizard, you must add a transactionA transaction is a group of SQL statements whose effects are logically connected. Anything from simple queries to inserting, and deleting operations can be considered a transaction, as well as more complex groups of several statements which accomplish a specific task. field that will allow you to enter the date. Click the Plus (+) button of the Form fields grid, and enter the label: Archive articles older than. Once added, change its submit as property to date. If left as text, it will provide bad input to the database transaction.
Note: If you are using a Microsoft Access database, in the Submit as drop-down menu, another option will be available: Date MS Access. Select this option when submitting the date.
If you have MX Form Validation installed, an additional step is available in the wizard: the third, providing a way to validate input. Simply skip this step, as it is not required.
In the final step of the wizard, you have to write the SQL queryA query is a SQL command that will extract information from the tables of a database. Essentially, a query is a request for information from your database. that will perform the actual operation. It is a simple update query, involving the field added at the last step as dynamic dataThe InterAKT Dynamic Data tool is a replacement for the standard dynamic data dialog. It is used in the MX Kollection 3, to provide a unified way of building mark-ups, or place holders. These are recordset fields, server or session variables, and other types of dynamic data that are replaced at runtime by their corresponding values:
UPDATE page_pag SET visible_pag=0
WHERE date_pag<{Archive_articles_older_than}
Just paste the above code in the SQL area. The dynamic mark-up can be selected by clicking the InterAKT Dynamic Data icon, and choosing the right transaction field.
When you click the Finish button, a form will be added into the page, along with some server behaviors. If you need to edit the transaction properties, simply double-click the corresponding server behavior in the Server Behaviors tab of the Application panel.
By default, the Custom Form Wizard will name the submit button as Insert Record. Change it to Archive.
If you preview the page in the browser, after you login, a standard text-box where you can enter a date is displayed. If you enter a valid date, it will perform the requested operation and return you to the admin index.
The problem with this approach is that you have to enter the date by hand, and in the correct format. Why not use a calendar, where you can visually select the date?
To improve the standard text-field, you must have MX Widgets installed. If you do, then simply select the text-field on page, and apply the DatePicker text field server behaviors, from the Server Behaviors tab->MX Kollection->Form controls.
Once the dialog box opens, you can configure some properties for the calendar, like whether to use single - click or double-click for activation, and more. Select the options that suits your taste, and click on OK to apply it:
In Dreamweaver, there is little modification to be seen, unless you look at the code. When you save and preview the page in the browser, however, a new button is displayed next to the text-field. When you press it, a calendar will open, allowing you to select the date:
When you click the Archive button, the SQL query will run, and will update records as necessary. You can verify this behavior, by opening the Article list in the administration area, and notice the new values.
The next improvement you'll add to your site, is to replace the text-area form element used to enter the article content with InterAKT's KTMLLite control, allowing you to enter rich content visually.