Forum

Thread tagged as: Question, Field-Types

Check value within array in template

Hi,

I have created a file type which returns an array, which works great, I simply want to check if a value within the array exists.

<perch:if exists="venue-link['profile']" >
                <div class="col-md-3"><img class="img-responsive" src="<perch:events id="venue-link" type="teamlist" output="profile" />"></div>
                <div class="col-md-9">
                <perch:else />
     <div class="col-md-12">
</perch:if>

Can it be done?

Here is the returned array

Array
(
    [path] => /the-team/linda-tallent.php
    [title] => Linda Tallent
    [navtext] => Linda Tallent
    [id] => 30
    [profile] => 
    [name] => Linda Tallent
    [info] => Linda has gained a reputation for providing training that gives clear, practical, realistic advice. She has over twenty years experience working as a teacher, senior leader in nursery and primary schools and as a local authority Primary and Teaching consultant with a specialism in Early Years. Linda’s training is informed by her experiences in schools, observations and research findings. She has contributed to local authority conferences as a keynote speaker and has a proven track record of delivering high quality training courses. 

To date, Linda has published three books offering practical guidance relating to EYFS, inclusion and raising boys’ achievement. 

Linda was a series consultant for the Oxford University Press Project X Phonics books, published in 2010, for Getting the Best out of Boys Guide, published in 2011, Project Alien Adventures published in 2013 and Big Writing Adventures published 2015. 

Linda is a CE4O accredited Early Years Sector Specialist and has a Master's degree in Early Education and Care.
    [_default] => 
)
Adam Barnes

Adam Barnes 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

No, but you could flatten your array (perhaps in addition) and then use something like venue-link-profile

Hi Drew,

How do you mean?

Thanks

Drew McLellan

Drew McLellan 2638 points
Perch Support

Which part is confusing?

How to flatten the array in perch, would it happen in the template, the layout or the filetype?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Perch won't do it for you, you'd need to do it yourself in your field type.