21278 Posts in 5728 Topics by 2599 members
| Go to End | Next > | |
| Author | Topic: | 1537 Views |
-
Re: question add image template - noob

15 July 2011 at 8:53am
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 -
Re: question add image template - noob

15 July 2011 at 9:03am
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
-
Re: question add image template - noob

16 July 2011 at 2:18am
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
-
Re: question add image template - noob

16 July 2011 at 2:31am
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
-
Re: question add image template - noob

16 July 2011 at 4:18am Last edited: 16 July 2011 6:17am
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 -
Re: question add image template - noob

19 July 2011 at 1:13am
Do you mean call it in the template?
<% control Logos %>
<a href="$Link">$LogoImage</a>
<% end_control %> -
Re: question add image template - noob

19 July 2011 at 1:33am
thx zenmonkey works perfect
and sorry for the problems :c
you are the best lml+999 for you c:
-
Re: question add image template - noob

19 July 2011 at 1:47am
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
| 1537 Views | ||
| Go to Top | Next > |


