symfony2 how to lists twig in another twig

81 views Asked by At

In my application I have entity doctor and status I want to list all the status of the doctor in the doctor twig. what must I do to get result (every doctor have his list of status )? what can I do ?`

<div class="row" style="margin-left: 10px">
<div class="col-md-6">
    <div class=" tiles white col-md-12 no-padding">
        <div class="tiles green cover-pic-wrapper">
            <div class="overlayer bottom-right">
                <div class="overlayer-wrapper">
                    <div class="padding-10 hidden-xs">
                        <button type="button" class="btn btn-primary btn-small"><i class="fa fa-check"></i>&nbsp;&nbsp;joindre</button> <button type="button" class="btn btn-primary btn-small">Ajouter</button>
                    </div>
                </div>
            </div>
            <img src="{{ asset('bundles/assets/img/cover_pic.png')}}" alt="">
        </div>
        <div class="tiles white">

            <div class="row">
                <div class="col-md-3 col-sm-3">
                    <div class="user-profile-pic">
                        <img width="69" height="69"  src="{{ asset(entity.image.WebPath) }}" alt="">
                    </div>
                    <div class="user-mini-description">
                        <h3 class="text-black semi-bold">
                            {{ entity.nom }} {{ entity.prenom }}
                        </h3>

                    </div>
                </div>
                <div class="col-md-5 user-description-box  col-sm-5">
                    <h4 class="semi-bold no-margin"> Information Personnel</h4>
                    <h3 class="no-margin">{{ entity.specialite }}</h3>
                    <br>
                    <p><i class="fa fa-database"></i>{{ entity.dateDiplome|date('Y-m-d H:i:s') }}</p>
                    <p><i class="fa fa-university"></i>{{ entity.etablissement }}</p>
                    <p><i class="fa fa-home"></i>{{ entity.adresse }}</p>
                    <p><i class="fa fa-phone"></i>{{ entity.tel }}</p>
                </div>

            </div>

            <div class="tiles-body">
                <div class="row">
                    <div class="post col-md-12">

                        <div class="info-wrapper">
                            <div class="username">
                                <span class="dark-text">Emplacement sur google map:</span>
                            </div>
                            <!--google map begin-->
                            <div id="map-canvas">
                                <script>
                                    // In this example, we center the map, and add a marker, using a LatLng object
                                    // literal instead of a google.maps.LatLng object. LatLng object literals are
                                    // a convenient way to add a LatLng coordinate and, in most cases, can be used
                                    // in place of a google.maps.LatLng object.

                                    var map;
                                    function initialize() {
                                        var mapOptions = {
                                            zoom: 10,
                                            center: {lat: {{ entity.latitude }}, lng: {{ entity.langitude }}}
                                        };
                                        map = new google.maps.Map(document.getElementById('map-canvas'),
                                                mapOptions);

                                        var marker = new google.maps.Marker({
                                            // The below line is equivalent to writing:
                                            // position: new google.maps.LatLng(-34.397, 150.644)

                                            position: {lat: {{ entity.latitude }}, lng: {{ entity.langitude }}},
                                            map: map
                                        });

                                        // You can use a LatLng literal in place of a google.maps.LatLng object when
                                        // creating the Marker object. Once the Marker object is instantiated, its
                                        // position will be available as a google.maps.LatLng object. In this case,
                                        // we retrieve the marker's position using the
                                        // google.maps.LatLng.getPosition() method.
                                        var infowindow = new google.maps.InfoWindow({
                                            content: '<h5>{{ entity.nom }} {{ entity.prenom }}</h5><img width="69" height="69"  src="{{ asset(entity.image.WebPath) }}" alt="">'
                                        });

                                        google.maps.event.addListener(marker, 'click', function() {
                                            infowindow.open(map, marker);
                                        });
                                    }

                                    google.maps.event.addDomListener(window, 'load', initialize);

                                </script>
                            </div>
                            <!--google map end-->
                        </div>
                        <div class="clearfix"></div>
                        <br>
                        <br>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="col-md-6">
    <div class="row">
        <div class="tiles white col-md-12  no-padding">
            <div class="tiles-body">
                <h5><span class="semi-bold">Paramétre</span>&nbsp;&nbsp; <a href="#" class="text-info normal-text">view more</a></h5>
                <div class="row">

                    <div class="col-md-12">
                        <div class="friend-list">

                            <div>
                                <a href="{{ path('medecin_edit', { 'id': entity.id }) }}"> <button class="btn btn-primary" type="button">Modifier</button> </a>
                                <a href="{{ path('recherche-doctor') }}"> <button class="btn btn-primary" type="button">Médecin</button></a>
                               <a href="{{ path('consultation_new') }}"> <button class="btn btn-primary" type="button">consultation</button></a>
                                <a href="{{ path('examen_new') }}"> <button class="btn btn-primary" type="button">Examen</button></a>
                                <a href="{{ path('patient_new') }}"> <button class="btn btn-primary" type="button">patient</button></a>

                                <button class="btn btn-primary" type="button">sécurité</button>
                                <a href="{{ path('fos_user_security_logout') }}"> <button class="btn btn-primary" style="float: right" type="button">Déconnexion</button> </a>

                            </div>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <br>
    <div class="row">
        <div class="col-md-12 no-padding">
            <div class="tiles white">
                <textarea rows="3" class="form-control user-status-box post-input" placeholder="ajouter votre statut"></textarea>
            </div>
            <div class="tiles grey padding-10">
                <div class="pull-left">
                    <button class="btn btn-default btn-sm btn-small" type="button"><i class="fa fa-camera"></i></button>
                    <button class="btn btn-default btn-sm btn-small" type="button"><i class="fa fa-map-marker"></i></button>
                </div>
                <div class="pull-right">
                   <a href="{{ path('statut_new') }}"> <button class="btn btn-primary btn-sm btn-small" type="button">Ajouter</button></a>
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
    </div>
    <br>
    <br>
    <div class="row">
        <div class="post col-md-12">
            <div class="info-wrapper">
                <div class="username">
                    <span class="bold">**{{ entity.statut.text }}**</span>
                </div>
                <div class="info">
                   <p class="text-black">Intervention sans machine cœur-poumon sur cœur battant
                       Cette intervention ressemble au pontage cardiaque, sauf que le cœur n’est pas arrêté et qu’on n’a pas recours à la machine cœur-poumon. À l’aide d’équipement spécial,
                       on stabilise ou calme la région cardiaque et les chirurgiens opèrent le cœur pendant qu’il continue de battre.</p><br/>
                    <img src="{{ asset('bundles/assets/img/med/principe-thrapie-cellulaire.png') }}">

                </div>
                <div class="more-details">
                    <ul class="post-links">
                        <li><a href="#" class="muted">2 Minutes ago</a></li>
                        <li><a href="#" class="text-info">Collapse</a></li>
                        <li><a href="#" class="text-info"><i class="fa fa-reply"></i> Reply</a></li>
                        <li><a href="#" class="text-warning"><i class="fa fa-star"></i> Favourited</a></li>
                        <li><a href="#" class="muted">More</a></li>
                    </ul>
                </div>

            </div>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
</div>

`

1

There are 1 answers

1
D4V1D On

If your Doctor entity has the correct getter/method getStatut() you then should be able to do the following in Twig:

{% for statut in entity.statut %}
     {{ statut.whateverProperty }}
{% endfor %}