Disqus Recent Comments, Top Commenters, and Most Discussed Widget for BlogEngine.NET

by filip 20. February 2012 18:11

After I switched to Disqus comments, I noticed that my recent comments widget no longer worked. So I wrote a new widget that adds some JavaScript to the web page which includes the recent comments (and a few other options, if desired) when using Disqus.

The widget is is available on the blogengine.net gallery website.

Known issues
-The character limit when using the combination look doesn't seem to be working. I need to look into this more, but right now it seems Disqus is ignoring the character count.

Tags: , ,

Web Development

New Comment System

by filip 17. February 2012 12:13

The blog now uses a new comment system - Disqus.

I upgraded to BE v2.5, and found various instructions on how to move to Disqus... including these.

There was one problem, however. The instructions state that on post.aspx, JavaScript needs to change to the following:

<script type="text/javascript">
    var disqus_title = '<%=Post.Title %>';
    var disqus_identifier = '<%= Post.Id.ToString() %>';
    var disqus_url = '<%= Post.AbsoluteLink %>';
    var disqus_developer = '<%= BlogEngine.Core.BlogSettings.Instance.DisqusDevMode ? 1 : 0 %>';
    (function () {
        var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
        dsq.src = 'http://<%=BlogEngine.Core.BlogSettings.Instance.DisqusWebsiteName %>.disqus.com/embed.js';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();
</script>

However, that is not accurate and will result in errors.  The correct code needs to reference Page, and not Post.

<script type="text/javascript">
    var disqus_title = '<%=Page.Title %>';
    var disqus_identifier = '<%= Page.Id.ToString() %>';
    var disqus_url = '<%= Page.AbsoluteLink %>';
    var disqus_developer = '<%= BlogEngine.Core.BlogSettings.Instance.DisqusDevMode ? 1 : 0 %>';
    (function () {
        var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
        dsq.src = 'http://<%=BlogEngine.Core.BlogSettings.Instance.DisqusWebsiteName %>.disqus.com/embed.js';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();
</script>

If the above is not changed, the blog will throw the following error:

page.aspx(14): error CS0120: An object reference is required for the non-static field, method, or property 'BlogEngine.Core.Post.Title.get'

One more change needs to be done if the above takes place. In archive.aspx.cs, the following line:

comments.InnerHtml = string.Format("<span><a href=\"{0}#disqus_thread\">{1}</a></span>", post.PermaLink, Resources.labels.comments);

needs to change to:

comments.InnerHtml = string.Format("<span><a href=\"{0}#disqus_thread\">{1}</a></span>", post.AbsoluteLink, Resources.labels.comments);

The change above will allow the Archive to correctly display the number of comments and reactions to each post.

Tags: , , ,

Web Development

Change combobox background color in AS3

by filip 8. November 2011 11:30

I needed to change the background color of the text region of a flash combobox - using AS3 at runtime.

Styles for some reason were not working.  The solution was to directly address the textfield property and change its background color.  Here's an example:

cbo.textField.textField.background = true;
cbo.textField.textField.backgroundColor = 0xDEDE29;

Tags: ,

Web Development

Flash Combobox setStyle works in Test (debug) and not in Publish (swf)

by filip 25. August 2011 09:15

I tried to customize the combobox ( AS3 ), and everything was working fine by using cbo.setStyle( "embedFonts" ) and cbo.setStyle( "textFormat" ) while testing the movie.  However, when I published the SWF, the styles were no longer working.

It seems like setStyle doesn't really work properly for comboboxes for some reason.  The solution was to apply the setStyle to the textField inside the combobox, and not to the combobox itself.

For example, this doesn't work: 

 

cbo.setStyle( "embedFonts", true );
cbo.setStyle( "textFormat", tf );

 

but this works:

cbo.textField.setStyle( "embedFonts", true );
cbo.textField.setStyle( "textFormat", tf );

 

Tags: , ,

Web Development

Change the color of the trendline value in FusionCharts v3 for Flash

by filip 14. October 2010 15:07

It seems like FusionCharts does not support changing the color of a trendline via the TRENDVALUES style application.  The color always seems to default to the color of the trendline.

The fix to this issue involves modifying the source of the XYPlotChart.as file (you’ll need the source for fusioncharts to be able to do this).

Search the file for the following line (it should be line 1789):

trendFontObj.color = this.trendLines [i].color;

Right afer this line, paste the following code:

if ( this.styleM.getTextStyle (this.objects.TRENDVALUES).color != undefined )
               {
                    trendFontObj.color = this.styleM.getTextStyle (this.objects.TRENDVALUES).color;
                }

There may be a more “elegant” way of doing this, but the code above will enable you to change the color of trend value lines by using styles in fusioncharts.

Tags: ,

Web Development

Bloodforge Band

Looking for the Bloodforge band site? Click here.

About Filip Stanek

Death Note Pic I'm a developer at ACG in Cincinnati, OH. I like ASP.NET, Flash, and other web technologies, & enjoy playing chess, video games, etc.

Currently playing:

Disqus

Month List