Generic Content Marked as Draft - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Generic Content Marked as Draft

  • Generic Content Marked as Draft
  • So...

    I've successfully (almost) built a custom module based on the products sample.  No matter what I do though, any newly created items always appear as draft.  

    The documentation:
    http://www.sitefinity.com/40/help/developers-guide/sitefinity-essentials-modules-content-lifecycle.html

    Isn't really helpful.  Can someone point me in the right direction?
  • Hello Victor,

    Can you provide a sample that shows how you are publishing/ saving the items ? Are you using workflow or the fluent API ?

    Greetings,
    Teodor
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
  • I missed a step somewhere.  I went back and copied the sample again and it worked just fine.  I am still confused about something though.  In the Products sample in the file ProductDesigner.cs the following code appears but the line but the last line is commented out.

    If thought that "uncommenting" out  the line would let me pick more own "content filter" for my custom type (JobListing) but what happens instead if the content is from the "News" module.  Am I missing something?

    var resources = Res.Get<EmploymentResources>();
                var contentSelectorsSettings = new ContentSelectorsDesignerView();
                contentSelectorsSettings.ContentTitleText = resources.DesignerContentTitleText;
                contentSelectorsSettings.ChooseAllText = resources.DesignerChooseAllText;
                contentSelectorsSettings.ChooseSingleText = resources.DesignerChooseSingleText;
                contentSelectorsSettings.ChooseSimpleFilterText = resources.DesignerChooseSimpleFilterText;
                contentSelectorsSettings.ChooseAdvancedFilterText = resources.DesignerChooseAdvancedFilterText;
                contentSelectorsSettings.NoContentToSelectText = resources.DesignerNoContentToSelectText;
                contentSelectorsSettings.ContentSelector.TitleText = resources.DesignerContentSelectorTitleText;
                contentSelectorsSettings.ContentSelector.ItemType = typeof(JobListing).FullName;
     
                //var listSettings = new ListSettingsDesignerView();
                //listSettings.SortItemsText = resources.DesignerListSettingsSortItemstext;
                //listSettings.DesignedMasterViewType = typeof(MasterListView).FullName;
     
                var singleItemSettings = new SingleItemSettingsDesignerView();
                singleItemSettings.DesignedDetailViewType = typeof(ProductDetailsView).FullName;
     
                var customSettings = new CustomSettingsDesignerView();
                customSettings.HidePrice = true;
     
     
                views.Add(contentSelectorsSettings.ViewName, contentSelectorsSettings);
  • Hello Victor,

    The designer can be used in 3 modes

               var contentSelectorsSettings = new SomeDesignerContentSelectorsDesignerView(); - content selector tab
                   contentSelectorsSettings.ContentSelector.ItemType = typeof(MyItem).FullName;
           

                var listSettings = new ListSettingsDesignerView(); - list view designer
                listSettings.DesignedMasterViewType = typeof(MyMasterView).FullName;
                listSettings.LayoutTemplatePath = ControlUtilities.ToVppPath("Telerik.Sitefinity.Samples.Templates.Designers.ContentView.MyItem.MyItemSettingsDesignerView.ascx");

                var singleItemSettings = new SingleItemSettingsDesignerView();
                singleItemSettings.DesignedDetailViewType = typeof(MyDetailsView).FullName;
                views.Add(contentSelectorsSettings.ViewName, contentSelectorsSettings);
                views.Add(listSettings.ViewName, listSettings);
                views.Add(singleItemSettings.ViewName, singleItemSettings);

    If the DetailsView or MasterView are under not the proper namespace you will get items from anther provider.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
  • OK.  I got the content selector showing the right content on the pages but..

    The single item buton, still shows news (see below)

    Code:

    01.var contentSelectorsSettings = new ContentSelectorsDesignerView();
    02. 
    03.            contentSelectorsSettings.ContentTitleText = resources.DesignerContentTitleText;
    04.            contentSelectorsSettings.ChooseAllText = resources.DesignerChooseAllText;
    05.            contentSelectorsSettings.ChooseSingleText = resources.DesignerChooseSingleText;
    06.            contentSelectorsSettings.ChooseSimpleFilterText = resources.DesignerChooseSimpleFilterText;
    07.            contentSelectorsSettings.ChooseAdvancedFilterText = resources.DesignerChooseAdvancedFilterText;
    08.            contentSelectorsSettings.NoContentToSelectText = resources.DesignerNoContentToSelectText;
    09.            contentSelectorsSettings.ContentSelector.TitleText = resources.DesignerContentSelectorTitleText;
    10.            contentSelectorsSettings.ContentSelector.ItemType = typeof(JobListing).FullName;
    11.            contentSelectorsSettings.SingleSelectorButtonText = "Job Listings";
    12.             
    13.            contentSelectorsSettings.ContentSelector.ServiceUrl = "~/Sitefinity/Services/Content/Products.svc";
     

     

  • Hello Victor,

    There are two reasons not to see the data

    1. You use localization and the filter of the selector is not set

    selector.ItemsFilter = Visible == true AND Status == Live AND Culture == en"

    2. There is an issue with the web service and its methods.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
  • The items filter is being set.

    As far as the service goes, it never gets called.  I confirmed this in Fiddler. 
    The HTML source on the page still shows the NewsService.svc as the ServiceURLBase.

    Sys.Application.add_init(function()
        $create(Telerik.Sitefinity.Web.UI.RadGridBinder, "_checkboxClass":"sfPropCheckbox","_loadingText":"Loading...","allowAutomaticDelete":false,"bindOnLoad":false,"clientTemplates":["ctl05_ctl00_ctl00_ctl00_ctl00_ctl00_ctl01_ctl00_ctl00_selector_ctl00_ctl00_itemSelector_ctl00_ctl00_selectorBinder_ctl00_clientTemplate"],"dataKeyNames":["Id"],"filterExpression":null,"id":"ctl05_ctl00_ctl00_ctl00_ctl00_ctl00_ctl01_ctl00_ctl00_selector_ctl00_ctl00_itemSelector_ctl00_ctl00_selectorBinder","isMultilingual":false,"managerType":null,"serviceBaseUrl":"/Sitefinity/Services/Content/NewsItemService.svc/","sortExpression":null,"targetId":"ctl05_ctl00_ctl00_ctl00_ctl00_ctl00_ctl01_ctl00_ctl00_selector_ctl00_ctl00_itemSelector_ctl00_ctl00_selectorGrid", null, null, $get("ctl05_ctl00_ctl00_ctl00_ctl00_ctl00_ctl01_ctl00_ctl00_selector_ctl00_ctl00_itemSelector_ctl00_ctl00_selectorBinder"));
    );

    Any other thoughts or ideas would be appreciated.
  • Hi Victor,

    1. Add the following code in the control designer template

    <sitefinity:FormManager  runat="server" ID="FormsManager1" />
    <div id="selectorTag" style="display: none;" class="sfDesignerSelector sfFlatDialogSelector">
       <designers:ContentSelector
           ID="selector"
           runat="server"
           TitleText="<%$Resources:Labels, ChooseEvents %>"
           AllowMultipleSelection="false" 
           WorkMode="List"
           SearchBoxInnerText=""
           SearchBoxTitleText="<%$Resources:Labels, NarrowByTypingTitleOrDate %>"
           ListModeClientTemplate="<strong class='sfItemTitle'>Title</strong> <span class='sfDate'>EventStart ? EventStart.sitefinityLocaleFormat('dd MMM yyyy') + ' – ': ""EventEnd ? EventEnd.sitefinityLocaleFormat('dd MMM yyyy') : ""</span>">
       </designers:ContentSelector>
    </div>
     
      
         
            
            
              <asp:Label ID="selectedContentTitle" runat="server" Text="<%$Resources:Labels, NoContentSelected %>" CssClass="sfSelectedItem"></asp:Label>
             <span class="sfLinkBtn sfChange" runat="server" id="btnSelectSingleItemWrapper">
                <asp:LinkButton NavigateUrl="javascript:void(0)" runat="server" ID="btnSelectSingleItem"  OnClientClick="return false;" CssClass="sfLinkBtnIn" ><asp:Literal ID="Literal1" runat="server" Text="<%$Resources:Labels, SelectEvent %>" /></asp:LinkButton>
              </span>
          

    2. Add the following code in the control designer class

    protected override void InitializeControls(Web.UI.GenericContainer container)
           
       
     
               var resources = Res.Get<Labels>();
               ContentSelector.TitleText = resources.SelectItem;
               ContentSelector.ItemType = typeof(MyType).FullName;
               ContentSelector.ServiceUrl = "~/Sitefinity/Services/Content/MyService.svc/";
               btnSelectSingleItem.Text = "select a single item";
           
     
     public override IEnumerable<ScriptDescriptor> GetScriptDescriptors()
           
               var scriptDescriptors = new List<ScriptDescriptor>(base.GetScriptDescriptors());
               var desc = (ScriptControlDescriptor)scriptDescriptors.Last();
               desc.AddProperty("_selectContentButton", btnSelectSingleItem.ClientID);
               desc.AddComponentProperty("contentSelector", ContentSelector.ClientID);
               return scriptDescriptors.ToArray();
           
     
           /// <summary>
           /// Gets a collection of <see cref="T:System.Web.UI.ScriptReference"/> objects that define script resources that the control requires.
           /// </summary>
           /// <returns>
           /// An <see cref="T:System.Collections.IEnumerable"/> collection of <see cref="T:System.Web.UI.ScriptReference"/> objects.
           /// </returns>
           public override IEnumerable<System.Web.UI.ScriptReference> GetScriptReferences()
           
               var res = new List<ScriptReference>(base.GetScriptReferences());
               var assemblyName = this.GetType().Assembly.GetName().ToString();
               res.Add(new ScriptReference(designerScriptName, assemblyName));
               return res.ToArray();
           
     
     
     
           protected override string LayoutTemplateName
           
               get
               
                   return ContentCustomDesigner.designerTemplate;
               
           
     
       
     
           protected virtual LinkButton btnSelectSingleItem
           
               get
               
                   return this.Container.GetControl<LinkButton>("btnSelectSingleItem", true);
               
           
     
           protected virtual ContentSelector ContentSelector
           
               get
               
                   return this.Container.GetControl<ContentSelector>("selector", true);
               
           

    3. Add the code below to the client component

    Telerik.Sitefinity.Samples.ContentBlockCustomDesigner = function (element)
     
        // element
     
        this._contentSelector = null;
        this._selectContentButton = null;
        this._showContentSelectorDelegate = null;
     
        Telerik.Sitefinity.Samples.ContentBlockCustomDesigner.initializeBase(this, [element]);
     
    Telerik.Sitefinity.Samples.ContentBlockCustomDesigner.prototype =
     
        initialize: function ()
            Telerik.Sitefinity.Samples.ContentBlockCustomDesigner.callBaseMethod(this, 'initialize');
     
            this._showContentSelectorDelegate = Function.createDelegate(this, this._showContentSelector);
            $addHandler($get(this._selectContentButton), "click", this._showContentSelectorDelegate);
        ,
     
           dispose: function ()
     
            if (this._showContentSelectorDelegate)
                $removeHandler($get(this._selectContentButton), "click", this._showContentSelectorDelegate);
                delete this._showContentSelectorDelegate;
            
        ,
     
     
     
        get_contentSelector: function ()
            return this._contentSelector;
        ,
     
        set_contentSelector: function (value)
            this._contentSelector = value;
        ,
     
        get_selectContentButton: function ()
            return this._selectContentButton;
        ,
     
        set_selectContentButton: function (value)
            this._selectContentButton = value;
        ,
     
     
     
        _showContentSelector: function ()
            this.get_contentSelector().dataBind();
            jQuery(this.get_element()).find('#selectorTag').show();
            dialogBase.resizeToContent();
        ,
       
     
     
     
        refreshUI: function ()
       
        ,
     
        // forces the designer to apply the changes on UI to the cotnrol Data
        applyChanges: function ()
            var data = this.get_controlData();
           
        
     


    Regards,
    Ivan Dimitrov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
  • I added this workaround to the "AddViews" function and i worked like it was supposed to.  
    Is it possible there's a bug when setting the ContentSelector.ItemType?

    Either way, thanks for all your help.

    foreach (Control ctl in contentSelectorsSettings.Controls[0].Controls)
                
                      
                    if (ctl.ToString() == "Telerik.Sitefinity.Web.UI.ControlDesign.ContentSelector")
                    
                        ((Telerik.Sitefinity.Web.UI.ControlDesign.ContentSelector)ctl).ItemType=typeof(JobListing).FullName;
                        ((Telerik.Sitefinity.Web.UI.ControlDesign.ContentSelector)ctl).TitleText="Job Listings";
                        ((Telerik.Sitefinity.Web.UI.ControlDesign.ContentSelector)ctl).ListModeClientTemplate = "<strong     class='sfItemTitle'>JobTitle</strong><span class='sfDate'>PublicationDate ? PublicationDate.sitefinityLocaleFormat('dd MMM yyyy') : "" by Author</span>";
                        ((Telerik.Sitefinity.Web.UI.ControlDesign.ContentSelector)ctl).SearchBoxTitleText="Narrow by typing job title";
                        ((Telerik.Sitefinity.Web.UI.ControlDesign.ContentSelector)ctl).ServiceUrl = "~/Sitefinity/Services/Content/Products.svc/";
                    
  • Hello Victor,

    There should not be an issue. I have the sample that opens the dialog working properly at my end.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
  • I probably missed something somewhere. 

    Thanks for taking the time to help!
  • Please share the sample I am also having the same issue
  • Hi Moiz,

    The code that I used is shown several posts above.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  • Hi Ivan Dimitrov,

    I've seen your code, I am asking for your sample just to be sure of where to put it.

    Also while I was debugging yesterday. I noticed that sitefinity renders the list correctly the first time, after we built the solution. But the nest time we edit the widget it show's the same news.

    I used this line to set my service from the code.
    contentSelectorsSettings.ContentSelector.ServiceUrl = "~/Sitefinity/Services/Content/Products.svc";
    but I noticed that, the designer was still calling the NewsService.