1283 Posts
8 years ago

Hi folks, 

EDIT::11/10/15::I have edited this by improving the wording. This was called "field x::storage::the GOOD WAY"



User 'a' might want to add 2 images. 

User 'b' might want to add 6 images. 

User 'c' might want to add 4 images.

With FieldX you allow the user to repeat a field if they want to, this saves space on your site. 



Create Field to be Repeated 

In the SEBLOD area 'Forms & Content Types', open the ARTICLE content type. I will start by using the Admin Form View

Create a new field by clicking the large '+' icon, select the field type 'Text' and fill in info, I chose:

{" Title: My Text Field", "Name: my_text_field", "Label: My Text Field", "Format / Object: none"}

NOTE: The text field data will be stored by FieldX, NOT the text field

Save and Close the field.   

Place the field in the form, I chose 'TOPBODY', this keeps it separate form the other fields and easier to see for this demo. 



Create FieldX Field

Click the Large '+' icon. Select ' FieldX', fill in info, I chose: 

{" Title: My FieldX", "Name: my_fieldx", "Label: My FieldX", "Field: my_text_field", "Format / Object: Custom | Article | my_fieldx[my_text_field]"}. 

NOTE: "Field: my_text_field" tells FieldX which field to repeat.

Your context will determine whether you alter the remaining values in the CONSTRUCTION section: 

{"Default: 1", "Maximum: 10", "Minimum: 1", "Add: Yes", "Del: Yes", "Drag: Yes"}

If you look in the Databsase you can see a new table "#__cck_store_form_article" with the column "my_fieldx". 



Complete the Form 

Change the view from Admin form View to Site Form View, add the text and fieldx fields to the form, use the same position as in Admin Form View for this example.

You should already have a "submit button" in the Article content type, if not, find "Button Submit" by filtering the list of unused fields and add it to the Site Form View. Do the same for "Article Title".

Save and Close.  


Add SEBLOD Form to Site View 

Next, create a new Joomla! Menu Item, call it 'My FieldX Demo' (or choose any title you like). For Menu Item Type click 'SEBLOD', then select 'Form'. 

For 'Content Type (Form)', select 'Article' ('Article' because that is the content type the fields were added to). 

Save and Close.


Add Content 

Navigate to the front end of your site. By default public users can not enter data, so log in and navigate to menu item just created 'My FieldX Demo'. 

You can see both fields hopefully (following a tutorial never goes to plan so hopefully all is good for you here).

The Field "My Text Field" can be seen, we will hide this field later. 

Fill in the Article Form: 

{" Title: FieldX with Fruit Example", "My FieldX[0]: Apple", "My FieldX[1]: Banana", "My FieldX[2]: Orange"}

(I used the values Apple, Banana, Orange, so in My FieldX I entered 'Apple', clicked the plus sign, entered 'Banana', clicked the plus sign, entered 'Orange'). Save and Close. 

NOTE: Check out database tables "#__content" and "#__cck_store_form_article" to see what happened.



Modify Form

Because we do not need to see the field 'My Text Field' you can hide it.

In the SEBLOD area 'Forms & Content Types', open the Article content type. For each form view (Admin and Site), in the column VARIATION, for the field 'My Text Field' select 'hidden' form the select list (as an additional step you can move it to the position 'Hidden'. I am lead to believe this is a good thing to do for reasons I am not qualified to explain). The field is still in the form, but now hidden. 



Make Content Viewable 

In the SEBLOD area,  'Forms & Content Types', open the Article content type. Change the view to Intro View. Add the the field 'My FieldX' created earlier. Place the field in 'TOPBODY'. Change the view to Content View and repeat. 

Save and Close. 



View Content 

Navigate to the Joomla's Article Manager, you should see the newly created article. I am using a fresh install of Joomla so if I make it a 'featured article' the Article's Intro view will appear on the home page as an item in a list of featured articles. You should be able to see the article with the values you entered earlier. If you click the article title or read more button, you will be redirected to the article's Content view, again with the data you entered earlier. 

NOTE: If you create a new content type, you will need to create a List from List & Search Type, then create a SEBLOD Menu Item to view the List.



If there are any errors let me know :) 



Get a VIP membership
1283 Posts
8 years ago
Level 1

Hi Folks,

EDIT::11/10/15::I have edited this by improving the wording and removed images as a result



CUSTOM Storage Length

If the storage of your field is "Custom", you run the risk of truncating the data stored. Below is the content from the DB under "my_fieldx",  made more readable:


As you can see, a lot of characters are added to the values "Apple", "Banana", and "Orange". 

NOTE: Because we are storing using the setting CUSTOM (required for FIELDX and GROUPX), Seblod adds in it's own funky stuff, making the entry longer.

If your FieldX storage setting is less than the required value then you will not be able to store all of the data. To solve this, in the config area for "My FieldX" field, amend storage like this:

{" Format / Object: Custom | Article | my_fieldx[my_text_field] | Alter (Checked), | VarChar(1024), Change Column" }

If 1024 is not enough, amend to what you need...




Get a Book for SEBLOD