Adding an image field
Permalink Browser Info Environment
Hi Jordan
Just created a very long block so did not want to re create and just wanted to add an extra image field. All field numbers currently go up to field_22 so did the following
1. In db.xml added <field name="field_23_image_fID" type="I"></field>
2. In edit.php added <?php echo $al->image('field_23_image_fID', 'field_23_image_fID', 'Choose Image', $field_23_image); ?>
3. In controller.php added to public function view() { the following $this->set('field_23_image', (empty($this->field_23_image_fID) ? null : $this->get_image_object($this->field_23_image_fID, 100, 50, true)));
and
to public function edit() { $this->set('field_23_image', (empty($this->field_23_image_fID) ? null : File::getByID($this->field_23_image_fID)));
and to public function save($args) { $args['field_23_image_fID'] = empty($args['field_23_image_fID']) ? 0 : $args['field_23_image_fID'];
4. in view.php added the following <img src="<?php echo $field_2_image->src; ?>" onmouseover="this.src='<?php echo $field_23_image->src; ?>'" onmouseout="this.src='<?php echo $field_2_image->src; ?>'"
Now if i go into edit I see the extra image selection field and select image and then save. When I come to view I don't get any result for the added image filed as below
<img src="/files/cache/1ddce7d51fcf3659f12f1f9a9a52ff62_f49.png" onmouseover="this.src=''" onmouseout="this.src='/files/cache/1ddce7d51fcf3659f12f1f9a9a52ff62_f49.png'" width="99" height="46" alt="test colour">
Have I missed adding any other data ?
Just created a very long block so did not want to re create and just wanted to add an extra image field. All field numbers currently go up to field_22 so did the following
1. In db.xml added <field name="field_23_image_fID" type="I"></field>
2. In edit.php added <?php echo $al->image('field_23_image_fID', 'field_23_image_fID', 'Choose Image', $field_23_image); ?>
3. In controller.php added to public function view() { the following $this->set('field_23_image', (empty($this->field_23_image_fID) ? null : $this->get_image_object($this->field_23_image_fID, 100, 50, true)));
and
to public function edit() { $this->set('field_23_image', (empty($this->field_23_image_fID) ? null : File::getByID($this->field_23_image_fID)));
and to public function save($args) { $args['field_23_image_fID'] = empty($args['field_23_image_fID']) ? 0 : $args['field_23_image_fID'];
4. in view.php added the following <img src="<?php echo $field_2_image->src; ?>" onmouseover="this.src='<?php echo $field_23_image->src; ?>'" onmouseout="this.src='<?php echo $field_2_image->src; ?>'"
Now if i go into edit I see the extra image selection field and select image and then save. When I come to view I don't get any result for the added image filed as below
<img src="/files/cache/1ddce7d51fcf3659f12f1f9a9a52ff62_f49.png" onmouseover="this.src=''" onmouseout="this.src='/files/cache/1ddce7d51fcf3659f12f1f9a9a52ff62_f49.png'" width="99" height="46" alt="test colour">
Have I missed adding any other data ?
Type: | Discussion |
---|---|
Status: | New |
-Jordan
> On Oct 13, 2014, at 6:09 AM, concrete5 Community <discussions@concretecms.com> wrote: