Jump to content

Urlsegment + combo field


Krlos
 Share

Recommended Posts

I'm trying to use Urlsegment + combo field, but have this problem I can't solve:

I have a combo field with some fields and one category field based on a page reference field.

When I try to filter content using the first url segment urlSegment1, I get no data, but if I use the page reference page ID it works.

Code to filter:

$segmento1 = $input->urlSegment1; (in this case "domo")

$filter = $pages->find("template=alojamiento, alojamiento_combo=$segmento1, sort=random, limit=20");

This wont work:

template=alojamiento, sort=random, alojamiento_combo=domo, limit=20

This works:

1184 being the ID of the page reference field.

template=alojamiento, sort=random, alojamiento_combo=1184, limit=20

I also tried, but don't work:

template=alojamiento, sort=random, alojamiento_combo.categoria=domo, limit=20

Any help is appreciated.

Link to comment
Share on other sites

Have you tried "alojamiento_combo.category.name=$segmento1"? If that doesn't work, then, as far as I understand the docs, you'll probably need to convert the name in your URL segment to a full path (e.g. "/categorias/domo/" or wherever in your structure the category is located). The docs say:

Quote

When searching single or multi-page reference fields, you can search by page ID or path.

You could of course retrieve the category in a separate query and use the return in your selector.

$categoria = $pages->get("template=categoria, name=$segmento1");
$filter = $pages->find("template=alojamiento, alojamiento_combo.categoria=$categoria, sort=random, limit=20");

 

  • Like 1
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...