Jump to content

Filtering in Pages: Getting the key for $data


Meddysong

Recommended Posts

Posted

My site is bilingual and filtering necessarily produces the "filtered by:" message with the field values in only one language because it looks up $data['value'], which is not a translatable field.

I'm trying to come up with a work-around and I think I've got something. I think I could store some language strings as a prefix plus the key name for the field. (meddysong_1, meddysong_2 and so on.) Then in the template, I could use {lang="meddysong_"} with the key name appended.

The problem is, I don't know how to get the key name. I've tried $data['key'], $data['name'], $data['formValue'] and am getting nothing back. Only $data['value'] produces anything.

What would be the equivalent for the key? And, more generally, how would I go about seeing what properties something has so that I don't have to ask next time I have a question like this?

Edit:

For clarity's sake, I should make it clear that I'm editing the filterMessage template from the Listing template set:

<div class='ipsMessage ipsMessage_general'>
	<a href='{$category->url()->csrf()->setQueryString( array( "do" => "clearFilters", 'd' => \IPS\cms\Databases\Dispatcher::i()->databaseId ) )}' class='ipsPos_right ipsButton ipsButton_veryLight ipsButton_verySmall'>{lang="cms_database_filtered_clear"}</a>
	{lang="cms_database_filtered_by"}
	{{foreach $activeFilters as $id => $data}}
		{$data['field']->_title} ({$data['value']})
	{{endforeach}}
</div>

 

Posted
On 5/29/2018 at 11:17 PM, Meddysong said:

I think I could store some language strings as a prefix plus the key name for the field.

Do you mean template key?

templatekey.thumb.jpg.71ce7b6fc4c968e1d377ca2195dc5c5e.jpg

If so use 

$data['field']->key

 

Posted
6 minutes ago, newbie LAC said:

Do you mean template key?

Sadly not.

It's a select box:

Untitled-1.thumb.jpg.a5c917d948e229982aaefde52801f3b3.jpg

What I'd like is the keys here. Then I can create some language strings (meddysong_translation, meddysong_proofreading) and hopefully display the translations rather than be forced to use the values that are only in English.

Posted
8 minutes ago, Meddysong said:

What I'd like is the keys here.

$data['field']->extra

return an array like

Array
(
    [translation] => Translation
    [proofreading] => Proofreading
    [chatting on skype] => Chatting on skype
    [graphics] => Graphics
)

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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