I would like to use the $_query object to search, filtering by a dynamic-metadata set that has the selected option in a select field. Currently it adds the options from the "news-and-events" metadata set if they are selected on the news-list-page (metadata), but the query doesn't display ONLY the metadata items that were selected in the output of the search it has ALL the pages with metadata from "news-and-events". What am I missing?
Example:
#set ( $news_list_page = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page") )
#set ( $news_list_page_metadata = $news_list_page.getChildren('dynamic-metadata') )
#set ( $query = $_.query() )
#set ( $query = $query.byMetadataSet("Main-Taxonomy-List") )
#set ( $query = $query.byContentType("news-detail") )
#set ( $query = $query.includePages(true) )
#set ( $query = $query.includeFiles(false) )
#set ( $query = $query.includeBlocks(false) )
#set ( $query = $query.includeFolders(false) )
#set ( $query = $query.includeSymlinks(false) )
#set ( $query = $query.sortBy("created") )
#set ( $query = $query.sortDirection("desc") )
#set ( $query = $query.maxResults(12) )
#set ( $news = $query.execute() )
<div class="region news-list-region">
<div class="region-holder">
<!-- Filter form -->
<form class="filter-form">
<div class="filter-form-holder">
<div class="filter-form-item">
<span class="filter-form-label">Search by:</span>
</div>
<div class="filter-form-item">
<div class="filter-form-select-wrapper">
<select class="filter-form-select" name="" id="select-1">
<option value="Recent news">Recent news</option>
<option value="2015-2016">2015-16</option>
<option value="2014-2015">2014-15</option>
<option value="2013-2014">2013-14</option>
</select>
</div>
</div>
<div class="filter-form-item">
<div class="filter-form-select-wrapper">
<label for="topics" class="hide-for-screen-reader">Please choose topic</label>
<select class="filter-form-select" name="topics" id="topics">
<option value="All Topics">All Topics</option>
#foreach( $news_items in $news_list_page_metadata )
#if( 'news-and-events' == $news_items.getChild('name').value )
#set( $taxonomy_list = $news_items.getChildren('value') )
#foreach( $taxonomy_item in $taxonomy_list )
<option value="${_EscapeTool.xml($taxonomy_item.value)}">${_EscapeTool.xml($taxonomy_item.value)}</option>
#end
#end
#end
</select>
</div>
</div>
<div class="filter-form-item">
<button type="submit" class="filter-form-btn btn btn-primary">Search</button>
</div>
</div>
</form>
#31 Posted by Penny on 29 Aug, 2016 07:39 PM
Hi,
Can you give me the id for the metadata fields that you have created? Also, are they all multi-selects. I can write mock something up to show you. I'd recommend storing them all as a string and then having the string in the outter tag.
#32 Posted by Penny on 29 Aug, 2016 07:40 PM
Also, can you send me a sample of what the html should be with a sample category in the class?
#33 Posted by voltmer1 on 29 Aug, 2016 08:32 PM
Okay, the metadata fields are multi selects ( are you referring to the id I have on the form input select?) you'll see the id in the attached HTML. Sorry my velocity is a mess, I am trying everything. If you need any clarity let me know.
#34 Posted by Penny on 29 Aug, 2016 08:34 PM
Hi,
I need the id for the metadata fields in Cascade. You can find that on the metadata panel for the news type. Just let me know. Thanks!
#35 Posted by voltmer1 on 29 Aug, 2016 08:45 PM
I am sorry, I don't know what you are referring to. If i go into the metadata from Administration and look at the set for the dynamic fields I've set up there isn't any "id" just the various options for the multi-select.
#36 Posted by Penny on 29 Aug, 2016 09:02 PM
On a News Article page, click Properties tab. Then scroll down, you will see a Metadata Set. Click on that little white icon. Then from there, click on the Dynamic Fields tab. Tell me what is in the Name area. Thanks!
#37 Posted by voltmer1 on 30 Aug, 2016 12:28 PM
Sorry Penny, I didn't know that was referred to as the "id" the set name that I am using has a multi-select named "news-and-events"