Closed (fixed)
Project:
Content Templates (Contemplate)
Version:
6.x-0.13
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
27 Aug 2008 at 21:08 UTC
Updated:
19 Nov 2009 at 13:11 UTC
Hey!
I'm using contemplate to hack up the rss feed - and transform it into an XML field that will be parsed by a completely custom front-end.
So far so good.
I can extract and display custom cck fields.
There is one problem however - there is also a "node reference" field in my data type.
The users are able to select multiple possible links to another datatype. (Projects can be "related" to other Projects).
This is what is in my template:
<?php
$xml_elements = array(
array(
'key' => 'descriptionENG',
'value' => $node->field_description_english[0]['safe'],
),
array(
'key' => 'descriptionDUT',
'value' => $node->field_description_dutch[0]['safe'],
),
foreach ($node->field_related_projects as $relatedproject)
{
array(
'key' => 'relatedProjects',
'value' => 'wakawaka',
),
}
);
?>
basically i want to get this:
<desciptionENG>
Description in english
</descriptionENG>
<desciptionDUT>
Description in dutch
</descriptionDUT>
<relatedProjects>
<relatedProject>
a related project node id
</relatedproject>
<relatedProject>
a related project node id
</relatedproject>
</relatedProjects>
As far as i can see - i'm obviously breaking my xml/rss feed by abusing that "array" function.
Can somebody help me out here?
Should be possible - i feel i'm close to the solution but missing some stupid thing.
Thanks in advance!
Comments
Comment #1
Blue_Boy1987 commentedAnother Try
(this just breaks my rss feed).
Can somebody tell me if i'm doin' it basically wrong - or just looking over a silly syntax mistake?
Comment #2
jrglasgow commentedYou cannot use a for loop in your array definition, try this
Comment #3
Blue_Boy1987 commentedAllright - goin' in the right direction here.
Now - is it possible to add an "attribute" to one of my xml elements?
Code as it is is like this:
And this is the output i want to get out of the related projects part
Thanks in advance again - you have been a great help allready.
Comment #4
dman commentedSome advice -
Figure out the legal ways of extending RSS before you get much more into customizing like that.
It is TOTALLY supported to add your own tags, but you should find out about namespaces and go from there.
Not only will it stop your current output from being totally invalid, like it is now, but you will also get the advantages of mash-ups.
http://developer.cooliris.com/ piclens sorta demonstrates how this can be achieved, and be really cool.
http://www.vast.com/rss/real_estate is another example of specific data embedded in valid feeds to extend them
If, at the moment, you are control of both the server and the consumer application, you can choose your syntax carefully.
Also, there are supported ways to embed translations in RSS, I think it's like
Standards are cool ... when you can find ways to make them work FOR you.
Comment #5
Blue_Boy1987 commentedAllright - good point.
Can somebody clarify the syntax to add these arguments (lang="eng" - for example) to the rss feed by extending the code above?
Comment #6
dman commentedThis reading may help on the lang syntax on XML HTML RSS elements
... I can't speak for the actual support in RSS readers tho...
And here is some info about extending RSS (OK, actually ATOM, but the theory should apply)
Here is an RSS reference demonstrating a few other extensions
Not sure about the php code you need either, I don't use contemplate, but it should be possible, or made possible to add arbitrary attributes.
Comment #7
jrglasgow commentedfor adding attributes check out the documentation for format_xml_elements(), which is the function being used to translate the array to an XML string.
for example to get:
do
Comment #8
dman commentedReally cool, thanks
Bizarrely, I have format_xml_elements() open in another window right now on a TOTALLY unrelated issue tracking down why it's giving PHP_STRICT warnings in an otherwise clean install :)
That's just freaky.
Comment #9
Bensbury commentedI'm interested in getting this to work but it doesn't work for me.
Using $xml_element in the Contemplate RSS Template blocks returns nothing.
I read this is a Drupal 6 issue, ???
I just want to add extra xml tags to my rss feed
Comment #10
jrglasgow commented@egeos,
notice: this is not an issue, this is a support request.
Yes you can add extra xml tags using contemplate. if you would like to add your own issue I would be glad to help you.
Comment #11
jrglasgow commentedI am going to assume that this is fixed since there has been no more comments posted
Comment #13
lelizondo commentedsubscribe
Comment #14
dman commentedFYI, and for reference, here's the custom code I added to the contemplate RSS for an Ubercart product to start to support Google Merchant syndication:
PHP tags required.
I'm actually going to roll this and more into a custom module that supports ubercart, but this worked when I was in the testing phase.
(Took me a few hours of research to get this far, so I though I'd share)