Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Lars Skjoldby 11 posts 29 karma points
    Jan 12, 2011 @ 11:40
    Lars Skjoldby
    0

    Comments and user notifications

    Hello

    If you comment on a Wordpress blog, you can typically check if you want to be notified when new comments are posted. This promotes interactivity on the blog - which must be the basics in every blog.

    I can't see this feature in Blog 4 Umbraco or am I missing something?

    Can anyone help or guide me to a solution, so users get an e-mail whenever new is posted on a commented blog.

    Best regards

    Lars Skjoldby
    www.skjoldby.com

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    Jan 12, 2011 @ 11:50
    Dirk De Grave
    0

    Don't think it's included in blog4umbraco, and you'll need to do some custom coding to get notifications working...

    • Have to have a relation between a node (post) and a user so user can get notified for each new comment. Can use event model and the umbraco relation api for that.
    • Need event handlers that check for new comment nodes and sents out emails to people registered to be notified of new comments (Start here for more info)

    Hope this helps.

    Regards,

    /Dirk

  • Lars Skjoldby 11 posts 29 karma points
    Jan 12, 2011 @ 13:20
    Lars Skjoldby
    0

    Hello Dirk

    Thank you for a quick respond. It would be beyond my knowledge to code such an extension.

    I'm surprised that it isn't already available, since the dialog is such an esential element of blogging.

    Best regards,
    Lars

  • Nigel Wilson 939 posts 2061 karma points
    Aug 03, 2011 @ 19:56
    Nigel Wilson
    0

    Hi Lars

    To re-start your forum post - I too am wanting this functionality for my blog.

    As a quick fix it would be easy enough to write a new method that sends you an email upon a successful comment being added. I would envisage adding another AJAX call to usercontrols/Blog4Umbraco/AJAXCommentForm.ascx as follows:

     

    ...
    jQuery.post(url, { author: jQuery("#commentform #author").val(), email: jQuery("#commentform #email").val(), url: jQuery("#commentform #url").val(), comment: jQuery("#commentform #comment").val() },
    function(data){
    jQuery("#commentLoading").hide();
    jQuery("#commentPosted").show().removeClass("error");

    #####Add code here to send email ######

    if(data == 0){
    ... 

     

    I did read on the codeplex site for the blog package that this is being developed so the above could be seen as a temporary solution pending an updated release of the blog package.

    If you are interested drop me a note - [email protected] - I will be looking to add this to my site over the next week or two so would happily provide the code and instructions on adding to your site. 

    Regards

    Nigel 

  • Thijs 97 posts 117 karma points
    Oct 19, 2011 @ 16:53
    Thijs
    0

    Hi

    I needed the same functionality. I succesfuly implemeted this. Here's how I did it

    1. 1. Javascript in AjaxCommentForm (SendNotificationEmail.aspx is the template made in step 4)
      ///EMAIL NOTIFICATION CODE
      var posLastSlash = url.lastIndexOf('/');
      var posLastPoint = url.lastIndexOf('.');
      var nodeid = url.substring(posLastSlash+1, posLastPoint);
      $.ajax({
          type: "GET",
          url: "SendNotificationEmail.aspx",
          data: "nodeid="+nodeid
      });
      ///END EMAIL NOTIFICATION CODE
      
    2. 2. SendNotificationEmail.xslt
       
      <xsl:template match="/">
        <xsl:variable name="nodeid" select="umbraco.library:RequestQueryString('nodeid')"/>
        <xsl:if test="$nodeid != ''">
          <xsl:variable name="comments" select="BlogLibrary:GetCommentsForPost($nodeid)"  />
          <xsl:variable name="uniqueEmails" select="$comments/*/comment [not(email = preceding-sibling::*/email)]" />
      
          <xsl:variable name="newComment" select="$comments/*/comment [last()]"/>
          <xsl:variable name="postUrl" select="concat('http://thijs.domain.com',umbraco.library:NiceUrl($nodeid))"/>
          <xsl:variable name="bodyText">
            <xsl:text>
              There is a new comment on
            </xsl:text>
      
            <a href="$postUrl"></a>
          </xsl:variable>
      
          <xsl:for-each select="$uniqueEmails">
            <xsl:variable name="email" select="./email"/>
            <xsl:value-of select="umbraco.library:SendMail('[email protected]', 
                                                            $email, 
                                                            'New comment!',
                                                            $bodyText,
                                                            'true'
                          )"/>
          </xsl:for-each>
        </xsl:if>
      </xsl:template>
      
    3. 3. Developer>Marcros>Add Macro>linked the xslt file to a macro
    4. 4. Settings>Templates>Add Template>use the macro on this template

    I hope this helps people in the future

    Thijs

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies