Forum
Perch blog category conditional
I'm currently using this in one of my blog templates in order to pull out the catTitle
.
<perch:categories id="categories" set="news">
<perch:if id="catTitle" match="eq" value="Athlete Spotlight">
<div class="athlete-spot"><span><perch:category id="catTitle" /></span></div>
</perch:if>
</perch:categories>
What I also want to do (because I am pulling out two categories of news), is have a slightly different html structure and I'd like to ensure the blog excerpt doesn't get output for posts belonging to the category of articles
. I tried:
<perch:categories id="categories" set="news">
<perch:if id="catTitle" match="neq" value="Athlete Spotlight">
<div class="news-excerpt">
<perch:blog id="excerpt" type="textarea" textile="true" chars="240" append="..." />
</div>
</perch:if>
</perch:categories>
Then realized that doesn't work as I'm trying to access the blog namespace within categories. What options are there for this type of thing, would I need to somehow ascertain the post category in my page and pass that into the template? Or could it be done in the template alone?
Does
excerpt
appear in the parent scope?It does indeed. With that thought I wrote:
Although this doesn't work, if I showall inside of the categories I can see parent.excerpt. I assuming I am trying to access the excerpt incorrectly inside the template
Ok scrap that, I assumed I needed to map the parent scope to the variable, i.e
blog.excerpt
- I was wrong. Got it working:Thanks Drew <3