Hi all

Merry Christmas :)

I have an Index action/view which lists all the records in my
database. This takes an additional 'page' parameter so that the
records appear in pages.

I'm trying now to generate an XML version of this. The XML version
will include all the records. ie. no paging is needed.

I read some discussions on this list and realized I don't need a new
action - I can just use the same one, and create an executeXML method
in my view. I did this, also set up a new output type as follows:

In output_types.xml
                        <output_type name="xml">
                                <parameter name="http_headers">
                                        <parameter 
name="Content-Type">text/xml</parameter>
                                </parameter>                            
                        </output_type>

In routing.xml:
                                        <route name="author.index.xml" 
pattern="^/author/index/xml$"
action="Author.Index" output_type="xml" />


In the view:
        public function executeXml(AgaviRequestDataHolder $rd)
        {
                $c = new Criteria();
    $c->addAscendingOrderByColumn(AuthorPeer::AUTHORID);                

    $authors = AuthorPeer::doSelect($c);
    $this->setAttribute('dataset', $authors);   
        }

In the template Index.xml.php:

<?xml version='1.0'?>
<?php if (isset($template['dataset']) && count($template['dataset']) > 0): ?>
        <div>
          <?php foreach ($template['dataset'] as $d): ?>
          <div><?php echo $d->getAuthorName(); ?></div>
          <?php endforeach; ?>
        </div>
<?php endif; ?>

but the eventual output does not contain any XML: I get a blank page.
Can anyone help? I'm sure I'm doing more than one thing wrong :)

Vikram

_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users

Reply via email to