7912 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » pb with dataobjectmanager testimonial example
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | ||
| Author | Topic: | 2838 Views |
-
Re: pb with dataobjectmanager testimonial example

26 June 2010 at 2:08am Last edited: 26 June 2010 2:16am
merci encore
je vais encore te demander une petite choses qui me coince mais qui doit juste être une question d'écriture (probleme 3)
N'hesite pas à ma dire si tu n'as pas le temps
--------- Problème 2
donc l'objet est "permanent" et je peux y accéder sans avoir à remplir à nouveaux les champs dans une autre pages avec un autre template ?par exemple AllProductPage.php et AllProductPage.ss
---------------------------- Problème 3
Je sais que tu m'as donné une autre technique pour les flashvars mais cela m'oblige à changer pas mal de chose .
J'ai donc essayé d'adapter ce que j'avais avant mais ce que je ne comprends pas c'est comment on peut affecter la valeur 'Imagename' à la variable $Imagename .
J'ai fait des essais donc voici le résultat sf que je ne comprends pas pour quoi cela ne marche dans certains cas
----------------- WOKING (en dur) ---------------------
public function flashvarFunction() {
$Imagename = "toto" ;
$flashVar="'myFlashVar=$Imagename'" ;
return $flashVar;}
----------------- NOT WOKING ---------------------
public function flashvarFunction() {
$Imagename = $this->Imagename
$flashVar="'myFlashVar=$Imagename'" ;
return $flashVar;}
----------------- NOT WOKING ---------------------
public function flashvarFunction() {
$vars = array (
'Imagename' => $this->Imagename
);$Imagename = {$vars['Imagename']};
$flashVar="'myFlashVar=$Imagename'" ;
return $flashVar;}
Merci
-
Re: pb with dataobjectmanager testimonial example

26 June 2010 at 4:38am
1) Oui, c'est ça.
2) C'est quoi $this->Imagename? Oui est-ce défini?
-
Re: pb with dataobjectmanager testimonial example

26 June 2010 at 4:53am
Comme toujours c'est parfait
cela vient des attributs d'un objet product je cherche donc un moyen d'affecter les valeurs des attributs à des flashvars sans passer par l'url .
Cela fonctionne en dur mais de manière dynamique
<?
class ProductPage extends Page
{
static $has_many = array (
'Products' => 'Product'
);public function getCMSFields()
{
$f = parent::getCMSFields();
$f->addFieldToTab("Root.Content.Products", new DataObjectManager(
$this,
'Products',
'Product',
array('Productname'=>'Productname','Imagename'=>'Imagename','Presentation' => 'Presentation','Contenance' => 'Contenance','Actifs' => 'Actifs','Price' => 'Price'),
'getCMSFields_forPopup'
));
return $f;
}}
class ProductPage_Controller extends Page_Controller
{public function index() {
return Director::redirect($this->Products()->First()->Link());
}static $allowed_actions = array (
'show'
);
public function show() {
return array (
'Product' => DataObject::get_by_id("Product",$this->urlParams['ID']));
}}
merci
-
Re: pb with dataobjectmanager testimonial example

26 June 2010 at 7:32pm
Bonjour Oncle Fromage
Mon message precedent n'était peut etre pas assez clair ?
Dis le moi
Merci
Thomas
-
Re: pb with dataobjectmanager testimonial example

27 June 2010 at 5:14am
Tu as bien un champ "Imagename" sur l'objet "Product?"
class Product extends DataObject
{
static $db = array (
'Imagename' => 'Varchar'
);public function FlashVar() {
return "someVar=$this->Imagename";
}
} -
Re: pb with dataobjectmanager testimonial example

27 June 2010 at 5:22am Last edited: 29 June 2010 2:32am
Thank you
For the saturday answer !
I'm know in front of my computer and I'm about to try you code but to be sure :
my Product.php file goes like this an I guess I have to had the code you sent me there (in bold) :
<?
class Product extends DataObject
{
static $db = array (
'Productname' => 'Text',
'Imagename' => 'Text',
'Presentation' => 'Text',
'Contenance' => 'Text',
'Actifs' => 'Text',
'Price' => 'Text'
);static $has_one = array (
'ProductPage' => 'ProductPage'
);public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Productname'),
new TextField('Imagename'),
new TextField('Presentation'),
new TextField('Contenance'),
new TextField('Actifs'),
new TextField('Price')
//new TextareaField('Quote')
);
}public function Link() {
return $this->ProductPage()->Link("show/$this->ID");
}public function FlashVar() {
return "someVar=$this->Imagename";
}
}And my other page ProductPage.php goes like this
<?
class ProductPage extends SiteTree
{
static $has_many = array (
'Products' => 'Product'
);public function getCMSFields()
{
$f = parent::getCMSFields();
$f->addFieldToTab("Root.Content.Products", new DataObjectManager(
$this,
'Products',
'Product',
array('Productname'=>'Productname','Imagename'=>'Imagename','Presentation' => 'Presentation','Contenance' => 'Contenance','Actifs' => 'Actifs','Price' => 'Price'),
'getCMSFields_forPopup'
));
return $f;
}}
class ProductPage_Controller extends Page_Controller
{public function index() {
return Director::redirect($this->Products()->First()->Link());
}static $allowed_actions = array (
'show'
);
public function show() {
return array (
'Product' => DataObject::get_by_id("Product",$this->urlParams['ID']));
}}
By the way I posted this earlier :
http://silverstripe.org/general-questions/show/287220#post287220
Je suppose que c'est une peu la même réponse ou faut t'il que j'utilise dataObjectManager pour y arriver ?
Merci encore et encore
Thomas
-
Re: pb with dataobjectmanager testimonial example

30 June 2010 at 3:39am Last edited: 30 June 2010 3:41am
Bonjour cher oncle cheese
J'ai une sorte de nouveau problème sur lequel je l''espere tu pourra m'aider:
Pour l'instant les scripts sur lesquels tu m'as (énormément) aidés font la chose suivante:
Je crées une page produits dans laquelle je peux ajoutés autant de produits que je veux via la popup de dataobjectmanager,
et cette page comporte un menu avec le Productname de tous les productsProuctqPage :
|_ product 1
|_ attribut 1
|_ attribut 2
|_ attribut 3
|_ product 2
|_ attribut 1
|_ attribut 2
|_ attribut 3Or dans les attributs de mes product j'ai besoin d'un champs HTML dans lequel jeux ajoutés des style comme dans Tyne MCe or
Il faut donc j'ai l'impression que je crée un une page par product c'est a dire comme ceci et je sais que nous en avion parlé.
ProuctqPage1 :
|_ product 1
|_ attribut 1
|_ attribut 2
|_ attribut 3
ProuctqPage2 :
|_ product 2
|_ attribut 1
|_ attribut 2
|_ attribut 3Mais dans ce cas de figure j'ai aussi besoins que chaque product page est un menu composé des ProductName du même niveaux (comme des siblings).
Je n'arrive pas a savoir si cela ce fait avec la template Product_show.ss ou avec les scripts.Voila mon code pour Product.php
<?
class Product extends DataObject
{
static $db = array (
'Productname' => 'Text',
'Imagename' => 'Text',
'Presentation' => 'Text',
'Contenance' => 'Text',
'Actifs' => 'Text',
'Price' => 'Text'
);static $has_one = array (
'ProductPage' => 'ProductPage'
);public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Productname'),
new TextField('Imagename'),
new TextField('Presentation'),
new TextField('Contenance'),
new TextField('Actifs'),
new TextField('Price')
//new TextareaField('Quote'));
}public function Link() {
return $this->ProductPage()->Link("show/$this->ID");
}public function FlashVar() {
return "someVar=$this->Imagename";
}
}et voila le code pour ProductPage.php
<?
class ProductPage extends SiteTree
{
static $has_many = array (
'Products' => 'Product'
);public function getCMSFields()
{
$f = parent::getCMSFields();
$f->addFieldToTab("Root.Content.Products", new DataObjectManager(
$this,
'Products',
'Product',
array('Productname'=>'Productname','Imagename'=>'Imagename','Presentation' => 'Presentation','Contenance' => 'Contenance','Actifs' => 'Actifs','Price' => 'Price'),
'getCMSFields_forPopup'));
return $f;
}}
class ProductPage_Controller extends Page_Controller
{public function index() {
return Director::redirect($this->Products()->First()->Link());
}static $allowed_actions = array (
'show'
);
public function show() {
return array (
'Product' => DataObject::get_by_id("Product",$this->urlParams['ID']));
}}
Merci de ton aide si tua s un peu de temps
T
| 2838 Views | ||
| Go to Top |

