November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
When you say "requires me to have the actual IContent", do you mean the IContent of the Block that needs the default values (for example CurrentBlock) or the IContent of the blocks you want to have as default values?
Not sure if I understand you right but I will try to explain.
The reason I need IContent is to be able to add the Block to the ContentArea (using ContentArea.Add(IContent content)). The Block itself does not use any EPi-Block related properties (e.g. CurrentBlock) but maybe that is needed to be able to edit the contentarea.
In clear words: what I am trying to achieve is that when I create a new page of pagetype NewsPage should there already be a "SharingBlock" in the NewsPage's ContentArea called SubArea.
Ah I see, I think I missunderstood your intent.
I would suggest that you create a ContentArea in a page such as your StartPage or preferebly if you have a some kind of Settings Page.
When you create your NewsPage, you Get your StartPage/SettingsPage and copy the ContentArea value to your new NewsPage
Yeah that works for now. If anyone got a solution which does not include creation of another property would I be glad to hear it.
I would suggest that you in one way or another have a Property or Setting where you define your default values.
If you want to refer to an existing Block you do not want to hard code Id values or similar that refers to your "SharingBlock" into your code.
Or is the case that you want to create a new instance of your SharingBlock each time you create a NewsPage?
Yeah I have thought about that too and I came across the same thought to prevent hardcoding. Creating a new instance could be a solution but that would create a lot of waste blocks. Then I could rather have all the block stuffs inside the pagetype itself. A GetAny-solution could have worked though since there probably only will be one instance of the block.
I think it depends on if you want to put in more blocks except that SharingBlock, then ContentArea would be ideal. Otherwise only having a ContentReference or maybe a Local Block (a public virtual SharingBlock {get;set;} on your Page Type) and populate the Local Block Properties when you create your Page?
Which leads me to the question. What kind of information do you have on your SharingBlock?
I agree about creating a new instance would create alot of waste blocks so I would not walk along that road.
What do you mean with a "GetAny-solution", find any instance of SharingBlock among all your created Blocks?
The block's properties ar for instance ShowFacebook (bool), showTwitter etc. nothing else than bool. And yes that was what I meant when saying GetAny().
Ok I think I understand
I think that if the case is following:
* You're not going to add more Content such as Pages or Blocks in that ContentArea AND
* You're interested in always setting showing/hiding Facebook or Twitter on each page instead of controlling multiple Pages with only one place to show/hide Facebook or Twitter (as a Shared Block)
I would suggest that you add a SharingBlock as a Local Block to your Page Type, and you should be able to set your default values on SetDefaultValues on your NewsPage or your SharingBlock.
Hello.
I have been working on a block which will add sharing functionality to pages. This works all fine but the problem is that I want to pre-populate this block into certain pagetypes (e.g. Newspages). I thought I could do this by adding the block in the SetDefaultValues-method however that requires me to have the actual IContent. I can think of three approaches, however I have not had any success with any of them.
Perhaps we can solve this out. Thanks in advance!
David Rutqvist