solved Profile Specific Listing - Coding Question

Ken Rich
Ken Rich
@ken-rich
8 years ago
926 posts
I created a new module with Aparna.

If I place this code on the item_list.tpl page it lists only the products owned by the profile. If I place it on the item_detail.tpl page it lists all the products for the whole network.

I don't understand why and want to know how to rewrite it so that only the products owned by the profile are listed when the code is installed on a detail page.

  {jrCore_list module="jrStore" profile_id=$_profile_id order_by="product_display_order numerical_asc" pagebreak="4" page=$_post.p pager=true}




--

Ken Rich
indiegospel.net

updated by @ken-rich: 07/25/16 01:47:07AM
michael
@michael
8 years ago
7,717 posts
when you don't understand why, then its time for {debug}

Docs: "{debug}"
https://www.jamroom.net/the-jamroom-network/documentation/development/1477/debug

You need to know what you are asking for, in your case there are only 2 variables
{jrCore_list module="jrStore" profile_id=$_profile_id order_by="product_display_order numerical_asc" pagebreak="4" page=$_post.p pager=true}
Other than $_profile_id and $_post.p all other requested info is clearly visible. So the difference is probably that the values of {$_post.p} and {$_profile_id} are different on different pages.

--edit--
In a case like that I would put this code to see what their values are
$_profile_id: {$_profile_id} <br>
$_post.p : {$_post.p} <br>
{jrCore_list module="jrStore" profile_id=$_profile_id order_by="product_display_order numerical_asc" pagebreak="4" page=$_post.p pager=true}

updated by @michael: 04/22/16 05:02:09PM
Ken Rich
Ken Rich
@ken-rich
8 years ago
926 posts
On the list page it comes back:
$_profile_id: 1175
$_post.p :          

On the detail page:
$_profile_id: 
$_post.p :          

I don't really see how that is helpful to me though. I had already inferred that the list.tpl was listing items specific to my profile and the detail.tpl was listing for all profiles.

My problem is, I don't know how to make the item_detail.tpl page behave like the item_list.tpl page, in terms of only listing items specific to the profile.

Is that something determined in the php for the module, or can a change to the code I'm using in the template produce the desired result? That is, a change to this code:

{jrCore_list module="jrStore" profile_id=$_profile_id order_by="product_display_order numerical_asc" pagebreak="4" page=$_post.p pager=true}

I've looked at all the list variables in the documentation and if there is a way - I'm not seeing it. Or perhaps I am staring right at it but not comprehending.


--

Ken Rich
indiegospel.net
michael
@michael
8 years ago
7,717 posts
Staring right at it, yep.

Maybe its a thought process thing, the code you're using is not magic, its language, just like English is a language.

When you ask for two different things it shouldn't be a surprise that you get two different results.

In one of the requests your asking:
* "Can I have a list of store modules in this order....."

In the other
* "Can I have a list of store modules from profile 1175 in this order....."

The server is replying to you by giving you what you asked for.

If you want both locations to be the same, you have to ask the same question.

you're wanting the list to be from profile 1175, so you need to pass in the 1175 to the jrCore_list function.

the debug panel will tell you if 1175 is available to you at all in that location. It might be on a different variable name, but thats ok. Use whatever variable name its on.

--edit--
You'll probably find it on
profile_id=$item._profile_id

updated by @michael: 04/23/16 12:57:48AM
Ken Rich
Ken Rich
@ken-rich
8 years ago
926 posts
Hi Michael,

I saw your edit after I solved it - lol.

I did the debug and saw that it was under $ post and $ item. I chose $item.

Knowing nothing about coding conventions I initially tried it as :
profile_id=$item_profile_id
but that didn't work. Then I tried
profile_id=$item.profile_id
which DID work but when I saw your edit I revised to
profile_id=$item._profile_id

I'm still not clear as to why this was not necessary on the item_index.tpl or how one is supposed to know when a . instead of a _ is necessary, but at least I'm able to achieve the desired outcome on this particular issue. Thanks.


--

Ken Rich
indiegospel.net