C5-8.4* How to programmatically add pages to Dashboard pages?

Permalink
I need to show a table in Dashboard. Say, a table of orders, similar to the Community Store 'Orders' page (dashboard/store/orders). So I can add my own single page to the Dashboard with a block to list data - a list/table of orders, each having a 'View' button. This list/table will automatically get data from a database. So far so good.

BTW, I can't find where that 'Orders' single page is in the package. Looked everywhere but can't find it. The 'community_store/single_pages/dashboard/store/orders.php' is actually an order summary page, not the all orders listing page. Where is the orders listing page code located?

And how do I display that each individual order, similar to that Community Store 'Order' page (dashboard/store/orders/order/[order_No])? How are these individual pages added under the 'Orders' page? As I can't find the listing code, I can't figure out how these pages are created.

I guess these individual order pages are not actually created as pages, but rather simply stored as data tables in the DB. How does C5 build a path and render the view somehow without actual pages? How is it done? Or am I wrong?

linuxoid
 
hutman replied on at Permalink Reply
hutman
I'm no exactly sure what kind of answer you are expecting here. But you can create dashboard pages by using the CIF format and a package. Like this:

<?xml version="1.0"?>
<concrete5-cif version="1.0">
    <singlepages>
        <page
            name="Page Name"
            path="/dashboard/page-name"
            filename="/dashboard/page-name.php"
            pagetype=""
            description=""
            package="package_handle"
        />
    </singlepages>
</concrete5-cif>


Then your directory structure would be something like

package_name/controllers/single_page/dashboard/page_name.php
package_name/single_pages/dashboard/page-name.php
linuxoid replied on at Permalink Reply
linuxoid
That's not what I need. I know how to add single pages manually.

What I need is such functionality as Community Store orders. I just can't find and figure out how they actually show a summary of all orders in the Dashboard and then how each order can be displayed on its own page in the Dashboard under the 'orders' page. How can I make something similar myself?

I have a table in a DB - a DB object, actually an Express object, I need to show the whole table data on a summary page in the Dashboard - I guess I can set it up manually as a single page.

But how do I make each table row data to be displayed at their own URL in the Dashboard underneath the main summary page? I don't think they create a physical page for each order. Looks like they simply get orders data from the DB and show it at a separate URL beneath. But if there's no page, how do you make a dynamic URL (say with the order number) and show data on it?

For example:
- the orders URL is /dashboard/store/orders - single page created manually
- each order URL will be /dashboard/store/orders/order/12345 - this is a dynamically created URL, each order is part of the DB object, not a page
hutman replied on at Permalink Reply
hutman
If your main page is /dashboard/store/orders you can then make your "detail page" be another function in your controller called order that takes the id as a parameter and then displays a different set of logic within the single page view.
linuxoid replied on at Permalink Reply
linuxoid
ok, but how can I do that? I can't figure out how CS do that.

They have a single order controller showing data for each order. But I can't find out how they create individual URLs.

They also display summary on the Orders page. But I can't find a controller/view which does that.
hutman replied on at Permalink Reply
hutman
linuxoid replied on at Permalink Reply
linuxoid
Yes, I've looked at these.

Excuse my ignorance, I've never used such C5 functionality before, so I have no idea how it's done - how is the URL created for each order so that you can actually show results on that page/URL?
hutman replied on at Permalink Reply
hutman
So the basic page is /dashboard/store/orders which routes you to the controller then there is /order after that, which routes you to the order function of the orders controllers, then there is the /order_id after that, which passes the order_id into the order function in the orders controller. Then that function sets variables and passes them to the view.
linuxoid replied on at Permalink Reply
linuxoid
$this->redirect('/dashboard/store/orders/order',$oID);

Is that just it? Is that all I have to do to make up any URL I like and it will look like a page for the user?
hutman replied on at Permalink Reply
hutman
More or less, yes. You need to make sure that the controller and function exist but that's all.
linuxoid replied on at Permalink Reply
linuxoid
Ryan's just responded:
"...if you view a specific order via a path, e.g. /dashboard/store/orders/order/24, concrete5 tries to look for a order function in the controller, and pass it the extra variable that is passed via the url segment (the id of the order, the 24)"

No, no THAT simple! ))) C5 really does that??? Wow!