|
Content widget inside custom widget
|
|
05-15-2012, 11:50 AM
Post: #1
|
|||
|
|||
|
Content widget inside custom widget
i've been playing around with barebones and i've found the learning curve to be very low and it to be a very powerful system. currently just doing some proof of concept stuff, but I was curious if it is possible to have a content widget inside a custom widget?
Thanks! |
|||
|
05-16-2012, 06:34 AM
(This post was last modified: 05-16-2012 06:40 AM by thruska.)
Post: #2
|
|||
|
|||
|
RE: Content widget inside custom widget
Yes.
There are two ways to do this. There is a minimal editor that doesn't include shortcodes that can be used - the content editor is a reusable component (same for the code editor). The Flash shortcode uses the content editor without shortcodes for "alternate content" that is displayed when Flash isn't installed (SEO purposes, etc). You can follow that pattern for the quick-n-dirty method. This approach also lets you have access to the content to do whatever you want with it. The other approach is to use the Content Widget to get the full-blown, shortcode-enabled editor. This option requires inclusion of a Master Widget. Widgets can contain Master Widgets. Master Widgets are managed by the system and can contain one or more widgets (every page has a 'root' Master Widget). You can also create, as of 1.1, "one widget" Master Widgets. This allows you to tell the system to create one widget of a specific type within a Master Widget. The default Layout widget uses this second approach. All the @mw_...@ logic gets transformed into Master Widgets behind the scenes. The @mw_$...@ logic gets transformed into "one widget" Master Widgets behind the scenes through slightly different logic. Use the Layout widget for a pattern of the various calls you'll need to make to set up a one widget Master Widget with a Content widget and send processing requests to the appropriate handlers at the correct times. The downside to the second approach is that it does NOT let you have access to the content - at least not easily. You can get into the nitty-gritty of the $bb_langpage["widgets"] structure really fast if you try to access the data of other widgets. And that structure is subject to change between versions of Barebones CMS. There is a third, VERY unpleasant option - make a Frankenstein clone of the Content Widget that integrates the various shortcodes from the Content Widget and your custom widget code and the content editor. I don't even know what will happen if you do this or even if it is possible without severely breaking compatibility with future versions of Barebones CMS. I don't recommend this approach but it would give you "relatively clean" access to the content while having shortcode support. It really depends on what you need to do and you should base your decision primarily on whether or not you need shortcodes and whether or not you need programmatic access to the content that the user enters. If you don't need shortcodes or can figure out a way to not use them, then go with the first approach. It is a lot less messy. Author of Barebones CMS If you found my reply to be helpful, be sure to donate! All funding goes toward future product development. |
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)

Search
Help



