Jump to content

getTag and getRandom (solved)


mel47
 Share

Recommended Posts

Hi,

I have this working line to find a specific image.

$banniere = $pages->get(1)->images->findTag('banniere')->getTag($user->language->name);

But now, I want to add getRandom(). I tried different versions

$pages->get(1)->images->findTag('banniere')->getTag($user->language->name)->getRandom()
$pages->get(1)->images->getRandom()->findTag('banniere')->getTag($user->language->name)

but always received this error : Method Pageimage::getRandom does not exist or is not callable in this context.
Is it compatible? How I can do that?

Thanks!
Mel

EDIT : solved by myself. Error I commonly do, mixing up get() and find()...  Sorry for the disturbance.

$banniere = $pages->get(1)->images->findTag('banniere')->findTag($user->language->name)->getRandom();

 

 

Edited by mel47
solved myself...
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...