[Fixed] Single Page from package not working
Permalink
Trying to add a Single Page to my package, but it is not found by Concrete5 (with latest version: 5.7.5.9).
I just want a simple Single Page without controller (for now), and located in my package. So I added a file in packages/my_package/single_pages/sptest.php which only contains some HTML text to see if it works.
Then I added this code in my package controller:
(As explained here:http://documentation.concrete5.org/developers/working-with-pages/si... )
Then I went to the page "Single Pages" in Concrete5 Dashboard, and just typed "sptest" in the form after my site's URL, and clicked "Add".
But I get the error: That specified path doesn't appear to be a valid static page.
Did I miss something ?
I just want a simple Single Page without controller (for now), and located in my package. So I added a file in packages/my_package/single_pages/sptest.php which only contains some HTML text to see if it works.
Then I added this code in my package controller:
SinglePage::add('/sptest', $pkg);
Then I went to the page "Single Pages" in Concrete5 Dashboard, and just typed "sptest" in the form after my site's URL, and clicked "Add".
But I get the error: That specified path doesn't appear to be a valid static page.
Did I miss something ?
Ok, thanks, so I actually have to uninstall and then re-install my package to make it work.
It does work, but it makes me lose parts of my package configuration in the process of uninstalling, which is very annoying.
Instead, here is a quick hack I made so that I can add a Single Page from my package without having to re-install the whole package. I temporarily add the following code to my package controller, in the method "getPackageName()":
And then I go to a page that displays my package's name in concrete5 Dashboard (like the Details page of my package). The Single Page is now added and I can remove the temporary code.
It does work, but it makes me lose parts of my package configuration in the process of uninstalling, which is very annoying.
Instead, here is a quick hack I made so that I can add a Single Page from my package without having to re-install the whole package. I temporarily add the following code to my package controller, in the method "getPackageName()":
$pkg = $this; SinglePage::add('/sptest', $pkg);
And then I go to a page that displays my package's name in concrete5 Dashboard (like the Details page of my package). The Single Page is now added and I can remove the temporary code.
You don't actually have to uninstall and reinstall, you just have to increment your version number and put your new code so that it gets called by the upgrade method.
Nice, it works. Thank you.
You also have to have the correct namespacing inside of the Single Page, so make sure that the top of your Single Page has this code too
Of course replacing MyPackage with the correctly camelcased package name.