Jump to:

5521 Posts in 1734 Topics by 1223 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Search Results, Many_Many Relationship Data

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 856 Views
  • stew
    Avatar
    Community Member
    30 Posts

    Search Results, Many_Many Relationship Data Link to this post

    Hey guys,

    I'm trying to get the final problem solved before I can get the project I've been working on launched.

    The main issue with searching was resolved thanks to Barry in the thread further down the page, however I've been left with one last little niggle that I just can't find the answer to.

    Each search result is that of an Organisation which may have a Venue, the Venues are controlled through a many_many relationship since quite a few Organisations share a venue. The problem I have is that I can't get the actual data of the Venue outputted on the search results page, I have tried the usual <% control Venues %> bit but that didn't work.

    Does anyone know how to do this? I could just add in a new batch of fields for the venue details in the Organisation DataObject but I'd rather keep them separate since so many of the Organisations share venues it seems daft to make the client reenter the Venues so many times.

    Thanks,

    Stewart

  • stew
    Avatar
    Community Member
    30 Posts

    Re: Search Results, Many_Many Relationship Data Link to this post

    Thought I'd add a wee bit of code in that might help explain what I am trying to do.

    This is in OrganisationHolder.ss, basically if a Venue is attached to the Organisation it gets the Latitude and Longitude of the Venue and outputs it, if not it gets it from the Organisation object itself:

                <% if Venues %>
                      <% control Venues %>
                            <li class="map-location" data-jmapping="{id: $ID, point: {lat: $Latitude, lng: $Longitude }, category: '$MapCategory'}" style="width: 100%;">
                      <% end_control %>
                   <% else %>
                      <li class="map-location" data-jmapping="{id: $ID, point: {lat: $Latitude, lng: $Longitude }, category: '$MapCategory'}" style="width: 100%;">
                   <% end_if %>

    I need to get the exact same result in the Search_Results.ss but it's not working :S

    856 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.