XML MadeSimple [Default template] [Solved]

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
janb

Re: XML MadeSimple [Default template] [Solved]

Post by janb »

Hi  Cécile

I think the default template are using {$xml} witch is raw data from the feed and will not be affected by the max_items parameter from what I can understand looking at the code.

If you have a valid feed, {$feed} should be available as a smarty tag.
Add {get_template_vars} in the feed template to confirm this.

I have problems getting this to work as well :(
Could you post the feed link you are using?

JanB
Last edited by janb on Fri Apr 16, 2010 8:42 am, edited 1 time in total.
oaouh
New Member
New Member
Posts: 6
Joined: Thu Apr 15, 2010 8:21 am

Re: XML MadeSimple [Default template] [Solved]

Post by oaouh »

Ok I found the issue. I think the module was thought to read Atom feeds, not RSS feeds, which don't have the same rules for the name of the tags.

Indeed, Atom feeds look like that :

Code: Select all

<feed> 
     <entry>
      ...
     </entry>
</feed>
Even though RSS feeds look like :

Code: Select all

<rss>
    <channel>
        <item>
            ...
        </item>
    </channel>
</rss>
In my case, I wanted to read a RSS feed. If you are in the same case, edit the file : root_of_your_site/modules/XMLMadeSimple/action.default.php with a text editor then replace all the "$xml->entry" by "$xml->channel->item" (3 places).
So you should have : 

Code: Select all

if (isset($xml->channel->item))
   {
      if (isset($params['max_items']))
      {       
        $entries = array();
        foreach ($xml->channel->item as $entry)
        {
           $entries[] = $entry;
        }
        $feeds = array_slice($entries, 0, $params['max_items']);
      }
      else
      {
         $feeds = $xml->channel->item;
      }
    $this->smarty->assign('feeds', $feeds);
}
Then, you have to use the $feeds array in your template, which takes the max_items limit into account.

Here is an exemple of what you can write in the 'default' template :

Code: Select all

{foreach from=$feeds item=actu}
<h3>{$actu->title}</h3>
{$actu->pubDate}<br/>
{$actu->description}<br/>
<a class="liresuite" href="{$actu->link}">read more</a>
{/foreach}
<p>These news come from <a href="{$xml->channel->link}">{$xml->channel->title}</a>.</p>
Hoping this message could help other CMSMS developers...

Bye !
Cécile
oaouh
New Member
New Member
Posts: 6
Joined: Thu Apr 15, 2010 8:21 am

Re: XML MadeSimple [Default template] [Solved]

Post by oaouh »

Oooops, sorry JanB, I just saw your answer... :D
Thank you for your help.
janb

Re: XML MadeSimple [Default template] [Solved]

Post by janb »

Hey Cécile

No prob.
Thank's for posting the RSS solution.

JanB
masama1
Forum Members
Forum Members
Posts: 10
Joined: Thu Jul 08, 2010 8:44 am

Re: XML MadeSimple [Default template] [Solved]

Post by masama1 »

Hi and thank you for great lessons here. I was able to import XML first time ever! I have XML at http://www.edeamedia.com/testi/testi.xml. There is, as i understood correctly, subchilds also. How should i handle them with XML Made Simple?
Locked

Return to “Modules/Add-Ons”