8 years ago
12
Topic

Hi Guys,

I have this issue that i need sort it out on my Form and Content Type. 

Scenario is :

Organisation submit data on the form. But part of this form should have capability of adding more and more sites (locations). But I was thinking more of creating each article for each site with initial data. Hope this make sense to anyone :)

so to recap there are organisations that has 10 locations. But Organisation should be able to add all of those 10 locations in a single form. But I want the form to save as 10 different articles which helps that organisation to be search. 

Get a VIP membership
1283 Posts
Bucklash
8 years ago
1
Level 1

Hi codekadiya

I would use for loop in afterstore.

I would assign all required values in to an array or arrays or however you like to do it.

and then loop through the values creating an article in each loop

Something like this:

$arrLength = count($sitesArray);

// for loop for ($i = 0; $i < $arrLength; $i++) { $newContent = new JCckContent( array('joomla_content') );

$addContent = $newContent->create( 'my_cool_sites_content_type', array( // #__content table 'id' => 0, // 0 creates new 'title' => $sitesArray['title'][$i], // or however you stored the values 'alias' => $sitesArray['alias'][$i], // or however you stored the values 'catid' => (int) $sitesArray['catid'], // or maybe $fields['catid']->value etc... etc... ), array( // #__cck_store_form_my_cool_sites_content_type 'some_local_field' => $fields['field_only for current_content_type']->value ), array( // #__cck_store_item_content 'some_global_field' => $fields['global_field_of_article_object']->value ) ); }

7 years ago
0
Level 2

Hi Bucklash,

Can you please explain this more. Also steps if possible. 

Thanks a lot. 

4229 Posts
Kadministrator
8 years ago
1
Level 1

Hi, you can use FIeldX or GroupX, it stored in single article but you can still search it:

https://www.seblod.com/resources/extensions/plug-ins/field-x

https://www.seblod.com/resources/extensions/plug-ins/group-x-field

7 years ago
0
Level 2

But Klas, when we save in single article the map and listing will show single item, But what I basically want to save as multiple items which then map and listing will show as multiple pages

7 years ago
7
Level 1

Hi Bucklash and Klas,

Thank you so much for the reply and ideas for this thread. I think I found a road which is similar to Bucklash but really need guidance and help to see it through. 

The logic is using Codepack : BeforeStore type and write the PHP query to store each of the locations as separate new articles in to the database. But I will add another dropdown box to get how many locations user going to provide. so I can run the loop until then.

Can you please confirm this is a good idea or worse idea ever :P. can you also help me to get the php query (example with few fields, as i read this article : https://docs.joomla.org/Inserting,_Updating_and_Removing_data_using_JDatabase) which helps. but need experts advice. 


Thank you. 

4229 Posts
Kadministrator
7 years ago
2
Level 2

Hi,

you should not insert data using JDatabase, you need to use JCckContent class which does necessary queries for you - to insert Seblod article you need to insert data in several tables, not just in com_content, this is why JCckContent exists. You don't need a drop down, you can just count a a number of selected options. 

If you are not a coder I suggest you get one to help you or use Seblod services to do this for you.

7 years ago
1
Level 3

Hi KLAS,

Is there tutorial i can find for JCckContent so i can give it a try...

4229 Posts
Kadministrator
7 years ago
0
Level 4

1283 Posts
Bucklash
7 years ago
3
Level 2

Hi codekadiya

You up for a trade? If I can assist you with this, maybe you could assist me with a Joomla / Seblod thing another time?

We're both in 'Straylia....

7 years ago
0
Level 3

Hi Bucklash Yes im up for that. Thanks a lot.

1283 Posts
Bucklash
7 years ago
1
Level 3

cool

im reachable at fretroom.com.au

7 years ago
0
Level 4

Emailed you. Thank you so much :)

Get a VIP membership