Jump to content

Recommended Posts

Posted
$products = $pages->find("parent=/fabrics/");
foreach ($products as $product) {
 echo $product->code; //Produces the correct alphanumeric value
 echo $product->collection; //This produces a number. Should be something like 'Avanti'
}

Hey there, as the title suggests I am only getting a numeric id from the above code. You can assume that all other code and values for this template work fine and that there is a field in this template called collections.

So I thought I would get the value of this field. What am I missing?

Thanks in advance!

Posted

Looks fine from here. What field is it, that you called collection? Did you doublecheck for spelling issues, in your post you mention "collections", while in the code it's "collection".

Posted

Sounds a bit like "collection" might be a Page type field. If that's the case, try something like $page->collection->title (if it's set to contain one Page) or $page->collection->first()->title (if it's set to contain multiple Pages).

  • Like 2
Posted

Thanks to you both! The $page->collection->first()->title solution was the one that worked as you were quite right it was a page field.

Thanks a lot 

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...