Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the CollectiveAccess support forum! Here the developers and community answer questions related to use of the software. Please include the following information in every new issue posted here:

  1. Version of the software that is used, along with browser and version

  2. If the issue pertains to Providence, Pawtucket or both

  3. What steps you’ve taken to try to resolve the issue

  4. Screenshots demonstrating the issue

  5. The relevant sections of your installation profile or configuration including the codes and settings defined for your local elements.


If your question pertains to data import or export, please also include:

  1. Data sample

  2. Your mapping


Answers may be delayed for posts that do not include sufficient information.

Trouble displaying a list of entities in a custom page

Hello all,

I am attempting to add a new page to pawtucket2 that displays a list of entities.

My end goal is to display a list of entities that are related to any object with a certain type of relationship (e.g. Show all entities that have a relationship with the type "Donor of").

I have successfully created a page and added a link to it in the pageHeader.php file, so the creation of the page isn't the problem.

It is my understanding that I should be able to display variables in the page either with php or with triple curly braces ("{{{}}}") directly in html.
I've tried using: {{{^ca_entities.preferred_labels.displayname}}}    (among other attempts)
But no matter what I put in, nothing shows up: Whatever goes in between the triple curly braces disappears.

I think my issue is that this is generally used with reference to an object or other record and cannot just be used on its own to simply return the whole contents of a sql column.
I took a look in other php files from the default theme and they all use a lot of php variables and functions to return the data they need but without the API documentation (the url in the wiki page leads no where), along with the fact that this looks like it should be simple to implement, has me stumped.

So essentially I'm wondering how I can get a list of all objects that have a relationship with an entity in a php page in pawtucket2.
I'm using pawtucket2 and providence version 1.7.5

I'd appreciate any help!

Thanks!

Comments

  • Hi uwmustech,

    The display you're trying to use only works on detail pages where a specific table has already been loaded (ie ca_entities).  You'll need to create a search result in your view to do what you're doing, which will require some knowledge of php.
  • The curly bracket syntax just substitutes variables into the view that have been set by the controller. In some cases, the standard DetailController for example, expressions within curly brackets are supported by having the controller scan the relevant view for curly-bracketed tags and then filling them with relevant content. In an entity detail – which seems to be the source of your example – bracketed expressions like  {{{^ca_entities.preferred_labels.displayname}}} are parsed out of the view by the controller and then processed as display templates against the entity specified in the detail's URL. On it's own, in your own controller, that value has no specific meaning because you haven't set it to anything.

    To achieve a page that lists all entities related to any object with a specific relationship type you'll first have to do a query on the relevant relationship for the desired relationship type, then convert the set of found relationships to a unique set of entities and finally render them. It's a multistep process. Where the rendering happens depends upon how flexible you need the formatting to be. You could pre-render the names in the controller and simply pass a list into the view for output; or you could do something along the lines of what happens in the DetailController, where it looks for bracketed values within the view and uses them as formatting templates to renders values.
  • edited August 11
    Thanks for the responses, that clears some things up.
    I guess I'll see how much I can get done based on the direction you provided me with.
    seth, can this all be done with the API (does the information at accessing_data apply to Pawtucket2)? Because one course of action would be to just do a few database queries on their own since all I need is a list of entity names.

    Also, do you have any information as to when the Pawtucket2 API documentation will be available?

    Thanks for the help.
  • edited August 11
    Just an update.

    I have the basic functionality working by using this sql query:

    $donors = $db_conn->query("SELECT displayname FROM ca_entity_labels WHERE entity_id IN (SELECT "
    ."entity_id FROM ca_entities WHERE type_id = ".$type_id." AND entity_id IN (SELECT DISTINCT "
    ."entity_id FROM ca_objects_x_entities WHERE type_id IN (".implode(", ", $rel_types).")));");

    Where $type_id is the type of the entity (individual, organization, etc.) and $rel_types is an array of acceptable relationship types ("donor of" in this case).

    I can connect to the database because I can get settings variables from setup.php using: $this->request->config->get("setting_name");
    Though this works, I would still very much like to use the method seth recommended because in the future I might want more flexibility (e.g. adding related links, photos, etc.).

    Thanks.

Sign In or Register to comment.