Cannot redeclare class upon installing a custom theme

Permalink 1 user found helpful
I created a VERY bare bones theme for Concrete5 to experiment with theme creation -- a single file titled full.php with the following content:

<html>
<head>
<?php Loader::element('header_required', array('pageTitle' => $pageTitle)); ?>
</head>
<body>
<?php
       $a = new Area('Main');
       $a->setAreaGridMaximumColumns(12);
   $a->display($c);
?>
<?php Loader::element('footer_required'); ?>
</body>
</html>


In the page_theme.php file I put the following:

<?php
namespace Concrete\Theme\Test;
use Concrete\Core\Page\Theme\Theme;
class PageTheme extends Theme {
    protected $pThemeGridFrameworkHandle = 'bootstrap3';
}


I disabled all caching on my site then installed this theme. Everything seemed fine. Then I set the theme as active. Suddenly every page is giving me the same error:

Cannot redeclare class Concrete\Theme\Test\PageTheme

I cannot get to the admin panel to change the theme back to Elemental, either, as the admin panel throws the same error.

I tried deleting the contents of application/files/cache but that did not help.

What have I done?

 
mhawke replied on at Permalink Best Answer Reply
mhawke
Have a look at the page_theme.php file in the core 'Elemental' for the proper structure. Yours should be
namespace Concrete\Theme\Test;
class PageTheme extends \Concrete\Core\Page\Theme\Theme {
}


Your actually should be building your Test theme under the 'application/themes/test' folder because if you don't then the next time you update concrete5 to a new version, you will lose your work. If you build it in the 'application/themes/test' folder then your page_theme.php file should be:

namespace Application\Theme\Test;
class PageTheme extends \Concrete\Core\Page\Theme\Theme {
}
stevendesu replied on at Permalink Reply
This fixed it, I just needed to change the Concrete namespace to Application. Guess that's what I get for trying to copy and paste the Elemental theme and use that as a starting point
Sadu replied on at Permalink Reply
Sadu
Fixed it for me too. Thanks.
yagogak replied on at Permalink Reply
Hi Mhawke !

This fix the first issue thanks, but now when i browse the site i got a error :

Call to a member function hasPageThemeGridFrameworkOffsetClasses() on a non-object

My custom theme is a copy of Elemetal

Any idea ?
Thanks A lot
mhawke replied on at Permalink Reply
mhawke
kellito13 replied on at Permalink Reply
mine is like this

namespace Application\Theme\Test;

use Concrete\Core\Area\Layout\Preset\Provider\ThemeProviderInterface;

class PageTheme extends \Concrete\Core\Page\Theme\Theme implements ThemeProviderInterface
cdowner replied on at Permalink Reply 1 Attachment
cdowner
Can anyone give me some pointer with the issue I am having. I have also attach a screen shot

Cannot redeclare class Application\Theme\Test\PageTheme
MrKDilkington replied on at Permalink Reply
MrKDilkington
@cdowner

What is the name of your theme and the path to it?

Please zip your page_theme.php and attach it as a reply.
cdowner replied on at Permalink Reply 2 Attachments
cdowner
I have done the copied the elemental folder and change it to test in the Application folder
MrKDilkington replied on at Permalink Reply
MrKDilkington
@cdowner

I think one of the problems might be an extra file in your theme called PageTheme.php.
application\themes\test\PageTheme.php

For more information there is a tutorial that cover this topic:
"How to copy the Elemental theme to use as a base for new themes"
http://documentation.concrete5.org/tutorials/how-to-copy-the-elemen...
cdowner replied on at Permalink Reply
cdowner
So from my understanding I should create my own theme and label it PageTheme as a PHP file?

As this is the only thing I have not done if the above mention is correct.
MrKDilkington replied on at Permalink Reply
MrKDilkington
@cdowner

Your test theme had a file called PageTheme.php that should not be there.
cdowner replied on at Permalink Reply
cdowner
the only php page in test folder I converted from the elemental file is named page_theme, I even copied that page and renamed it to PageTheme and that still didn't work.

<?php

namespace Application\Theme\Test;

use Concrete\Core\Area\Layout\Preset\Provider\ThemeProviderInterface;

class PageTheme extends

\Concrete\Core\Page\Theme\Theme implements ThemeProviderInterface
{
public function registerAssets()
{
mhawke replied on at Permalink Reply
mhawke
I'm not sure why MrKDilkington isn't suggesting his own free add-on (modesty?) which installs a copy of the Elemental theme on your website.

http://www.concrete5.org/marketplace/themes/cloneamental...
cdowner replied on at Permalink Reply
cdowner
I am unable to get to the site interface, but I will try to copy the file to the test and see if I can get it working that way
mhawke replied on at Permalink Reply
mhawke
Do you get Dashboard access if you remove the 'application/themes/test' folder?
cdowner replied on at Permalink Reply
cdowner
I get the interface but I am unable to do any editing
mhawke replied on at Permalink Reply
mhawke
Have you installed the free Cloneamental theme or are you still fighting with your own?
cdowner replied on at Permalink Reply
cdowner
How should I install it with out the interface
mhawke replied on at Permalink Reply
mhawke
Sorry, I thought you meant that you couldn't edit page content. Are you getting error messages from the Dashboard? Tell me what's happening.
cdowner replied on at Permalink Reply
cdowner
I get t the dashboard but it wont allow me to edit it, I remove the installation and DB and install fresh and keep getting the same error after I do the test folder and make the changes.

An unexpected error occurred.
Cannot redeclare class Application\Theme\Test\PageTheme
< Back to Home

with that on the dash board I am unable to edit anything.

I really appreciate all the help I have been getting with this.
mhawke replied on at Permalink Reply
mhawke
My point is that the Cloneamental theme is all you need to start customizing it. Make another fresh install (yes I know it's a pain) but don't do anything else regarding your Test theme. After your fresh install, head to the 'Dashbaord -> Extend concrete5 -> Get more themes' and search for 'Cloneamental' and install it. This will give you a copy of the core Elemental theme but in your 'application/theme/cloneamental/' folder so you can customize it.
cdowner replied on at Permalink Reply
cdowner
After a fresh install it wont let me do that.

I am now reinstalling: Install concrete5 Version 5.6.3.4 which worked but I had a hard time upgrading so that was why I did a clean install
mhawke replied on at Permalink Reply
mhawke
Version 5.6 CANNOT be upgraded to 5.7.

What do you mean 'it won't let me do that'. Error messages are the lifeblood of debugging so even if the error message doesn't mean anything to you, post it here so we can see what's happening.
cdowner replied on at Permalink Reply
cdowner
It wont let me edit 5.7 ver
mhawke replied on at Permalink Reply
mhawke
What shows up on the screen when it 'won't let you edit'? Details, details, details please!!!
cdowner replied on at Permalink Reply 1 Attachment
cdowner
Please see the attached picture
mhawke replied on at Permalink Reply
mhawke
Before you do a fresh install of 5.7, make sure you delete the 'application/theme/test' folder and then do the install. How are you re-installing it? Can you tell me your installation procedure?
cdowner replied on at Permalink Reply
cdowner
Yes I am running Install concrete5 Version 5.7.5.3 now to see what happen
cdowner replied on at Permalink Reply 1 Attachment
cdowner
This is what I get after the installation and I am unable to do any edit

An unexpected error occurred.
file_exists(): open_basedir restriction in effect. File(C:/zpanel/hostdata/elroy/public_html/journelconsulting_com/concrete/themes/elemental/css/fonts.googleapis.com/css?family=Titillium+Web:200,400,700,900) is not within the allowed path(s): (c:/zpanel/hostdata/elroy/public_html/journelconsulting_com;c:/windows/temp)
< Back to Home
cdowner replied on at Permalink Reply
cdowner
I am now running a fresh install without web theme

Install concrete5 Version 5.7.5.4
mhawke replied on at Permalink Reply
mhawke
So can you get to 'Dashboard -> Extend concrete5 -> Get more themes' and search for 'Cloneamental' and install it?

Have the error message gone away? That seems like a hosting issue to me.
cdowner replied on at Permalink Reply
cdowner
I am getting:

Install concrete5
Version 5.7.5.4

{"error":{"message":"file_exists(): open_basedir restriction in effect. File(C:\/zpanel\/hostdata\/elroy\/public_html\/journelconsulting_com\/concrete\/themes\/elemental\/css\/fonts.googleapis.com\/css?family=Titillium+Web:200,400,700,900) is not within the allowed path(s): (c:\/zpanel\/hostdata\/elroy\/public_html\/journelconsulting_com;c:\/windows\/temp)"},"errors":["file_exists(): open_basedir restriction in effect. File(C:\/zpanel\/hostdata\/elroy\/public_html\/journelconsulting_com\/concrete\/themes\/elemental\/css\/fonts.googleapis.com\/css?family=Titillium+Web:200,400,700,900) is not within the allowed path(s): (c:\/zpanel\/hostdata\/elroy\/public_html\/journelconsulting_com;c:\/windows\/temp)"]}
Back


I am unable to edit anything.
cdowner replied on at Permalink Reply 1 Attachment
cdowner
When I click the back button I get:

An unexpected error occurred.
file_exists(): open_basedir restriction in effect. File(C:/zpanel/hostdata/elroy/public_html/journelconsulting_com/concrete/themes/elemental/css/fonts.googleapis.com/css?family=Titillium+Web:200,400,700,900) is not within the allowed path(s): (c:/zpanel/hostdata/elroy/public_html/journelconsulting_com;c:/windows/temp)
mhawke replied on at Permalink Reply
mhawke
I would put in a support ticket with your host. I believe that error is a server configuration issue.
cdowner replied on at Permalink Reply
cdowner
the earlier version works well, I have services running on the server without any issues
mhawke replied on at Permalink Reply
mhawke
Yeah, I know what you're saying but I'd still put in a ticket. Can't hurt and might help. 5.7 uses a lot of new stuff that older versions never attempted.
cdowner replied on at Permalink Reply
cdowner
I do my own hosting
cdowner replied on at Permalink Reply
cdowner
file_exists(): open_basedir restriction in effect.

When this is changed to none on the Vhost it completely turn off Apache services

php_admin_value open_basedir none
mhawke replied on at Permalink Reply
mhawke
Well then I can't help you because I don't do any hosting. This might help:

http://www.concrete5.org/community/forums/usage/stack-errors-on-app...
mhawke replied on at Permalink Reply
mhawke
cdowner replied on at Permalink Reply
cdowner
mhawke replied on at Permalink Reply
mhawke
I'm sorry my friend. Apache configuration is not my speciality.