solved variables in jrCore_list search

blindmime
@blindmime
11 years ago
772 posts
I have skin page where I want to list items from jrFile. My jrProfile datastore has a field I've named profile_salesperson. I get this value into the page via the url like http://domain.net/proofs?rep=Some+Name.

My jrCore_list is:
{jrCore_list module="jrFile" search1="file_approved != on" order_by="file_display_order numerical_asc" pagebreak="10" page=$_post.p pager=true}

I want to add a search2 to list only jrFile items from profiles where profile_salesperson = $rep.
updated by @blindmime: 05/21/14 01:27:52PM
brian
@brian
11 years ago
10,149 posts
{jrCore_list module="jrFile" search1="file_approved != on" search2="profile_salesperson = `$rep`" order_by="file_display_order numerical_asc" pagebreak="10" page=$_post.p pager=true}

Let me know if that works for you - I believe profile/user keys are always searchable even in list calls to other modules.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
blindmime
@blindmime
11 years ago
772 posts
Yes, I actually tried that, but the list is blank if I add that search2.

I do see both values in {debug}.
brian
@brian
11 years ago
10,149 posts
blindmime:
Yes, I actually tried that, but the list is blank if I add that search2.

I do see both values in {debug}.

When you say "blank" do you mean you get a blank page (i.e. php error) or just that there are no results?

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
blindmime
@blindmime
11 years ago
772 posts
No results with the search2 addition as above.
brian
@brian
11 years ago
10,149 posts
Are you sure that $rep is the correct value? It should work.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
blindmime
@blindmime
11 years ago
772 posts
Yes, I have it outputting in the page header OK.

Here's my code (maybe I'm typing something wrong...

{jrCore_list module="jrFile" search1="file_approved != on" search2="profile_salesperson = `$rep`" order_by="file_display_order numerical_asc" pagebreak="10" page=$_post.p pager=true}
brian
@brian
11 years ago
10,149 posts
Yeah that looks correct - if you leave off search2 does it return results?

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
SteveX
SteveX
@ultrajam
11 years ago
2,587 posts
Is the profile_salesperson the same profile as the file? Or is it that the salesperson (who has their own separate profile) needs to see the unapproved file list?


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
blindmime
@blindmime
11 years ago
772 posts
If I leave off search2 I get a list of all the unapproved files. Which is good. But additionally, I want a list of unapproved files pertaining to each salesperson. (Incidentally if search1="file_approved = off" doesn't give me the same list as search1="file_approved != on").

The profile_salesperson is not the same as the profile the item belongs to. Basically, I have profiles for clients. jrFile items are added for each job we are doing for those clients. The clients are given a url to go download a pdf and proof their job. They can make changes or approve jobs via jrComments. Each client profile has a profile_salesperson (not each jrFile item or proof). I have a page built where I pass in the salesperson's name via $rep and I want it to pull all of the unapproved proofs for a particular salesperson so they can track their jobs.
brian
@brian
11 years ago
10,149 posts
blindmime:
(Incidentally if search1="file_approved = off" doesn't give me the same list as search1="file_approved != on").

Correct - and it's important to understand that distinction. The way the JR5 DataStore works is that it only stores information for item keys that have a value - i.e. file_approved will only be set on items where a value for that field has been created (possibly on an update form for an item).

So when you use a != indicator, you are going to get EVERY item that not only does the key not equal the value, but you are also going to get every item where that key has not been set.

When you do file_approved = off, you are specifically looking for that key with that value - items that are missing the file_approved key will not appear.

So in your case the file_approved != on is probably the one you want.

Quote:
The profile_salesperson is not the same as the profile the item belongs to. Basically, I have profiles for clients. jrFile items are added for each job we are doing for those clients. The clients are given a url to go download a pdf and proof their job. They can make changes or approve jobs via jrComments. Each client profile has a profile_salesperson (not each jrFile item or proof). I have a page built where I pass in the salesperson's name via $rep and I want it to pull all of the unapproved proofs for a particular salesperson so they can track their jobs.

Yeah that's the problem - the profile info that gets search is the profile that is attached to the item (the item creator) - NOT the rep that is doing the searching. This is why there are no matches.

The only way I can think of to do this is to have a custom field in the file item - something like file_rep_id that gets filled in with the rep ID - you can then easily search on both criteria.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
blindmime
@blindmime
11 years ago
772 posts
If I pull up {debug} I can see the profile_salesperson for each item in the list. (at least I think that's what I'm seeing) Are you sure I can't search this? It would make things so much better.

Maybe there's another way to achieve this without adding another field I have to enter something into with every job?

If I have to make another field, is there a way to pull a value into it on creation, based on item's profile?
blindmime
@blindmime
11 years ago
772 posts
I get profile_salesperson => "Some Name" 10 times in the $_items array on that page.
michael
@michael
11 years ago
7,806 posts
then you should be able to use it:

same code as brian pasted above:
{jrCore_list module="jrFile" search1="file_approved != on" search2="profile_salesperson = `$rep`" order_by="file_display_order numerical_asc" pagebreak="10" page=$_post.p pager=true}

if thats not working, then it could be $rep thats wrong, try with the actual name
{jrCore_list module="jrFile" search1="file_approved != on" search2="profile_salesperson = Some Name" order_by="file_display_order numerical_asc" pagebreak="10" page=$_post.p pager=true}
blindmime
@blindmime
11 years ago
772 posts
The code Brian pasted is what I was trying but wasn't working. So I started this thread.

I think I may have found an issue with the search. After further testing, search2="profile_salesperson = `$rep`" does work, but only if the value is one word (has no spaces).

Do I need to encode the space?
michael
@michael
11 years ago
7,806 posts
try it with '' around it
search2="profile_salesperson = '`$rep`'"
blindmime
@blindmime
11 years ago
772 posts
Didn't work.
SteveX
SteveX
@ultrajam
11 years ago
2,587 posts
Quote: My jrProfile datastore has a field I've named profile_salesperson. I get this value into the page via the url like http://domain.net/proofs?rep=Some+Name.

So $rep = "Some+Name".

Is that what you have stored in the database as profile_salesperson? Exactly "Some+Name".

If not you will need to account for the encoding you have added in your url before searching.

Otherwise you are searching for "Some+Name" which may not exist in your database so it isn't found. (I expect you need to search for "Some Name" not "Some+Name")


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
SteveX
SteveX
@ultrajam
11 years ago
2,587 posts
{$rep = $rep|replace:"+":" "}


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
blindmime
@blindmime
11 years ago
772 posts
No. profile_salesperson is "Some Name". $rep is also "Some Name". it's just brought in via the url as http://domain.net/proofs?rep=Some+Name. In the {debug} it shows as "Some Name" and outputs on the page as "Some Name".

I'm not searching for "Some+Name" (although I've tried that, as I've tried a thousand other ways).

Searching for "Some Name" produces nothing in the list. There is something not working in the search. I've hard coded the value and I've tried a thousand other ways. The only way it works is if the value is one word.
brian
@brian
11 years ago
10,149 posts
I think I see the root cause here in the profile search_params listener - there is a bug that is only returning the first 3 space separated elements of the search - good catch.

Let me get that fixed up and a new release pushed out.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
brian
@brian
11 years ago
10,149 posts
OK this should be fixed now in version 1.1.19 of the User Profiles module - update and let me know if that fixes it for you.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
blindmime
@blindmime
11 years ago
772 posts
Thanks, guys. What a team!
blindmime
@blindmime
11 years ago
772 posts
I believe it's working perfectly, Brian. Thanks again.
brian
@brian
11 years ago
10,149 posts
blindmime:
I believe it's working perfectly, Brian. Thanks again.

Right on - glad to hear that.

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

Tags