default userpic

Parse Atom XML with PHP

Vote 0 Votes

Hi,
I have a custom PHP/MySQL site and use MT for the blog. I really would like to tie the two together and learn a little bit more about how to do so.

Basically, I am looking for a way to show the latest 4 posts on my homepage (which is not controlled by MovableType). I have tried parsing the Atom XML feed using PHP to do this but none of the scripts I have found seem to work.

Could someone point me in the right direction?

Thanks alot,
Ben

Reported on Movable Type 5

5 Replies

| Add a Reply
  • Just create a new index template that is outputted as a PHP file that you can include on your main page.

  • Thanks alot Mike, I will try this.

  • So if I clone the Main Index template I can include this on a non-movable type page?

    How does it find the database? Are we talking about two different things?


    • So if I clone the Main Index template I can include this on a non-movable type page?

      You don't need to clone the Main Index. Just click on the create new index template link and create a whole new index template. Then write a combination of PHP code and MT markup to create a PHP include that you can write to a directory where you non-MT site can load that file once it's published.

      How does it find the database?

      The database is essentially irrelevant. You'll write a fresh new template which, when published, will be a PHP include. You then modify your non-MT site to do a PHP include or require on that outputted file.

  • Ben,

    What Mike is saying and which I also recommend is that you create a new template that could be called "Blog Include".

    The coding that you will put on the new template will be based on the one from the "Main Index" template. You won't put all the coding from the "Main Index" template, but the part starting from <mt:Entries> and ending in </mt:Entries>.

    The output of this new "Blog Include" template could be a file called "includes/blog-include.php".

    Then you would include this "includes/blog-include.php" file as a php include or require it.

    Hope you're following us.

    Kind Regards,
    Mihai Bocsaru

Add a Reply

If you need to share template code, replace all the "<" signs with "&lt;" or use this utility.

Forum Groups

1773 6162

Last Topic: Excluding categories from blog by kholechek on Feb 9, 2012

86 302

Last Topic: website entries by masoud on Oct 26, 2011

1429 5077

Last Topic: What apocalypse hit this community in the middle of 2011? by 75th on Feb 10, 2012

694 2908

Last Topic: Blogspot to Movable Type by sdude on Feb 8, 2012

84 291

Last Topic: How to have some other characters in entry basename automatically written by Afshin Haghighatnia on Dec 22, 2011

173 737

Last Topic: About the MT version stated in HTML source by Alex E. Schneider on Feb 7, 2012

190 565

Last Topic: Analytics Reporting by michael webster on Feb 5, 2012

48 210

Last Topic: An idea and also a request by Afshin Haghighatnia on Jun 29, 2011

64 246

Last Topic: jQuery in MT 5.1 still at 1.4 - why? by perlmonkey on May 25, 2011

code.sixapart.com

137 478

Last Topic: Getting a thumbnail with xpath by Peter on Mar 13, 2011

222 720

Last Topic: Custom Field for Asset Not Appearing by android on Feb 9, 2012