Jump to content

[SOLVED] ANYONE Familiar With Zend Framework?


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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.