1

Does anyone know how to decode the queries codes (stored like this YToxOntzOjU6ImZpZWxkIjthOjE6e3M6ODoidGFibGltbWUiO3M6MzoiMDFCIjt9fQ== in exp_super_search_history table) to transform it in this kind of format : search="keywords=green&channel=products&category=pants+shirts&status=-closed&orderby=title+asc&limit=100"

So I can use it as a parameter in {exp:super_search:results} tag.

Thanks in advance for the reply.

PS : already tried with a little bit of PHP (base64_decode()) but doesn't give the format needed.

EDIT ::

Hi, in fact I'll explain exactly what I'm trying to do :

In a template I make a query to retrieve all the member's last saved search datas.

{exp:query sql="SELECT essh.*
FROM exp_super_search_history essh
INNER JOIN
    (SELECT member_id, MAX(search_date) AS MaxDateSearch
    FROM exp_super_search_history WHERE saved='y' AND member_id != '0'
    GROUP BY member_id) groupedessh
ON essh.member_id = groupedessh.member_id
AND essh.search_date = groupedessh.MaxDateSearch"}

Whithin this query loop I wanted to show the results of all these searches retrieved by puttting the exp:super_search:results tags with the parameter search={query}. THat's the reason I wanted to decode the query value from exp_super_search_history.

The goal is : On this page I want to loop on all the member's last saved search results and send them an email once a week with the links to all the new added entries that matches their saved criterias.

Instead of trying to decode the {query} thing you suggested me to use the Super_Search:Search tag to build the URL string, what I did :

URL :

<?php
$the_url= '{if super_search_tablimme}tablimme={super_search_tablimme}{/if}{if super_search_comm}&comm={super_search_comm}{/if}{if super_search_offr}&offr={super_search_offr}{/if}{if super_search_prix-from}&prix-from={super_search_prix-from}{/if}{if super_search_prix-to}&prix-to={super_search_prix-to}{/if}';
?>

And after that :

{embed="template_group/template" the_url="<?php echo $lol; ?>" the_author="{member_id}"}

All works perfectly, except that on this list of results by member, I only see results filtered by criterias for the member I'm connected with.

Example 1, when I'm connected as member 1, on my list template I see :

member_id : 1

URL = tablimme=01&offr=V&prix-from=2000&prix-to=190000

results filterd

member_id : 2

URL =

all the results from the channel (not filtered because it doesn't have retrieved the URL, as you can see above, because I'm not connected with this member account)

Example 2, when I'm connected as member 2, on my list template I see :

member_id : 1

URL = all the results from the channel (not filtered because it doesn't have retrieved the URL, as you can see above, because I'm not connected with this member account)

member_id : 2

URL = tablimme=011

results filterd

I think the issue is at the Super_Search:Search tag level, not at the Super_Search:Results because as it is written in the Super Search Dococumentation we can add the search criterias we want in the search="" parameter.

This is for a immo project I have for a client. Can you give me help on this please ?

  • How about simply using {exp:super_search:search} with the search_id="" parameter instead? solspace.com/docs/super_search/search/#search_id This should retrieve all your search criteria, using standard variables. You could build your string this way (perhaps pass it in an embed for {exp:super_search:results} to use). – Solspace Feb 11 '15 at 1:54
  • Thanks for your answer. Thats a good idea but now that I've done this way I'm stuck with another problem : I see the URL created (and the results) only if I'm connected but I need to see this list when I'm not connected (this page is meant to be called by a cronjob to send to all the users the newly added entries that match their search criterias). Any idea how to fix this ? – pikarge Feb 12 '15 at 13:20
  • rectification : I see the URL created only for the member I'm logged with. I think the Super_Search:Search with the search_id="" parameter only works when you're connected. I'm stuck with my issue. Any thoughts ? – pikarge Feb 16 '15 at 14:53
  • If you're looking in the exp_super_search_history table, I'm assuming you're looking for saved searches. Guest users can also save searches, which are stored as a cookie only in their case. Of course, once the cookie expires, or if cookies are disabled, the saved search will not be available anymore for guest users. Make sure the exp_super_search_history cookie is present. – Solspace Feb 17 '15 at 10:44
  • @Solspace I think I didn't explain well my issue, I edited my post to explain better what I need. Thanks in advance for your help on this. – pikarge Feb 17 '15 at 16:20
0

So, what I did (if it can help someone) (thanks to @Solspace for his answers) :

In my template templategroup/list :

{exp:query sql="SELECT essh.history_id, essh.member_id, essh.results, essh.search_name, essh.search_date, essh.saved, essh.query AS my_query
FROM exp_super_search_history essh
INNER JOIN
    (SELECT member_id, MAX(search_date) AS MaxDateSearch
    FROM exp_super_search_history WHERE saved='y' AND member_id != '0'
    GROUP BY member_id) groupedessh
    ON essh.member_id = groupedessh.member_id 
    AND essh.search_date = groupedessh.MaxDateSearch
INNER JOIN
    (SELECT member_id
    FROM exp_members) groupedem
    ON essh.member_id = groupedem.member_id
    AND essh.member_id = groupedem.member_id"}


<?php
 $qr       = '{my_query}';
    $decoded      = base64_decode($qr);
    $unserialized = unserialize($decoded);

    if ( ! function_exists('convertArrayToString') ) {
    function convertArrayToString($array) {

        $string = '';

        foreach($array as $i => $cell) {

            if($i == 'field') {

                foreach($cell as $i => $c) {
                    $string .= $i . '=' . $c . '&';
                }

            } else {

                $key   = key($cell) . '-' . $i;
                $value = current($cell);

                $string .= $key . '=' . $value . '&';
            }
        }

        return rtrim($string, '&');
    }
    $the_url = convertArrayToString($unserialized);
    $the_url = str_replace("+", " ", $the_url); // to delete the "+" that it places instead of a white space, otherwise it doesn't match the value of the super search criteria's value
    echo $the_url;
} else {
    $the_url = convertArrayToString($unserialized);
    $the_url = str_replace("+", " ", $the_url); // to delete the "+" that it places instead of a white space, otherwise it doesn't match the value of the super search criteria's value
    echo $the_url;
}
?>

{embed="template_group/results_list" the_query="<?php echo $the_url; ?>" the_author="{member_id}"}

{/exp:query}

In my template templategroup/results_list :

{exp:super_search:results channel="my_channel" orderby="entry_date+desc" search_words_within_words="no" search="{embed:the_query}"}
     {if super_search_no_results}
     <p>No reslut that matches the search criterias</p>
     {/if}
     <a href="{url_title_path='goods/goods-details'}" title="Learn more about this good">{title}</a>
{/exp:super_search:results}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.