public function edit($id) { $ads = Model\Portal\Ads::where('code', $id)->first(); if ($ads) { $this->form_validation->set_rules('show', 'Tampil', 'required'); if ($this->form_validation->run() == FALSE) { $this->template->build('edit', compact('ads')); } else { if (isset($_FILES['image'])) { $manager = new Intervention\Image\ImageManager(); $image = $manager->make($_FILES['image']['tmp_name']); $image->resize($ads->width, $ads->height); $image->save(PATH_ADS . '/ads_' . $ads->code . '.jpg'); $ads->image = 'ads_' . $ads->code . '.jpg'; } $ads->show = $this->input->post('show'); $ads->link = $this->input->post('link'); $ads->save(); set_message_success('Iklan berhasil diperbarui.'); redirect('ads', 'refresh'); } } else { set_message_error('Iklan tidak ada'); redirect('ads', 'refresh'); } }
function ads_placement($code) { $ads = Model\Portal\Ads::where('code', $code)->first(); if ($ads && $ads->show) { $html = '<a href="' . $ads->link . '" target="' . $ads->target . '">'; $html .= '<img src="' . $ads->image_url . '" width="' . $ads->width . '" height="' . $ads->height . '" title="' . $ads->name . '">'; $html .= '</a>'; } else { $html = ''; } return $html; }