Jump to content

Need help understanding where a template (.tpl) is loaded using PHP.


Recommended Posts

Greetings.  I have a specific problem and I am not a PHP coder unfortunately.  I am working with a shopping cart (cubecart) that is done in PHP.  The shopping cart is actually a complete site dynamically creating ALL the website pages from the product categories and their associated products, the individual product details, as well as a shopping cart.  The shopping cart uses a template system (using .tpl files).  However, it uses 2 main global templates (index.tpl and cart.tpl) to load all other templates inside one of these two global templates.

 

For all pages besides the actual shopping cart, it uses the global template index.tpl and for the shopping cart it uses the cart.tpl.  All templates have an associated .php file that encompasses the back-end PHP code.  Currently, as mentioned, when you go around on the website, the index.tpl file is the template being loaded, and acts as a page container for all other minor templates (i.e. inside the index.tpl template, it calls a menu template, and a header and footer template just to name a few.  However, if you click to view your "shopping cart" it loads the cart.tpl template.  At this point the index.tpl template is no longer in play, and the cart.tpl is the page container for all other minor templates. 

 

I have attached the index templates associated include .php file below, the cart include PHP file, as well as the include php file for the 'small' shopping cart (This 'shopping cart' is the one you would see from page to page that tells you how many items you have in your shopping cart.  But clicking "view basket" it loads the cart.tpl as mentioned). 

 

Can someone help me understand how the global templates (index.tpl or cart.tpl gets called/used depending on whether your viewing the contents of the shopping cart (i.e. ready to check out) or anywhere else on the site????

 

 
<?php
/*
+--------------------------------------------------------------------------

+--------------------------------------------------------------------------
|   index.inc.php
|   ========================================
|   Main pages of the store 
+--------------------------------------------------------------------------
*/
if (!defined('CC_INI_SET')) die("Access Denied");

$body = new XTemplate ("global".CC_DS."index.tpl");

## Extra Events
$extraEvents = "";
if (isset($_GET['added']) && !empty($_GET['added'])) {
    if ($cc_session->ccUserData['customer_id'] == false && $config['hide_prices'] == 1) {
        ## have a break, have a KitKat
    } else {
        $extraEvents = "flashBasket(6);";
    }
}
$body->assign("EXTRA_EVENTS",$extraEvents);

if (isset($_GET['searchStr'])) {
    $body->assign("SEARCHSTR", sanitizeVar($_GET['searchStr']));
} else {
    $body->assign("SEARCHSTR","");
}

$body->assign("CURRENCY_VER",$currencyVer);

## Incluse langauge config
include("language".CC_DS.LANG_FOLDER.CC_DS."config.php");
$body->assign("VAL_ISO",$charsetIso);

## START CONTENT BOXES
require_once"includes".CC_DS."boxes".CC_DS."searchForm.inc.php";
$body->assign("SEARCH_FORM",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."session.inc.php";
$body->assign("SESSION",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."categories.inc.php";
$body->assign("CATEGORIES",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."randomProd.inc.php";
$body->assign("RANDOM_PROD",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."info.inc.php";
$body->assign("INFORMATION",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."language.inc.php";
$body->assign("LANGUAGE",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."currency.inc.php";
$body->assign("CURRENCY",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."shoppingCart.inc.php";
$body->assign("SHOPPING_CART",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."popularProducts.inc.php";
$body->assign("POPULAR_PRODUCTS",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."saleItems.inc.php";
$body->assign("SALE_ITEMS",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."mailList.inc.php";
$body->assign("MAIL_LIST",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."siteDocs.inc.php";
$body->assign("SITE_DOCS",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."skin.inc.php";
$body->assign("SKIN",$box_content);
## END CONTENT BOXES

require_once"includes".CC_DS."content".CC_DS."hdrImage.inc.php";
$body->assign("HDRIMAGE",$hdr_image);

## START  MAIN CONTENT
if (!empty($_GET['_a'])) {
    #if ($_GET['_a'] == 'search') $_GET['_a'] = 'viewCat';
    if (file_exists("includes".CC_DS."content".CC_DS.sanitizeVar($_GET['_a']).".inc.php")) {
        require_once"includes".CC_DS."content".CC_DS.sanitizeVar($_GET['_a']).".inc.php";
    } else {
        require_once"includes".CC_DS."content".CC_DS."index.inc.php";
    }
} else {
    require_once"includes".CC_DS."content".CC_DS."index.inc.php";
}

## END MAIN CONTENT

## Start DaisyBlossoms Content
require_once"includes".CC_DS."content".CC_DS."hdrImage.inc.php";
##  End DaisyBlossoms Content

## START META DATA
if (isset($meta)) {
    $meta['title'] = sefMetaTitle();
    $meta['description'] = sefMetaDesc();
    $meta['keywords'] = sefMetaKeywords();
    
} else {
    $meta['title'] = htmlspecialchars(str_replace("&#39;","'",$config['siteTitle']));
    $meta['description'] = $config['metaDescription'];
    $meta['keywords'] = $config['metaKeyWords'];
}

$body->assign("META_TITLE", stripslashes($meta['title']));
$body->assign("META_DESC", stripslashes($meta['description']));
$body->assign("META_KEYWORDS", stripslashes($meta['keywords']));


?>
  

 

The Cart include PHP file

 

 
<?php
/*
+--------------------------------------------------------------------------
|   CubeCart 4
|
|   cart.inc.php
|   ========================================
|   Controls Cart Actions   
+--------------------------------------------------------------------------
*/
if (!defined('CC_INI_SET')) die("Access Denied");

$body = new XTemplate("global".CC_DS."cart.tpl");

if (isset($_GET['searchStr'])) {
    $body->assign("SEARCHSTR", sanitizeVar($_GET['searchStr']));
} else {
    $body->assign("SEARCHSTR", "");
}
$body->assign("CURRENCY_VER",$currencyVer);

## Incluse langauge config
include("language".CC_DS.LANG_FOLDER.CC_DS."config.php");
$body->assign("VAL_ISO",$charsetIso);

## START META DATA
$body->assign("META_TITLE", stripslashes(htmlspecialchars(str_replace("&#39;", "'", $config['siteTitle']))));
$body->assign("META_DESC", stripslashes($config['metaDescription']));
$body->assign("META_KEYWORDS", stripslashes($config['metaKeyWords']));

$returnPage = urlencode(currentPage());

## START  MAIN CONTENT
switch (sanitizeVar($_GET['_a'])) {
    case "step1":
        require_once "includes".CC_DS."content".CC_DS."step1.inc.php";
        break;
    case "cart":
    case "step2":
        require_once "includes".CC_DS."content".CC_DS."cart.inc.php";
        break; 
    case "step3":
        require_once "includes".CC_DS."content".CC_DS."gateway.inc.php";
        break; 
    case "reg":
        require_once "includes".CC_DS."content".CC_DS."reg.inc.php";
        break;
    case "viewOrders":
        require_once "includes".CC_DS."content".CC_DS."viewOrders.inc.php";
        break;
    case "viewOrder":
        require_once "includes".CC_DS."content".CC_DS."viewOrder.inc.php";
        break;
    case "error":
        require_once "includes".CC_DS."content".CC_DS."error.inc.php";
        break;
    case "confirmed":
        require_once "includes".CC_DS."content".CC_DS."confirmed.inc.php";
        break;
    default:
        httpredir("index.php");
}

## START CONTENT BOXES
require_once "includes".CC_DS."boxes".CC_DS."searchForm.inc.php";
$body->assign("SEARCH_FORM", $box_content);

require_once "includes".CC_DS."boxes".CC_DS."session.inc.php";
$body->assign("SESSION", $box_content);

require_once "includes".CC_DS."boxes".CC_DS."siteDocs.inc.php";
$body->assign("SITE_DOCS", $box_content);

require_once "includes".CC_DS."boxes".CC_DS."cartNavi.inc.php";
$body->assign("CART_NAVI", $box_content);

## added in 4.0.3 - not part of templates, but designers can use them if they want
require_once"includes".CC_DS."boxes".CC_DS."currency.inc.php";
$body->assign("CURRENCY",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."categories.inc.php";
$body->assign("CATEGORIES",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."mailList.inc.php";
$body->assign("MAIL_LIST",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."shoppingCart.inc.php";
$body->assign("SHOPPING_CART",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."randomProd.inc.php";
$body->assign("RANDOM_PROD",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."info.inc.php";
$body->assign("INFORMATION",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."language.inc.php";
$body->assign("LANGUAGE",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."popularProducts.inc.php";
$body->assign("POPULAR_PRODUCTS",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."saleItems.inc.php";
$body->assign("SALE_ITEMS",$box_content);

require_once"includes".CC_DS."boxes".CC_DS."skin.inc.php";
$body->assign("SKIN",$box_content);
## END CONTENT BOXES

?>

 

And the Basket

 

 
<?php

/*

+--------------------------------------------------------------------------

|   CubeCart 4

+--------------------------------------------------------------------------

|   shoppingCart.inc.php

|   ========================================

|   Shopping Cart Box   

+--------------------------------------------------------------------------

*/



if (!defined('CC_INI_SET')) die("Access Denied");



if (!$cc_session->user_is_search_engine()) { // || !$config['sef']) {



    ## include lang file

    $lang = getLang("includes".CC_DS."boxes".CC_DS."shoppingCart.inc.php");

    $box_content = new XTemplate("boxes".CC_DS."shoppingCart.tpl");

    $box_content->assign("LANG_SHOPPING_CART_TITLE",$lang['shoppingCart']['shopping_cart']);

    

    require_once "classes".CC_DS."cart".CC_DS."shoppingCart.php";

    

    $cart   = new cart();

    $basket = ($_GET['_a'] != 'logout') ? $cart->cartContents($cc_session->ccUserData['basket']) : null;

    

    if (isset($_POST['add']) && $_POST['add']>0) {

        if (!isset($_POST['productOptions'])) {

            ## check product options are selected if they are required

            $prodOpts = $db->select("SELECT count(product) as noOpts FROM ".$glob['dbprefix']."CubeCart_options_bot WHERE product=".$db->mySQLSafe($_POST['add']));

            ## if they are required redirect to product view page

            if ($prodOpts[0]['noOpts'] > 0) {

                ## Problem relating to #807 here?

                if ($config['sef']) {

                    ## Generate a SEO URL

                    //$productUrl = sef_get_base_url().generateProductUrl($_POST['add']).'?notice=1';

                    $productUrl = generateProductUrl($_POST['add']).'?notice=1'; 

                } else {

                    $productUrl = 'index.php?_a=viewProd&productId='.$_POST['add'].'&notice=1';

                }

                ## Lose notice for product options

                httpredir(str_replace("&notice=1","",$_SERVER['HTTP_REFERER']).$addedStr);

                exit;

            }

        }

        

        ## add product to the cart

        $quantity   = (is_numeric($_POST['quan']) && $_POST['quan'] > 0) ? $_POST['quan'] : 1;

        ## Allow for integer AND float quantities

        $quantity   = (isset($prodType[0]['prodType']) && $prodType[0]['prodType'] == 2) ? $quantity : ceil($quantity);

        $basket     = (isset($_POST['productOptions'])) ? $basket = $cart->add($_POST['add'], $quantity, $_POST['productOptions']) : $cart->add($_POST['add'], $quantity, '');

        

        ## Go to cart or back to same page

        if ($config['add_to_basket_act'] == true) {

            ## Go to the cart

            if ($cc_session->ccUserData['customer_id']>0) {

                httpredir($config['rootRel']."index.php?_g=co&_a=step2");

            } else {

                httpredir($config['rootRel']."index.php?_g=co&_a=cart");

            }

        } else {

            $allowedVars = array('_a', 'category', 'catId', 'docId', 'page', 'priceMax', 'priceMin', 'prodId', 'productId', 'review', 'searchStr');

            

            ## Stay on same page but get rid of those pesky post variables

            parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY), $query);

            

            if (isset($query['searchStr'])) {

                ## Rehash this later - could benefit from the code used below

                if (is_array($query) && !empty($query)) {

                    foreach ($query as $key => $value) {

                        if (in_array($key, $allowedVars) && !empty($value)) {

                            #$append[$key] = $value;

                            if (is_array($value)) {

                                foreach ($value as $val) {

                                    $queryArray[] = sprintf('%s[]=%d', $key, $val);

                                }

                            } else {

                                $queryArray[] = sprintf('%s=%s', $key, urlencode($value));

                            }

                        }

                    }

                    ## Add flash basket

                    $queryArray[]   = "added=1";

                    $querystring    = '?'.implode('&', $queryArray);

                }

                httpredir($glob['storeURL'].'/index.php'.$querystring);

            } else {

                ## need to add added=1, as well as any allowed vars - PHP5 compatible

                if (!preg_match('#^'.$GLOBALS['storeURL'].'#', $_SERVER['HTTP_REFERER']) || empty($_SERVER['HTTP_REFERER'])) {

                    httpredir('index.php');

                } else {

                    $return_url     = parse_url($_SERVER['HTTP_REFERER']);

                    if (is_array($query)) {

                        foreach ($query as $key => $value) {

                            if (in_array($key, $allowedVars) && !empty($value)) {

                                $append[$key] = $value;

                            }

                        }

                    }

                    $append['added']    = 1;

                    $redirect_to = sprintf('%s/%s?%s', $GLOBALS['storeURL'], substr($return_url['path'], strlen($GLOBALS['rootRel'])), http_build_query($append));

                    httpredir($redirect_to);

                }

            }

        }

        

    } else if (isset($_POST['gc']['cert']) && $_POST['gc']['cert'] == true) {

        $gc = fetchDbConfig('gift_certs');

        

        if (empty($_POST['gc']['amount']) || empty($_POST['gc']['recipName']) || (empty($_POST['gc']['recipEmail']) && $_POST['gc']['delivery'] == 'e')) {

            ## Empty fields

            $errorGCMsg = 1;

        } else if ($_POST['gc']['delivery'] == 'e' && !validateEmail($_POST['gc']['recipEmail'])) {

            ## Invalid email address

            $errorGCMsg = 2;

            

        } else {

            if (!isset($gc['min']) || empty($gc['min']))    $gc['min'] = 1;

            if ($_POST['gc']['amount'] < $gc['min'])        $errorGCMsg = 3;

            

            if (isset($gc['max']) && !empty($gc['max']) && $_POST['gc']['amount'] > $gc['max']) $errorGCMsg = 3;

            

            if (!isset($errorGCMsg)) {

    

                $basket = $cart->addCert($_POST['gc']);

                ## Go to cart or back to same page

                if ($config['add_to_basket_act']) {

                    ## Go to the cart

                    httpredir(basename($_SERVER['PHP_SELF'])."?_g=co&_a=cart");

                } else {

                    // stay on same page but dump those mingy post vars

                    httpredir(basename($_SERVER['PHP_SELF'])."?_a=giftCert&added=1");

                }

            }

        }

    }

    $cartTotal = NULL;

    

    if (is_array($basket['conts']) && !empty($basket['conts'])) {

        foreach ($basket['conts'] as $key => $value) {

            if ($basket['conts'][$key]['custom'] == true) {

                $price = $basket['conts'][$key]['gcInfo']['amount'];

                $name =  $lang['shoppingCart']['gift_cert'];

            } else {

                $productId = $cart->getProductId($key);

                

                ## Get product details

                $product = $db->select("SELECT name, price, sale_price, productId FROM ".$glob['dbprefix']."CubeCart_inventory WHERE productId=".$db->mySQLSafe($productId));

                if (($val = prodAltLang($product[0]['productId'])) == true) {

                    $product[0]['name'] = $val['name'];

                }

                

                ## Build the product options

                

                $optionKeys = $cart->getOptions($key);

                

                $optionsCost = 0;

                

                if (!empty($optionKeys)) {                  

                    $options = explode('|', $optionKeys);

                    foreach ($options as $value) {

                        ## Split on separator

                        $value_data     = explode('@', $value);

                        $option_top     = $db->select(sprintf("SELECT T.* FROM %1\$sCubeCart_options_top AS T WHERE T.option_id = %2\$s", $glob['dbprefix'], $value_data[0]));

                        if ($option_top) {

                            $option_name    = $option_top[0]['option_name'];

                            if ($option_top[0]['option_type'] == 0) {

                                $option     = $db->select(sprintf("SELECT M.*, B.* FROM %1\$sCubeCart_options_mid AS M, %1\$sCubeCart_options_bot AS B WHERE M.value_id = B.value_id AND B.assign_id = %2\$d", $glob['dbprefix'], $value_data[1]));

                                if ($option) {

                                    $option_price   = $option[0]['option_price'];

                                    $option_symbol  = $option[0]['option_symbol'];

                                    $option_value   = $option[0]['value_name']; 

                                }

                            } else {

                                $option         = $db->select(sprintf("SELECT B.* FROM %1\$sCubeCart_options_bot AS B WHERE B.option_id = %2\$d AND B.product = %3\$d LIMIT 1", $glob['dbprefix'], $value_data[0], $productId));    

                                if ($option) {

                                    $option_price   = $option[0]['option_price'];

                                    $option_symbol  = $option[0]['option_symbol'];

                                    $option_value   = $value_data[1];

                                }

                            }

                        }

                        if ($option_price > 0) {

                            if ($option_symbol == "+") {

                                $optionsCost = $optionsCost + $option_price;

                            } else if ($option_symbol == "-") {

                                $optionsCost = $optionsCost - $option_price;

                            } else if ($option_symbol == "~") {

                                $optionsCost = 0;

                            }

                        }

                    }

                }

                $price  = (salePrice($product[0]['price'], $product[0]['sale_price']) == false) ? $price = $product[0]['price'] : salePrice($product[0]['price'], $product[0]['sale_price']);

                $price += $optionsCost;

                if ($price < 0) $price = 0;

                $name   = $product[0]['name'];

            }

            

            $box_content->assign("PRODUCT_PRICE", priceFormat($price, true));

            $box_content->assign("VAL_NO_PRODUCT", $cart->cartArray['conts'][$key]["quantity"]);

            $box_content->assign("PRODUCT_ID", $productId);

            

            ## Chop name if too long

            if (strlen($name) > 15) $name = substr($name,0,15)."..";

            

            $box_content->assign("VAL_PRODUCT_NAME", validHTML($name));

            $box_content->parse("shopping_cart.contents_true");

            $cartTotal = $cartTotal + ($price * $cart->cartArray['conts'][$key]["quantity"]);

        }

    } else {

        $box_content->assign("LANG_CART_EMPTY",$lang['shoppingCart']['basket_empty']);

        $box_content->parse("shopping_cart.contents_false");

    }

    

    $box_content->assign("VAL_CART_ITEMS", $cart->noItems());

    $box_content->assign("LANG_ITEMS_IN_CART", $lang['shoppingCart']['items_in_cart']);

    

    if (isset($cartTotal) && $cartTotal>0) {

        $box_content->assign("VAL_CART_TOTAL", priceFormat($cartTotal,true));

    } else {

        $box_content->assign("VAL_CART_TOTAL", priceFormat(0, TRUE));

    }

    

    $box_content->assign("LANG_TOTAL_CART_PRICE",$lang['shoppingCart']['total']);

    $box_content->assign("LANG_VIEW_CART",$lang['shoppingCart']['view_basket']);

    

    if ($cc_session->ccUserData['customer_id']>0) {

        $box_content->assign("CART_STEP", "step2");

    } else {

        $box_content->assign("CART_STEP", "cart");

    }

    

    if ($config['hide_prices'] && !$cc_session->ccUserData['customer_id'] && !$GLOBALS[CC_ADMIN_SESSION_NAME]) {

        // have a break, have a KitKat

    } else {

        $box_content->parse("shopping_cart.view_cart");

    }

    

    $box_content->parse("shopping_cart");

    $box_content = $box_content->text("shopping_cart");

} else {

    $box_content = null;

}

?>

The templates are defined at the top of each file as far as I can see. Looks a similar mechanism to the Smarty template engine.

$body = new XTemplate ("global".CC_DS."index.tpl");
$body = new XTemplate("global".CC_DS."cart.tpl");
$box_content = new XTemplate("boxes".CC_DS."shoppingCart.tpl");

 

Find out where the CC_DS constant is defined to get the full template path

The templates are defined at the top of each file as far as I can see. Looks a similar mechanism to the Smarty template engine.

$body = new XTemplate ("global".CC_DS."index.tpl");
$body = new XTemplate("global".CC_DS."cart.tpl");
$box_content = new XTemplate("boxes".CC_DS."shoppingCart.tpl");

 

Find out where the CC_DS constant is defined to get the full template path

 

Thanks.  I believe the CC_DS represents a "/" as each one of those files are located in a folder structure as:

 

global/index.tpl

global/cart.tpl

boxes/shoppingcart.tpl

 

But this still won't explain how one template gets loads vs. another (i.e. index.tpl vs. cart.tpl) the two global templates.

This is the index template being called (instantiated):

$body = new XTemplate ("global".CC_DS."index.tpl");

This is the cart template being called (instantiated):

$body = new XTemplate("global".CC_DS."cart.tpl");

 

This doesnt make sense:

But this still won't explain how one template gets loads vs. another (i.e. index.tpl vs. cart.tpl) the two global templates.

 

Every time you see $body->assign() or $variable->assign() this is data being passed into the template. There are just far too many includes in the php code to see what is going on. The data within these includes will more than likely change when URL params are used in each page call therefore changing the layout of the template.

 

Im not sure what you need help for? Are you redesigning the site?

If this is Cubecart then surely they must have a document structure definition of their site templates or a user forum.

Thanks Neil.

 

If I didn't make sense that understandable as I don't know PHP.  But you are correct, I would like to load a different global template when you view the details of an individual product.  As of now, the global/index.tpl file is what loads as sort of the site "container" with all content loading within it.  The only time it isn't the main "global" template is when you go to the shopping cart to check out, it loads the global template "cart.tpl". 

 

The second part of it all is, as of now, if you are looking at the products page, and you click the link to view the "details" of a individual product, it loads the template for an individual product within the index.tpl template.  What I would like to do is change it so that when you click the link it loads the the individual product details template into a 'different' global template.

 

This is the link to view a product's details:

<a href="index.php?_a=viewProd&productId={PRODUCT_ID}" target="_self">

 

 

If I didn't mention it: However you design the global template index.tpl to look, all your pages will look like this template, until you go to the "cart.tpl" which you then have freedom to make it look as much or different than the index.tpl template.  If I can figure out how to load the individual product template into a complete different global template, I would have the ability to change it completely.

This will be difficult for you if you dont know php.

Im guessing its the following param that defines what code is run and applied to the template:

_a=viewProd

 

So to change the product detail template you would be looking at something like

if($_GET['_a'] == 'viewProd') {
$body = new XTemplate ("global".CC_DS."product.tpl");
}
else {
// load the default template
}

 

There will probably be more in the code that you will have to modify.

So to change the product detail template you would be looking at something like

if($_GET['_a'] == 'viewProd') {
$body = new XTemplate ("global".CC_DS."product.tpl");
}
else {
// load the default template
}

 

Wow, thanks Neil, I have got more help here in just one day than the whole cubecart community.

I don't know PHP but I have done a bit of programming, so I can see the gif of what is going on, just don't know what all the functions are doing when they are called.

 

I am looking for someone that I can pay to help me figure out the calling of a new global template for two parts of the shopping cart (1) for when you click on the individual product and (2) for when you login.

 

I just need help in getting one called correctly and working any other grey areas such as how you mentioned there probably is other areas that have to be changed.  I can't imagine it would take long to figure out but I can provide all the necessary files.

 

Would you be up for providing me a small amount of your time to accomplish this for a fee?    I can't say for sure, but I imagine someone who knows their way around PHP could easily figure out all the 'additional' areas that would need changed just to call a different global template in a few hours.

 

Can you let me know?

I think I might figured it out.  However, not sure about a few things:

 

In the global/index.inc.php file I changed:

if(isset($_GET['_a'])) {
$body = new XTemplate ("global".CC_DS."index.tpl");
}
[code]

And changed it to:

[code]
if($_GET['_a'] == 'viewProd') {
$body = new XTemplate ("global".CC_DS."product.tpl");	
} else if(isset($_GET['_a'])) {
$body = new XTemplate ("global".CC_DS."index.tpl");
} else {
$body = new XTemplate ("global".CC_DS."home.tpl");
} 

 

This allowed me to have a individual different "homepage" than the rest of the site, and also loads the viewProd.tpl into the now global template "product.tpl".  So far so good.

 

HOWEVER!  I am researching some of the syntax as I believe this might not be "right" - it might work, but I need to look into the isset function and see if I need to check that on the first "IF" statement.

 

If you have any input on my change that could be a problem or how it could be better please tell me.

 

THanks again.[/code][/code]

This is incorrect

if($_GET['_a'] == 'viewProd') {
$body = new XTemplate ("global".CC_DS."product.tpl");	
} else if(isset($_GET['_a'])) {
$body = new XTemplate ("global".CC_DS."index.tpl");
} else {
$body = new XTemplate ("global".CC_DS."home.tpl");
} 

 

When $_GET['_a'] == 'viewProd' you are setting $body to a new instance of the index teplate using isset($_GET['_a']) because _a is set and set to 'viewProd'. You may need to add a new url param to set the index template like:

 

if($_GET['_a'] == 'viewProd') {
$body = new XTemplate ("global".CC_DS."product.tpl");	
} else if($_GET['_a'] == 'index') {
$body = new XTemplate ("global".CC_DS."index.tpl");
} else {
$body = new XTemplate ("global".CC_DS."home.tpl");
} 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.