webhoes Posted August 1, 2017 Share Posted August 1, 2017 Hello, I have a page with a google map and a function that renders blok of a field regio_verspreiding on all childs of that page. I want a list box where I can select the childeren. For the selected child I would like to see the map and show the output of that function only for that selected child. It is this page: https://chrysemys.nl/regios/ I put back the old code for now as example. I tried this, but I am quite stuck... and get is get to work. What should I change? $map = $modules->get('MarkupGoogleMap'); ?> <div id="content-region" class="content pw-replace"> <section> <!--Eco blog--> <div class="eco_blog_section"> <div class="container"> <div class="row"> <!--Eco blog column--> <div class="eco_blog_detail_content col-xs-12"> <label> Kies een regio: <select name="r_selector"> <?php foreach($page->children as $r){ echo "<option value='{$r->id}'>{$r->title}</option>"; } ?> </select> </label> <?php if ($inputs->get->r_selector) { $section = (int) $inputs->get->r_selector; // Add this to your selector string $selector .= ", r_selector={$section}"; // To make the pagination work, add the section get variable to the whitelist $inputs->whitelist('r_selector', $section); } ?> <?php echo $map->render($inputs, 'map'); ?> <div class="regios"> <?php // echo renderVerspreidingenRegio($pages->get($r)->regio_verspreiding->each); ?> </div> </div> </div> </div> </div> <!--Eco blog ends--> </section> </div> Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted August 1, 2017 Share Posted August 1, 2017 Hey, @webhoes! I did not dive too deep into your code, but: I think you use $inputs instead of $input. I don't see the code for the form which has to include the select and therefore do not see the way that r_selector will ever get into the $input object. You need to sent the form to get the input parameters. 1 Link to comment Share on other sites More sharing options...
webhoes Posted August 1, 2017 Author Share Posted August 1, 2017 I tried $input but that generates an error with the search form _main.php. Therefor I changed it to $inputs. The output of the form/list box should be an page ID that is used in the function for the google map and the second function. That is the idea what I came up with. It seems I also need jquery to refresh the page after an selection is made... Link to comment Share on other sites More sharing options...
webhoes Posted August 3, 2017 Author Share Posted August 3, 2017 I got it working with this code <div id="content-region" class="content pw-replace"> <?php if($_GET['regio'] != Null){$result = $_GET['regio'];} else {$result = '1404';}; ?> <section> <!--Eco blog--> <div class="eco_blog_section"> <div class="container"> <div class="row"> <!--Eco blog column--> <div class="eco_blog_detail_content col-xs-12"> <label> <h3>Kies een regio</h3> <select onchange='document.location = (document.location.href.split("?")[0] + "?regio=" + this.value )' value="GO"> <?php foreach($page->children as $r){ echo " <option value ='" . $r->id . "' " . ($r->id == $result ? 'selected': Null) . ">" . $r->title . "</option>"; } ?> </select> </label> <?php echo $map->render($pages->get($result)->regio_verspreiding, 'map'); ?> <div class="regios"> <h3><?php echo $pages->get($result)->title; ?></h3> <?php echo renderVerspreidingRegio($pages->get($result)->regio_verspreiding); ?> </div> </div> </div> </div> </div> <!--Eco blog ends--> </section> </div> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now