Recommended

Skip Navigation LinksHome / Articles / View Article

Silverlight and Drupal: Syndication

+ Add to SilverlightShow Favorites
3 comments   /   posted by Matt Serbinski on Aug 25, 2008
(15 votes)
Categories: 18 Aug 08 - 28 Sep 08

Note: This article is submitted by Matt Serbinski for Silverlight: Write and Win contest.Thanks a lot, Matt! Hello All, Please drop a comment if you like it.

It is time to vote now! Please, choose your favorite articles and enter your vote by going to contest page. Thank you!

I will be writing a few posts on connecting silverlight and drupal in which I will replicate my main site. I will be doing this piece by piece as I investigate each drupal module that I am using and how I can request the appropriate data to populate my silverlight controls. I have outlined the basics needed to accomplish this in my previous post and will be focusing on the new information that is needed to complete each new piece.

Download source code

Drupal's aggregator module is a core module that is used for fetching syndicated content from other sites. However, it has the ability to provide an xml syndication button for your drupal site if you decide to show the syndication block. There is much more functionality that this module can provide, but all I needed was a simple link to my sites syndication. After doing some initial research I did not find a way to call some method that returned my sites syndication. So I decided to 'cheat' a little bit and produce my sites syndication link manually (at least I did not hard code this!). Here is the php below:

$mainSiteRSS = variable_get('site_name', 'Drupal');
$mainSiteRSS .= url('rss.xml');
return array('rssLoaded', $mainSiteRSS);

I simply grab the sites name, append 'rss.xml' and return a correctly formatted url string to my silverlight application. I then tie that url to my rss button:

private void rssLoaded(object feedSite)
{
    string rssLocation = ((MethodToCall)feedSite).MethodName;
    Uri rssLink = new Uri("http://" + rssLocation, UriKind.RelativeOrAbsolute);
    HtmlPage.Window.Navigate(rssLink);
}

Remember, I have a generic method that gets called when drupal returns its data that casts the data to a MethodToCall object as outlined in my previous post.

And that's it! This was one of the simpler controls and that is one reason that I decided to start with this one. The silverlight code was very simple as well; just a button that looks like the standard rss icon that was made using Expression Blend that has a click event that sends a request to drupal to return my sites syndication link, as outlined above in the php code. Here is the XAML for the rss icon:

<Button Click="rss_Click">
    <Button.Template>
        <ControlTemplate TargetType="Button">
            <Canvas>
                <Rectangle Width="50" Height="50" Fill="Orange" RadiusX="5" RadiusY="5" />
                <Canvas>
                    <Ellipse Width="10" Height="10" Fill="White" Canvas.Left="10" Canvas.Top="30" />
                    <Path Stroke="White" StrokeThickness="5" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Data="M 15,20 a 15,15 90 0 1 15,15" />
                    <Path Stroke="White" StrokeThickness="5" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Data="M 15,10 a 25,25 90 0 1 25,25" />
               </Canvas>
          
</Canvas>
       </ControlTemplate>
    </Button.Template>
</Button>

I will post my full source code when I complete this entire replication of my site to silverlight. Until then, I will post the source for each control in a separate solution. If there is a specific drupal module that you would like converted to a silverlight control let me know and I will try to help you out! 

Share


Comments

Comments RSS RSS
  • RE: Silverlight and Drupal: Syndication  

    posted by TJS on Sep 29, 2008 18:01

    Much cleaner code, looks great.

  • RE: Silverlight and Drupal: Syndication  

    posted by frank on Oct 01, 2008 18:33

    Steam is truth!

  • RE: Silverlight and Drupal: Syndication  

    posted by Matt on Sep 18, 2009 17:00
    That is great! I will be using this on my VB6 site. Thank you so much for developing it!

Add Comment

 
 

   
  
  
   
Please add 8 and 5 and type the answer here:

Help us make SilverlightShow even better and win a free t-shirt. Whether you'd like to suggest a change in the structure, content organization, section layout or any other aspect of SilverlightShow appearance - we'd love to hear from you! Need a material (article, tutorial, or other) on a specific topic? Let us know and SilverlightShow content authors will work to have that prepared for you. (hide this)