The Blog




Adding Customfields

Customfields allow you to expand the internal tables of OGMA and add new fields. Say for example you wanted to allow each of your users to a a bio about themselves which could then be used on the site as an "About the Author" Section

Add a Field

First off you need to create the field and add it to the Users Table.

Form the admin Panel Select Site->Custom Fields

Click Create New Customfield

Fill in the relevant fields.

  • Name unique name for the field

  • Table select the Table to attach the Customfield to.

  • Type select the type of field.

  • Add to Cache Select whether to add the new field to the caching for the table.

  • Description used when building the forms for the Labels

  • Options Any additional field options, e.g. for textarea you can specify the number of rows.

So as you can see above we have created a new Field called "bio" which will be added to the custom tab on the Users admin page. As we've added it to the cache ic can be retrieved by querying the Users DB and fetching the field.

$usersdb = new Query('users');

$user = $userdb->getCache()->find("user = mike")->get();

echo $user['bio'];

Some notes on how it works

If you have records already created on a table the new field will be amended to each of the existing records.

If you delete the new Field it will also be deleted form each of the records.

Adding and deleting fields forces the Cache to be rebuilt for that table.

We do not recommend you cache large field types (textarea, editor etc..) on table that you expect to have a lot of records in.

blog comments powered by Disqus


Sponsors

 style="display:inline-block;width:300px;height:250px"

 data-ad-client="ca-pub-2147322061915808"

 data-ad-slot="6874835794">

Theme Created by BLACKTIE.CO