We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5810
    • 5 Posts
    Also, to get the snippet to work with the snippet code from the README, I had to modify the last few lines of HyperFlexSearchForm.inc.php, replacing
    // including the snippet
    return require ($filename_t);
    


    with

    else 
    {
    	$HyperFlexSearchForm_t = substr(file_get_contents($filename_t),5,-2);	//avoid <?php tags
    }
    
      • 5810
      • 5 Posts
      Benjamin, I see you haven’t been active here for nearly a month, perhaps you’re away. Anyway, for my own purposes I’ve solved the ’relevance’ issue as follows - I’ve removed the differentiation between ’partial’ and ’relevance’ searches, instead I’m using the ’partial’ sql along with a relevance score which is the sum of the keyword matches in each row, and then sorting by that relevance score. So if you put "one two" into the search box, items containing "one two" will be returned first, then items containing only "one" or only "two"

      (note this means I also removed $useAllWords as in this context all words are always used, and removed $minChars as a separate ’relevance’ mode no longer exists)

      I’ve also added in searching in the TVs. Code is attached in case you are interested, all changes from snippet.HyperFlexSearchForm.autogenerated.php are marked up with my username
        • 3098
        • 37 Posts
        Hi shobu and cormacparle smiley

        I’m back now and I will check this out as soon as possible !


        Thank you for your interest.

        Benjamin
          • 26182
          • 164 Posts
          Hi,

          I’m getting this error:

          « MODx Parse Error »
          MODx encountered the following error while attempting to parse the requested resource:
          « PHP Parse Error »
           
          PHP error debug
            Error: 	include_once(/var/www/html/dev/rcs/assets/../manager/cache_sync.class.processor.php) [function.include-once]: failed to open stream: No such file or directory	 
            Error type/ Nr.: 	Warning - 2	 
            File: 	/var/www/html/dev/rcs/assets/snippets/HyperFlexSearchForm/snippet.HyperFlexSearchForm.autogenerated.php	 
            Line: 	236	 
            Line 236 source: 	include_once $modx->config['rb_base_dir']."../manager/cache_sync.class.processor.php"; 	 
           
          Parser timing
            MySQL: 	0.0151 s	(7 Requests)
            PHP: 	0.0455 s	 
            Total: 	0.0606 s
            • 26182
            • 164 Posts
            I changed this line in the HFSF_module1.php file:

            include_once $modx->config[’rb_base_dir’]."../manager/cache_sync.class.processor.php";

            to

            include_once $modx->config[’rb_base_dir’]."../manager/processors/cache_sync.class.processor.php";

            after i deleted the autogenerated file...

            i am using this snippet call

            [[HyperFlexSearchForm]]

            I also used this

            [!HyperFlexSearchForm?!]

            and nothing displays on the page.

            What am I doing wrong?

            Thanks,

            Sarah
              • 5810
              • 5 Posts
              This might be self-evident if you’ve used modx a bit already, but I’m new to it myself and have found that you need to put snippet code in the template rather than in the page for it to work. Hope that helps
                • 26016
                • 561 Posts
                Quote from: sarah at Nov 01, 2007, 01:45 AM

                I changed this line in the HFSF_module1.php file:
                include_once $modx->config[’rb_base_dir’]."../manager/cache_sync.class.processor.php";
                to
                include_once $modx->config[’rb_base_dir’]."../manager/processors/cache_sync.class.processor.php";

                after i deleted the autogenerated file...i am using this snippet call
                [[HyperFlexSearchForm]] I also used this [!HyperFlexSearchForm?!]

                and nothing displays on the page. What am I doing wrong?
                I stumbled on the same error Sarah found, and made that change. And then I also got nothing for awhile! Not having a week to play with the code, I experimented. My solution was truly bizarro.... almost out of desperation, I opened up the archive to a previous version, 3r2, pulled this snippet code from the README, and used it to replace the latest suggested code:
                <?php
                
                // snippet name
                $snipName_t = "HyperFlexSearchForm";
                // snippet description
                $snipDesc_t = "<strong>v3r2</strong> Add advanced search features to the original FlexSeachForm snippet";
                
                // setting snippet path
                $snipPath_t = $modx->config["rb_base_dir"].'snippets/';
                // including the main file
                return require $snipPath_t.$snipName_t."/".$snipName_t.".inc.php";
                
                ?>
                

                Worked like a champ! My snippet call was this: [!HyperFlexSearchForm? &FSF_showResults=`1` !] I also got it to work using both the Parent Search and Template Search parameters. I used the snippet on a page rather than in a template, and that’s why I wanted to "show results" there. I’m quite sure it would work fine in a template too, just display the results in a separate page rather than right in the template.

                It’s SO tantalizing to find a snippet like this with fancy features, but at the same time very frustrating when it doesn’t work. Oh, well, I guess we get what we pay for! grin Why didn’t the snippet code from the latest README work? I think it’s because it contains example code, but it’s not obvious what to take out, despite the notes in there. in any case, I don’t really know, and because the above works, I’ll let someone else figure it out.

                I’m sure Benjamin can enlighten us when he comes back again in a few months. wink To me, it’s extremely useful to be able to search by template or folder! I hope this helps someone, causing them to swear less than I did!

                Cheers, Samba
                  MODx and Wordpress development
                  Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
                  • 26182
                  • 164 Posts
                  Thanks samba. Unfortunately, I’m still getting errors argh. Oh well.

                  « MODx Parse Error »
                  MODx encountered the following error while attempting to parse the requested resource:
                  « PHP Parse Error »
                   
                  PHP error debug
                    Error: 	include_once(/www/itnews/assets/../manager/cache_sync.class.processor.php) [function.include-once]: failed to open stream: No such file or directory	 
                    Error type/ Nr.: 	Warning - 2	 
                    File: 	/www/itnews/assets/snippets/HyperFlexSearchForm/snippet.HyperFlexSearchForm.autogenerated.php	 
                    Line: 	236	 
                    Line 236 source: 	include_once $modx->config['rb_base_dir']."../manager/cache_sync.class.processor.php"; 	 
                   
                  Parser timing
                    MySQL: 	0.0145 s	(6 Requests)
                    PHP: 	0.1140 s	 
                    Total: 	0.1285 s
                  
                    • 5810
                    • 5 Posts
                    sarah I just noticed in your error messages the paths are different - one is /var/www/html/dev/rcs/assets/ and the other is /www/itnews/assets/
                    I guess you’re trying this in different places, but I thought I’d point it out just in case you’re not and you hadn’t noticed.

                    Here’s the snippet code from resources > snippets that I used, in case it’s any help:

                    <?php
                    // snippet name
                    $snipName_t = "HyperFlexSearchForm";
                    // snippet description
                    $snipDesc_t = "<strong>v3r4</strong> Add advanced search features to the original FlexSeachForm snippet";
                    
                    // setting snippet path
                    $snipPath_t = $modx->config["rb_base_dir"].'snippets/';
                    // including the main file
                    include $snipPath_t.$snipName_t."/".$snipName_t.".inc.php";
                    
                    // snippet parameters
                    $snipParam_at = array();
                    $snipParam_at['templateSearch'] = "Artwork main,Artist main";
                    $snipParam_at['templateSearchMode'] = "1";
                    $snipParam_at['showResultExtract'] = "0";
                    
                    
                    // snippet evaluation
                    return $modx->evalSnippet($HyperFlexSearchForm_t, $snipParam_at);
                    ?>


                    You’ll need to change the $snipParam_at[’templateSearch’] variable to whatever templates you want to search

                    My snippet call on the search template page is just:

                    [!HyperFlexSearchForm!]
                      • 26016
                      • 561 Posts
                      Sarah,
                      To add to cormacparle’s point, based on your latest error, I think you may need to make the same change to HFSF_module1.php that you mentioned before, delete the autogenerated file, and try again. If that works, then the fixed version of HFSF_module1.php can become standard for your installations.

                      It also may be worth mentioning that cormacparle’s code seems to be searching for items with templates "Artwork main" and "Artist main", which of course probably doesn’t apply to your system. You can specify parameters either in the snippet call or in the snippet itself, and this can be a little tricky.

                      Come to think of it, when I unzipped the original archive and installed, I got some sort of error because HyperFlexSearchForm.inc.php was in DOS format rather than Unix, something about a line ending. So I saved the file in Unix format and that fixed it. My unzip program may have borked it; not sure.

                      Hope that helps.
                        MODx and Wordpress development
                        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4