Jump to content

select box for showing different content


webhoes
 Share

Recommended Posts

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

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

I got it working with this code :D

<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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...