multilingual CRUD library setup in CI

Hi guys

Rather lengthy post coming up, but I'd like to discuss this with you guys.

The company I work at uses it's own PHP framework and has some cool features that I'd like to implement in CI.

One of these is the CRUD library: we have a library/database setup that stores database table field information (conveniently named FieldInfo). For example, it stores the field type (text, textarea, hidden field, select, checkbox...), the field name in 5 different languages etc.

We also have a method that builds the forms, based on FieldInfo with the correct <input type='' />'s, correct language etc... Another method builds an html table, displaying the data stored in the database. Each database table also has a TableNameViewState table. In the viewstate table, we keep track of how many and which columns are shown in the datatable, sorting order etc, so when you log out, it will display the same way when you return.

This makes a very powerful and flexible basis to build applications on, but it still has some limitations. I would like to create something similar in CI with libraries and methods, but include some of CI's own magic and make that extra bit better.

For example: our own system only allows support for 5 languages, simply because we have 5 fields in the FieldInfo table "NameNL", "NameEN", "NameFR" etc... Ideally, I would like a system that could support as many languages as I'd like.

I was thinking of going with a 3-tables-per-table setup in the database: one table that holds the actual data, a viewstate table (as explained) and a third table that stores fieldname translations. Or maybe keep the 2 table setup and have, next to FieldInfo a FieldTranslations table.

Any insights from you guys? How would you handle it?

Sounds like a reasonable course of action.

For language handling, I'd suggest first having a look at CodeIngiter's language capabilities:

CodeIgniter has some form handling and validation capabilities:

As well as a table helper:

You could extend any of these classes or if they don't do quite what you want, add program your own libraries.

Thanks, I was indeed planning on using the language library, but haven't really figured it out yet. I'd rather store my field name translations in a table, as it's easier to update them there (with a CMS). All other strings would be stored in a language file though.

Thanks for the table library link, I totally forgot about it!

I'll likely write my own form helper, or extend the current one, because I'll need more functionality.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.