What version of Ghost are you using?
v4.3.3
How was Ghost installed and configured?
running local dev using ghost-CLI
Hi there,
I’m working on creating an music portfolio website theme for Ghost. I’m trying to use the ghost’s routing to provide data for all posts tagged ‘portfolio’, and display template html components for each post.
My problem is that I don’t understand how to access the data in my template. The docs mention a {{#tag}} helper, but this helper doesn’t seem to have its own entry in the docs, only {{#tags}} which I believe isn’t what is needed, since I’m trying to display the list of posts from within the tag API call.
here’s what my dev/setting/routes.yaml looks like :
Summary
routes:
/portfolio/:
template: portfolio
data: tag.portfolio
collections:
/:
permalink: /{slug}/
template: index
taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/
I’m using the internal tag ‘#portfolio’ but I’ve renamed the slug appropriately, dropping the ‘hash-’ (see pic). I’m noticing that navigating to ‘localhost:2368/tag/portfolio/’ is giving a 404, but maybe that is normal behaviour for internal tags? When I am navigating to external tags, they are displaying fine.
Here’s my failed attempt to add the data to my template (portfolio.hbs). However, right now, none of the elements within the block are appearing in the DOM. I’m trying to use the {{#post}}{{/post}} helper, and i’ve also swapped this for {{#tag}}{{/tag}} with the same result. This code was previously working fine using a direct {{#get}} call, which is commented out here.
Summary
{{!-- {{#get "posts" include="tags" filter="tag:portfolio" formats="plaintext"}}
{{#foreach posts}} --}}
{{#post}}
{{#foreach posts}}
<div class="portfolio-item" id={{slug}}>
<img src={{feature_image}}
onload="var self=this;setTimeout(function(){self.style.opacity=1;},100);" style="opacity: 1;" />
<div class="portfolio-item-detail">
<div class="portfolio-item-header">
<div class="portfolio-item-header-left split-block"></div>
<div class="portfolio-item-header-right split-block"></div>
</div>
<div class="portfolio-item-playlist">
<img class="portfolio-item-play-arrow" src="{{asset "ui/portfolio/play-arrow.svg"}}" />
</div>
<div class="portfolio-item-text">
{{plaintext}}
</div>
</div>
</div>
{{/foreach}}
{{/post}}
{{!-- {{/get}} --}}
</div>
Thanks in advance for the help! I’m sure there’s a simple way to make this work, but I’m not seeing how from the documentation I’ve been reading. Finally, I should mention that I have been restarting my local Ghost every time I change the routing file ;)
Fili