Forums

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): Developing with Sitefinity > page selector

page selector

  • Annie Intermediate avatar

    Posted on Jan 14, 2012 (permalink)

    Hi,

    I would like to use Sitefinity's page selector in a custom module. How do I go about doing that?. Also is there any sample code that I can refer to.

    Thanks,
    Annie

    Reply

  • Haroon avatar

    Posted on Jan 24, 2012 (permalink)

    Can please any body answer. it's strange why there is no PageSelector Field in moduleBuilder as we can see ImageSelector and MediaSelector !

    Reply

  • Matthew avatar

    Posted on Mar 2, 2012 (permalink)

    Hi,
    I think it's probably not answered mainly because there doesn't appear to be an official way of doing this and this is the Sitefinity 3 Forums? 

    That being said, here's what I think you can do. After creating a dynamic module via Module Builder, a DynamicModulesConfig.config should get generated in the App_Data/Sitefinity/Configurations folder. This should create the views for your dynamic module. There should be 4x views, a BackendList, an BackendInsertView, a BackendPreviewView and a BackendEditView. What I did was to change the view/sections/../field element for an existing TextField. 

    From something like 

    <field rows="1" id="PageControl" dataFieldName="Page" displayMode="Write" wrapperTag="Li" title="Page" fieldType="Telerik.Sitefinity.Web.UI.Fields.TextField" cssClass="sfFormSeparator" fieldName="Page" type:this="Telerik.Sitefinity.Web.UI.Fields.Config.TextFieldDefinitionElement, Telerik.Sitefinity">

    to instead use the PageField like:

    <field rootNodeID="F669D9A7-009D-4D83-DDAA-000000000002" webServiceUrl="~/Sitefinity/Services/Pages/PagesService.svc/" id="PageControl" dataFieldName="Page" displayMode="Write" wrapperTag="Li" title="Page" fieldType="Telerik.Sitefinity.Web.UI.Fields.PageField" cssClass="sfFormSeparator" fieldName="Page" type:this="Telerik.Sitefinity.Web.UI.Fields.Config.PageFieldElement, Telerik.Sitefinity">

    I did this only for the Create and Edit views, I was not concerned about the preview view. You will probably have to use a correct rootNodeID (page_node) if this is not some default rootNodeId. It seems to be working but I did have problems when adding a new field to an existing module specifically for this module. The field for which I change the view control when it was working for a field which existed when the module was created.

    I Hope this helps

    Reply

  • Travis avatar

    Posted on Apr 11, 2012 (permalink)

    I'm not sure if this is what you're looking for, if not, Matthew's comment will probably suffice. Anyway, my comment relates to using the Page Selector from a custom module. Since I could not find how to do this, I figured I'd post that here, even if it is in the wrong forum (3.x). My comments are related to developing in Sitefinity 5.

    I had the requirement to reference a single page in the site hierarchy from my custom module's content items. I utilized the PageFieldElement control from my modules definitions to accomplish this, as well as couple other pieces of code.

    My content item has a property called PageGroupID. It is a Guid. There is nothing fancy about it in the least, it's just a standard property defined in the following way within my content item class (in this case ParternItem.cs)

    [DataMember, FieldAlias("PageGroupID")]
    public Guid PageGroupID { get { return this.pageGroupID; } set { this.pageGroupID = value; } }

    Then, in my definitions class, I have the following code, within the CreateBackendSections method, when I'm adding all my fields to my detail view:

    var pageGroupField = new PageFieldElement(mainSection.Fields)
    {
        ID = "pageGroupField",
        DataFieldName = "PageGroupID",
        DisplayMode = displayMode,
        Title = "LogoFieldTitle",
        WrapperTag = HtmlTextWriterTag.Li,
        CssClass = "sfUserAvatar",
        ResourceClassId = typeof(PartnersResources).Name,
        RootNodeID = Telerik.Sitefinity.Abstractions.SiteInitializer.FrontendRootNodeId,
        WebServiceUrl = "~/Sitefinity/Services/Pages/PagesService.svc"
    };
    mainSection.Fields.Add(pageGroupField);

    I've specified my RootNodeID as the FrontEndRootNodeID, so you may want to change that, but, that seemed to work for me. I am able to select a page and it remains after save. Hopefully this is of help to someone.

    edit: you'll probably want to change the CSS class, and my title is referencing a junk resource that I just left in there for testing... you'd likely change both of those anyways

    Reply

  • Register for webinar
Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): Developing with Sitefinity > page selector