How do I create a custom Home page where the blog is not the default.

I’m fairly new at content box so I may be missing something simple, but I need to be able to use a custom homepage with its own layout so I can include image carousels and other components not currently available within content box. I don’t want the blog to be the primary entry point. I see how i can create a CMS page and force it to be the homepage of the site, and I currently have my setup running this way, but using this method does not allow me to add anything except for what can be added through the html editor as widgets. I tried to use the relocate widget to a custom homepage but threw an error because the cb variable was not available.

From what I can tell, the only way to do this is to create a custom page that uses a different layout and the create widgets for the homepage components that I’d like to use. Is this correct?

Currently ContentBox doesn’t support this, I have raised a ticket for this feature and will just have to wait.

But for now the only way is to use the Page content to create the page, and then make that page the default.

You can create an interceptor to do this now, to intercept this, but there is a bug in ColdBox that needs attention to when preProcess calls the event.Override() because it will not be called the current way ColdBox works. Again I have brought that to the attention of Luis, because it opens up other problems with code as well.

We do this with the ContentBox site so I don’t know why you say we cannot do it already. We have a home layout for it and it is completely different. Also it is a page and not the blog.

Am I missing something

Luis Majano
CEO
Ortus Solutions, Corp
Toll Free/Fax: 1-888-557-8057
Direct: 909-248-3408
www.ortussolutions.com
Twitter: @lmajano, @ortussolutions

Yes you’re missing the problem Luis…

Basically here is what happens in ColdBox, was the preProcess() called yep run it, did we then override this yep then call the override event. But if the second preProcess() uses the event override, the override will NEVER get called.

And ContentBox as it uses one event.override() a second will never get called…

I haven’t worked out how to get the link to a thread in gmail from the browser, but search for

Overriding the event using preEvent

And you will see the modification I suggest, but it is not a full blown solution to the problem which is why I raised it in the first place.

I also mentioned it again in the following thread

[Survey] What do you want in ColdBox?

So does that mean it goes in one ear and out the other when people find these things?

As stated that BUG has caused an issue with future ContentBox development of modules for me, and is why I stopped writing modules for ContentBox until that is fixed.

Sorry Andrew but first of all I have no clue what you are describing my friend.can you expand again on this?

Second I don’t know what this has to do with creating a home page with a different layout.

Luis Majano
CEO
Ortus Solutions, Corp
Toll Free/Fax: 1-888-557-8057
Direct: 909-248-3408
www.ortussolutions.com
Twitter: @lmajano, @ortussolutions

Ok here goes…

About 12 months ago I made the suggestion, that would allow a custom layout to use a defined template for the home page, as it stands ContentBox will only accept either a blog page or a custom page defined within ContentBox.

That means, enhancing ContentBox with some very good WordPress themes, impossible to achieve. I would have to show you what I started working on to appreciate that problem. But the solution was to override the code in ContentBox that does the preEvent()… Sorry I kept saying prePrcoess() :frowning:

Anyway in a framework I began working on, that allows child themes to be created from a parent module that allows the re-use of code. Amongst this I am defining the page that will be defined as the home page, so that I can override ContentBox.

As an example ContentBox does this in the BaseContentHandler.cfc

// Home page determination either blog or a page
if( event.getCurrentRoute() eq “/” AND prc.cbSettings.cb_site_homepage neq “cbBlog”){
event.overrideEvent(“contentbox-ui:page.index”);
prc.pageOverride = prc.cbSettings.cb_site_homepage;
}

This forces ContentBox to handle everything.

The solution would be for my custom framework then do intercept and make the following change when it is called.

//------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------
public void function preEvent(event, interceptData) eventPattern="^contentbox-ui" {
if( event.getCurrentRoute() eq “/”) {
event.overrideEvent(“myModule:displayHome.index”);
}
}

This then forces my framework to take control from ContentBox… But that is until ColdBox blocks you.

You see the preEvent() above in my framework is never called, that is because the overrideEvent() has already been called. So we then dig further into controller.cfc and we can immediately see the problem, I won’t spell it out below because I have already done that in the other 2 threads.

But what the problem is if one person already has an overrideEvent() another author or user will never be able to use this, which can cause problems if that handler relies on things being setup in that preEvent().

I thought I spelled that problem out, and it is a problem with ContentBox, as I stated if one wants to override ContentBox to provide even an external home page or provide things with better ease in ContentBox it currently can’t be done with the problem as described.

I am sure I don’t need to spell this problem out any further!

But because all my new modules, now rely on this one module being loaded, and certain things being setup in that preEvent() for the handler, everything stops working for my modules, because that preEvent is never going to run as it currently stands.

I dug a little deeper and true there is a way to do this. I created a custom homepage template and modified the layout to my taste excluding all of the blog features. I created a new content page which used the homepage template as its page, then went into settings and set this page as the homepage of the site. This works, but it seems more of a workaround. ContentBox is running under its module structure, and thats fine for the blog features, but it would seem to me that any other pages that do not run under the content box framework should run at the cold box level so they can take advantage of the root layout folders, handlers, etc. Like i said before, I’m new to contentBox/Coldbox so I could be missing something.

What it comes down to is I’d like to add functionality, such as photo galleries, musical event listings, member bio pages, etc, which i could easily do at the root coldbox level but having a hard time seeing how to include those features at the content box level. Its a great product though!

Ahh I get you know, you want to execute the normal ColdBox events instead of ContentBox?
Is that right?

ContentBox runs in two modes of operation:

  1. Default: Take over mode, this means that all routes are intercepted and ContentBox controls the home page event and URLs. You can still execute parent events, but you need to prefix them with “parent” in the URL, unless you have registered modules and routes.

  2. Restricted to an URL entry point. YOu do this by opening the modules/contentbox-ui/ModuleConfig.cfc and editing the “this.entrypoint”. You must then assign a URL entry point for ContentBox, the UI that is. So it could be /site, /cms, /go, /whatever. This way, the default events and parent application events remain untouched and ContentBox is just another module.

Does it make sense now.

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Correct! Exactly what I was looking for!

A couple of questions…how do I make the session that is created when an administrator logs in available to the UI? I would like to modify the menu structure based and make links available based on that login.

Also, I’ve incorporated a twitter bootstrap theme into content box, but noted that there was no built in ability to do drop down menus. I modified the generate menu function to accommodate for this for now, but I know its not the proper way to do it. Do you have plans to incorporate this in the future? Or is it already there and did I just miss it?

Last one (for now)…Post Types: Wordpress has a post type concept where you can define different types of posts that can be used to create different views. By defining a custom post type, i could create blog posts that would allow me to display content in any way I choose which would not be included in the standard blog listings.

For example: A post type can be defined in the system as a calendar of events. This would include the event title, event description, event date, and any other meta data that was deemed appropriate. The default layout for that would be filtered so it would only display those entries defined with that post type, and those entries would be filtered out of the main blog. This creates a very flexible mechanism by which all types of content can be used within the system without programming specific modules. Widgets could then be developed to allow for excerpts of the different post types to be included in any template.

I can see developers creating all kinds of different post types that could be shared and uploaded to the base system allowing it to be easily extended.

Again, I see where we can add meta data to any post or page so you may have thought of this already and i may just be missing something, but I don’t see how it can be used in the way i described.

Hi Robert, you asked: “Again, I see where we can add meta data to any post or page so you may have thought of this already and i may just be missing something, but I don’t see how it can be used in the way i described.”

Here is how the data can be accessed inside a widget.

id = cb.getCustomField(‘id’,0);

This gives me many hooks to grab different items.

Thanks,

George Murphy

Actually What Robert is referring to, is that WordPress allows for content to be assigned different categories and sub categories. This allows for greater control on where and when the content is displayed.

I brought this up over 12 months ago, and raised a ticket for it as well.

So basically lets say you have a site, that has lets say a portfolio of work. You can create a Blog post and assign images to this category, but when you go and view a normal blog those categories do not show up in the blog.

At the moment if you want to create a Blog with 2 types of Blogs it can’t be done, unless you run two instances of ContentBox.

Close Andrew. its not so much the category assignment as the ability to create entirely different types of blog posts which have their own templates for display. In wordpress, you can upload different post types which use the base tables in the background for storing the content, but extends them. I guess its possible using some kind of master parent category which would be used to filter out any items not assigned to that category, but the blog would have to filter that category out.

Yeah problem is WordPress is configurable even depending on what theme you might have installed, at least that has been my experience with it.

But I do think that ContentBox needs sub and sub/sub categories to any level as well, this would allow us to create blogs that can look like this, allowing People to decided that they wish the technical or whatever on the same blog. Especially if you want to create a news like portal.

Technical
->ColdFusion
->Java
->JavaScript

Cooking
->Preparation
->Ingredients

Just pulling names out of my head at the moment, but this is what I tried to discuss with Luis last year. The concept is the same, its just how will it get implemented. I know there are people out there that do use this in the WordPress concept, especially with a lot of the plugins and stuff.

At the moment if I recall what Luis stated to me, is that Pages do use a different category than Blogs, I haven’t investigated that but it is what Luis stated last year. But for a lot of us who would very much like to push the limits of ContentBox to being the best, I think something like this is very much needed.

I agree. The platform itself is very well done, but I too would like to see it taken further. For example, in wordpress I installed a plugin that allowed me to enter address locations and display them on a page as a map or as a list, with search features. In reality, all it is doing is using the word press posting tables, aloong with pre-defined meta data, to create the posts along with their own custom templates for display.

Although I could write a custom module using coldbox and tie it in, it seems a bit much when the base system should be able to handle it. The custom field features are already there, its just a matter of extending cb to use them in a different way and preventing the main cb blog from displaying them. All in all, i do think this is an excellent product and one of, if not the best framework if seen for ColdFusion. I do think the developer community needs to get more involved to provide plugins and modules.

On another note, I asked this in a different posting, but you seem to have a good grasp on the product. Do you know how to tell if a user is logged in or not? I’m trying to determine whether or not to show the logout link but cant find a way to determine the status of the session. I found the meta widget which contains this code: securityService.getAuthorSession().isLoggedIn() and uses it to tell if the user is logged in, but when i tried to use it in a template I got an error. Any help would be great!

Thanks

Robert

Answers Below

A couple of questions…how do I make the session that is created when an administrator logs in available to the UI? I would like

to modify the menu structure based and make links available based on that login.

You don’t have to do anything, it is already available as you are in the same application. Actually, prc.oUser is available anywhere in the application. That is the new or active user session, you have the object available anywhere.

Also, I’ve incorporated a twitter bootstrap theme into content box, but noted that there was no built in ability to do drop down

menus. I modified the generate menu function to accommodate for this for now, but I know its not the proper way to do it. Do you have plans to incorporate this in the future? Or is it already there and did I just miss it?

You missed it :slight_smile: We use this extensively in our www.gocontentbox.org site.

    #cb.rootMenu( type="li", levels="2" )#

You can also use the cb.subPageMenu() as well.

Last one (for now)…Post Types: Wordpress has a post type concept where you can define different types of posts that can be used to create different views. By defining a custom post type, i could create blog posts that would allow me to display content in any way I choose which would not be included in the standard blog listings.

Do you mean adding a layout to posts? Much how you can change the layout of a page? That could be beneficial, to add the ability to change the layout of a blog entry.

For example: A post type can be defined in the system as a calendar of events. This would include the event title, event description, event date, and any other meta data that was deemed appropriate. The default layout for that would be filtered so it would only display those entries defined with that post type, and those entries would be filtered out of the main blog. This creates a very flexible mechanism by which all types of content can be used within the system without programming specific modules. Widgets could then be developed to allow for excerpts of the different post types to be included in any template.

I can see developers creating all kinds of different post types that could be shared and uploaded to the base system allowing it to be easily extended.

These are just sub types or custom types to our base content objects, but you would still need to code them and also have a way to populate them right? You can try extending our Entry entity and adding whatever you need. You could still use the UI to manage them and edit them, but to add the extra metadata you would need to add those entries into the editor panels. You can do that very easily via the events on the entry editor. You can then listen to onEntrySave to update the extra attributes.

component extends=“contentbox.model.content.Entry” table=""{

custom properties

property name=“interceptorService” inject=“coldbox:interceptorService”;

}

Try it, I don’t have al the properties and things at my disposal here. But basically you are extending the entry content object via inheritance and adding your own properties. Now, this requires for you to add these table/properties into the system. But with one CFC you can potentially do everything. Because you can also use the entity to register itself to the editor display and save events. Now is this what you where thinking sir? Or something more magical :slight_smile:

I did a cfdump of prc.oUser and i get key does not exist error.

Line 997 of cbHelper.cfc has this line :

b.append(’<li class="#arrayToList(classText, " “)#”>#pageResults.pages[x].getTitle()#’);

Nothing i tried allowed me to build a drop down coldbox menu until I changed it to this:

if (pageResults.pages[x].hasChild()) {

b.append(’

  • #pageResults.pages[x].getTitle()# ');

    } else {

    b.append(’

  • #pageResults.pages[x].getTitle()#’);

    }

    Only then could i get the dropdown menu to work properly using the code below.

    I look into extending the entry. It needs to enclude a default post type of blog, then allow for custom post types, with additional meta data for the custom post type. The admin interface should automatically pick up the custom post meta data based on the post type. Custom Views would then output the display of the custom post type and the blog would have to filter those out. Not sure how to handle that.

  • Yeah agreed.

    I had begun working on a Parent / Child framework in ContentBox, that would have brought a lot of this stuff to ContentBox. So far I got as far as getting a theme registered, where you could in the exact same manor as WordPress… Drag n Drop widgets to registered layout containers…

    But as I stated to Luis, I stopped working on this because ColdBox has a bug that stops code from running. I am hoping that Luis realises the impact that bug has with modules in ContentBox and fix it as quick as possible.

    Then the competition to get people to release modules, would be non existent because I have around 20 modules for content box that rely on this fix and I can’t release until ColdBox fixes that problem.

    But to give you an idea if you know WordPress, it not only allows for the theme to be registered, but it registers its widgets, when you drag the widget to the layout container it also allows you to configure the widget in the same manner that WordPress allows.

    Yeah I do have a good grasp of the product, only because I have tried to push it further than possible. But as Luis stated the logged in user is available. In which I did reply to that post of yours asking.

    This is also another thing that I had worked on, the concept was that one could create the menu structure in the same way that WordPress does. But again, it is off no use because of the bug in ColdBox.

    Andrew, why don’t you just do a pull request and fix the bug if you know what the issue is? Why is it that Luis always has to be the one to fix issues? I think he’s done a tremendous amount already by providing us with an amazing framework which allow us to develop on and make money. I’m sure if there is a solution many people will benefit from you contribution.

    Nolan, I already explained that to Luis.

    The problem is that I don’t believe my fix is a long term fix, if you look at the previous posts I have made on this, it is probably in need of a major rewrite for that section. So like a good solider I brought it to the attention of the developers for them to have a think about the problem, and hopefully between everyone can code a long term solution.

    Have a look at how runEvent works with overrideEvent(), if you are familiar with that then you can see the potential problem very easily.

    As far as pull requests go, I tried this last time with git. And I had around 8 changes that I patched and it got messy with a one pull request system. It might be because I am not up with git, because 99.9% of my work is SVN related, so I just don’t have the time to digest git at the moment.

    But as stated in this case, I am not well adverse with ColdBox to create a long term solution here.

    And I agree Luis has been a machine with ColdBox, and now ContentBox. But as I said in a previous email, not everyone has the time to dig deep into the framework to understand it to even apply a fix of this magnitude to begin with. ContentBox is different.