Design & Custom Templates Broken on Templates with View::getInstance()

Permalink
I am using custom page list templates that use a \View::getInstance()->inc() of a card.php file to format the output of each page into a styled card. This was working for the first 3 different templates I made however it suddenly started causing this error where when you click on Design & Custom Templates to change the template of the page list block, the controls don't come up and it throws a seemingly unrelated error into the console.

I have attempted including the requireAssets calls to the spectrum that is supposedly missing, but that then causes the error to say that a Core function in concrete5 is missing.

Another attempted fix was adding these lines above the \View::getInstance()->inc() line like this:
$packagePath = \Package::getByHandle('theme_package')->getPackagePath();
\View::getInstance()->setThemeByPath($packagePath.'/themes/theme_name');
\View::getInstance()->inc('elements/cards/card-category.php', $params);


However this causes a "Class 'Concrete\Core\View\Router' not found" error that displays as shown in the last 2 attached screenshots.

Any help in figuring out what is missing or broken would be greatly appreciated.

5 Attachments

 
hutman replied on at Permalink Reply
hutman
So this isn't really answering your question, but are you 100% sure that the js error that you show isn't breaking your editing? JS errors can really break the screen, and it appears that could be the problem and it might not be related to your code.

On another note, have you thought about using elements files instead of doing it this way? They're easier to include and the package stuff is built in. You just put your file in /packages/package_name/elements/file_name.php and then call it like View::element('file_name', array('params' => $params), 'package_name');
claplant replied on at Permalink Reply
View::element seems to work and solve the bug, however I need to be able to point it to my packages elements folder, not the concrete elements folder. Would you know how I can do that?
hutman replied on at Permalink Best Answer Reply
hutman
If you see in my example where I have 'package_name' that should do it. Your elements need to be in /packages/package_name/elements
claplant replied on at Permalink Reply
That did it, had to change the first line to:
$package = \Package::getByHandle('theme_package');


One thing I'd like to know for future use though, is there a way to then specify the theme in the theme package that it should look for?
ie: Look in "theme_package/themes/theme1/elements" instead of "theme_package/elements".
hutman replied on at Permalink Reply
hutman
No, not that I know of.
claplant replied on at Permalink Reply
Shoot, maybe someone else will know.
Thanks for your help!