Page level filter in PHP include to trigger page actions

Hello,

I am building an app. for doctors’ offices to track appointments where sometimes there may be multiple locations. The idea here is that if you’re a front desk person at office 1, you only care/need office 1 activity. If you’re an admin, you may want to see all, or the office you’re in that day.

I am trying to create a page level level filter in my top bar to allow for this:

My code structure is such that the top bar is a PHP include file.

What I am having a tough time with is how to pass variables from the PHP include to the page and more importantly and perhaps more challenging, how to trigger an action from something that takes place in the top bar PHP include.

The use case here is a user is working at office 1 and wants to only see office 1 activity. She would select office 1 from the select menu which would trigger a series of already define server connect activities on the page to filter out everything except office 1.

How would you approach triggering the change from the select menu in the PHP include to trigger on page server connect actions? How would you pass the variable to the page?

Any thoughts would be greatly appreciated!

Hey Liran,

You might have to post your specifics, as at a very basic level, a variable within a php include seems to be working fine:

Here is the contents of a header file that was created by first creating the header in main.php, and then using the move to include function of Wappler:

Then on main.php, I can select the value of the variable in data bindings, or use the available actions:


Now, if you want to for example, reload a server connect that is in the page, but do so when the select updates, you can manually code the server connect load ( eg. serverconnect.load() ) , as it won’t be available in the picker, OR you also can put your server connects up in the header. Kinda depends on the details you face.

EDIT: I’m also making the assumption that the page you are dealing with is not the head page for the include – if it were, then everything is available, in both directions.

Thanks for the reply Ken.

This ^^^ is correct.

This is exactly what I need to do.

And, yes you're right, my select lives in the header include which is on all my pages.

Can you provide some guidance on how I'd go about manually coding the server connect load? I presume I do this on the page (not the include).

Something like...
SelectID on value changed load server connect.

Then your select will have something like this:

 <select id="select1" class="form-control" dmx-on:changed="serverconnect1.load()">
     <option value="1">Option One</option>
     <option value="2">Option Two</option>
     <option value="3">Option Three</option>
</select>

Thanks for the reply @mebeingken.

I was able to get this working by setting a variable on the include that equals the value of the select.

On the page, I set another variable that is the value of the variable above.

When the on page variable is updated, I trigger my server connect actions.