Full service web hosting, great prices and support. Starts at $1.99/month!
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Template Determination

  1. #1
    New Member
    Join Date
    Mar 2012
    Posts
    28
    Contribute If you enjoy reading the
    content here, click the below
    image to support our site.
    Click Here To Contribute To Our Site

    Total Contributions For

    fang27     $ 0.00
    Rep Power
    0


    Default Template Determination

    Does anyone know where the template is pulled from the database? Meaning, which script calls up which template that has been set in the Admin?

    (Meaning, which file is DIR_WS_TEMPLATES defined? Where is the info pulled from the database and the constant set?)
    Last edited by fang27; 09-18-2014 at 01:34 PM.

  2. #2
    osCMax Development Team

    Template Determination

    ridexbuilder's Avatar
    Join Date
    Jul 2008
    Location
    Haggisland
    Posts
    4,164
    Contribute If you enjoy reading the
    content here, click the below
    image to support our site.
    Click Here To Contribute To Our Site

    Total Contributions For

    ridexbuilder     $ 15.00
    Rep Power
    99


    Default Re: Template Determination

    This isn't relevant if making your own template.
    http://wiki.oscdox.com/v2.5/bts_docs - though we have added a few new features, to assist with further customisation, see:
    https://code.google.com/p/oscmax2/source/list

    Developers resource at bitbucket
    *** *** ***
    oscmax.co.uk / ejsolutions.co.uk
    Hosting plans with installation, configuration, contributions, support and maintenance.
    *** FREE osCmax hosting available ***
    oscmaxtemplates.com

  3. #3
    New Member
    Join Date
    Mar 2012
    Posts
    28
    Contribute If you enjoy reading the
    content here, click the below
    image to support our site.
    Click Here To Contribute To Our Site

    Total Contributions For

    fang27     $ 0.00
    Rep Power
    0


    Cool Re: Template Determination

    Quote Originally Posted by ridexbuilder View Post
    This isn't relevant if making your own template.
    http://wiki.oscdox.com/v2.5/bts_docs - though we have added a few new features, to assist with further customisation, see:
    https://code.google.com/p/oscmax2/source/list
    Didn't claim it was. Or what I was doing. I've created themes before.

    This circumstance is different, so I will explain: I want users to be forced to a mobile website if they meet the criteria (i.e. their device matches a mobile device).

    Since I wrote this, I found that it is in the function bts_template_switch() in the includes/configure_bts.php file where I could add code to test for a mobile device and serve up a different theme based on that.

    If this is the proper (or only) place to do this, great. If it isn't, let me know!

  4. #4
    osCMax Development Team

    Template Determination

    ridexbuilder's Avatar
    Join Date
    Jul 2008
    Location
    Haggisland
    Posts
    4,164
    Contribute If you enjoy reading the
    content here, click the below
    image to support our site.
    Click Here To Contribute To Our Site

    Total Contributions For

    ridexbuilder     $ 15.00
    Rep Power
    99


    Post Re: Template Determination

    You can't expect a relevant response if not given the full story.
    Your methodology appears to be similar to that of the iOS contribution and is the initial route that I went down a good few months ago, whereby the user agent determines the 'profile' used. This is contrary to the bootstrap method that goes on the premise of mobile first and template determination by screen resolution i.e. dynamic sizing.
    During my initial testing, I became concerned about the duplication of code and the ongoing maintenance of have distinct mobile pages. The bootstrap methodology helps to contain this with common code, at the expense of styling (CSS) complexity.
    Last edited by ridexbuilder; 09-19-2014 at 06:36 AM.

    Developers resource at bitbucket
    *** *** ***
    oscmax.co.uk / ejsolutions.co.uk
    Hosting plans with installation, configuration, contributions, support and maintenance.
    *** FREE osCmax hosting available ***
    oscmaxtemplates.com

  5. #5
    New Member
    Join Date
    Mar 2012
    Posts
    28
    Contribute If you enjoy reading the
    content here, click the below
    image to support our site.
    Click Here To Contribute To Our Site

    Total Contributions For

    fang27     $ 0.00
    Rep Power
    0


    Wink Re: Template Determination

    Quote Originally Posted by ridexbuilder View Post
    You can't expect a relevant response if not given the full story.
    Your methodology appears to be similar to that of the iOS contribution and is the initial route that I went down a good few months ago, whereby the user agent determines the 'profile' used. This is contrary to the bootstrap method that goes on the premise of mobile first and template determination by screen resolution i.e. dynamic sizing.
    During my initial testing, I became concerned about the duplication of code and the ongoing maintenance of have distinct mobile pages. The bootstrap methodology helps to contain this with common code, at the expense of styling (CSS) complexity.

    Yeah, responsive vs. adaptive web design. I choose adaptive.

    As for relevant response: it would have been to simply answer the question.

  6. #6
    wkdwich
    Guest


    Default Re: Template Determination

    fang have you made any progress on this project?

  7. #7
    New Member
    Join Date
    Mar 2012
    Posts
    28
    Contribute If you enjoy reading the
    content here, click the below
    image to support our site.
    Click Here To Contribute To Our Site

    Total Contributions For

    fang27     $ 0.00
    Rep Power
    0


    1 out of 1 members found this post helpful.

    Default Re: Template Determination

    Quote Originally Posted by wkdwich View Post
    fang have you made any progress on this project?
    I did indeed: sorry for not posting back sooner!

    The place where the template is determined is in the file configure_bts.php - near the bottom is "function bts_template_switch()" - within that you need to change the code to detect a mobile environment. I use the Mobile Detect script from Github.

    Upload the Mobile_Detect.php file to the catalog/includes directory (or where-ever you want to put it) and change this code:


    PHP Code:
    function bts_template_switch() {
      if ((
    TEMPLATE_SWITCHING_ALLOWED == 'true') && (isset($_GET['tplDir'])) && is_dir(DIR_WS_TEMPLATES_BASE basename($_GET['tplDir'])) ) {
        
    $tplDir basename($_GET['tplDir']);
        
    tep_session_register('tplDir');
      } else {
        if ((
    tep_session_is_registered('tplDir')) && (TEMPLATE_SWITCHING_ALLOWED == 'true') && is_dir(DIR_WS_TEMPLATES_BASE basename($_SESSION['tplDir']))){
          
    $tplDir basename($_SESSION['tplDir']);
        }else{
          
    $tplDir DIR_WS_TEMPLATES_DEFAULT;
        }
      }

      if ((
    preg_match('{^[[:alnum:]|_|-]+$}'$tplDir)) && (is_dir (DIR_WS_TEMPLATES_BASE $tplDir))){
        
    // 'Input Validated' only allow alfanumeric characters and underscores in template name
        
    define('DIR_WS_TEMPLATES'DIR_WS_TEMPLATES_BASE $tplDir '/' );
      } else {
        if (
    $bts_debug === TRUE) { $illegal_directory '<b>' strip_tags($tplDir) . '</b> '; }
        exit(
    '<table width="100%" style="font-family: Verdana, Arial, sans-serif; font-size: 11px; line-height:1.5; background-color: #ffe6e6; border:solid 1px #ff8e90; padding:5px;"><tr><td align="center">Your template directory ' $illegal_directory 'can not be found.  Please login to your admin panel and go to the <b>Default Template Directory</b> under <b>Templates</b> in the <b>Configuration</b> menu.</td></tr></table>');
      }
      
      return 
    $tplDir;

    to this:

    PHP Code:
    function bts_template_switch() {
      if ((
    TEMPLATE_SWITCHING_ALLOWED == 'true') && (isset($_GET['tplDir'])) && is_dir(DIR_WS_TEMPLATES_BASE basename($_GET['tplDir'])) ) {
        
    $tplDir basename($_GET['tplDir']);
        
    tep_session_register('tplDir');
      } else {
        if ((
    tep_session_is_registered('tplDir')) && (TEMPLATE_SWITCHING_ALLOWED == 'true') && is_dir(DIR_WS_TEMPLATES_BASE basename($_SESSION['tplDir']))){
          
    $tplDir basename($_SESSION['tplDir']);
        }else{
          
    $tplDir DIR_WS_TEMPLATES_DEFAULT;
          
        
    //Newest detection script  2013-08-30
            
    require '<<<directory path to>>>Mobile_Detect.php';
            
    $detect = new Mobile_Detect;
        
    //Check for mobile environment.
             
    if ($detect->isMobile()) {
                
    $tplDir "mobile-template-directory-name";
            } 
        
        }
      }

      if ((
    preg_match('{^[[:alnum:]|_|-]+$}'$tplDir)) && (is_dir (DIR_WS_TEMPLATES_BASE $tplDir))){
        
    // 'Input Validated' only allow alfanumeric characters and underscores in template name
        
    define('DIR_WS_TEMPLATES'DIR_WS_TEMPLATES_BASE $tplDir '/' );
      } else {
        if (
    $bts_debug === TRUE) { $illegal_directory '<b>' strip_tags($tplDir) . '</b> '; }
        exit(
    '<table width="100%" style="font-family: Verdana, Arial, sans-serif; font-size: 11px; line-height:1.5; background-color: #ffe6e6; border:solid 1px #ff8e90; padding:5px;"><tr><td align="center">Your template directory ' $illegal_directory 'can not be found.  Please login to your admin panel and go to the <b>Default Template Directory</b> under <b>Templates</b> in the <b>Configuration</b> menu.</td></tr></table>');
      }
      
      return 
    $tplDir;


    This all on Oscmax 2.54

    I am sure there is smoother way of coding that, but I was in a hurry and haven't had time to go back to it.

    I am considering, eventually, releasing my mobile theme that I created.

  8. #8
    osCMax Development Team

    Template Determination

    pgmarshall's Avatar
    Join Date
    Feb 2009
    Location
    London
    Posts
    3,517
    Contribute If you enjoy reading the
    content here, click the below
    image to support our site.
    Click Here To Contribute To Our Site

    Total Contributions For

    pgmarshall     $ 35.00
    Rep Power
    80


    Default Re: Template Determination

    I have used a similar approach to build a multi-site store using customer groups - ie. Customer group 1 = URL1, Customer group 2 = URL2
    pgmarshall
    _______________________________

  9. #9
    wkdwich
    Guest


    Default Re: Template Determination

    Hey Fang, I'd love to test your template on my 2.0.35 installs to see if it will work there.. I'm going to look into what you posted up there and see if I can get it that far and switch to say fallback..

    Oh.. does this put in the veiwport meta tag and the other things that google is now insisting every site has?
    Last edited by wkdwich; 03-19-2015 at 07:56 PM.

  10. #10
    wkdwich
    Guest

Page 1 of 2 12 LastLast

Similar Threads

  1. BTS Template Tutorial, Examples, converting osC template to BTS
    By michael_s in forum osCMax v2 Features Discussion
    Replies: 25
    Last Post: 10-31-2012, 08:24 AM
  2. please help for my template
    By celeroncillo in forum Templating, CSS, Design
    Replies: 11
    Last Post: 01-09-2012, 01:26 PM
  3. bts template system with html template
    By silverping in forum osCmax v2 Customization/Mods
    Replies: 1
    Last Post: 10-08-2009, 09:12 AM
  4. new web 2.0 template
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 04-10-2009, 09:00 AM
  5. TEMPLATE INSTALL ISSUE --> Illegal Template Directory
    By ashelleydesign in forum osCmax v2 Installation issues
    Replies: 4
    Last Post: 02-02-2007, 06:59 AM

Bookmarks

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
  •