sfJoomlaBridge
sfJoomlaBridge is a symfony plugin that provides a bridge between a Joomla and a Symfony application. It allows to display symfony pages into Joomla.
It adds a new helper class: Joomla with 2 main functions :
- link_to_joomla($module_action), to make a link to another symfony page (action/module) but in the Joomla application context.
- form_tag_joomla($internal_uri = ' ', $options = array()), to declare a form that will be submitted to Symfony in Joomla context.
- import_sf_resources(), used internally by the plugin to add specific Symfony resources (Ajax js for example)
Installation
- Install the plugin
symfony plugin-install http://plugins.symfony-project.com/sfJoomlaBridgePlugin
or download it and unzip in your /plugins directory
- Copy the files in /web/sfJoomlaBridge directly to your application /web directory (com_symfony folder should be now in the web/components/ directory of Joomla)
- Clear your cache
symfony cc
Configuation
Joomla component
- In web/components/com_symfony, open symfony.html.php, line 8 modify the name of Symfony controller file (frontoffice.php by default). Take care to use a production controller, because we should't have any debug information.
- Un-comment line 34 with file_get_contents if you don't have curl installed on you web server, and comment the curl related lines above.
- In /web/index.php of Joomla main controller
before (near line 114)
// mainframe is an API workhorse, lots of 'core' interaction routines $mainframe = new mosMainFrame( $database, $option, '.' ); $mainframe->initSession();
add
//Before Joomla initialize its mainframe, lets play…
// check missing component — added before $mainframe is being initialized
//##########################
if (!file_exists($mosConfig_absolute_path . '/components/'. $option )) {
$option = 'com_symfony';
//set component to com_cake if a controller is not found.
}
Symfony
- First you need to modify the absolute path of the Joomla controller in /plugins/sfJoomlaBridgePlugin/config/config.php, by default it's /index.php
- Views : If your symfony application will only be used inside the Joomla application, you can disable the layout globally in apps/app/config/view.yml
has_layout: off
Or it is not the case, you can disable the layout for some pages (view.yml of concerned module)
- We need to enable a new filter specific for this plugin. Open /plugins/sfJoomlaBridge/config/_filter.yml and copy paste the content after the common filter of the filter.yml of you application, at this point your file should look like this :
rendering: ~
web_debug: ~
security: ~
# generally, you will want to insert your own filters here
cache: ~
common: ~
joomla:
class: sfCommonJoomlaFilter
param:
head_tag: head_joomla
flash: ~
execution: ~
- In the template there is a special tag that will be used by the filter
<head_joomla></head_joomla>
In fact this tag will be used (and replaced) to add dynamically specific web resources for Symfony (js, css). You can modify this tag in filter.yml by modifying the head_tag parameter of the joomla filter. If your template doesn't need any resource, you can ignore it.
Usage
- 1 - You need to declare the following helpers (or use the default helpers loaded parameter in you settings.yml) :
<?php use_helper('Asset', 'Javascript', 'Joomla', 'Tag'); ?>
- 2 - To make a link to another symfony page, in this case to the module index and the users action.
<?php echo link_to_joomla('Users list', 'index/users'); ?>
- 3 - To declare a form that will be handled by Symfony, in this case form will be submitted to validateCreate action of users module
<?php echo form_tag_joomla('users/validateCreate', array( 'id' => 'sf_admin_create_form', 'name' => 'sf_admin_create_form', )) ?>
Changelog
0.8.0
- Can handle Symfony forms now (GET method)
- Allow standard use of Symfony Ajax helpers
- New specific filter
- New helpers to add sf resources dynamically
0.7.0
- Initial version
Demo
- You can find a demo on my blog
- You can find a more complete tutorial in the snippets section of my blog
Notes
- This plugin is still beta.
- I am searching beta testers to get some feeback. (C0il on IRC on, comment on my blog or whatever you want !)
TODO
COil :)
Attachments
- sfJoomlaBridgePlugin-0.7.0.tgz (3.5 kB) - added by COil on 03/02/07 17:28:22.
- sfJoomlaBridgePlugin-0.8.0.tgz (6.6 kB) - added by COil on 03/13/07 12:09:57.