Display content items on Service Portal?

selenasmith
Kilo Contributor

I have a SC category titled "Knowledge/Info" which contains content items linking out to external content.   In the new Helsinki Service Portal, I added an icon link widget to this category but no items are displayed.   Any thoughts?

6 REPLIES 6

kshavage
Kilo Contributor

If you want to display the Content Items in service portal then you need to clone SC Category Page widget then modify the below code.



Body HTML template


In html code you need to provide the url for content items.



<div>


  <h4 ng-if="data.error">{{data.error}}</h4>


  <div ng-init="spSearch.targetCatalog()">


      <h4 class="m-t-none">{{data.category}}</h4>


      <div class="row">        


          <div class="col-sm-6 col-md-4" ng-repeat="item in data.items">


              <div class="panel panel-{{::options.color}} b">


                  <a target="{{item.target}}" ng-href="{{getItemHREF(item)}}


" ng-click="onClick($event, item)" class="panel-body block">


<div class="overflow-100">


                         


        <a ng-if="item.sys_class_name == 'sc_cat_item_content' && item.content_type == 'external'" href="{{item.url}}" target="_blank"><h4 class="m-t-none m-b-xs">{{item.name}}<span ng-if="item.content_type == 'external'"> âžš</span></h4></a>


<img ng-src="{{item.picture}}" ng-if="item.picture" class="m-r-sm m-b-sm item-image pull-left" />


<div class="text-muted item-short-desc">{{item.short_description}}</div>


</div>


                  </a>


                  <div class="panel-footer">


<a ng-if="item.sys_class_name != 'sc_cat_item_content' || item.content_type == 'kb' || item.content_type == 'literal'" href="?id={{item.page}}&sys_id={{item.sys_id}}" class="pull-left text-muted">${View Details}</a>


<a ng-if="item.sys_class_name == 'sc_cat_item_content' && item.content_type == 'external'" href="{{item.url}}" target="_blank" class="pull-left text-muted">${View Details}</a>


<span ng-if="data.showPrices && item.price != '$0.00'" class="pull-right item-price font-bold">{{item.price}}</span>  


</div>


              </div>


          </div>


      </div>


  </div>


</div>



Server Script :



In Server Script modify the query string @ line number 23 and 24.



var cat = new GlideRecord('sc_category');


                      cat.get(data.category_id);


                      data.category = cat.getDisplayValue('title');


                      var items = data.items = [];


                      var sc = new GlideRecord('sc_cat_item_category');


                      if (data.category_id)


                                              sc.addQuery('sc_category', data.category_id);



                      sc.addQuery('sc_cat_item.active',true);


                      sc.addQuery('sc_cat_item.sys_class_name', 'NOT IN', 'sc_cat_item_wizard');


                      sc.addQuery('sc_cat_item.sys_class_name', 'sc_cat_item_content');


                      sc.orderBy('sc_cat_item.order');


                      sc.orderBy('sc_cat_item.name');


                      sc.query();


                      while (sc.next()) {


                                              // Does user have permission to see this item?


                                              if (!$sp.canReadRecord("sc_cat_item", sc.sc_cat_item.sys_id.getDisplayValue()))


                                                                      continue;



This above new widget (Copy SC Category Page) you can replace with SC Category Page on the sc_category page then only content items will display as per clicked on categories.



Hello, I want to fetch description of  content Item as well in the same widget.

description is html field and I am able to fetch as string.

 

How can I fetch as HTML field. What will be the scope.

 

Thanks,

Akhil