Certain loop behavior has me confused about when to use "../"



  • So I'm theming the list of topics in a category and I encountered some unexpected behavior regarding when to use something like {topics.title} vs {../title}.

    The relevant code for category.tpl is this:

    <!-- BEGIN topics -->
    <!-- IMPORT partials/category/topic.tpl -->
    <!-- END topics -->
    

    And inside partials/category/topic.tpl:

    {../title}
    {../postcount}
    {../viewcount}
    {../teaser.user.username}
    

    API data:

    {  
        "name":"General Discussion",
        "title":"General Discussion",
        "description":"A place to talk about whatever you want",
        "topics":[  
            {  
                "title":"Hey now",
                "postcount": 3,
                "viewcount": 3,
                "user":{  
                    "username":"testuser"
                },
                "teaser":{ 
                    "content":"<p><a class=\"plugin-mentions-a\" href=\"http://localhost:4567//uid/7\">@testuser</a> Does this notify you?</p>\n",
                    "user":{  
                        "username":"zombachu"
                    }
                }
            },
            {  
                "title":"test",
                "postcount":23,
                "viewcount":8,
                "user":{  
                    "username":"zombachu"
                },
                "teaser":{  
                    "user":{  
                        "username":"zombachu"
                    }
                }
            }
        ]
    }
    

    Why does ../whatever in topic.tpl give me the data in the topic that I'm asking for, but {../title} give me the category's title instead of the topic's title? {topics.whatever} works for everything too, including title but it feels weird to me referring to a variable that doesn't exist in topic.tpl.

    I understand that .. typically means going up a level/directory but in Persona's categories listing they do the same in partials/categories/item.tpl. Am I doing something incorrectly or is this a bug?


Log in to reply
 


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.