Loading...

All project content is available for reading, but you need to be a member of the project for Subversion checkout of source code, or to create/modify any information.
Login if you are a member. Apply here to request membership (open to all).

Ticket #42 (assigned defect)

Opened 10 years ago

Last modified 10 years ago

Picturegalery doesn't read dynamic property

Reported by: lars.oyvind.bodahl@… Owned by: lars.oyvind.bodahl@…
Priority: major Component: PictureGallery
Keywords: Cc:

Description

When you try to create a new pictrue gallery page, the getRootFolders() always return "/Global". The page to be created always returns null for the RootFolders property.

If you edit an existing page, things works like normal.

Change History

comment:1 Changed 10 years ago by lars.oyvind.bodahl@…

Need to change getRootFolders() so it checks values on the parent page if we're dealing with a page to be created.

comment:2 Changed 10 years ago by simon@…

  • Owner changed from Sveinung to sveinung@…
  • Status changed from new to assigned

Re-eassigning to correct username.

comment:3 Changed 10 years ago by lars.oyvind.bodahl@…

Here are some of the things I tried. It's probably me doing something wrong, but I would appreciate if someone can help me find a solution :)

We need to change the protected string getRootFolders() method, to do a if(page.IsNewPage) check first. The current code doesn't work for new pages.

I thought it would be a simple problem to solve, but the only way I managed to extract the value from the dynamic property is to access it by its index...

DOES NOT WORK:
new page. Get value from parent page.
PageData parentPage = DataFactory.Instance.GetPage(page.CurrentPage.ParentLink);
EPiServer.Core.PropertyData rootFolderProperty = parentPageRootFolders? as PropertyData;
if (rootFolderProperty != null && rootFolderProperty.Value != null)

return rootFolderProperty.Value.ToString();


DOES NOT WORK:
PageData pd = DataFactory.Instance.GetDefaultPageData(parentPage.ParentLink, 40, AccessLevel.NoAccess);
if (pdRootFolders? != null)

return pdRootFolders?.ToString();


DOES NOT WORK:
DynamicPropertyCollection props = DynamicProperty.ListForPage(parentPage.PageLink);
if (propsRootFolders? != null && propsRootFolders?.InheritedValue != null)

return propsRootFolders?.InheritedValue;

WORKS:
if (props[4] != null && props[4].InheritedValue != null)

return props[4].InheritedValue;

comment:4 follow-up: ↓ 5 Changed 10 years ago by mari@…

  • Owner changed from sveinung@… to lars.oyvind.bodahl@…

I have a theory:

This happens when creating a new page, i.e there does not exist a published version of the PageData at the time you're trying to access the property value.

If you try to explicitly load the unpublished version, you should get hold of the property value.
The code should look similar to this:

//load unpublished version
PageReference unPublishedRef = new PageReference(CurrentPage.PageLink.ID, true);
PageData parentPage = DataFactory.Instance.GetPage(unPublishedRef); 
if (parentPage["RootFolders"] != null ) 
   return parentPage["RootFolders"] as string;

comment:5 in reply to: ↑ 4 Changed 10 years ago by lars.oyvind.bodahl@…

That works for regular page properties, but not for dynamic properties. I've tried fetching/creating pages in all the ways I know of, but nothing works :(


Replying to mari@bvnetwork.no:

I have a theory: This happens when creating a new page, i.e there does not exist a published version of the PageData at the time you're trying to access the property value. If you try to explicitly load the unpublished version, you should get hold of the property value.
The code should look similar to this: #!cs //load unpublished version PageReference unPublishedRef = new PageReference(CurrentPage.[wiki:PageLink].ID, true); PageData parentPage = DataFactory.Instance.[wiki:GetPage](unPublishedRef); if (parentPage[wiki:"RootFolders" RootFolders] != null ) return parentPage[wiki:"RootFolders" RootFolders] as string;

Note: See HelpUser/Tickets for help on using tickets.