Jump to content

[SOLVED] Content displays twice


DanielHardy

Recommended Posts

 

Hi,

I am very new to, and have just started learning the Zend Framework. Within my layout.phtml file I am telling it to display the content of the current page. Here is the full code:

 


<? /* application/layouts/scripts/layout.phtml

      This line outputs the doctype we set in the bootstrap */ ?>
<?= $this->doctype() ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head> 
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Manchester United Fans Forum</title>
  <?= $this->headLink()->appendStylesheet('https://mi-linux.wlv.ac.uk/~0607197/QuickStart/public/css/global.css') ?>


</head>
<body>

<!--
    Layouts are a great place to put header and footer content that will be
    needed on all pages that share the same layout.  To understand fully what
    having layouts inside a MVC application mean, check out the Zend_Layout
    section of the manual.
    http://framework.zend.com/manual/en/zend.layout.html
    -->
<div id="layout" style="background-image:url('http://i17.photobucket.com/albums/b65/dan666cheese/main-3.jpg') ; height: 650px; width:800px; margin:auto;">
   
   <div id="topgap" style="height:120px; width:800px; ">
   </div>
    <div id="header-navigation" style=" ">
        <!-- To keep urls consistent with the applications router (right now we
             are using the default router), we will employ the use of the url
             view helper
             http://framework.zend.com/manual/en/zend.view.helpers.html
             -->
       <a href="<?= $this->url(
            array('controller'=>'home'),
            'default',
            true) ?>">Home</a>
   
   
      <a href="<?= $this->url(
            array('controller'=>'feed'),
            'default',
            true) ?>">News</a>
    </div>
   <div id"maingap" style="height:25px;">
   </div>
   <?= $this->layout()->content; ?>
</div>

<!-- This next call will now include any content that was generated in the
     dispatching of a controllers action (or series of actions).  -->

<?= $this->layout()->content ?>

<!-- If your application requires it, this would be a great place to put a
     footer for all pages. -->

</body>
</html>

 

I am using a controller and a view that produces an rss feed. Here is the code for index.phtml :

 


<div id="hello" style="color:#FFFFFF; text-align:center; ">
<b>Latest Football News (Provided By The BBC):</b> <br />
<dl>
    <!-- Loop through the entries provided by the controller -->
    <? foreach ($this->entries as $entry): ?>
   <div id="title" style="color:#000000; font-weight:bold;font-size:18px; ">
    <dt><?= $this->escape($entry['title']) ?></dt>
   </div>
    <dd><?= $this->escape($entry['description']) ?></dd>
    <? endforeach ?>
</dl>

</div>

 

Now when I navigate to the feed page, the content displays twice on the page. Any Ideas why?

 

 

 

Just incase it is relevant, here is the controller code:

 


<?php

// application/controllers/FeedController.php

class FeedController extends Zend_Controller_Action 
{
    protected $_model;

    public function indexAction()
    {
        // Read remote feed
        try
        {
            $rss = Zend_Feed::import('http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/football/rss.xml');
        } 
        catch (Zend_Feed_Exception $e)
        {
            // feed import failed
            echo "Exception caught importing feed: {$e->getMessage()}\n";
            exit;
        }

        // Initialize the channel data array
        $channel = array(
            'title'       => $rss->title(),
            'link'        => $rss->link(),
            'description' => $rss->description(),
            'items'       => array()
            );
        
        // Loop over each item and store relevant data
        foreach ($rss as $item) {
            $channel['items'][] = array(
                'title'       => $item->title(),
                'link'        => $item->link(),
                'description' => $item->description()
                );
        }

        // Pass to view
        $this->view->entries = $channel['items'];
    }

}

Thanks in advance for any help you might be able to give me

 

Daniel

 

 

Link to comment
https://forums.phpfreaks.com/topic/148119-solved-content-displays-twice/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.