On Fri, 16 Aug 2013 21:11:02 -0700, GB wrote:
> Paul,
>
> Thanks for serving in this role. New to CROOGO but been around Cake
> forawhile. I have a Bootstrap template that I am trying to adapt to CROOGO
> and was hoping to get some direction on correct approaches to take. I'm
> sure I could brute force the thing but prefer to stick close to conventions
> of Cake/Croogo. As Croogo grows, this will probably be a common task, I'm
> willing to write up what I learn once I'm done.
>
> So some questions:
> - I noticed Croogo has 'regions', which Cake adopted recently. Is Croogo
> best practice to use Croogo regions? Cake regions? Are they the same?
I think you're thinking of view blocks. Cake does not have 'region' per se.
They are different.
> - My first step was to take a Croogo menu and make it populate the HTML
> menu for the template I have. When I inserted the Croogo code to do that,
> I got the Croogo HTML and CSS and need to adapt this to my template. I will
> need to do a similar function in several different areas of the template.
> What is the correct way to adapt this? Elements? Custom Layout? Adapt
> template to Croogo? Other?
Themes.
You can override most of Croogo's default template using themes.
https://github.com/rchavik/Readable-Theme has some example for:
- Override Nodes views:
https://github.com/rchavik/Readable-Theme/tree/master/Plugin/Nodes/Nodes
- Override email template from a plugin:
https://github.com/rchavik/Readable-Theme/blob/master/Plugin/Contacts/Emails/text/contact.ctp
- Generate custom markup for menu:
https://github.com/rchavik/Readable-Theme/blob/master/Helper/CustomHelper.php
> - I have other node types that I want to use to populate e.g. sliders,
> etc. They all require more information than is available in the node
> table: e.g. my slider nodes will have in addition to title, body:
> image/video URL, timing. WordPress uses a metadata function to extend the
> data required by a node.
We have something similar: CustomFields. We could use this feature to store
simple key value attributes in the database. The Meta plugin uses this to store
meta_keywords and meta_description for each node.
However, I would recommend _against_ using this for data that will be used
in 'reports'. For example, if you have an 'Book' content type, don't store the
authors using custom fields.
> What is best way to achieve in Cake? I tried to
> navigate the taxonomy stuff without success. Is extending the fields of
> 'nodes' taboo?
Personally, I don't think it's taboo. But you'll have to figure out a way to make
it easy for upgrade. So, try not to modify the Nodes plugin itself. Instead, create
a separate plugin and extend the core Node MVC.
Using the previous 'book' content type, you could create a new Books plugin:
- Nodes.Node hasOne Books.BookDetail (with conditions where 'type' => 'book'). Inject
the relationship using Croogo::hookModelProperty()
- BookDetail model has the author_id, isbn_number, publish_date, etc.
- Use the Migrations plugin to create your book_details table, etc.
- Create the tab elements for /admin displaying custom book detail fields, and display
it using Croogo::hookAdminTab()
- If needed, create Books.BooksNodeController and Books.BooksNode to implement your
specific needs. Or use a behavior.
Extending a plugin is a bit hard to get right, but doable.