Jump to content

Multi lang and repeaters in a page field


Recommended Posts


I'm using repeaters (lang_image) for images with multi language captions in a template. These pages are used in a page fieldtype. Everything works fine with the default language (swedish) but not when i switch to english. Then i get this:

Error: Call to a member function size()... 

My code looks like this:

foreach ($page->person as $pers) {
    echo "<img src='{$pers->lang_image->first()->images->size(300,300)->url}'>";

Got this working, not sure how though since the code is the same as the one i tried yesterday.  :huh:

Forgot to change language. Still doesn't work.

Link to comment
Share on other sites

When you get that error message "call to member function size()", what is 'images' ? Is it NULL or is it a single image field that has become a multi-image field? To tell, you could try doing a var_dump() on it or this:

$images = $pers->lang_image->first()->images;
echo "images is: ";
if(is_null($images)) echo "NULL";
  else if(is_object($images)) echo get_class($images); 
  else var_dump(images);  

If it turns out that it's null, then I'd be curious what the first() is returning to you. You could run the same code on that result. We know it's got to be an object since the error occurred on the size() call and not on images. 

$first = $pers->lang_image->first();
echo "first is: " . get_class($first); 

Please let me know what you find?

Link to comment
Share on other sites

The first code snippet returns "images is: Pageimage" for the  default language.

Switching to non-default returns "images is: NULL".

The second code snippet returns "first is: RepeaterPage" for default language. Non default language returns "" (empty/nothing).

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

  • Recently Browsing   0 members

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