HTML Logo by World Wide Web Consortium ( Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.

URGENT How to create a module?

Login / Search

 [ Join | More ]
 Add topic 
#103449 (In Topic #20247)

Non-joined user

I need module that will show all entries of a user on profile page.

Any ideas?

Back to the top
Item has a rating of 5 (Liked by Chris GrahamLiked by FletchLiked by Jean)  

Community saint

First, I'll say if you plan on doing some more customisations like this, you should probably spend considerable time learning the programming side of ocPortal so you are in a better position to help yourself. Or as Chris suggested in the other message thread, open a paid support ticket if it is something you really must have. If you aren't a programmer, the learning curve can be pretty steep. I'm not a programmer by trade, but I'm also not new to programming in general. I started using ocPortal a couple of years ago and I'm still learning! If you want to learn the ocPortal system, here are three pages that contain just about everything you need to know about the programming side of things for ocPortal v9:

Also check out the Official Docs and Community Docs links in the Support link in the menu at the top of this page.

With that said, don't let that discourage you from asking for help! If you get hung up on something, and can't find the answer in the documentation, ask and hopefully someone will be able to point you in the right direction.

I don't think this is going to be a particularly easy customization (db queries make my head hurt). It's not a simple case of a little tweak here and a little tweak there, but still very possible. You would need to create a profile tab hook. You can see examples of the hooks for the existing tabs in the sources\hooks\systems\profiles_tabs directory. You would create your hook in the sources_custom directory at sources_custom\hooks\systems\profiles_tabs. Using an existing hook file as a template to create a new hook in the sources_custom location, here is an example to get you started: 


  1. <?php
  3. class Hook_Profiles_Tabs_member_products
  4. {
  6.         /**
  7.          * Find whether this hook is active.
  8.          *
  9.          * @param  MEMBER                       The ID of the member who is being viewed
  10.          * @param  MEMBER                       The ID of the member who is doing the viewing
  11.          * @return boolean                      Whether this hook is active
  12.          */
  13.         function is_active($member_id_of,$member_id_viewing)
  14.         {
  15.                 //The return of this function will need to be altered. It determines whether the tab is
  16.                 //visible or not. return true; makes the tab always visible even if there is no content.
  17.                 //You would need to run a query to see if the Products catalog contains entries where the
  18.                 //submitter ID is equal to $member_id_of. If the query returns results, the return value
  19.                 //would be true if the query doesn't return any results,
  20.                 return true;
  21.         }
  23.         /**
  24.          * Standard modular render function for profile tab hooks.
  25.          *
  26.          * @param  MEMBER                       The ID of the member who is being viewed
  27.          * @param  MEMBER                       The ID of the member who is doing the viewing
  28.          * @param  boolean                      Whether to leave the tab contents NULL, if h hook supports it, so that AJAX can load it later
  29.          * @return array                        A triple: The tab title, the tab contents, the suggested tab order
  30.          */
  31.         function render_tab($member_id_of,$member_id_viewing,$leave_to_ajax_if_possible=false)
  32.         {
  33.                 //Require any language or source files needed. Multiple requires may be needed depending on what you're doing.
  34.                 //Uncomment, modify, and/or add any require_lang or require_code lines you need.
  35.                 //require_lang('language_ini_file');
  36.                 //require_code('source_file');
  38.                 //$title is the name of the tab
  39.                 $title="Products";
  41.                 //$order is where the tab will be in the row of tabs. Lower number means closer to left, higher number means farther to the right.
  42.                 //A quick test on a default installation showed a value of 10 or less puts the tab as the first tab, a value of 11 puts the tab in
  43.                 //the second tab slot, a value of 199 would put the tab just to the left of the Edit tab.
  44.                 $order=11;
  46.                 //I'm not really sure how the ajax stuff works. I'm guessing this might be to only load the tab contents
  47.                 //when the tab is selected so the profile page isn't loading all of the data for all of the tabs at once?
  48.                 if ($leave_to_ajax_if_possible) return array($title,NULL,$order);
  50.                 //Here is where the fun starts. Gather your data and put it into the HTML that will display in the tab.
  51.                 //If you want to separate the data from the HTML to make it easier to make layout changes you would have to
  52.                 //learn the ocPortal template system. Separating the data from the HTML would allow you to pass the data to
  53.                 //a template. And then, to change the layout of the data in the tab, all you would have to do is edit the
  54.                 //template(s) instead of re-coding the $content variable in this code.
  55.                 $content="Your HTML tab content here.";
  58.                 //This returns your tab data to the calling function so it can render your tab.
  59.                 return array($title,$content,$order);
  60.         }
  62. }

I have commented the code to explain what things do and what things you will still need to do to complete it. Off the top of my head, I couldn't tell you how to query the Products catalogue to get just the products for the specific user. Chances are you may be able to re-use some of the code from the sources\blocks\main_cc_embed.php to generate the data for the $content variable. The main_cc_embed.php block doesn't filter the query results to a specific user, so that is where you will have to go digging through the documentation and experiment a little. I probably won't have time to tackle this further until next week.
Back to the top

Community saint

Attached to this post is an archive, This will place a Products tab on the member profile page if the member has submitted items to the products catalogue. The tab should only contain items submitted by the member being viewed and it was written to only work for the default products catalogue. If you have other catalogues marked as ecommerce catalogues, the member_products.php script will need to be revised. This isn't 100% tested, but so far it seems to be working. The main thing I haven't tested are permissions. If you have special permissions on some product categories, the code for member_products.php will need to be updated to account for that. Otherwise I believe it will show all products from all categories that were submitted by the member of the member profile being viewed.

This consists of one script and two templates:


member_products.php - place this file in sources_custom\hooks\systems\profiles_tabs
*.tpl - place both template (.tpl) files in themes\default\templates_custom

You can change the layout of the grid by altering CATALOGUE_products_PROFILE_TAB_GRID_ENTRY_WRAP.tpl. 

By default the tab is named Products, it should be the second tab, it will show a maximum of 10 items per page, and display the grid layout. You can alter all of these settings by changing variables in member_products.php on lines 42 through 45. The lines are commented with instructions; change them as needed:


     $title='Products'; //this is the name of the tab
     $order=11; //order is where the tab will be in the row of tabs. Lower number means closer to left, higher number means farther to the right. Default first tab (About) is 10, default last tab (Edit) is 200.
     $max_products_per_page=10; //maximum number of items to show per page
     $_display_type='GRID'; //set this to GRID for grid layout. set this to TITLELIST for title list layout. this is case sensitive.

If it doesn't work, post any problems or errors here.

Products tab
» Download: (4 Kb, 119 downloads so far)
Back to the top

Honoured member

How do you mean Entries? Because there is the Activity feed addon which you might be able to be used or converted to your needs.

Just Jarv
Back to the top
1 guests and 0 members have just viewed this: None
Control functions:
 Add topic 

Quick reply   Contract

Your name:
Your message: