2011-10-05 3 views
-1
echo '<tr class="class_row">'; 
echo '<td>'; 

echo $this->Html->link($post['Post']['title'], 
       array('controller'=>'posts','action'=>'view',$post['Post']['id']), 
       array('id'=>'id_anchor_title','class'=>'class_anchor_title')); 
echo '<h6><i>'.$this->Time->format('d-M-Y',strtotime($post['Post']['created'])).'</i></h6>'; 
echo '<br/>';       
$last_paragraph=$post['Post']['body']; 
$length = strlen($last_paragraph);     
echo $this->Text->truncate($last_paragraph,150,array('ending' => '...','exact' => false)); 
echo '<br/>'; 
//echo debug($last_paragraph); 
if($length > 151){ 
    echo $this->Html->link('more', 
       array('controller'=>'posts','action'=>'view',$post['Post']['id']), 
       array('id'=>'id_anchor_more','class'=>'class_anchor_more')); 
} 
       echo '</td>'; 
echo '<td>'.$this->Html->link('Edit', 
        array('controller'=>'posts','action'=>'edit',$post['Post']['id'])).'</td>'; 
echo '<td>'.$this->Html->link('Delete', 
        array('controller'=>'posts','action'=>'delete',$post['Post']['id'])).'</td>'; 
echo '</td>'; 
echo '</tr>'; 

내가 게시 할 때 '더보기'링크/앵커가 게시물의 내용/본문으로 추가됩니다.PHP, CakePHP, HTML : 앵커 태그가 코드 태그 안에 추가됩니다. 어떻게이 앵커 태그를 분리 할 수 ​​있습니까?

휴식을 취하고 '더'가 신체의 한 부분 인 것을 어떻게 멈출 수 있습니까?

게시물의 내용이나 본문에 다음 줄이 있는데, 별도의 링크가됩니다.

<a href="/posts/view/37" id="id_anchor_more" class="class_anchor_more">more</a> 

링크는 내부해야한다 :

<table> 
<tr> 
<td>Content..Data.. <br/>'more' </td> 
<td>Edit</td> 
<td>Delete</td> 
</tr> 
</table> 

누군가가이 문제를 해결하는 데 도움이 수 있습니까?

는 동일한 열 <td> 문제 내가 <pre class="brush: cpp"> ...body.. </pre> 다음 문제가 발생 태그 내부의 코드를 삽입 할 때 내가 syntaxhighlighter http://alexgorbatchev.com/SyntaxHighlighter/을 사용하고 있습니다 몸과 '더'를 가질 수 없습니다.

+0

그것을 둘러싸보십시오. 현재 출력과 원하는 출력을 게시 할 수 있습니까? – Rifat

+0

전류 출력이 => mysqldump는 -u 루트 --password = mypassword 여기서 databaseName> backupfile.sql mysqldump는 -u 루트 --password = mypassword ... more EditDelete하지만 난이 '더', '편집'원하는이다, 게시물의 내용이 아닌 링크/앵커로 '삭제'합니다. – shibly

+0

이 코드는 내 케이크에서 잘 작동합니다 .PHP – littlechad

답변

2
<style> 
    table tr td h6{font-style: italic;} 
</style> 
<tr class="class_row"> 
    <td> 
     <?php 
     echo $this->Html->link($post['Post']['title'], 
      '/posts/view'.$post['Post']['id'], 
      array('id'=>'id_anchor_title','class'=>'class_anchor_title') 
     );?> 
     <h6><?php echo $this->Time->format('d-M-Y',strtotime($post['Post']['created']));?></h6> 
     <br/> 
     <?php 
     $last_paragraph=$post['Post']['body']; 
     $length = strlen($last_paragraph);     
     echo $this->Text->truncate($last_paragraph,150,array('ending' => '...','exact' => false)); 
     ?> 
     <br/> 
     <?php 
     if($length > 151){ 
      echo $this->Html->link('more', '/posts/view'.$post['Post']['id'], 
       array('id'=>'id_anchor_more','class'=>'class_anchor_more') 
      ); 
     } 
     ?> 
    </td> 
    <td><?php echo $this->Html->link('Edit', '/posts/edit'.$post['Post']['id']);?></td> 
    <td><?php echo $this->Html->link('Delete', '/posts/delete'.$post['Post']['id']);?></td> 
</tr> 

내가 그것을이 방법을 작성하여 쉽게 읽을 수있을 거라고 생각 시도하고 난 내 작업 CakePHP의 프로젝트에 검사를하지 그것, 그리고 그것은 잘 작동, 나는 그냥 원래의 코드를 변경하지 않습니다, 그냥 에코 제거.

내가 당신의 $post['Post']['body']은 아마 당신의 링크를 일반 텍스트 만드는 무언가를 포함하는 것으로 의심, 당신을 얻을 수 없습니다 사업부 또는 뭔가

<div> 
    <?php 
    echo $this->Text->truncate(
     $last_paragraph, 
     150, 
     array('ending' => '...', 'exact' => false) 
    );?> 
</div> 
+0

문제는 코드를 게시 할 때

 ..Code..
코드를 추가하므로
..
태그가 게시물에 추가되었습니다. 나는 이것을 사용했다, http://alexgorbatchev.com/SyntaxHighlighter/ 여기에 CSS와 자바 스크립트는 기존 것과 충돌 할 수있다. – shibly

+0

나는 모든 echo 'body'/ message를

..
안에 넣어야 만한다. – shibly

2

HTML 구조가 잘못되었습니다. 링크 뒤에 </td> 마감 기한이 누락되었습니다.

이렇게하면 the HTML helper to create tables을 사용하는 것이 좋습니다 : 실수로 태그가 누락 될 가능성을 제거합니다.

+0

아니요, ''이 있습니다. – shibly

+0

하지만 잘못된 위치에 있습니다. (하나의 셀 안에 두 개의 셀이 있습니다.) 생성 된 HTML을 살펴보고 유효성 검사기를 통해 실행하십시오. – JJJ

+2

누락 된 태그를 추가하기 위해 질문을 편집 한 것으로 나타났습니다. 실제 코드에 있는지 확인하십시오. – JJJ

1

html 태그와 텍스트에와 $post['Post']['body']을 대체,이

echo '<tr class="class_row">'; 
    echo '<td>'; 

    echo $this->Html->link($post['Post']['title'], 
        array('controller'=>'posts','action'=>'view',$post['Post']['id']), 
        array('id'=>'id_anchor_title','class'=>'class_anchor_title')); 
    echo '<h6><i>'.$this->Time->format('d-M-Y',strtotime($post['Post']['created'])).'</i></h6>'; 
    echo '<br/>';       
    $last_paragraph=$post['Post']['body']; 
    $length = strlen($last_paragraph);     
    echo $this->Text->truncate($last_paragraph,150,array('ending' => '...','exact' => false)); 
    echo '</td>'; 

    if($length > 151){ 
     echo '<td>'.$this->Html->link('more', 
        array('controller'=>'posts','action'=>'view',$post['Post']['id']), 
        array('id'=>'id_anchor_more','class'=>'class_anchor_more')).'</td>'; 
    } 
        echo '</td>'; 
    echo '<td>'.$this->Html->link('Edit', 
         array('controller'=>'posts','action'=>'edit',$post['Post']['id'])).'</td>'; 
    echo '<td>'.$this->Html->link('Delete', 
         array('controller'=>'posts','action'=>'delete',$post['Post']['id'])).'</td>'; 
    echo '</tr>'; 
+0

이 작동합니까 "echo <'td'>"? – littlechad

+0

@littlechad 덕분에 오타였습니다.[fixed] – Rifat

+0

'more'는 새로운 열 ''을 만듭니다. 같은 칼럼 ''에서 몸체와 'more'를 가질 수 없다는 것은 syntaxhighlighter http://alexgorbatchev.com/SyntaxHighlighter/를 사용하고 있는데, 태그 안에

 ...body..
코드를 넣으면 문제가 발생합니다. – shibly