Jump to content

Recommended Posts

Posted

Hello guys.

I'm trying to find a list of products that can belong to several areas, the areas consist in a number or numbers separated by "|" like the following example:

1.- Some products:

product = 31  -> areas = 3|16     belongs to area 3 and 16

product = 32  -> areas = 2|14

product = 33  -> areas = 5

product = 34  -> areas = 3

2.- Area I'm looking for:

$area = 3

3.- My selector

$products = $pages->get("/product/")->find("areas=$area");

4.- results

I'm getting product 34 whereas I would like to get product 31 as well. Any ideas?

Thank you.

Posted

Yes its a textfile, the problem is that using *=  in the following case

$area = 3

product = 31  -> areas = 2|13   

product = 34  -> areas = 3

 

It would match 3 and 13

Posted

I've used this type of method for various things in the past, perhaps not on PW, but the way I've done it is to surround the entire string with the "\" character, eg |2|13|

This way I believe you can use the %=|3| selector to find only the 3

edit: and you could also use %=|3 to find 31, 310, 35 etc

  • Like 1
Posted

No. If you really want to use this textfield approach, use muzzer’s technique and make sure every area is wrapped in pipe symbols, so you can select areas %= '|$area|'.

However you should be aware that that’s not a good idea at all. If it’s at all possible to use pagefields, as LostKobrakai suggested, you should do that. Once you have set up your areas as pages, it will make everything much easier.

  • Like 1

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