I will try to explain as best as possible. The problem is as follows
It is assumed that you should create a relationship many to many the problem is that it seems not to keep the relationship between DataObject and the page just kept in the DataObject.
This should not be longer than another site should not be alone show me items that classname with some ID
but apparently this is not so the code is as follows.
File Iconografia.php
Class Iconografia extends DataObject {
public static $db = array();
public static $has_one = array(
'Imagen' => 'Image'
);
static $belongs_many_many = array(
'Objs' => __CLASS__
);
/* For DataObjectManage */
/*public function getImagen(){
$image = $this->Imagen();
return $image->CroppedImage(50,50);
}
public function getName() {
$image = $this->Imagen();
return $image->Name;
}*/
public function getCMSFields_forPopup() {
$fields = new FieldSet();
$ImgField = new ImageField('Imagen','Icono');
$ImgField->setFolderName('Iconografia');
$fields->push($ImgField);
return $fields;
}
}
File SolucionesHolder.php
class SolucionesHolder extends Page {
static $db = array ();
static $has_one = array (
'ImgHeader' => 'Image'
);
static $many_many = array(
'MyIconografia' => 'Iconografia'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$MyIco = new ManyManyComplexTableField(
$this,
'MyIconografia',
'Iconografia',
Array('Imagen'=>'Icono','Name'=>'Nombre'),
'getCMSFields_forPopup'
);
$ImgField = new ImageField ( 'ImgHeader', 'Imagen de cabezera' );
$ImgField->setFolderName ( 'Categorias' );
$fields->addFieldToTab("Root.Content.Iconografia",$MyIco);
$fields->addFieldToTab("Root.Content.Main", $ImgField );
return $fields;
}
}
My SiteTree is Like this
|-Site
|-Solutions => PageClass
\
*|-- DataCenter => SolucionesHolder => many_many (Iconografia)
*|-- Voice => SolucionesHolder => many_many (Iconografia)
*\
**|-- Product 1 => SolucionPage => => many_many (Iconografia)
**|-- Product 2 => SolucionPage => => many_many (Iconografia)
**|-- Product 3 => SolucionPage => => many_many (Iconografia)
**|-- Product 4 => SolucionPage => => many_many (Iconografia)
....
I hope to be clear in advance thank you very much