83 Posts
squareweb
5 years ago
Topic

Hi,

I've managed to redirect from a (search and)  list-form to a front-end content-form to add children of specific content-type by passing parent-ID of Parent (from list). It works fine until I click "save and new" in the child-form. The item(child) is saved but the new empty form doesn't contain the parent_ID anymore because the URL-parameter (which was initially passed through by the list-form) is gone. Is there a way to keep or get the parent-ID in the URL-variable while using the "save-and-new"-button? I do not see such a possibility in the button-config.

Thanks in advance

Mark

Get a VIP membership
4229 Posts
Kadministrator
5 years ago
4
Level 1

Hi,

save&new does not pass any values. You could try using button Free and replicate url for new article + pass necessary variables from parent using Custom variables feature.

83 Posts
squareweb
5 years ago
0
Level 2

Thanks Klass for your response. But does Button free save content? Nothing get saved when I "submit" button free?

Thanks

83 Posts
squareweb
5 years ago
2
Level 2

Well, I've tried to turn this around and spend one day trying all possible combinations with button-free as well as save-and-new (submit)....

Maybe it's my lack of knowledge but I can't get it working the Seblods-way. With the submit-button option it's impossible to pass URL-parameters and with the button-free option it's possible to send parameters but nothing gets saved.

I guess I have to use "save and close" then control is returned to the list and then I've to hit again "add new child"-button... This is a pity because it's taking extra time (clicks). 

If anyone has any idea how to stay in the "child-form" to add multiple children after each other without losing the parent-ID thery're welcome (:-

For now I'll try my luck figuring out session-variables although there is not information on the internet about this in Seblod.

Keep you posted.

Regards

4229 Posts
Kadministrator
5 years ago
1
Level 3

Have you tried Save&redirect  - on the second thought it should be a better option, you can include custom variables in redirect and choose menu leading to this form for redirect.

83 Posts
squareweb
5 years ago
0
Level 4

Hi Klas, thans for responding.

I've managed to fix this with the help of session-variables and URL-extension (live value of current URL) together with codepack-etension (before-render and after-store).

My solution below:

In search-list-form (parent form):

1. Add icon field to redirect to child-content-form (menu-item) to add child-content

In child-content-add-form:

1. Create field (codepack - beforerender).

2. Add session-code (see below) to store URL of first add-content-form (this one contains parent-id in URL).

3. add free field containing URL of current add-form (set bij live-value: URL, custom (all checkboxes on)

4. Add after-store-code (codepack) field to set target-URL ($config['url’], which was saved on before-render), see code below.

Now you can use “save & new” as many times as you like without returning to the main search-list-form after every (child) save. The parentID is provided by replicating the first child-content-form-URL which is stored in session-var and restored in config-URL every time after child-save.

On adding last child-record user can use “save and close-button” so control will be returned to parent search-list-form.

//======================

// before render code

//======================

//

// initialising stuff

//

define( '_JEXEC', 1 );

define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../..' ));

require_once ( JPATH_BASE. '/includes/defines.php' );

require_once ( JPATH_BASE. '/includes/framework.php' );

$mainframe = JFactory::getApplication('site');

$mainframe->initialise();

$session = JFactory::getSession();

//

// get parentID from field-value (this value is passed by URL-parameter from parent search form)

//

$myparentID = $fields['td_parentid']->value;

//

// save current (first) content-add-form-URL (because this one is working alright)

$myURI = $fields['sysdisplayfield']->value;

//

// second or n-th time (myparentID = empty)? use saved session-URL

// first time? (myparentID NOT empty)? save current URL in session-URL

//

if(empty($myparentID)){

echo "empty....using myURI" . $session->get('myURI');

$fields['td_parentid']->value = $session->get('trParentID');

} else {

$session->set('trParentID', $myparentID);

$session->set('myURI', $myURI);

echo "td_parentid: " . $myparentID;

}

//

//======================

// after save code

//======================

//

// get URL from session en store in config-URL to show add-content-form with correct parent-ID

//

$session = JFactory::getSession();

$config['url'] = $session->get('myURI');

Get a VIP membership