Delete a page in portraitpress theme?

Topics: Controls, Themes
Feb 22, 2009 at 9:50 PM
Edited Feb 22, 2009 at 9:57 PM
I cannot seem to find the delete link on a page after logging in, under pages in the control panel I click on the #pages at the top left which allows editing, but how do I delete a page.  Thank you.
Coordinator
Feb 22, 2009 at 9:59 PM
Click on the link to view the page (alternatively, Save the page in the editor which will take you to the page), then you should have Edit/Delete links when you're on the actual Page.
Feb 22, 2009 at 10:10 PM
I agree the Edit/Delete links should be there but they are not to be seen.
Feb 22, 2009 at 10:13 PM
Edited Feb 22, 2009 at 10:20 PM
The only way I can find to delete a page is in VWD.
Coordinator
Feb 22, 2009 at 10:37 PM
I have the Portrait Press theme installed on my computer.  I do have Edit | Delete links.

These Edit | Delete links aren't even part of this theme, or any theme.  The Edit | Delete links come from the page.aspx file in the root of your blog.  If you switch to a different theme (the Standard theme, for example), do you see the Edit | Delete links when viewing the same page, and while logged in?
Feb 22, 2009 at 10:44 PM
I now realize I should have edited the title of my post, I do not see the edit/delete links anywhere with any theme, I think I may have added something to the page.aspx and then deleted it later and probably deleted the links with it. I'll try to fix it now that I know what the problem is. Thanks
Feb 22, 2009 at 10:47 PM
This is the page.aspx code, what am I missing?

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="page.aspx.cs" Inherits="page" %>
<asp:content id="Content1" contentplaceholderid="cphBody" runat="Server">
  <div id="page">
    <h1 runat="server" id="h1Title" />
    <div runat="server" id="divText" />    
    <%=AdminLinks %>
  </div>
</asp:content>

Coordinator
Feb 22, 2009 at 10:54 PM
The Edit/Delete links come from <%=AdminLinks %> (which you have).  And "AdminLinks" is defined in the page.aspx.cs file, also in the root of your blog.  Here's the AdminLinks code I have in my page.aspx.cs file ...

public string AdminLinks
{
    get
    {
        if (System.Threading.Thread.CurrentPrincipal.Identity.IsAuthenticated)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("<div id=\"admin\">");
            sb.AppendFormat("<a href=\"{0}admin/Pages/Pages.aspx?id={1}\">{2}</a> | ", Utils.RelativeWebRoot, this.Page.Id.ToString(), Resources.labels.edit);
            sb.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"if (confirm('Are you sure you want to delete the page?')) location.href='?deletepage={0}'\">{1}</a>", this.Page.Id.ToString(), Resources.labels.delete);
            sb.AppendLine("</div>");
            return sb.ToString();
        }

        return string.Empty;
    }
}
Feb 22, 2009 at 11:03 PM
I cut and pasted your code, logged in, went to pages in control panel, clicked on pages, clicked on #pages in the top left corner, opened the page and still no edit/delete links, go figure.
Coordinator
Feb 22, 2009 at 11:10 PM
Two ideas come to mind ...

The <div> tag where the Delete | Edit links are has an ID of "admin".  Maybe in your CSS file, you are suppressing the content for #admin?  You might have a display: none in there or visibility: hidden or something along those lines ...

If that's not the case, as a test, try changing the last part of that code above.

Replace

return string.Empty;

With

return "not logged in";

Then, do you at least see "not logged in" where the Delete | Edit links might be?
Feb 22, 2009 at 11:22 PM
It won't accept "not logged in";
Coordinator
Feb 22, 2009 at 11:35 PM
So here's what it should look like (in its entirety).  I also added return "anything!"; at the top.  So, see if you see "anything!" when you pull up the page in your browser.

public string AdminLinks
{
    get
    {
        return "anything!";

        if (System.Threading.Thread.CurrentPrincipal.Identity.IsAuthenticated)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("<div id=\"admin\">");
            sb.AppendFormat("<a href=\"{0}admin/Pages/Pages.aspx?id={1}\">{2}</a> | ", Utils.RelativeWebRoot, this.Page.Id.ToString(), Resources.labels.edit);
            sb.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"if (confirm('Are you sure you want to delete the page?')) location.href='?deletepage={0}'\">{1}</a>", this.Page.Id.ToString(), Resources.labels.delete);
            sb.AppendLine("</div>");
            return sb.ToString();
        }

        return "not logged in";
    }
}
Feb 22, 2009 at 11:40 PM
Cut and pasted the code and still no links, also there is a green line under if and the comment unreachable code.
Coordinator
Feb 22, 2009 at 11:48 PM
The green squigly line is expected.  That's there because the rest of the code can't be reached.  Making these changes was just a temporary test.  With this temporary code, there won't be any links.  All that would be outputted is "anything!" (without the quotes).

For now, leave that modified, temporary code in page.aspx.cs.  Open up the page again in your browser and do a View Source.  See if you can find the "anything!" in there.  One possiblity is there is an unclosed HTML tag in your page's HTML that is hiding these admin links (and also hiding the anything! text).
Feb 22, 2009 at 11:54 PM
I could not find the "anything" anywhere doing a page source.

One thing when I pasted your code in the .cs page, I had t add another }
Coordinator
Feb 23, 2009 at 12:00 AM
Just wanted to confirm, the URL of your page is something like /page/pageName.aspx ?  This is a page and not a post, right?

I would maybe try creating a new, simple test page to see if you see anything! on the new page.  

Back in your page.aspx file, you could try putting some text around <%= AdminLinks => to see if that shows up.  Example:

test <%=AdminLinks %> testing
Feb 23, 2009 at 12:00 AM
Just to try something, I replaced the page.aspx and the .cs page with new ones from the blogengine download and still no edit/delete links.
Feb 23, 2009 at 1:26 AM
Yes it is a page and not a post. I have tried creating a new page and still no links or anything.
Coordinator
Feb 23, 2009 at 2:18 AM
Not holding back, if you replace your entire page.aspx file with what's below, do you see any of the new stuff (test1, test2, test3, test4, test5 or test6)?

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="page.aspx.cs" Inherits="page" %>
<asp:content id="Content1" contentplaceholderid="cphBody" runat="Server">
  test1 ...
  <div id="page">
    test2 ...
    <h1 runat="server" id="h1Title" />
    test3 ...
    <div runat="server" id="divText" />    
    test4 ...
    <%=AdminLinks %>
    test5 ...
  </div>
  test6 ...
</asp:content>
Feb 23, 2009 at 2:59 AM
Edited Feb 23, 2009 at 3:01 AM
Yes, the test1 and others are now on my pages.
Feb 23, 2009 at 3:06 AM
Well you are not going to believe this, I now see the edit/delete links on my pages, the problem was I was going though the control panel, clicking on pages, then in the upper left clicking on the #pages and I could then edit the page, it was there I was looking for the delete link in the wrong area. Thanks for your help.