TOPIC:

Extend Contentbuilder Delete 2 weeks 13 hours ago #277274

  • Topic Author
  • Dankill
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 23
  • Thanks: 0
I am looking for a little advice on a problem I am working on for my site. I have augmented ContentBuilder and BreezingForms by having the forms add map markers to a database based on the submission's data and have set it up so that edits to the submissions also update the markers.

My difficulty right now is removing these markers when a user chooses to delete their submission. I don't believe there is a way to alter the "Delete" behaviour from the backend of BreezingForms, so I am thinking that I will have to extend the code to accomplish this additional function.

The function called from the Delete buttons is "contentbuilder_delete();", but I haven't yet been able to track it down in the code.

Perhaps someone who has some experience extending the plugin could offer some suggestions or alternatives?

Thank you!

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

Extend Contentbuilder Delete 1 week 6 days ago #277296

  • Mirec's Avatar
  • Mirec
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 3110
  • Karma: 2
  • Thanks: 153
Hi,

could you please send me the backend link and access data by email ma@evolucio.hr so I can see what I can do, I need to check how works this the functionality that you added

Let me know!

Regards,
Mirko

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

Last edit: Post by Mirec.

Extend Contentbuilder Delete 1 week 12 hours ago #277572

  • Topic Author
  • Dankill
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 23
  • Thanks: 0
Hi, thanks for taking a look. I am not allowed to provide backend access, but I will try to lay out what changes I have implemented.

So, again, my goal has been an integrated map that adds markers based on the locations of user submissions; when a form is submitted, it connects to a geocoding API to convert an address to latitude + longitude data and adds pair of markers to a database. The following code is from the End Submit of my BreezingForms:

Preparation Code
$this -> execPieceByName('ff_InitLib');

use Joomla\CMS\Log\Log;

$db = JFactory::getDbo();

// Get the record ID being worked on
$uri = $this->record_id;

// Prepare addresses to pass to Geocode API
$find=" ";
$replace="+";
$cargo_pickup_address =  str_replace($find,$replace,ff_getSubmit('pickup_address')) . "," . str_replace($find,$replace,ff_getSubmit('pickup_city')) . "," . str_replace($find,$replace,ff_getSubmit('pickup_province')) . ",Canada"; 
$cargo_destination_address =  str_replace($find,$replace,ff_getSubmit('destination_address')) . "," . str_replace($find,$replace,ff_getSubmit('destination_city')). "," . str_replace($find,$replace,ff_getSubmit('destination_province')) . ",Canada"; 
$geocode_url_pickup = "https://geocode.maps.co/search?q={" . $cargo_pickup_address . "}";
$geocode_url_destination = "https://geocode.maps.co/search?q={" . $cargo_destination_address . "}";

Connect to Geocode API to convert addresses
// init curl for pickup marker
$ch_pickup = curl_init();
curl_setopt($ch_pickup, CURLOPT_URL, $geocode_url_pickup);

// receive server response ...
curl_setopt($ch_pickup, CURLOPT_RETURNTRANSFER, true);// gives you a response from the server

$response = curl_exec ($ch_pickup);// return in the response var

// close curl connection for pickup marker
curl_close ($ch_pickup);

$data = json_decode($response, true);

//Output variables for testing
    if (JDEBUG)
    {
        $formatted_geocode = print_r($geocode_url_pickup, true);
        $formatted_response = print_r($response, true);
        $formatted_json = print_r($data, true);
        Log::add($formatted_geocode, Log::DEBUG, 'SQL Output');
        Log::add($formatted_response, Log::DEBUG, 'SQL Output');
        Log::add($formatted_json, Log::DEBUG, 'SQL Output');
        Log::add($data->lat, Log::DEBUG, 'SQL Output');
        Log::add($data->lon, Log::DEBUG, 'SQL Output');
        Log::add($data->display_name, Log::DEBUG, 'SQL Output');
    }

$pickup_lat = $data[0]["lat"];
$pickup_long = $data[0]["lon"];
$pickup_description = '<a href="Address of marker's description"]  . '</a>';

// init curl for destination marker
$ch_destination = curl_init();
curl_setopt($ch_destination, CURLOPT_URL, $geocode_url_destination);

// receive server response ...
curl_setopt($ch_destination, CURLOPT_RETURNTRANSFER, true);// gives you a response from the server

$response = curl_exec ($ch_destination);// return in the response var

// close curl connection for pickup marker
curl_close ($ch_destination);

$data = json_decode($response, true);

$destination_lat = $data[0]["lat"];
$destination_long = $data[0]["lon"];
$destination_description = '<a href="Address of marker's description"]  . '</a>';

Add or update the markers in the database (Database name obscured)
// Begin a transaction to insert pickup marker if there was not an existing set, or update existing
try
{
    $db->transactionStart();
	
    $query = $db->getQuery(true);

    $col_array = array("catid", "title", "alias", "latitude", "longitude", "description", "osm_icon", "osm_marker_color", "osm_icon_color", "osm_icon_prefix", "osm_icon_spin", "osm_icon_class", "published", "checked_out", "ordering", "access", "language");
    $values = array(1, $db->quote('ID ' . $uri . ' Pickup'), $db->quote('id-' . $uri . 'p'), $db->quote($pickup_lat), $db->quote($pickup_long), $db->quote($pickup_description), $db->quote('circle'), $db->quote('blue'), $db->quote('#ffffff'), $db->quote('fa'), 0, $db->quote(' '), 1, 0, 1, 1, $db->quote('*'));

    //Output variables for testing
    if (JDEBUG)
    {
        $formatted_columns = print_r($col_array, true);
        $formatted_values = print_r($values, true);
        Log::add($formatted_columns, Log::DEBUG, 'SQL Output');
        Log::add($formatted_values, Log::DEBUG, 'SQL Output');
    }

// Select and build a marker to add to the database for the relevant record
    $query = "INSERT INTO #DATABASE_NAME# (" . implode(',', $col_array) . ") values (" . implode(',', $values) . ") 
        ON DUPLICATE KEY UPDATE " . $db->quoteName('latitude') . "=" . $db->quote($pickup_lat) . "," . $db->quoteName('longitude') . "=" . $db->quote($pickup_long) . "," . $db->quoteName('description') . "=" . $db->quote($pickup_description);
    
$db->quoteName('longitude') . '=' . $db->quote($pickup_long) . ',' . $db->quoteName('description') . '=' . $db->quote($pickup_description));

    echo $query;
    $db->setQuery($query);
    $db->execute();

    $db->transactionCommit();
}
catch (Exception $e)
{
    // catch any database errors.
    $db->transactionRollback();
    JErrorPage::render($e);
}

// Begin a transaction to insert destination marker
try
{
    $db->transactionStart();
	
    $query = $db->getQuery(true);

    $col_array = array("catid", "title", "alias", "latitude", "longitude", "description", "osm_icon", "osm_marker_color", "osm_icon_color", "osm_icon_prefix", "osm_icon_spin", "osm_icon_class", "published", "checked_out", "ordering", "access", "language");
    $values = array(1, $db->quote('ID ' . $uri . ' Destination'), $db->quote('id-' . $uri . 'd'), $db->quote($destination_lat), $db->quote($destination_long), $db->quote($destination_description), $db->quote('circle'), $db->quote('red'), $db->quote('#ffffff'), $db->quote('fa'), 0, $db->quote(' '), 1, 0, 1, 1, $db->quote('*'));

    //Output variables for testing
    if (JDEBUG)
    {
        $formatted_columns = print_r($col_array, true);
        $formatted_values = print_r($values, true);
        Log::add($formatted_columns, Log::DEBUG, 'SQL Output');
        Log::add($formatted_values, Log::DEBUG, 'SQL Output');
    }

    // Select and build a marker to add to the database for the relevant record

    $query = "INSERT INTO #DATABASE_NAME# (" . implode(',', $col_array) . ") values (" . implode(',', $values) . ") 
        ON DUPLICATE KEY UPDATE " . $db->quoteName('latitude') . "=" . $db->quote($destination_lat) . "," . $db->quoteName('longitude') . "=" . $db->quote($destination_long) . "," . $db->quoteName('description') . "=" . $db->quote($destination_description); 

$db->quoteName('longitude') . '=' . $db->quote($destination_long) . ',' . $db->quoteName('description') . '=' . $db->quote($destination_description));


    $db->setQuery($query);
    $db->execute();

    $db->transactionCommit();
}
catch (Exception $e)
{
    // catch any database errors.
    $db->transactionRollback();
    JErrorPage::render($e);
}

Now I just need to alter the Delete Submission behaviour from Contentbuilder (on the views and the individual records) to remove these markers, which should be fairly simple if I can find out where to create the code.

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

Extend Contentbuilder Delete 6 days 22 hours ago #277582

  • Mirec's Avatar
  • Mirec
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 3110
  • Karma: 2
  • Thanks: 153
HI,

hmm I do need check this a little deeply.


Now I just need to alter the Delete Submission behaviour from Contentbuilder (on the views and the individual records) to remove these markers, which should be fairly simple if I can find out where to create the code.



understand, for this, we should change the source code of CB, I'll check this and then I will let you know!

we need to check the source code and check how to insert this code for wiping those markers.

I will let you know!

Regards,
Mirko

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

  • Page:
  • 1
Time to create page: 0.045 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!