Support Forum

Req. for code change: sp_SectionStart

BO BOZ
BOZ
Member

As I come across bugs I hope to assist in squashing them not just reporting them, to assist this I will use a common format to call attention to the bug as I see it and hopefully offer what I believe is the code fix. This is the first I hope to squash of many to help make this great project as solid as it can be. Most of what I have seen so far as bugs are output of additional or unused div tables or styling elements due to function logic not actually needed output.

 

Request for code change: Function sp_SectionStart

Change reason abstract: Function outputs some code elements that are not used in some circumstances that can confuse some browser rendering engines IE class=’ ‘ when called intentionally with no class. Cleans human readability in source output.

 

Functionality change: No change in use format

Added Functionality: Ability to call div with ID without class, Debug addition using section name

File location: /forum/content/sp-common-view-functions.php

 

Previous code:

Line 129 of function:

# output section starting div
    if(!empty($rowId)) $rowId=” id=’$rowId'”;
    $out = “<div class=’$tagClass$rowClass’$rowId>n”;

 

Replace with code:

Line 129 of function:

  # output section starting div
    if(!empty($rowId)){ $tagId = ” id=’$rowId'”; }else{ if(!empty($tagId)){$tagId = ” id=’$tagId'”;} }
    if(!empty($tagClass)){ $tagClass = ” class='” . $tagClass; if(!empty($rowClass)){ $tagClass = $tagClass . $rowClass; } $tagClass .= “‘”; }
    $out = “r<div” . $tagId . $tagClass . “>r”;
    if($dbug){$out .= “<!– Begin “. $sectionName . ” –>r”;}

5 Answers

New Answer

BO BOZ
BOZ
Member

Request for code change: Function sp_SectionEnd

Change reason abstract: Function outputs some code elements that are not used in some circumstances that can confuse some browser rendering engines IE Adds divs at end even when no class or id is given. Cleans human readability in source output.

 

Functionality change: No change in use format

Added Functionality: Debug addition using section name

File location: /forum/content/sp-common-view-functions.php

 

Previous code:

do_action(‘sph_BeforeSectionEnd_’.$sectionName, $a);

    $out = “<div$tagId$tagClass></div>n”;
    $out.= “</div>n”;

    $out = apply_filters(‘sph_SectionEnd’, $out, $sectionName, $a);

 

Replace with code:

do_action(‘sph_BeforeSectionEnd_’.$sectionName, $a);

# output section end div
    if(!empty($tagClass)){$tagClass=” class=’$tagClass'”;}
    if(!empty($tagId)){$tagId=” id=’$tagId'”;}

    if($tagClass||$tagId){$out = “r<div” . $tagId . $tagClass . “></div>r”;}
    if($dbug){$out .= “r<!– End “. $sectionName . ” –>r”;}
    $out.= “</div>r”;

    $out = apply_filters(‘sph_SectionEnd’, $out, $sectionName, $a);

MP Mr Papa
Mr Papa
Member

ya know… I have written this down at least three times to go back and address those empty divs and keep forgetting…what I get for not opening a ticket…  hate to have fix things up for IE wink but right thing to do…

I am not sure I support adding the debug stuff though…  its already very simple to to without any added code…

add_filter('sph_SectionEnd', 'my_debug_function', 10, 3);
function my_debug_function($out, $name, $a) {
    $out .= "n<!– End ". $name. " –>n";
    return $out;
}

and you have same without slowing down core…

will look more closely at your changes and see if we can apply them… thanks!

MP Mr Papa
Mr Papa
Member

I have committed a change to svn that should clean up these endless divs… 

Boz, please svn up and have a look… thanks!

BO BOZ
BOZ
Member

Heh the IE was meant as In Example, but yeah fixing for IE is a pain too although I wouldnt do it in functions sorry for the confusion.wink

Mr Papa said

ya know… I have written this down at least three times to go back and address those empty divs and keep forgetting…what I get for not opening a ticket…  hate to have fix things up for IE wink but right thing to do…

I am not sure I support adding the debug stuff though…  its already very simple to to without any added code…

add_filter('sph_SectionEnd', 'my_debug_function', 10, 3);
function my_debug_function($out, $name, $a) {
    $out .= "n<!– End ". $name. " –>n";
    return $out;
}

and you have same without slowing down core…

will look more closely at your changes and see if we can apply them… thanks!

 

MP Mr Papa
Mr Papa
Member

no worries. I need to not be so lazy and add stuff to a list I can forget about and open tickets instead! thanks for reminding!