AngularJS based theme

Permalink
Hi all. I'm a Concrete5 newbie, so, my apologies for any stupid question!

I'm creating a new theme where many parts contain/are managed by AngularJS.
Angular works fine. My problem is that in the partials (that are loaded by Angular) I cannot use the Concrete5 classes and context.

In practice, I have a default.php page template which contains an HTML page that imports (among other libs) angular and a JS script file where the angular app is created.
The angular code loads a partial.php, which contains some additional HTML. In this HTML code I would like to use the Concrete5 classes (e.g., the Area class) and to access the Concrete5 context (e.g., the $c variable representing the current page), e.g.:
[HTML]
<?php
    $a = new Area('Payments');
    $a->display($c);
?>
[HTML]


When I run the code I gent an errore saying:
"PHP Fatal error: Uncaught Error: Class 'Concrete\Core\Area\Area' not found in /[...]/agreement.php".

Question: is it possible to load external PHP files (through angular) and have Concrete5 classes and context available in this files?

Any help or link in this sense would be really appreciated.
Thank you!

 
JohntheFish replied on at Permalink Reply
JohntheFish
The c5 core outputs some useful variables as JS globals in the header. Includes CCM_CID (same as $c->getCollectionID())
stefano83 replied on at Permalink Reply
Thanks John for your reply.
1) Where can I find info about this global variables? Is it in the docs? Do you have a link by any chance?

2) What about including a new c5 Area in my partial.php? Is this possible? How to make c5 classes available in the partial.php?

Thanks again
JohntheFish replied on at Permalink Reply
JohntheFish
The docs on creating themes are better than most. I don't think there is anything in the docs for CCM_CID. Stuff like that comes by archaeology and osmosis. Its been in C5 since ...., so you may also find something in the legacy howtos.

Have a look at the header output on a page in Elemental theme. If your theme doesn't output similar, then you have missed something.

I don't know about (2). You could investigate creating a psuedo page to render where you pass the cID and area name into it. Stacks do something like that, so look at the code for the stack block (its a hidden block that is used to display a stack).
JohntheFish replied on at Permalink Reply
JohntheFish
Also look at Cloneamental. Better than Elemental as a starting point as it is already packaged.