Make blog searchable.

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
rahulu
Forum Members
Forum Members
Posts: 17
Joined: Tue Jan 19, 2016 5:30 am

Make blog searchable.

Post by rahulu »

Hi Every one,

I am using cmsms 1.11.7.
When I search the blog from search not able to search the blog.

I used the following code but it's not work.

Code: Select all

function SearchResult($returnid, $articleid, $attr = '')
    {
      $result = array();
      
      if ($attr == 'blogentry')
   {
     $db =& $this->GetDb();
     $q = "SELECT title FROM ".cms_db_prefix()."module_blogs_entries WHERE
              active = 1 AND id = ?";
     $dbresult = $db->Execute( $q, array( $articleid ) );
     if ($dbresult)
       {
      
         $row = $dbresult->FetchRow();

         //0 position is the prefix displayed in the list results.
         $result[0] = $this->GetFriendlyName();
      
         //1 position is the title
         $result[1] = $row['title'];

         //2 position is the URL to the title.
         
         $aliased_title = munge_string_to_url($row['title']);
         $prettyurl = 'Blogs/' . $articleid.'/'.$returnid."/$aliased_title";
         $result[2] = $this->CreateLink('cntnt01', 'detail', $returnid, '', array('articleid' => $articleid) ,'', true, false, '', true, $prettyurl);

       }
   }
      
      return $result;
    }

    function SearchReindex(&$module)
    {
      $db =& $this->GetDb();
      
      $query = 'SELECT * FROM '.cms_db_prefix().'module_blogs_entries';
      $result = &$db->Execute($query);

      while ($result && !$result->EOF)
   {
     if ($result->fields['active'] == '1')
       {
         $module->AddWords($this->GetName(), 
            $result->fields['id'], 'blogentry', 
            $result->fields['title'] . ' ' . $result->fields['text'],
            NULL);
       }
     $result->MoveNext();
   }
   
     //Update search index
    $module =& $this->GetModuleInstance('Search');
    if ($module != FALSE)
      {
   $module->DeleteWords($this->GetName(), $entryid, 'blogentry');
      }
      
    }

Have any one any idea about blog make searchable?
Please reply.

Thanks in advance.
Last edited by velden on Thu Jan 28, 2016 9:43 am, edited 1 time in total.
Reason: please use [code] tags around your sample code
Post Reply

Return to “The Lounge”