Content item open url direct

Eder Luiz Da Si
Tera Contributor

I have one catalog item(Content Item) with content type as external content on which it goes to the external url . I would like to click the item and open the link in another tab directly. currently opens the item with the url.

 

server codes and html:

 

 

 

(function() {
	data.category_id = $sp.getParameter("sys_id");
	if (options && options.sys_id)
		data.category_id = options.sys_id;

	data.sc_catalog_page = "xx_ssc_sc";
	// Does user have permission to see this category?
	if (!$sp.canReadRecord("sc_category", data.category_id)) {
		data.error = "You do not have permission to see this category";
		return;
	} 
	
	var gr = new GlideRecord('sc_category');
	gr.addEncodedQuery('parent='+data.category_id);	
	gr.addActiveQuery();
	gr.orderBy('order');
	gr.orderBy('title');
	gr.query();	
	var items = data.items = [];
	
	
	
	if (gr.getRowCount() == 0){
		
			var cat = new GlideRecord('sc_category');
			cat.get(data.category_id);
			data.category = cat.getDisplayValue('title');		
			data.parent = cat.getDisplayValue('parent.title');	
		data.parent_sysid = cat.getDisplayValue('parent.sys_id');	
			
		
		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_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;			
			
			var item = {};
			var gr2 = new GlideRecord('sc_cat_item');
			gr2.get(sc.sc_cat_item);
			$sp.getRecordDisplayValues(item, gr2, 'name,short_description,picture,price,sys_id');
			item.sys_class_name = sc.sc_cat_item.sys_class_name + "";
			item.page = 'ssc_cat_item';
			if (item.sys_class_name == 'sc_cat_item_guide')
				item.page = 'sc_cat_item_guide';
			if(item.sys_id == '9fab39e2d7532100a9ad1e173e24d484')
				item.page = 'xxx_incident';
			if(item.sys_id == '9f95a0a41bfd701407d487bfe54bcb88')
				item.page = 'ssc_item';

						
			items.push(item);
		}
		
	} else if (gr.hasNext()) {
		
		while(gr.next()){
			
			if (!$sp.canReadRecord("sc_category", gr.sys_id.getDisplayValue()))
				continue;
			
			data.category = gr.getDisplayValue('parent.title');			
			data.parent = '';		
			
			var item = {};
			//$sp.getRecordDisplayValues(item, gr, name+','+short_description+','+picture+',price,sys_id');
			item.name = gr.getDisplayValue('title');
			item.short_description = gr.getDisplayValue('description');
			item.picture = gr.getDisplayValue('homepage_image');
			item.sys_id = gr.getDisplayValue('sys_id');
			item.price = gr.getDisplayValue('price');
			item.sys_class_name = 'sc_category' + "";
			//item.page = 'xx_sc_category';
			item.page = 'xx_ssc_category';
			if (item.sys_class_name == 'sc_cat_item_guide')
				item.page = 'sc_cat_item_guide';			
			
		
			items.push(item);
		
		}
		
		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.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;
			
			var item = {};
			var gr2 = new GlideRecord('sc_cat_item');
			gr2.get(sc.sc_cat_item);
			$sp.getRecordDisplayValues(item, gr2, 'name,short_description,picture,price,sys_id');
			item.sys_class_name = sc.sc_cat_item.sys_class_name + "";
			item.page = 'ssc_cat_item';
			if (item.sys_class_name == 'sc_cat_item_guide')
				item.page = 'sc_cat_item_guide';
			if(item.sys_id == '9fab39e2d7532100a9ad1e173e24d484')
				item.page = 'xxx_incident';

			items.push(item);
		}
		
	}
	
	
})()

 

 

 

 

 

 

 

<div ng-controller='DemoController' ng-app="myApp">
	<div infinite-scroll='loadMore()' infinite-scroll-distance='2'>
		<h1 ng-if="data.error">{{data.error}}</h1>
		<div ng-init="spSearch.targetCatalog()">
			<h3 class="font-thin m-t-none">{{data.category}}</h3>
			<div class="row">
				<div class="col-sm-6 col-md-4" ng-repeat="item in data.items">
                  
					<!-- /* <div ng-if="item.sys_id == 'a704728bdb9db3003abb63901496190b'" ng-class="blockClass(item.sys_id)">
						<div class="ribbon">
							<span>${Popular}</span>
						</div>
						<a href="?id={{item.page}}&sys_id={{item.sys_id}}" class="panel-body block">
							<div class="overflow-100">
								<strong>
									<h4 style="font-weight: bold" class="m-t-none m-b-xs">{{item.name}}</h4>
								</strong>
								<img ng-src="{{item.picture}}" ng-if="item.picture" class="m-r-sm m-b-sm item-image pull-left" />
								<div class='desc' ng-class="textClass(item.sys_id)">{{item.short_description}}</div>
							</div>
						</a>
					</div> */ -->
                  
					<div ng-if="item.sys_id != 'a704728bdb9db3003abb63901496190b'" ng-class="blockClass(item.sys_id)">
						<a href="?id={{item.page}}&sys_id={{item.sys_id}}" class="panel-body block">
							<div class="overflow-100">
								<img ng-src="{{item.picture}}" ng-if="item.picture" class="item-image pull-left" />
								<strong>
									<h4 style="font-weight: bold" class="m-t-none m-b-xs">{{item.name}}</h4>
                              </strong>
								<div class='desc' ng-class="textClass(item.sys_id)">{{item.short_description}}</div>
							</div>
						</a>
					</div>
                  
				</div>
			</div>
		</div>
	</div>

 

 

 

 thanks

1 ACCEPTED SOLUTION

Craig Gruwell
Mega Sage

In your href tag, add the following:  target="_blank"

 

For more info visit https://www.w3schools.com/tags/att_a_target.asp 

View solution in original post

1 REPLY 1

Craig Gruwell
Mega Sage

In your href tag, add the following:  target="_blank"

 

For more info visit https://www.w3schools.com/tags/att_a_target.asp