Express Entry Object

Hi, I have created an Express structure containing three Entities:- Section, Card and Image. Each with one to may associations. There are two types of Entries Sections with a number of Cards in them and Cards with detail about the card and a number of Images associated with the card. When a Card is selected in a Section Page I want to create an Entry instance for the selected Card which can then be used to build the appropriate Card page with the detail and assassinated images.
In essence - Is it possible to build a new instance of an Express Entry Object by getting the EntryID for a specific instance in the current page and using this to generate the new Entry?

I mean ‘associated’ not ‘assassinated’ images. Things can get frustrating, but not that bad!

1 Like

What actual relations do you want to have? Just write all, like

  • Section can have multiple cards
  • Card can have multiple images and so on.

Your post is not specific enough and it seems you are trying to over-complicate simple things (I can be wrong though). Not sure where does creating new instances fit in? From you description, it seems you need another express entity, but maybe this is not what you want to achieve.

Thanks for your reply. I am really trying to understand some of the processing behind Express. I have created three objects - Section, Card and Card Image. with a ‘many to many’ association between Section and Card and a ‘one to many’ between Card and Card Image.
I have created forms for each and linked pages – below are screenshots of them:



(These are obviously not the final versions, just a starting framework)
What I want to do is - from the Section Page (All Cards) click on the image of a Card and go to the appropriate Card Page. So click on the image of the Green Fan and go to The Card Page for it.
Both the pages are created using a Custom Template which extracts attributes from the instance of the $entry object it is presented with.
I wanted to bypass creating individual pages for each card by creating the appropriate $entry for the selected card when the image is clicked in the Section page. This can then be passed to a single page which can then extract and display the attributes. So, by clicking on, say, Happiness a $entry instance is created for that card which can then be processed by the Custom Template of a standard Card Page.
I have a schema of the Express related tables in the Concrete Database and can see how this could be achieved fairly easily with SQL but obviously I don’t want to do that. So what I need to know is what method will populate a $entry.

What exactly is the problem? Since it sound like you have a good solution.
You can use Page Types controller instead Single Pages.
You will need to pass express id of card in url
https://website.com/card/37/some-slug-for-seo
where /card is your page type or single page controller.
You would need to create controller file with code like

public function view($id, $slug) {
    $card = Express::getByID($id); // get express object by id from url
    $this->set('card', $card); // pass $card variables to template file
}

and then display values from $card express object in page template.

Thanks for your help. I have it working through a Single Page except for one serious problem – I have had to put the Controller in the controllers folder under concrete! I cannot get it to find the controller file under the application folder and suspect the problem is in the Name Space declaration.

The view element is called card_details.php and is located in application/single_pages
The controller is in application/controllers/single_page, I set up the folder single_page to mirror the structure in the concrete/controllers folder.

The code in card_details.php in the controllers folder under application is:-

<?php

namespace Application\Controller\SinglePage;

use Concrete\Core\Page\Controller\PageController;

class CardDetails extends PageController

{

public function view($card = null)

{

$this->set(‘card01’, $card); ?>

controller value <?php echo $card?>

<?php }

}?>

The only difference between this and the version in the controllers folder under concrete is the namespace statement which is:-

namespace Concrete\Controller\SinglePage;

Obviously I can’t go forward using the concrete folders. Do I need to register the Application\ Controller\SinglePage namespace to get it recognised, and, if so, how?

Controller file card_details.php should be placed in:

application/controllers/single_page/card_details.php

Template/view file should be placed in:

application/single_pages/card_details.php

Namespace and file name seems fine.

Single page should be installed in CMS (manually in Dashboard or through package).

Try to clear cache if something is not working immediately.

1 Like

Thanks again I’ve finally solved it and now have it working properly with the Controller under the application folder. As you said,my code was OK. The actual problem was that I followed the process outlined in the documentation for single pages -
Single Pages Overview.

This has you creating the view php file and then adding it to the list of Single Pages in the Dashboard. If you do this and then later add the Controller under the application folder the system does not find it. You need to have both the Controller AND the View php files in place before adding the page. It seems to be a problem either with Concrete or the documentation.
(I’m using Concrete 9.1.3 with PHP 8.1.2)

1 Like