Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsBlogBlogHow to add custom meta-description tag to a blog postHow to add custom meta-description tag to a blog post
Previous
 
Next
New Post
4/2/2010 2:32 AM
 
Hello,

I am using the basic blog module on DNN and I need to add custom meta-description tags to every blog entry. Does anyone know how to do this?

Thank you in advance.

MK
 
New Post
4/5/2010 4:10 PM
 

Are you hoping to have the same custom tag on every entry, or the option to put a unique tag value on each entry?

 
New Post
4/5/2010 4:15 PM
 
Hello and thank you for your response. I need to add custom meta-description tags to every blog entry (a unique tag value on each blog entry). Thanks
 
New Post
4/5/2010 4:25 PM
 

Sounds to me like you would have to hack an aspx code change for this to work.

 
New Post
7/14/2010 8:36 AM
 
Hi MK - having read this and then spent all morning figuring it out (I needed to do this for a client) I thought I'd chip in and help you.  The way I did this may not be the best, but it works.

The basic idea is... make a blog post template page (e.g. blogpost.ascx) and don't use that template for anything other than the blog posts.  Add a page load method to get the url (so you can get the entryID) and use that entryID to retrieve some data related to that entry from the db (I took the summary i.e. Description field).  Overwrite the existing metadescription with that data.

So, in your template file you're using add:

<script runat="server">

Public ReadOnly Property  BasePage() As DotNetNuke.Framework.CDefault
    Get
        Return DirectCast((Page), DotNetNuke.Framework.CDefault)
    End Get
End Property

Private Sub Page_Load(ByVal sender As System.Object, ByVal e _
    As System.EventArgs) Handles MyBase.Load
  
    ' Olly method to get the summary from the DB and set as the MetaDescription
    Dim description As String = ""
    Dim objConn As New SqlConnection(ConfigurationManager.ConnectionStrings("YourDBConnectionString").ConnectionString)
    Dim sqlCmd = New SqlCommand()

    ' Get the actual url and take just the entry ID
    Try
        Dim entryID As String = Request.Url.ToString
        entryID = entryID.Substring(entryID.LastIndexOf("=") + 1)

        ' Get the description field from the blog page
        objConn.Open()
        Dim strSql As String = "SELECT TOP 1 Description FROM dnn_Blog_Entries WHERE EntryID = " & entryID
        sqlCmd.Connection = objConn
        sqlCmd.CommandText = strSql
        sqlCmd.CommandType = CommandType.Text

        Dim dr As SqlDataReader = sqlCmd.ExecuteReader()
        If dr.Read Then
            description = dr("Description").ToString()
        End If
        dr.Close()
    Catch ex As Exception
    ' Close up
    Finally
        If objConn.State = ConnectionState.Open Then
            objConn.Close()
        End If
        objConn.Dispose()
        sqlCmd.Dispose()
    End Try
    
    '  Knock off the &lt; etc rubbish
    description = description.Substring(9, description.Length - 19)
    
    ' Write the description to the meta description
    BasePage.Description = "News | " & description
End Sub

</script>

That's pretty much it.  It's a hack but it now means each blog post has a unique meta description.  You can use the same method to mess around with title and keywords etc. e.g. BasePage.Description = whatever

Hope this helps - you'll probably need to mess about with it but it's certainly possible

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsBlogBlogHow to add custom meta-description tag to a blog postHow to add custom meta-description tag to a blog post


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out