Passing ID to PHP function in VaeQL
  • Having some trouble getting the following code to work:


    <v:collection path="exhibitions[hasValidEvents(<v->, $event_day) > 0]">


    hasValidEvents is a PHP function in __vae.php, and it returns a 0 or a 1 for every entry. I can manually call it inline with no issues as such:


    <v=hasValidEvents('1240912', $event_day)>


    This will return a 1 or 0 properly, but trying to use or any other way I know to access the ID does not have the desired result.

  • 2 Answers sorted by
  • This will not work because PHP functions don't work in VaeQL predicates. You should use a loop in PHP that loops through the exhibitions. You could create your own tag using vae_register_tag() that only renders the inside tags if that function returns true.

  • OK, I'm going to try what you suggest - however I drew the conclusion that my approach would work from the blog:
    http://vaeplatform.com/blog

    "Now VaeQL supports the entire PHP function library, and you can even define your own functions in PHP and use them in VaeML. All the old functions are there too...

    Functions can take arguments, which can be paths, variables, functions, or a full VaeQL query in its own right."


    The main thing I'm trying to avoid is breaking the synchronicity between the v:collection tag and v:paginate. Otherwise, I could easily accomplish what I'm trying to do in a nested v:if.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

In this Discussion