<?php
/*
Type: Snippet
Name: search_form
Description: Generated Search Form For Products
*/
ini_set("error_reporting", E_ALL);
ini_set("display_errors", true);
$cssClass = (isset($cssClass))?$cssClass:"product_search";
$mode = (isset($mode))?$mode:"home";
$submitlabel = ($mode=="home")?"Go":"Search";
$displayresults = ($mode=="home")?"":$modx->runSnippet('search_result_totals');
$basePath = $modx->config['base_path'];
include_once $basePath.'assets/modules/productmanager/config.inc.php';
//global $pm_config;
include_once $basePath.$pm_config["path_module"].$pm_config["path_class"].'options.php';
include_once $basePath.$pm_config["path_module"].$pm_config["path_class"].'categories.php';
$cats = new Categories();
$categories = $cats->getAllCatNames();
...
the code
...
return $outHtml;
?>
<?php
/*
Type: Snippet
Name: search_result_totals
Description: Search Result Totals for Product Manager
*/
$basePath = $modx->config['base_path'];
include_once $basePath.'assets/modules/productmanager/config.inc.php';
//global $pm_config;
include_once $basePath.$pm_config["path_module"].$pm_config["path_class"].'options.php';
include_once $basePath.$pm_config["path_module"].$pm_config["path_class"].'categories.php';
include_once $basePath.$pm_config["path_module"].$pm_config["path_class"].'fields.php';
include_once $basePath.$pm_config["path_module"].$pm_config["path_class"].'types.php';
include_once $basePath.$pm_config["path_module"].$pm_config["path_class"].'products.php';
include_once $basePath.$pm_config["path_module"].$pm_config["path_class"].'productdata.php';
$cats = new Categories();
$categories = $cats->getAllCatNames();
$catWhere = Array();
foreach($categories as $catid => $catname) {
if($_REQUEST["cat_".$catid] > 0) {
$catWhere[] = "( catid = ".$catid." AND optid = ".$_REQUEST["cat_".$catid]." )";
}
}
$where = implode(" AND ",$catWhere);
if(empty($where)) {
$where = "1";
}
$sql = "SELECT DISTINCT(prodid) as productid FROM ".$pm_config["db_prefix"].$pm_config["dbt_cat_link"]." WHERE ".$where.";";
$result = $modx->dbQuery($sql);
$rowCount = $modx->recordCount($result);
$start = $_REQUEST["strt"];
$start = 1;
$end = $start + 10;
$retVal = "<p>Displaying {$start} - {$end} of {$rowCount} Products or Services</p>\n";
return $retVal;
?>


Whenever you include a file in PHP, the included file inherits the variable scope of the file it was included in. So if you have two separate snippets that use a variable with the same name, the snippet you include in this manner will overwrite the previous snippet’s variable.
More information about Variable Scope is available on php.net.
What is the contents of the config file you included in this example?
[me=jamie]runs off and reads[/me]