[RFE+patch] patch to check for right_column.php before page

veggiespam <[email protected]> 25 Aug 2003 19:02:33 -0000
Newsgroups gmane.comp.web.oscommerce.suggestions
Message-ID <594be5c858d63d021cf0d4ed9336401e@osCommerce-Forums>
This message was sent from: Suggestions and Proposals
http://forums.oscommerce.com/viewtopic.php?p=219474#219474
----------------------------------------------------------------

all but one of my clients hates the right column of the standard OSC layout. so, for quick projects we just put a blank file in its place. however, this is not good enough; as the table structure assumes there will be something there, thus always leaving a large empty area on the right.

i'd like to see OSC check for the existence of the right_column.php file before doing the whole {TD} of the right column. it will look cleaner and be much easier for people to customize, as we won't have to edit every single file to remove the column in the future. it will also be a starting point for the templatization mentioned in the wish lists (ala check this box for a right column...).

here is a script in perl which will add this check for right column. just run it on catalog/*.php and cvs commit the newly modified files. it'd be trivial to extend this patch to also check for the left column or footer (and i'll do it if asked). 

[code]
#!/usr/bin/perl -ni

BEGIN {
        $start_area = 0;
}

if ( /body_text_eof/ ) {
        print STDERR "start of rightn";
        $start_area = 1;
} elsif ($start_area == 0) {
        print $_;
        next;
}

if ( m#</table></td>#  && ($start_area == 1) ) {
        # end of replacement section, so do replacenemt
        print STDERR "end of rightn";
        $start_area = 0;
    print '<!-- body_text_eof //-->' . "n";
    print '<?php if (file_exists(DIR_WS_INCLUDES . 'column_right.php') &&
(filesize(DIR_WS_INCLUDES . 'column_right.php') > 0)) { ?>' . "n";
    print '    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table
border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">'
. "n";
    print '<!-- right_navigation //-->' . "n";
    print '<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>' . "n";
        print '<!-- right_navigation_eof //-->' . "n";
    print '    </table></td>' . "n";
        print '<?php } ?>' . "n";

}
[/code]

as mentioned by one of the osc developers in bug 1356, this patch will not be needed once the template mechanism is introduced.  but in the meantime, it'd be a nice feature that's quick to implement.