Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Managing many_many relationships with bummzack/translatable-dataobject


Go to End


1195 Views

Avatar
dianaAvila

Community Member, 12 Posts

29 October 2015 at 3:32am

Edited: 29/10/2015 3:34am

Hi,
I'm working on a bi-lingual (EN and FR) site and have the following:

class Tip extends DataObject{
    public static $db = array (
        "Title"=>"Varchar(255)",
        "Content"=>"HTMLText"
    );
    public static $has_one = array(
        "Image"=>"Image"
    );
    static $many_many = array(
        'RelatedProducts'=>'Product',
    );
    private static $translatable_fields = array(
        'Title',
        'Content',
        'RelatedProducts'

    );

For products:

Product is already translated by using translatable, so I have 2 pages for the same product, one for EN and one for FR
class Product extends Page {

	private static $description = 'Use this PageType to create Products in the site.';
	// private static $icon = 'mysite/images/product';
	
	private static $db = array(
		'Headline' => 'HTMLText',

	);


	public static $has_one = array(
		'PrimaryImage' => 'Image',
       
	);
	
	static $has_many = array(
        'ProductImages' => 'ProductImage',
        'ProductDirections' => 'ProductDirection',
        'AvailableSizes' => 'AvailableSize'
        
    );
    public static $belongs_many_many = array (
      'ProductFeatures' => 'ProductFeature',
      'Recipes'=>'Recipe',
      'Tips'=>'Tip',
		  'CollectionProgramOptions' => 'CollectionProgramOption',
    );

Is there a way to create an additional column in the TIp-Product table to have Product_id_fr?

And I will also appreciate help on how to add these fields to the my form. (Content and Title are working fine).

Thanks!