Some extension not working?

Feb 17, 2009 at 7:47 PM
Edited Feb 17, 2009 at 7:48 PM
Hi, I’m having trouble with some of the extensions. I’m creating a new theme and wanted to use Breakpost but it doesn’t seem to work – it just shows the text [more] in all post views. I then tried adding a comment which should have been e-mailed to me and this didn’t work either – although it has done in the past and the settings page shows successful set-up.

 I started to think a reference or something to extensions has been accidently deleted but some of them still work – BBCode and Smilies work fine and everything in the extension manager is set to enabled.

 Does anyone know why these two extension would stop working?

Coordinator
Feb 17, 2009 at 8:13 PM
Do you see anything else besides [more] in all post views?  Hopefully the text leading up to [more] is still there?

Have you modified the post.aspx.cs file in the root of your blog?  That's the page that is setting the 'serving location' to 'SinglePost' so the BreakPost extension knows to remove [more] and show the entire blog post.

=== from post.aspx.cs ===
postView.Location = ServingLocation.SinglePost;

In your theme, are you changing the "Location" property anywhere ... like in the PostView.ascx or PostView.ascx.cs file?

Regarding emails when someone leaves a comment, by default, if you're logged into your blog and leaving a comment, the SendCommentMail extension won't send an email to you.  Only if the person leaving the comment is not logged into the blog will SendCommentMail send an email to you.  Not sure if you were aware of this ...
Feb 17, 2009 at 9:00 PM
Edited Feb 17, 2009 at 9:01 PM
I get everything in the post – the text before and after more, with [more] shown in the middle. I hadn’t played about with post.aspx but to be safe I downloaded a fresh copy of blogengine and copied both post.aspx and the .cs file into my site and it makes no difference. I haven’t changed the location anywhere.

I did originally fall for the e-mail thing but realised this could be the problem, logged out and it still didn’t work.

I think my ‘tinkering’ has caused an issue somewhere but I cannot work out were. Seeing as most of the work I’ve done is CSS related it may be quicker for me to start again with the style sheet added and then add the classes! The fresh copy of blogengine works fine on the server.

Thanks

Feb 17, 2009 at 9:46 PM
I have tracked the [more] issue down to the code behind, but cannot figure out how to solve it. There was a similar issue with one of the themes as described here - http://www.nyveldt.com/blog/post/Curiously-Green-Theme-Update.aspx#comment

With code behind I was referencing the content with <%=Post.Content %>. If I use no code behind and the normal <asp:PlaceHolder ID="BodyContent" runat="server" /> the more extension works.
So the question is how to use code behind with the correct <asp:PlaceHolder...>  ?




Coordinator
Feb 17, 2009 at 9:52 PM
If you just use the placeholder without Post.Content, does it work?  It looks like it should work ... regardless if you have a code behind.  The standard theme, for example, uses the placeholder without a code behind.

The Curiously Green theme uses "Post.Content" which doesn't work with the BreakMore extension because Post.Content retrieves the actual content, ignoring any modifications extensions like BreakPost do.

Actually, Post.Content should never really be used in the PostView.ascx file because of these problems.
Feb 18, 2009 at 7:16 AM
When using <asp:placeholder....> with code behind you end up with no post being shown at all. This is the reason I started using Post.Content but this now looks like it's causing the problem with extensions.

For what reasons would asp:placeholder not work with code behind? Could I be missing a reference somewhere for this?

Coordinator
Feb 18, 2009 at 3:59 PM
The two requirements I can see to get the content to be outputted in the PlaceHolder is to make sure the PlaceHolder has an id of "BodyContent" with a runat="server" tag ...

=== PlaceHolder tag from Standard theme's PostView.ascx ===
<asp:PlaceHolder ID="BodyContent" runat="server" />

The second requirement is that your PostView.ascx file inherits from the PostViewBase class.  It's the PostViewBase class that is inserting the content into the BodyContent placeholder.

There's two ways to ensure this.  If you don't have a code behind for PostView.ascx, then just make sure you have an Inherits attribute in your PostView.ascx <%@ Control %> directive ...

=== Example from Standard theme's PostView.ascx ===
<%@ Control Language="C#" AutoEventWireup="true" EnableViewState="false" Inherits="BlogEngine.Core.Web.Controls.PostViewBase" %>

If you do have a code behind file for PostView.ascx (e.g. PostView.ascx.cs), then your Inherits attribute in PostView.ascx will be the class name in PostView.ascx.cs.  You would then want to make sure that your code behind file is inheriting from PostViewBase.  This can be achieved like this ...

=== PostView.ascx ===
<%@ Control Language="C#" AutoEventWireup="true" EnableViewState="false" CodeFile="PostView.ascx.cs" Inherits="MyPostViewCodeBehind" %>

=== PostView.ascx.cs ===
public class MyPostViewCodeBehind : BlogEngine.Core.Web.Controls.PostViewBase
Feb 18, 2009 at 6:15 PM
Thanks Ben but I have all those references correct and still no post shown if the <asp:placeholder....> format is used. I have just noticed a warning in visual studio in the code behind....

public partial class themes_Flutter_PostView : BlogEngine.Core.Web.Controls.PostViewBase
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}


It states 'Page_Load hides inherited member 'blogengine.Core.Web.Controls.PostViewBase.Page_Load'. Ue new keyword if hiding was intended'
Could this be the problem?


Coordinator
Feb 18, 2009 at 6:45 PM
Yes, that does appear to be the problem ... nice catch.  Your Page_Load event is hiding the Page_Load event in PostViewBase where the BodyContent placeholder is populated with content.  If the PostViewBase's Page_Load event was marked as virtual, then you could use the "override" keyword on your Page_Load event and then do a base.OnLoad(e) to invoke the PostViewBase's Page_Load event.  Unfortunately, the Page_Load event in PostViewBase isn't marked as virtual, but you can still manually call the PostViewBase's Page_Load event.

Somewhere in your Page_Load event, add:

base.Page_Load(sender, e);
Coordinator
Feb 18, 2009 at 6:49 PM
Also, you can optionally follow the recommendations by Visual Studio by adding the "new" keyword to your Page_Load event to make it clear you are hiding the PostViewBase's Page_Load event ...

protected new void Page_Load(object sender, EventArgs e)
Feb 18, 2009 at 9:53 PM
Great stuff ! That works a treat and my breakpost now works fine. 

Still struggling with the e-mail though. I changed the to/from lines as per discussions in other posts and I now get some mails - but it only sends copies to the two last comments!!

I will get there in the end.

Thanks for your help.