Hi,
this is my first post here and I'm new in developing sugar modules.
I'm using the yui autocompleter for distinct results, but this code:
<SCRIPT>
//BEGIN ACL JAVASCRIPT
</SCRIPT>
is always attached to the correct autocomplete return values while typing and is show in the dropdown.
This is the way I'm using the yui autocompleter:
.js file
yui.css fileCode:var myServer = "index.php"; var mySchema = ["\n", "\t"]; var myDataSource = new YAHOO.widget.DS_XHR(myServer, mySchema); myDataSource.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT; myDataSource.queryMatchSubset = true; myDataSource.scriptQueryAppend = "table=expenses&field=destination&action=yui&module=Expenses&sugar_body_only=true&to_pdf=true"; var myAutoComp = new YAHOO.widget.AutoComplete( "destinationn", "destination_container", myDataSource ); myAutoComp.animVert = true; myAutoComp.queryDelay = 0.25; myAutoComp.autoHighlight = true; myAutoComp.useShadow = true; myAutoComp.useIFrame = true; myAutoComp.typeAhead = true; myAutoComp.allowBrowserAutocomplete = false; myAutoComp.delimChar = ""; myAutoComp.formatResult = function(oResultItem, sQuery) { var sKey = oResultItem[0]; var nQuantity = oResultItem[1]; var sKeyQuery = sKey.substr(0, sQuery.length); var sKeyRemainder = sKey.substr(sQuery.length); var aMarkup = [sKeyQuery,sKeyRemainder]; return (aMarkup.join("")); };
htmlCode:.yuicontainer { position:relative; width:120px; z-index:9001; }/* set width of widget here*/ .yuisearch { position:absolute; top:1.7em; width:120px; } .yui-ac-content {position:absolute;width:100%;border:1px solid #404040;background:#fff;overflow:hidden;z-index:9050;} .ysearchquery {position:absolute;right:10px;color:#808080;z-index:10;} .yui-ac-shadow {position:absolute;margin:.3em;width:100%;background:#a0a0a0;z-index:9049;} .yui-ul {padding:0px;width:100%;margin-top:0px;margin-bottom:0px;} .yui-li {padding:0px;cursor:default;white-space:nowrap;margin-top:0px;margin-bottom:0px;} li.yui-ac-highlight {background:#ff0;} table.tabForm td ul li { list-style-type: none; margin-bottom: 0px; }
I defined these two methods in the main module class:Code:<script type="text/javascript" src="modules/Expenses/include/javascript/yui/YAHOO.js"></script> <script type="text/javascript" src="modules/Expenses/include/javascript/yui/dom.js"></script> <script type="text/javascript" src="modules/Expenses/include/javascript/yui/event.js"></script> <script type="text/javascript" src="modules/Expenses/include/javascript/yui/connection.js"></script> <script type="text/javascript" src="modules/Expenses/include/javascript/yui/animation.js"></script> <script type="text/javascript" src="modules/Expenses/include/javascript/yui/json.js"></script> <script type="text/javascript" src="modules/Expenses/include/javascript/yui/autocomplete.js"></script> <link rel="stylesheet" href="modules/Expenses/include/css/yui.css" type="text/css" media="screen" /> <div id="ysearchautocomplete0" class="yuicontainer"> <input style="width:120px" type=text size="25" name="destinationn" id="destinationn" class="dataField" value="{DESTINATION_NAME}"> <div id="destination_container" class="yuisearch"></div> </div> <script type="text/javascript" src="modules/Expenses/include/javascript/expenses.js"></script> <input id='destination_id' name='destination_id' type="hidden" value="{DESTINATION_ID}" />
and this is the content of my yui.php located in the module root directory:Code:/** * publish the results from yui query to expenses.js autocomplete * * @param array $results */ function pushResults( $results ) { foreach ( $results as $result_key => $result_value ) { echo $result_value . "\n"; } } /** * build the array which returns on a query-request from a yui autocomplete field * * @param string $query * @param string $table * @param string $field * @return array $return_results autocomplete search results */ function initArray( $query, $table, $field ) { $return_results = array(); $sql = " SELECT DISTINCT(" . $field . ") FROM " . $table . " WHERE " . $field . " LIKE '" . $query . "%' ORDER BY " . $field . " ASC"; $result = $this->db->query( $sql, true, " Error filling in additional detail fields: " ); while( $hash = $this->db->fetchByAssoc( $result ) ) { $return_results[] = $hash[$field]; } return $return_results; }
The autocomplete is working fine, but there is some content attached to the autocomplete result which I can't explain to me:Code:include( 'modules/Expenses/NewEntryPoint.php' ); require_once( 'modules/Expenses/Expense.php' ); $query = $_GET['query']; $table = $_GET['table']; $field = $_GET['field']; $focus = new Expense(); $focus->pushResults( $focus->initArray( $query, $table, $field ) );
When I put all logic/code directly in yui.php without an instance of the main class, everything is working correct - without the attached code from above.Code:<SCRIPT> //BEGIN ACL JAVASCRIPT </SCRIPT>
It seems that the instance of the module class produces the output from above.
How can I supress or disable this content?
Is there anywhere a documentation of the possible sugar-defined $_GET variables for accessing a module?
Like: action=yui&module=Expenses&sugar_body_only=true&to _pdf=true
$sugar_body_only, $to_pdf, $action etc.
I didn't find anything in forum and wiki.
Thanks for help
Andi
» Operating system type and version (ubuntu edgy edge)
» Sugar Suite version (4.5.1a)
» Webserver type and version (Apache 2.0.55)
» PHP version (5.2.1)
» MySQL server version (4.1.15)


LinkBack URL
About LinkBacks




Reply With Quote
Bookmarks