caPropelTreePlugin - 0.9.8

Easy PropelTree

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

caPropelTreePlugin v 0.9.8

Licence

MIT - free for comercal and non-comercial use

Why do you need caPropelTreePlugin ?

  • if you need admin menu.
  • if you need an advanced tree
  • if you write your's CMS, store or portal
  • in other cases where you organize items (for example, continents / countries / regions)

What can a caPropelTreePlugin ?

  • add the node to the parent
  • delete node
  • edit node
  • move the node to another location
  • extensibility and adaptation to your function
  • implemented i18n and i10n

Requirements

  • symfony 1.2.x
  • Propel 1.3.x
  • JQuery

Let's get started

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


Some use

Add page

caPropelTreePlugin add node part 1

  1. click to show add
  2. cilck to icon add in your node caPropelNestedSetManager add node part 2
  3. enter text and save
  4. node "contatct us" appears on the screen

Edit node

caPropelTreePlugin add node part 1

  1. click to show edit
  2. cilck to icon edit in your node
  3. enter text and save
  4. node succes rename

Move node

caPropelTreePlugin add node part 1

  1. click to show move
  2. cilck to icon push in your node (node add to cliboard)
  3. click to icon put before node
  4. node succes put

Delete node

caPropelTreePlugin add node part 1

  1. click to show delete
  2. cilck to icon delete in your node
  3. node succes delete

Change cluture all tree

caPropelTreePlugin add node part 1

  1. click to "pl_PL" to change culture
  2. or click to "en_EN"

More info

You can read a good introduction to nested sets