Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,267
    Plugin Contributions
    3

    Default Re: Merging PHP Files

    Different modules often require additional code added to the same php file(s), and as you have observed, after installing one module, a second module may also affect a file (or files) that was altered by the first module.

    If (like 99% of us) you have only a smattering of PHP knowledge (or less), getting things to work is often a process of trial and error.

    So the key to your "experimentation procedure" is making sure you backup any file(s) that require a manual edit so that if (after your edits) the website falls over, it's simply a case of loading up the ORIGINAL file(s) and starting over.

    Often (but not always), the ORDER in which lines of code appear in a PHP file, is important, because there may be a chronology to the processing of the code. (The PHP must perform "A" before it is is allowed to perform "B", and then it goes on to process "C"...). This is typical of many CONDITIONAL bits of code... (IF...ELSE statements).

    Then there are PHP files that just need to LIST things like functions and operations. When needed, the list is simply "scrolled through " until the calling command finds the code driving the function it was told to collect, which it then uses to perform whatever action was called for. An example of this are language DEFINE statements which are listed one by one under each other. (There will be a "visual" order to these to make them easier to find, but generally it does not matter if define statement "A" is above or below define statement "B").

    At other times (typically in TEMPLATE files), the location of a piece of code influences the position (or behaviour) of an element in the displayed HTML in a browser, and a key indictor of this, is evidence of php being embedded into (or surrounded by) HTML tags.

    So, try to establish whether the clip of code you need to add is important for any CHRONOLOGY in behaviour, or important for any POSITIONING on the final "page", or whether it just needs to be there to describe a FUNCTION that needs to happen.

    Again, there's no real danger in making a mistake in a PHP file IF you have a backup of the original file that you can restore if things go pear-shaped.

    Where modules require database changes (SQL Inserts), things can be a little different. Getting the php edits wrong in these cases can result in errors that involve calls to the database.
    20 years a Zencart User

  2. #2
    Join Date
    Mar 2008
    Location
    QLD - Aussie
    Posts
    192
    Plugin Contributions
    0

    Default Re: Merging PHP Files

    Hi schoolboy
    thank you so much for your speedy reply & comprehensive explanation .

    just another question - so if there are 2 identical lines with slight differences in the commands (eg/

    $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=edit', 'NONSSL') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=delete', 'NONSSL') . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');

    $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=edit', 'NONSSL') . '">' . zen_image_button('button_details.gif', IMAGE_DETAILS) . '</a> <a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=delete', 'NONSSL') . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');


    would one have both the lines in the merged file? I mean will it be processed correctly if duplicated? (if you know what I mean?)

    Again, thank you so much for your help, and my apologies for my very basic questions

  3. #3
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,267
    Plugin Contributions
    3

    Default Re: Merging PHP Files

    Difficult one to give a blanket answer on.

    There can be many duplications of php commands in any one file, each with a subtle difference somewhere. Such duplication is generally INTENTIONAL and CRITICAL, so just getting rid of what may seem to be "copied code" is not advisable.

    In your case, the difference is simply the NAME of the image it calls, because the ACTION side of the scripts is identical.

    It should therefore be safe to use only ONE of these - and when it runs, look at the image it displays. If you get a blank page, or prefer the OTHER image... well, you know what to do.
    20 years a Zencart User

 

 

Similar Threads

  1. Merging html_header.php files?
    By jabbawest in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 31 Jul 2010, 12:50 AM
  2. what steps and software do you use for merging files?
    By mybiz9999 in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 14 Jul 2010, 10:08 AM
  3. Best software for comparing/merging files
    By Berserker in forum General Questions
    Replies: 3
    Last Post: 6 Dec 2008, 11:36 PM

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