[contentbox-1.1.0] - Using ContentBox layout with submodules

Hey guys,

I am using ContentBox to provide CMS for a new e-commerce website. I’m working on building a checkout module, located under /modules/contentbox/modules/checkout. The entire website is using a layout located under /modules/contentbox/layouts/SomeLayout/. When a user is directed to /checkout, I want it to pull in the checkout module code and use my main site layout in /modules/contentbox/layouts/SomeLayout/. So far, I have it pulling up my checkout views fine but I’m unable to figure out how to surround the view with my layout.

Best,

Grant

Not sure I follow Grant, once a layout has been activated it will be the one used.

The modules shouldn’t have any need to change the layout, can you give some better example on what you’re actually doing. I think the checkout module is not written correctly, as what you are trying to do is the default behavior.

Andrew,

I’ve at least found what it is doing. When I access /checkout/, it is using a layout, just not the layout (theme) I’ve set as the default layout in ContentBox. It’s using ROOT/layout/Layout.Main.cfm. My theme is located in /modules/contentbox/layouts/LayoutName.

I’m guessing I should update my ROOT/config/ColdBox.cfc layoutSettings to something like this?

layoutSettings = {
defaultLayout = “/modules/contentbox/layouts/LayoutName/layouts/pages.cfm”
};

However, when I did that, now I’m getting variable “cb” doesn’t exist. Man, I’m confused haha.

Best,

Grant

Is this a standard ContentBox installation?

Then remove that layout setting, it is not needed for ContentBox, the UI will always use the activated layout. That setting is for ColdBox and not ContentBox. Unless you are dropping ContentBox into an existing ColdBox application, you will never need to touch anything in the ColdBox folders, except the config folder of course.

Yes, this is a standard ContentBox installation. When I removed the setting, now /checkout loads with no layout. It just renders the view content only.

Just in case it’s helpful, here is my checkout module ModuleConfig.cfc. Pretty basic.

Yes, sorry…

What you need to do, is create pages in ContentBox, then the page can be assigned to a layout for that theme. The downside to this is that you need to then create widgets to do anything more than what ContentBox can deliver naitively.

In your theme create a file called testPage (or call it what you need too), and leave it with the layout or some dummy stuff. Then when you create the page, you can then select this layout from the drop down on the right side under layouts Just enter dummy stuff into the editor, and publish it. This also allows for the page to be added to the menus either top or side.

Now make sure you reload the application from the drop down in the DashBoard before you assign the layout for the theme, otherwise you can’t use it.

Now the layout can then contain what you need, and then have the render to do what you need to do. But remember this is a hack of sorts, because it will be hard coded for your page. But you could create widgets to then display stuff and place this into the created page, and of course you can then nest the pages if you need too.

Now the downside at the moment, is that modules can’t have their own contained widgets, I think I raised a ticket for this and Luis is looking at revamping this entire process I think anyway. There is another couple of ways you could do this, but this is probably the easiest for now.

But I can show you how you can add Widgets for your modules in the mean time, I am not sure if I have blogged this process yet, but it isn’t that hard. That means the widgets are contained for that theme, so that when the module is unloaded then the widgets can’t be used.

That should get you going some. But let me know if you do get stuck, if you do need help hit me up on Google+ anytime and we can jump into a hangout if you need some help. Right now I need some sleep…