Try our conversational search powered by Generative AI!

Using "Fetch data from page in EPiServer CMS" programmatically

Vote:
 

Hi,

I'm probably not using this functionality as it was intended, but I was hoping that someone could explain what I'm doing wrong!

I created a page in what you could describe as a "templates" folder. This contains a page that I've populated with content that I want to update all over the place by only editing it once.

I then used the copy and paste facility to copy and paste that page elsewhere in my website's hierarchy.

I then edited the page, and in the "shortcut / external link" tab, chose "Fetch data from page in EPiServer CMS".

Now I am accessing that content programmatically, but referencing the PageLink of the copied page. Why, when I change the original page, is the content I'm fetching from the copy not updating as well?

I might've got this bit of functionality completely the wrong way around!

Cheers for any help,

Karl 

#31471
Jul 31, 2009 18:40
Vote:
 

I think the shourtcut/external link only affects how the page is displayed. So if you look at the PageData object in codebehind you will still get the real values of this page.

If you think about it, this makes sense. What if you would like to change the link the page fetches it's data from, then you would have to operate on real values of the page (the PageData object of the actual page, not the linked page).

If you want to get the values displayed, look at the the PageShortcutType and PageShortcutLink properties of the page. If the PageShortCutType property value is PageShortcutType.FetchData, then get the data from the page named in PageShortcutLink instead.

 

#31474
Aug 01, 2009 9:52
Vote:
 

When you use the Fetch data from there is different ways of geting content.

 If you use CurrentPage.Property["propertyName"] you will get the template (fetch data from) of the propertyName is empty on current page.

if ypou use CurrentPage.Property.Get("propertyName") you wll always the the property from the current page.

#31486
Aug 03, 2009 10:42
Vote:
 

Ah, I was unaware of that. If you have a writable PageData object, however, both CurrentPage.Property["propertyName"] and CurrentPage.Property.Get("propertyName") will return the "local" page values.

#31493
Aug 03, 2009 11:23
Vote:
 

Fantastic, that explains it! Thanks very much chaps.

 Karl. 

#31648
Aug 05, 2009 11:23
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.