Notes by JDeveloper for JDeveloper
Once you master it, you're gonna like it

The Behavior of Field in Seblod

Written by Viktor Iwan

Seblod is a best thing happen in Joomla ! but as developer, you sometime like to extend seblod to have field the way you wanted, this article explain on how seblod field works. At this time of writing there's no official developer guide in seblod, so this is solely based on my experience on working with seblod for over 3 years.
Seblod field is working in two level of depth: Form Field (field that joomla user sees) and Construction Field (field that made Form field, storage and behavior set here). 

Form Field

There are two type of the form field:

  • Bind to specific content type
  • Independent for any content type

On your first several project, you likely to use the bind type, it indicates by a locked icon on content type screen.

Note: when you see this padlock active, every field you create will be a bind one

 

You use Independent type, for field that likely need for multiple usage, for example a social tag field . You need to have function for article to be able to share in Twitter and Facebook. By build a social tag field, you can use in multiple content type.

A form field is required to build a Content Types. It has  many field types and you can see on the List Field. When setting up a form field.  Each parameter usually self-explainatory like Default Value, Max Length, etc. Two thing that you need to aware is:

  • Format of the value stored
  • Joomla Object Type
  • Location of the value stored (Storage location)

Format of the value stored

There are 3  type of value format:

  • Standard. Usually use single value in single field
  • JSON. Create multiple-value in single field in JSON Format
  • Custom. Create multiple -value in single field in native SEBLOD Format

Location of the value stored (Storage location)

There are 5 storage object type:

  • Free Type. You have option to store anywhere
  • Article. Store in relation with  #__content
  • Category. Store in relation with  #__categories
  • User.  Store in relation with  #__users
  • Usergroup. Store in relation with  #__usergroup

Two more option that you able to set:

  • Field. Related with field column on joomla core table based on Storage object you set above
  • Alter. The decision when you need to modify joomla core table OR use additional SEBLOD’s custom field table.

When you manage an article, If your storage  field location is in introtext, you have to use Custom Format. When you manage a category,  you also have to use Custom Format in Description

Technical notes
For additional seblod custom field table, the rules of additional table’s name  as follow


Form Field

Object

Table in Database

Bind Mode

Article

#__cck_store_form_<content type name>

Unbind Mode

Article

#__cck_store_item_<content type name>

Bind Mode

User

#__cck_store_form_user

Unbind Mode

User

#__cck_store_item_users

 

Construction Field

Construction Field is highly related with understanding #__cck_core_fields table works
One of characteristic of Construction Field is where storage is set to ‘dev’.  Another thing to look is the ‘storage_field’.  “storage_field “  stored column name  of where the value of Form Field stored
So, let’s take a look on ‘core_defaultvalue’ field. The objective for this field is to set a default value in Form field.

Now, see how’s the process behind the scene works. If you run query for ‘core_defaultvalue’ in name field on  ‘#__cck_core_fields’, and you look at ‘storage’ and ‘storage_field’ you’ll find two value:
‘storage’ is set to ‘dev’, ‘storage_field’ is set to ‘defaultvalue’

What happen is..when you create an Form Field,  for example a Text Field, you’ll be ask for a default value and ‘core_defaultvalue’ will handle this. If you set a value in default value field,  it will be stored in defaultvalue column on ‘#__cck_core_fields’.

 


Seblod's JCckDev::renderForm Mastery

Written by Viktor Iwan

Due little documentation about seblod development, here a little note tips regarding JCckDev::renderForm

What is renderForm anyway ?

If you build a field plugin, you might want to set parameter for it. I'm not refer to how field display in Admin or Site Form, but how field get setup. Perhaps a visual screenshot would help:

Seblod Field Setting

 

So, a seblod field that you see in Admin/Site Form (i call it Form Field) is made by another field (i call it Construction Field). Now, what i'm shere here is refer to Construction Field.

Construction Field is use in edit.php, of tmpl folder in cck plugin field:

JcckDev::renderForm() is use to display parameter to construct your Form Field

An example of JcckDev::renderForm usage, would be like this:

echo JCckDev::renderForm( 'core_defaultvalue', $this->item->defaultvalue, $config );

Let's see how we can understand and do little bit 'magic' with this function alone

renderForm() is declared on libraries/cms/cck/dev.php, but before we dig into explanation of its parameter, i would like you to know that field setting (and behavior) is related with '#__cck_core_fields' table.

So let's start:

public static function renderForm( $field, $value, &$config = array( 'doValidation' => 2 ), $override = array(), $inherit = array(), $class = '' )

$field : field name 
$value : Default value (please aware the where the value stored)
$config : some configration, i use to live it as default and i rarely find any new setting here in other fields
$override : some override with default configuration, the most 'magic' begin here
$inherit : Well.. no idea, i use to live it as default which 'array ()', you can set array('name' => somevalue, 'name' => somevalue,'after'=>somevalue )
$class: set specific class

 

 For example, let's built a default twitter username parameter on top of core_defaultvalue field

1. Copy Paste and override the label

echo JCckDev::renderForm( 'core_defaultvalue', $this->item->defaultvalue, $config, array('label'=>'Twitter Username' );

2. Change storage field

echo JCckDev::renderForm( 'core_defaultvalue', @$options2['defaulttwitter'], $config, array('label'=>'Twitter Username','storage_field'=>'json[options2][defaulttwitter]' );

 $option2 is the recommended way to have custom parameter, if you like to use/override other field, please see #__cck_core_fields and see other field (but beware of breaking core seblod functionality, if you unsure, use options2)

3 Add CSS Class, 'twitterusername' (optional)

echo JCckDev::renderForm( 'core_defaultvalue', @$options2['defaulttwitter'], $config, array('label'=>'Twitter Username','storage_field'=>'json[options2][defaulttwitter]',array(),'twitterusername' );

note: notice i use 'array()' to send null array for $inherit parameter

 

You like to know on how seblod field works ? Click this Seblod Field Behavior Article (coming soon)

Like to improve and make this article better to readl ? Email me : This email address is being protected from spambots. You need JavaScript enabled to view it.

 

 

 

 

 


Load Seblod Anywhere (and current limitation)

Written by Viktor Iwan

So you need to load seblod in any where you wanted ? let the search begin

Read more

Custom Seblod Plugin Development - Part I

Written by Viktor Iwan

SEBLOD 2.0 powers your Joomla site into Powerfull Website Engine. I personally think that this CCK Component  is what missing in Joomla. But still, there's no such thing that 'out-of-the-box' development tools. Eventhough with a lot of awesomness, There's couple of things that require you to do customization. Fortunately, Octopoos team open the opportunity to extend seblod, that is through custom seblod plugin development.

Here's one you should understand about Seblod plugin. Basically seblod plugin is a joomla plugin, a seblod plugin will construct a field, and this field will helps you construct your content type. Why i use the word "construct" ? it is because every field will have it's own independent characteristic (parameter/variable). Think about Inheritance concept is Object Oriented Progamming, the concept still the same.

So when you use "select_dynamic" for student_list, and then you use "select_dynamic" for project_list, these "select_dynamic" basically are different (the query is different, right). Hope this all make sense for you.

So how you create your own base seblod plugins ? This simple question require a lot of answer, i can't give you the details since i'm still learning about it myself, but i'll share to you what i already know... let's start !

Read more