5 Replies Latest reply on Jun 9, 2016 12:31 PM by Scott A Johnson

    content soy file in Plugin

    npanta@italentcorp.com

      Hi all,

      Ryan King

      I have created HelloWorld Plugin.I want to access the content.soy(/themes/src/main/themes/MyTheme/soy/place/content.soy) in my HelloWorld plugin.Please provide any Information.

       

      Thank you,

      Narsi

        • Re: content soy file in Plugin
          Scott A Johnson

          Hi Narsi,

           

          If you would like to use the template in content.soy for a custom action, you'll want to add an entry in the struts.xml of your plugin as such:

           

                  <action name="place-content" class="com....CustomPlaceContentAction">
                      <interceptor-ref name="defaultStack"/>
                      <interceptor-ref name="placeInterceptor"/>
                      <param name="tab">jive-place-link-content</param>
                      <result name="success" type="soy-page">jive.place.content</result>
                  </action>
          

           

           

          Hope this helps,

          Scott

            • Re: content soy file in Plugin
              npanta@italentcorp.com

              Hi Scott A Johnson,

               

              1) I added action tab in structs.xml file.

               

              Screen Shot 2016-06-06 at 4.16.23 PM.png

              2)HelloWorldAction.java class is

              Screen Shot 2016-06-06 at 4.19.55 PM.png

               

              3) custList Map in themes/myTheme/soy/place/content.soy file  added as

                                              "@param custList"

              Screen Shot 2016-06-06 at 4.21.53 PM.png

               

              but When i am hitting "localhost:8080/community/space/content" url,getting the below error

              localhost 8080 content-page.png

              Please advise on what is wrong here?

               

              Thank you,

              Narsi.

                • Re: content soy file in Plugin
                  Scott A Johnson

                  Hi Narsi,

                   

                  You should probably be extending PlaceContentAction instead of AdminActionSupport.

                   

                  The error is probably due to the base model not being populated for this soy template.

                   

                  Two other notes:

                  1) If the purpose of this customization is to add markup to the Place Content page, you would probably be better served using a PluginTemplateDefinition as described here: Extending Jive with Plugin Template Definitions by the epic Ryan King

                  2) If you decide that you need to alter the OOB Place Content page and content.soy template instead of using PTDs, you will probably want to extend PlaceContentAction as I mentioned, and override the execute method instead of the getModel method.

                   

                  Hope this helps,

                  Scott

                    • Re: content soy file in Plugin
                      npanta@italentcorp.com

                      Hi Scott A Johnson,

                       

                      We are trying to add tagCloud,Trending Content to the left hand side of the content page in a place. To do that we are looking into the plugin.As a first step we are trying to display some data which is coming from plugin but we are facing template failed to render error.

                       

                      As you said in your previous comment.When we are trying to override execute( ) with Object as a return type it is throwing "The return type is incompatible with PlaceContentAction.execute()" error message

                      Screen Shot 2016-06-09 at 12.48.31 PM.png

                       

                      Tell me the best way to add trending content and tag cloud to content.soy file(if plugin is not the best solution).We tried with api calls(Javascript) to display tags of a place on content.soy file but it is taking some time to load.

                      Thank you so much Scott A Johnson for your support.

                       

                      Thanks,

                      Narsi.

                        • Re: content soy file in Plugin
                          Scott A Johnson

                          Hey Narsi,

                           

                          The simplest and cleanest mechanism for displaying additional information on an existing page in Jive is usually by using a PluginTemplateDefinition as I mentioned. But this does usually involve displaying the content using Javascript and may result in a delay in display as you've found.

                           

                          An alternative would be to modify the content.soy template and the model object.

                           

                          There are two ways to do this, extending/overriding the PlaceContnetAction class itself as you're trying to do, or using a PluginTemplateDefinition.

                           

                          In the Action class, you could alter the model object within the execute method doing something like this.

                           

                          @Override
                          public String execute() {
                            String result = super.execute();
                          
                              BrowseViewBean viewBean = getBrowseActionSupport().getPopulatedBrowseViewBean();
                              viewBean.getProp().put("user", "foo");
                              model = viewBean;
                              
                              return result;
                          }
                          

                           

                          Assuming you dont overwrite an existing prop value, this should work for you.

                           

                          The other option would be to do basically the same using a PluginTemplateDefintion.

                           

                          @Override
                          public Object getModel(ActionInvocation ai, Object actionModel) {
                            BrowseViewBean viewBean;
                            viewBean = (BrowseViewBean) actionModel;
                          
                              viewBean.getProp().put("user", "foo");
                           return null;
                          }
                          
                          
                          

                           

                          You'll need to alter the content.soy template to include the prop field as well.

                           

                          Hopefully that helps,

                          Scott