× Requests and support related to jBackend.

Customize jBackapp for K2 items

More
8 years 4 months ago #4549 by mobilechipmunk
Replied by mobilechipmunk on topic Customize jBackapp for K2 items
I've changed the services.js to pull k2 items


.factory('FeedService', function($http) {

var feeds = {
section_a: "https://**.me/api/get/k2/items?cat=5",
section_b: "https://**.me/api/get/k2/items/33",
section_c: "https://**.me/api/get/k2/items?cat=6"
};

var content = "https://**.me/api/get/k2/items/"

return {

You state i need to change fields in controllers.js. But what do I change?

For articles it is

$scope.successGetSectionContent = function(data) {
$scope.maxIntro = 100;
$scope.items = data.articles;
for (var i = 0; i < $scope.items.length; i++) {
$scope.items.content = $scope.items.content.replace(/<[^>]+>/gm, '');
if ($scope.items.content.length > $scope.maxIntro) {
$scope.items.content = $scope.items.content.substr(0, $scope.maxIntro) + '...';
}
}
};

The json for k2 items isn't much different except item is now items

this is my code for the sections.html

<div ng-repeat="item in items" class="list card" ng-click="goToContent(items.id)">

<div class="item item-avatar">
<h2>{{items.title}}</h2>
<p>{{items.published_date}}</p>
</div>

<div class="item item-body">
<img class="full-image" ng-src="{{items.images.imageXLarge}}">
<div ng-bind-html="items.content"></div>
</div>

</div>

Please point me in the right direction.

Please Log in or Create an account to join the conversation.

More
8 years 4 months ago #4550 by admin
Replied by admin on topic Customize jBackapp for K2 items
If you write the data content in your console log you will see which fields now you have with K2. Once you assign items to your $scope:
$scope.items = data.items;

Then you need to change fields in the template:
<div class="item item-avatar">
<h2>{{items.title}}</h2>
<p>{{items.modified}}</p>
</div>

<div class="item item-body">
<img class="full-image" ng-src="{{items.images.imageXLarge}}">
<div ng-bind-html="items.introtext"></div>
</div>

Kind regards,
Luigi

Please Log in or Create an account to join the conversation.

More
8 years 4 months ago #4551 by mobilechipmunk
Replied by mobilechipmunk on topic Customize jBackapp for K2 items
Is the sample you gave before or after the changes? I have the exact same code in the content.html.

code for sections.html is <div ng-repeat="item in items" class="list card" ng-click="goToContent(items.id)">

<div class="item item-avatar">
<h2>{{items.title}}</h2>
<p>{{items.published_date}}</p>
</div>

<div class="item item-body">
<img class="full-image" ng-src="{{item.images.imageXLarge}}">
<div ng-bind-html="items.content"></div>
</div>

</div>

thes is my controller

controller('SectionsCtrl', function($scope, $state, $stateParams, $ionicPopup, FeedService) {

$scope.items = data.items;

$scope.successGetSectionContent = function(data) {
$scope.maxIntro = 100;
$scope.items = items.articles;
for (var i = 0; i < $scope.items.length; i++) {
$scope.items.content = $scope.items.content.replace(/<[^>]+>/gm, '');
if ($scope.items.content.length > $scope.maxIntro) {
$scope.items.content = $scope.items.content.substr(0, $scope.maxIntro) + '...';
}
}
};


i see the fields from the response I get from postman but not pulling up.

Please Log in or Create an account to join the conversation.

More
8 years 4 months ago - 8 years 4 months ago #4552 by alphaa
Replied by alphaa on topic Customize jBackapp for K2 items
I have the same problem but just in terms of content. My item is not displayed but in "sections" that's good.
Here is the solution:

In controllers.js :

.controller('SectionsCtrl', function($scope, $state, $stateParams, $ionicPopup, FeedService) {

$scope.items = [];

$scope.successGetSectionContent = function(data) {
$scope.maxIntro = 100;
$scope.items = data.items;
for (var i = 0; i < $scope.items.length; i++) {
$scope.items.content = $scope.items.content.replace(/<[^>]+>/gm, '');
if ($scope.items.content.length > $scope.maxIntro) {
$scope.items.content = $scope.items.content.substr(0, $scope.maxIntro) + '...';
}
}
};

In sections.html :

<ion-view view-title="Sections">
<ion-content>

<div ng-repeat="item in items" class="list card" ng-click="goToContent(item.id)">

<div class="item item-avatar">
<h2>{{item.title}}</h2>
</div>

<div class="item item-body">
<img class="full-image" ng-src="{{item.images.imageLarge}}">
</div>

</ion-content>
</ion-view>

this is where I have a problem because my article is not displayed.

In content.html :
<ion-view view-title="sitename- contenu ">
<ion-content>
<div class="item item-avatar">
<h2>{{item.title}}</h2>
</div>
<div class="item item-body">
<img class="full-image" ng-src="{{item.images.imageLarge}}">
<div ng-bind-html="items.content"></div>
</div>
</ion-content>
</ion-view>
Last edit: 8 years 4 months ago by alphaa.

Please Log in or Create an account to join the conversation.

More
8 years 4 months ago - 8 years 4 months ago #4553 by alphaa
Replied by alphaa on topic Customize jBackapp for K2 items
u
Last edit: 8 years 4 months ago by alphaa.

Please Log in or Create an account to join the conversation.

More
8 years 4 months ago #4554 by mobilechipmunk
Replied by mobilechipmunk on topic Customize jBackapp for K2 items
I have the same code and still blank. Where are you getting your friends from? I'm not getting those fields from the json response

Please Log in or Create an account to join the conversation.

Time to create page: 0.088 seconds