• Resolved Grey Man

    (@christopher-greenhough)


    I don’t like to ask for help until I’ve tried to resolve a problem myself, but I cannot seem to get nested loops to work. Maybe I’ve missed something obvious, but as I need to resolve this soon I’m hoping someone else can see it : )

    Here’s the feed I’m working with:
    http://www.smart-feeds.com/getfeeds.aspx?Param=event/live/open

    And one example of where I’m at with the shortcode in WordPress:

    [jsoncontentimporter url="http://www.smart-feeds.com/getfeeds.aspx?Param=event/live/open" numberofdisplayeditems="-1" urlgettimeout="10" oneofthesewordsmustbein="Football" oneofthesewordsmustbeindepth="2" basenode="liveEvents"]
    {subloop:event:1}
    <h3>{sport}</h3>
    <small>{group}</small>
    <h4>{name}</h4>
    {/subloop:event}
    [/jsoncontentimporter]

    This is fine. However, I cannot, however hard I try, find a way to retrieve the [path] (array? ) information nested within each {event}.

    Likewise, I’m able to access the first-level data within the parallel {liveEvent} which I need to match up with {event}. That’s fine. But again, the nested {matchClock} or {score} I’m drawing a blank on. My {subloop} or {subloop-array} code is printing out within the post for these, so something is not right.

    I must be making a syntax error or something, but I’m stumped.

    Found this link useful for an easy way to see the data structure:

    Can you help?

    https://ww.wp.xz.cn/plugins/json-content-importer/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter Grey Man

    (@christopher-greenhough)

    Weird, it didn’t keep the link I wanted to post. Let’s try again: http://jsonviewer.stack.hu

    Plugin Author berkux

    (@berkux)

    Hi Grey Man,

    accessing [path], {matchClock} or {score} is possible, the template-code is a bit tricky.

    But there’s one issue: If “0” is the value of the JSON, yet nothing is displayed.
    Here’s the deal: Donate what it’s worth for you, and I’ll fix this.

    Best
    Bernhard

    Thread Starter Grey Man

    (@christopher-greenhough)

    Hahaha. I had a feeling you might say that. How about I donate $5 since that’s honestly all I have in my PayPal account. Next month I’m happy to donate more. Is that fair? : )

    Thread Starter Grey Man

    (@christopher-greenhough)

    Having trouble with the PayPal login so I’ve sent a payment to your email address (from Chris G). Thank you.

    Thread Starter Grey Man

    (@christopher-greenhough)

    Obviously it’s worth more than that. I apologize for the paltry sum.

    Plugin Author berkux

    (@berkux)

    I’ll rembember you on 1st of april 😉

    try:
    {subloop:event:1}<h3>{sport}</h3> <small>{group}</small><h4>{name}</h4>{subloop-array:event.path:3}{id} {englishName}
    {/subloop-array:event.path}
    liveData: {subloop:liveData:3}eventId: {eventId}
    time: {subloop:liveData.matchClock:3}{liveData.matchClock.period}
    {/subloop:liveData.matchClock} standing: {subloop:liveData.score:3}{home} {away}
    {/subloop:liveData.score} {/subloop:liveData}{/subloop:event}

    “{home}” and “{away}” is “0” so this is not displayed and the described problem I’ll fix.

    Thread Starter Grey Man

    (@christopher-greenhough)

    Aha! Thank you so much, I’ll try that. I’ve been banging my head against it for hours. Didn’t realize I could use dot notation. Takes me back to my Flash ActionScript days. Truly appreciate your help. And I’m sorry for the meagre donation. If you don’t receive more next month, feel free to drop me a line with a gentle reminder!

    Thread Starter Grey Man

    (@christopher-greenhough)

    Thanks Bernhard. Perfect. For now I’ve solved the “0” issue by checking the blanks with jQuery and inserting text where required. A working solution. Next stop would be, I guess, ajax updating the scores from the json feed.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘No luck with nested subloop or subloop-array’ is closed to new replies.