Modify admin links

Topics: ASP.NET 2.0
Jan 23, 2011 at 7:23 PM

Im tying to modify the method  "protected string AdminLinks" in CommentViewBase so that it doesnt return the ip adress, but it still does even after i remove the line of code completely.

 

Anyone know why?

Jan 24, 2011 at 5:40 PM

Bump

Coordinator
Jan 24, 2011 at 7:34 PM

Inside of your theme folder, there is CommentView.ascx that inherit and override that base class you changed. You should not change base, modify view in your theme instead.

Jan 24, 2011 at 8:22 PM
Edited Jan 24, 2011 at 8:24 PM

The only thing i see that points to the class is :

 

<%= AdminLinks %>

 

How can i modify this? I want to change it so it doesnt show the ip.

 

Here is the full code:

 

<%@ Control Language="C#" EnableViewState="False" Inherits="BlogEngine.Core.Web.Controls.CommentViewBase" %>

<link rel="stylesheet" href="style.css" type="text/css" />
<div id="id_<%=Comment.Id %>" class="comment">
    <div class="topRow"><%= Comment.Website != null ? "<a href=\"" + Comment.Website + "\">" + Comment.Author + "</a>" : Comment.Author %> wrote:</div>
    <div class="clearer"></div>
    <div class="contentRow"><div class="content"><%= ResolveLinks(Comment.Content) %></div><div class="gravatar"><%= Gravatar(80)%></div></div>
    <div><div class="flag"><%= Flag %> &nbsp</div><div class="author">| <%= ReplyToLink %> <%= AdminLinks %></div><div class="date"> <%= Comment.DateCreated.ToString("MMMM dd yyyy HH:mm") %></div></div> 
    <div class="clearer"></div> 
</div>
<div class="comment-replies"
     id="replies_<%=Comment.Id %>"
     <%= (Comment.Comments.Count == 0) ? " style=\"display:none;\"" : "" %>>
 
    <asp:PlaceHolder ID="phSubComments" runat="server" />
 
</div>

Coordinator
Jan 24, 2011 at 10:13 PM

Ye, unfortunately you can't override this one. My guess is you not recompiling after changing code - it is in the core library and DLL has to be recompiled to make any effect on your site. I just commented out these 3 lines and IP gone:

//sb.AppendFormat(
//    " | <a href=\"http://www.domaintools.com/go/?service=whois&amp;q={0}/\">{0}</a>", 
//    this.Comment.IP);

Still, you might want to split on "|" and remove second link (IP) rather than mess with core library, it will be really hard to upgrade when you make changes like that. So, in your theme's CommentView:

<%@ Control Language="C#" EnableViewState="False" Inherits="BlogEngine.Core.Web.Controls.CommentViewBase" %>
<%
    List<string> myList = new List<string>(this.AdminLinks.Split(("|").ToCharArray()));
    myList.RemoveAt(2); // removing IP
    string newAdmin = string.Join("|", myList.ToArray());
 %>
Then just use "newAdmin" instead of AdminLinks.

Jan 25, 2011 at 7:57 AM

What do you mean by upgrade? I already editied some of the other core elements.

 

Anyway, back to the original question, what if i want to add a prefix to the information? Like:

Ip Adress: ......... Name: .............

 

Im not at home right now, but i think i have the idea.

 

<%@ Control Language="C#" EnableViewState="False" Inherits="BlogEngine.Core.Web.Controls.CommentViewBase" %>
<%
List<string> myList = new List<string>(this.AdminLinks.Split(("|").ToCharArray()));
myList.Append ... watever... (something like this);
myList.RemoveAt(2); // removing IP
string newAdmin = string.Join("|", myList.ToArray());
%>

And then rejoin it at the end.



Althou i would still modify the core class.
Jan 25, 2011 at 6:00 PM

Is it actually possible to use a list in ascx page?