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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Assigning Links to rotating pics


Reply

3 Posts   627 Views

Avatar
jparks

20 August 2010 at 6:28pm Community Member, 7 Posts

OK, well this is part two ... The pics are rotating and using the DOM people can log in and add their banners. I have added another field to the DOM that allows people to add an URL

-------------------
<?php
class Banner extends DataObject
{
   static $db = array (
      'Name' => 'Text',
      'Description' => 'Text',
      'URL' => 'Text'
   );
   
   static $has_one = array (
      'Attachment' => 'Image',
      'BannerPage' => 'BannerPage'
   );
   
   public function getCMSFields_forPopup()
   {
      return new FieldSet(
         new TextField('Name'),
         new TextField('URL'),
         new TextareaField('Description'),
         new FileIFrameField('Attachment')
      );
   }
}
?>

I am using this function to call the pics

public function Banners() {
$folder = Folder::findOrMake("Uploads");
return DataObject::get("Image", "ParentID = $folder->ID");
}

Thank you Uncle

What is the best way to attribute the URL value to the image?

Thank you for your help!

Avatar
UncleCheese

21 August 2010 at 1:52am 4085 Posts

That looks right to me. What is giving you trouble?

Avatar
jparks

21 August 2010 at 3:10am Community Member, 7 Posts

What is the best way to attribute the URL value to the image?

When a user goes into the DOM and adds a Banner they can input a url ... I want that url to be attached to the pic so when the Banner is displayed on the homepage you can click on the pic and be taken to that advertiser's website.

Thank you for your help!