How to extend wappler with php functions

(I’m on the verge of giving up …
The documentation really really needs to be more thorough.)

Can you please explain to me how I can use a php function as a condition for displaying data.
I would like to store my functions so I can use them globally through out my application and I want to call them somehow …

1 Like

I also want to run custom functions when I post a form

1 Like

You do it as you should without wappler
include the file in the head section then use your function

that’s my guess :slightly_smiling_face:

But how do I refer to a function in the query builder in “conditions”.
Lets say I have a function_a($post_id) that returns an array of IDs.
In the conditions tab of any query I would like to state:
if fieldX is in function_a($current_post_id)

I haven’t figured out how to get current user id or current post id in a loop or how to refer to them…
To be honest I find this software to be really hard to understand.

Please confirm if you are trying to do some integration with WordPress as $post_id and $current_post_id both sound like WordPress variable names?

To get current ids or currnet posts in a loop you should create a ‘repeat’ action and use a ‘query’ as an expression. Then inside the ‘repeat’ action you can create any conditionals you want. For example lets say that for each customer you want to display all orders and display a ‘completed’ or ‘pending’ badge for each one of the orders. This is what you would do

Create a query ti get all customers
Create a repeat action and use the above query as an expression
Inside the repeat you would create another query that would filter orders by the ‘customer id’

Inside Appconnect you would create a ‘serverconnect’ call that would return the results of the repeat

Hope I helped you a little
Thank you


Just made a quick test with a simple php echo and it works. Here is the code I used

<!doctype html>
<meta charset="UTF-8">
<title>Untitled Document</title>
  <script type="text/javascript" src="../dmxAppConnect/dmxAppConnect.js"></script>
  <body is="dmx-app">
    <div dmx-repeat:repeat1="">
       <p dmx-show="comunidad_id!=3">{{comunidad_name_gr}}</p>
      <p dmx-show="comunidad_id==3"><?php echo 'ok';?> {{comunidad_name_gr}}</p> 
    <dmx-serverconnect id="serverconnect1" url="../dmxConnect/api/frontend/franchisees_locations/get_active_communidades.php"></dmx-serverconnect>

Here is the result in the browser (you will see that ‘ok’ is only displayed when the id of the record is equal to 3)

Hi Tina,

Just to start from the beginning: Wappler is not a PHP editor. if you are just a PHP coder that wants to write everything in code - you can better use a regular code only editor.

That said - Wappler do has all the powers of server side development. But we made them much more easier to access and made you even more productive, so you don’t have to write all this PHP code by yourself each time.

This is done by the integrated Server Connect framework - which gives you a full blown runtime generator of all the PHP or other server side code you will ever need.

It is also works on on much higher level - so instead of writing you code line by line - you are now creating a server side workflow actions containing multiple steps of all the work that you need to do server side.

So you can have multi step actions like querying a database, looping through the records, sending mail for each record or just do an extra formatting before returning the data to the client where it is nicely displayed with the front-end framework App Connect.

So Server Connect might have a small learning curve to find our about all the available actions and data formatting options, but believe me it is nothing like learning all the PHP that you have done and also it will make you hugely productive.

You can read all about it here:

As for your data formatting question - you can do it indeed server side with the integrated Data Formatter there - it has tons of usefull strings and number formatting functions - that you might have written in PHP yourself indeed, but now with the data formatter it is much easier and integrated.

It is however more advisable and a better way to do data formatting on the client side. So you just keep your server actions data retrieval and processing while on the client side with the App Connect Data Formatter - you do the needed formatting for the display. This is also explained in the docs here:

So check it out and give the docs a good reading and you will see that with Wappler you have a tool that even PHP coders you will be gaining a huge amount of productivity boost.


George so cool that you are here listening to us. Means a lot!

1 Like

100% agree with George. Wappler needs a bit of time to understand how it works. But once you get the idea of how things are accomplished you will get 1000% more productive. It is unbelievable what it can be created within Wappler (ServerConnect & AppConnect) in a few hours. The best part is that the debugging proccess almost disappears. If you are new to Wappler I would suggest the following.

Try to implement any functionality you want through Serverconnect and Appconnect.
If you find yourself stuck post it here.
If still not possible try to handcode it and integrate into your Wappler code. (like the simple example posted above)
btw if it is a good idea for everyone then very possible that this functionality will be intergrated in Wappler in one of the next updates.

Think of Wappler as a Photoshop for developers. Believe it or not there are only a few things (if any) that can not be done with Wappler using Server and App Connect.

1 Like

He want to implement an external php library
and its not mentioned in the documentation

for example we use Hiri calendar like this one
how can i do that in wappler

Well you should read the external php API and call relative functions from Wappler when needed. I once did this with an external js API. Had to find the functions from the API and call them from Wappler when I wanted to. Dont know how this php calendar works but you should use as much as possible interaction with it through ServerConnect and update the frontend with Appconnect calling calendar actions when needed.

back at the original question :slightly_smiling_face:

how can you call a php function from server connect
or js function from app connect

1 Like

:slight_smile: well basically you should create the functionality in serverconnect. For example if you want to format days, use the formatter. But also please let me try something. This is interesting.

Well Server Connect is pretty much runtime server side language generator, so it runs a=on PHP servers just as easy as it runs on others like ASP and ASP.NET

This means that all the functions and data filters we create have to be compatible with all the server languages we support.

So you can’t just “hack-in” a PHP function in server connect, we have to make it available as data filter for all the languages.

well that isn’t good news.

you should add an action that we can supply with a function and return a value.

well we actually get over 70 formatting functions and a full blown javascript expressions evaluation engine, so there is nothing you can’t do in the current data expressions. So is really no need to do any custom functions in PHP.

But i just mentioned the use case

Formatting is not the issue or tge needed results.
We need to get the current date in Hijri calendar by supplying the current Georgian date.

We already have a lot of date formatting functions and you can write a simple calculation expression ( as javascript expression which is evaluated in PHP) to convert the date.

If that is much requested we can also add the function to the standard date conversion functions. Its just that nobody requested this before.

Sometimes it is faster to write a php function that returns a value to a variable.
Add it to the current page and call that variable in the query builders conditions tab.
But if I understand you correctly, this is not possible?