Find the "text"
Username:  
Password:
  > Home
v User Guide
    > Introduction
    > Hello World
    > Flow Control
    > Function Calls
    > Authentication
    > Database access
    v Content Management
       o Would you like some TEA
       o Find the "text"
       o Virtual page
    > Remote Calling
    > Object-Oriented
    > Other Features
> Reference
> Portal Object
> Development Guide


Shortcuts
sys Class
debug Class
Intrinsic Conversions
>> User Guide >> Content Management >> Find the "text" <=  =>      <  1  >  
Find the "text"

The text entered into the TEA is saved as a "text" class variable.  Each web page got a "text" class of its own, to nicely separate text contents from each other.  If you want to refer to "text" variables for another page, you can use the file& part of the variable (e.g. text%/products/index.htm&headline).

In the "text" command, only the name:item part of the variable needs to be specified, not the entire "text" variable.  (The ":item" part is usually omitted unless you want to multiple items with the same text name.)  You usually access a "text" variable only if you want to process the content as in our "search" example below.

There are a several things to point out before we go into the "search" example: a) The variable sys%textpagelist containing all the path/page that are available in the "text" class, b) the "htmlstrip" BEE Conversion that remove all HTML tags in the text to avoid hitting inside of a tag, and c) the "countstric" BEE Conversion that returns the number of substrings (case-insensitive match) contained in the input string.

var hitList = "(array)";

foreach (sys%textpagelist as page) {

   foreach (text%{page}& as text) {

         var stripped = {text%{page}&{text}|htmlstrip};

         if ("{stripped|countstric:{sys%form:searchkey}}" > 0)

               var hitList = "(var)hitList" conv="push:{page}";

   }

}

// Now hitList will contain all the path/pages with user-entered

// text containing the value of the "searchkey" form entry.

 

You can make the above really complicated by accepting multiple search keys, ignoring trivial keys (like common words or prepositions), counting the number of hits, sorting the page output with pages of higher hit-rate at the top, displaying a summary of the hit text, and even paging the result list if it is too long.  (We got a function that does just these in "common/search.bs".)

 

Previous Page       Next Page

Accsoft Computer Technology Pty Ltd     ABN: 98 065 617 549
PO Box 892, Epping NSW 1710         Level 1, Epping Office Park, 242 Beecroft Rd, Epping NSW 2121, Australia
Tel: Sydney - (02)98691668     National - 1300-881668         Fax: (02)98691866
© Copyright 2003 Accsoft Computer Technology Pty Ltd