Bienvenido, Invitado
Recordarme

TEMA:

Extend Contentbuilder Delete 2 meses 3 semanas antes #277274

  • Autor del tema
  • Dankill
  • Fuera de línea
  • Junior Breezer
  • Junior Breezer
  • Mensajes: 23
  • Gracias recibidas: 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!

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Extend Contentbuilder Delete 2 meses 3 semanas antes #277296

  • Avatar de Mirec
  • Mirec
  • Fuera de línea
  • Ultimate Breezer
  • Ultimate Breezer
  • Mensajes: 3262
  • Karma: 2
  • Gracias recibidas: 160
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

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Última Edición: Post by Mirec.

Extend Contentbuilder Delete 2 meses 2 semanas antes #277572

  • Autor del tema
  • Dankill
  • Fuera de línea
  • Junior Breezer
  • Junior Breezer
  • Mensajes: 23
  • Gracias recibidas: 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.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Extend Contentbuilder Delete 2 meses 2 semanas antes #277582

  • Avatar de Mirec
  • Mirec
  • Fuera de línea
  • Ultimate Breezer
  • Ultimate Breezer
  • Mensajes: 3262
  • Karma: 2
  • Gracias recibidas: 160
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

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

  • Página:
  • 1
Tiempo de carga de la página: 0.188 segundos