Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2009
    Location
    Aransas Pass, TX
    Posts
    101
    Plugin Contributions
    1

    Default require () the Zen way

    I would like some help to 'zen' this line of code. I think it is my last 'unzenned' code line.
    Code:
     require (DIR_WS_LANGUAGES . "english/YOUR_TEMPLATE/" . $_GET['main_page'] . ".php");
    If you don't already understand what I am asking, it is unlikely you can help, but here goes anyway.

    Somewhere there must be a variable or function to give me "english/YOUR_TEMPLATE".

    Thanks!

  2. #2
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: require () the Zen way

    I understand what you are trying to do, but I suspect there may be an easier way. Van you explain in a little more detail which page(s) you are loading, and what info you want to show/load?

  3. #3
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: require () the Zen way

    The language, well is in the language session variable. The current template directory is in the template dir. :)

    $_SESSION['language']
    $template_dir
    Are the two variables with the text desired. They need to be concatenated with the appropriate separator. Also, whatever it is you are looking for should likely be checked to see that it exists before actually requiring it. Unfortunately that now-a-days typically refers to attempting to first get the language with the template override, followed by the language without the template override. I would think that next the base language with template override should be attempted and if non-existent the base language's base file. Something that perhaps I just relearned or maybe it had changed, is that generally with language files on the store front that there does not appear to be a cascade of language file loading. I thought for some reason that if it was desired to override one language define, that it could be put into the override filename by itself and that all of the other defines would be loaded by the base file, but it's a one or other load, not both in sequence of the override first.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,489
    Plugin Contributions
    88

    Default Re: require () the Zen way

    Note that if you're creating a new main_page, then placing the line
    Code:
    require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
    in your page's /includes/modules/pages/new_page/header_php.php file will cause the page's associated language file (new_page.php) to be loaded from the current template directory ($template_dir, as @mc12345678 indicated) or, if not present there, from the base directory of the current language (e.g. /includes/languages/english).

  5. #5
    Join Date
    Nov 2009
    Location
    Aransas Pass, TX
    Posts
    101
    Plugin Contributions
    1

    Default Re: require () the Zen way

    As it turns out '$template_dir' is not established yet. I found the query.
    Code:
      $template_dir = "";
      $sql = "select template_dir
      from " . TABLE_TEMPLATE_SELECT . "
      where template_language = 0";
      $template_query = $db->Execute($sql);
      $template_dir = $template_query->fields['template_dir'];
    Which gives me;
    Code:
        require (DIR_WS_LANGUAGES . $_SESSION['language'] . "/" . $template_dir . "/" . $_GET['main_page'] . ".php");
    This is my 'hook' in 'init_sanitize.php' so some variables are not yet initialized.
    This all happens before the 'header_php.php'.

    Thanks.

 

 

Similar Threads

  1. Replies: 8
    Last Post: 1 Apr 2018, 08:00 PM
  2. Is there a way to require login or differentiate pricing?
    By saltsandsuch in forum General Questions
    Replies: 1
    Last Post: 15 May 2013, 11:48 AM
  3. Replies: 1
    Last Post: 23 Jan 2011, 10:42 PM
  4. Is there a way to require a purchase?
    By jaxbakers in forum Managing Customers and Orders
    Replies: 1
    Last Post: 22 Jul 2006, 01:00 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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR