How to Namespace when Hyphens are in the path
Permalink
Hi guys and girls,
I'm building a front-end Single Page within a Package that needs to sit underneath an exisiting page whose slug name contains a hyphen. Running Concrete5 5.7.3.1.
So I have index.php/get-involved/ and I need a Single Page from an 'Events' Package to display as index.php/get-involved/events
I have the view.php up and working, but the Single Page can't seem to locate the Controller, possibly because the namespacing is wrong?
Current namespacing:
I've tried camel case, which as I understand it automatically adds underscores?
How do I wire up the controller's namespacing to account for the page's position beneath a URL that includes a hyphen?
Current directories:
Controller: packages/events/controllers/single_page/get-involved/events.php
View: packages/events/single_pages/get-involved/events.php
(I have tried Controller: packages/events/controllers/single_page/get_involved/events.php also...)
Many thanks for your help!
I'm building a front-end Single Page within a Package that needs to sit underneath an exisiting page whose slug name contains a hyphen. Running Concrete5 5.7.3.1.
So I have index.php/get-involved/ and I need a Single Page from an 'Events' Package to display as index.php/get-involved/events
I have the view.php up and working, but the Single Page can't seem to locate the Controller, possibly because the namespacing is wrong?
Current namespacing:
namespace Concrete\Package\Events\Controller\SinglePage\GetInvolved
I've tried camel case, which as I understand it automatically adds underscores?
How do I wire up the controller's namespacing to account for the page's position beneath a URL that includes a hyphen?
Current directories:
Controller: packages/events/controllers/single_page/get-involved/events.php
View: packages/events/single_pages/get-involved/events.php
(I have tried Controller: packages/events/controllers/single_page/get_involved/events.php also...)
Many thanks for your help!
Turns out the namespacing wasn't the problem, but thanks! Of the three or four possibilities for how to manage namespacing hyphenated pages, your reply has confirmed the one method that definitely works. Thank you!
I'm coming up on the same issue. But I'm trying to deal with the page specifically with the hyphen
Controller: /packages/pkg_name/controllers/single_page/page_name.php
View: /package/pkg_name/single_pages/page-name.php
namespace: Concrete\Package\PkgName\Controller\SinglePage
class: class PageName extends PageController
not having any luck
Controller: /packages/pkg_name/controllers/single_page/page_name.php
View: /package/pkg_name/single_pages/page-name.php
namespace: Concrete\Package\PkgName\Controller\SinglePage
class: class PageName extends PageController
not having any luck
I generally avoid hyphens, because it hurts my head, but the project I am working on right now requires them. Here's my tuppence worth:
Controller:
my_package/controllers/single_page/somefolder/my_page.php (my UNDERSCORE page)
=> namespace Concrete\Package\MyPackage\Controller\SinglePage\Somefolder
class => MyPage
Note: single_page (single underscore page - SINGULAR)
Single page:
my_package/single_pages/somefolder/my-page.php ( my DASH page)
Note: single_pages (single underscore pages - PLURAL)
Like I said, it hurts my head.
Controller:
my_package/controllers/single_page/somefolder/my_page.php (my UNDERSCORE page)
=> namespace Concrete\Package\MyPackage\Controller\SinglePage\Somefolder
class => MyPage
Note: single_page (single underscore page - SINGULAR)
Single page:
my_package/single_pages/somefolder/my-page.php ( my DASH page)
Note: single_pages (single underscore pages - PLURAL)
Like I said, it hurts my head.
It sounds like you've done everything I'd recommend. Maybe I'm missing something that you've described, though, so he's what works for me:
URL is /membership-checkout/session
Single page is: single_pages/membership-checkout/session.php
Controller is: controllers/single_page/membership_checkout/session.php