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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

question add image template - noob


20 Posts   2162 Views


15 July 2011 at 8:53am Community Member, 15 Posts

but example

click on the image and take me to another site...
with the URL to be added to the image when the photo was added to the server through the tab


15 July 2011 at 9:03am Community Member, 528 Posts

Ah the method I gave you was a way to post an entire folder of images to a page.

If you want an image with a link you'll need to do it totally differently. You'll need to create a DataObject with has Link and an Image. Take a look here


16 July 2011 at 2:18am Community Member, 15 Posts

this is my code for upload images

class Logo extends DataObject {

static $db = array(
    'TextoAlternativo' => 'Varchar',

static $has_one = array(
'LogoImage' => 'Image'

function getCMSFields_forPopup() {
return new FieldSet(
   new TextField('TextoAlternativo',"Texto Alternativo (para google)"),
   new TextField('Link',"Link externo"),
   new ImageField('LogoImage', 'Agregar imagen del logo',null,null,null,'assets/Logos')


and with the other function calls this images to show in template


16 July 2011 at 2:31am Community Member, 528 Posts

Okay then you'll to create a $has_many relation on whatever page type will hold the Logo object and add an ImageDataObjectManager to the CMS fields


16 July 2011 at 4:18am (Last edited: 16 July 2011 6:17am), Community Member, 15 Posts

i have this in


class Inicio extends Page{

   static $icon = "localhost/images/treeicons/homepage";
   static $has_many = array(

   function getCMSFields() {      
      $fields = parent::getCMSFields();
      $Logox = new FileDataObjectManager(
         'TextoAlternativo' =>'Texto Alternativo (para google)',
         'Link' =>'Link Externo'         
      $Logox->setAddTitle( 'A Logo' );
      $fields->addFieldToTab( 'Root.Content.Logos', $Logox );
      return $fields;

class Inicio_Controller extends Page_Controller {


when I upload the images through the tab in the database is created a field called "logo" which contains these images
how do I call all the field with the images?
because in this field not have a folder that store these images


19 July 2011 at 1:13am Community Member, 528 Posts

Do you mean call it in the template?

<% control Logos %>
<a href="$Link">$LogoImage</a>
<% end_control %>


19 July 2011 at 1:33am Community Member, 15 Posts

thx zenmonkey works perfect
and sorry for the problems :c
you are the best lml

+999 for you c:


19 July 2011 at 1:47am Community Member, 528 Posts

No Problem. It takes a little while to wrap your head around it. When I started with SS I didn't even know any PHP.

Just need to remember that when you call the relation in the template you need to use plural name and that teh Name of the function to call the image will be whatever you called the $Image relation on the dataobject (in this case LogoImage). You can also change the FileDataObjectManager to an ImageDataObjectManger. It just gives you some more viewing options in the CMS