0

THE ENVIRONMENT: Concrete5 parses the URL to find a page's controller - or tools file, which has no view - and renders it's view. That's a bit simplistic, but it's the gist.

Because Concrete5 has such a beautiful architecture for handling a large amount of content, I am wanting to use it as a sort of backend mechanism to power a web-app written in backbone. Backbone requires a RESTful implementation, which I have seen implemented with Slim - a PHP-based RESTful api.

THE CONFLICT: Because Concrete5 parses the URL (to either discover the page's controller [which renders the view] or a tool file [which does not render a view]) it conflicts with the REST implementation of Slim. This part is true...

THIS PART IS MERELY BELIEF: Slim's URLs are faux, used merely to make ajax calls (REST) which Backbone uses upon success. The browser is prevented from performing it's default action - which means there is no conflict with Concrete5 ONCE YOU ARE ON THE PAGE OF CHOICE.

THE QUESTIONS:

1). So is the answer merely to create a single_page and simply not render the view?
2). Once 'not rendered', can I simply proceed with the above beliefs?
3). Or will I be running into more conflicts than I realize?

Surely, there's a way to enable C5 to have a page (not the whole site by setting the global 'C5_ENVIRONMENT_ONLY' variable to 'true') to work with a RESTful api.

Has anyone else done something similar in some other CMS / Backbone project?

TIA

Ricalsin
  • 950
  • 9
  • 28

1 Answers1

1

Are you serving content that is managed in the C5 site to the backbone front-end app? Or is this app distinct from the C5 content? If the front-end app is different from the C5 content, then I'd just bypass C5 entirely for this path and put the app there to do its own thing (C5's router is only called if no page exists at the actual requested URL).

If the content is being managed by C5, then I don't think it's going to be possible to make both Slim/Backbone and C5's differing routing systems work together. The only solution I could think of in this case is to serve the backbone app as a Concrete5 tools file, but use rewrite rules in your htaccess file to trick c5 into thinking all requests to the backbone app are going to the one tools file that's serving it... then hack the backbone/slim router to recognize those htaccess modifications (e.g. htaccess converts requests to a certain path to be querystring parameters instead, then your backbone/slim app puts those querystring parameters back into wherever the frameworks are looking for URL path components).

Either way, it's going to be a total pain in the neck, and very possibly not worth the trouble.

Jordan Lev
  • 2,773
  • 2
  • 26
  • 39
  • Yes, content served by C5. I was thinking along those lines too (mod_rewrite, tools, etc) but I think that might be wrong. Doesn't the paragraph I wrote starting with "Slim's URLs are faux..." change your thinking on this? The page is prevented from refreshing (preventDefault) due to Backbone's use of jQuery. So I'm really only using one C5 page; meaning, a URL is only parsed by C5 once. That could be one tool file. Or, it could be one page that simply does not have any html in the "view" - allowing Backbone to render it's templates using underscore. I'm hoping C5 can be a web-app. :) – Ricalsin Aug 14 '12 at 17:06
  • ..If correct, this would still effectively cause C5 to manage/serve content via its controller (page or tool) by allowing it's methods to be called both by the Slim REST api as well as Backbone models and views. – Ricalsin Aug 14 '12 at 17:41
  • I don't know enough about slim to know how its routing works. I do know enough about C5 to think that it is a poor framework for web apps (as opposed to informational websites, which it excels at). – Jordan Lev Aug 14 '12 at 17:59
  • I guess I'll know more when I try it out soon - I've been contemplating this part for awhile now. I'm not really using C5 as a framework for a web-app. Backbone is an authoring tool that can be made to perform the web-app portion and - if the two can be connected - C5 can be made to support that effort. I have a unique application that can use the potential powerhouse combination. Thanks for your thoughts, Jordan; always appreciated. Your C5 packages are highly rated by the C5 community. BTW, did you see Linux Journal's article that rated Concrete5 best CMS? Finally, some respect. :) – Ricalsin Aug 14 '12 at 18:21