Widget is not display from PageDefinitionOptions

Hi Team, 

I created a page and I included sample widget there but its not showing there.

I written my code below, can you check and verify once what mistake I done there. Thansk

using System;
using Telligent.Evolution.Extensibility;
using Telligent.Evolution.Extensibility.Api.Version1;
using Telligent.Evolution.Extensibility.Content.Version1;
using Telligent.Evolution.Extensibility.Security.Version1;
using Telligent.Evolution.Extensibility.Urls.Version1;
using Telligent.Evolution.Extensibility.Version1;

namespace Telligent.Test.Widget.Extension
{
    public class TestApplicationType : IApplicationType, ITranslatablePlugin, INavigable
    {
        IApplicationStateChanges _applicationState = null;
        ITranslatablePluginController _translations = null;

        #region IPlugin Members
        string IPlugin.Name
        {
            get { return "Test Appl"; }
        }
        string IPlugin.Description
        {
            get { return "Community Member Test ApplicationType."; }
        }

        void IPlugin.Initialize()
        {

        }
        #endregion

        #region IApplicationType Members
        Guid IApplicationType.ApplicationTypeId
        {
            get { return ContentTypes.ApplicationId; ; }
        }

        string IApplicationType.ApplicationTypeName
        {
            get { return _translations.GetLanguageResourceValue("ApplicationTypeName"); }
        }

        void IApplicationType.AttachChangeEvents(IApplicationStateChanges stateChanges)
        {
            _applicationState = stateChanges;
        }

        Guid[] IApplicationType.ContainerTypes
        {
            get { return new Guid[] { Apis.Get<IGroups>().ContentTypeId }; }
        }

        IApplication IApplicationType.Get(Guid applicationId)
        {
            return Apis.Get<IApplications>().Get(applicationId, applicationId);
        }
        #endregion

        #region ITranslatablePlugin Members
        Translation[] ITranslatablePlugin.DefaultTranslations
        {
            get
            {
                var t = new Translation("en-US");
                t.Set("ApplicationTypeName", "test");
                t.Set("page-members-custom", "Sample User Page");
                t.Set("page-members-custom-description", "Shows a page at the url members/{username}/custompage.");
                t.Set("UserNotFoundException", "User {0} not found.");
                return new Translation[] { t };
            }
        }
        void ITranslatablePlugin.SetController(ITranslatablePluginController controller)
        {
            _translations = controller;
        }
        #endregion
       

        void INavigable.RegisterUrls(IUrlController controller)
        {
            controller.AddPage("page-custom", "custom", null, null, "page-custom", new PageDefinitionOptions()
            {
                DefaultPageXml = @"<contentFragmentPage pageName=""page-members-custom"" isCustom=""false"" layout=""Content"" themeType=""0c647246-6735-42f9-875d-c8b991fe739b"">
      <regions>
        <region regionName=""Content"">
          <contentFragments>
            <contentFragment type=""Telligent.Evolution.ScriptedContentFragments.ScriptedContentFragment, Telligent.Evolution.ScriptedContentFragments::0a176676-40f8-484e-aaf6-6935ecb6ff44"" showHeader=""False"" cssClassAddition=""no-wrapper with-spacing responsive-1"" isLocked=""False"" configuration="""" />
         </contentFragments>
        </region>
      </regions>
      <contentFragmentTabs />
    </contentFragmentPage>",
                TitleFunction = () => _translations.GetLanguageResourceValue("page-members-custom"),
                DescriptionFunction = () => _translations.GetLanguageResourceValue("page-members-custom-description"),
            });
        }
    }
}

  • You page names do not match from the xml to the page definition.  Beyond that the easiest way to make sure your definition s right is to add widgets to the page, export the xml and use it as a guide.

  • Hi  ,

    Thanks for your reply,

    I tried as per suggestion like create a new widget and export into excel. After I added to my code still I can see empty page and the widget also not included in my page.

    I attached the code below, can you please check and verify what mistake I done below, Thanks!

    Regards,

    using System;
    using System.Web;
    using Telligent.Evolution.Extensibility;
    using Telligent.Evolution.Extensibility.Api.Version1;
    using Telligent.Evolution.Extensibility.Content.Version1;
    using Telligent.Evolution.Extensibility.Security.Version1;
    using Telligent.Evolution.Extensibility.Urls.Version1;
    using Telligent.Evolution.Extensibility.Version1;
    
    namespace Telligent.TestPoint.Widget.Extension
    {
        public class TestApplicationType : IApplicationType, ITranslatablePlugin, IPermissionRegistrar, INavigable
        {
            IApplicationStateChanges _applicationState = null;
            ITranslatablePluginController _translations = null;
    
            #region IPlugin Members
            string IPlugin.Name
            {
                get { return "Test"; }
            }
            string IPlugin.Description
            {
                get { return "Community Member Test ApplicationType."; }
            }
    
            void IPlugin.Initialize()
            {
    
            }
            #endregion
    
            #region IApplicationType Members
            Guid IApplicationType.ApplicationTypeId
            {
                get { return ContentTypes.ApplicationId; ; }
            }
    
            string IApplicationType.ApplicationTypeName
            {
                get { return _translations.GetLanguageResourceValue("ApplicationTypeName"); }
            }
    
            void IApplicationType.AttachChangeEvents(IApplicationStateChanges stateChanges)
            {
                _applicationState = stateChanges;
            }
    
            Guid[] IApplicationType.ContainerTypes
            {
                get { return new Guid[] { Apis.Get<IGroups>().ContentTypeId }; }
            }
    
            IApplication IApplicationType.Get(Guid applicationId)
            {
                return Apis.Get<IApplications>().Get(applicationId, applicationId);
            }
            #endregion
    
            #region ITranslatablePlugin Members
            Translation[] ITranslatablePlugin.DefaultTranslations
            {
                get
                {
                    var t = new Translation("en-US");
                    t.Set("ApplicationTypeName", "Test");
                    t.Set("page-members-custom", "Sample User Page");
                    t.Set("page-members-custom-description", "Shows a page at the url members/{username}/custompage.");
                    t.Set("UserNotFoundException", "User {0} not found.");
                    return new Translation[] { t };
                }
            }
            void ITranslatablePlugin.SetController(ITranslatablePluginController controller)
            {
                _translations = controller;
            }
            #endregion
    
            void INavigable.RegisterUrls(IUrlController controller)
            {
                controller.AddPage("page-custom", "custom", null, null, "page-custom", new PageDefinitionOptions()
                {
                    DefaultPageXml = @"<scriptedContentFragments>
    	<scriptedContentFragment name=""Test Widget"" version=""11.1.4.12924"" description="" instanceIdentifier=""1a3d34f1b617450093715f417c700b08"" theme="" isCacheable=""false"" varyCacheByUser=""false"" showHeaderByDefault=""true"" cssClass="" lastModified=""2021-07-09 07:02:38Z"">
    		<contentScript language=""Velocity""><![CDATA[Test Data]]></contentScript>
    		<headerScript language=""Velocity"" />
    		<additionalCssScript language=""Velocity"" />
    	</scriptedContentFragment>
    </scriptedContentFragments>",
                    TitleFunction = () => _translations.GetLanguageResourceValue("page-members-custom"),
                    DescriptionFunction = () => _translations.GetLanguageResourceValue("page-members-custom-description"),
                    ParseContext = ParseUserContext
                });
            }
    
            private void ParseUserContext(PageContext context)
            {
                var userName = context.GetTokenValue("UserName");
    
                if (userName != null)
                {
                    var usersApi = Apis.Get<IUsers>();
                    string decodedUserName = PublicApi.Url.DecodeFileComponent(userName.ToString());
                    var user = usersApi.Get(new UsersGetOptions() { Username = decodedUserName });
    
                    ContextItem contextItem = null;
    
                    if (user != null && !user.HasErrors())
                    {
                        contextItem = new ContextItem()
                        {
                            TypeName = "User",
                            ApplicationId = user.ContentId,
                            ApplicationTypeId = usersApi.ContentTypeId,
                            ContainerId = user.ContentId,
                            ContainerTypeId = usersApi.ContentTypeId,
                            ContentId = user.ContentId,
                            ContentTypeId = usersApi.ContentTypeId,
                            Id = user.Id.ToString()
                        };
                    }
                    else
                    {
                        if (usersApi.AccessingUser.IsSystemAccount.Value)
                        {
                            var url = Apis.Get<ICoreUrls>().LogIn(new CoreUrlLoginOptions() { ReturnToCurrentUrl = true });
                            HttpContext.Current.Response.Redirect(url);
                        }
                        else
                        {
                            throw new CustomException(String.Format(_translations.GetLanguageResourceValue("UserNotFoundException"), decodedUserName));
                        }
                    }
    
                    if (contextItem != null)
                        context.ContextItems.Put(contextItem);
                }
            }
    
            public class CustomException : Exception, Telligent.Evolution.Extensibility.Version1.IUserRenderableException
            {
                public CustomException() { }
                public CustomException(string message) : base(message) { }
    
                public string GetUserRenderableMessage()
                {
                    return this.Message;
                }
            }
        }
    }
    

    Kiran

  • First...never export things into Excel...use a text editor.   You also exported a widget, you need to export the page with the widget on it, it wants a page definition, you are just supplying the widget.

  • Hi   Thanks for your advice.

    Now I added bookmark like below from the AddPage() from through widget. I created a sample contenttypeid and contentid and passed below,

    var bookmarkControl = $('#bookmarkControl');

    var contentId='4432D1A1-ED6C-442D-BC9d-3587CD711D35';

    var contenttypeId='F76726AB-D59F-475C-9D22-4A79E3F0EC07';

    bookmarkControl.evolutionBookmark({
        initialState: true,  // content is bookmarked
        contentId: contentId,
        contentTypeId: contenttypeId,
        contentTypeName: 'Test One',
        onBookmark: function(contentId, contentTypeId, typeId, callback) {
            alert(contentId + ' bookmarked!');
    
            // ...perform AJAX-based saving of bookmark here...
    
            // After a successful save, callback to notify the bookmark plugin
            callback();
        },
        onUnbookmark: function(contentId, contentTypeId, typeId, callback) {
            alert(contentId + ' unbookmarked!');
    
            // ...perform AJAX-based saving of bookmark here...
    
            // After a successful save, callback to notify the bookmark plugin
            callback();
        }
    });

    When I click the bookmark button, my application has been struck down and I got the below exception. Can you help me please to resolve this issue.

  • I recommend investigating the Developer Training section for an orientation into how custom code integrates into our platform.

    It might be best to start at the top:  Getting Started 

    Then read about how the platform manages content and applications:  The Content Model 

    Check out how the UI can be customized  UI Customization and how Widgets are used:  Widgets 

     Then read about Themes, particulary page definitions:  Themes 

    Then you can dive into custom Page definitions and routings, which it seems is where you started:  Page Definition and URL Routing 

    I am not exactly sure where you are adding the code for your bookmark, but for things like Bookmarks and other core services, I would recommend checking out the Plugin infrastructure to avoid re-implementing something the platform does for you:  Bookmarks