Jump to content
Alejandro

Programatically create and update listings

Recommended Posts

Alejandro

Here's something you can try to programmatically create listings from other extensions/plugins:

<?php
// Load the JReviews framework
require_once JPATH_BASE.'/components/com_jreviews/jreviews/framework.php';

// Set the form token
$_POST[cmsFramework::getToken()] = 1;

// Let the framework know the code is accessed directly so it suppresses output headers
$_REQUEST['requested'] = 1;

// Build the request data
$params = [];

// Routing data

$params['data']['controller'] = 'listings';
$params['data']['action'] = '_save';

// Ensure that the form passes the consent checkbox validation if it's enabled
$params['data']['consent'] = true;

// Add  the standard fields
// Catid is required and must be a JReviews category, title is required if not disabled
$params['data']['Listing'] = [
	'catid' => 23,
	'title' => 'Programatically submitted listing',
	'introtext' => '<p>This is the listing summary.</p>',
	'fulltext' => '<p>This is the listing description.</p>',
];

// Add the custom field data
// For select,radio,checkbox fields, use the field option values
// Checkbox and multiselect fields need to use array inputs
$params['data']['Field']['Listing'] = [
	'jr_website' => 'http://origamiappbuilder.com',
	'jr_checkbox' => ['one','two']
];

$Dispatcher = new S2Dispatcher('jreviews');

// If running the script via cron without a specific Joomla user you will want to 
// set the listing owner by uncommenting the two lines below
// to load it using the user ID
// $auth = S2Object::make('auth');
// $auth->loadUser(46);

$output = $Dispatcher->dispatch($params);

$output = json_decode($output,true);

if ($output['success'] == true) 
{
	// Listing was successfully created

	$listingId = $output['listing_id'];	
}

 

Share this post


Link to post
bk-1530585905

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
bk-1530585905

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Alejandro

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
bk-1530585905

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Alejandro

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
bk-1530585905

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
bk-1530585905

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
bk-1530585905

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Alejandro

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
bk-1530585905

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Alejandro

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
bk-1530585905

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Edited by bk-1530585905

Share this post


Link to post
Alejandro

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
bk-1530585905

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Alejandro

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
oliver hauser

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Edited by oliver hauser
Found some solutions

Share this post


Link to post
Alejandro

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
oliver hauser

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Please refer to our Privacy Policy.