exclude div content from internal search

General questions about CMSimple

exclude div content from internal search

Postby flukey92 » Wed Jan 11, 2012 9:42 am

Hi All!

Is it possible with a div class to exclude particular divs in the search.
for e.g.

I refer to different products on each of my product pages in a box called "similar products"
Now when i search for any of these parts it is coming up with any page that has the product also in its similar products section as it rightly should do.
However im awkward and fussy (as many of you already know ;) ) and want to make the experience to the visitor as easy as possible. so that if they search for one specific item, i can make sure it only shows them the official page for that item so that they dont get lost so to speak and leave.

i figured the easiest way to tell the search would be using a div class but i may be wrong.

If my question needs rewording dont be afraid to ask, im just wondering if there is anything currently in place re: search that can help with this :)

kr

flukey
RJS Electronics Ltd - LED Push Switches, LCD Programmable Keys, Anti Vandal Push Buttons, Relays, Custom Cable Assemblies
Visit my Web Hosting / Design website here - www.flukedesigns.co.uk
flukey92
 
Posts: 86
Joined: Thu Aug 11, 2011 9:39 am
Location: Bedford, UK

Re: exclude div content from internal search

Postby cmb » Wed Jan 11, 2012 1:08 pm

Hi Flukey,

flukey92 wrote:Is it possible with a div class to exclude particular divs in the search.

That's hardly possible with CMSimple. CMSimple doesn't rely on a real (X)HTML parser, as this is not widespread available under PHP 4, and for performance reasons. Instead all that's available are regular expressions. And it's generally not possible to match nested structures with regular expressions, for example:
Code: Select all
<div class="exclude-from-search">Blah blah<div class="inside">blah blah</div>blah blah</div>

couldn't be excluded only up to the first </div>.

So IMO it's better to mark the text, that should be excluded from the search by an HTML comment, for example:
Code: Select all
<!-- exclude-from-search -->Blah blah<div class="inside">blah blah</div>blah blah<!-- /exclude-from-search -->


Then you can change cmsimple/search.php (use the one from CMSimple_XH 1.5.1) by adding 1 line between line 46 and 47:
Code: Select all

        $pagexyz 
= evaluate_plugincall($pagexyz, TRUE);
        $pagexyz = preg_replace('/<!-- exclude-from-search -->.*?<!-- \/exclude-from-search -->/isU', '', $pagexyz);
            $pagexyz = mb_strtolower(strip_tags($pagexyz), 'utf-8');
 


Christoph
Christoph M. Becker---Plugins for CMSimple_XH
cmb
 
Posts: 5481
Joined: Tue Jun 21, 2011 11:04 am
Location: Germany

Re: exclude div content from internal search

Postby flukey92 » Wed Jan 11, 2012 2:55 pm

Thankyou very much Christoph

Once again you have saved the day!

Not trying to blow your trumpet but your knowledge of cmsimple is remarkable :)

I'll try this out now,

I think we've spoke before about searching for specific keywords and it going straight to that page if there is only one result? Cant quite remember what we said about this but i think it should be a suggestion to be considered for any new updates to xh

After ive tried this out i will apply the latest update for XH after ive done a backup as ive made many configurations to the core files of XH and wouldnt want them to disappear :)

Kind Regards

flukey
RJS Electronics Ltd - LED Push Switches, LCD Programmable Keys, Anti Vandal Push Buttons, Relays, Custom Cable Assemblies
Visit my Web Hosting / Design website here - www.flukedesigns.co.uk
flukey92
 
Posts: 86
Joined: Thu Aug 11, 2011 9:39 am
Location: Bedford, UK

Re: exclude div content from internal search

Postby flukey92 » Wed Jan 11, 2012 2:57 pm

Just to add,

Whether i used it inside a div container or inside a html comment made no difference to me, it was just one idea of containing the text,

Using a html comment would also work for me :)

KR

flukey
RJS Electronics Ltd - LED Push Switches, LCD Programmable Keys, Anti Vandal Push Buttons, Relays, Custom Cable Assemblies
Visit my Web Hosting / Design website here - www.flukedesigns.co.uk
flukey92
 
Posts: 86
Joined: Thu Aug 11, 2011 9:39 am
Location: Bedford, UK

Re: exclude div content from internal search

Postby cmb » Wed Jan 11, 2012 3:46 pm

Hi Flukey,

flukey92 wrote:I think we've spoke before about searching for specific keywords and it going straight to that page if there is only one result? Cant quite remember what we said about this but i think it should be a suggestion to be considered for any new updates to xh

You asked it before: http://www.cmsimpleforum.com/viewtopic.php?f=8&t=3746&p=23047#p23047. Unfortunately nobody answered. :( But probably you're right, and this should be added to the core.

Christoph
Christoph M. Becker---Plugins for CMSimple_XH
cmb
 
Posts: 5481
Joined: Tue Jun 21, 2011 11:04 am
Location: Germany

Re: exclude div content from internal search

Postby flukey92 » Wed Jan 11, 2012 4:24 pm

Yeah thats the one originally my idea was choosing specific keywords to link to pages, im not sure how the backend coding of cmsimple goes but i presume itd be a lot easier to make it so it happens if there is only one result instead.

Afterall if theres more than one listing in the search results it may be possible that the viewer wants one of the other pages not the page you have chosen.

Just an idea :)

KR

flukey / Rob
RJS Electronics Ltd - LED Push Switches, LCD Programmable Keys, Anti Vandal Push Buttons, Relays, Custom Cable Assemblies
Visit my Web Hosting / Design website here - www.flukedesigns.co.uk
flukey92
 
Posts: 86
Joined: Thu Aug 11, 2011 9:39 am
Location: Bedford, UK

Re: exclude div content from internal search

Postby cmb » Sat Jan 21, 2012 2:56 pm

Hi flukey,

flukey92 wrote:I think we've spoke before about searching for specific keywords and it going straight to that page if there is only one result? Cant quite remember what we said about this but i think it should be a suggestion to be considered for any new updates to xh

We spoke about it and rejected this suggestion, as it might be irritating for the user to land on the page without explicitly being informed, that there was only 1 search result. Consider search engines, which handle it the same way (AFAIK even Google's internal site search).

If you (and others) like to have this nonetheless, you can change it yourself.

Christoph
Christoph M. Becker---Plugins for CMSimple_XH
cmb
 
Posts: 5481
Joined: Tue Jun 21, 2011 11:04 am
Location: Germany

Re: exclude div content from internal search

Postby flukey92 » Mon Jan 23, 2012 1:29 pm

Thanks Christoph,

Im just going through the process of backing up my server now and documenting all changes to core files so i know what to do in the event of me corrupting any of the main files. plus hopefully ill see what codes ive put in over the year that i can scrap :)

After that i shall apply this straight away or look into a way that it will redirect to said page after 10seconds but leave some text to inform the user that this is what is happening

KR

flukey
RJS Electronics Ltd - LED Push Switches, LCD Programmable Keys, Anti Vandal Push Buttons, Relays, Custom Cable Assemblies
Visit my Web Hosting / Design website here - www.flukedesigns.co.uk
flukey92
 
Posts: 86
Joined: Thu Aug 11, 2011 9:39 am
Location: Bedford, UK

Re: exclude div content from internal search

Postby flukey92 » Wed Jan 25, 2012 2:01 pm

just to confirm everythings working okay :)

One thing i'd like to add to the code Christoph/CMB was so kind to help me with

From:
Code: Select all
       $pagexyz = evaluate_plugincall($pagexyz, TRUE);
          $pagexyz = preg_replace('/<!--excl-->.*?<!--\/excl-->/isU', '', $pagexyz);
            $pagexyz = mb_strtolower(strip_tags($pagexyz), 'utf-8');
     

To
Code: Select all
       $pagexyz = evaluate_plugincall($pagexyz, TRUE);
          $pagexyz = preg_replace('/<!--excl-->.*?<!--\/excl-->/isU', 'excluded', $pagexyz);
            $pagexyz = mb_strtolower(strip_tags($pagexyz), 'utf-8');
     

I added the excluded bit in the empty tag so that i can search for "excluded" and it will show any pages where i have used the "<!--excl-->" tag, its harder to explain than it is to understand :L. but it helps when im trying to work out why certain pages don tshow up in the search :) the best bit is that "excluded" doesnt show up on your html output anywhere even in the source, so for an extra 8bits of hard disk space i think its worth it :)

KR

flukey
RJS Electronics Ltd - LED Push Switches, LCD Programmable Keys, Anti Vandal Push Buttons, Relays, Custom Cable Assemblies
Visit my Web Hosting / Design website here - www.flukedesigns.co.uk
flukey92
 
Posts: 86
Joined: Thu Aug 11, 2011 9:39 am
Location: Bedford, UK

Re: exclude div content from internal search

Postby cmb » Wed Jan 25, 2012 2:09 pm

Hi flukey,

that's a good modification! Thanks for pointing it out -- should be helpful for others with some contents that should be excluded from the search.

About the SPAM: have a look at http://www.cmsimpleforum.com/viewtopic.php?f=2&t=4135

Christoph
Christoph M. Becker---Plugins for CMSimple_XH
cmb
 
Posts: 5481
Joined: Tue Jun 21, 2011 11:04 am
Location: Germany

Next

Return to General

Who is online

Users browsing this forum: htsopelas and 1 guest