2013-12-26 2 views
0

Следующий заголовок добавлен в мой index.ctp в CAKEPHP 2.XXX .... Как его удалить?удалить Заголовок по умолчанию: «CakePHP: быстрый ...» из моего «index.ctp»

здесь вы идете:

<div id="header"> 
    <h1><a href="http://cakephp.org">CakePHP: the rapid development php framework</a></h1> 
</div> 

вот мой index.ctp файл

<h1>Blog posts</h1> 
<p><?php echo $this->Html->link("Add Post", array('action' => 'add')); ?></p> 
<table> 
    <tr> 
     <th>Id</th> 
     <th>Title</th> 
     <th>Action</th> 
     <th>Created</th> 
    </tr> 

    <!-- Here's where we loop through our $posts array, printing out post info --> 

    <?php foreach ($posts as $post): ?> 
     <tr> 
      <td><?php echo $post['Post']['id']; ?></td> 
      <td> 
       <?php 
       echo $this->Html->link(
         $post['Post']['title'], array('action' => 'view', $post['Post']['id']) 
       ); 
       ?> 
      </td> 

      <td> 
       <?php 
       echo $this->Form->postLink(
         'Delete', array('action' => 'delete', $post['Post']['id']), array('confirm' => 'Are you sure?') 
       ); 
       ?> 
       <?php 
       echo $this->Html->link(
         'Edit', array('action' => 'edit', $post['Post']['id']), array('confirm' => 'EDIT ?') 
       ); 
       ?> 
      </td> 
      <td> 
       <?php echo $post['Post']['created']; ?> 
      </td> 
     </tr> 
      <?php endforeach; ?> 

</table> 

помочь мне плз ....

Я пытался добавить default.ctp в «приложение/layouts ", но мое приложение не работает ... оно показывает только default.ctp, но не мой index.ctp

следующий мой Cont файл ролика ....

<?php 

    class PostsController extends AppController { 
     public $helpers = array('Html', 'Form'); 

     public function index() { 
      $this->set('posts', $this->Post->find('all')); 
     } 
     public function view($id = null) { 
      if (!$id) { 
       throw new NotFoundException(__('Invalid post')); 
      } 

      $post = $this->Post->findById($id); 
      if (!$post) { 
       throw new NotFoundException(__('Invalid post')); 
      } 
      $this->set('post', $post); 
     } 
     public function add() { 
      if ($this->request->is('post')) { 
       $this->Post->create(); 
       if ($this->Post->save($this->request->data)) { 
        // $this->Session->setFlash(__('Your post has been saved.')); 
        return $this->redirect(array('action' => 'index')); 
       } 
       $this->Session->setFlash(__('Unable to add your post.')); 
      } 
     } 
     public function edit($id = null) { 
      if (!$id) { 
       throw new NotFoundException(__('Invalid post')); 
      } 

      $post = $this->Post->findById($id); 
      if (!$post) { 
       throw new NotFoundException(__('Invalid post')); 
      } 

      if ($this->request->is(array('post', 'put'))) { 
       $this->Post->id = $id; 
       if ($this->Post->save($this->request->data)) { 
       // $this->Session->setFlash(__('Your post has been updated.')); 
        return $this->redirect(array('action' => 'index')); 
       } 
       $this->Session->setFlash(__('Unable to update your post.')); 
      } 

      if (!$this->request->data) { 
       $this->request->data = $post; 
      } 
     } 
     public function delete($id) { 
      if ($this->request->is('get')) { 
       throw new MethodNotAllowedException(); 
      } 

      if ($this->Post->delete($id)) { 
       //$this->Session->setFlash(__('The post with id: %s has been deleted.', h($id))  ); 
       return $this->redirect(array('action' => 'index')); 
      } 
     } 
    } 


    ?> 
+0

Добавить контроллер. похоже, что вы используете макет по умолчанию. вам нужно создать новый макет для заголовка –

+0

@MoyedAnsari ... Это мой файл с контроллером ..... так какие должны быть возможные резоны .... –

+0

у вас есть макет, отличный от по умолчанию? –

ответ

1

использовать следующие строки, чтобы изменить макеты по умолчанию -

public function index() { 
      $this->layout= 'home'; // new name of layout that you are going to assign 
      $this->set('posts', $this->Post->find('all')); 
     } 

и поместить другое имя файла home.ctp в APP/VIEW/макет/

копируя исходный макет по умолчанию default.php внутри вашего каталога cake/lib/view/layout и удаляйте содержимое нижнего колонтитула в соответствии с вашими потребностями.

ваш home.ctp должен быть вроде как -

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<title><?php echo $title_for_layout?></title> 
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> 
<!-- Include external files and scripts here (See HTML helper for more info.) --> 
<?php 
echo $this->fetch('meta'); 
echo $this->fetch('css'); 
echo $this->fetch('script'); 
?> 
</head> 
<body> 

<!-- If you'd like some sort of menu to 
show up on all of your views, include it here --> 
<div id="header"> 
    <div id="menu">...</div> 
</div> 

<!-- Here's where I want my views to be displayed --> 
<?php echo $this->fetch('content'); ?> 

<!-- Add a footer to each displayed page --> 
<div id="footer">...</div> 

</body> 
</html> 
+0

thnks .... приятное описание ,,,, я застрял с прошлого дня .... наконец-то решил .... thnksssss –

+0

рад помочь тебе – Abhishek

1

Внутри вашего действия сделать макет равен ложному

$this->layout= ''; 

Это заставит CakePHP не включать любой макет для вашего приложения.

Incase вы хотите использовать свой собственный макет, пожалуйста, следуйте инструкциям, приведенным в нижеследующей ссылки

http://book.cakephp.org/2.0/en/views.html

Смежные вопросы