Fredrik Haglund has a quite good article about Page Folders in his blog http://blog.fredrikhaglund.se/blog/2008/09/05/page-folders-and-uploading-of-files-in-episerver/
I think It's written for an earlier version of EPiServer but I think you can get the basics in the article and the comments.
That is nice article yes, I can get folder id, but not that is the issue, I want get id for the page who I editing now, if I'm open 2 pages from one type and one in edit mode from the same type I want to get just folder id of page who I editing now
I don't really understand what you mean with "type" and "editing now".
Where are you trying to use this? On a Template or in some kind of plugin?
maybe I can't explain very well I'm sorry,
Here the example:
I have archive pages with uploaded pdf files, must to get only pdf files who are in edit mode, to do something with them.
string[] pdfFiles = GetFileNames(paths + folderId.ToString(), "*.pdf"); // I create array with all files, paths - PageFiles folder in VPP and folderId - Page folder id, I has made paths in VPP programmatically and put files there.
and then I loop through the all files like this:
for (int i = 0; i < pdfFiles.Length; i++ )
{
string fullpath = paths + CurrentPage.Property["PageFolderID"].Value + "\\" + pdfFiles[i];
}
and I must build variable fullpath who is for page in edit mode only, I try to get it like this:
for (int i = 0; i < pdfFiles.Length; i++ )
{
if (IsInEditMode() == true)
{
fullpath = paths + CurrentPage.Property["PageFolderID"].Value + "\\" + pdfFiles[i];
}
else
{
return;
}
}
IsInEditMode() is method who check if I'm in edit mode but that code get the pages in view and edit mode, and I don't want that
Could you explain what GetFileNames do? Since that seems to be the method that brings you all the files?
Could you also show what the IsInEditMode() looks like? There are some ways to find out whether You are in edit mode and I guess that your implementation does not look at your pdf files so either it will return TRUE or FALSE on each iteration of pdfFiles.Length.
GetFileNames method get all files
private static string[] GetFileNames(string path, string filter)
{
string[] files = Directory.GetFiles(path, filter);
for (int i = 0; i < files.Length; i++)
files[i] = Path.GetFileName(files[i]);
return files;
}
and IsInEditMode is very simple bool method for check if I'm in edit mode
public bool IsInEditMode()
{
bool isInEditMode = false;
if (HttpContext.Current.Request.UrlReferrer != null)
{
isInEditMode = Regex.IsMatch(HttpContext.Current.Request.UrlReferrer.AbsoluteUri, "/admin/|/edit/", RegexOptions.IgnoreCase);
}
return isInEditMode;
}
Ok, I think it's better that you find the page you are looking at in edit mode, and use this from Fredrik's blog
HostingEnvironment.VirtualPathProvider.GetDirectory(virtualPathFromFolderId) as UnifiedDirectory;
Here you should be able to find all Files and be able to filter out files with a filename that ends with .pdf
Hi, I have an issue, for geting the current page folder property id but for the page who is only in edit mode.
Id I get that way: CurrentPage.Property["PageFolderID"].Value
I want to get :
if(CurrentPage.Property["PageFolderID"].Value is in edit mode){
CurrentPage.Property["PageFolderIDForThePageInEditMode"].Value
//do something
}
Best Regards!