5 Posts
afi
8 years ago
Topic

Hi community!

Hope someone can give me an advice...

I have a form for submitting a new category and a new article in one step. How can I manage that the ID of the stored new category is automatically stored in the atricle's cat_id field?

Thank you very much!

afi

Get a VIP membership
4229 Posts
Kadministrator
8 years ago
2
Level 1

Hi,

you can't store 2 different content objects (article, category) at once, to do something like what you desire you would need to store one of them using custom code e.g. using afterStore event from Code pack

5 Posts
afi
8 years ago
0
Level 2

Hi Klas,

thank you for your hint. But, how SEBLOD is designed to solve similar scenarios like this? For instance if you have an order management and you want store all order details and then all related order positions referencing it the order they belong to?

5 Posts
afi
8 years ago
0
Level 2

Hi,

Thank you! As you adviced the Code pack solved my issue. I create new category within onBeforeStore event and correspondingly update the cat_id of the article to reference the new category before it is stored.

But in consequence I came to a new issue. I'm not sure if this is a general issue with SEBLOD or just because I use the Code pack. The stored category and the stored article automatically get updates within the asset and ucm_history table. But the version note is not stored. The field in JOOMLA//Article//Base//Article Version Note has no defined storage. How can I update the article's version note before storing the article? And if I have to do manually (e.g. within onAfterStore event), how can I get the version_id of the current article's version item in ucm_history table? Because there can be several versions for each article and the latest version_id is not necessarily also the current version (e.g. if the user choose a previous version as currently active).

And another issue is, how can I add the Versions button in the front-end editing using a SEBLOD form? in standard Joomla form I see the button. But I cannot add to SEBLOD form (site form). It is also not prepared within App Folder//Core. Is there a way to get the Versions button in the SEBLOD site form?

4229 Posts
Kadministrator
8 years ago
0
Level 1

Hi,

you can manage parent-child relations in few different ways in sebod:

a) using fieldX or groupX - here you have just one record in the database table (e.g. orders) and all data is stored to parent (in json format, child field is added using field X or (more likely applicable to your case) using groupX, where you can add a whole group of fields from child content type (see

http://www.seblod.com/resources/extensions/plug-ins/group-x-field for details)

b) using some field that will relate the two content types - you can use Joomla article field or select dynamic/checkbox dynamic (with query that selects articles from some category). But in this case you need to store this 2 article separately e.g. first creates order, then when user saves the article, redirect to the child form.

With some ajax javascript you could potentially store both at the same time, but this would be a custom solution outside the scope of this forum. Alternatively you can also use server side (php) code to do the same, e-g- to get category id you would first need to store it or run a query to get next insert id from category table.

Get a Book for SEBLOD