Hi there!

I'm having a hard time using namespaces in a cake2-created feed. I'm
trying to create an iTunes-compatible podcast-feed which requires the
itunes:-namespace.

Digging around the RssHelper-code I actually came to the conclusion
that it's either a cakephp-bug or simply not yet implemented (right).
To make it work I actually had to:

In RssHelper.php on line ~ 315-ish, remove the " around $namespace so
that it says:
/////
if (!empty($namespace)) {
        $xml .= ' xmlns:' . $namespace . '';
}
/////
In the same file on line around 260 (RssHelper::item way down), right
before the call to $this->elem, add
/////
$attrib = array_merge($attrib, $att);
/////
to merge the attributes given as argument to ::item with the
attributes given to $this->elem() (reason comes below). The same thing
I had to do in RssHelper::channel, ca. line 150, right before
"$elems .= $this->elem(...)" inside the foreach-loop:
/////
$attributes = array_merge($attributes, $attrib);
/////

That way (when setting things up as suggested in the 2.0-book in the
Rss-section), I can add
/////
array('namespace' =>'itunes="http://www.itunes.com/dtds/
podcast-1.0.dtd"')
/////
as first argument to $this->Rss->channel() (in Views/layouts/rss/
default.ctp) and $this->Rss->item() in my view. Then the namespace-
declaration gets added to each and every generated xml-string before
it's being sent to Xml::built.

OTHERWISE Xml::built would complain that the namespace has not been
declared and simply ignore them/render the tags without the prefix,
because Rss-Helper builts the xml from inside to outside so defining
the namespace in the surrounding rss-tag only (as it probably should
be done) doesn't help at all.


My "fix" above is in no way a desirable solution because, as I said,
it adds the declaration to any xml-tag which produces loads of
overhead. There's another "fix" possible: In RssHelper::elem there's a
switch which checks for a prefix and, if it's "atom:", adds the
declaration for it. I could easily "hardcode" the declaration for
"itunes:" in there, but that would be just as unsatisfying as the
declaration get's added to each "itunes:" element instead of being
declared for the whole "rss"-scope.


So does anyone have any thoughts on this? Am I on a completely wrong
path here or is this really a bug or a not yet implemented feature of
cakephp2? And if so, do I really need to rewrite the RssHelper/write
my own which somehow builts stuff from outside to inside? ;-)


Regards,

Benni Graf.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to