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
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
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
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
this is my code for upload images
<?php
class Logo extends DataObject {
static $db = array(
'TextoAlternativo' => 'Varchar',
'Link'=>'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
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
i have this in
<?php
class Inicio extends Page{
static $icon = "localhost/images/treeicons/homepage";
static $has_many = array(
'Logos'=>'Logo'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$Logox = new FileDataObjectManager(
$this,
'Logos',
'Logo',
'LogoImage',
array(
'TextoAlternativo' =>'Texto Alternativo (para google)',
'Link' =>'Link Externo'
),
'getCMSFields_forPopup'
);
$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
Do you mean call it in the template?
<% control Logos %>
<a href="$Link">$LogoImage</a>
<% end_control %>
thx zenmonkey works perfect
and sorry for the problems :c
you are the best lml
+999 for you c:
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
Cheers