Create a new "listing format" for an entity?

I know this question bites off a big hunk, so I'm not looking for someone to do the work for me, I'm just looking for pointers to some training materials or pre-existing examples.

I'd like to create new "views" (I don't know if I'm saying that correctly) to change the way objects/entities appear.  Specifically, I'd like to create a list of the "top five rated" products in the Social Commerce items for sale.  I'd like the list to appear in the main body area of the customindex mod (to the right of the login portal I added in left column) and I'd like the list to be much more condensed than it is in the shop.  More like the two-liner member list instead of the three-inch-tall panels it comes with by default.

How do I go about creating a new list format for an entity, such as shop items, and controlling which items appear in the list?<!--EndFragment -->

  • I'd say clone the code from the core, code your extras, create plugin to load that code, maybe setup a plugin trigger/ hook, and call via that aspect...

  • How are you identifying the top 5 sale items?

    You can either modify the custom index code directly or create a new plugin to override the routines.

    In index.php you would need to do something like the following which just gets the 4 most current groups that the end user has access to.  Write your own routine to collect the information you are looking for and format as you would like to have it appear.

    //newest groups
    //  $groups = list_entities('group','',0,4,false, false, false);

    Pass the new variable you create with the list of entities into the layout canvas

    //display the contents in our new canvas layout
        $body = elgg_view_layout('new_index',$login, $files, $newest_members, $blogs, $groups, $bookmarks, $your_variable_here);

    update views/default/canvas/layouts/new_index.php to display this new information.  I think the info would be stored in $vars['area7']


  • Dhrup you make it sound so slam-dunk...  kkelley, I appreciate the effort that went into that repsonse, and I understand PHP "fairly well" but I'm afraid the Elgg-speak is all Greek to me.  I was planning on taking a copy someone else's stuff and change it approach but there are thousands of files all referencing each other in hundreds of directories.  Albeit for good reason, this is some really extruded code which makes the simple and elegant look complex and intimidating.  I need some resources on where to start enough that I even understand what to ask or look for.  And this forum/group/site/tool system/thing makes it even more challenging to find or get answers.

    Where can people learn the back-end basics 'round here?

  • @EV
    OOPS... It is *not slam-dink ;-)
    You *did ask for " I'm not looking for someone to do the work for me, I'm just looking for pointers...."
    yes, i have not given any " to some training materials or pre-existing examples.."
    because i believe none exists..
    i missed the ref to eCommerce plugin.
    the "more condensed than it is in the shop...
    and " instead of the three-inch-tall panels it comes with by default..."
    without even looking at the code..;-( I think you're refering to the default style that Elgg formats the output for list_entities.
    The top 5 rated products - ( once again I'm not reading the plugin code..) -- most likely done using metadata for the rating - but you'll have to read the code to verify. This means you'll need to code a fetch entities by metadata ( there is such a function in Elgg engine) and filter by meta's value ..not sure how easily this can be done) to get the top 5 rated.
    The 3 inch tall panels is most likely controlled by the CSS unless there's too much data there whioch needs tall panel - icon size?, etc..


    PHP "Fairly well"..

    Elgg => Greek ;-)

    You will find it easier to understand if you concentrate on MVC architecture and OOP programming -- that is how Elgg is.. If one comes from a straight PHP coding background with PHP functions only and you're *not familiar w/ MVC, OOP -- makes life more difficult. My own first baby steps with Elgg were in this manner until I realized what the architecture and prog style was... I was fortunate that I had some knowledge of the technology involved and so could recognize and realize my limitations and what I did not know.

  • The learning curve can be very steep for the first modifiation that you need to do.  Not only do you need to understand how Elgg works but then you need to understand the plugins that you are interested in enhancing for your own needs.   There isn't any basic beginners manual form what I have seen. 

    I don't know the commerce plug in but from what I have found, format can be created for all object types/subtypes.

    When I was learning, I read a lot of code, but plugins and the core engine to learn how things worked.  Then I would play with things.

    For example, to find the default display informatio for file objects, you would look the in file plugin directory (mod/file/views/default/object/file.php)

    In quick looking at the plugin, it looks like

    $most_rateds = get_purchased_orders('final_value','','object','rating','','',true,'','DESC',500,0);

    is the call to get the top rated products.  I would search the plugin for this call and see what it does and what is returned.

    I wish I could help you out more.


  • Thanks to you both, especially the "$most_rateds" tip.  All of your cautionary tales and what-not are valid; last time I got elbows-deep in code was pre-MySQL5 and during the php4.1 to 4.4 days if I recall, so no - I have not had OOP or MVC experience in LAMP which is one frustration.  And any experience from other platforms doesn't seem to apply.  And yes, at the core of all this I was hoping there were some training docs I could read to learn the basics.  Sucks.

    The primary frustration is that copy/paste/change works for tweaks and hacks here and there, but if what you want to do goes beyond CSS or SQL changes then you have to get under the hood at an architectural level with lots of deeply-rooted function calls and such.  The things I want to do are tiny lateral steps, but they're outside the existing design which puts them in the "big and hairy" category.  One major limiting factor I can see for Elgg is that all sites will look, feel and function exactly the same at all but the cosmetic levels.  Hopefully the developer community can build some real flexibility into future versions to allow more leeway and creativity in realizing ideas with the engine.

    It seems I'll have a steep learning curve without any documentation, I'll probably be better off finding a community programmer if I'm trying to get the next biggest thing since YouTube to production, yes?  It's a shame really, now that I think about it, how hard could it be to have a walk-through explaining the MVC architecture and "which-files-do-what" overview?  Without this I feel the gap between developers and users will widen, something that is very stressful in open-source communities.  Just my thoughts, figured I'd get them out of my system I suppose.  Sorry for the impromptu rant/vent.