Forum
Composite field sort. Possible bug with type="time"
I am trying to sort a set of sessions by two fields, speaker_track
and speaker_time
. I've created sort_time
as my composite field and I'm joining the values with ,
.
When I retrieve the content It's not coming out in the right order.
Looking at perch2_content_index
the values for sort_time
only contain speaker_track
.
If I change the composite to use speaker_track
and speaker_day
then sort_time
contains both values joined by ,
.
If I change the composite to just use speaker_time
then sort_time
is empty.
Have I hit upon a bug with composite fields and the time field?
This is the template defining the content model.
<perch:content id="speaker_slot" type="select" label="Slot type" options="Speaker slot|speaker_slot, Unconfirmed speaker slot|unconfirmed_slot, Non Speaker slot|non_speaker_slot, Gap|gap_slot" suppress="true" order="1" />
<perch:content id="speaker_day" type="select" label="Day" options="Day 1|day_one, Day 2|day_two" allowempty="true" order="100" suppress="true" />
<perch:content id="speaker_track" type="select" label="Track" options="Track 1|track_one, Track 2|track_two, Other|track_other" allowempty="true" order="105" suppress="true" />
<perch:content id="speaker_time" type="time" label="Time" maxlength="2" size="xs" order="110" suppress="true" />
<perch:content id="sort_time" type="composite" for="speaker_time speaker_track" join="," suppress="true"/>
<div class="row--speaker speaker">
<div class="block__id" id="<perch:content id="talk_slug" type="slug" for="talk_title" />"></div>
<h2 class="speaker__talk-title"><perch:content id="talk_title" type="text" label="Talk title" order="80" /></h2>
<perch:content id="speaker_name" type="text" label="Speaker name" order="100" title="true" suppress="true" />
<perch:content id="talk_details" type="textarea" size="m" label="Talk Details" editor="markitup" textile="true" order="90" />
</div>
This is the output from the page debug
Debug Message
SELECT * FROM perch2_pages WHERE pagePath='/schedule.php' LIMIT 1
SELECT * FROM perch2_blog_posts WHERE postStatus='Published' AND postDateTime<='2015-06-22 12:00:00' AND postSlug=''
SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/schedule.php' OR regionPage='*' ORDER BY regionPage DESC
SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='sessions' AND (regionPage='/sessions.php' OR regionPage='*')
SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='sort_time' WHERE ((idx.regionID=126 AND idx.itemRev=54)) AND ((idx.indexKey='speaker_day' AND idx.indexValue='day_one') OR (idx.indexKey='speaker_track' AND idx.indexValue IN ('track_one', 'track_two'))) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID HAVING count(*)=2 ORDER BY sortval ASC
Using template: /templates/content/programme_item.html
Trying using
speaker_time_hour
andspeaker_time_minute
, as those are actually two form fields.Perfect! I didn't realise that you could extract the individual components like that.