Diem comes with a set of built-in widgets. They allow to generate valid HTML and require no technical knowledge.
To add a widget on a page, click the "Add" button on the front application lower tool bar.
These widgets add content on the page.
Add a title on the page.
Add a link on the page.
Add a text on the page. A text may be composed with a title, a body and a media.
Add a media on the page. Can bee an image, flash, video or sound.
These widgets add navigation elements on the page.
Add an automatic breadcrumb on the page.
Advanced widgets to enhance the site.
Add an internal search engine form to allow users to performs searches on the site.
Customize the search form template
Copy dmFrontPlugin/modules/dmWidget/templates/_dmWidgetAdvancedSearchForm.php
to apps/front/modules/dmWidget/templates/_dmWidgetAdvancedSearchForm.php
then modify it to match your needs.
Displays the search results for the current search. Should be added on the main.search page.
Customize the search results template
Copy dmFrontPlugin/modules/dmWidget/templates/_dmWidgetAdvancedSearchResults.php
to apps/front/modules/dmWidget/templates/_dmWidgetAdvancedSearchResults.php
then modify it to match your needs.
It's as simple as adding an action in the config/dm/modules.yml file.
In this example, we will create the diem-project.org widget that shows the latest gougle group entries.
config/dm/modules.yml:
Project:
Global:
... # our existing modules
community: # declare a new community module
actions:
ggFeed: # declare a new action for the community module
Then we go back to the front application and click the "Update Project" button. It will generate the community/ggFeed component and template in apps/front/modules/ggFeed.
Troubleshooting
If the files are not created, see the Troubleshooting
Now we can click the front lower tool bar "Add" button, and drag & drop the new community/ggFeed widget somewhere on the page.
Of course, it does nothing yet. Display an external feed require a controller and a template.
To write the controller, edit the file
apps/front/modules/community/actions/components.class.php:
class communityComponents extends myFrontModuleComponents { public function executeGgFeed() { // use cache not to fetch google groups feed each time $cache = $this->context->get('cache_manager')->getCache('feed'); if ($cache->has('diem-users')) { $this->items = $cache->get('diem-users'); } else { $feedUrl = 'http://groups.google.com/group/diem-users/feed/rss_v2_0_msgs.xml'; $this->items = sfFeedPeer::createFromWeb($feedUrl)->getItems(); $cache->set('diem-users', $this->items, 1800); } } }
The controller uses sfFeed2Plugin to fetch the feed. This plugin is not packaged with Diem, but you can install it as any symfony plugin.
Then we will create the template, in
apps/front/modules/community/templates/_ggFeed.php
foreach($items as $item) { echo £link($item->getLink())->text($item->getTitle()); }
This template uses Diem template helpers
For more info on specific widget creation, see the config/dm/modules.yml documentation.
Questions and Feedback
If you need support or have a technical question, you can