Every PHP-programmer faces the task of outputting a large number of lists (dictionaries/references) on the HTML-page.The typical lists are gender, country, job etc. Here is an example of the HTML-page containing lists (dictionaries/references):
List elements are marked with red. List can be either “select” element or “checkbox” and “radio”:
The core is that generally there are many such lists on the page. Every web-site consists of a number of such pages. It takes a lot of time and efforts to work with the large amount of lists and references. Every list is actually stored in a separate table of a database and is extracted from it by its own specific request. If there are many of lists, the page code becomes too complicated to cope with. Moreover, if the system has been developed for a long time, it suddenly becomes clear that every reference should work in several languages at the same time, for example, in English, Russian and German. And program code becomes more and more inexplicable and complicated with every such upgrade of the page. So,
One cool tool is wanted for the comfortable work with any dictionaries/reference.The tool should work with all system dictionaries at once and provide them with a single API. Would you like to create a new list? This problem does not exist with the tool now: any task is solved in a minute as it does not require any additional coding.
What are the main tasks of the tool?Undoubtedly, they are
How does it work and where it can be used? Library solves two main tasks:
How can the list be displayed with myref library?For example, if you need to show “gender” and “job function” lists on your HTML-page then execute only one command in your script:
$refs = $refController->getReferences(array( ‘gender’, ’job_ function’ )); The reaction of the library on this command will be:
var_dump($refs);
array(2) {
["job_function"]=>
array(3) {
["design"]=>
string(17) "Making web design"
["prog"]=>
string(11) "Programming"
["srs"]=>
string(31) "Preparing Software Requirements"
}
["gender"]=>
array(2) {
["f"]=>
string(6) "Female"
["m"]=>
string(4) "Male"
}
}
Then we need to output all received values onto the HTML-page. Only one command is required for this in Smarty ( http://smarty.php.net ):
$tpl->assign($refs);
In the HTML-templates lists are created in a similar simple way:
{html_options name=gender options=$gender}
{html_options name=job_function options=$job_ function }
The ordinary way of displaying the list is the following:
<select name=”gender”>
<?php
foreach ($refs[‘gender’] as $key=>$val) {
echo “<option value=\”$key\”>$val</option>\n”;
}
?>
</select>
And one more similar block for the job_function reference. All is quite simple…
How can the lists be added to the database with this library?The administrative script available with the library can be used for inputting data to the database. Script and library installation is carefully described in the installation manual. There is no point in describing the order of operations in the administrative script, so I recommend you to see the demonstrational version of the script and to read the user’s guide for it. It is possible to put lists into the database not only through the available administrative script, so you can use your own one with API provided by myref library: methods for adding, removing, changing and obtaining the lists). Additional advantages of the myref library
Return the error code and get the translation to the different languages. You can manage the error messages in the administrative system and database, and not in the configuration file! The myref package consists of:
SummaryUndoubtedly, this library makes script-related tasks much easier for PHP-programmer and enables him to considerably shorten the time for software development and to concentrate on other much more important modules. Order ScriptOrder for $15 from eMetrix secure payment system.
Live Demo
Be in touch with Script Updates
|








