I have an index.php file which has a php include file that has a modal for looking up contacts. This file is included after the opening body tag but before any route elements.
<?php include 'inc/global_contacts.php'; ?>
The index.php file also includes the main menu and some other elements that are used on every page. After the main menu I use route elements to include the code for which ever page is requested. In this case the damages page.
<div is="dmx-route" id="route_damages" path="/damages" url="inc/damages/route_parent.php"></div>
I have a variable called var_contact_id in the route file that is set on load of the route file. I am bumping my head against the wall trying to setValue of this variable when a button that is rendered in a table of contacts in the included inc/global_contacts.php is clicked.
I suspected the include file can’t see the var_contact_id variable so as a test I included the file the route uses instead of using the route element.
<?php include 'inc/damages/route_parent.php'; ?>
Low and behold after using an include file instead of a route element, clicking the button now properly sets the var_contact_id variable to the contact_id of whichever contact was clicked in the list.
I prefer to use the route because otherwise I have to write code to only include the file if “damages” is in the url or something like that. I even tried including the global_contacts file after the route but it didn’t make a difference.
Hope all that makes sense. Am I missing something simple for setting a variable from outside a route?
Thanks in advance
Last updated: