Jump to content


Photo
- - - - -

How do I add a content type to etomite?


  • Please log in to reply
6 replies to this topic

#1 serge

serge

    Etomite Forum Newbie

  • Member
  • 2 posts

Posted 05 May 2009 - 09:44 PM

Hi,

I have a question I hope someone can help me with:

I have a site that features my panoramas. I use a template/snippet/chunk to generate an xml file on the fly from the database. The xml file is actually a KML file and if you open it in google earth, it shows all my panoramas (neat!).

http://360photo.org/360photo_org.kml

There's one problem though. By default Etomite only knows the document types text/plain, text/html and text/xml. I need the type text/kml and I need my webserver to add the content type application/vnd.google-earth.kml+xml to the http header.

I started off by adding a mod_rewrite rule that translates requests for 360photo_org.kml to 360photo_org.html. I have given the panorama the alias 360photo_org. That works.

Then I added the content type to my apache server:
AddType application/vnd.google-earth.kml+xml .kml

And then I added the content type text/kml to /manager/actions/dynamic/mutate_content.dynamic.action.php

That did not work. The header from my webserver simply says Content-type text/kml. If I save the kml file as a static file on my server and request it, I do get the right content type in my header.

I also tried adding "application/vnd.google-earth.kml+xml" to mutate_content.dynamic.action.php and I tried setting this content type explicitly for the page in the etomite_site_content table.

To summarize: I'm not sure what I'm doing I guess.. The webserver seems to be configured correctly, but etomite is handling/mangling the header. And I don't know where to look for a fix.

Can anybody help?

Thanx,
Serge.

p.s. right now, while it says Content-type: text/kml in the header, it works o.k. in firefox, byt Chrome doesn't understand it should display a dialog. It simply shows the content of the file.

#2 Ralph

Ralph

    Loves Etomite Forums!

  • Admin
  • 6,539 posts

Posted 05 May 2009 - 11:38 PM

That's the problem with newer document/header types, some browser clients don't recognize them... One reason why Etomite doesn't support application/xhtml+xml is because Internet Explorer doesn't recoginze or support it... It takes lines of conditional code to make sure proper headers are sent to browser clients...

But in answer to your original question, you can add header types to the select drop-down in manager/actions/dynamic/mutate_content.dynamic.action.php if you are daring enough to gve it a go... Be warned that you would also need to make changes to index.php to account for browsers as well in the outputContent() function...

You're on your own as far as support, however, because we don't support experimental code base hacking...

#3 petewalker

petewalker

    Etomite Forum Newbie

  • Member
  • 22 posts

Posted 07 May 2009 - 11:34 PM

You're on your own as far as support, however, because we don't support experimental code base hacking...

Not to rock the boat Ralph, but is the etomite project not an opensource endeavour?... Seems rather odd that you would make such a statement. Etomite has changed a LOT since the days of Phaze, and just to mention, I am sure that Alex would be proud of where it has gone. Is it "hacking" or is it "enhancing"...?

Edited by petewalker, 07 May 2009 - 11:35 PM.


#4 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,106 posts

Posted 09 May 2009 - 09:44 PM

Is it "hacking" or is it "enhancing"...?

That depends on
1) Whether it works and how stable it is
2) Whether you ask the etomite community to help fix anything you have broken if it doesn't work.

I have managed to get some "enhancements" for inclusion in the code base because they have been thoroughly tested by a number of installations and users, the changes were well documented and have a good rationale for doing it that was researched and the implications for other users was considered. My sugggestion if you are attempting this is to have a development environment so that you can blow it away and rebuild it (if it all goes pear shaped) and so that you don't inadvertantly create a fork that is unsupportable.

#5 serge

serge

    Etomite Forum Newbie

  • Member
  • 2 posts

Posted 09 May 2009 - 09:48 PM

That's the problem with newer document/header types, some browser clients don't recognize them... One reason why Etomite doesn't support application/xhtml+xml is because Internet Explorer doesn't recognize or support it... It takes lines of conditional code to make sure proper headers are sent to browser clients...


Ah, a quick google reveals what you're refering to. I see!

But in answer to your original question, you can add header types to the select drop-down in manager/actions/dynamic/mutate_content.dynamic.action.php if you are daring enough to give it a go... Be warned that you would also need to make changes to index.php to account for browsers as well in the outputContent() function...


Thanks for the pointers. In the end it seems it was really simple. I edited manager/actions/dynamic/mutate_content.dynamic.action.php, inserted this line at line 1012:
<option value="application/vnd.google-earth.kml+xml" <?php echo $content['contentType']=="application/vnd.google-earth.kml+xml" ? "selected='selected'" : "" ;?>>text/kml</option>


The only thing I had to do was to edit the page again and set the content type to kml, so both the contentType field in the site_content table and the cache file assets/cache/etomiteCache.idx.php were updated.

It didn't work before because I neglected to update the cache file :blush:

Editing index.php doesn't seem to be necessary so far.

Perhaps I'm the only one that ever wanted to add a content-type, but if not it could imho easily be fixed with mutate_content.dynamic.action.php getting it's types for the dropdown box from a content-type lookup table

You're on your own as far as support, however, because we don't support experimental code base hacking...


I'll take my chances :)

Thanks again,
serge.

p.s. my message showed up in the rss feed, but your answer didn't. The rss probably does not include replies. Strange.

#6 Ralph

Ralph

    Loves Etomite Forums!

  • Admin
  • 6,539 posts

Posted 09 May 2009 - 10:06 PM

@petewalker

What I meant, as CrisD mentioned, is that if you're gonna hack at the code base you're on your own when things go wrong... These forums are here to support the code base, as released, not code that someone butchers... Problems along these lines are part of why Alex left and the folks at ModX became an authorized fork of the Etomite code base...


@serge

I wasn't totally sure whether you would need to modify the parser, index.php, or not... Glad you got it working... As you discovered by Googling, there can be definite compatibility issues with some header types...

#7 petewalker

petewalker

    Etomite Forum Newbie

  • Member
  • 22 posts

Posted 11 May 2009 - 12:53 AM

@petewalker

What I meant, as CrisD mentioned, is that if you're gonna hack at the code base you're on your own when things go wrong... These forums are here to support the code base, as released, not code that someone butchers... Problems along these lines are part of why Alex left and the folks at ModX became an authorized fork of the Etomite code base...


Ok mate, I totally understand - nicely explained. As u would well know, I have a real hate-hate relationship with ModX, but lets not go there...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users