Reindex Search.module CMSMS 1.3

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
pb
Forum Members
Forum Members
Posts: 27
Joined: Sun Jun 01, 2008 8:41 pm

Reindex Search.module CMSMS 1.3

Post by pb »

To spare RAM (550KB with the default content) and a little time  you change the function Redindex to this:

Code: Select all

function Reindex()
  {
    $db =& $this->GetDb();

    $db_prefix = cms_db_prefix();
    $db->Execute('DROP TABLE '.cms_db_prefix().'module_search_items');
    $db->Execute('DROP TABLE '.cms_db_prefix().'module_search_index');
    $dict = NewDataDictionary($db);
    $flds= "
		id I KEY,
		module_name C(100),
		content_id I,
		extra_attr C(100),
		expires " . CMS_ADODB_DT;

    $taboptarray = array('mysql' => 'TYPE=MyISAM');
    $sqlarray = $dict->CreateTableSQL(cms_db_prefix().'module_search_items', $flds, $taboptarray);
    $dict->ExecuteSQLArray($sqlarray);

    $db->CreateSequence(cms_db_prefix()."module_search_items_seq");
    $flds= "
		item_id I,
		word C(255),
		count I
	";
  $taboptarray = array('mysql' => 'TYPE=MyISAM');
  $sqlarray = $dict->CreateTableSQL(cms_db_prefix().'module_search_index', $flds, $taboptarray);
  $dict->ExecuteSQLArray($sqlarray);

  $sqlarray = $dict->CreateIndexSQL('count', $db_prefix."module_search_index", 'count');
  $dict->ExecuteSQLArray($sqlarray);
 
  
    global $gCms;
    $templateops =& $gCms->GetTemplateOperations();
    $alltemplates = $templateops->LoadTemplates();
    reset($alltemplates);
    while (list($key) = each($alltemplates))
      {
	$onetemplate =& $alltemplates[$key];
	//$this->EditTemplatePost($onetemplate);
	$params = array('template' => &$onetemplate,
                        'forceindexcontent'=>1);
	$this->DoEvent('Core', 'EditTemplatePost', $params);
      }

    $gcbops =& $gCms->GetGlobalContentOperations();
    $allblobs = $gcbops->LoadHtmlBlobs();
    reset($allblobs);
    while (list($key) = each($allblobs))
      {
	$oneblob =& $allblobs[$key];
	//$this->EditHtmlBlobPost($oneblob);
	$params = array('global_content' => &$oneblob);
	$this->DoEvent('Core', 'EditHtmlBlobPost', $params);
      }
		
    global $gCms;
    foreach($gCms->modules as $key=>$value)
      {
	if ($gCms->modules[$key]['installed'] == true &&
	    $gCms->modules[$key]['active'] == true)
	  {
	    if (method_exists($gCms->modules[$key]['object'], 'SearchReindex'))
	      {
		$gCms->modules[$key]['object']->SearchReindex($this);
	      }
	  }
      }
  }
It is better to drop tables and make new one  as to delete all of items and than write it all.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Reindex Search.module CMSMS 1.3

Post by calguy1000 »

pb, please read the appropriate sticky posts about how to contribute

essentially, submit svn diffs against current svn

please
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
pb
Forum Members
Forum Members
Posts: 27
Joined: Sun Jun 01, 2008 8:41 pm

Re: Reindex Search.module CMSMS 1.3

Post by pb »

I never have worked with svn and why i should do this ?

These  are all tips and tricks and everyone can use it or not here and directly.

Why i should do more work for this ?
thoms
Forum Members
Forum Members
Posts: 84
Joined: Tue Dec 25, 2007 5:56 pm

Re: Reindex Search.module CMSMS 1.3

Post by thoms »

You obviously have good ideas, good knowledge and the willingness to contribute to CMSMS.

Posting patches here in the forum brings some major problems:

1. Many users won't find it, especially in some weeks and months
2. Everytime I make an upgrade/update of CMSms, I have to change your patches again (if it is still possible and working in upcoming versions)

If you would submit your patches to the SVN, they could get part of CMSms and would be integrated in further versions.

So, your work would not be "lost in space", but make CMSms a still better CMS.

You find an explanation of a SVN client at
http://dev.cmsmadesimple.org/docman/vie ... isesvn.htm

thoms
pb
Forum Members
Forum Members
Posts: 27
Joined: Sun Jun 01, 2008 8:41 pm

Re: Reindex Search.module CMSMS 1.3

Post by pb »

and would be integrated in further versions
Everyone can use the tricks , developers too and so as soon as possible and at once or they can take it in further versions.

But 1.3 seems to be the last version before 2.0.
So, your work would not be "lost in space",
Tricks from me are made for my own use, i am not interested to have more work.

And as long as very old  bugs has only a device to nobody i think the tricks are "lost in space".
Pierre M.

Re: Reindex Search.module CMSMS 1.3

Post by Pierre M. »

Hello,

I agree with thoms : when patches are good they are better merged to benefit to everybody with the next release. This way all users of official packages get them, use them, like them and the support team supports them.

And I understand Calguy1000 asking for "submit svn diffs against current svn" : I'm sure it is pain for the DevTeam to merge uncurrent diffs.

"pb", if you can't checkout the current SVN to make your diffs against it, may be someone can volunteer as your svn-forge mate ?

Have fun contributing and improving CMSms :-)

Pierre
pb
Forum Members
Forum Members
Posts: 27
Joined: Sun Jun 01, 2008 8:41 pm

Re: Reindex Search.module CMSMS 1.3

Post by pb »

By the friendly words of Calguy1000 i decided  to do nothing more in this way.

I use CMSMS only for one customer who wanted this but it was to slow - so i must do this work.

So the site is ready and my work is done.
Post Reply

Return to “Tips and Tricks”