osCmax v2.5 User Manual
Results 1 to 6 of 6

help with referencing classes

This is a discussion on help with referencing classes within the osCMax v2 Features Discussion forums, part of the osCmax v2.0 Forums category; I read through the bts tutorials but I am still in wonder of how a class connects to a tpl ...

      
  1. #1
    Senior Member blackhawk's Avatar
    Join Date
    Aug 2009
    Location
    indiana
    Posts
    640
    Blog Entries
    1
    Rep Power
    27


    Default help with referencing classes

    I read through the bts tutorials but I am still in wonder of how a class connects to a tpl file. for my tracking contribution, I have a class in includes/class/tracking_module.php that is being called from account_history_info.php (file located in the catalog directory). So when I place...

    [code]
    require(DIR_WS_CLASSES . '/' . FILENAME_TRACKING_MODULE);
    require (DIR_WS_LANGUAGES . $language . '/' . FILENAME_TRACKING_MODULE);
    require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_HISTORY_INFO);
    $tracking = new tracking_module();

    [/code

    in account_history_info.php, should it be ok to put ...

    Code:
    <?php  echo $tracking->insert_courier_ajax_js(); ?>
    within the head tag of main_page.tpl.php?

    I keep getting an error when my site loads that says....

    Code:
    Fatal error:  Call to a member function insert_courier_ajax_js() on a non-object in C:xamppsitecatalogmain_page.tpl.php on line 116
    any advice?

    thanks

  2. #2
    osCMax Development Team
    Join Date
    Nov 2002
    Location
    Orlando
    Posts
    433
    Rep Power
    14


    Default Re: help with referencing classes

    I don't have this installed but looking at it in "Beyond Compare" I think your account_history_info.php should look like this. You don't need to put anything in main_page

    PHP Code:
    <?php
    /*
    $Id: account_history_info.php 3 2006-05-27 04:59:07Z user $

      osCMax Power E-Commerce
      http://oscdox.com

      Copyright 2006 osCMax

      Released under the GNU General Public License
    */

    // Most of this file is changed or moved to BTS - Basic Template System - format.
    // For adding in contribution or modification - parts of this file has been moved to: catalogtemplatesfallbackcontents<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).
    //       catalogtemplatesfallbackcontents<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).
    // (Sub 'fallback' with your current template to see if there is a template specific file.)

      
    require('includes/application_top.php');
      require(
    DIR_WS_CLASSES '/' FILENAME_TRACKING_MODULE);
      include(
    DIR_WS_LANGUAGES $language '/' FILENAME_TRACKING_MODULE);
      
    $tracking = new tracking_module();

      if (!
    tep_session_is_registered('customer_id')) {
        
    $navigation->set_snapshot();
        
    tep_redirect(tep_href_link(FILENAME_LOGIN'''SSL'));
      }

      if (!isset(
    $HTTP_GET_VARS['order_id']) || (isset($HTTP_GET_VARS['order_id']) && !is_numeric($HTTP_GET_VARS['order_id']))) {
        
    tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY'''SSL'));
      }
      
      
    $customer_info_query tep_db_query("select customers_id from " TABLE_ORDERS " where orders_id = '". (int)$HTTP_GET_VARS['order_id'] . "'");
      
    $customer_info tep_db_fetch_array($customer_info_query);
      if (
    $customer_info['customers_id'] != $customer_id) {
        
    tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY'''SSL'));
      }

      require(
    DIR_WS_LANGUAGES $language '/' FILENAME_ACCOUNT_HISTORY_INFO);

      
    $breadcrumb->add(NAVBAR_TITLE_1tep_href_link(FILENAME_ACCOUNT'''SSL'));
      
    $breadcrumb->add(NAVBAR_TITLE_2tep_href_link(FILENAME_ACCOUNT_HISTORY'''SSL'));
      
    $breadcrumb->add(sprintf(NAVBAR_TITLE_3$HTTP_GET_VARS['order_id']), tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO'order_id=' $HTTP_GET_VARS['order_id'], 'SSL'));

      require(
    DIR_WS_CLASSES 'order.php');
      
    $order = new order($HTTP_GET_VARS['order_id']);

      
    $content CONTENT_ACCOUNT_HISTORY_INFO;

      include (
    bts_select('main'$content_template)); // BTSv1.5

      
    require(DIR_WS_INCLUDES 'application_bottom.php');
    ?>
    Then your account_history_info.tpl.php should look roughly like this

    PHP Code:
        <table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
              <tr>
                <td class="pageHeading" align="center"><?php echo HEADING_TITLE?></td>
                <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES 'table_background_history.gif'HEADING_TITLEHEADING_IMAGE_WIDTHHEADING_IMAGE_HEIGHT); ?></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td><?php echo tep_draw_separator('pixel_trans.gif''100%''10'); ?></td>
          </tr>
          <tr>
            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td class="main" colspan="2"><b><?php echo sprintf(HEADING_ORDER_NUMBER$HTTP_GET_VARS['order_id']) . ' <small>(' $order->info['orders_status'] . ')</small>'?></b></td>
              </tr>
              <tr>
                <td class="smallText"><?php echo HEADING_ORDER_DATE ' ' tep_date_long($order->info['date_purchased']); ?></td>
                <td class="smallText" align="right"><?php echo HEADING_ORDER_TOTAL ' ' $order->info['total']; ?></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
              <tr class="infoBoxContents">
    <?php
      
    if ($order->delivery != false) {
    ?>
                <td width="30%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="main"><b><?php echo HEADING_DELIVERY_ADDRESS?></b></td>
                  </tr>
                  <tr>
                    <td class="main"><?php echo tep_address_format($order->delivery['format_id'], $order->delivery1' ''<br>'); ?></td>
                  </tr>
    <?php
        
    if (tep_not_null($order->info['shipping_method'])) {
    ?>
                  <tr>
                    <td class="main"><b><?php echo HEADING_SHIPPING_METHOD?></b></td>
                  </tr>
                  <tr>
                    <td class="main"><?php echo $order->info['shipping_method']; ?></td>
                  </tr>
    <?php
        
    }
    ?>
                </table></td>
    <?php
      
    }
    ?>
                <td width="<?php echo (($order->delivery != false) ? '70%' '100%'); ?>" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
                  <tr>
                    <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
    <?php
      
    if (sizeof($order->info['tax_groups']) > 1) {
    ?>
                      <tr>
                        <td class="main" colspan="2"><b><?php echo HEADING_PRODUCTS?></b></td>
                        <td class="smallText" align="right"><b><?php echo HEADING_TAX?></b></td>
                        <td class="smallText" align="right"><b><?php echo HEADING_TOTAL?></b></td>
                      </tr>
    <?php
      
    } else {
    ?>
                      <tr>
                        <td class="main" colspan="3"><b><?php echo HEADING_PRODUCTS?></b></td>
                      </tr>
    <?php
      
    }

      for (
    $i=0$n=sizeof($order->products); $i<$n$i++) {
        echo 
    '          <tr>' "n" .
             
    '            <td class="main" align="right" valign="top" width="30">' $order->products[$i]['qty'] . '&nbsp;x</td>' "n" .
             
    '            <td class="main" valign="top">' $order->products[$i]['name'];

        if ( (isset(
    $order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
          for (
    $j=0$n2=sizeof($order->products[$i]['attributes']); $j<$n2$j++) {
            echo 
    '<br><nobr><small>&nbsp;<i> - ' $order->products[$i]['attributes'][$j]['option'] . ': ' $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';
          }
        }

        echo 
    '</td>' "n";

        if (
    sizeof($order->info['tax_groups']) > 1) {
          echo 
    '            <td class="main" valign="top" align="right">' tep_display_tax_value($order->products[$i]['tax']) . '%</td>' "n";
        }

        echo 
    '            <td class="main" align="right" valign="top">' $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true$order->info['currency'], $order->info['currency_value']) . '</td>' "n" .
             
    '          </tr>' "n";
      }
    ?>
                    </table></td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td><?php echo tep_draw_separator('pixel_trans.gif''100%''10'); ?></td>
          </tr>
          <tr>
            <td class="main"><b><?php echo HEADING_BILLING_INFORMATION?></b></td>
          </tr>
          <tr>
            <td><?php echo tep_draw_separator('pixel_trans.gif''100%''10'); ?></td>
          </tr>
          <tr>
            <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
              <tr class="infoBoxContents">
                <td width="30%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="main"><b><?php echo HEADING_BILLING_ADDRESS?></b></td>
                  </tr>
                  <tr>
                    <td class="main"><?php echo tep_address_format($order->billing['format_id'], $order->billing1' ''<br>'); ?></td>
                  </tr>
                  <tr>
                    <td class="main"><b><?php echo HEADING_PAYMENT_METHOD?></b></td>
                  </tr>
                  <tr>
                    <td class="main"><?php echo $order->info['payment_method']; ?></td>
                  </tr>
                </table></td>
                <td width="70%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
    <?php
      
    for ($i=0$n=sizeof($order->totals); $i<$n$i++) {
        echo 
    '              <tr>' "n" .
             
    '                <td class="main" align="right" width="100%">' $order->totals[$i]['title'] . '</td>' "n" .
             
    '                <td class="main" align="right">' $order->totals[$i]['text'] . '</td>' "n" .
             
    '              </tr>' "n";
      }
    ?>
                </table></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td><?php echo tep_draw_separator('pixel_trans.gif''100%''10'); ?></td>
          </tr>
          <tr>
            <td class="main"><b><?php echo HEADING_ORDER_HISTORY?></b></td>
          </tr>
          <tr>
            <td><?php echo tep_draw_separator('pixel_trans.gif''100%''10'); ?></td>
          </tr>
          <tr>
            <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
              <tr class="infoBoxContents">
                <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
    <?php
      $statuses_query 
    tep_db_query("select os.orders_status_name, osh.date_added, osh.comments, osh.tracking_id from " TABLE_ORDERS_STATUS " os, " TABLE_ORDERS_STATUS_HISTORY " osh where osh.orders_id = '" . (int)$HTTP_GET_VARS['order_id'] . "' and osh.orders_status_id = os.orders_status_id and os.language_id = '" . (int)$languages_id "' order by osh.date_added");
      while (
    $statuses tep_db_fetch_array($statuses_query)) {
        echo 
    '              <tr>' "n" .
             
    '                <td class="main" valign="top" width="70">' tep_date_short($statuses['date_added']) . '</td>' "n" .
             
    '                <td class="main" valign="top" width="70">' $statuses['orders_status_name'] . '</td>' "n" .
             
    '                <td class="main" valign="top">' . (empty($statuses['comments']) ? '&nbsp;' nl2br(tep_output_string_protected($statuses['comments']))) . '</td>' "n" .
                 
    '                <td class="main" align="center" valign="top">' $tracking->display_tracking_link($statuses['tracking_id'], TRACKING_LINK_LABEL) . '</td>' "n" .
             
    '              </tr>' "n";
      }
    ?>
                </table></td>
              </tr>
            </table></td>
          </tr>
              <tr><td>
              <div id="text_box" class="smallText" style="margin: 10px 0 5px 0;">
              <!-- tracking_module noscript -->
              <?php $tracking->display_no_js(); ?>
              <!-- end tracking_module noscript -->
              </div>
              </td></tr>
    <?php
      
    if (DOWNLOAD_ENABLED == 'true') include(DIR_WS_MODULES 'downloads.php');
    ?>
          <tr>
            <td><?php echo tep_draw_separator('pixel_trans.gif''100%''10'); ?></td>
          </tr>
          <tr>
            <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
              <tr class="infoBoxContents">
                <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif''10''1'); ?></td>
                    <td><?php echo '<a href="' tep_href_link(FILENAME_ACCOUNT_HISTORYtep_get_all_get_params(array('order_id')), 'SSL') . '">' tep_image_button('button_back.gif'IMAGE_BUTTON_BACK) . '</a>'?></td>
    <?php                      
    // fedex tracking
        
    $order_id $HTTP_GET_VARS['order_id'];
    //    $trackLink = tep_track_fedex($order_id);
    ?>                                
                                    <td class="main" align="right">
    <?php
        
    if ($trackLink) {
            echo 
    '<a href="' $trackLink '"><b>track this shipment</b></a>';
            }
        else {
            echo 
    tep_draw_separator('pixel_trans.gif''10''1');
            }
    ?>
                                    </td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
          </tr>
        </table>
    John

  3. #3
    Senior Member blackhawk's Avatar
    Join Date
    Aug 2009
    Location
    indiana
    Posts
    640
    Blog Entries
    1
    Rep Power
    27


    Default Re: help with referencing classes

    Thank you so much John. The original code was not in BTS format and had that tracker->ajax code inside of a <head> tag of an html section. so I just figured it would work the same way with BTS. I'll try your suggestion and get back with you but I have a feeling I'm still gonna need that little piece of code somewhere...

    bh

  4. #4
    osCMax Development Team
    Join Date
    Nov 2002
    Location
    Orlando
    Posts
    433
    Rep Power
    14


    Default Re: help with referencing classes

    Sorry, I had missed that line but you can still do this without having to put it into main_page and the reason not to put it in main_page is it's getting called for every page when it's only needed for one page. I've been doing a great deal of testing using Yslow and Google Page Speed and I've dramatically increased my speed ratings on my test site although I've only moved some of my changes over and a lot of it just makes sense. Like all the slimbox code is only called for product info which is the only page that uses it.

    Keep in mind that the instructions are planning on your head tag info only having what he has listed and some things will interfere.

    So, basically you can copy the way advanced_search is done like this. Right under the content variable call add the $javascript and you could make a css file for the extra css and link right about this line or read further down to another way.
    PHP Code:
      $content CONTENT_ACCOUNT_HISTORY_INFO;
      
    $javascript $content '.js.php'
    Then you can create a file account_history_info.js.php in includes/javascript and put the code in there like this.
    PHP Code:
    <?php echo $tracking->insert_courier_ajax_js(); ?>
    In my main_page I have this right about my </head> tag and I've been moving code out that only works on one page like product_info.php out of the main page
    PHP Code:
    <?php if (isset($javascript) && file_exists(DIR_WS_JAVASCRIPT basename($javascript))) { require(DIR_WS_JAVASCRIPT basename($javascript)); } ?>
    I've discovered that css links can be put in with the javascript filles above the script but even better is to make a stylesheets folder in you template dir and then make specific stylesheets like product_info.css but you have to have this in your main_page for that to work
    PHP Code:
    <?php if (bts_select('stylesheets'$PHP_SELF)) { // if a specific stylesheet exists for this page it will be loaded ?>
    <link rel="stylesheet" type="text/css" href="<?php echo (bts_select('stylesheets'$PHP_SELF)); // BTSv1.5 ?>">
    <?php ?>
    Let me know how it ends up working out.
    John

  5. #5
    osCMax Development Team
    pgmarshall's Avatar
    Join Date
    Feb 2009
    Location
    London
    Posts
    2,678
    Rep Power
    49


    Smile Re: help with referencing classes

    Sorry to hijack this thread ... but JohnW - have you enabled the GZip within osCmax?

    I am doing a similar process as you by trying to optimise my site to run quicker - however, I have enabled the GZip functionality within the admin panel but Google Page Speed and YSlow are still telling me that I should GZip the code ... not sure what else I need to do ...

    Any pointers?

    Or do you think it is merely that my host does not provide GZip? (I would have thought that they would though!)

    Thanks,
    pgmarshall
    _______________________________

  6. #6
    osCMax Development Team
    Join Date
    Nov 2002
    Location
    Orlando
    Posts
    433
    Rep Power
    14


    Default Re: help with referencing classes

    Hey PG,

    I guess we could always start a thread on this subject as it should be important to everyone and there is a big improvement be had, but I'm pretty sure Blackhawk will find this useful.

    The key to gzip is mod_deflate on Apache as Pagespeed discusses and not any other setting anywhere else that I tried worked. It's a big difference so time well spent but I think you might be able to gzip a file and have that work but I haven't tried it. Try it with a long css or javascript file and let me know.

    Google's page speed builds on the info Yslow provides and I have more to work on but I had my Yslow rating up to 99 on my test site.

    Have you ever changed your error level in application_top to
    error_reporting(E_ALL & E_NOTICE); where the ~ is removed from E_NOTICE?
    John

Similar Threads

  1. infoboxes and inlcudes/classes/boxes.php
    By adiwillow in forum osCmax v2 Customization/Mods
    Replies: 2
    Last Post: 07-07-2007, 02:17 AM
  2. Adding New Classes
    By JaaMor in forum osCommerce 2.2 Modification Help
    Replies: 1
    Last Post: 11-13-2003, 08:26 AM
  3. Tax classes
    By messias in forum osCommerce 2.2 Modification Help
    Replies: 3
    Last Post: 02-06-2003, 11:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •