• Resolved hixen

    (@hixen)


    Like the topic says, is it possible to search in attached files?

    An example: I upload a filenam.doc file to the site, is it possible to have an option that says include search in attached files, and WordPress searches throuh the filename.doc and shows it’s findings?

    If it’s possible, can anyone point my into the right direction.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter hixen

    (@hixen)

    Anyone?

    Bad solution, but I don’t know any other.
    I don’t know if WordPress can do this alone, but php can
    you have to put the result of this function into a variable, and use a function like that (I translate the code for you) :

    <?php
    /******************************************************************************/
    /*                                                                            */
    /*                       __        ____                                       */
    /*                 ___  / /  ___  / __/__  __ _____________ ___               */
    /*                / _ \/ _ \/ _ \_\ \/ _ \/ // / __/ __/ -_|_-<               */
    /*               / .__/_//_/ .__/___/\___/\_,_/_/  \__/\__/___/               */
    /*              /_/       /_/                                                 */
    /*                                                                            */
    /*                                                                            */
    /******************************************************************************/
    /*                                                                            */
    /* Titre          : find a character in a string                      */
    /*                                                                            */
    /* URL            : http://www.phpsources.org/scripts154-PHP.htm              */
    /* Auteur         : PHP Sources                                               */
    /* Date รฉdition   : 04 Jan 2006                                               */
    /*                                                                            */
    /******************************************************************************/
    
      $my_string = 'abcefghigkmnlopqrstuvwxyz'; // put your variable containing your .doc instead $my_string
      $find_me  = 'a'; // put the search instead $find_me
      $position = strpos($my_string, $find_me);
    
      // you have to use ===  because == won't display anything
      // because the letter 'a' is in position 0
    
      if ($position === false) {
          echo '',$find_me,' not found in ',$my_string,'';
          } else
          {
          echo '',$find_me,' in in  ',$my_string,'';
          echo 'in position ',$position,'';
          }
    
    ?>

    if the translated code don’t work, try to use the original – maybe I’ve make a mistake.

    I think what’s being asked here is to have the search look within the documents themselves, that’s not quite so simple.

    The problem with that is that you’d need to query all the files, read the contents of each file and check for the search term (that’s alot of work for a script to do), so basically loop over each file, checking contents as you go (not something you can do with a query).

    http://php.net/manual/en/function.file-get-contents.php

    I’d not consider such a method to be efficient, especially if you’ve got more then a handful (5-10) attachments, the processing required would grow as the amount of attachments does.

    Maybe an alternative would be to tag attachments?
    http://wordpress.org/extend/plugins/media-tags/

    that’s why I said my solution was ” a bad solution ” :p

    The search everything plugin has the option to search attachments.

    I don’t think it’s for the content :p

    Search every attachment:
    (post type = attachment)

    that’s why I said my solution was ” a bad solution ” :p

    I wasn’t meaning to imply there was a problem with your suggestion(ie. a bad suggestion), simply pointing out that it may not fully address the question asked.. ๐Ÿ˜‰ No harm done.. ๐Ÿ™‚

    The search everything plugin has the option to search attachments.

    It won’t search “in” attachments though, such as .doc files (or any other file), because (well, put simply) the content of those files is not in the database, which is where the search is looking, but good suggestion nonetheless.. ๐Ÿ™‚

    I wasn’t meaning to imply there was a problem with your suggestion

    There is one ๐Ÿ˜€

    Thread Starter hixen

    (@hixen)

    Thanks alot guys, your input was very helpfull.

    I will tag my attachments since that seems the best way, and write a short description for each file.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Is it possible to search in attached files?’ is closed to new replies.