Results 1 to 4 of 4
  1. #1

    help question Is there an override for filenames.php?

    I know about adding additional defines to filenames in /includes/extra_datafiles/ but what if I need to override a define already existing in /includes/filenames.php? Can I do so without editing the file directly (to keep core file intact)?

    I tried reiterating the same define('CONSTANT',''); line in the newly added /extra_datafiles/*_filenames.php file, but the constant still contains the definition from /includes/filenames.php instead of the one from /extra_datafiles/.

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

    Default Re: Is there an override for filenames.php?

    Quote Originally Posted by RobertH View Post
    I know about adding additional defines to filenames in /includes/extra_datafiles/ but what if I need to override a define already existing in /includes/filenames.php? Can I do so without editing the file directly (to keep core file intact)?

    I tried reiterating the same define('CONSTANT',''); line in the newly added /extra_datafiles/*_filenames.php file, but the constant still contains the definition from /includes/filenames.php instead of the one from /extra_datafiles/.
    If you need to override a definition in /includes/filenames.php, the best way is to get that definition placed before that file is loaded.

    Place your customization in /includes/extra_configures/filenames_override.php (or a name of your choosing).

  3. #3

    Default Re: Is there an override for filenames.php?

    Quote Originally Posted by lat9 View Post
    If you need to override a definition in /includes/filenames.php, the best way is to get that definition placed before that file is loaded.

    Place your customization in /includes/extra_configures/filenames_override.php (or a name of your choosing).
    Ah okay, that makes sense. That works fine!

    What about overrides to files in /includes/functions/ or /includes/classes/? I found this thread from 2009 where a user advises to create an override in /init_includes/, but is there a built-in method for doing this now? Or what would be the suggested procedure for overrides on those files that don't have custom_template override systems?

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

    Default Re: Is there an override for filenames.php?

    Quote Originally Posted by RobertH View Post
    Ah okay, that makes sense. That works fine!

    What about overrides to files in /includes/functions/ or /includes/classes/? I found this thread from 2009 where a user advises to create an override in /init_includes/, but is there a built-in method for doing this now? Or what would be the suggested procedure for overrides on those files that don't have custom_template override systems?
    Using the /includes/auto_loaders/overrides and /includes/init_includes/overrides sub-directories work, but their use (IMO) can cause issues when you're upgrading. I used those methods in the past and then, when upgrading, forgot that they were there ... and wound up spending much more time trying to figure out what the heck was going on.

    My advice, make your customized changes directly to the core files in /includes/functions and /includes/init_includes and heavily comment the changes. I've adopted the methods used by the legendary Conor Kerr (now deceased) as illustrated below.

    Let's pretend that you want to modify the function zen_get_buy_now_button (present in /includes/functions_general.php) to add a specific class to the output when the associated product is "call_for_price".

    The original code fragment in that function reads:
    Code:
        case ($button_check->fields['product_is_call'] == '1'):
          $return_button = '<a href="' . zen_href_link(FILENAME_CONTACT_US, '', 'SSL') . '">' . TEXT_CALL_FOR_PRICE . '</a>';
          break;
    I'd make the update as follows:
    Code:
        case ($button_check->fields['product_is_call'] == '1'):
    
    //-bof-20180227-lat9-Add class to enable link's styling
    //      $return_button = '<a href="' . zen_href_link(FILENAME_CONTACT_US, '', 'SSL') . '">' . TEXT_CALL_FOR_PRICE . '</a>';
          $return_button = '<a href="' . zen_href_link(FILENAME_CONTACT_US, '', 'SSL') . '" class="buynow-call-for-price">' . TEXT_CALL_FOR_PRICE . '</a>';
    //-eof-20180227-lat9
    
          break;
    The change is surrounded by //-bof and //-eof comments, with a blank line before the //-bof and after the //-eof (it "helps" your file-comparison program properly locate the changes). Keeping the original code also helps on an upgrade, so you can see what was changed!

 

 

Similar Threads

  1. Is there a way to override the pages header.php file...
    By retched in forum Contribution-Writing Guidelines
    Replies: 3
    Last Post: 10 Jun 2011, 08:14 PM
  2. is there an override folder for the admin pages too?
    By photoseller in forum General Questions
    Replies: 1
    Last Post: 2 Jul 2010, 07:59 AM
  3. is there an override to includes/filenames.php?
    By R1ckster in forum Templates, Stylesheets, Page Layout
    Replies: 10
    Last Post: 20 Sep 2007, 10:51 AM

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