klox7 VIP
Total posts: 914
04 Sep 2014 17:04

I have countries as categories. I need to search through countries with text search.

So I was thinking of adding new field (text) that will be hidden from input form. When I save form I want this field to be populated with same value that user selected in category. I need this also when user edit his record (in case of changing category). Any possible quick workaround? Thanks!

Last Modified: 11 Nov 2014


Sergey
Total posts: 13,748
05 Sep 2014 09:35

To me it make no sense. If your categpries are countries then simply category click is a search by categpry. You see only article in this category.


klox7 VIP
Total posts: 914
05 Sep 2014 11:48

For me text search is first step to search through all possible values. I already have filter by location but I want for my users to be able to write in search input anything they want.

So if I have hotels as records I want to serve users results based on "hotels in italy" search.


Sergey
Total posts: 13,748
08 Sep 2014 01:01

I cannot make this change in Cobalt 8 already. So even if I want to add categories to search I cannot. Only in Cobalt 9.


klox7 VIP
Total posts: 914
08 Sep 2014 06:41

But is it possible to use field SQL query to save another field value or is it just for list values?


Sergey
Total posts: 13,748
09 Sep 2014 01:55

It is not this simple. Index is altered in places for Cobalt. YOu have to hak at least 4 files. And it is also very complex. And we are talking about saving category name right? Why you ask about field value?


klox7 VIP
Total posts: 914
09 Sep 2014 05:55

Sergey Why you ask about field value?

Yes I was talking for category. And to save country from geo field to another field also not possible right?

Now that I think of I can probably duplicate input with javascript.


Sergey
Total posts: 13,748
11 Sep 2014 02:12

klox7 Now that I think of I can probably duplicate input with javascript.

Yes you can create hidden field in custom form and JS that populate this field when category is selected.


Jeff VIP
Total posts: 745
11 Sep 2014 02:18

Sergey It is not this simple. Index is altered in places for Cobalt. YOu have to hak at least 4 files. And it is also very complex. And we are talking about saving category name right?

I have to agree with that, I have tried it before and gave it up.

Searching categories through text search is not a bad suggestion if you think of it. The majority of Cobalt fields can be indexed for text search, even the fields that are better off as a search filter (like categories). So in terms of consistency and versatility, it's not such a crazy idea.

The use of third party (ajax) search modules has been discussed here earlier. It is just another/extra means to enhance the user experience.

klox7 And to save country from geo field to another field also not possible right?

I like the idea of saving a field value into another field. It reminds me of the concat plugin for Seblod, where you can combine anything (multiple field values, text, etc) to be saved as one value.


Sergey
Total posts: 13,748
11 Sep 2014 02:24

Jeff Searching categories through text search is a bad suggestion if you think of it. The majority of Cobalt fields can be indexed for text search, even the fields that are better off as a search filter (like categories). So in terms of consistency and versatility, it's not such a crazy idea.

I am not saying that this is creazy idea. Idea is good. And if theer is a parameter, one who do not like it just tun category name indexing off.

I am saying that I cannot implement it in Cobalt 8 because I will not be able to merge those changes to Cobalt 9 which is in development.


Jeff VIP
Total posts: 745
11 Sep 2014 02:28

Sergey I am saying that I cannot implement it in Cobalt 8 because I will not be able to merge those changes to Cobalt 9 which is in development.

My bad. I already understood that it won't be implemented as soon as Cobalt 9, which makes perfect sense :-)


nblgeoweb VIP
Total posts: 178
11 Sep 2014 15:51

I suggest thinking about if you really need categories at all if it's a big problem for you. I found that in a lot of my projects that a field with a value that otherwise would have been a category works quite well. Instead of listing the contents of a category, you apply a filter to the record listing. The biggest thing I miss when not using categories is the ability to follow/watch a category. The equivalent ability when not using categories would be to follow a filter. That functionality is coming in Cobalt 9 if I remember correctly.


klox7 VIP
Total posts: 914
11 Sep 2014 16:55

nblgeoweb I suggest thinking about if you really need categories at all if it's a big problem for you.

I acctually wouldn't need categories if I could list all field values with links to results without manually creating them. I use countries as categories and around 250 categories is too much for me, but I don't know workaround for listing.


klox7 VIP
Total posts: 914
23 Sep 2014 13:20

Sergey Yes you can create hidden field in custom form and JS that populate this field when category is selected.

I managed to do this with jquery like this:

$(document).ready(function() {
    $("#jformcategory").change(function () {
        var country = "";
        $("select option:selected").each(function () {
            country += $(this).text() + " ";
        });
        $("#field_301").val(country);
    }).change();
});

But the problem is text() function includes "Country - Select Country - Use Global English (United Kingdom) No No unarchive Public Published".

How can I select only "Country"?


Sergey
Total posts: 13,748
24 Sep 2014 10:29

This $("select option:selected") select all option on all form. You have to limit it by ID $("select#selectfieldid option:selected")


klox7 VIP
Total posts: 914
24 Sep 2014 12:12

Thanks. Another question just out of curiosity. Could I save value to another field with cobalt events?

Click here to link...


Sergey
Total posts: 13,748
25 Sep 2014 03:39

yes of course. ALl you need to do in the event

$_POST['jfomr']['fields'][10] = 'text field ID 10';
$_POST['jfomr']['fields'][12] = array('select field ID 10', 'another value');

klox7 VIP
Total posts: 914
03 Nov 2014 11:07

OK, so for this I have to create plugin. If I hardcode it that's fine for me but I'm thinking of doing configurable plugin if I will be able to.

My question is what would be the best practice to save category value to some other field for different sections types?


Sergey
Total posts: 13,748
03 Nov 2014 11:59

klox7 My question is what would be the best practice to save category value to some other field for different sections types?

What are you doing there? your tasks and cases are very interesting.

So you want while saving one type, save it's category in another type? How do you know in what article? Parent article?

Please explain more.


klox7 VIP
Total posts: 914
03 Nov 2014 13:34

Sergey So you want while saving one type, save it's category in another type? How do you know in what article? Parent article?

Hmm, connected categories in relation parent-child would probably be interesting in some cases but this is not what I mean. But it would be useful for the project I'm working on. For ex. in travel area. If you have resort with different accomodations then your accomodations could inherit category value from resort (category could be country, resort type - ex. family, tropical etc.). That would work I think. But as I said I'm doing something different.

OK, let me try to explain.

I miss the ability to text search through categories. My workaround is that I created text field and when users select category in edit form it adds that value to text field with help of JS.

But since I don't like this solution I read about your Cobalt events which seems more bullet proof. Now I'm not a developer so I'm figuring out as I go. With your help of course.

And because of some other discussions (how to add field value to meta description, open graph tags etc.) I was thinking of creating plugin that will trigger events. You could select some of the existing events in plugin parameters (like on save article add category to field value, on article save add field value to meta description) and for others you could have 3 textarea inputs, one for onAfterArticleSaved, one for onBeforeArticleSaved and one for onActivity. This way you could just insert your code in those inputs and the plugin wold take care the rest for you.

Now my problem or my question is following. This plugin should work for all types and its sections. So if I want to save category in field value I have to select Type and field. But if I have different types (each with its specific field) I need to configure this for all types. So how to do this?

Can I use some multiple select and system will know which field coresponds to which type? So if I have parameter for "Choose types" and "Choose fields" what is best practice to "link" right type with right field?


Sergey
Total posts: 13,748
06 Nov 2014 11:58

klox7 I miss the ability to text search through categories. My workaround is that I created text field and when users select category in edit form it adds that value to text field with help of JS.

Why specialized category filter does not work? I think it is even better. Easier to select, more exact result.

Ша you want category name be in fulltext index I may add this parameter. Or you need text input that search only categories?

Powered by Cobalt