Forum

Thread tagged as: Blog

Blog SectionID

I have a blog with three sections: let's call them: Section1, Section2, Section3

I'd like to add some html code to the top of each post page depending on whether the post a visitor is viewing is from Section1, Section2 or Section3..

I was hoping to use:

    <perch:if exists="sectionID" value="Section1">
        <p>Section1 content goes here</p>
    </perch:if>

    <perch:if exists="sectionID" value="Section2">
        <p>Section2 content goes here</p>
    </perch:if>

    <perch:if exists="sectionID" value="Section2">
        <p>Section3 content goes here</p>
    </perch:if>

When I try that I get all three "Sectionx content goes here" messages and not just the one that perch:if should be displaying. In fact, it doesn't seem to matter what I have entered for value, all three messages get output.

Thanks!

Franz Neumann

Franz Neumann 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

exists doesn't use value - I think you want id.

But also if that's our sectionID variable, it will always be an integer.

Thanks Drew.