It'd be nice to start having some categories on this forum - So that we could tag a post with: Issue - General - Suggestion - HowTo
Anyway I'm starting this post to either get feedback on Widgets, if you've worked with them before, or this will become a way for me to track my widget progress
To start things off, I'll go ahead and attache the PSD made in CS3, to allow you to make your own 'widget image'
The font of 'Lucida Grande' 22pt regular and a letter spacing of 10 seems to be what was used.
Once you've created the image, upload it to: app/webroot/wildflower/widgets/
make sure to keep the file names consistent - To keep thins in line, I'll create an image left widget. Allowing people to have a pre-defined image left, content right design. My widget image should then be: wf_widget_image_left.png
All widget files are located here: wildflower/views/elements/widgets/
To make it simple, I've copied one of the existing widget and renamed it to match my image: wf_widget_image_left.ctp and wf_widget_image_left_config.ctp - once again naming convention is key.
A widget consists off 2 files: - public view (wf_widget_image_left.ctp) - admin view (wf_widget_image_left_config.ctp)
Customizing the public view, will change the look and feel of the widget for the public to see. Similarly, customizing the admin view will allow more elements to be added to a widget.
If you were to stop here, you could check the admin and edit a page - You will notice that our brand new widget is already listed and can be used. Of course it would have the same functionality as the original widget, but it just goes to show how nice this CMS is :)
ps: the file was zipped as 'psd' isn't a recognized extension on this forum
No problem - You can think of Widgets as re-usable templates. The contact form widget is actually empty, which doesn't help much. I apologize as I did not finish uploading my code, and therefore the above tutorial is incomplete.
Going back to the definition of Widgets, say you wanted to have a certain layout always applied to one item on a page. And you wanted for admins to be able to create that item, without a ton of html knowledge. You would create a "Widget" that they could click on, enter some info and you would do all the formatting for them.
I'll upload my code for the "Image Left - Content Right" template and hopefully that will help you understand what I meant.
Now for the image lookup to actually work, we need to snatch the code from the image insert functionality, so that we can create an array of all images.
In the wild_widgets_controller.php, under the function wf_config($name, $id){}, add the following before $this->render
This may not be some 'proper' cakePHP/WF code, but it works :)
The config file is a simple copy of the image code, this creates a list of 'usable' images and saves that image to a hidden field. The right content is a simple textarea where HTML can be entered.
If you upload these files to your widget folder, you can see them working right away. For the purpose of my design, I needed the image on the left to always be 200px, and therefore I'm using the image resize functionality built-in to WF to do this. Others may have a different use.
Now the beauty of this, is that you can have ANYONE create an image-left content-right page, without screwing anything up. It's as easy as selecting the image to be used and adding some content!
As a disclaimer I am not responsible for anything that happens to your staging area if you use the code above and everything around you starts to fail/burn/drown/etc. I'm also offering my apologies as a developer to you as the consumer/wannabedeveloper about this horribly hacked code and your inability to get a promotion at work because of it :D
BUGS: - On the image left functionality, the paging still happens if you add ($this->paginate['limit'] = 10;) to the controller, but it's currently not working. I'll be working on fixing this asap.
As a quick fix to the image paging, I simply defined my left image widget to have: - height of 300px and have overflow-y: auto; and removed the paging call of: - echo $this->element('wf_pagination');