Dashboard Single Page -> Sub-page blank
Permalink
Hi all
In a package, I have a Dashboard Single Page, which is just working fine.
The controller is here:
The page is here:
So far so good:
The "Main" Single Page Controller is as follows:
As I said, working fine.
Now I wanted to create a sub-page (Settings-Page).
I added a new controller under:
And the Sub-Page under:
As I read (at sooo many places now), the Controller for the Sub-Page must be in a subfolder as described above.
The controller is as follows:
The package controller installer method:
I also tried like this: (as mentioned somewhere)
but that just gives me my Single Page and an empty one. The sub-page is still empty though.
Now the sub-page is shown at the right dashboard bar, but its completely blank, just an empty body!
I'm on it for 2 days now and I don't get it!! PLEASE HELP!
In a package, I have a Dashboard Single Page, which is just working fine.
The controller is here:
/packages/package_handle/controllers/single_page/dashboard/my_single_page.php
The page is here:
/packages/package_handle/single_pages/dashboard/my_single_page.php
So far so good:
The "Main" Single Page Controller is as follows:
namespace Concrete\Package\PackageHandle\Controller\SinglePage\Dashboard; //... class MySinglePage extends DashboardPageController { //... public function view() { $theSome = 'working great!'; $this->set('some_stuff', $theSome); } //... }
As I said, working fine.
Now I wanted to create a sub-page (Settings-Page).
I added a new controller under:
/packages/package_handle/controllers/single_page/dashboard/settings/my_single_page_settings.php
And the Sub-Page under:
/packages/package_handle/single_pages/dashboard/settings/my_single_page_settings.php
As I read (at sooo many places now), the Controller for the Sub-Page must be in a subfolder as described above.
The controller is as follows:
namespace Concrete\Package\PackageHandle\Controller\SinglePage\Dashboard; //... class MySinglePageSettings extends DashboardPageController { //... public function view() { $theSettingSome = 'NOT working AT ALL!'; $this->set('some_setting_stuff', $theSettingSome); } //... }
The package controller installer method:
public function install() { $pkg = parent::install(); SinglePage::add('/dashboard/newsletter/settings', $pkg); }
public function install() { $pkg = parent::install(); SinglePage::add('/dashboard/newsletter', $pkg); SinglePage::add('/dashboard/newsletter/settings', $pkg); }
but that just gives me my Single Page and an empty one. The sub-page is still empty though.
Now the sub-page is shown at the right dashboard bar, but its completely blank, just an empty body!
I'm on it for 2 days now and I don't get it!! PLEASE HELP!
Sorry Still no luck, As you already know its a newsletter, not a mysinglepage.... I'll edit my question, if goodnightfirefly's answer doesn't fit either... that'll make things easier
EDIT: I took too long to type :)
==========================
Your current filename/namespaces would create a new page at
but I think you want
is that correct?
If so, you just need to change your controller filename to
and your view file to
and finally, updating the controller contents to
==========================
Your current filename/namespaces would create a new page at
http://yoursite.com/dashboard/settings/my_single_page_settings
but I think you want
http://yoursite.com/dashboard/my_single_page/settings
is that correct?
If so, you just need to change your controller filename to
/packages/package_handle/controllers/single_page/dashboard/my_single_page/settings.php
and your view file to
/packages/package_handle/single_pages/dashboard/my_single_page/settings.php
and finally, updating the controller contents to
namespace Concrete\Package\PackageHandle\Controller\SinglePage\Dashboard\MySinglePage; //... class Settings extends DashboardPageController { //...
goodnightfirefly, YOU ARE THE CHIEF!!!! Now it's logic that a subpage must be in the "subpage" namespace too...
Now if I want to add another single page at the same level like the settings page. Think the namespaces are ok, but the problem is in the installer method of the package:
The settings class
The settings controller path:
The newsletter_sent class:and the path to it:
Any ideas?
public function install() { $pkg = parent::install(); // If I do this, the settings page is installed, but not the newsletter_sent page SinglePage::add('/dashboard/newsletter/settings', $pkg); // If I do this, I get another newsletter "folder" SinglePage::add('/dashboard/newsletter/newsletter_sent/', $pkg); // If I do this, I get just the newsletter without sub-pages SinglePage::add('/dashboard/newsletter', $pkg);
The settings class
namespace Concrete\Package\DanielGasserComNewsLetter\Controller\SinglePage\Dashboard\Newsletter;
/packages/daniel_gasser_com_news_letter/controllers/single_page/dashboard/newsletter/settings.php
The newsletter_sent class:
namespace Concrete\Package\DanielGasserComNewsLetter\Controller\SinglePage\Dashboard\Newsletter;
/packages/daniel_gasser_com_news_letter/controllers/single_page/dashboard/newsletter/newsletter_sent.php
Any ideas?
Does your newsletter_sent.php controller have a class name of NewsletterSent with a view() method?
Yes it has, the page itself is running but at the wrong place:
Newsletter
-->settings
Newsletter
-->newsletter sent
instead of:
Newsletter
-->settings
-->newsletter sent
because of the installer (I suppose)
Newsletter
-->settings
Newsletter
-->newsletter sent
instead of:
Newsletter
-->settings
-->newsletter sent
because of the installer (I suppose)
public function install() { $pkg = parent::install(); SinglePage::add('/dashboard/newsletter/settings', $pkg); SinglePage::add('/dashboard/newsletter/newsletter_sent', $pkg);
Ah I see what you mean now about 'another newsletter folder'. I believe it is because the system is trying to add a 'newsletter' single page but it already exists.
If you look in the Dashboard > Pages & Themes > Single Pages you should see both 'Newsletter' pages, but one has the path of /newsletter while the other one has /newsletter1. (I'm just going by memory for that so I could be wrong).
C5 member jordanlev has created a boilerplate package that has many useful helper methods, one of them being this method which only adds single pages if they don't already exist: (https://github.com/jordanlev/c5_boilerplate_crud/blob/master/package... )
Try adding that getOrAddSinglePage() method to your package controller and adding single pages like this:
You may have to rearrange your code a little, notice that you need the in order to pass $pkg to the but follow along with the code and you should be able to work it out :)
Also note that package is for 5.6, so you will need to add
Post back if you hit any roadblocks and we will go from there
If you look in the Dashboard > Pages & Themes > Single Pages you should see both 'Newsletter' pages, but one has the path of /newsletter while the other one has /newsletter1. (I'm just going by memory for that so I could be wrong).
C5 member jordanlev has created a boilerplate package that has many useful helper methods, one of them being this method which only adds single pages if they don't already exist: (https://github.com/jordanlev/c5_boilerplate_crud/blob/master/package... )
Try adding that getOrAddSinglePage() method to your package controller and adding single pages like this:
$this->getOrAddSinglePage($pkg, '/dashboard/newsletter/newsletter_sent', 'Newsletter Sent');
You may have to rearrange your code a little, notice that you need the
$pkg = parent::install();
$this->installOrUpgrade($pkg);
Also note that package is for 5.6, so you will need to add
use Page; use SinglePage;
Post back if you hit any roadblocks and we will go from there
Thx for this, but it does the same thing as before...
And here's the one from jordanlev:
The 'getOrAddSinglePage' I took as it is from the repostiory. What am I missing?
Newsletter/dashboard/newsletter-3 Newsletter/dashboard/newsletter-4 Settings/dashboard/newsletter-4/settings Newsletter/dashboard/newsletter-5 Newsletter sent/dashboard/newsletter-5/newsletter_sent
And here's the one from jordanlev:
private function installOrUpgrade($pkg) { $this->getOrAddSinglePage($pkg, '/dashboard/newsletter', 'Newsletter'); $this->getOrAddSinglePage($pkg, '/dashboard/newsletter/settings', 'Settings'); $this->getOrAddSinglePage($pkg, '/dashboard/newsletter/newsletter_sent', 'Newsletter sent'); }
The 'getOrAddSinglePage' I took as it is from the repostiory. What am I missing?
I had some entries in the table "PagePaths" like newsletter-1, newsletter-2 and so on, that is why it wasn't working, thx you once again goodnightfirefly
Excellent! Glad you have it working :)
It's going to be a nice little package BTW. I'll add credits at your name ;-)
and your single page at
which should start with
Also, from previous posts it seems that you need to have all of your paths and namespaces correct when the package installs, so if you update these things and it still doesn't work, try uninstalling the package and installing again (a pain, I know).