Hello again. I'm truly stumped this time. I have a structure of media folders like this -
Main Gallery Folder > Sub Folders > The Media Items (Photos)
And I have a Razor macro that is supposed to go through all the photos (regardless of which folder they are in) and pull the twelve newest items. Here's the simplified code -
// 1129 is the id of the "main gallery folder" dynamic mediaFolder = new umbraco.MacroEngines.DynamicMedia(1129);
It was working fine before, but now, when I add new media items in the subfolders, they don't show up... If I move them directly below the "main gallery folder" they do show up!
So why, all of a sudden, is the Descendants method not searching the subfolders? Thanks for any help!
Yes, that should work. But it doesn't pull any new images that I upload.
I did some more digging to find out why it's stopped working "all of a sudden". Turns out that it has to do with the subfolders themselves. The existing subfolders I created a while ago, during a slightly older version of Umbraco. But if I upload images into new folders that I create now, then they don't show up in the query.
Is there a way to go behind the scenes and see if there is some difference with the folder structure?
That's the basic structure I have too. All my docTypes are the defaults.
Further narrowed the issue down a bit... I remembered that I started using a new user account a while ago. At the beginning I was using the built-in admin account. Then I made another account, with admin permissions.
So when I create media folders using my new account, the images don't show up in the query. When I log in using the built-in account and update the folders, then the images will show up.
But the basic problem is that when I create or update a media folder with any account besides the default, first admin account, the contents don't show up in queries.
Also, I should mention that this is Umbraco 6.1.6.
The items only disappear if I use a specific account to create / update. Also, it displays the same behavior in development and on the production server.
But I suppose it's worth a shot... What is Examine and how do I delete the indices?
Examine is an underlying search engine and is used by DynamicMedia for caching
Examine indexes are found in \App_Data\TEMP\ExamineIndexes\
Stop your application pool (otherwise the indexes are locked and cannot be deleted)
Delete all sub folders and contents in the ExamineIndexes folder
Restart application pool and the indexes will be recreated
See if your items turn up
Worth a try but if the same thing is happening in both development and production it is unlikely this is the problem.
One other thing to try is to check that when you create folders in media that you then click the properties tab and then click the save button as the create action only doesn't fully save and the save button isn't shown in the default "contents" view.
The problem went away after a while... So no clue.
But thanks for the help. I think going to properties and clicking save again was the fix. If that's by design, then it'd be nice if there were some indication that the media folder is not published.
Getting media descendants in folder>subfolder
Hello again. I'm truly stumped this time. I have a structure of media folders like this -
Main Gallery Folder > Sub Folders > The Media Items (Photos)
And I have a Razor macro that is supposed to go through all the photos (regardless of which folder they are in) and pull the twelve newest items. Here's the simplified code -
It was working fine before, but now, when I add new media items in the subfolders, they don't show up... If I move them directly below the "main gallery folder" they do show up!
So why, all of a sudden, is the Descendants method not searching the subfolders? Thanks for any help!
Hi Chris,
So you want to display 12 Latest Image present regardless of the Folder it lies ?
@using umbraco @using System; @using umbraco.MacroEngines; @using umbraco.BusinessLogic @using System.Collections.Generic; @using umbraco.cms.businesslogic.media; @{ dynamic mediaFolder = new DynamicMedia(1143); foreach(dynamic photo in mediaFolder.Descendants("File").OrderBy("CreateDate, desc").Take(12)){ @photo.Name <br/> } }
Sorry again here it is and works well for me
Yes, that should work. But it doesn't pull any new images that I upload.
I did some more digging to find out why it's stopped working "all of a sudden". Turns out that it has to do with the subfolders themselves. The existing subfolders I created a while ago, during a slightly older version of Umbraco. But if I upload images into new folders that I create now, then they don't show up in the query.
Is there a way to go behind the scenes and see if there is some difference with the folder structure?
Weird i have the following working under v4.11.8 and using this structure under Media Section
Are you using the Media Type "Image" ? or any other within the folder ?
That's the basic structure I have too. All my docTypes are the defaults.
Further narrowed the issue down a bit... I remembered that I started using a new user account a while ago. At the beginning I was using the built-in admin account. Then I made another account, with admin permissions.
So when I create media folders using my new account, the images don't show up in the query. When I log in using the built-in account and update the folders, then the images will show up.
Is there a way to fix that?
Sorry to confuse the issue with all the posts.
But the basic problem is that when I create or update a media folder with any account besides the default, first admin account, the contents don't show up in queries.
Also, I should mention that this is Umbraco 6.1.6.
I wonder if this issue is causing your problem as DynamicMedia is using Examine under the hood.
Maybe try stopping you application pool, delete the Examine indexes so they are refreshed on start and see if the items appear?
Jeavon
The items only disappear if I use a specific account to create / update. Also, it displays the same behavior in development and on the production server.
But I suppose it's worth a shot... What is Examine and how do I delete the indices?
Hi Chris,
This is very odd behaviour going on.
Examine is an underlying search engine and is used by DynamicMedia for caching
Examine indexes are found in \App_Data\TEMP\ExamineIndexes\
Worth a try but if the same thing is happening in both development and production it is unlikely this is the problem.
One other thing to try is to check that when you create folders in media that you then click the properties tab and then click the save button as the create action only doesn't fully save and the save button isn't shown in the default "contents" view.
Jeavon
The problem went away after a while... So no clue.
But thanks for the help. I think going to properties and clicking save again was the fix. If that's by design, then it'd be nice if there were some indication that the media folder is not published.
is working on a reply...