Controllers, Subdirectories and custom views

Permalink
I'm working on a simple webshop app in Concrete 5. Based on the documentation examples, these pages should be single pages. The entire webshop should be accessible from example.com/webshop. So to test everything I started with a product page, and taking into consideration the "/webshop", I got the following file structure.

/controllers/webshop/product.php (class ProductController)
/models/webshop/product.php (class ProductModel)
/single_pages/webshop/product.php (whichs maps to example.com/webshop/product)
/themes/mytheme/webshop/product.php (for a custom template).

Now this is were the problems start appearing.

First, /themes/mytheme/webshop/product.php isn't used a custom template. I have to move it to the root of my theme folder for it to be used. Which is not that big a deal, but I'd like to keep everything in a /webshop folder for a nice file structure.

Now the big problem is that the controller isn't actually doing anything. It gets loaded, but none of the functions are executed. "on_start()" does nothing. It only appears to work when everything is in it's respective root:

/controllers/product.php
/models/product.php
/single_pages/product.php

This isn't exactly what I wanted. I tried to remap the now existing example.com/product to /example.com/webshop/product, but of course you can't remap the URL for a single pages.

I hope it's clear what I mean, and if there is a way to do this.

 
Nitrev replied on at Permalink Reply
Anybody?
ryan replied on at Permalink Reply
ryan
So, I think what you're trying to do is extend concrete and keep things organized at the same time.

The best way to do this is to keep your application in the package format:

http://www.concrete5.org/help/building_with_concrete5/developers/pa...

You'd basically move all your code to a webshop package
/packages/webshop
packages/webshop/models, page_types, controllers etc..

Hope that gets you started.
Nitrev replied on at Permalink Reply
The package idea seems the best option, but seeing as how you can uninstall packages, I foresee problems (seeing as how the client already managed to delete several pages from the system despite my explicit warnings not to click that d*mn button). If they can uninstall the entire webshop, that would be....bad

I was just more or less hoping that the system would be "smart" enough to recognize the subdirectory and act accordingly, or that there would be an option to create routes like in other PHP-based MVC systems.
Nitrev replied on at Permalink Reply
In fact, what I want to is more or less identical to the dashboard setup

/concrete/controllers/dashboard/install.php
/concrete/model/dashboard/homepage.php
/concrete/single_pages/dashboard/install.php
/concrete/themes/core/dashboard.php


So appearantly a more flexibel setup is possible, but looking through the files I can't really see how these files work together with the "mysite/dashboard/sitemap" mappings etc.
malthoff replied on at Permalink Reply
malthoff
could someone please answer that question? i find these help forums damn ugly. i cannot find a good description about controllers and views and who calls who... c5 seems to be good but documentation really sucks
NUL76 replied on at Permalink Reply
NUL76
I'd still go for the package setup. That way you can add your own part in the dashboard and everything works as you described.

You could easily give the client his own account and block the 'add functionality' page for his usergroup.

And you still keep organized and won't mess with the c5 structure for any updates et cetera.

Question answered :)
klickagent replied on at Permalink Reply
hi Nitrev, did you finish your webshop add-on for concrete5? i m interested how you did it, or if you found a finished add-on somewhere else. thanks for your answer.