Categories
Closed this issue · 4 comments
I'm trying to pull categories via this JSON extension. I found out how to do so with this: #7. When I pull the source to my page I can see that it is fetching the categories, but my code isn't pulling them to my external source. For instance, the code below will fetch everything but category_group, and I assue you that isn't empty. Take a look below:
Template Code:
{exp:json:entries channel="gathering" show_categories="yes" fields="title|url_title" }
Template Output:
http://www.lcbcchurch.com/mobileJSON/gatherings
External Code trying to pull the JSON:
$('.loading-wrapper').append('<div class="loading">Your page is loading…</div>');
$.ajax({
url: "http://www.lcbcchurch.com/mobileJSON/gatherings",
dataType: "json",
success:function(data){
eventResults(data);
}
});
function eventResults(data) {
for(var i = 0; i<data.length;i++){
$(".gathering").append("<a href='#"+data[i]["url_title"]+"' class='campus' rel='external'><h1>"+data[i]["title"]+"</h1>"+data[i]["category_group"]+"");
}
$('.loading-wrapper').empty();
// Call the pics ready function
}
Thoughts?
try console.log(data) where you have eventResults(data), and then paste the result from your console here.
[
Object
categories: Array[4]
entry_id: 544
title: "More than Ordinary"
url_title: "more-than-ordinary"
proto: Object
defineGetter: function defineGetter() {
length: 2
name: "defineGetter"
proto: function () {
defineSetter: function defineSetter() {
length: 2
name: "defineSetter"
proto: function () {
lookupGetter: function lookupGetter() {
length: 1
name: "lookupGetter"
proto: function () {
lookupSetter: function lookupSetter() {
length: 1
name: "lookupSetter"
proto: function () {
constructor: function Object() {
create: function create() {
defineProperties: function defineProperties() {
defineProperty: function defineProperty() {
freeze: function freeze() {
getOwnPropertyDescriptor: function getOwnPropertyDescriptor() {
getOwnPropertyNames: function getOwnPropertyNames() {
getPrototypeOf: function getPrototypeOf() {
isExtensible: function isExtensible() {
isFrozen: function isFrozen() {
isSealed: function isSealed() {
keys: function keys() {
length: 1
name: "Object"
preventExtensions: function preventExtensions() {
prototype: Object
seal: function seal() {
proto: function () {
hasOwnProperty: function hasOwnProperty() {
length: 1
name: "hasOwnProperty"
proto: function () {
isPrototypeOf: function isPrototypeOf() {
length: 1
name: "isPrototypeOf"
proto: function () {
propertyIsEnumerable: function propertyIsEnumerable() {
length: 1
name: "propertyIsEnumerable"
proto: function () {
toLocaleString: function toLocaleString() {
length: 0
name: "toLocaleString"
proto: function () {
toString: function toString() {
length: 0
name: "toString"
proto: function () {
valueOf: function valueOf() {
length: 0
name: "valueOf"
proto: function () {
That's just one of the objects expanded. Does that help? Thanks!
OK. Categories is an array, so you actually want to do this:
+data[i]["categories"][0]["category_group"]+
Thanks, that worked perfectly!