![]() |
|
caPropelTreePlugin - 0.9.8Easy PropelTree |
|
MIT - free for comercal and non-comercial use
Imagine that we are building applications are presented in multiple languages. Let the tree of pages.
Add new table to your schema.xml, for example:
<table name="np_page" treeMode="NestedSet" isI18N="true" i18nTable="np_page_i18n"> <column name="page_id" type="INTEGER" primaryKey="true" required="true" autoIncrement="true"/> <column name="tree_left" type="INTEGER" default="0" nestedSetLeftKey="true" /> <column name="tree_right" type="INTEGER" default="0" nestedSetRightKey="true" /> <index> <index-column name="tree_left"/> </index> <index> <index-column name="tree_right"/> </index> </table> <table name="np_page_i18n"> <column name="page_id" type="INTEGER" primaryKey="true" required="true"/> <column name="culture" type="VARCHAR" size="7" primaryKey="true" required="true" isCulture="true"/> <column name="page_title" type="VARCHAR" size="255"/> <column name="body_html" type="LONGVARCHAR"/> <foreign-key foreignTable="np_page" onDelete="cascade"> <reference local="page_id" foreign="page_id"/> </foreign-key> </table>
Build model, form, and insert sql
$ symfony propel:build-all
Download caPropelTreePlugin
Put extracted files to plugins directory
Publish assets
$ symfony plugin:publish-assets
Add i18n and enabled module to settings.yml:
all:
.settings:
i18n: on # Enable interface translation. Set to off if your application should not be translated.
default_culture: en_EN
enabled_modules: [default, caPropelTree]
App.yml to a file, you can add options, for example:
all:
caPropelTreePlugin:
culture: [en_EN, pl_PL, de_DE] #all culture
sModelNameclass: NpPage #object width tree
sObjectIdMethod: getPageId # PK of object
sObjectNameWidthCultureMethod: __toString # name with some culture
sFormCreateNodeName: NpPageForm #form to add node
sFormEditNodeName: NpPageForm #form to edit node
sExtensionCultureMenu: false #name partial to extension cuture menu
sExtensionMainMenu: false #name partial to extension main menu
sExtensionNodeMenu: false #name partial to extension node menu
add __toString function to your model:
class NpPage extends BaseNpPageNestedSet { public function __toString($sCulture = 'en_EN') { return (string)($this->getPageTitle($sCulture)); } }
add i18n to your form
class NpPageForm extends BaseNpPageForm { public function configure() { unset( $this['tree_left'],$this['tree_right'] ); $this->embedI18n(sfConfig::get('app_caPropelTreePlugin_culture')); $this->widgetSchema->setLabel('en_EN', 'English'); $this->widgetSchema->setLabel('pl_PL', 'Polish'); $this->widgetSchema->setLabel('de_DE', 'Deutsch '); } }
clear cache
$ symfony cc
insert tree width caPropelTreePlugin in you action. Add componets in your template:
<?php include_component('caPropelTree', 'RenderTree'); ?>
Download and install JQuery:
Put jquery.js to /web/js
Add to view.yml
default:
http_metas:
content-type: text/html
javascripts: [ jquery.js]
has_layout: on
layout: layout
Or download plugins with JQuery
We look forward to menu page on tree






You can read a good introduction to nested sets