• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Problem with Custom work

We're working on providing a new way to request custom work. We had hoped to have it going when we migrated the site, but we've had some family health issues to deal with.

For now, just post here.

What map function do you need?

-- hugh
 
I have a map with several apartments. Each apartment can be available or unavailable. I set the availability of the apartment by the fabrik form, but I would like to set it also from the "Bubble template" of the viz map. How can I do?
 
You mean you want to be able to do something like click on a button and update the record with an AJAX call, or something like that?

-- hugh
 
There's nothing built-in to do that, but it might be possible, rolling your own code to fire an AJAX call. Probably by inserting the markup for a button in the template, with a data attribute for the rowid, then having a viz_X.js (in ./components/com_fabrik/js, replace X with nymeric viz id) file listening for that button press. But I've never tried it, so I don't have any example code to hand.

-- hugh
 
Thank you! :)
Unfortunately I do not know the Javascript language, who can I contact to make this change?
 
Well, the Javascript part is relatively easy. In your bubble template in the viz, add something like ...

Code:
<button class="mapButton" type="button" data-rowid="{rowid}">Push Me!</button>

... which adds a button (Push Me!) to the template, with a data-rowid attribute set to the rowid of that pin.

The viz_X.js ...

Code:
// set up a delegated event for all buttons with class mapButton
jQuery('body').on('click', '.mapButton', function(e) {
    e.preventDefault();
    // get the rowid from the data attribute we added to the button markup
    var rowid = jQuery(e.target).data('rowid');
    // fire off an AJAX call the Fabrik userAjax class
    var url = Fabrik.liveSite + "/index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=doButton";
    jQuery.ajax({
        url       : url,
        data      : {
            rowid: rowid
        }
    }).done(function (r) {
        // show the result in an alert
        alert(r);
    });
});

... then you need to add a file, ./components/com_fabrik/user_ajax.php ...

PHP:
class UserAjax
{
   public function doButton()
   {
      // get the rowid from the input data
      $app = JFactory::getApplication();
      $rowid = $app->input->get('rowid', '');

      // make sure we got a rowid
      if (!empty($rowid))
      {
         // run a query to set a field on our table for that rowid
         // CHANGE ME!  Replace with your table and field names
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->update('yourtable')
            ->set('available = 1')
           ->where('id = ' . (int)$rowid);
         $db->setQuery($query);
         $db->execute();
         $result = "Set row $rowid to available";
      }
      else
      {
         $result = "Error!  No rowid!";
      }

      echo $result;
   }
}

That should give you a button that set a field called "available" to 1 in "yourtable" for the row's pin it was clicked on.

You can modify this to set it to 0, or have two button ("Make Available" and "Make Unavailable") by adding two buttons in the bubble template, change the class names, and add a second on('click') handler for the other one, that calls a different method within the userAjax class.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top