Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: DataIdMultiSelector or String.Selector which is bound to the current Page-Node?

$
0
0
Hello,

I'm working currently on a C1 4.2 project and have the following issue:

Prerequisites:
  • I have a IPageFolderData datatype ITeaser
  • I have multiple pages which all contains own ITeaser datafolders containing teaser-data
  • I have a function which allows the user select, which of the available teaser should be displayed on the page
Problem:
When I use the default DataIdMultiSelector this way:
<f:widgetfunction name="Composite.Widgets.String.DataIdMultiSelector" xmlns:f="http://www.composite.net/ns/function/1.0">
    <f:param name="OptionsType">MyProject.ITeaser</f:param>
    <f:param name="CompactMode" value="true" />
</f:widgetfunction>
The selection works as desired, but I always see all datas added to all pages.
But the requirement is, that the user needs to be able to select only from the ITeaser datas from the current Page-Node.

After some reading and testing, I came up with something like this:
<f:widgetfunction name="Composite.Widgets.String.Selector" xmlns:f="http://www.composite.net/ns/function/1.0">
    <f:param name="Options">
        <f:function name="MyProject.GetAllTeasers" xmlns:f="http://www.composite.net/ns/function/1.0">
            <f:param name="currentPageId"><!-- PAGE ID? --></f:param>
        </f:function>
    </f:param>
    <f:param name="KeyFieldName">Id</f:param>
    <f:param name="LabelFieldName">Title</f:param>
    <f:param name="Multiple" value="true" />
    <f:param name="Compact" value="true" />
</f:widgetfunction>
I created a Custom C# function, which takes the current Page-Id as GUID and delivers all ITeaser from this page. I also tried to get the current PageId in the function itself, without any luck.

To access the current PageId, I tried using the PageRenderer.CurrentPageId or the SitemapNavigatior.CurrentPageId, but they're always Guid.Empty...

Does anyone have a solution for this problem, or am I wrong with this requirement using Composite? Are there any other possible solutions to this?

Thanks alot for any help.

Best regards and happy coding,
Chris

Viewing all articles
Browse latest Browse all 2540

Trending Articles