Hi there, just more info of the bug reported a post above. I have tried on another OSX system, the popup worked as expected in Safari and in Firefox the popup appeared but only contained the statement "I can't handle sub-URLs of a CMSMain object."
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.
DataObjectManager Module /
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba
Preview: DataObjectManager module
@ howardgrigg, I had this same issue and can't for the life of me remember what was causing it. I ended up fixing it though, it was something I was doing wrong in the code. I'll do my best to remember what it was. Good luck!
Cause of the issue mentioned in my post of 1 April 2009 at 10:03am:
Using the line from trunk, the pop-up's save button works correctly; with the line from nestedurls, it does not.
Ben
.
My post of 1 April 2009 at 10:03am:
I'm running revision 103 of DataObjectManager against revision 73881 of trunk. When I click the "save" button on the "add" pop-up window, the object I'm trying to add never gets saved to the database. Instead, I get sent to some kind of page that has an add link and a search box, etc.
The "add" pop-up window's form tag is as follows:
<form id="DataObjectManager_Popup_AddForm" action="admin/EditForm/field/Articles?ctf[Articles][per_page]=10&ctf[Articles][showall]=0&ctf[Articles][sort]=Created&ctf[Articles][sort_dir]=DESC&ctf[Articles][search]=&ctf[Articles][filter]=" method="post" enctype="application/x-www-form-urlencoded">
Is that the correct action? It looks funny to me.
Hi Uncle Cheese
Fantastic work! The DataObjectManager is just what I needed.
Do you have an example of how to setup ManyManyDataObjectManager? I want to use it to enable users to select images to go in the right column on the page and have have the ability to have different images on everypage. I might have missed something but when I use DataObjectManager it puts the same objects on every page.
Thanks
Aaron
Hi, Aaron.
Great use of the DataObjectManager. I'd recommend using a ManyManyFileDataObjectManager if I were you, since it will display the images in a grid for you, as well as streamline the upload process.
If you have the many_many relation set up correctly, it should be the same as a ManyManyComplexTableField, only with one more argument.
new ManyManyFileDataObjectManager(
$this,
'MyImages'
'MyImage',
'Image' // The fieldname on the $has_one array of your MyImage dataobject.
array( // headers...
'getCMSFields_forPopup'
);
You can read more in the documentation in the SS wiki.
Uncle Cheese. Thank you for all your hard work and help.
I would like to use the Testimonials page type to manage testimonials. I have set up the page so that I can add testimonials and I can see the database table where they are stored. What I don't know how to do is randomly grab a Testimonial and display it on any give page on the site. My guess is that in the Page_Controller I would have a function that could select a random Testimonial from the database and display the Testimonial Content and Author on my page. I don't need a page that shows all of the Testimonials.
Page_Controller
function RandomTestimonial()
{
return DataObject::get_one("Testimonial", null, true, "RAND()");
}
FYI: Please do not rely on the example code included with dataobject_manager. I'll be removing it soon. You can recreate it in mysite/code if you want.
I have a simple question regarding the display of content in a template. I'm using FileDataObjectManager and my files are as follows:
Partner.php
-----------
<?php
class Partner extends DataObject
{
static $db = array (
'Name' => 'Text',
'URL' => 'Text'
);
static $has_one = array (
'Logo' => 'File',
'PartnerPage' => 'PartnerPage'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Name'),
new TextField('URL'),
new FileIFrameField('Logo')
);
}
}
?>
-----------
PartnerPage.php
-----------
<?php
class PartnerPage extends Page
{
static $has_many = array (
'Partners' => 'Partner'
);
public function getCMSFields()
{
$f = parent::getCMSFields();
$manager = new FileDataObjectManager(
$this, // Controller
'Partners', // Source name
'Partner', // Source class
'Logo', // File name on DataObject
array(
'Name' => 'Name',
'URL' => 'URL'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
// If undefined, all types are allowed. Pass with or without a leading "."
$manager->setAllowedFileTypes(array('jpg','gif'));
// Label for the upload button in the popup
$manager->setBrowseButtonText("Upload (JPG or GIF only)");
// In grid view, what field will appear underneath the icon. If left out, it defaults to the file title.
$manager->setGridLabelField('Name');
// Plural form of the objects being managed. Used on the "Add" button.
// If left out, this defaults to [MyObjectName]s
$manager->setPluralTitle('Partners');
$f->addFieldToTab("Root.Content.Partners", $manager);
$f->removeFieldFromTab('Root.Content', 'HeaderImage');
return $f;
}
}
class PartnerPage_Controller extends Page_Controller
{
}
?>
-----------
PartnerLogo.ss
-----------
<% if Partners %>
<div id="partners"><div class="container">
<div id="partner-logos">
<ul>
<% control Partners %>
<li class="partner-logo"><a href="#" title="$Name" style="background-image: url('$Logo.URL')"><span>$Name</span></a></li>
<% end_control %>
</ul>
</div>
</div></div><!-- end #partners -->
<% end_if %>
-----------
Can anyone tell me why the above template file PartnerLogos.ss does not return any Partners, when in the CMS I clearly have added records using dataobjectmanager and I can see them under the Partners tab in the CMS?