EpiServer - simple plugin to lookup page from PageFiles ID

Each page in EPiServer has a directory in VPP PageFiles (created when first uploading a file to it) directory.


For example: \\myFileServer\VPP\PageFiles\35566\my_pic.gif

However, the ID after PageFiles has nothing to do with the page id in EPiserver.

You can get the ID from the page using the CurrentPage["PageFolderID"]

Here is a very simple and small plug-in (action window section) to be used to quickly find the page for a specific PageFiles ID. (you have to provide your own loading.gif though)

Markup:


<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FindPageFromPagefileId.ascx.cs"
    Inherits="Additions.Plugins.FindPageFromPagefileId" %>

<h1>
   Find page from pagefile ID</h1>
<br />
<p>
    PageFiles ID</p>
    <asp:TextBox runat="server" Width="90"  ID="txtPageFileID"></asp:TextBox>

    <asp:Button runat="server" ID="Button1" Text="Leta sida"
    onclick="Button1_Click" OnClientClick="loading()" />

    <br /><br />
    <div id="loader" style="display:none;">
        <image src="/UI/Images/loading.gif" />
    </div>
    <br />
    <asp:HyperLink runat="server" ID="linkPage"></asp:HyperLink>
    <p>
    <asp:Label runat="server" ID="msg" ForeColor="Red"></asp:Label>
    </p>

    <script type="text/javascript">
        function loading() {
            document.getElementById('loader').style.display = "block";
        }
    </script>

And codebehind:


[GuiPlugIn(DisplayName = "Find page from pagefiles ID", Area = PlugInArea.ActionWindow, 
Description = "Find page using specific pagefiles ID"
Url = "~/UI/Additions/Plugins/FindPageFromPagefileId.ascx", SortIndex = 60)]
    public partial class FindPageFromPagefileId : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (txtPageFileID.Text.Length < 1)
                return;
            IList<PageReference> pages = DataFactory.Instance.GetDescendents(PageReference.RootPage);
            linkPage.Text = "<span style=\"color:red\">Page could not be found</span>";
            linkPage.NavigateUrl = "";

            foreach (PageReference pr in pages)
            {
                PageData pd = DataFactory.Instance.GetPage(pr);

                if (pd != null && pd.Property["PageFolderID"] != null)
                {
                    object pagefilesID = pd.Property["PageFolderID"].Value;

                    if (pagefilesID != null && pagefilesID.ToString() == txtPageFileID.Text)
                    {
                        linkPage.Text = "&raquo; " + pd.PageName;
                        linkPage.NavigateUrl = pd.LinkURL;
                        break;
                    }
                }
            }
        }
    }

1 kommentar:

  1. Casinos Near Harrah's Casino & Resort, Las Vegas, Nevada
    A 거제 출장안마 map 아산 출장마사지 showing 영주 출장샵 casinos 김해 출장샵 and other gaming facilities located near Harrah's Casino & Resort, Las 창원 출장안마 Vegas, Nevada, United States.

    SvaraRadera