2011-08-22 9 views
1

Wordpress 내에서 게시물 템플릿을 사용하여 테이블을 만듭니다. 그러나 형식이 조금 엉망입니다.Wordpress가 테이블을 올바르게 표시하지 않습니까?

코드를 생성하는 PHP가 들어가서 당일 사용자의 테스트 정보를 서버에 쿼리합니다. 그런 다음 내부 보고서를 정리하여 테이블 만 얻습니다. 이 보고서는 </tbody> 태그를 닫지 않으므로 str_replace를 사용하여 해당 태그를 닫아야합니다.

global $current_user; 

get_currentuserinfo(); 

$raw_contents = file_get_contents('http://******/NamedRptRun.asp?Rpt=DailyUserSum&Prj=******_****UserId='.($current_user->user_login)); 

    $trim_raw = trim($raw_contents); 
//echo htmlentities($trim_raw); 

if ($trim_raw == 'No Records Returned') { 

    echo 'No test cases to report today.'; 

} else { 

    $tag = '<TABLE'; 

    $topTrim_contents = stristr($raw_contents, $tag); 

    $tag = '</BODY>'; 

    $table_only = stristr($topTrim_contents, $tag, TRUE); 

    $table_only = str_replace("</tr></table>", "</tbody></tr></table>",$table_only); 

    echo htmlentities($table_only); 
    echo str_replace(array("\r\n","\n","\t"), ' ',$table_only); 

} 

이렇게하면 표 (디버깅 목적으로 만 사용)와 표가되어야합니다. 그러나 테이블의 값은 실제로 테이블 내에 있지 않지만 테이블 위의 라인에 표시됩니다.

<TABLE cellspacing=0 cellpadding=0 border=1 bordercolor=Silver> 
<thead class=b> 
<TR bgColor=WHITE> 
<th>&nbsp;Engineer&nbsp;</th><th>&nbsp;Passed&nbsp;</th><th>&nbsp;PWWarn&nbsp;</th><th>&nbsp;Blocked&nbsp;</th><th>&nbsp;Failed&nbsp;</th><th>&nbsp;Total Run&nbsp;</th></tr></thead><tbody class=h><TR bgColor=#F1F1F1><TD nowrap>myname</td><TD nowrap>1</td><TD nowrap>0</td><TD nowrap>0</td><TD >0</td><TD nowrap>1</td></tbody></tr></table> 

10001 
Engineer Passed  PWWarn  Blocked  Failed  Total Run 
myname 

왜 이런 일이 발생할 수 있는지에 대한 의견이 있으십니까?

붙여 넣기보기 페이지 생성 된 최종 테이블의 원본.

<table border="1" cellspacing="0" cellpadding="0"> 
    <thead class="b"> 
     <tr bgcolor="WHITE"> 
      <th> Engineer</th> 
      <th> Passed</th> 
      <th> PWWarn</th> 
      <th> Blocked</th> 
      <th> Failed</th> 
      <th> Total Run</th> 
     </tr> 
    </thead> 
    <tbody class="h"> 
     <tr bgcolor="#F1F1F1"> 
      <td nowrap="nowrap">myname</td> 
     </tr> 
    </tbody> 
</table> 
+0

닫는 ''및 ''태그는 처음부터 잘못되어 있습니다. 또한 어떤 브라우저를 사용하고 있습니까? 내가 문제를 재현하는 데 도움이 될 수도 ... –

+0

나는 파이어 폭스와 크롬의 최신 버전을 사용하고있다. 또한 Wordpress 3.2.1을 실행 중이며 재미있는 점은 3.1에서 잘 작동한다는 것입니다. –

+0

음, 귀하의 HTML - 심지어 원래 버전; 방금 붙여 넣기 - WordPress 3.2.1의 게시물에서 나에게 알맞게 렌더링합니다. 어쩌면 당신의 테마 CSS 또는 플러그인이나 다른 것들이 mangling 것들입니까? –

답변

0

SimplePostTemplate의 저자에게 문의 한 후 해결책을 찾았습니다. 마치 wordpress가 나쁜 HTML을 걸러내는 것처럼 보이는데, 이는 정확히 내 테이블에서 무엇을했는지, 그리고 왜 제대로 표시되지 않는지입니다.

나는 WordPress에 도착하기 전에 다른 부서에 HTML을 정리하도록 요청할 수 있었기 때문에 필터를 전달하고 문제를 해결했습니다.

관련 문제