api ordering item insert

5 years 8 months ago #61662 by oleg_kosarev
i'm insert item for this code
// Define component paths
define('JPATH_COMPONENT_SITE', JPATH_SITE . DS . 'components' . DS . 'com_flexicontent');
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
 
require_once(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'models' . DS . 'item.php');
$item_model = new FlexicontentModelItem();
$user = JFactory::getUser();
 
$data = array();
$data['id'] = 0;
$data['type_id'] = '2'; // e.g. 1 for article
$data['language'] = 'lv-LV'; // e.g. 'en-GB'
$data['catid'] = 100; // INTEGER ... the main category of the item
$data['created_by'] = $user->id; //User Add INTEGER ID users
$data['vstate'] = 1;  // item version is approved
$data['state'] = 1;  // 1 for published ...
$data['attribs']['ilayout'] = 'layoutDefault';
$data['title'] = "Title245";
$data['alias'] = "code";
$data['text'] = "Text for desk";
$data['custom']['code'] = '012345';
$data['custom']['price'] = '4.59';
$data['custom']['kompensacija'] = 0;
$data["prev_order"] = '6';

Add items ok But
$data["prev_order"]
and
$data["order"]
and
$data["ordering"]
Not working admin panel filed order in 0. What insert ordering items?

Please Log in or Create an account to join the conversation.

5 years 8 months ago #61667 by ggppdk
Replied by ggppdk on topic api ordering item insert
Hello

yes the proper way is to use:
$data["ordering"] = ............;

and it should allow it, i will commit a fix (will be in future release):

To test the fix now, the model file to edit is:
administrator/component/com_flexicontent/models/parentitemclass.php
- please do not make any other chages to the file !! your installation will not work after upgrading


The item model code will clear $data["ordering"] ,
if the USER cannot "editState", but later it also does:
// For new items get next available ordering number
if ($isnew) {
	$item->ordering = $item->getNextOrder();
}

Try this fix to allow it:
// For new items get next available ordering number
if ($isnew) {
	if ( empty($item->ordering) || !$canEditState) $item->ordering = $item->getNextOrder();
}

test and post back


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

5 years 8 months ago #61716 by oleg_kosarev
im get CategoryID and ordering
explame:
$ordering == 20;
categoryID == 130
write for update ordering for this code
function updateCat($ordering, $idCat) {
    require_once (JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'defineconstants.php');
    JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'tables');
    require_once (JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.fields.php');
    require_once (JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.helper.php');
    require_once (JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'helpers' . DS . 'permission.php');
    require_once (JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'models' . DS . 'category.php');
 
// Create an instance of the category model
    $catModel = new FlexicontentModelCategory();
 
// Create the data
    $data = array();
    $data['cid'] = $idCat;
    $data['ordering'] = $ordering;
 
 
// Save the new category
    $status = $catModel->save($data);
 
 
    if (!$status) {
        return $data->id;
    } else {
        return $status;
    }
}
 
                var_dump(updateCat($item[section_order_pos], $idCat));
                var_dump($catid);
 
return bool(true) string(3) "133" but ordering not set this is bug but i'm error code?

Please Log in or Create an account to join the conversation.

5 years 8 months ago #61718 by ggppdk
Replied by ggppdk on topic api ordering item insert
Hello

we were taking about creating item,
- maybe you responded to the wrong thread ?


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
© 2018 Flexicontent. All Rights Reserved.
Save
Cookies user prefences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline